Skip to content

Commit 6c08ea2

Browse files
committed
[NEW] added Keeplaived ansible playbook
1 parent 037e24b commit 6c08ea2

File tree

8 files changed

+98
-3
lines changed

8 files changed

+98
-3
lines changed

Ansible/activemq-artemis/cluster/templates/master-broker.xml.j2

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,9 @@ under the License.
144144
<global-max-messages>-1</global-max-messages>
145145
<!-- Cluster Configuration: Connectors and Cluster-Connections -->
146146
<connectors>
147-
{% for name, url in connectors.items() %}
148-
<connector name="{{ name }}">{{ url }}</connector>
149-
{% endfor %}
147+
{% for name, url in connectors.items() %}
148+
<connector name="{{ name }}">{{ url }}</connector>
149+
{% endfor %}
150150
</connectors>
151151

152152
<ha-policy>

Ansible/keepalived/ansible.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[defaults]
2+
callbacks_enabled = profile_tasks

Ansible/keepalived/configure.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
- name: Configure Keepalived on Master and Slave servers
3+
hosts: all
4+
become: true
5+
vars_files:
6+
- vars.yml
7+
8+
tasks:
9+
- name: Ensure Keepalived is installed
10+
ansible.builtin.package:
11+
name: keepalived
12+
state: present
13+
14+
- name: Generate Keepalived configuration for master
15+
ansible.builtin.template:
16+
src: templates/master.conf.j2
17+
dest: /etc/keepalived/keepalived.conf
18+
owner: root
19+
group: root
20+
mode: 0644
21+
when: "'master' in group_names"
22+
23+
- name: Generate Keepalived configuration for slaves
24+
ansible.builtin.template:
25+
src: templates/slave.conf.j2
26+
dest: /etc/keepalived/keepalived.conf
27+
owner: root
28+
group: root
29+
mode: 0644
30+
when: "'slave' in group_names"
31+
32+
- name: Restart Keepalived service
33+
ansible.builtin.service:
34+
name: keepalived
35+
state: restarted

Ansible/keepalived/install.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
- name: Install Keepalived on multiple OS families
3+
hosts: all
4+
become: true
5+
tasks:
6+
- name: Install Keepalived on Debian/Ubuntu systems
7+
ansible.builtin.package:
8+
name: keepalived
9+
state: present
10+
when: ansible_facts['os_family'] == "Debian"
11+
12+
- name: Install Keepalived on Red Hat/CentOS systems
13+
ansible.builtin.package:
14+
name: keepalived
15+
state: present
16+
when: ansible_facts['os_family'] == "RedHat"

Ansible/keepalived/inventory.ini

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[master]
2+
rockylinux ansible_host=142.93.56.4 ansible_user=root
3+
4+
[slave]
5+
debian ansible_host=157.245.130.56 ansible_user=root
6+
ubuntu ansible_host=134.209.77.220 ansible_user=root
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
vrrp_instance VI_1 {
2+
state MASTER
3+
interface {{ interface }}
4+
virtual_router_id {{ virtual_router_id }}
5+
priority {{ master_priority }}
6+
advert_int {{ advert_int }}
7+
authentication {
8+
auth_type PASS
9+
auth_pass {{ auth_pass }}
10+
}
11+
virtual_ipaddress {
12+
{{ virtual_ipaddress }}
13+
}
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
vrrp_instance VI_1 {
2+
state BACKUP
3+
interface {{ interface }}
4+
virtual_router_id {{ virtual_router_id }}
5+
priority {{ slave_priority }}
6+
advert_int {{ advert_int }}
7+
authentication {
8+
auth_type PASS
9+
auth_pass {{ auth_pass }}
10+
}
11+
virtual_ipaddress {
12+
{{ virtual_ipaddress }}
13+
}
14+
}

Ansible/keepalived/vars.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# vars.yml
2+
interface: eth0
3+
virtual_router_id: 51
4+
auth_pass: 1111
5+
virtual_ipaddress: 192.168.1.100
6+
master_priority: 100
7+
slave_priority: 80
8+
advert_int: 1

0 commit comments

Comments
 (0)