On 03. mars 2017 10:33, niraj pandey wrote:
How can I copy a file from machine A to machine B and machine C on
different location. ie:
On machine A I have file abc and I want to copy it on the /tmp area of
machine B and /opt area of machine C.
I tried this so far:
*My inventory file:*
[webserver]
machine-B dst=/tmp
machine-C dst=/opt
*Playbook:*
- hosts: webserver
tasks:
- name: Transfer file from ServerA to ServerB
synchronize:
src: /home/niraj/ansible_testing
dest: "{{ hostvars[item]['dst'] }}"
with_items: "{{ groups['webserver'] }}"
#dest: /home/niraj
#mode: pull
delegate_to: machine-A
This should do it.
- hosts: webserver
tasks:
- name: Transfer file from ServerA to ServerB
synchronize:
src: /home/niraj/ansible_testing
dest: "{{ dst }}"
delegate_to: machine-A
--
Kai Stian Olstad
--
You received this message because you are subscribed to the Google Groups "Ansible
Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/1288649b-c503-3edf-912c-0a281950bebf%40olstad.com.
For more options, visit https://groups.google.com/d/optout.