I need to copy file /etc/resolv.conf
from a remote host and copy it on multiple remote hosts.
my hosts:
Ansible
ubuntu1-4
I want to copy this file from ubuntu1
to ubuntu2
, ubuntu3
and ubuntu4
I tried the synchronize
module but I can't/don't want to use rsync
as a demon on ubuntu1-4
.
Is there a better way than copying it on Ansible and from Ansible to ubuntu2
till 4
?
Best Answer
If you're just talking about a single file you don't need the
synchronize
module. You can grab a file from a remote host using thefetch
module. Once you have the file on your local system, you can just use thecopy
module to distribute it to other hosts.Something like:
While this works, a better solution would be to maintain the appropriate
resolv.conf
as part of your ansible configuration and distribute it to all hosts, rather than copying it from one remote to others.