Inventory
The Inventory file is basically the list of your “Targets”, or your clusters, in Scale’s language. If you have cluster-specific settings for ansible, it makes a ton of sense to put them here. For instance, the IP range of my clusters doesn’t necessarily correlate to the store number, so I put a variable in the inventory for each store, and the IP address, in my inventory file for staging clusters. For my inventory for production machine, no such value is needed, and is omitted. My production-inventory.yaml
looks like so:
all:
hosts:
"001" :
ansible_host: 10.2.1.98
"002" :
ansible_host: 10.2.2.98
"003" :
ansible_host: 10.2.3.98
"004" :
ansible_host: 10.2.4.98
"005" :
ansible_host: 10.2.5.98
This allows me to limit an ansible playbook run to a single store, with a 3 digit identifier. There are 3 nodes in each cluster, but the first node starts with .98. There are some fun and interesting ways to generate these files, but those will be the topic of a separate discussion. I save these files in individual folders with each playbook, in case there needs to be something different. I am sure that a compelling case could be made to have one inventory that does all things, but as mentioned above, I’m still working on it!