How can I transfer files to hosts use ansible?
I installed ansible in my ansible-node, and in the /etc/ansible/hosts, there are so many hosts:
10.10.10.2
10.10.10.3
10.10.10.4
....
10.10.10.200
I checked the ping, all alive:
# ansible all -m ping -k
but I want to upload a directory to each host from my ansible-node. how to do with this?
Write the playbook:
---
- hosts: myHostGroupInHostsFile
become: True
gather_facts: False
tasks:
- name: Copy /etc/directory
copy:
src: /Path/on/ansible_node/directory/
dest: /etc/directory
owner: root
group: root
mode: '0644'
And start the playbook:
ansible-playbook myPlaybook.yml
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.