Skip to content

Commit

Permalink
Add support for wider distro set
Browse files Browse the repository at this point in the history
This patch makes pacemaker/corosync more universal, and now it's
possbile to use role against CentOS 7 and CentOS 8
  • Loading branch information
Dmitriy Rabotyagov committed Jul 29, 2020
1 parent ff08d17 commit e662194
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 27 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ansible-pacemaker-corosync role
===============================

Deploys corosync/pacemaker on Ubuntu 14.04
Deploys corosync/pacemaker

# Variables

Expand Down
1 change: 1 addition & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
service:
name: "{{ item }}"
state: restarted
enabled: yes
with_items:
- corosync
- pacemaker
54 changes: 28 additions & 26 deletions tasks/pacemaker.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
- name: Enable HighAvailability repository
command: yum-config-manager --enable HighAvailability
changed_when: false
when:
- ansible_os_family | lower == 'redhat'
- ansible_distribution_major_version is version('8', '=')

- name: Installs pacemaker & corosync
apt: pkg={{item}} state=present
package:
name: "{{ item }}"
state: present
with_items:
- corosync
- pacemaker

- name: Install haveged
apt: pkg=haveged state=present
when: haveged_enabled | default(true)
package:
name: haveged
state: present
when: haveged_enabled | default(True) | bool

- name: Generates corosync key
become: true
Expand All @@ -19,21 +30,28 @@
notify: Restart corosync

- name: Generate tmpdir for authkey
local_action: tempfile
local_action:
module: tempfile
register: authkey_tempfile
changed_when: False
check_mode: no
when: inventory_hostname != groups[pacemaker_corosync_group][0]

- name: Fetch authkey for other nodes
fetch: src=/etc/corosync/authkey dest="{{ authkey_tempfile.path }}" flat=yes
fetch:
src: /etc/corosync/authkey
dest: "{{ authkey_tempfile.path }}"
flat: yes
delegate_to: "{{ groups[pacemaker_corosync_group][0] }}"
changed_when: False
check_mode: no
when: inventory_hostname != groups[pacemaker_corosync_group][0]

- name: Copy authkey to other nodes
copy: src="{{ authkey_tempfile.path }}" dest=/etc/corosync/authkey mode=0400
copy:
src: "{{ authkey_tempfile.path }}"
dest: /etc/corosync/authkey
mode: "0400"
when: inventory_hostname != groups[pacemaker_corosync_group][0]
notify: Restart corosync

Expand All @@ -49,23 +67,23 @@
- name: Chowns authkeys
file:
path: /etc/corosync/authkey
mode: 0400
mode: "0400"
owner: root
notify: Restart corosync

- name: Creates corosync config
template:
src: corosync.conf.j2
dest: /etc/corosync/corosync.conf
mode: 0400
mode: "0400"
owner: root
notify: Restart corosync

- name: Adds logrotate config for corosync
template:
src: corosync_logrotate.conf.j2
dest: /etc/logrotate.d/corosync
mode: 0644
mode: "0644"
owner: root

- name: Creates services directory
Expand All @@ -78,7 +96,7 @@
src: pcmk
dest: /etc/corosync/service.d/pcmk
owner: root
mode: 0400
mode: "0400"
notify: Restart corosync

- name: Adds ferm filtering
Expand All @@ -88,19 +106,3 @@
when: ferm_enabled | default(false)
tags: ferm
notify: Restart ferm

- name: Enables corosync at boot
copy:
dest: /etc/default/corosync
content: "START=yes"
when: ansible_service_mgr != "systemd"

- name: Enables corosync at boot
systemd: name=corosync.service state=started enabled=yes
when: ansible_service_mgr == "systemd"

- name: Registers pacemaker service
service:
name: pacemaker
enabled: true

0 comments on commit e662194

Please sign in to comment.