# Need help

**URL:** <https://forum.ansible.com/t/need-help/25790>\
**Category:** Ansible Project\
**Created:** [October 20, 2017, 11:11am UTC](https://forum.ansible.com/t/need-help/25790 "2017-10-20T11:11:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![parwinderjit\_singh](https://avatars.discourse-cdn.com/v4/letter/p/eb8c5e/32.png) [@parwinderjit\_singh](https://forum.ansible.com/u/parwinderjit_singh)\
**Post date:** [October 20, 2017, 11:11am UTC](https://forum.ansible.com/t/need-help/25790/1 "2017-10-20T11:11:08Z")

</div>

Hi All,

i have a below inventory file

[ansible]  
parv-vm-01 ansible\_ssh\_host=10.48.21.99 host\_fqdn=parv-vm-01

[cloudera\_mysql]  
parv-vm-02 ansible\_ssh\_host=10.48.21.94 host\_fqdn=parv-vm-02

[cloudera\_manager]

[cloudera\_data]  
parv-vm-06 ansible\_ssh\_host=10.48.21.85 host\_fqdn=parv-vm-06  
parv-vm-07 ansible\_ssh\_host=10.48.21.84 host\_fqdn=parv-vm-07  
parv-vm-01 ansible\_ssh\_host=10.48.21.99 host\_fqdn=parv-vm-01

I want to create a nagios host file which contain all the IP which are there in my inventory file like below

define host{  
use linux-server  
host\_name parv-vm-06  
alias parv-vm-06  
address 10.48.21.85  
max\_check\_attempts 5  
check\_period 24x7  
notification\_interval 30  
notification\_period 24x7  
}

define host{  
use linux-server  
host\_name parv-vm-07  
alias parv-vm-07  
address 10.48.21.84  
max\_check\_attempts 5  
check\_period 24x7  
notification\_interval 30  
notification\_period 24x7  
}

How can i make this. can anyone tell me

---

<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 21, 2017, 8:27am UTC](https://forum.ansible.com/t/need-help/25790/2 "2017-10-21T08:27:57Z")

</div>

You can use the template module for loop over group['all'], this is a special group that contains all the hosts in the inventory.

To get variable of a host use hostvars['name'] or hostvars[variable]
