0

Im trying to SCP a .sql file from one server to another, and I am trying to use an Ansible module to do so. I stumbled across the fetch and copy modules, but I am not sure how to specify which host I want to copy the file from.

This is my current Ansible file:

firstDB database dump happens on seperate host

    - hosts: galeraDatabase
      become: yes
      remote_user: kday
      become_method: sudo

      tasks:
    - name: Copy file to the galera server
      fetch:
        dest: /tmp/
        src: /tmp/{{ tenant }}Prod.sql
        validate_checksum: yes
        fail_on_missing: yes

Basically, I want to take the dump file from the firstDB host, and then get it over to the other galeraDatabase host. How would I do this? Im order to use fetch or copy, I would need to pass it the second hostname to copy the files from, and I don't see any parameters to do that inside of the documentation. Should I be using a different method altogether?

Thanks

J. Doe
  • 1,479
  • 5
  • 25
  • 49

1 Answers1

1

Try using the synchronize module with delegate_to, or if you don't have rsync then use the copy module. Some good answers relating to this topic already on stackoverflow.

Also, check the ansible documentation for more info on the copy and synchronize modules along with the delegate_to tasks parameter.

hth.

Community
  • 1
  • 1
cachonfinga
  • 860
  • 2
  • 8
  • 14