@richm @tomjelinek
Premise
I am currently implementing QDevice, QNetd, Diskless SBD for crmsh and there are some topics that are constantly being raised:
main.yml complexity: There are some tasks that should be converted into "runners" inside of shell folders. This way we can do more complex differences or reordering of tasks, if required.
- Pacemaker version: We need to add
__ha_cluster_pacemaker_version and handling, because of stonith > fencing changes as we are preloading some default properties.
- SBD might need split off as well, because there are some differences in SBD_OPTS and Timeout values.
- FQCN module names: Self explanatory
- 80 character line limit forces line breaks to conform with this limitation, which results in almost unreadable code and comments.
Proposed changes
I will complete current PR without going deeper into issues above, so subsequent changes can go separately.
1. Restructure
-
main:
- Leave only set vars, install packages, configure cluster, destroy cluster, qnetd, export
- Everything else should stay inside of shell runners, which will help us customize better.
-
Divergence of current structure: I want to try implementing using crm init, which is very rigid and opinionated. It does not work with current structure so it would have to come inside of shell_crmsh runner, but it is not possible with current main structure.
2. Pacemaker Version
This one is fairly simple as we need to drive logic based on versions now. Example:
# We need to query the Pacemaker version for version specific workflows.
# This is required for example for 'stonith' to 'fencing' switch in 3.0.1.
# Reason for noqa: Direct use of rpm removes dependency on python3-rpm.
- name: Get Pacemaker version # noqa command-instead-of-module
ansible.builtin.command:
cmd: "rpm -q --queryformat '%{VERSION}' pacemaker"
register: __ha_cluster_pacemaker_version_command
changed_when: false
- name: Set fact with Pacemaker version
ansible.builtin.set_fact:
__ha_cluster_pacemaker_version:
"{{ __ha_cluster_pacemaker_version_command.stdout }}"
Which can be consumed:
vars:
__property_name: >-
{{ 'fencing-enabled'
if __ha_cluster_pacemaker_version | d('1.0.0') is version('3.0.1', '>=')
else 'stonith-enabled' }}
3. Code Quality
- FQCN is already in
shell_crmsh task files, but it would be good idea to improve this in main and shell_pcs.
- Remove 80 character limit from tests and linting. Default 160 limit is good for readability and formatting.
- Module formatting: Switch like this will make this look better:
# Before
- name: Configure SBD
include_tasks: shell_{{ ha_cluster_pacemaker_shell }}/sbd.yml
# After
- name: Configure SBD
ansible.builtin.include_tasks:
file: "shell_{{ ha_cluster_pacemaker_shell }}/sbd.yml"
4. Loop Control
item should no longer be used as it breaks multi-layer loops so we need to start using loop_var more.
- This is also very useful for looping over list of dictionaries, because
label simplifies output.
@richm @tomjelinek
Premise
I am currently implementing QDevice, QNetd, Diskless SBD for
crmshand there are some topics that are constantly being raised:main.ymlcomplexity: There are some tasks that should be converted into "runners" inside of shell folders. This way we can do more complex differences or reordering of tasks, if required.__ha_cluster_pacemaker_versionand handling, because ofstonith>fencingchanges as we are preloading some default properties.Proposed changes
I will complete current PR without going deeper into issues above, so subsequent changes can go separately.
1. Restructure
main:
Divergence of current structure: I want to try implementing using
crm init, which is very rigid and opinionated. It does not work with current structure so it would have to come inside of shell_crmsh runner, but it is not possible with current main structure.2. Pacemaker Version
This one is fairly simple as we need to drive logic based on versions now. Example:
Which can be consumed:
3. Code Quality
shell_crmshtask files, but it would be good idea to improve this inmainandshell_pcs.4. Loop Control
itemshould no longer be used as it breaks multi-layer loops so we need to start usingloop_varmore.labelsimplifies output.