Anybody know of a way to deploy a template to multiple servers, but have each configuration simultaneously centralized on another server? I do not want the servers speaking with each other, so synchronize would not really be an option. I would also prefer not to use fetch, as having the different configurations live on the main workstation would become too clunky too quickly.
Anybody know of a way to deploy a template to multiple servers, but
have each configuration simultaneously centralized on another server?
How about delegate_to?
- hosts: myservers
tasks:
- name: put foo on myservers
template:
src: foo.txt.j2
dest: /etc/foo.txt
- name: put foo for myservers onto centralserver
template:
src: foo.txt.j2
dest: "/srv/myservers/{{ inventory_hostname }}"
delegate_to: centralserver
That seems to work for me; it's not *simultaneous* simultaneous, but it's
in one playbook anyway. :^)
-Josh (jbs@care.com)
(apologies for the automatic corporate disclaimer that follows)
This email is intended for the person(s) to whom it is addressed and may contain information that is PRIVILEGED or CONFIDENTIAL. Any unauthorized use, distribution, copying, or disclosure by any person other than the addressee(s) is strictly prohibited. If you have received this email in error, please notify the sender immediately by return email and delete the message and any attachments from your system.
you can do in 1 task:
- template: …
delegate_to: “{{item}}”
with_items: - “{{inventory_hostname}}” # or ansible_host, depends on your inventory
- central-host
Thanks for the tip about delegation, donno how I have not used it yet. Do you have to change security settings when you do though? I am getting an SSH unreachable error on just that one delegate task (not the rest of them).
Thanks for the tip about delegation, donno how I have not used it yet.
Do you have to change security settings when you do though? I am
getting an SSH unreachable error on just that one delegate task (not
the rest of them).
I think your Ansible control host would need to be able to SSH to "the
central server", so if it can't, that might give you an error like this. I
tested it in an environment where my control host can SSH to everything.
If "the central server" *is* the Ansible control host, and isn't allowed
to SSH to itself, then 'delegate_to: localhost' should work and not use
SSH at all.
-Josh (jbs@care.com)
(apologies for the automatic corporate disclaimer that follows)
This email is intended for the person(s) to whom it is addressed and may contain information that is PRIVILEGED or CONFIDENTIAL. Any unauthorized use, distribution, copying, or disclosure by any person other than the addressee(s) is strictly prohibited. If you have received this email in error, please notify the sender immediately by return email and delete the message and any attachments from your system.
use localhost
instead of the host name, unless you defined ‘localhost’ in your inventory it should avoid remote connections and use in the ‘local’ connection plugin.
Ok guys, I got it working. Thank you for all the help!