Loops Ansible-在路径中迭代项的问题
我是Ansible的新手,似乎无法使用“with_items”遍历路径中的项 下面是示例代码,用于遍历路径中的一些文件,并将配置应用于JUniter路由器Loops Ansible-在路径中迭代项的问题,loops,path,ansible,Loops,Path,Ansible,我是Ansible的新手,似乎无法使用“with_items”遍历路径中的项 下面是示例代码,用于遍历路径中的一些文件,并将配置应用于JUniter路由器 --- - name: Get Juniper Device Facts hosts: "junos_devices" gather_facts: false connection: local tasks: - name: Update prefix-lists junos_config: src:
---
- name: Get Juniper Device Facts
hosts: "junos_devices"
gather_facts: false
connection: local
tasks:
- name: Update prefix-lists
junos_config:
src: prefix-lists/{{item}}
with_items: "/home/python/prefix-lists/*"
我得到的错误是:
failed: [192.168.216.66] (item=/home/python/prefix-lists/*) => {"changed": false, "failed": true, "item": "/home/python/prefix-lists/*", "msg": "path specified in src not found"}
有人知道我为什么不能这样做吗?为什么
带有项目?使用
例如:
# copy each file over that matches the given pattern
- name: Copy each file over that matches the given pattern
copy:
src: "{{ item }}"
dest: "/etc/fooapp/"
owner: "root"
mode: 0600
with_fileglob:
- "/playbooks/files/fooapp/*"
为什么带有项目
?使用
例如:
# copy each file over that matches the given pattern
- name: Copy each file over that matches the given pattern
copy:
src: "{{ item }}"
dest: "/etc/fooapp/"
owner: "root"
mode: 0600
with_fileglob:
- "/playbooks/files/fooapp/*"
Hi Konstantin,使用with_fileglob而不是with_items工作,谢谢你的帮助。实际上它不工作,因为Ansible没有像我预期的那样在迭代文件中应用配置。Hi Konstantin,使用with_fileglob而不是with_items工作,谢谢你的帮助。实际上它不工作,因为Ansible没有像我预期的那样在迭代文件中应用配置。