|
45 | 45 | tags: always |
46 | 46 | tags: always |
47 | 47 |
|
| 48 | + |
| 49 | +# Process all hosts in play and define flag facts based on their intended role during installation. |
| 50 | +# - Detect Scale-Out and Addhosts operations. |
| 51 | +# - Set host identification flags |
| 52 | +# - Validate addhosts list against hosts in the play. |
| 53 | +- name: SAP HANA - Main - Identify hosts in play |
| 54 | + ansible.builtin.include_tasks: |
| 55 | + file: pre_tasks/identify_hosts.yml |
| 56 | + |
| 57 | + |
48 | 58 | # SAP HANA presence has to be validated for both new system and adding new hosts. |
| 59 | +# - Detection is executed even in force mode, but fails are skipped to allow execution of the role. |
| 60 | +# - Host identification flags are used to ignore /hana/shared file detection check for Scale-Out addhosts hosts. |
49 | 61 | - name: SAP HANA - Main - Validate presence of existing SAP HANA database |
50 | 62 | ansible.builtin.include_tasks: |
51 | | - file: pre_tasks/hana_exists.yml |
| 63 | + file: pre_tasks/detect_hana.yml |
52 | 64 | apply: |
53 | 65 | tags: |
54 | 66 | - sap_hana_install_check_hana_exists |
55 | | - when: |
56 | | - - (sap_hana_install_new_system and not sap_hana_install_force) |
57 | | - or not sap_hana_install_new_system |
58 | 67 | tags: |
59 | 68 | - sap_hana_install_check_hana_exists |
60 | 69 |
|
61 | 70 |
|
62 | | -- name: SAP HANA - Main - Identify hosts in play based on addhosts |
| 71 | +# Validate detected SAP installations against allowed Scale-Out scenarios. |
| 72 | +- name: SAP HANA - Main - Validate hosts in play |
63 | 73 | ansible.builtin.include_tasks: |
64 | | - file: pre_tasks/identify_hosts.yml |
| 74 | + file: pre_tasks/validate_hosts.yml |
| 75 | + when: __sap_hana_install_fact_is_scaleout |
65 | 76 |
|
66 | 77 |
|
67 | 78 | - name: SAP HANA - Main - Ensure SAP HANA is running for existing systems or addhosts operations |
|
77 | 88 | # - Configuration - Run always to ensure idempotent outcome. |
78 | 89 |
|
79 | 90 | - name: Block for Installation tasks |
80 | | - when: sap_hana_install_new_system or |
81 | | - ('sap_hana_install_create_configfile' in ansible_run_tags | d([])) or |
82 | | - ('sap_hana_install_hdblcm_commandline' in ansible_run_tags | d([])) |
| 91 | + # Stop execution of remaining tasks in the role, if any task in the block failed on any host. |
| 92 | + # This ensures that the role does not proceed skipping failed host, but fails the entire role execution. |
| 93 | + # 'any_errors_fatal' is not documented to work on task level, therefore we use simple block. |
| 94 | + # http://docs.ansible.com/projects/ansible/latest/playbook_guide/playbooks_error_handling.html#aborting-on-the-first-error-any-errors-fatal |
| 95 | + # Runs on all hosts in Scale-Out scenario, but allows independent failures for single host installations. |
| 96 | + any_errors_fatal: "{{ true if __sap_hana_install_fact_is_scaleout else false }}" |
| 97 | + when: |
| 98 | + - sap_hana_install_new_system |
| 99 | + or (ansible_run_tags | d([]) |
| 100 | + | intersect(['sap_hana_install_create_configfile', 'sap_hana_install_hdblcm_commandline'])) | length > 0 |
83 | 101 | block: |
| 102 | + # Task file contains pseudo-idempotency checks and cannot be skipped for installed system. |
84 | 103 | - name: SAP HANA - Install - Pre-Tasks |
85 | 104 | ansible.builtin.include_tasks: |
86 | 105 | file: pre_install.yml |
|
91 | 110 | - name: SAP HANA - Install |
92 | 111 | ansible.builtin.include_tasks: |
93 | 112 | file: hana_install.yml |
94 | | - when: > |
95 | | - (not __sap_hana_install_fact_is_installed and __sap_hana_install_fact_is_main_host) or |
96 | | - ('sap_hana_install_hdblcm_commandline' in ansible_run_tags | d([])) |
| 113 | + when: |
| 114 | + - (not __sap_hana_install_fact_is_installed and __sap_hana_install_fact_is_main_host) |
| 115 | + or (ansible_run_tags | d([]) | intersect(['sap_hana_install_hdblcm_commandline'])) | length > 0 |
97 | 116 | tags: sap_hana_install_hdblcm_commandline |
98 | 117 |
|
99 | 118 | - name: SAP HANA - Install - Post-tasks |
|
102 | 121 |
|
103 | 122 |
|
104 | 123 | - name: Block for Addhosts tasks |
105 | | - when: > |
106 | | - not sap_hana_install_new_system and |
107 | | - ((__sap_hana_install_fact_is_scaleout and __sap_hana_install_fact_is_installed) or |
108 | | - ('sap_hana_install_hdblcm_commandline' in ansible_run_tags | d([])) or |
109 | | - ('sap_hana_install_create_configfile' in ansible_run_tags | d([]))) |
| 124 | + # Stop execution of remaining tasks in the role, if any task in the block failed on any host. |
| 125 | + # This ensures that the role does not proceed skipping failed host, but fails the entire role execution. |
| 126 | + # 'any_errors_fatal' is not documented to work on task level, therefore we use simple block. |
| 127 | + # http://docs.ansible.com/projects/ansible/latest/playbook_guide/playbooks_error_handling.html#aborting-on-the-first-error-any-errors-fatal |
| 128 | + # Runs on all hosts in addhosts scenario. |
| 129 | + any_errors_fatal: true |
| 130 | + when: |
| 131 | + - not sap_hana_install_new_system |
| 132 | + and (__sap_hana_install_fact_is_scaleout |
| 133 | + or (ansible_run_tags | d([]) |
| 134 | + | intersect(['sap_hana_install_create_configfile', 'sap_hana_install_hdblcm_commandline'])) | length > 0) |
110 | 135 | block: |
111 | 136 | # Execute only if new hosts are to be added. |
112 | 137 | - name: SAP HANA - Addhosts - Pre-Tasks |
113 | 138 | ansible.builtin.include_tasks: |
114 | 139 | file: pre_addhosts.yml |
115 | | - when: > |
116 | | - (__sap_hana_install_fact_addhosts_hosts_new | d([]) | length > 0) or |
117 | | - ('sap_hana_install_hdblcm_commandline' in ansible_run_tags | d([])) or |
118 | | - ('sap_hana_install_create_configfile' in ansible_run_tags | d([])) |
| 140 | + when: |
| 141 | + - __sap_hana_install_fact_addhosts_hosts_new | d([]) | length > 0 |
| 142 | + or (ansible_run_tags | d([]) |
| 143 | + | intersect(['sap_hana_install_create_configfile', 'sap_hana_install_hdblcm_commandline'])) | length > 0 |
119 | 144 | tags: |
120 | 145 | - sap_hana_install_hdblcm_commandline |
121 | 146 | - sap_hana_install_create_configfile |
|
124 | 149 | ansible.builtin.include_tasks: |
125 | 150 | file: hana_addhosts.yml |
126 | 151 | when: |
127 | | - (__sap_hana_install_fact_addhosts_hosts_new | d([]) | length > 0 and __sap_hana_install_fact_is_main_host) or |
128 | | - ('sap_hana_install_hdblcm_commandline' in ansible_run_tags | d([])) or |
129 | | - ('sap_hana_install_create_configfile' in ansible_run_tags | d([])) |
| 152 | + - (__sap_hana_install_fact_addhosts_hosts_new | d([]) | length > 0 and __sap_hana_install_fact_is_main_host) |
| 153 | + or (ansible_run_tags | d([]) |
| 154 | + | intersect(['sap_hana_install_create_configfile', 'sap_hana_install_hdblcm_commandline'])) | length > 0 |
130 | 155 | tags: |
131 | 156 | - sap_hana_install_hdblcm_commandline |
132 | 157 | - sap_hana_install_create_configfile |
|
148 | 173 | gsub ("^\\s*hosts?: ", ""); gsub (", ", ","); print; a=0} |
149 | 174 | }' |
150 | 175 | args: |
151 | | - chdir: "{{ sap_hana_install_shared_path }}/{{ sap_hana_install_sid }}/hdblcm" |
| 176 | + chdir: "{{ __sap_hana_install_shared_path }}/hdblcm" |
152 | 177 | register: __sap_hana_install_register_completion_result |
153 | 178 | changed_when: false |
154 | 179 | when: |
|
164 | 189 | SID - {{ sap_hana_install_sid }} |
165 | 190 | NR - {{ sap_hana_install_number }} |
166 | 191 |
|
167 | | - {% if sap_hana_install_new_system and __sap_hana_install_fact_is_installed and __sap_hana_install_fact_addhosts_hosts_new | length > 0 %} |
168 | | - The new hosts defined in the variable 'sap_hana_install_addhosts' were not added: {{ __sap_hana_install_fact_addhosts_hosts_new | join(', ') }}. |
169 | | - Execute this role with the variable 'sap_hana_install_new_system' set to false to add new hosts. |
170 | | - {% endif %} |
171 | | -
|
172 | 192 | {% if sap_hana_install_configure_firewall %} |
173 | 193 | Firewall is enabled and SAP HANA ports are open. |
174 | 194 | {% endif %} |
|
179 | 199 | Fapolicyd is configured for SAP folders ({{ sap_hana_install_directories | map('quote') | join(', ') }}). |
180 | 200 | {% endif %} |
181 | 201 | vars: |
182 | | - __sap_hana_install_fact_hana_version: "{{ __sap_hana_install_register_completion_result.stdout.split(';')[0] }}" |
183 | | - __sap_hana_install_fact_hana_hosts: "{{ __sap_hana_install_register_completion_result.stdout.split(';')[1] }}" |
| 202 | + __sap_hana_install_fact_hana_version: "{{ __sap_hana_install_register_completion_result.stdout.split(';')[0] | d('N/A') }}" |
| 203 | + __sap_hana_install_fact_hana_hosts: "{{ __sap_hana_install_register_completion_result.stdout.split(';')[1] | d('N/A') }}" |
184 | 204 | when: |
185 | 205 | - not ansible_check_mode |
186 | 206 | - __sap_hana_install_fact_is_main_host |
0 commit comments