Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

integrate pacemaker-remote #1

Merged
merged 4 commits into from Jan 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -6,6 +6,6 @@ Deploys corosync/pacemaker
# Variables

- `pacemaker_corosync_group`: Ansible group name for corosync cluster (default: false, *mandatory*)
- `pacemaker_remote_group`: Ansible group name for pacemaker-remote cluster (default: false, *mandatory*)
- `pacemaker_corosync_ring_interface`: Interface to use for ring0 communications (default: false, *mandatory*)
- `pacemaker_corosync_fqdn`: Whether use inventory_hostname or ansible_fqdn as node name for corosync (default: false)

1 change: 0 additions & 1 deletion handlers/main.yml
Expand Up @@ -5,4 +5,3 @@
enabled: yes
with_items:
- corosync
- pacemaker
17 changes: 16 additions & 1 deletion tasks/pacemaker.yml
Expand Up @@ -5,13 +5,28 @@
- ansible_os_family | lower == 'redhat'
- ansible_distribution_major_version is version('8', '=')

- name: Installs pacemaker & corosync
- 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: "inventory_hostname in groups[pacemaker_remote_group]"

- name: Install haveged
package:
Expand Down
20 changes: 15 additions & 5 deletions templates/corosync.conf.j2
@@ -1,4 +1,9 @@
{% set _pacemaker_corosync_bind_addr = hostvars[inventory_hostname]['ansible_' + pacemaker_corosync_ring_interface | replace('-', '_')].ipv4.address %}
{% if inventory_hostname in groups[pacemaker_corosync_group] %}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However this change does not make much sense to me, and I guess I need to revert it. Why you should be obliged to use eth1 interface for pacemaker_corosync_group? I think that user should leverage either group_vars or another variable should be added to control interface for different groups.

{% set _pacemaker_corosync_bind_addr = hostvars[inventory_hostname]['ansible_eth1' | replace('-', '_')].ipv4.address %}
{% else %}
{% set _pacemaker_corosync_bind_addr = hostvars[inventory_hostname]['ansible_' + pacemaker_corosync_ring_interface | replace('-', '_')].ipv4.address %}
{% endif %}

totem {
version: 2
cluster_name: {{ pacemaker_corosync_group }}
Expand Down Expand Up @@ -28,16 +33,21 @@ quorum {

{% if pacemaker_enable_nodelist|default(true) %}
nodelist {
{% for node in groups[pacemaker_corosync_group]|sort %}

{% for node in groups[pacemaker_remote_group]|sort + groups[pacemaker_corosync_group]|sort %}
{% if node in groups[pacemaker_corosync_group] %}
{% set _tmp_pacemaker_corosync_ring_interface = 'eth1' %}
{% else %}
{% set _tmp_pacemaker_corosync_ring_interface = pacemaker_corosync_ring_interface %}
{% endif %}
node {
ring0_addr: {{ _pacemaker_corosync_bind_addr }}
ring0_addr: {{ hostvars[node]['ansible_' + _tmp_pacemaker_corosync_ring_interface | replace('-', '_')].ipv4.address }}
name: {{ pacemaker_corosync_fqdn | bool | ternary(hostvars[node].ansible_fqdn, node) }}
nodeid: {{ loop.index }}
}
{% endfor %}
}
{% endif %}

}
logging {
to_logfile: {{ (pacemaker_corosync_use_logfile | bool) | ternary('yes', 'no') }}
{% if pacemaker_corosync_use_logfile | bool %}
Expand Down