"コマンド"または "シェル"モジュールで変数を使用することはできますか? 次のコードがあります。変数ファイルを使用していくつかの設定を提供したいと考えています:可能性: "コマンド"または "シェル"に変数を追加する方法
私の変数ファイルからHadoopのバージョンを読みたいと思います。他のモジュールでは、{{ansible_version}}を使うことができますが、コマンドやシェルでは動作しません。
- name: start ZooKeeper HA
command: hadoop-2.7.1/bin/hdfs zkfc -formatZK -nonInteractive
- name: start zkfc
shell: hadoop-2.7.1/sbin/hadoop-daemon.sh start zkfc
私はに変換したい
次:
- name: Iniciar zkfc
command: {{ hadoop_version }}/sbin/hadoop-daemon.sh start zkfc
私はこの構文で実行した場合、それは次のエラーがスローされますので:
- name: inicializar estado ZooKeeper HA
command: {{hadoop_version}}/bin/hdfs zkfc -formatZK -nonInteractive
^here
We could be wrong, but this one looks like it might be an issue with
missing quotes. Always quote template expression brackets when they
start a value. For instance:
with_items:
- {{ foo }}
Should be written as:
with_items:
- "{{ foo }}"
私が使用して試してみるのが、同じ問題:
- name: Iniciar zkfc
command: "{{ hadoop_version }}"/sbin/hadoop-daemon.sh start zkfc
正しい構文は何ですか?