在庫ファイルのグループvarとして定義した変数にアクセスできないのはなぜですか?playbook.yml
?ここで 可変変数が定義されていません
playbook.yml
の内容です:
---
- name: test ansible local provisioning
hosts: all
vars:
playbook_var: "playbook_var"
tasks:
- name: Test ansible is working
debug: msg="Ansible seems to be working, this variable is from plabook {{ playbook_var }} and this variable is from hosts file {{ hosts_file_var }}"
そしてここhosts
です:
TASK [Test ansible is working] *************************************************
fatal: [ansible_host]: FAILED! => {"failed": true, "msg": "the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was: 'hosts_file_var' is undefined
The error appears to have been in '/vagrant/provisioning/ansible_host/playbook.yml': line 7, column 7, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
tasks:
- name: Test ansible is working
^here
"}
私は「ドン、いくつかの側面があります:
[all:vars]
hosts_file_var="hosts_file_var"
Ansibleは、次のエラーがスローされますどのようにAncersプロセス変数について理解していますか?
こちらはansible.cfg
です。
[defaults]
inventory = hosts
remote_user = vagrant
localhostエントリのため
ansible_connection=local
ホスト/グループのVARを宣言することも必要ですされ注意を仕事得るために必要なすべての構成です。結果は次のようになります: '' msg ":" Ansibleは動作しているようですが、この変数はplabookのplaybook_varからのもので、この変数はhostsファイルhosts_file_var "からです。あなたの主なエラーメッセージは '' hosts_file_var 'は未定義です.''なので、投稿したインベントリファイルを使用していないようです。 – techraf
あなたのエラーメッセージは、 'anipal-playbook'呼び出しで' -i'引数を省略したときのエラーメッセージです。 – techraf
それに加えて、あなたが質問に投稿した 'hosts'が完成した場合、Anipalはエラーを投げるべきで、もしエラーが出なければ、あなたのAnabilitiesは別のものを使います。 – techraf