snippetMinor
How to handle availability zones and failover with ansible? Is it even within the scope of ansible?
Viewed 0 times
thehandlewithwithinscopezonesfailoveravailabilityhowand
Problem
I am only getting started with ansible.
I want to set up a new development infrastructure with the infrastructure as code principle. First thing I'll have to prove is a Jenkins instance with a few nodes for a Java dev team.
I want to do it correct right from the start, so I want to include some redundancy. Let's assume that in this scenario there are 3 sites with bare metal servers. I want to set up a Jenkins master in all 3 zones which form a cluster.
But I don't want to think about that myself. I just want to provide the info to ansbile what server is in which availability zone, and ansible should make sure to set up a Jenkins master in each availability zone and connecting it to the cluster.
Maybe this is already out-of-scope for ansible and I need another tool on top of ansible?
Any thoughts?
I want to set up a new development infrastructure with the infrastructure as code principle. First thing I'll have to prove is a Jenkins instance with a few nodes for a Java dev team.
I want to do it correct right from the start, so I want to include some redundancy. Let's assume that in this scenario there are 3 sites with bare metal servers. I want to set up a Jenkins master in all 3 zones which form a cluster.
But I don't want to think about that myself. I just want to provide the info to ansbile what server is in which availability zone, and ansible should make sure to set up a Jenkins master in each availability zone and connecting it to the cluster.
Maybe this is already out-of-scope for ansible and I need another tool on top of ansible?
Any thoughts?
Solution
What your are describing can typically be addressed with a correct inventory design.
From there you can easily:
This is a super-quick overlook. I suggest you read in depth working with inventory to get a better understanding of all the inventory concepts and pay attention to the part concerning the organization of variables in the inventory for groups and hosts
[zone1]
serverA
serverB
serverC
[zone2]
server1
server2
server3
[zone3]
serverX
serverY
serverZ
[jenkins_master]
serverA
server1
serverX
[jenkins_slave]
serverB
serverC
server2
server3
serverY
serverZFrom there you can easily:
- create plays that will target a group or a pattern and that you can limit to an other group or pattern at runtime, e.g. target
jenkins_masterand run the playbook on all of them or limit it tozone1.
- create inventory vars for your hosts and groups so that e.g. servers in
zone1will know what is the uri of the master in that zone.
This is a super-quick overlook. I suggest you read in depth working with inventory to get a better understanding of all the inventory concepts and pay attention to the part concerning the organization of variables in the inventory for groups and hosts
Code Snippets
[zone1]
serverA
serverB
serverC
[zone2]
server1
server2
server3
[zone3]
serverX
serverY
serverZ
[jenkins_master]
serverA
server1
serverX
[jenkins_slave]
serverB
serverC
server2
server3
serverY
serverZContext
StackExchange DevOps Q#9241, answer score: 5
Revisions (0)
No revisions yet.