Need help

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

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]