当我执行这个剧本时,我遇到了一些问题:
- 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
Run Code Online (Sandbox Code Playgroud)
我收到的错误是:
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."}
Run Code Online (Sandbox Code Playgroud)
这是我的小组:
/etc/ansible# cat hosts | grep ios
[ios]
[ios1]
Run Code Online (Sandbox Code Playgroud)
这是我的common.j2文件:
/etc/ansible# ls ios1/
common.j2
/etc/ansible# ls ios/
common.j2
Run Code Online (Sandbox Code Playgroud)
有人可以详细说明为什么group_names退货[u'group_names]吗?