Re: [ansible-project] Im generating a hosts file based on my inventory

6 views
Skip to first unread message

Vladimir Botka

unread,
Jan 13, 2021, 10:53:12 PM1/13/21
to 'Aristotle D Aguirre' via Ansible Project
On Wed, 13 Jan 2021 17:39:31 -0800 (PST)
"'Aristotle D Aguirre' via Ansible Project"
<ansible...@googlegroups.com> wrote:

> ... template
> {% for host in groups.all %}
> {{ hostvars[host]['ansible_all_ipv4_addresses'],
> hostvars[host]['ansible_fqdn'],hostvars[host]['inventory_hostname_short'] }}
> {% endfor %}
>
> ... result
> ([u'192.10.100.1'], u'server01.example.com', u' u'server01')
> ([u'192.10.100.2'], u'server02.example.com', u' u'server02')
>
> ... expected
> 192.10.100.1 server01.example.com server01
> 192.10.100.2 server02.example.com server02

Fix the template
https://gist.github.com/vbotka/31cdd229878a72780a72ea412252ab95

* Expand the items one by one
* Take the first item of *ansible_all_ipv4_addresses* (if this is what
you want)


--
Vladimir Botka
Reply all
Reply to author
Forward
0 new messages