Best approach to inventory/vars organization?

Hi all,

This is my first post here so apologies if this has been already asked
before :slight_smile: . Any pointers to the relevant conversation will be much
appreciated.

I’m trying to understand what approach I should take regarding

organizing my inventory, considering the following:

  • I have an external, custom-made CMDB (somewhat tweakeable).
  • The servers are scattered through 15+ datacentres
  • The servers might belong to different customers.
  • I want to be able to override vars defined on a Datacentre-level with
    others defined at customer-level or host-level.

That’d look like :

[Datacentre1]
CustomerA-webserver1
customerA-webserver2
customerA-database1
customerB-server1
customerB-server2

[Datacentre1:vars]
dns1: 1.1.1.1
dns2: 1.1.1.2
ntp1: 1.1.1.1
ntp2: 1.1.1.2

[Datacentre2]
customerC-webserver1
customerC-webserver2
CustomerD-server1

[Datacentre2:vars]
dns1: 2.1.1.1
dns2: 2.1.1.2
ntp1: 2.1.1.1
ntp2: 2.1.1.2

The playbooks I’m focusing on writing now are about standardizing basic system
configurations (ntp.conf , resolv.conf , syslog etc) and the
Datacenter-inherited values should be good 90% of the time, but there are
exceptions; that’s why I need to come up with this schema.

Longer term, all this data could be incorporated into the CMDB but at the
moment I want to see if this can be reasonably accomplished with
Ansible-only configuration.

Also I’ve explored the possibility of defining this into roles, but I’m not
seeing how I can easily override values for a certain host or “customer”
group.

Thanks,

Fran

  • I have an external, custom-made CMDB (somewhat tweakeable).

(A) If you have one of these, you don’t have it render the inventory file. Instead, have it emit JSON and use a dynamic inventory script. I think you allude to this below.

(B) Inventory in Ansible is a graph (not just a tree!) and systems can be in groups based on location, purpose, or more than one thing.

(C) As for overriding for customers, I’m not sure you would really want to – unless customers are in fact on different NTP servers. If they were, I’d put those NTP server variables in customer groups and not in datacenter groups, or have subgroups like

customer_dc1

etc

As you see fit.