Skip to content

Commit

Permalink
feat: easily install cloud agents
Browse files Browse the repository at this point in the history
  • Loading branch information
tomjelinek committed Feb 28, 2024
1 parent b92ac74 commit 6039c45
Show file tree
Hide file tree
Showing 12 changed files with 135 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ variables:
- cluster_advanced_knet_full
- cluster_advanced_knet_implicit
- cluster_advanced_udp_full
- cluster_basic_cloud_packages
- cluster_basic_custom_fence_agents
- cluster_basic_custom_packages
- cluster_basic_custom_pcsd_tls_cert_role
Expand Down
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,17 @@ boolean, default: `true`
If set to `true`, cluster services will be configured to start on boot. If set
to `false`, cluster services will be configured not to start on boot.

#### `ha_cluster_install_cloud_agents`

boolean, default: `false`

The role automatically installs needed HA Cluster packages. However, resource
and fence agents for cloud environments are not installed by default on RHEL.
If you need those to be installed, set this variable to `true`. Alternatively,
you can specify those packages in
[`ha_cluster_fence_agent_packages`](#ha_cluster_fence_agent_packages) and
[`ha_cluster_extra_packages`](#ha_cluster_extra_packages) variables.

#### `ha_cluster_fence_agent_packages`

list of fence agent packages to install, default: fence-agents-all, fence-virt
Expand All @@ -136,8 +147,8 @@ This variable can be used to install additional packages not installed
automatically by the role, for example custom resource agents.

It is possible to specify fence agents here as well. However,
`ha_cluster_fence_agent_packages` is preferred for that, so that its default
value is overridden.
[`ha_cluster_fence_agent_packages`](#ha_cluster_fence_agent_packages) is
preferred for that, so that its default value is overridden.

#### `ha_cluster_hacluster_password`

Expand Down
2 changes: 1 addition & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ ha_cluster_cluster_present: true

ha_cluster_start_on_boot: true

ha_cluster_install_cloud_agents: false
ha_cluster_extra_packages: []

# Default fence agent packages are defined in respective os_family var files
ha_cluster_fence_agent_packages:
"{{ __ha_cluster_fence_agent_packages_default }}"
Expand Down
3 changes: 3 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
+
ha_cluster_sbd_enabled | ternary(__ha_cluster_sbd_packages, [])
+
ha_cluster_install_cloud_agents |
ternary(__ha_cluster_cloud_agents_packages, [])
+
ha_cluster_fence_agent_packages }}"
state: present
use: "{{ (__ha_cluster_is_ostree | d(false)) |
Expand Down
69 changes: 69 additions & 0 deletions tests/tests_cluster_basic_cloud_packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# SPDX-License-Identifier: MIT
---
- name: Minimal cluster configuration, install cloud agents
hosts: all
vars_files: vars/main.yml
vars:
ha_cluster_cluster_name: test-cluster
ha_cluster_install_cloud_agents: true
__test_agents_rhel_8:
- resource-agents-aliyun
- resource-agents-gcp
- fence-agents-aliyun
- fence-agents-aws
- fence-agents-azure-arm
- fence-agents-gce
__test_agents_rhel_9:
- resource-agents-cloud
- fence-agents-aliyun
- fence-agents-aws
- fence-agents-azure-arm
- fence-agents-compute
- fence-agents-gce
- fence-agents-ibm-powervs
- fence-agents-ibm-vpc
- fence-agents-kubevirt
- fence-agents-openstack
__test_agents: "{{ (ansible_facts['distribution_major_version'] == '8') |
ternary(__test_agents_rhel_8, __test_agents_rhel_9) }}"

tasks:
- name: Run test
tags: tests::verify
when: ansible_facts['distribution'] == "RedHat"
block:
- name: Set up test environment
include_role:
name: linux-system-roles.ha_cluster
tasks_from: test_setup.yml

- name: Skip test on ostree systems
meta: end_host
when: __ha_cluster_is_ostree | d(false)

- name: Ensure cloud agents are not installed
package:
name: "{{ __test_agents }}"
state: absent

- name: Run HA Cluster role
include_role:
name: linux-system-roles.ha_cluster
public: true

- name: Get packages status
package_facts:

- name: Check installed packages
assert:
that:
- "item in ansible_facts.packages"
loop: "{{ __test_agents }}"

- name: Check cluster status
include_tasks: tasks/assert_cluster_running.yml

- name: Message
debug:
msg: This test is RHEL specific
when: ansible_facts['distribution'] != "RedHat"
8 changes: 8 additions & 0 deletions vars/CentOS_8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,11 @@ __ha_cluster_repos:
name: HighAvailability
- id: resilientstorage
name: ResilientStorage

__ha_cluster_cloud_agents_packages:
- resource-agents-aliyun
- resource-agents-gcp
- fence-agents-aliyun
- fence-agents-aws
- fence-agents-azure-arm
- fence-agents-gce
12 changes: 12 additions & 0 deletions vars/CentOS_9.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,15 @@ __ha_cluster_repos:
name: HighAvailability
- id: resilientstorage
name: ResilientStorage

__ha_cluster_cloud_agents_packages:
- resource-agents-cloud
- fence-agents-aliyun
- fence-agents-aws
- fence-agents-azure-arm
- fence-agents-compute
- fence-agents-gce
- fence-agents-ibm-powervs
- fence-agents-ibm-vpc
- fence-agents-kubevirt
- fence-agents-openstack
4 changes: 4 additions & 0 deletions vars/Fedora.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# SPDX-License-Identifier: MIT
---
# Put internal variables here with Fedora specific values.
__ha_cluster_cloud_agents_packages: []
2 changes: 2 additions & 0 deletions vars/RedHat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ __ha_cluster_fullstack_node_packages:
- pacemaker
- openssl # used in the role for generating preshared keys

__ha_cluster_cloud_agents_packages: []

__ha_cluster_qdevice_node_packages:
- corosync-qdevice
# dependencies of a script to set up qdevice certificates
Expand Down
8 changes: 8 additions & 0 deletions vars/RedHat_8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,11 @@ __ha_cluster_repos:
name: High Availability
- id: rhel-8-for-{{ ansible_architecture }}-resilientstorage-rpms
name: Resilient Storage

__ha_cluster_cloud_agents_packages:
- resource-agents-aliyun
- resource-agents-gcp
- fence-agents-aliyun
- fence-agents-aws
- fence-agents-azure-arm
- fence-agents-gce
12 changes: 12 additions & 0 deletions vars/RedHat_9.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,15 @@ __ha_cluster_repos:
name: High Availability
- id: rhel-9-for-{{ ansible_architecture }}-resilientstorage-rpms
name: Resilient Storage

__ha_cluster_cloud_agents_packages:
- resource-agents-cloud
- fence-agents-aliyun
- fence-agents-aws
- fence-agents-azure-arm
- fence-agents-compute
- fence-agents-gce
- fence-agents-ibm-powervs
- fence-agents-ibm-vpc
- fence-agents-kubevirt
- fence-agents-openstack
2 changes: 2 additions & 0 deletions vars/Suse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ __ha_cluster_role_essential_packages:

__ha_cluster_fullstack_node_packages: []

__ha_cluster_cloud_agents_packages: []

__ha_cluster_qdevice_node_packages:
- corosync-qdevice

Expand Down

0 comments on commit 6039c45

Please sign in to comment.