Hello all!
I have an issue in my environment where I cannot use the synchronize module to transfer data between two remote nodes. So I need a different way to do this.
ServerA: Ansible Server (Tower Instance)
ServerA1: Ansible Server (Tower Instance)
ServerA2: Ansible Server (Tower Instance)
ServerB: Data Server
ServerC: User Server
I want to run a playbook on ServerA and have it copy a/many file(s) from ServerB to ServerC. I cannot use synchronize do to environmental issues. So how can I get this done ether using copy or fetch modules. Or something else like SCP from the shell or command module.
I cannot find a good example of doing this other than the synchronize module. I do not want to just copy the data files to the tower servers. I need to keep my environment the same as it is today without changes.
I'm using ansible 2.7. These are all Redhat Linux Servers.
Here is a sample I tried. Really simple but...Inventory comes from tower server which is why the hosts says "all"
---
- name: Playbook1
hosts: all
gather_facts: yes
become: yes
remote_user: user1
tasks:
- name: Copy file to dest server
fetch:
src: "/var/tmp/file1"
dest: "/var/tmp/"
flat: yes
delegate_to: ServerB
---
- name: Playbook2
hosts: all
gather_facts: yes
become: yes
remote_user: user1
tasks:
- name: Copy file to dest server
copy:
src: "/var/tmp/file1"
dest: "/var/tmp/"
remote_src: yes
delegate_to: ServerB
Any help would be appreciated.
Regards,
Glen