拷贝单个文件到目标服务器上
[root@Jenkins copymodule]# cat copy.yml
---
- hosts: all
remote_user: root
gather_facts: false
tasks:
- name: "复制主机上的文件到目标服务器上"
copy:
src: "/root/ansible/luyan/copymodule/copytest1.txt"
dest: "/opt/copymodule"
owner: root
group: root
mode: 755
拷贝多个文件到目标服务器上
[root@Jenkins copymodule]# cat copyduogewenjian.yml
---
- hosts: all
remote_user: root
gather_facts: false
tasks:
- name: "复制主机上的文件到目标服务器上"
copy:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
owner: root
group: root
mode: 755
with_items:
- {src: "/root/ansible/luyan/copymodule/copytest1.txt", dest: "/opt/copymodule" }
- {src: "/root/ansible/luyan/copymodule/copytest2.txt", dest: "/opt/copymodule" }
- {src: "/root/ansible/luyan/copymodule/copytest3.txt", dest: "/opt/copymodule" }