generated from linux-system-roles/template
-
Notifications
You must be signed in to change notification settings - Fork 23
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
feat: crmsh workflow and SUSE support #186
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
88919c1
crmsh workflow and SUSE support added
marcelmamula 501a6ea
review corrections, no_log, bool, formatting
marcelmamula fbeecba
fixes for linting, maintenance, packages
marcelmamula 52c1f16
Update tasks/shell_crmsh/crm-cib-resource-primitive.yml
marcelmamula 7bdeebe
__ha_cluster_fence_agent_packages_final added
marcelmamula 8eab942
ha_cluster_fence_agent_packages defaults update
marcelmamula File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,3 @@ | ||
# SPDX-License-Identifier: MIT | ||
--- | ||
# All required repositories are already part of SLES for SAP 15 SP5+. |
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
Empty file.
marcelmamula marked this conversation as resolved.
Show resolved
Hide resolved
|
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,128 @@ | ||
# SPDX-License-Identifier: MIT | ||
--- | ||
- name: Check cluster configuration variables | ||
block: | ||
- name: Fail if passwords are not specified | ||
ansible.builtin.fail: | ||
msg: "{{ item }} must be specified" | ||
when: | ||
- lookup("vars", item, default="") | string | length < 1 | ||
- ha_cluster_cluster_present | bool | ||
loop: | ||
- ha_cluster_hacluster_password | ||
run_once: true | ||
marcelmamula marked this conversation as resolved.
Show resolved
Hide resolved
|
||
no_log: true | ||
|
||
- name: Fail if nodes do not have the same number of SBD devices specified | ||
ansible.builtin.fail: | ||
msg: All nodes must have the same number of SBD devices specified | ||
when: | ||
- ha_cluster_cluster_present | bool | ||
- ha_cluster_sbd_enabled | bool | ||
- > | ||
ansible_play_hosts | ||
| map('extract', hostvars, ['ha_cluster', 'sbd_devices']) | ||
| map('default', [], true) | ||
| map('length') | unique | length > 1 | ||
run_once: true | ||
|
||
# Running a qnetd on a cluster node does't make sense, fencing would make | ||
# the qnetd unavailable, even if temporarily. | ||
- name: Fail if configuring qnetd on a cluster node | ||
ansible.builtin.fail: | ||
msg: > | ||
Qnetd cannot be configured on a cluster node - | ||
'ha_cluster_cluster_present' and 'ha_cluster_qnetd.present' cannot | ||
be both set to true | ||
when: | ||
- ha_cluster_cluster_present | bool | ||
- ha_cluster_qnetd.present | d(false) | ||
|
||
- name: Fail if no valid level is specified for a fencing level | ||
ansible.builtin.fail: | ||
msg: Specify 'level' 1..9 for each fencing level | ||
when: | ||
- not((item.level | d() | int) > 0 and (item.level | d() | int) < 10) | ||
loop: "{{ ha_cluster_stonith_levels }}" | ||
run_once: true | ||
|
||
- name: Fail if no target is specified for a fencing level | ||
ansible.builtin.fail: | ||
msg: > | ||
Specify exactly one of 'target', 'target_pattern', 'target_attribute' | ||
for each fencing level | ||
when: | ||
- > | ||
[item.target is defined, | ||
item.target_pattern is defined, | ||
item.target_attribute is defined] | ||
| select | list | length != 1 | ||
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) }}" | ||
|
||
- name: Collect cluster node names | ||
ansible.builtin.set_fact: | ||
__ha_cluster_all_node_names: "{{ | ||
ansible_play_hosts | ||
| map('extract', hostvars, '__ha_cluster_node_name') | ||
| list | ||
}}" | ||
|
||
- name: Extract qdevice settings | ||
ansible.builtin.set_fact: | ||
__ha_cluster_qdevice_in_use: "{{ 'device' in ha_cluster_quorum }}" | ||
__ha_cluster_qdevice_model: "{{ ha_cluster_quorum.device.model | d('') }}" | ||
# This may set empty value, if it is not defined. Such value is not valid. | ||
# It will be caught by crm validation before we try using it in the role. | ||
__ha_cluster_qdevice_host: "{{ | ||
ha_cluster_quorum.device.model_options | d([]) | ||
| selectattr('name', 'match', '^host$') | ||
| map(attribute='value') | list | last | d('') | ||
}}" | ||
__ha_cluster_qdevice_crm_address: "{{ | ||
ha_cluster_quorum.device.model_options | d([]) | ||
| selectattr('name', 'match', '^crm-address$') | ||
| map(attribute='value') | list | last | d('') | ||
}}" | ||
|
||
- name: Figure out if ATB needs to be enabled for SBD | ||
ansible.builtin.set_fact: | ||
# SBD needs ATB enabled if all of these are true: | ||
# - sbd does not use devices (In check-and-prepare-role-variables.yml it | ||
# is verified that all nodes have the same number of devices defined. | ||
# Therefore it is enough to check devices of any single node.) | ||
# - number of nodes is even | ||
# - qdevice is not used | ||
__ha_cluster_sbd_needs_atb: "{{ | ||
ha_cluster_sbd_enabled | ||
and not ha_cluster.sbd_devices | d([]) | ||
and __ha_cluster_all_node_names | length is even | ||
and not __ha_cluster_qdevice_in_use | ||
}}" | ||
|
||
- name: Fail if SBD needs ATB enabled and the user configured ATB to be disabled | ||
ansible.builtin.fail: | ||
msg: Cannot set auto_tie_breaker to disabled when SBD needs it to be enabled | ||
when: | ||
- __ha_cluster_sbd_needs_atb | bool | ||
- ha_cluster_quorum.options | d([]) | ||
| selectattr('name', 'match', '^auto_tie_breaker$') | ||
| map(attribute='value') | select('in', ['0', 0]) | list | length > 0 |
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,4 @@ | ||
# SPDX-License-Identifier: MIT | ||
--- | ||
# Placeholder for potential auth tasks for crmsh | ||
# There are no authentication steps for crmsh currently. |
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,4 @@ | ||
# SPDX-License-Identifier: MIT | ||
--- | ||
# Placeholder for potential configure tasks for crmsh | ||
# There are no configure steps for crmsh currently. |
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,63 @@ | ||
# SPDX-License-Identifier: MIT | ||
--- | ||
- name: Get stat of cluster configuration files | ||
ansible.builtin.stat: | ||
path: "{{ item }}" | ||
loop: | ||
- /etc/corosync/corosync.conf | ||
- /var/lib/pacemaker/cib/cib.xml | ||
register: __ha_cluster_config_files_stat | ||
|
||
- name: Stop cluster | ||
ansible.builtin.command: | ||
cmd: crm cluster stop --all | ||
when: not __ha_cluster_config_files_stat.results | | ||
selectattr('stat.exists', 'equalto', false) | list | length > 0 | ||
changed_when: true | ||
|
||
- name: Stop cluster daemons | ||
ansible.builtin.service: | ||
name: "{{ item }}" | ||
state: stopped # noqa no-handler | ||
loop: | ||
- pacemaker | ||
- corosync | ||
- corosync-qdevice | ||
|
||
- name: Backup configuration files by renaming to _backup | ||
ansible.builtin.copy: | ||
src: "{{ config_file.item }}" | ||
dest: "/root/{{ config_file.stat.path | basename }}_backup" | ||
owner: root | ||
group: root | ||
mode: '0600' | ||
remote_src: true | ||
backup: true | ||
loop: "{{ __ha_cluster_config_files_stat.results }}" | ||
loop_control: | ||
loop_var: config_file | ||
when: config_file.stat.exists | ||
|
||
- name: Remove cluster configuration files | ||
ansible.builtin.file: | ||
path: "{{ config_file.item }}" | ||
state: absent | ||
loop: "{{ __ha_cluster_config_files_stat.results }}" | ||
loop_control: | ||
loop_var: config_file | ||
when: config_file.stat.exists | ||
|
||
- name: Find all files in /var/lib/pacemaker/cib/ | ||
ansible.builtin.find: | ||
paths: /var/lib/pacemaker/cib | ||
recurse: true | ||
patterns: | ||
- 'cib*' | ||
- 'shadow*' | ||
register: __ha_cluster_cib_files | ||
|
||
- name: Remove all files in /var/lib/pacemaker/cib/ | ||
ansible.builtin.file: | ||
path: "{{ item.path }}" | ||
state: absent | ||
loop: "{{ __ha_cluster_cib_files.files }}" |
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,53 @@ | ||
# SPDX-License-Identifier: MIT | ||
--- | ||
- name: Create a corosync.conf tempfile | ||
ansible.builtin.tempfile: | ||
state: file | ||
suffix: _ha_cluster_corosync_conf | ||
register: __ha_cluster_tempfile_corosync_conf | ||
run_once: true # noqa: run_once[task] | ||
# We always need to create corosync.conf file to see whether it's the same as | ||
# what is already present on the cluster nodes. However, we don't want to | ||
# report it as a change since the only thing which matters is copying the | ||
# resulting corosync.conf to cluster nodes. | ||
check_mode: false | ||
changed_when: not ansible_check_mode | ||
|
||
- name: Generate corosync.conf using template | ||
ansible.builtin.template: | ||
src: corosync.j2 | ||
dest: "{{ __ha_cluster_tempfile_corosync_conf.path }}" | ||
owner: root | ||
group: root | ||
mode: '0644' | ||
run_once: true # noqa: run_once[task] | ||
|
||
- name: Fetch created corosync.conf file | ||
ansible.builtin.slurp: | ||
src: "{{ __ha_cluster_tempfile_corosync_conf.path }}" | ||
register: __ha_cluster_data_corosync_conf | ||
run_once: true # noqa: run_once[task] | ||
when: __ha_cluster_tempfile_corosync_conf.path is defined | ||
|
||
- name: Distribute corosync.conf file | ||
ansible.builtin.copy: | ||
content: "{{ __ha_cluster_data_corosync_conf['content'] | b64decode }}" | ||
dest: /etc/corosync/corosync.conf | ||
owner: root | ||
group: root | ||
mode: '0644' | ||
register: __ha_cluster_distribute_corosync_conf | ||
when: __ha_cluster_data_corosync_conf is defined | ||
|
||
- name: Remove a corosync.conf tempfile | ||
ansible.builtin.file: | ||
path: "{{ __ha_cluster_tempfile_corosync_conf.path }}" | ||
state: absent | ||
when: __ha_cluster_tempfile_corosync_conf.path is defined | ||
run_once: true # noqa: run_once[task] | ||
# We always need to create corosync.conf file to see whether it's the same as | ||
# what is already present on the cluster nodes. However, we don't want to | ||
# report it as a change since the only thing which matters is copying the | ||
# resulting corosync.conf to cluster nodes. | ||
check_mode: false | ||
changed_when: not ansible_check_mode |
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,37 @@ | ||
# SPDX-License-Identifier: MIT | ||
--- | ||
- name: Get corosync authkey | ||
ansible.builtin.include_tasks: ../presharedkey.yml | ||
vars: | ||
preshared_key_label: corosync authkey | ||
preshared_key_src: "{{ ha_cluster_corosync_key_src }}" | ||
preshared_key_dest: /etc/corosync/authkey | ||
preshared_key_length: 256 | ||
|
||
- name: Distribute corosync authkey | ||
ansible.builtin.copy: | ||
content: "{{ __ha_cluster_some_preshared_key | b64decode }}" | ||
dest: /etc/corosync/authkey | ||
owner: root | ||
group: root | ||
mode: '0400' | ||
register: __ha_cluster_distribute_corosync_authkey | ||
marcelmamula marked this conversation as resolved.
Show resolved
Hide resolved
|
||
no_log: true | ||
|
||
- name: Get pacemaker authkey | ||
ansible.builtin.include_tasks: ../presharedkey.yml | ||
vars: | ||
preshared_key_label: pacemaker authkey | ||
preshared_key_src: "{{ ha_cluster_pacemaker_key_src }}" | ||
preshared_key_dest: /etc/pacemaker/authkey | ||
preshared_key_length: 256 | ||
|
||
- name: Distribute pacemaker authkey | ||
ansible.builtin.copy: | ||
content: "{{ __ha_cluster_some_preshared_key | b64decode }}" | ||
dest: /etc/pacemaker/authkey | ||
owner: hacluster | ||
group: haclient | ||
mode: '0400' | ||
register: __ha_cluster_distribute_pacemaker_authkey | ||
no_log: true |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that is correct place, because it would expose private variable to potential user inputs.
I have added conditional into main yesterday to do switch, depending if users added something to it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what you mean. I believe my proposal encapsulates the desired behavior - putting this in
defaults/main.yml
:This allows users to provide their own list of packages for
ha_cluster_fence_agent_packages
(which is the desired behavior - @tomjelinek please correct me if I'm wrong), and if the user does not specifyha_cluster_fence_agent_packages
, it will be set to the default value__ha_cluster_fence_agent_packages
. And, since__ha_cluster_fence_agent_packages
is defined for different values depending on the platform/version, we get the correct value forha_cluster_fence_agent_packages
for all platforms/versions.I think this is not the "Ansible way" to do this. I believe the correct way to do this is the way I outlined this above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@richm I have changed to in latest commit after conversation with @tomjelinek.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the default variable was renamed to
__ha_cluster_fence_agent_packages_default
, so this should beThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@richm Changes are completed and pushed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@richm this can be marked as resolved?