Skip to content

Commit

Permalink
fix: pipe replaced, ms reworked, extra validation
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelmamula committed Apr 3, 2024
1 parent 8d842e3 commit 34f455c
Show file tree
Hide file tree
Showing 13 changed files with 104 additions and 148 deletions.
44 changes: 0 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -676,41 +676,6 @@ This variable defines resource clones. The items are as follows:
You may take a look at
[an example](#creating-a-cluster-with-fencing-and-several-resources).

#### `ha_cluster_resource_master_slave_clones`

**[Master Slave clones are deprecated](
https://crmsh.github.io/man-4.3/#cmdhelp_configure_ms), but they are
supported for crmsh and SUSE servers.**

structure, default: no master slave resource clones

```yaml
ha_cluster_resource_master_slave_clones:
- resource_id: resource-to-be-cloned
id: custom-clone-id
meta_attrs:
- attrs:
- name: clone_meta_attribute1_name
value: clone_meta_attribute1_value
- name: clone_meta_attribute2_name
value: clone_meta_attribute2_value
```

This variable defines master slave resource clones. The items are as follows:

* `resource_id` (mandatory) - Resource to be cloned. The resource must be
defined in
[`ha_cluster_resource_primitives`](#ha_cluster_resource_primitives) or
[`ha_cluster_resource_groups`](#ha_cluster_resource_groups).
* `id` (optional) - Custom ID of the clone. If no ID is specified, it will be
generated. Warning will be emitted if this option is not supported by the
cluster.
* `meta_attrs` (optional) - List of sets of the clone's meta attributes.
Currently, only one set is supported.

You may take a look at
[an example](#creating-a-cluster-with-fencing-and-several-resources).

#### `ha_cluster_resource_bundles`

structure, default: no bundle resources
Expand Down Expand Up @@ -1700,15 +1665,6 @@ SBD stonith resource.
value: '1'
- resource_id: cloned-group
promotable: true
ha_cluster_resource_master_slave_clones:
- resource_id: resource-to-be-cloned
id: custom-clone-id
meta_attrs:
- attrs:
- name: clone-max
value: '2'
- name: clone-node-max
value: '1'
ha_cluster_resource_bundles:
- id: bundle-with-resource
resource-id: bundled-resource
Expand Down
1 change: 0 additions & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ ha_cluster_resource_operation_defaults: {}
ha_cluster_resource_primitives: []
ha_cluster_resource_groups: []
ha_cluster_resource_clones: []
ha_cluster_resource_master_slave_clones: []
ha_cluster_resource_bundles: []

ha_cluster_stonith_levels: []
Expand Down
15 changes: 4 additions & 11 deletions tasks/shell_crmsh/create-and-push-cib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
# status changes, resulting in shadow CIB outdated and unable to patch.
# Sleep is implemented to ensure that cluster have enough time to freeze
# to ensure CIB export consistency.
# Meta-attrs is-managed will conflict with maintenance mode. Option n
# will skip their deletion.
# Meta-attrs is-managed will conflict with maintenance mode as well as
# individual resource maintenance attributes. Expect will skip their deletion.
- name: Put cluster in maintenance mode to freeze cib changes
ansible.builtin.expect:
command: crm configure property maintenance-mode=true
Expand Down Expand Up @@ -142,13 +142,6 @@
resource_clone: "{{ item }}"
loop: "{{ ha_cluster_resource_clones }}"

## Added support for Master Slave clone resources
- name: Configure cluster master slave clone resources
ansible.builtin.include_tasks: crm-cib-resource-master-slave.yml
vars:
resource: "{{ item }}"
loop: "{{ ha_cluster_resource_master_slave_clones }}"

## Stonith levels - fencing_topology
- name: Configure stonith levels - fencing_topology
ansible.builtin.include_tasks: crm-cib-stonith-level.yml
Expand Down Expand Up @@ -275,8 +268,8 @@
when: __ha_cluster_cib_diff.rc == 1
run_once: true # noqa: run_once[task]

# Meta-attrs is-managed will conflict with maintenance mode. Option n
# will skip their deletion.
# Meta-attrs is-managed will conflict with maintenance mode as well as
# individual resource maintenance attributes. Expect will skip their deletion.
- name: Disable maintenance mode
ansible.builtin.expect:
command: crm configure property maintenance-mode=false
Expand Down
24 changes: 18 additions & 6 deletions tasks/shell_crmsh/crm-cib-constraint-colocation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Verify if constraint.resource_leader.id exists
- name: Verify resource_leader presence {{ constraint.resource_leader.id }}
ansible.builtin.command:
cmd: |
cmd: >-
crm -c {{ __ha_cluster_crm_shadow }}
configure show {{ constraint.resource_leader.id }}
register: __ha_cluster_constraint_resource_leader
Expand All @@ -14,7 +14,7 @@
# Verify if constraint.resourceresource_follower_leader.id exists
- name: Verify resource_follower presence {{ constraint.resource_follower.id }}
ansible.builtin.command:
cmd: |
cmd: >-
crm -c {{ __ha_cluster_crm_shadow }}
configure show {{ constraint.resource_follower.id }}
register: __ha_cluster_constraint_resource_follower
Expand All @@ -32,7 +32,7 @@
# Verify if Shadow CIB already contains same constraint id.
- name: Verify colocation constraint presence {{ __ha_cluster_constraint_id }}
ansible.builtin.command:
cmd: |
cmd: >-
crm -c {{ __ha_cluster_crm_shadow }}
configure show {{ __ha_cluster_constraint_id }}
register: __ha_cluster_constraint_status
Expand All @@ -42,16 +42,17 @@
# Delete constraint id in Shadow CIB to avoid errors during cibadmin patch.
- name: Delete present colocation constraint {{ __ha_cluster_constraint_id }}
ansible.builtin.command:
cmd: |
cmd: >-
crm --force -c {{ __ha_cluster_crm_shadow }}
configure delete {{ __ha_cluster_constraint_id }}
when: __ha_cluster_constraint_status.rc == 0
check_mode: false
changed_when: not ansible_check_mode

# Expect module is used to combat crmsh freezing when asking for user prompt
- name: Configure colocation constraint {{ __ha_cluster_constraint_id }}
ansible.builtin.command:
cmd: |
ansible.builtin.expect:
command: |
crm -c {{ __ha_cluster_crm_shadow }}
configure colocation {{ __ha_cluster_constraint_id }}
{% for option in constraint.options | d([]) if option.name == 'score' %}
Expand All @@ -76,5 +77,16 @@
{% for option in constraint.options | d([]) if option.name != 'score' %}
{{ option.name | quote }}={{ option.value | quote }}
{% endfor %}
responses:
".*Do you still want to commit.*": "n"
check_mode: false
changed_when: not ansible_check_mode
ignore_errors: true
register: __ha_cluster_crmsh_output

- name: Display crm command error details
ansible.builtin.fail:
msg: "{{ __ha_cluster_crmsh_output.stdout_lines }}"
when:
- __ha_cluster_crmsh_output is defined
- __ha_cluster_crmsh_output.rc != 0
22 changes: 17 additions & 5 deletions tasks/shell_crmsh/crm-cib-constraint-location.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Verify if constraint.resource.id exists
- name: Verify resource presence {{ constraint.resource.id }}
ansible.builtin.command:
cmd: |
cmd: >-
crm -c {{ __ha_cluster_crm_shadow }}
configure show {{ constraint.resource.id }}
register: __ha_cluster_constraint_resource
Expand All @@ -25,7 +25,7 @@
# Verify if Shadow CIB already contains same constraint id.
- name: Verify location constraint presence {{ __ha_cluster_constraint_id }}
ansible.builtin.command:
cmd: |
cmd: >-
crm -c {{ __ha_cluster_crm_shadow }}
configure show {{ __ha_cluster_constraint_id }}
register: __ha_cluster_constraint_status
Expand All @@ -35,16 +35,17 @@
# Delete constraint id in Shadow CIB to avoid errors during cibadmin patch.
- name: Delete present location constraint {{ __ha_cluster_constraint_id }}
ansible.builtin.command:
cmd: |
cmd: >-
crm --force -c {{ __ha_cluster_crm_shadow }}
configure delete {{ __ha_cluster_constraint_id }}
when: __ha_cluster_constraint_status.rc == 0
check_mode: false
changed_when: not ansible_check_mode

# Expect module is used to combat crmsh freezing when asking for user prompt
- name: Configure location constraint {{ __ha_cluster_constraint_id }}
ansible.builtin.command:
cmd: |
ansible.builtin.expect:
command: |
crm -c {{ __ha_cluster_crm_shadow }}
configure location {{ __ha_cluster_constraint_id }}
{% if constraint.resource.pattern | d() %}
Expand Down Expand Up @@ -72,5 +73,16 @@
{% for option in constraint.options | d([]) if option.name != 'score' %}
{{ option.name | quote }}={{ option.value | quote }}
{% endfor %}
responses:
".*Do you still want to commit.*": "n"
check_mode: false
changed_when: not ansible_check_mode
ignore_errors: true
register: __ha_cluster_crmsh_output

- name: Display crm command error details
ansible.builtin.fail:
msg: "{{ __ha_cluster_crmsh_output.stdout_lines }}"
when:
- __ha_cluster_crmsh_output is defined
- __ha_cluster_crmsh_output.rc != 0
22 changes: 17 additions & 5 deletions tasks/shell_crmsh/crm-cib-constraint-order.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# Verify if constraint.resource_then.id exists
- name: Verify resource_then presence {{ constraint.resource_then.id }}
ansible.builtin.command:
cmd: |
cmd: >-
crm -c {{ __ha_cluster_crm_shadow }}
configure show {{ constraint.resource_then.id }}
register: __ha_cluster_constraint_resource_then
Expand All @@ -31,7 +31,7 @@
# Verify if Shadow CIB already contains same constraint id.
- name: Verify order constraint presence {{ __ha_cluster_constraint_id }}
ansible.builtin.command:
cmd: |
cmd: >-
crm -c {{ __ha_cluster_crm_shadow }}
configure show {{ __ha_cluster_constraint_id }}
register: __ha_cluster_constraint_status
Expand All @@ -41,16 +41,17 @@
# Delete constraint id in Shadow CIB to avoid errors during cibadmin patch.
- name: Delete present order constraint {{ __ha_cluster_constraint_id }}
ansible.builtin.command:
cmd: |
cmd: >-
crm --force -c {{ __ha_cluster_crm_shadow }}
configure delete {{ __ha_cluster_constraint_id }}
when: __ha_cluster_constraint_status.rc == 0
check_mode: false
changed_when: not ansible_check_mode

# Expect module is used to combat crmsh freezing when asking for user prompt
- name: Configure order constraint {{ __ha_cluster_constraint_id }}
ansible.builtin.command:
cmd: |
ansible.builtin.expect:
command: |
crm -c {{ __ha_cluster_crm_shadow }}
configure order {{ __ha_cluster_constraint_id | quote }}
{% for option in constraint.options | d([]) if option.name == 'kind' %}
Expand All @@ -66,5 +67,16 @@
if option.name != 'score' and option.name != 'kind'%}
{{ option.name | quote }}={{ option.value | quote }}
{% endfor %}
responses:
".*Do you still want to commit.*": "n"
check_mode: false
changed_when: not ansible_check_mode
ignore_errors: true
register: __ha_cluster_crmsh_output

- name: Display crm command error details
ansible.builtin.fail:
msg: "{{ __ha_cluster_crmsh_output.stdout_lines }}"
when:
- __ha_cluster_crmsh_output is defined
- __ha_cluster_crmsh_output.rc != 0
30 changes: 21 additions & 9 deletions tasks/shell_crmsh/crm-cib-constraint-set.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
# Verify if resources in sets exist
- name: Verify set resources presence
ansible.builtin.command:
cmd: |
cmd: >-
crm -c {{ __ha_cluster_crm_shadow }}
configure show {% for set in constraint.resource_sets %}
{% for resource in set.resource_ids %}
{{ resource | quote }}
{% endfor %}
{% endfor %}
{% for resource in set.resource_ids %}
{{ resource | quote }}
{% endfor %}
{% endfor %}
register: __ha_cluster_constraint_resource_set
changed_when: false
failed_when:
Expand All @@ -25,7 +25,7 @@
# Verify if Shadow CIB already contains same constraint id.
- name: Verify constraint set presence {{ __ha_cluster_constraint_id }}
ansible.builtin.command:
cmd: |
cmd: >-
crm -c {{ __ha_cluster_crm_shadow }}
configure show {{ __ha_cluster_constraint_id }}
register: __ha_cluster_resource_status
Expand All @@ -35,17 +35,18 @@
# Delete constraint id in Shadow CIB to avoid errors during cibadmin patch.
- name: Delete present constraint set {{ __ha_cluster_constraint_id }}
ansible.builtin.command:
cmd: |
cmd: >-
crm --force -c {{ __ha_cluster_crm_shadow }}
configure delete {{ __ha_cluster_constraint_id }}
when: __ha_cluster_resource_status.rc == 0
check_mode: false
changed_when: not ansible_check_mode

# Expect module is used to combat crmsh freezing when asking for user prompt
- name: Configure {{ constraint_type }} constraint set '{{
__ha_cluster_constraint_id }}' # noqa name[template]
ansible.builtin.command:
cmd: |
ansible.builtin.expect:
command: |
crm -c {{ __ha_cluster_crm_shadow }} configure
{{ constraint_type if constraint_type != 'ticket' else 'rsc_ticket' }}
{{ __ha_cluster_constraint_id }}
Expand Down Expand Up @@ -81,5 +82,16 @@
{% for option in constraint.options | d([]) %}
{{ option.name | quote }}={{ option.value | quote }}
{% endfor %}
responses:
".*Do you still want to commit.*": "n"
check_mode: false
changed_when: not ansible_check_mode
ignore_errors: true
register: __ha_cluster_crmsh_output

- name: Display crm command error details
ansible.builtin.fail:
msg: "{{ __ha_cluster_crmsh_output.stdout_lines }}"
when:
- __ha_cluster_crmsh_output is defined
- __ha_cluster_crmsh_output.rc != 0
8 changes: 5 additions & 3 deletions tasks/shell_crmsh/crm-cib-constraint-ticket.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Verify if constraint.resource.id exists
- name: Verify resource presence {{ constraint.resource.id }}
ansible.builtin.command:
cmd: |
cmd: >-
crm -c {{ __ha_cluster_crm_shadow }}
configure show {{ constraint.resource.id }}
register: __ha_cluster_constraint_resource
Expand All @@ -21,7 +21,7 @@
# Verify if Shadow CIB already contains same constraint id.
- name: Verify ticket constraint presence {{ __ha_cluster_constraint_id }}
ansible.builtin.command:
cmd: |
cmd: >-
crm -c {{ __ha_cluster_crm_shadow }}
configure show {{ __ha_cluster_constraint_id }}
register: __ha_cluster_constraint_status
Expand All @@ -31,7 +31,7 @@
# Delete constraint id in Shadow CIB to avoid errors during cibadmin patch.
- name: Delete present ticket constraint {{ __ha_cluster_constraint_id }}
ansible.builtin.command:
cmd: |
cmd: >-
crm --force -c {{ __ha_cluster_crm_shadow }}
configure delete {{ __ha_cluster_constraint_id }}
when: __ha_cluster_constraint_status.rc == 0
Expand All @@ -54,5 +54,7 @@
{% for option in constraint.options | d([]) %}
{{ option.name | quote }}={{ option.value | quote }}
{% endfor %}
# crm can get stuck if it encounters error and expects prompt response.
timeout: 60
check_mode: false
changed_when: not ansible_check_mode
Loading

0 comments on commit 34f455c

Please sign in to comment.