# How to adapt tempfile to cfg

**URL:** <https://forum.ansible.com/t/how-to-adapt-tempfile-to-cfg/30723>\
**Category:** Ansible Project\
**Created:** [July 8, 2019, 1:30pm UTC](https://forum.ansible.com/t/how-to-adapt-tempfile-to-cfg/30723 "2019-07-08T13:30:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oxs](https://avatars.discourse-cdn.com/v4/letter/o/ebca7d/32.png) [@Oxs](https://forum.ansible.com/u/Oxs)\
**Post date:** [July 8, 2019, 1:30pm UTC](https://forum.ansible.com/t/how-to-adapt-tempfile-to-cfg/30723/1 "2019-07-08T13:30:12Z")

</div>

Hey guys,

I use the following template file .j2 to update config file on remote host.

Template file: pg\_hba.conf.j2

{% for slave in groups[‘slaves’] %}  
host replication {{ [postgresql\_streaming\_user.name](http://postgresql_streaming_user.name) }} {{ hostvars[slave]**[‘ansible\_all\_ipv4\_addresses’]** }}/32 {{ postgresql\_default\_ipv4\_auth\_method }}  
{% endfor %}

Configuration file: pg\_hba.conf.j2

host database user **[u’10.123.214.7’]**/32 md5

How I can adapt my template file to remove this character in my configuration file **[u’ ……** **'] ?**

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [July 8, 2019, 2:54pm UTC](https://forum.ansible.com/t/how-to-adapt-tempfile-to-cfg/30723/2 "2019-07-08T14:54:53Z")

</div>

If the server just have one IP you probably should use  
ansible\_default\_ipv4.address instead if ansible\_all\_ipv4\_addresses.

If the server have multiple IP that you would like to include you would need to loop over ansible\_all\_ipv4\_addresses since it is a list of all IP on the server.

---

<div class="post-metadata">

**Author:** ![Oxs](https://avatars.discourse-cdn.com/v4/letter/o/ebca7d/32.png) [@Oxs](https://forum.ansible.com/u/Oxs)\
**Post date:** [July 8, 2019, 3:36pm UTC](https://forum.ansible.com/t/how-to-adapt-tempfile-to-cfg/30723/3 "2019-07-08T15:36:22Z")

</div>

Solution looks like this : [‘ansible\_default\_ipv4’][‘address’]
