From c33cc43148b3b20d7588bddb39d96c3f463023b1 Mon Sep 17 00:00:00 2001 From: Marcel Mamula Date: Wed, 14 Feb 2024 09:54:12 +0000 Subject: [PATCH 1/3] feat: SLES15 enablement, HAE detection --- README.md | 2 +- tasks/main.yml | 6 +-- .../check-and-prepare-role-variables.yml | 38 ++++++++++++------- tasks/shell_crmsh/cluster-destroy-crm.yml | 5 +++ tasks/shell_crmsh/cluster-setup-corosync.yml | 7 ++++ vars/Suse.yml | 6 ++- 6 files changed, 45 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 1d4673a0..1f7e0ff3 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ An Ansible role for managing High Availability Clustering. * Compatible OS * RHEL 8.3+, Fedora 31+ - * SLES 15 SP4+ with HA extension, SLES4SAP 15 SP4+ + * SLES 15 SP5+ with HA extension, SLES4SAP 15 SP5+ * Systems running RHEL are expected to be registered and have High-Availability repositories accessible, and ResilientStorage repositories accessible if using `ha_cluster_enable_repos_resilient_storage` diff --git a/tasks/main.yml b/tasks/main.yml index 3e20c8a3..31753026 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -8,6 +8,9 @@ when: - ha_cluster_enable_repos +- name: Check and prepare role variables + include_tasks: shell_{{ ha_cluster_pacemaker_shell }}/check-and-prepare-role-variables.yml # yamllint disable-line rule:line-length + - name: Install role essential packages package: name: "{{ @@ -18,9 +21,6 @@ use: "{{ (__ha_cluster_is_ostree | d(false)) | ternary('ansible.posix.rhel_rpm_ostree', omit) }}" -- name: Check and prepare role variables - include_tasks: shell_{{ ha_cluster_pacemaker_shell }}/check-and-prepare-role-variables.yml # yamllint disable-line rule:line-length - # The user is created by installing pacemaker packages. We just need to set the # password. - name: Set hacluster password diff --git a/tasks/shell_crmsh/check-and-prepare-role-variables.yml b/tasks/shell_crmsh/check-and-prepare-role-variables.yml index 08b2a75f..a2f68947 100644 --- a/tasks/shell_crmsh/check-and-prepare-role-variables.yml +++ b/tasks/shell_crmsh/check-and-prepare-role-variables.yml @@ -2,6 +2,30 @@ --- - name: Check cluster configuration variables block: + # High Availability Extension is required for cluster setup as well + # as qnetd/qdevice configuration. + - name: Gather package facts + ansible.builtin.package_facts: + manager: auto + + - name: Check High Availability Extension presence using product file + ansible.builtin.stat: + path: /etc/products.d/sle-ha.prod + register: __ha_cluster_ha_ext_stat + + # Registering HA Extension creates file /etc/products.d/sle-ha.prod and + # installs rpm sle-ha-release. Cluster software is not installed. + - name: Assert that High Availability Extension is present + ansible.builtin.assert: + that: + - "'sle-ha-release' in ansible_facts.packages" + - __ha_cluster_ha_ext_stat.stat.exists + success_msg: "High Availability Extension was detected." + fail_msg: "High Availability Extension is not registered! + Register HA Extension before executing again." + # Fatal fail will occur if any of cluster nodes is missing HAE + any_errors_fatal: true + - name: Fail if passwords are not specified ansible.builtin.fail: msg: "{{ item }} must be specified" @@ -59,20 +83,6 @@ loop: "{{ ha_cluster_stonith_levels }}" run_once: true -- name: Collect service information - ansible.builtin.service_facts: - -- name: Assert that required services are available - ansible.builtin.assert: - that: "'{{ item }}' in ansible_facts.services" - fail_msg: >- - The service '{{ item }}' was not found on this system. Ensure that this - service is available before running this role. - success_msg: >- - The service '{{ item }}' was discovered on this system. - loop: - - 'logd.service' - - name: Discover cluster node names ansible.builtin.set_fact: __ha_cluster_node_name: "{{ ha_cluster.node_name | d(inventory_hostname) }}" diff --git a/tasks/shell_crmsh/cluster-destroy-crm.yml b/tasks/shell_crmsh/cluster-destroy-crm.yml index ea3e60d1..5191bdab 100644 --- a/tasks/shell_crmsh/cluster-destroy-crm.yml +++ b/tasks/shell_crmsh/cluster-destroy-crm.yml @@ -15,6 +15,10 @@ selectattr('stat.exists', 'equalto', false) | list | length > 0 changed_when: true +- name: Populate service facts + ansible.builtin.service_facts: + +# Conditional added to skip qdevice in case qdevice was not configured - name: Stop cluster daemons ansible.builtin.service: name: "{{ item }}" @@ -23,6 +27,7 @@ - pacemaker - corosync - corosync-qdevice + when: item in ansible_facts.services - name: Backup configuration files by renaming to _backup ansible.builtin.copy: diff --git a/tasks/shell_crmsh/cluster-setup-corosync.yml b/tasks/shell_crmsh/cluster-setup-corosync.yml index 44991303..6809249a 100644 --- a/tasks/shell_crmsh/cluster-setup-corosync.yml +++ b/tasks/shell_crmsh/cluster-setup-corosync.yml @@ -13,6 +13,13 @@ check_mode: false changed_when: not ansible_check_mode +# Gather facts for corosync template creation +- name: Gather facts for corosync template + ansible.builtin.setup: + filter: + - eth0 + - eth1 + - name: Generate corosync.conf using template ansible.builtin.template: src: crmsh_corosync.j2 diff --git a/vars/Suse.yml b/vars/Suse.yml index dc18a4b3..1ea49e13 100644 --- a/vars/Suse.yml +++ b/vars/Suse.yml @@ -5,6 +5,8 @@ ha_cluster_pacemaker_shell: crmsh # Placeholder with pcs name __ha_cluster_pcs_provider: crm +# ClusterTools2 removed because it is SLES4SAP specific +# patterns-ha-ha_sles requires SLES 15 SP5+ or SLES4SAP 15 __ha_cluster_role_essential_packages: - 'pacemaker' - 'corosync' @@ -16,11 +18,13 @@ __ha_cluster_role_essential_packages: - 'cluster-glue' - 'socat' - 'libxml2-tools' - - 'ClusterTools2' - 'rsyslog' __ha_cluster_fullstack_node_packages: [] +__ha_cluster_qdevice_node_packages: + - corosync-qdevice + __ha_cluster_sbd_packages: - sbd - open-iscsi From cab069a529906dccf0e1721a362b2747ae0e58ad Mon Sep 17 00:00:00 2001 From: Marcel Mamula Date: Wed, 14 Feb 2024 13:44:31 +0000 Subject: [PATCH 2/3] reverted main ordering, moved HAE detection --- tasks/enable-repositories/Suse.yml | 24 +++++++++++++++++++ tasks/main.yml | 6 ++--- .../check-and-prepare-role-variables.yml | 24 ------------------- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/tasks/enable-repositories/Suse.yml b/tasks/enable-repositories/Suse.yml index c07e39f8..2ae1bc89 100644 --- a/tasks/enable-repositories/Suse.yml +++ b/tasks/enable-repositories/Suse.yml @@ -1,3 +1,27 @@ # SPDX-License-Identifier: MIT --- # All required repositories are already part of SLES for SAP 15 SP5+. + +# High Availability Extension is required for cluster setup as well +# as qnetd/qdevice configuration. +- name: Gather package facts + ansible.builtin.package_facts: + manager: auto + +- name: Check High Availability Extension presence using product file + ansible.builtin.stat: + path: /etc/products.d/sle-ha.prod + register: __ha_cluster_ha_ext_stat + +# Registering HA Extension creates file /etc/products.d/sle-ha.prod and +# installs rpm sle-ha-release. Cluster software is not installed. +- name: Assert that High Availability Extension is present + ansible.builtin.assert: + that: + - "'sle-ha-release' in ansible_facts.packages" + - __ha_cluster_ha_ext_stat.stat.exists + success_msg: "High Availability Extension was detected." + fail_msg: "High Availability Extension is not registered! + Register HA Extension before executing again." + # Fatal fail will occur if any of cluster nodes is missing HAE + any_errors_fatal: true diff --git a/tasks/main.yml b/tasks/main.yml index 31753026..3e20c8a3 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -8,9 +8,6 @@ when: - ha_cluster_enable_repos -- name: Check and prepare role variables - include_tasks: shell_{{ ha_cluster_pacemaker_shell }}/check-and-prepare-role-variables.yml # yamllint disable-line rule:line-length - - name: Install role essential packages package: name: "{{ @@ -21,6 +18,9 @@ use: "{{ (__ha_cluster_is_ostree | d(false)) | ternary('ansible.posix.rhel_rpm_ostree', omit) }}" +- name: Check and prepare role variables + include_tasks: shell_{{ ha_cluster_pacemaker_shell }}/check-and-prepare-role-variables.yml # yamllint disable-line rule:line-length + # The user is created by installing pacemaker packages. We just need to set the # password. - name: Set hacluster password diff --git a/tasks/shell_crmsh/check-and-prepare-role-variables.yml b/tasks/shell_crmsh/check-and-prepare-role-variables.yml index a2f68947..33f870fd 100644 --- a/tasks/shell_crmsh/check-and-prepare-role-variables.yml +++ b/tasks/shell_crmsh/check-and-prepare-role-variables.yml @@ -2,30 +2,6 @@ --- - name: Check cluster configuration variables block: - # High Availability Extension is required for cluster setup as well - # as qnetd/qdevice configuration. - - name: Gather package facts - ansible.builtin.package_facts: - manager: auto - - - name: Check High Availability Extension presence using product file - ansible.builtin.stat: - path: /etc/products.d/sle-ha.prod - register: __ha_cluster_ha_ext_stat - - # Registering HA Extension creates file /etc/products.d/sle-ha.prod and - # installs rpm sle-ha-release. Cluster software is not installed. - - name: Assert that High Availability Extension is present - ansible.builtin.assert: - that: - - "'sle-ha-release' in ansible_facts.packages" - - __ha_cluster_ha_ext_stat.stat.exists - success_msg: "High Availability Extension was detected." - fail_msg: "High Availability Extension is not registered! - Register HA Extension before executing again." - # Fatal fail will occur if any of cluster nodes is missing HAE - any_errors_fatal: true - - name: Fail if passwords are not specified ansible.builtin.fail: msg: "{{ item }} must be specified" From 89ad0672255a3bffa6dc871d340233f3f9d232ce Mon Sep 17 00:00:00 2001 From: Marcel Mamula Date: Thu, 15 Feb 2024 09:06:44 +0000 Subject: [PATCH 3/3] correction for .service names --- tasks/shell_crmsh/cluster-destroy-crm.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tasks/shell_crmsh/cluster-destroy-crm.yml b/tasks/shell_crmsh/cluster-destroy-crm.yml index 5191bdab..31a60668 100644 --- a/tasks/shell_crmsh/cluster-destroy-crm.yml +++ b/tasks/shell_crmsh/cluster-destroy-crm.yml @@ -24,9 +24,9 @@ name: "{{ item }}" state: stopped # noqa no-handler loop: - - pacemaker - - corosync - - corosync-qdevice + - pacemaker.service + - corosync.service + - corosync-qdevice.service when: item in ansible_facts.services - name: Backup configuration files by renaming to _backup