How to make Ansible use ALL inventory files in a directory?

46 views
Skip to first unread message

ZillaYT

unread,
Jan 10, 2018, 2:40:37 PM1/10/18
to Ansible Project
I'm segregating my development from my production inventories, and somewhat following the advice given in Laying out roles, inventories and playbooks. I therefore have the following directory structure.

/path_to_playbook/inventories
/path_to_playbook/inventories/development/hosts
/path_to_playbook/inventories/development/hosts/host_file_1
/path_to_playbook/inventories/development/hosts/host_file_2
/path_to_playbook/inventories/production/hosts
/path_to_playbook/inventories/production/hosts/host_file_1
/path_to_playbook/inventories/production/hosts/host_file_2

Now how can I write an ansible ad-hoc command to ping all the hosts in the /path_to_playbook/inventories/development/hosts directory? I don't want to create a  /path_to_playbook/inventories/development/hosts/all_hosts file that will contain the hosts in the host_file_* files since that will be hard to maintain

Brian Coca

unread,
Jan 10, 2018, 3:58:32 PM1/10/18
to Ansible Project
Just pass the directory to -i, ansible will use all the files contained within.





--
----------
Brian Coca
Reply all
Reply to author
Forward
0 new messages