Using Ansible Playbook to Copy Multiple Files to Target Server

Using Ansible Playbook to Copy Multiple Files to Target Server

Using with_items to Copy Multiple Files/Directories If you want to copy multiple files, you can use with_items to iterate over them. — – hosts: all remote_user: root gather_facts: false tasks: – name : copy file copy: src: /root/{{item}} dest: /usr/local/apps/ with_items: [’45.txt’, ‘run.sh’,’node_exporter.tar.gz’] [root@ansible ~]# ansible-playbook -C copy.yaml [root@ansible ~]# ansible-playbook copy.yaml Check the copied … Read more

Ansible Playbook: Copying Multiple Files

Ansible Playbook: Copying Multiple Files

1. Copying a Single File to the Target Server [root@Jenkins copymodule]# cat copy.yml—– hosts: allremote_user: rootgather_facts: falsetasks:– name: “Copy file from host to target server”copy:src: “/root/ansible/luyan/copymodule/copytest1.txt”dest: “/opt/copymodule”owner: rootgroup: rootmode: 755 2. Copying Multiple Files to the Target Server [root@Jenkins copymodule]# cat copyduogewenjian.yml—– hosts: allremote_user: rootgather_facts: falsetasks:– name: “Copy files from host to target server”copy:src: “{{ … Read more