Skip to content

Commit 9bcaba4

Browse files
committed
Refactor HANA resource ID retrieval to handle SUSE and RHEL styles with improved error handling
1 parent a9a437d commit 9bcaba4

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

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

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,29 @@
3232
test_execution_hostname: "{{ hostvars[cluster_status_pre.primary_node].ansible_hostname }}"
3333

3434
- name: "Test Execution: Get HANA resource id"
35-
ansible.builtin.shell: >-
35+
block:
36+
- name: "Try master resource ID (SUSE style)"
37+
ansible.builtin.shell: >-
3638
{{ commands
3739
| selectattr('name','equalto','get_hana_resource_id')
3840
| map(attribute=(ansible_os_family|upper))
3941
| first
4042
}}
41-
changed_when: false
42-
ignore_errors: true
43-
register: hana_resource_id
43+
changed_when: false
44+
register: hana_resource_id
45+
failed_when: hana_resource_id.rc != 0
46+
rescue:
47+
- name: "Try clone resource ID (RHEL style)"
48+
ansible.builtin.shell: >-
49+
{{ commands
50+
| selectattr('name','equalto','get_hana_resource_id')
51+
| map(attribute='REDHAT')
52+
| first
53+
}}
54+
changed_when: false
55+
register: hana_resource_id
56+
failed_when: hana_resource_id.rc != 0
57+
ignore_errors: true
4458

4559
- name: "Test Execution: Set the resource name"
4660
when: hana_resource_id.rc == 0

0 commit comments

Comments
 (0)