hosts_vars subdirectories

Hi folks,

Is there a way to organize the host_vars directory into subdirectories ?
If not, where to ask for it ?

We have a large number of hosts (500+) and our usage actually suffer from this flat organization.

I would suggest to treat any files from /hosts_vars// to be treated as they where sitting at the top level /host_vars/
So we could organize our hosts_vars by location/role (I’m not referring to the group_vars… that we intensively use in conjunction !) :
hosts_vars/

  • boston
    – (list of baremetal in boston)
  • newyork
    – (list of baremetal in newyork)
  • clients
    – (list of clients’s VM)
    (… and so on)

If someone knows a hack or point me to the right direction to adapt ansible to that, we will be glad to post a MR !

If this has already been discussed, please point me to the thread so I can convince you from my user story to allow that :slight_smile:

Regards,

Vincent

Sounds like your trying to implement group_vars,

I would group hosts in your inventory and and use group_vars. Its much more scalable and robust than using host_vars. Ideally (for me) host_vars are only used in test environments until the relevant groups are sorted out.

Have a look at http://docs.ansible.com/ansible/latest/playbooks_best_practices.html#how-to-differentiate-staging-vs-production for how that might work.