Groups
Groups
Sign in
Groups
Groups
Ansible Project
Conversations
About
Send feedback
Help
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 PM
1/13/21
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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