data modeling - group_vars and inventory with deeply nested subdirectories - example included

Skip to first unread message

Joey Freeland

Jun 8, 2021, 5:19:32 PMJun 8
to Ansible Development
I'm very new to using ansible; please forgive my ignorance.

I need to manage groups of machines that all look identical in their "group."  For various reasons I cannot just use an instance template in my cloud providers and some on-host bootstrap to configure the nodes when they start.

I have managed to get all of my variables to properly include by doing something like  Give it a shot.

This is not what other examples tend to look like.  I've spoken with a couple peers who were surprised this worked and suggested not going this route.

For various reasons I have to use ansible 2.9 for now.  I don't see any reason in why I wouldn't be able to do what I'm doing.

Is this not 'supported'?

Is this an anti-pattern?

Can anyone recommend an alternative or more appropriate approach to deeply nested group variable inheritance with as little repeating yourself as practical?

Joey Freeland

Jun 8, 2021, 5:24:43 PMJun 8
to Ansible Development makes the structure a bit easier to digest if you're not already a github1s user.

Sloane Hertel

Jun 14, 2021, 2:11:03 PMJun 14
to Ansible Development
I find the flattened common-example directory easier to read. It looks like the host vars issue is because REGION is defined in a couple places instead of CLUSTER_REGION.

It may be worth taking a look at the generator inventory plugin, which was added in 2.6. It looks like you're adding the group structure after adding the hosts, but you could probably also easily tweak the plugin to only generate groups.
Reply all
Reply to author
0 new messages