ansible-playbook copy模块(拷贝文件到目标服务器)

拷贝单个文件到目标服务器上

[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

ansible-playbook copy模块(拷贝文件到目标服务器)

 

 

 

 

拷贝多个文件到目标服务器上

[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" }

ansible-playbook copy模块(拷贝文件到目标服务器)

 

上一篇:RHCE8—题目详解


下一篇:用playbook部署lamp