# Recording generated template configurations

**URL:** <https://forum.ansible.com/t/recording-generated-template-configurations/22344>\
**Category:** Ansible Project\
**Created:** [August 22, 2016, 2:14pm UTC](https://forum.ansible.com/t/recording-generated-template-configurations/22344 "2016-08-22T14:14:59Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Soren\_Olegnowicz](https://avatars.discourse-cdn.com/v4/letter/s/8491ac/32.png) [@Soren\_Olegnowicz](https://forum.ansible.com/u/Soren_Olegnowicz)\
**Post date:** [August 22, 2016, 2:14pm UTC](https://forum.ansible.com/t/recording-generated-template-configurations/22344/1 "2016-08-22T14:14:59Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Josh\_Smift1](https://avatars.discourse-cdn.com/v4/letter/j/bcef8e/32.png) [@Josh\_Smift1](https://forum.ansible.com/u/Josh_Smift1)\
**Post date:** [August 22, 2016, 3:45pm UTC](https://forum.ansible.com/t/recording-generated-template-configurations/22344/2 "2016-08-22T15:45:43Z")

</div>

> 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?

&nbsp;&nbsp;- hosts: myservers

&nbsp;&nbsp;&nbsp;&nbsp;tasks:

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- name: put foo on myservers  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;template:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;src: foo.txt.j2  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dest: /etc/foo.txt

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- name: put foo for myservers onto centralserver  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;template:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;src: foo.txt.j2  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dest: "/srv/myservers/{{ inventory\_hostname }}"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;delegate\_to: centralserver

That seems to work for me; it's not \*simultaneous\* simultaneous, but it's  
in one playbook anyway. :^)

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-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.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [August 23, 2016, 2:12pm UTC](https://forum.ansible.com/t/recording-generated-template-configurations/22344/3 "2016-08-23T14:12:10Z")

</div>

you can do in 1 task:

- template: …  
delegate\_to: “{{item}}”  
with\_items:
- “{{inventory\_hostname}}” # or ansible\_host, depends on your inventory
- central-host

---

<div class="post-metadata">

**Author:** ![Soren\_Olegnowicz](https://avatars.discourse-cdn.com/v4/letter/s/8491ac/32.png) [@Soren\_Olegnowicz](https://forum.ansible.com/u/Soren_Olegnowicz)\
**Post date:** [August 23, 2016, 8:31pm UTC](https://forum.ansible.com/t/recording-generated-template-configurations/22344/4 "2016-08-23T20:31:08Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![Josh\_Smift1](https://avatars.discourse-cdn.com/v4/letter/j/bcef8e/32.png) [@Josh\_Smift1](https://forum.ansible.com/u/Josh_Smift1)\
**Post date:** [August 23, 2016, 9:37pm UTC](https://forum.ansible.com/t/recording-generated-template-configurations/22344/5 "2016-08-23T21:37:18Z")

</div>

> 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.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-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.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [August 24, 2016, 2:07pm UTC](https://forum.ansible.com/t/recording-generated-template-configurations/22344/6 "2016-08-24T14:07:31Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Soren\_Olegnowicz](https://avatars.discourse-cdn.com/v4/letter/s/8491ac/32.png) [@Soren\_Olegnowicz](https://forum.ansible.com/u/Soren_Olegnowicz)\
**Post date:** [August 24, 2016, 4:10pm UTC](https://forum.ansible.com/t/recording-generated-template-configurations/22344/7 "2016-08-24T16:10:36Z")

</div>

Ok guys, I got it working. Thank you for all the help!
