Hi,
Here is what I’m trying to achieve.
There are several environments (or clusters) that are relatively independent but still have some connections in between. Let’s say I have ‘production’, ‘staging’ and ‘general’ environments.
The last one contains common machines that are supplementary for the first two, say, DNS servers. When I create a box in ‘production’ or ‘staging’ I want to add a DNS record for that box on the DNS server inside ‘general’ environment.
Each environment is described by a standalone inventory file:
env/general/inventory
env/production/inventory
env/staging/inventory
My current approach is that all three inventories contain DNS servers. The ‘general’ environment has them as they need to be provisioned initially. ‘Production’ and ‘staging’ environments include them because the environments need to know the DNS servers in order to work with them (I use ‘delegate_to:’ to connect to a DNS server to add a record).
I would like to avoid having DNS servers in all the inventory files (the group ‘all’ should preferably refer to the hosts of an environment). I would also avoid having a single inventory for all the environments as it complicates the setup. One approach would be to treat the DNS servers as external resources for ‘production’ and ‘staging’ and to have them set up as inventory variables. But the provisioning playbook would need to ssh to a DNS server to add a record and, therefore, may need some additional arguments like ansible_ssh_host or ansible_ssh_user to connect to it. But how do I set up those if I don’t have the DNS server in the inventory? In no way…
I’d like to point out that the issue is not only about DNS servers. In the ‘general’ environment there can be other boxes, for example, a build machine that is used by both ‘production’ and ‘staging’ environments, or a common monitoring server.
So the question is how do you guys deal with similar situations? Does my setup make sense at all? Maybe I’m doing something very strange?