# Inventory report

**URL:** <https://forum.ansible.com/t/inventory-report/35763>\
**Category:** Ansible Project\
**Created:** [September 21, 2021, 2:18pm UTC](https://forum.ansible.com/t/inventory-report/35763 "2021-09-21T14:18:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pathi](https://avatars.discourse-cdn.com/v4/letter/p/d78d45/32.png) [@Pathi](https://forum.ansible.com/u/Pathi)\
**Post date:** [September 21, 2021, 2:18pm UTC](https://forum.ansible.com/t/inventory-report/35763/1 "2021-09-21T14:18:53Z")

</div>

Hi Some one help me with report wrting with template .j2

hostname,CPU,MEM,SWAP… for multipple servers.

Thanks  
Prabhakar

---

<div class="post-metadata">

**Author:** ![Dineshbabu\_Shankar](https://avatars.discourse-cdn.com/v4/letter/d/73ab20/32.png) [@Dineshbabu\_Shankar](https://forum.ansible.com/u/Dineshbabu_Shankar)\
**Post date:** [September 21, 2021, 2:32pm UTC](https://forum.ansible.com/t/inventory-report/35763/2 "2021-09-21T14:32:12Z")

</div>

{% 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

---

<div class="post-metadata">

**Author:** ![Pushparaj\_Gothandam](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/pushparaj_gothandam/32/5538_2.png) [@Pushparaj\_Gothandam](https://forum.ansible.com/u/Pushparaj_Gothandam)\
**Post date:** [September 21, 2021, 3:08pm UTC](https://forum.ansible.com/t/inventory-report/35763/3 "2021-09-21T15:08:38Z")

</div>

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](https://github.com/rajthecomputerguy/ansible/tree/master/linux/Collecting_Ansible_facts)

---

<div class="post-metadata">

**Author:** ![steve\_missoh](https://avatars.discourse-cdn.com/v4/letter/s/3da27b/32.png) [@steve\_missoh](https://forum.ansible.com/u/steve_missoh)\
**Post date:** [September 21, 2021, 3:27pm UTC](https://forum.ansible.com/t/inventory-report/35763/4 "2021-09-21T15:27:53Z")

</div>

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:
