Within a play, one of the tasks is to generate a yaml file (using the ansible-inventory command to take a "snapshot" of a subset of the current inventory). From that yaml file, I want to do two things - 1) Create a CSV file with values both from the yaml file and from other vars generated previously during the play, 2) Format an HTML email to display the same information in a different manner.
The CSV file will look as such: Date (from prev. var), Time (from prev. var), hostname,* owner, other_key_value* Sanitized yaml file: all: children: day_1: hosts: server_1: owner: another group key: value server_2: owner: some-team key: value day_2: hosts: server_1: owner: some-team key: value server_2: owner: another group key: value The jinja template thus far (for the csv): % for groupname, hosts in curr_inv.all.children.items() %} {% if 'day_' in groupname %} {% for hostname, static_vars in hosts.hosts.items() %} {{ my_dates[groupname].calendar_date }},{{ my_dates[groupname].time }},{{ hostname }} {% endfor %} {% endif %} {% endfor %} This gives me the first three necessary values without issue. Where I am having an issue is accessing the inner key=value pairs such as "owner: some-team". For the HTML formatting, I want to use the same data but display it as such: <h2>Date_1 - Time_1</h2> <strong>some-team</strong> server_that_belongs_to_this_group_1 server_that_belongs_to_this_group_2 server_that_belongs_to_this_group_3 <strong>a different group</strong> server_that_belongs_to_this_group_1 server_that_belongs_to_this_group_2 server_that_belongs_to_this_group_3 <h2>Date_2 - Time_1</h2> <strong>some-team</strong> server_that_belongs_to_this_group_1 server_that_belongs_to_this_group_2 server_that_belongs_to_this_group_3 <strong>a different group</strong> server_that_belongs_to_this_group_1 server_that_belongs_to_this_group_2 server_that_belongs_to_this_group_3 I hope this makes sense. Thank you! -- 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 ansible-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/baad6d30-6068-4087-be42-80d8f9cb6125%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.