Ansible fileglob中的自定义变量名,而不是项
下面是fileglob的用法:Ansible fileglob中的自定义变量名,而不是项,ansible,Ansible,下面是fileglob的用法: - 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/*" 但是有没有一个选项可以使用自定义变量名而不是{{item}} 使用“正
- 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/*"
但是有没有一个选项可以使用自定义变量名而不是{{item}}
使用“正常”回路时,有:
loop_control:
loop_var: item_name
使用fileglob时是否可能出现类似情况?是。这是可能的。使用循环或代替_fileglob。比如说
loop: "{{ query('fileglob', '/playbooks/files/fooapp/*') }}"
loop_control:
loop_var: item_name