1. - hosts: gale
      remote_user: root
      gather_facts: no
      name: copy files
    
      tasks:
      - name: copy files
        copy:
          src: "{{ item.src }}"
          dest: "{{ item.dest }}"
        with_items:
        - { src: salamander, dest: /opt }
        - { src: salamander.pub, dest: /mnt }

     

  2. glob
    Ansible copy module_技术

     

     Ansible copy module_技术_02

     

     

    ---
    - hosts: gale
      remote_user: root
      gather_facts: no
      vars:
        filename: ~/salamander*
    
      tasks:
      - name: copy files with glob
        copy: src={{ item }} dest=/tmp
        with_fileglob:
        - "{{ filename }}"