5

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?

5

What your are describing can typically be addressed with a correct inventory design.

[zone1]
serverA
serverB
serverC

[zone2]
server1
server2
server3

[zone3]
serverX
serverY
serverZ

[jenkins_master]
serverA
server1
serverX

[jenkins_slave]
serverB
serverC
server2
server3
serverY
serverZ

From 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_master and run the playbook on all of them or limit it to zone1.
  • create inventory vars for your hosts and groups so that e.g. servers in zone1 will 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.