Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ember.js/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ansible fileglob中的自定义变量名,而不是项_Ansible - Fatal编程技术网

Ansible 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}} 使用“正

下面是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}}

使用“正常”回路时,有:

  loop_control:
    loop_var: item_name

使用fileglob时是否可能出现类似情况?

是。这是可能的。使用循环或代替_fileglob。比如说

  loop: "{{ query('fileglob', '/playbooks/files/fooapp/*') }}"
  loop_control:
    loop_var: item_name