<p>What your are describing can typically be addressed with a correct inventory design.</p>

<pre><code>[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
</code></pre>

<p>From there you can easily:</p>

<ul>
<li>create <a href="https://docs.ansible.com/ansible/latest/user_guide/playbooks.html" rel="nofollow noreferrer">plays</a> that will target a group or a <a href="https://docs.ansible.com/ansible/latest/user_guide/intro_patterns.html" rel="nofollow noreferrer">pattern</a> and that you can limit to an other group or pattern at runtime, e.g. target <code>jenkins_master</code> and run the playbook on all of them or limit it to <code>zone1</code>.</li>
<li>create inventory vars for your hosts and groups so that e.g. servers in <code>zone1</code> will know what is the uri of the master in that zone.</li>
</ul>

<p>This is a super-quick overlook. I suggest you read in depth <a href="https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html" rel="nofollow noreferrer">working with inventory</a> to get a better understanding of all the inventory concepts and pay attention to the part concerning the <a href="https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html#organizing-host-and-group-variables" rel="nofollow noreferrer">organization of variables in the inventory for groups and hosts</a></p>

CC BY-SA 4.0
2019-09-26T20:57:50.930Z
2019-10-29T10:23:49.677Z
2019-10-29T10:23:49.677Z
Zeitounator
<p>I am only getting started with ansible.</p>

<p>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.</p>

<p>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.</p>

<p>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. </p>

<p>Maybe this is already out-of-scope for ansible and I need another tool on top of ansible?</p>

<p>Any thoughts?</p>

<jenkins><ansible><high-availability>
How to handle availability zones and failover with ansible? Is it even within the scope of ansible?
dfsg76
# How to handle availability zones and failover with ansible? Is it even within the scope of ansible?

(Asked by: username_0 on 2019-09-23)

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?

**Tags:** jenkins, ansible, high-availability


---

## 1 answers

### Answer by username_1 on 2019-09-26. Score: 5 | Accepted answer

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


---

