Have some way to merge the 'host' INI inventory and group_vars/$service to become a single $service.yml?

Hi List,

Today, we are using the approach as suggested by the official documentation (directory layout) http://docs.ansible.com/ansible/latest/playbooks_best_practices.html
but, if you have a big number of regions/different-pops and huge number of servers. so, It’s become a bit confused to be maintained.

So, my goal is to find a way to merge the ‘host’ inventory that has the usual “[services1]” and ‘groups_vars/services1’ to become a single ‘services.yml’, for me it is the best way.

p.s: I tried to use the INI format, but the fact is because do not fit well due to we use big number of variables (strings, arrays) for different regions & pops.

Thanks in advance,

in 2.4 you can use ansible-inventory to dump a yaml/json
representation of the inventory.

Brian,

I tried it, but the response is very polluted. I am looking for something more simple.

e.g:

cat hosts

[web:children]
web-region1

[web-region1]
1.2.3.4 var1=“[1, 2, 3]” var2=“caipirinha”
1.2.3.5 var1=“[6, 7, 8]” var2=“caipirinha-com-gelo”

cat group_vars/web-region1

var_name1: “1, 2”
var_name2: “3, 4”

So, the expectation should be to create a single

cat web-region1.yml

web-region1:

hosts:
1.2.3.4:
var1: “[1, 2, 3]”
var2: “caipirinha”

1.2.3.5:
var1: “[6, 7, 8]”
var2: “caipirinha-com-gelo”

vars:

var_name1: “1, 2”
var_name2: “3, 4”

Hi Guys,

I just created the simple tool here https://github.com/jpereira/ansible-tools/ to do that.