Copy multiple files with Ansible

前端 未结 11 1072
执念已碎
执念已碎 2021-01-29 22:29

How can I copy more than a single file into remote nodes by Ansible in a task?

I\'ve tried to duplicate the copy module line in my task to define files but it only copie

11条回答
  •  时光取名叫无心
    2021-01-29 22:42

    - name: find inq.Linux*
      find:  paths="/appl/scripts/inq" recurse=yes patterns="inq.Linux*"
      register: find_files
    
    
    - name: set fact
      set_fact:
        all_files:
          - "{{ find_files.files | map(attribute='path') | list }}"
      when: find_files > 0
    
    
    - name: copy files
      copy:
        src: "{{ item }}"
        dest: /destination/
      with_items: "{{ all_files }}"
      when: find_files > 0
    

提交回复
热议问题