Skip to content

Commit 909b702

Browse files
author
Dmitriy Rabotyagov
committed
Add support for wider distro set
This patch makes pacemaker/corosync more universal, and now it's possbile to use role against CentOS 7 and CentOS 8
1 parent ff08d17 commit 909b702

File tree

3 files changed

+30
-27
lines changed

3 files changed

+30
-27
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
ansible-pacemaker-corosync role
22
===============================
33

4-
Deploys corosync/pacemaker on Ubuntu 14.04
4+
Deploys corosync/pacemaker
55

66
# Variables
77

handlers/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
service:
33
name: "{{ item }}"
44
state: restarted
5+
enabled: yes
56
with_items:
67
- corosync
78
- pacemaker

tasks/pacemaker.yml

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
1+
- name: Enable HighAvailability repository
2+
command: yum-config-manager --enable HighAvailability
3+
changed_when: false
4+
when:
5+
- ansible_os_family | lower == 'redhat'
6+
- ansible_distribution_major_version is version('8', '=')
7+
18
- name: Installs pacemaker & corosync
2-
apt: pkg={{item}} state=present
9+
package:
10+
name: "{{ item }}"
11+
state: present
312
with_items:
413
- corosync
514
- pacemaker
615

716
- name: Install haveged
8-
apt: pkg=haveged state=present
9-
when: haveged_enabled | default(true)
17+
package:
18+
name: haveged
19+
state: present
20+
when: haveged_enabled | bool | default(true)
1021

1122
- name: Generates corosync key
1223
become: true
@@ -19,21 +30,28 @@
1930
notify: Restart corosync
2031

2132
- name: Generate tmpdir for authkey
22-
local_action: tempfile
33+
local_action:
34+
module: tempfile
2335
register: authkey_tempfile
2436
changed_when: False
2537
check_mode: no
2638
when: inventory_hostname != groups[pacemaker_corosync_group][0]
2739

2840
- name: Fetch authkey for other nodes
29-
fetch: src=/etc/corosync/authkey dest="{{ authkey_tempfile.path }}" flat=yes
41+
fetch:
42+
src: /etc/corosync/authkey
43+
dest: "{{ authkey_tempfile.path }}"
44+
flat: yes
3045
delegate_to: "{{ groups[pacemaker_corosync_group][0] }}"
3146
changed_when: False
3247
check_mode: no
3348
when: inventory_hostname != groups[pacemaker_corosync_group][0]
3449

3550
- name: Copy authkey to other nodes
36-
copy: src="{{ authkey_tempfile.path }}" dest=/etc/corosync/authkey mode=0400
51+
copy:
52+
src: "{{ authkey_tempfile.path }}"
53+
dest: /etc/corosync/authkey
54+
mode: "0400"
3755
when: inventory_hostname != groups[pacemaker_corosync_group][0]
3856
notify: Restart corosync
3957

@@ -49,23 +67,23 @@
4967
- name: Chowns authkeys
5068
file:
5169
path: /etc/corosync/authkey
52-
mode: 0400
70+
mode: "0400"
5371
owner: root
5472
notify: Restart corosync
5573

5674
- name: Creates corosync config
5775
template:
5876
src: corosync.conf.j2
5977
dest: /etc/corosync/corosync.conf
60-
mode: 0400
78+
mode: "0400"
6179
owner: root
6280
notify: Restart corosync
6381

6482
- name: Adds logrotate config for corosync
6583
template:
6684
src: corosync_logrotate.conf.j2
6785
dest: /etc/logrotate.d/corosync
68-
mode: 0644
86+
mode: "0644"
6987
owner: root
7088

7189
- name: Creates services directory
@@ -78,7 +96,7 @@
7896
src: pcmk
7997
dest: /etc/corosync/service.d/pcmk
8098
owner: root
81-
mode: 0400
99+
mode: "0400"
82100
notify: Restart corosync
83101

84102
- name: Adds ferm filtering
@@ -88,19 +106,3 @@
88106
when: ferm_enabled | default(false)
89107
tags: ferm
90108
notify: Restart ferm
91-
92-
- name: Enables corosync at boot
93-
copy:
94-
dest: /etc/default/corosync
95-
content: "START=yes"
96-
when: ansible_service_mgr != "systemd"
97-
98-
- name: Enables corosync at boot
99-
systemd: name=corosync.service state=started enabled=yes
100-
when: ansible_service_mgr == "systemd"
101-
102-
- name: Registers pacemaker service
103-
service:
104-
name: pacemaker
105-
enabled: true
106-

0 commit comments

Comments
 (0)