|
35 | 35 | ) |
36 | 36 | block: |
37 | 37 |
|
| 38 | + # Ensure that property 'stonith-enabled' is set to 'false' if no Stonith resources are defined. |
| 39 | + # NOTE: We cannot allow user set 'stonith-enabled' 'true' if there are no fencing resources. |
38 | 40 | - name: "SAP HA Prepare Pacemaker - (STONITH) Set to disabled when no fencing resource is defined" |
| 41 | + when: ha_cluster_cluster_properties is not defined # We cannot append to defined variable due to precedence. |
39 | 42 | ansible.builtin.set_fact: |
40 | | - sap_ha_pacemaker_cluster_cluster_properties: |
41 | | - "{{ sap_ha_pacemaker_cluster_cluster_properties | combine({'stonith-enabled': false}) }}" |
| 43 | + __sap_ha_pacemaker_cluster_cluster_properties: |
| 44 | + "{{ __sap_ha_pacemaker_cluster_cluster_properties | combine({'stonith-enabled': false}) }}" |
42 | 45 |
|
43 | 46 | - name: "SAP HA Prepare Pacemaker - Warn that there is no STONITH configured" |
44 | 47 | ansible.builtin.pause: |
|
53 | 56 |
|
54 | 57 | # END of block for disabling stonith |
55 | 58 |
|
56 | | -# Add additional stonith properties to sap_ha_pacemaker_cluster_cluster_properties |
57 | | -# Checks if pcmk_delay_max is defined and non zero, then multiples it by 2. |
| 59 | +# Stonith cluster properties |
| 60 | +# Property 'concurrent-fencing' is 'false' by default, but Scale-Out requires 'true'. |
| 61 | +# NOTE: Reversed combine ensures that user defined values are retained. |
| 62 | +# TODO: Enable during implementation of Scale-Out. |
| 63 | +# - name: "SAP HA Prepare Pacemaker - Disable concurrent-fencing in properties" |
| 64 | +# when: ha_cluster_cluster_properties is not defined # We cannot append to defined variable due to precedence. |
| 65 | +# ansible.builtin.set_fact: |
| 66 | +# __sap_ha_pacemaker_cluster_cluster_properties: |
| 67 | +# "{{ {'concurrent-fencing': true} | combine(__sap_ha_pacemaker_cluster_cluster_properties) }}" |
| 68 | +# when: |
| 69 | +# - sap_ha_pacemaker_cluster_host_type | select('search', 'hana_scaleout') | length > 0 |
| 70 | + |
| 71 | + |
| 72 | +# Property 'priority-fencing-delay' is required to ensure proper fencing order. |
| 73 | +# The value is based on 'pcmk_delay_max', if it is defined in '__sap_ha_pacemaker_cluster_stonith_default'. |
| 74 | +# This task will not change property if it is already defined. |
| 75 | +# NOTE: Reversed combine ensures that user defined values are retained. |
58 | 76 | - name: "SAP HA Prepare Pacemaker - (STONITH) Add priority-fencing-delay property" |
| 77 | + when: ha_cluster_cluster_properties is not defined # We cannot append to defined variable due to precedence. |
59 | 78 | ansible.builtin.set_fact: |
60 | | - sap_ha_pacemaker_cluster_cluster_properties: |
61 | | - "{{ sap_ha_pacemaker_cluster_cluster_properties | combine({'priority-fencing-delay': |
62 | | - __sap_ha_pacemaker_cluster_stonith_default.options.pcmk_delay_max | int * 2}) |
63 | | - if __sap_ha_pacemaker_cluster_stonith_default.options.pcmk_delay_max is defined |
64 | | - and __sap_ha_pacemaker_cluster_stonith_default.options.pcmk_delay_max | int != 0 |
65 | | - else sap_ha_pacemaker_cluster_cluster_properties }}" |
| 79 | + __sap_ha_pacemaker_cluster_cluster_properties: |
| 80 | + "{{ {'priority-fencing-delay': (__pcmk_delay_max | int * 2 |
| 81 | + if __pcmk_delay_max is defined and __pcmk_delay_max | int != 0 |
| 82 | + else 30)} | combine(__sap_ha_pacemaker_cluster_cluster_properties) |
| 83 | + if __sap_ha_pacemaker_cluster_cluster_properties['priority-fencing-delay'] is not defined |
| 84 | + else __sap_ha_pacemaker_cluster_cluster_properties }}" |
| 85 | + vars: |
| 86 | + __pcmk_delay_max: |
| 87 | + "{{ (__sap_ha_pacemaker_cluster_stonith_default['instance_attrs'][0]['attrs'] |
| 88 | + | selectattr('name', 'equalto', 'pcmk_delay_max') | first).value }}" |
66 | 89 |
|
67 | | -- name: "SAP HA Prepare Pacemaker - (STONITH) Define cluster properties" |
| 90 | +# Ensure that property 'concurrent-fencing' is set to 'true' for Azure. |
| 91 | +# Source: https://learn.microsoft.com/en-us/azure/sap/workloads/high-availability-guide-suse-pacemaker?tabs=msi#create-a-fencing-device-on-the-pacemaker-cluster |
| 92 | +# NOTE: Reversed combine ensures that user defined values are retained. |
| 93 | +- name: "SAP HA Prepare Pacemaker - (STONITH) - MSAZURE VM - Add cluster property 'concurrent-fencing'" |
68 | 94 | when: |
69 | | - - sap_ha_pacemaker_cluster_cluster_properties is defined |
70 | | - - sap_ha_pacemaker_cluster_cluster_properties is iterable |
71 | | - - sap_ha_pacemaker_cluster_cluster_properties | length > 0 |
| 95 | + - ha_cluster_cluster_properties is not defined # We cannot append to defined variable due to precedence. |
| 96 | + - __sap_ha_pacemaker_cluster_platform == "cloud_msazure_vm" |
72 | 97 | ansible.builtin.set_fact: |
73 | | - __sap_ha_pacemaker_cluster_cluster_properties: "{{ __sap_ha_pacemaker_cluster_cluster_properties | d([]) + __stonith_properties }}" |
74 | | - vars: |
75 | | - __stonith_properties: |
| 98 | + __sap_ha_pacemaker_cluster_cluster_properties: |
| 99 | + "{{ {'concurrent-fencing': true} | combine(__sap_ha_pacemaker_cluster_cluster_properties) }}" |
| 100 | + |
| 101 | + |
| 102 | +# Prepare structure compatible with the variable 'ha_cluster_cluster_properties'. |
| 103 | +- name: "SAP HA Prepare Pacemaker - (STONITH) Define cluster properties" |
| 104 | + # This task is skipped if 'ha_cluster_cluster_properties' is defined, as both structures are different. |
| 105 | + when: ha_cluster_cluster_properties is not defined # We cannot append to defined variable due to precedence. |
| 106 | + ansible.builtin.set_fact: |
| 107 | + __sap_ha_pacemaker_cluster_cluster_properties: |
76 | 108 | - attrs: |- |
77 | | - {% set attrs = __sap_ha_pacemaker_cluster_cluster_properties | map(attribute='attrs') | flatten -%} |
78 | | - {%- for default_cluster_properties in (sap_ha_pacemaker_cluster_cluster_properties | dict2items) -%} |
79 | | - {% if default_cluster_properties.key not in |
80 | | - (__sap_ha_pacemaker_cluster_cluster_properties | map(attribute='attrs') | flatten | map(attribute='name')) -%} |
81 | | - {% set role_attrs = attrs.extend([ |
82 | | - { |
83 | | - 'name': default_cluster_properties.key, |
84 | | - 'value': default_cluster_properties.value |
85 | | - } |
86 | | - ]) -%} |
87 | | - {%- endif %} |
| 109 | + {% set attrs = [] -%} |
| 110 | + {%- for default_cluster_properties in (__sap_ha_pacemaker_cluster_cluster_properties | dict2items) -%} |
| 111 | + {% set role_attrs = attrs.extend([ |
| 112 | + { |
| 113 | + 'name': default_cluster_properties.key, |
| 114 | + 'value': default_cluster_properties.value |
| 115 | + } |
| 116 | + ]) -%} |
88 | 117 | {%- endfor %} |
89 | 118 | {{ attrs }} |
90 | 119 |
|
|
0 commit comments