1
我運行的一些問題,當我執行這個劇本:GROUP_NAMES變量ansible
- hosts: all
connection: local
tasks:
- template: src=/etc/ansible/{{group_names}}/common.j2 dest=/etc/ansible/configs/{{inventory_hostname}}.txt
name: create common config snippets
,我得到的錯誤是:
fatal: [R1]: FAILED! => {"changed": false, "failed": true, "msg": "Unable to find '/etc/ansible/[u'ios']/common.j2' in expected paths."}
fatal: [R2]: FAILED! => {"changed": false, "failed": true, "msg": "Unable to find '/etc/ansible/[u'ios1']/common.j2' in expected paths."}
,這裏是我的羣:
/etc/ansible# cat hosts | grep ios
[ios]
[ios1]
這裏是我的common.j2
文件:
/etc/ansible# ls ios1/
common.j2
/etc/ansible# ls ios/
common.j2
可能有人闡述爲什麼group_names
返回[u'group_names]
好嗎?
'group_names' [是一個列表(https://docs.ansible.com/ansible/latest/playbooks_variables.html#magic-variables-and-how-to-access-information-about-other-hosts)。它沒有意義的,它代替在這樣的一個文件名。 – larsks
我是新來ansible,我不知道,並感謝這麼多提示答案。 – NANIS