# jinja2 using host facts to create playbook for haproxy back end configuration question

**URL:** <https://forum.ansible.com/t/jinja2-using-host-facts-to-create-playbook-for-haproxy-back-end-configuration-question/24357>\
**Category:** Ansible Project\
**Created:** [April 29, 2017, 6:59pm UTC](https://forum.ansible.com/t/jinja2-using-host-facts-to-create-playbook-for-haproxy-back-end-configuration-question/24357 "2017-04-29T18:59:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Owen\_Corcoran](https://avatars.discourse-cdn.com/v4/letter/o/977dab/32.png) [@Owen\_Corcoran](https://forum.ansible.com/u/Owen_Corcoran)\
**Post date:** [April 29, 2017, 6:59pm UTC](https://forum.ansible.com/t/jinja2-using-host-facts-to-create-playbook-for-haproxy-back-end-configuration-question/24357/1 "2017-04-29T18:59:26Z")

</div>

Hi guys,

I’m putting together a playbook for a project and i cant seem to find a way to do the following:

I was to create a ha proxy config file specifying the backends from the system facts gathered namely from the hostname and host ip gathered from the haproxy hosts specified in my hosts file.

I was this info to get collected ( which is working) and iterate over the ip and hostname inserting them into the jinja2 template file. i know how to use the looping in jinja2 but i just cant seem to find how to achieve this.

Any ideas welcome

Cheers
