Hi Some one help me with report wrting with template .j2
hostname,CPU,MEM,SWAP… for multipple servers.
Thanks
Prabhakar
Hi Some one help me with report wrting with template .j2
hostname,CPU,MEM,SWAP… for multipple servers.
Thanks
Prabhakar
{% for host in ansible_play_batch %}
{{hostvars[host][‘ansible_hostname’]}},{{hostvars[host][‘ansible_distribution’]}},{{hostvars[host][‘ansible_distribution_version’]}},{{hostvars[host][output.stdline]}}
{% endfor %}
Replace ansible_distribution with what variable you required.
Variable names pls check with setup modules
Please look at this example, this will help you to extract information in csv
https://github.com/rajthecomputerguy/ansible/tree/master/linux/Collecting_Ansible_facts
SImply,
in your j2:
{% for host in groups[‘all’] %}
{{ hostvars[host][“ansible_facts”][‘fqdn’] }} {{ hostvars[host][“ansible_facts”][‘processor_vcpus’] }} {{ hostvars[host][“ansible_facts”][‘memtotal_mb’] }} {{ hostvars[host][“ansible_facts”][‘swaptotal_mb’] }}
{% endfor %}
then in your playbook: