I have thousands of Jinja that I need to automate.
I have this jinja template
############################################
127.0.0.1 localhost localhostdomain
{% for host in groups.all %}
{{ hostvars[host]['ansible_all_ipv4_addresses'],
hostvars[host]['ansible_fqdn'],hostvars[host]['inventory_hostname_short'] }}
{% endfor %}
############################################
THis is my playbook
###################################
cat hosts.yml
---
- hosts: all
name:
become: yes
tasks:
- name: Template
template:
src: j.j2
dest: /tmp/myhosts
#################################
I got it right, but this is the output:
###############################
cat /tmp/myhosts
127.0.0.1 localhost localhostdomain
([u'192.10.100.1'], u'server01.example.com', u' u'server01')
([u'192.10.100.2'], u'server02.example.com', u' u'server02')
######################################################
I am hoping for an output like this
########################
127.0.0.1 localhost localhostdomain
192.10.100.1 server01.example.com server01
192.10.100.2 server02.example.com server02
############################
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/241b9458-184b-45e3-b925-063d6526ef0cn%40googlegroups.com.