Skip to content

Commit 8c8c0f4

Browse files
Configuration checks fixes (#134)
1 parent 686b826 commit 8c8c0f4

File tree

19 files changed

+279
-51
lines changed

19 files changed

+279
-51
lines changed

src/modules/configuration_check_module.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import logging
99
import time
1010
import json
11+
import re
1112
from typing import Optional, Dict, Any, List, Type
1213
from datetime import datetime
1314
from concurrent.futures import ThreadPoolExecutor
@@ -437,6 +438,8 @@ def validate_string(self, check: Check, collected_data: str) -> Dict[str, Any]:
437438

438439
if check.validator_args.get("strip_whitespace", True):
439440
expected = str(expected).strip()
441+
expected = re.sub(r'\s+', ' ', expected)
442+
collected = re.sub(r'\s+', ' ', collected)
440443

441444
if check.validator_args.get("case_insensitive", False):
442445
expected = expected.lower()

src/modules/get_cluster_status_db.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def _process_node_attributes(self, cluster_status_xml: ET.Element) -> Dict[str,
221221
HanaSRProvider.ANGI: {
222222
"clone_attr": f"hana_{self.database_sid}_clone_state",
223223
"sync_attr": (
224-
f"master-{self.hana_clone_resource_name}"
224+
f"master-{self.hana_primitive_resource_name}"
225225
if self.hana_clone_resource_name
226226
else f"master-rsc_SAPHanaCon_{self.database_sid.upper()}"
227227
+ f"_HDB{self.db_instance_number}"

src/roles/configuration_checks/tasks/files/network.yml

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -204,17 +204,20 @@ checks:
204204
command: |-
205205
az vm nic list --resource-group {{ CONTEXT.resource_group_name }} \
206206
--vm-name {{ CONTEXT.vm_name }} \
207-
--subscription {{ CONTEXT.subscription_id }} \
208-
--query "[].id" -o tsv | while read nic_id; do \
209-
nic=$(basename "$nic_id"); \
207+
--subscription {{ CONTEXT.subscription_id }} --query "[].id" -o tsv |
208+
while read -r nic_id; do
209+
nic=$(basename "$nic_id")
210210
az network nic show --resource-group {{ CONTEXT.resource_group_name }} --name "$nic" \
211-
--query "ipConfigurations[].{IP:privateIPAddress, Primary:primary}" -o tsv | \
212-
while IFS=$'\t' read -r ip is_primary; do \
213-
if [ "${is_primary,,}" = "true" ]; then \
214-
echo "$nic: $ip Primary"; \
215-
else \
216-
echo "$nic: $ip Secondary"; \
217-
fi; \
218-
done; \
211+
--query "ipConfigurations[].{IP:privateIPAddress, Primary:primary}" -o tsv |
212+
while read -r line; do
213+
ip=$(echo "$line" | awk '{print $1}')
214+
is_primary=$(echo "$line" | awk '{print $2}' | tr -d '\r\t ' | tr '[:upper:]' '[:lower:]')
215+
if [ "$is_primary" = "true" ]; then
216+
echo "$nic: $ip Primary"
217+
else
218+
echo "$nic: $ip Secondary"
219+
fi
220+
done
219221
done
222+
220223
report: *check

src/roles/configuration_checks/tasks/files/virtual_machine.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ checks:
413413
database_type: [*hana, *ase, *db2, *oracle]
414414
collector_type: *command
415415
collector_args:
416-
command: "/bin/mdatp health"
416+
command: "if command -v mdatp >/dev/null 2>&1; then mdatp health; else echo 'Microsoft Defender not installed'; fi"
417417
user: *root
418418
report: *section
419419

@@ -581,7 +581,7 @@ checks:
581581
database_type: [*hana, *ase, *db2, *oracle]
582582
collector_type: *command
583583
collector_args:
584-
command: "/bin/mdatp exclusion list"
584+
command: "if command -v mdatp >/dev/null 2>&1; then mdatp exclusion list; else echo 'Microsoft Defender not installed'; fi"
585585
user: *root
586586
report: *section
587587

src/roles/ha_db_hana/tasks/files/constants.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ RESOURCE_DEFAULTS:
112112
required: false
113113
instance_attributes:
114114
pcmk_delay_max:
115-
value: "15"
115+
value: ["15", "15s"]
116116
required: false
117117
pcmk_monitor_retries:
118118
value: "4"
@@ -142,7 +142,7 @@ RESOURCE_DEFAULTS:
142142
required: false
143143
instance_attributes:
144144
pcmk_delay_max:
145-
value: "15"
145+
value: ["15", "15s"]
146146
required: false
147147
pcmk_monitor_retries:
148148
value: "4"
@@ -492,7 +492,7 @@ RESOURCE_DEFAULTS:
492492
required: false
493493
instance_attributes:
494494
pcmk_delay_max:
495-
value: "15"
495+
value: ["15", "15s"]
496496
required: false
497497
pcmk_monitor_retries:
498498
value: "4"
@@ -815,7 +815,7 @@ GLOBAL_INI:
815815
value: "susHanaSR"
816816
required: true
817817
path:
818-
value: ["/usr/share/SAPHanaSR", "/hana/shared/myHooks"]
818+
value: ["/usr/share/SAPHanaSR-angi", "/hana/shared/myHooks"]
819819
required: true
820820
execution_order:
821821
value: "1"

src/roles/ha_db_hana/tasks/ha-config.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,104 @@
3333
when: (ansible_os_family | upper) == "SUSE"
3434
ansible.builtin.include_tasks: "roles/misc/tasks/get-saphanasr-provider.yml"
3535

36+
- name: "Pre validation: Get HANA resource id for saphanasr_angi"
37+
when: saphanasr_provider | default('SAPHanaSR') == "SAPHanaSR-angi"
38+
block:
39+
- name: "Pre validation: Get HANA clone resource id for saphanasr_angi"
40+
become: true
41+
ansible.builtin.shell: >-
42+
set -o pipefail && {{ commands
43+
| selectattr('name','equalto','get_hana_clone_resource_id_saphanasr_angi')
44+
| map(attribute=(ansible_os_family|upper))
45+
| first
46+
}}
47+
args:
48+
executable: /bin/bash
49+
changed_when: false
50+
register: hana_clone_resource_id
51+
failed_when: hana_clone_resource_id.rc != 0
52+
53+
- name: "Pre validation: Get HANA primitive resource id for saphanasr_angi"
54+
become: true
55+
ansible.builtin.shell: >-
56+
set -o pipefail && {{ commands
57+
| selectattr('name','equalto','get_hana_primitive_resource_id_saphanasr_angi')
58+
| map(attribute=(ansible_os_family|upper))
59+
| first
60+
}}
61+
args:
62+
executable: /bin/bash
63+
changed_when: false
64+
register: hana_primitive_resource_id
65+
failed_when: hana_primitive_resource_id.rc != 0
66+
67+
- name: "Pre validation: Set fact the hana_clone_resource_name"
68+
ansible.builtin.set_fact:
69+
hana_clone_resource_name: "{{ hana_clone_resource_id.stdout }}"
70+
hana_primitive_resource_name: "{{ hana_primitive_resource_id.stdout }}"
71+
72+
- name: "Pre validation: Get HANA Clone resource id"
73+
when: saphanasr_provider | default('SAPHanaSR') == "SAPHanaSR"
74+
block:
75+
- name: "Try master resource ID"
76+
become: true
77+
ansible.builtin.shell: >-
78+
set -o pipefail && {{ commands
79+
| selectattr('name','equalto','get_hana_clone_resource_id')
80+
| map(attribute=(ansible_os_family|upper))
81+
| first
82+
}}
83+
args:
84+
executable: /bin/bash
85+
changed_when: false
86+
register: hana_clone_resource_id
87+
failed_when: hana_clone_resource_id.rc != 0
88+
rescue:
89+
- name: "Try clone resource ID"
90+
become: true
91+
ansible.builtin.shell: >-
92+
set -o pipefail && {{ commands
93+
| selectattr('name','equalto','get_hana_clone_resource_id')
94+
| map(attribute='REDHAT')
95+
| first
96+
}}
97+
args:
98+
executable: /bin/bash
99+
changed_when: false
100+
register: hana_clone_resource_id
101+
failed_when: hana_clone_resource_id.rc != 0
102+
ignore_errors: true
103+
always:
104+
- name: "Test Execution: Set the resource name"
105+
when:
106+
- hana_clone_resource_id.rc == 0
107+
- hana_clone_resource_id.stdout is defined
108+
- hana_clone_resource_id.stdout | type_debug != 'NoneType'
109+
- hana_clone_resource_id.stdout | trim | length > 1
110+
ansible.builtin.set_fact:
111+
hana_clone_resource_name: "{{ hana_clone_resource_id.stdout }}"
112+
113+
- name: "Pre validation: Get HANA Primitive resource id"
114+
when: saphanasr_provider | default('SAPHanaSR') == "SAPHanaSR"
115+
block:
116+
- name: "Pre validation: Get HANA Primitive resource id"
117+
become: true
118+
ansible.builtin.shell: >-
119+
set -o pipefail && {{ commands
120+
| selectattr('name','equalto','get_hana_primitive_resource_id')
121+
| map(attribute=(ansible_os_family|upper))
122+
| first
123+
}}
124+
args:
125+
executable: /bin/bash
126+
changed_when: false
127+
register: hana_primitive_resource_id
128+
failed_when: hana_primitive_resource_id.rc != 0
129+
130+
- name: "Pre validation: Set fact the hana_primitive_resource_name"
131+
ansible.builtin.set_fact:
132+
hana_primitive_resource_name: "{{ hana_primitive_resource_id.stdout }}"
133+
36134
- name: "Retrieve Virtual Machine name"
37135
ansible.builtin.uri:
38136
url: http://169.254.169.254/metadata/instance?api-version=2021-02-01

src/roles/ha_db_hana/tasks/resource-migration.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
- name: "Test Execution: Get HANA resource id for saphanasr_angi"
3838
ansible.builtin.shell: >-
3939
set -o pipefail && {{ commands
40-
| selectattr('name','equalto','get_hana_resource_id_saphanasr_angi')
40+
| selectattr('name','equalto','get_hana_clone_resource_id_saphanasr_angi')
4141
| map(attribute=(ansible_os_family|upper))
4242
| first
4343
}}

src/roles/ha_scs/tasks/files/constants.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ RESOURCE_DEFAULTS:
129129
required: false
130130
instance_attributes:
131131
pcmk_delay_max:
132-
value: "15"
132+
value: ["15", "15s"]
133133
required: false
134134
pcmk_monitor_retries:
135135
value: "4"
@@ -169,7 +169,7 @@ RESOURCE_DEFAULTS:
169169
sbd_stonith:
170170
instance_attributes:
171171
pcmk_delay_max:
172-
value: "15"
172+
value: ["15", "15s"]
173173
required: false
174174
pcmk_monitor_retries:
175175
value: "4"
@@ -388,7 +388,7 @@ RESOURCE_DEFAULTS:
388388
fence_agent:
389389
instance_attributes:
390390
pcmk_delay_max:
391-
value: "15"
391+
value: ["15", "15s"]
392392
required: false
393393
pcmk_monitor_retries:
394394
value: "4"
@@ -428,7 +428,7 @@ RESOURCE_DEFAULTS:
428428
sbd_stonith:
429429
instance_attributes:
430430
pcmk_delay_max:
431-
value: "15"
431+
value: ["15", "15s"]
432432
required: false
433433
pcmk_monitor_retries:
434434
value: "4"

src/roles/misc/tasks/pre-validations-db.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
- name: "Pre validation: Get HANA resource id for saphanasr_angi"
2222
when: saphanasr_provider | default('SAPHanaSR') == "SAPHanaSR-angi"
2323
block:
24-
- name: "Pre validation: Get HANA resource id for saphanasr_angi"
24+
- name: "Pre validation: Get HANA clone resource id for saphanasr_angi"
2525
become: true
2626
ansible.builtin.shell: >-
2727
set -o pipefail && {{ commands
28-
| selectattr('name','equalto','get_hana_resource_id_saphanasr_angi')
28+
| selectattr('name','equalto','get_hana_clone_resource_id_saphanasr_angi')
2929
| map(attribute=(ansible_os_family|upper))
3030
| first
3131
}}
@@ -35,9 +35,24 @@
3535
register: hana_clone_resource_id
3636
failed_when: hana_clone_resource_id.rc != 0
3737

38+
- name: "Pre validation: Get HANA primitive resource id for saphanasr_angi"
39+
become: true
40+
ansible.builtin.shell: >-
41+
set -o pipefail && {{ commands
42+
| selectattr('name','equalto','get_hana_primitive_resource_id_saphanasr_angi')
43+
| map(attribute=(ansible_os_family|upper))
44+
| first
45+
}}
46+
args:
47+
executable: /bin/bash
48+
changed_when: false
49+
register: hana_primitive_resource_id
50+
failed_when: hana_primitive_resource_id.rc != 0
51+
3852
- name: "Pre validation: Set fact the hana_clone_resource_name"
3953
ansible.builtin.set_fact:
40-
hana_clone_resource_name: "{{ hana_clone_resource_id.stdout }}"
54+
hana_clone_resource_name: "{{ hana_clone_resource_id.stdout }}"
55+
hana_primitive_resource_name: "{{ hana_primitive_resource_id.stdout }}"
4156

4257
- name: "Pre validation: Get HANA Clone resource id"
4358
when: saphanasr_provider | default('SAPHanaSR') == "SAPHanaSR"

src/roles/misc/tasks/render-html-report.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@
1919
test_group_name: "{{ test_group_name }}_{{ ansible_os_family | upper }}"
2020
report_template: "{{ html_report_template }}"
2121
workspace_directory: "{{ _workspace_directory }}"
22-
test_case_results: "{{ all_results | default({}) }}"
22+
test_case_results: "{{ all_results | default([]) }}"
2323
system_info: "{{ system_info | default({}) }}"
2424
register: report_file_path

0 commit comments

Comments
 (0)