I suggest using a directory that contains the files you need to build up 
your inventory.  You can also use symlinks I think
This is described in the documentation in the section starting '*Aggregating 
inventory sources with a directory' *here:
https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html#using-multiple-inventory-sources

I think this might be a simpler way to achieve what you want rather than 
using add_host and including lots of inventory files directly into your 
playbook.

It does depend on not having hostnames that clash of course.

Hope this helps,

Jon

On Monday, December 30, 2019 at 8:19:47 AM UTC, Yehuda Pinhas wrote:
>
> Hi,
> I have been searching all over the internet and there isn't any good 
> documentation that explains how to build my inventory properly. The 
> official documentation is bad and there aren't any example on inet that I 
> could find.
>
> Can you please help me? I need to build inventory file that contains 6 
> groups total and each group will have around 100 hosts in it..
> this is what I currently have.
>
> all:
>   hosts:
>     POC-ENV:
>       hosts:
>         ansible_host: /home/ansible/MACCABI/hosts/POC-ENV_list.yml
>     Nexus:
>       hosts:
>         ansible_host: /home/ansible/MACCABI/hosts/nexus_list.yml
>     Switches:
>       hosts:
>         ansible_host: /home/ansible/MACCABI/hosts/switch_list.yml
>     Avaya:
>       hosts:
>         ansible_host: /home/ansible/MACCABI/avaya_list.yml
>     Branch-Switches:
>       hosts:
>         ansible_host: /home/ansible/MACCABI/branch-switch_list.yml
>     Branch-Routers:
>       hosts:
>         ansible_host: /home/ansible/MACCABI/branch-router_list.yml
>
> As you can see there are 6 groups: POC-ENV, Nexus, Switches, Avaya, 
> Branch-Switches, Branch-Routers and I am trying to list all the hosts in a 
> file and direct the inventory to read it from there since I have so many.
>
>
> What am I doing wrong? can you fix my code?
> Thanks for the helpers.
>
>
>
>
>
>
>
>
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/47d21ffe-f405-42c4-8797-19eea1aebc84%40googlegroups.com.

Reply via email to