-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Florent CARLI <florent.carli@rte-france.com>
- Loading branch information
1 parent
f38dd10
commit c98964a
Showing
10 changed files
with
210 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Configure HA Role | ||
|
||
This role configures the High Availability part of a seapath cluster (Corosync and Pacemaker) | ||
|
||
## Requirements | ||
|
||
no requirement. | ||
|
||
## Role Variables | ||
|
||
no variables. | ||
|
||
## Example Playbook | ||
|
||
```yaml | ||
- name: Configure HA | ||
hosts: cluster_machines | ||
roles: | ||
- { role: seapath_ansible.configure_ha } | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[Match] | ||
Name=en* eth* | ||
KernelCommandLine=!nfsroot | ||
KernelCommandLine=!ip | ||
|
||
[Network] | ||
DHCP=no | ||
|
||
[Link] | ||
MTUBytes=1500 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
galaxy_info: | ||
author: "RTE" | ||
description: configures the High Availability part of a seapath cluster (Corosync and Pacemaker) | ||
license: Apache-2.0 | ||
min_ansible_version: 2.9.10 | ||
platforms: | ||
- name: Debian | ||
versions: | ||
- all | ||
dependencies: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Copyright (C) 2024 RTE | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
--- | ||
- block: | ||
- name: Fetch corosync configuration | ||
fetch: | ||
src: "/etc/corosync/corosync.conf" | ||
dest: "{{ tmpdir }}/corosync.conf" | ||
flat: true | ||
run_once: true | ||
- name: Fetch corosync key | ||
fetch: | ||
src: "/etc/corosync/authkey" | ||
dest: "{{ tmpdir }}/authkey" | ||
flat: true | ||
run_once: true | ||
when: groups['unconfigured_machine_group'] is defined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
# Copyright (C) 2024 RTE | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
--- | ||
- include_vars: "{{ ansible_distribution }}.yml" | ||
|
||
- name: Save cluster machine informations | ||
template: | ||
src: cluster.conf.j2 | ||
dest: /etc/cluster.conf | ||
|
||
# Check if corosync is already setup | ||
- name: check corosync service status | ||
systemd: | ||
name: corosync | ||
state: started | ||
check_mode: true | ||
register: corosync_service_status | ||
- name: Create a group with unconfigured_machines | ||
add_host: | ||
name: "{{ item }}" | ||
groups: unconfigured_machine_group | ||
run_once: true | ||
loop: "{{ groups['cluster_machines'] }}" | ||
changed_when: false | ||
when: hostvars[item].corosync_service_status.changed | ||
- name: Create a group with valid_machines | ||
add_host: | ||
name: "{{ item }}" | ||
groups: valid_machine | ||
run_once: true | ||
loop: "{{ groups['cluster_machines'] }}" | ||
changed_when: false | ||
when: not hostvars[item].corosync_service_status.changed | ||
|
||
# Setup Corosync from scratch | ||
- name: templating corosync.conf | ||
template: | ||
src: corosync.conf.j2 | ||
dest: /etc/corosync/corosync.conf | ||
when: groups['valid_machine'] is undefined | ||
- name: Making sure that Corosync service is started | ||
ansible.builtin.systemd: | ||
name: corosync | ||
state: restarted | ||
enabled: yes | ||
|
||
- block: | ||
- name: Fetch corosync configuration | ||
fetch: | ||
src: "/etc/corosync/corosync.conf" | ||
dest: "{{ tmpdir }}/corosync.conf" | ||
flat: true | ||
run_once: true | ||
- name: Fetch corosync key | ||
fetch: | ||
src: "/etc/corosync/authkey" | ||
dest: "{{ tmpdir }}/authkey" | ||
flat: true | ||
run_once: true | ||
when: | ||
- groups['unconfigured_machine_group'] is defined | ||
- "'valid_machine' in group_names" | ||
|
||
- name: Setup Corosync using existing configuration | ||
block: | ||
- name: Install corosync configuration | ||
copy: | ||
src: "{{ tmpdir }}/corosync.conf" | ||
dest: /etc/corosync/corosync.conf | ||
owner: root | ||
group: root | ||
mode: '0644' | ||
- name: Install corosync key | ||
copy: | ||
src: "{{ tmpdir }}/authkey" | ||
dest: /etc/corosync/authkey | ||
owner: root | ||
group: root | ||
mode: '0400' | ||
- name: Start pacemaker | ||
ansible.builtin.systemd: | ||
name: corosync | ||
state: started | ||
enabled: true | ||
when: | ||
- groups['valid_machine'] is defined | ||
- "'unconfigured_machine_group' in group_names" | ||
|
||
- name: Setup Pacemaker on unconfigured_machine_group | ||
block: | ||
- name: Start Pacemaker | ||
ansible.builtin.systemd: | ||
name: pacemaker | ||
state: started | ||
enabled: true | ||
- name: wait for pacemaker | ||
command: "{{ crm_command_path }} status" | ||
register: result | ||
until: result.rc == 0 | ||
retries: 3 | ||
delay: 1 | ||
- name: Disable stonith | ||
command: "{{ crm_command_path }} configure property stonith-enabled=false" | ||
run_once: true | ||
when: groups['valid_machine'] is undefined | ||
when: | ||
- groups['valid_machine'] is defined | ||
- "'unconfigured_machine_group' in group_names" | ||
|
||
# run extra CRM commands | ||
- name: run extra CRM configuration commands for vm-mgr http api | ||
command: | ||
cmd: crm -d config load update - | ||
stdin: "{{ vmmgrapi_cmd_list }}" | ||
when: | ||
- enable_vmmgr_http_api is defined | ||
- enable_vmmgr_http_api is true | ||
- admin_cluster_ip is defined | ||
run_once: true | ||
register: vmmgrapi_cmd_list_task | ||
changed_when: "'CIB commit successful' in vmmgrapi_cmd_list_task.stdout" | ||
vars: | ||
vmmgrapi_cmd_list: | | ||
primitive ClusterIP IPaddr2 params ip={{ admin_cluster_ip }} cidr_netmask=32 op monitor interval=30s meta target-role=Started | ||
primitive vmmgrapi systemd:nginx.service op monitor interval=30s | ||
colocation vmmgrapi_colocation inf: ClusterIP vmmgrapi | ||
order order_ClusterIP_vmmgrapi ClusterIP vmmgrapi | ||
- name: run extra CRM configuration commands | ||
command: | ||
cmd: crm -d config load update - | ||
stdin: "{{ extra_crm_cmd_to_run }}" | ||
when: extra_crm_cmd_to_run is defined | ||
run_once: true | ||
register: extra_crm_cmd_to_run_task | ||
changed_when: "'CIB commit successful' in extra_crm_cmd_to_run_task.stdout" |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Copyright (C) 2024, Red Hat | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
--- | ||
crm_command_path: "/usr/local/bin/crm" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Copyright (C) 2024, Red Hat | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
--- | ||
crm_command_path: "crm" |