Hello,
We currently have three datacenters, and they're all three basically the same with some very minor differences. Up until now, what I've done is created a playbook for each, and a hosts file for each datacenter. This was primarily because the ethernet interfaces slightly differed and we didn't want to have to remember to provide forgettable variables on the command line.
Now, we're finally migrating our systems where all datacenters will be exactly the same, so we can use the same playbook. To keep it simple, lets say that each datacenter has one load balancer, and two web servers.
DC1
[webservers]
1.1.1.20
1.1.1.30
[lbservers]
1.1.1.10
Typically, in our previous setup where each datacenter had its own hosts file and playbook, we'd do the following to deploy all the installation tasks:
ansible-playbook -i /ansible/dc1/hosts.txt /ansible/dc1/all_full_deploy.yml
Since our datacenters will basically be the same, and the playbook can now be the same, I understand that I could use just one playbook, and change out the hosts file and it'll work to isolate deployments to that datacenter. The issue, and why I'm writing this is that I'd also be able to, for example, deploy our website to all [webservers] regardless of which datacenter it's in—and it has to perform a few tasks on the respective load balancer when it does it (taking it out and adding it back).
So, what is the recommended way to have a multi-datacenter hosts file so that we can work with a single datacenter, or all of them ideally using the same hosts file and the same playbook?
Thank you guys in advance for any advice you can provide.
Sincerely,
Joel Strellner