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