# generate template once for group of hosts

**URL:** <https://forum.ansible.com/t/generate-template-once-for-group-of-hosts/26191>\
**Category:** Ansible Project\
**Created:** [December 2, 2017, 4:53am UTC](https://forum.ansible.com/t/generate-template-once-for-group-of-hosts/26191 "2017-12-02T04:53:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomr](https://avatars.discourse-cdn.com/v4/letter/t/d2c977/32.png) [@tomr](https://forum.ansible.com/u/tomr)\
**Post date:** [December 2, 2017, 4:53am UTC](https://forum.ansible.com/t/generate-template-once-for-group-of-hosts/26191/1 "2017-12-02T04:53:16Z")

</div>

My understanding is that ansible normally generates a file from a template once _per host_. Is it possible, when I know in advance that a file will be identical for all hosts in a group, to generate it only once?

Thanks,  
tomr

---

<div class="post-metadata">

**Author:** ![Pshem\_Kowalczyk](https://avatars.discourse-cdn.com/v4/letter/p/e480ec/32.png) [@Pshem\_Kowalczyk](https://forum.ansible.com/u/Pshem_Kowalczyk)\
**Post date:** [December 2, 2017, 5:19am UTC](https://forum.ansible.com/t/generate-template-once-for-group-of-hosts/26191/2 "2017-12-02T05:19:03Z")

</div>

You can do the following (use two tasks instead of one ‘template’):

1. Generate the template on the controller host (with delegate\_to: localhost and run\_once: true)
2. Copy the generated template to all the other hosts

kind regards  
Pshem
