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

Using Ansible Playbook to Copy Multiple Files to Target Server

[root@ansible ~]# ansible-playbook copy.yaml

Check the copied files on the target server

Using Ansible Playbook to Copy Multiple Files to Target Server

———————-end———————

Recommended Reading

1.Practical – k8s Monitoring MySQL

2.Practical – Prometheus Monitoring Domain Certificate Expiration

3.Practical – Prometheus Monitoring MySQL

4.Practical – Prometheus Monitoring Redis

5.Nginx Implementing WAF Dynamic IP Blocking via Lua+Redis

6.Comprehensive Interpretation and Practical Exercises of Jenkins

7.eCommerce Project Kubernetes Deployment and Performance Optimization Practice

8.Essential Shell Scripts for Work (2)

9.Essential Shell Scripts for Work

10.Essential Shell Scripts for Work (3)

If this article has helped you, please like & view & share, this is very important for me to continue sharing & creating quality articles. Thank you 🙏🏻, if you need learning materials please add WX:DaDangJia-01

Please like → light up “view” → share

Leave a Comment