# Need help with playbook to gather info from inventory and direct to a file

**URL:** <https://forum.ansible.com/t/need-help-with-playbook-to-gather-info-from-inventory-and-direct-to-a-file/25813>\
**Category:** Ansible Project\
**Created:** [October 25, 2017, 4:03am UTC](https://forum.ansible.com/t/need-help-with-playbook-to-gather-info-from-inventory-and-direct-to-a-file/25813 "2017-10-25T04:03:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sri\_pavan\_kumar\_goda](https://avatars.discourse-cdn.com/v4/letter/s/7993a0/32.png) [@sri\_pavan\_kumar\_goda](https://forum.ansible.com/u/sri_pavan_kumar_goda)\
**Post date:** [October 25, 2017, 4:03am UTC](https://forum.ansible.com/t/need-help-with-playbook-to-gather-info-from-inventory-and-direct-to-a-file/25813/1 "2017-10-25T04:03:21Z")

</div>

Hi All,

Need some help with creating a playbook to gather hostname, OS and package information from the inventory and output the result to a file in below format.

“Hostname, OS, Package”

I was able to come up with below playbook but it does not give the desired output.

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [October 25, 2017, 6:18pm UTC](https://forum.ansible.com/t/need-help-with-playbook-to-gather-info-from-inventory-and-direct-to-a-file/25813/2 "2017-10-25T18:18:30Z")

</div>

Use the template module, with Jinja you can have loops and loop over the variables.
