Execution
Date 08 Dec 2025 13:39:52 +0000
Duration 00:35:02.03
Controller aio1.openstack.local
User root
Versions
Ansible 2.18.6
ara 1.7.4 / 1.7.4
Python 3.12.3
Summary
2 Hosts
1377 Tasks
1365 Results
104 Plays
504 Files
0 Records

File: /etc/ansible/roles/pacemaker_corosync/tasks/pacemaker.yml

---

- name: Ensure all pre-requisites are installed
  package:
    name: gnupg2
    state: present

- name: Ensure config-manager is present for dnf
  package:
    name: dnf-plugins-core
    state: present
  when:
    - ansible_facts['os_family'] | lower == 'redhat'
    - ansible_facts['distribution_major_version'] is version('8', '>=')

- name: Enable HighAvailability repository
  command: "dnf config-manager --enable {{ _centos_ha_repo_name[ansible_facts['distribution_major_version']] }}"
  changed_when: false
  when:
    - ansible_facts['os_family'] | lower == 'redhat'

- name: Installs corosync
  package:
    name: "{{ item }}"
    state: present
  with_items:
    - corosync

- name: Installs pacemaker
  package:
    name: "{{ item }}"
    state: present
  with_items:
    - pacemaker
  when: "inventory_hostname in groups[pacemaker_corosync_group]"

- name: Installs pacemaker-remote
  package:
    name: "{{ item }}"
    state: present
  with_items:
    - pacemaker-remote
  when:
    - _pacemaker_remote_group_exists
    - "inventory_hostname in groups[pacemaker_remote_group]"

- name: Install EPEL repo for CentOS
  block:
    - name: Download EPEL gpg keys
      get_url:
        url: "{{ pacemaker_corosync_centos_epel_key }}"
        dest: /etc/pki/rpm-gpg
      register: _get_yum_keys
      until: _get_yum_keys is success
      retries: 5
      delay: 2

    - name: Install EPEL gpg keys
      rpm_key:
        key: "/etc/pki/rpm-gpg/{{ pacemaker_corosync_centos_epel_key.split('/')[-1] }}"
        state: present

    - name: Install the EPEL repository
      yum_repository:
        name: epel-haveged
        baseurl: "{{ pacemaker_corosync_centos_epel_mirror ~ '/' ~ ansible_facts['distribution_major_version'] ~ (ansible_facts['distribution_major_version'] is version('8', '>=')) | ternary('/Everything/', '/') ~ ansible_facts['architecture'] }}"
        description: "Extra Packages for Enterprise Linux {{ ansible_facts['distribution_major_version'] }} - $basearch"
        gpgcheck: yes
        enabled: yes
        state: present
        includepkgs: "haveged"
      register: install_epel_repo
      until: install_epel_repo is success
      retries: 5
      delay: 2
  when:
    - pacemaker_corosync_haveged_enabled | bool
    - ansible_facts['os_family'] | lower == 'redhat'

- name: Install haveged
  package:
    name: haveged
    state: present
  when: pacemaker_corosync_haveged_enabled | bool

- name: Generates corosync key
  command: corosync-keygen
  args:
    creates: /etc/corosync/authkey
  when: inventory_hostname == groups[pacemaker_corosync_group][0]
  notify: Restart corosync

- name: Generate tmpfile for authkey
  tempfile:
    state: file
  register: authkey_tempfile
  changed_when: False
  check_mode: no
  delegate_to: localhost
  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
  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"
  when: inventory_hostname != groups[pacemaker_corosync_group][0]
  notify: Restart corosync

- name: Clean up tmpdir
  file:
    path: "{{ authkey_tempfile.path }}"
    state: "absent"
  changed_when: False
  check_mode: no
  delegate_to: localhost
  when: inventory_hostname != groups[pacemaker_corosync_group][0]

- name: Chowns authkeys
  file:
    path: /etc/corosync/authkey
    mode: "0400"
    owner: root
  notify: Restart corosync

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

- name: Creates log directory
  file:
    path: /var/log/corosync
    state: directory
    mode: "0775"
  when: pacemaker_corosync_use_logfile | bool

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

- name: Creates services directory
  file:
    path: /etc/corosync/service.d/
    state: directory
    mode: "0755"

- name: Adds pacemaker service
  copy:
    src: pcmk
    dest: /etc/corosync/service.d/pcmk
    owner: root
    mode: "0400"
  notify: Restart corosync

- name: Adds ferm filtering
  template:
    src: "ferm.j2"
    dest: /etc/ferm/filter-input.d/60_corosync.conf
    mode: "0640"
  when: ferm_enabled | default(false)
  tags: ferm
  notify: Restart ferm