Joel, It would be:
- hosts: lbservers In theory, the --limit dc1 would limit the playbook to the lbservers in dc1. Just make sure you don't forget to limit! - James On Fri, Dec 6, 2013 at 12:32 PM, <[email protected]> wrote: > Hi James, > > First, thanks for the response. > > Would the example you provided still work when the .yml files declare there > hosts as: >> >> - hosts: lbservers > > > Or would it have to be changed to say: >> >> - hosts: dc1_lbservers > > > We have specific tasks that would need to be run on the lbservers vs the web > servers. > > Thanks, > > -Joel > > > On Friday, December 6, 2013 12:19:51 PM UTC-5, James Martin wrote: >> >> Joel, >> >> This is untested, but might work (depending on what your playbooks are >> doing). Try using multiple groups and parent groups with children. >> >> Assuming your playbooks ran against the webservers or lbserver goup: >> >> if you wanted updated only dc1 : >> >> ansible-playbook myplabook.yml --limit dc1 >> >> if you wanted to run against both datacenters: >> >> ansible-playbook myplaybook.yml >> >> >> hosts file: >> >> [dc1:children] >> dc1_webservers >> dc1_lbservers >> >> [dc1_webservers] >> 1.1.1.20 >> 1.1.1.30 >> >> [dc1_lbservers] >> 1.1.1.10 >> >> [dc2:children] >> dc2_webservers >> dc2_lbservers >> >> [dc1_webservers] >> 1.1.2.20 >> 1.1.2.30 >> >> [dc1_lbservers] >> 1.1.2.10 >> >> [webservers:children] >> dc1_webservers >> dc2_webservers >> >> [lbservers:children] >> dc1_lbservers >> dc2_lbservers >> >> >> - James >> >> On Fri, Dec 6, 2013 at 12:17 AM, <[email protected]> wrote: >> > 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 >> > >> > >> > DC2 >> > >> > [webservers] >> > 1.1.2.20 >> > 1.1.2.30 >> > >> > [lbservers] >> > 1.1.2.10 >> > >> > >> > DC3 >> > >> > [webservers] >> > 1.1.3.20 >> > 1.1.3.30 >> > >> > [lbservers] >> > 1.1.3.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 >> > >> > -- >> > You received this message because you are subscribed to the Google >> > Groups >> > "Ansible Project" group. >> > To unsubscribe from this group and stop receiving emails from it, send >> > an >> > email to [email protected]. >> > For more options, visit https://groups.google.com/groups/opt_out. > > -- > You received this message because you are subscribed to the Google Groups > "Ansible Project" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
