Ansible Copy Multiple Files
Ansible copy multiple files
To copy the files from ansible master control machine to remote target servers, we use ansible copy module. In the following examples i will show you how to copy multiple files using ansible copy module.
- name: copying a file from ansible master to remote server copy: src: /project/devops/devops.conf dest: /etc/devops.conf
Here it will copy the file from ansible master to remote target servers. We know that in ansible copy module, we use two parameters one is src, another one is dest. SRC represents source file path or path of the file which we are going to copy. DEST represents the destination path on the remote server. In this example we are copying devops.conf file from ansible master machine to remote server(target machine) etc directory. With ansible copy we can copy multiple files.
Ansible copy multiple files at once
- name: copy rundeck files copy: src=/project/devops/{{ item }} dest=/etc/rundeck/ with_items: - rundeck.conf - rundeck.properties - rundeck.key
In this example we are copying multiple files from ansible master machine to remote server. But in this example we are copying all the files from devops directory to remote server rundeck directory.
Ansible copy multiple files to multiple destinations
- name: ansible copy multiple files copy: src={{ item.src }} dest={{ item.dest }} with_items: - { src: '/project/jboss.conf', dest: '/etc/jboss' } - { src: '/project/rundeck.conf', dest: '/etc/rundeck' } - { src: '/project/httpd.conf', dest: '/etc/httpd' }
Here you can see we are copying multiple files to multiple destinations by using with_items. In this example we are copying three(3) files from different locations to different locations in remote server. Jboss.conf is copying to jboss directory, rundeck.conf is copying to rundeck directory and httpd.conf is copying to httpd directory.
- ansible copy multiple files
- best devops training in hyderabad
- best devops training in dilsukhnagar
- copy ansible multiple files
- best ansible training in hyderabad
- multiple files ansible copy
- multiple files copy ansible