# Best approach to inventory/vars organization?

**URL:** <https://forum.ansible.com/t/best-approach-to-inventory-vars-organization/15059>\
**Category:** Ansible Project\
**Created:** [April 21, 2014, 7:52pm UTC](https://forum.ansible.com/t/best-approach-to-inventory-vars-organization/15059 "2014-04-21T19:52:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fran\_Garcia](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/fran_garcia/32/4573_2.png) [@Fran\_Garcia](https://forum.ansible.com/u/Fran_Garcia)\
**Post date:** [April 21, 2014, 7:52pm UTC](https://forum.ansible.com/t/best-approach-to-inventory-vars-organization/15059/1 "2014-04-21T19:52:47Z")

</div>

Hi all,

This is my first post here so apologies if this has been already asked  
before 🙂 . 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

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [April 21, 2014, 11:23pm UTC](https://forum.ansible.com/t/best-approach-to-inventory-vars-organization/15059/2 "2014-04-21T23:23:06Z")

</div>

- 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.
