|
5 | 5 | ansible.builtin.debug: |
6 | 6 | var: role_path |
7 | 7 |
|
8 | | -# Load variable files in order: |
9 | | -# 1. Suse.yml / RedHat.yml - Specific to OS family. |
10 | | -# 2. SLES_15.yml / RedHat_9.yml - Specific to distribution (SLES, SLES_SAP or RedHat) and major release. |
11 | | -# 3. SLES_15.6.yml / RedHat_9.2 - Specific to distribution (SLES, SLES_SAP or RedHat) and minor release. |
12 | | -# 4. SLES_SAP_15.yml - Specific to distribution SLES_SAP and major release. |
13 | | -# 5. SLES_SAP_15.6.yml - Specific to distribution SLES_SAP and minor release. |
14 | | -- name: Include OS specific vars, specific |
15 | | - ansible.builtin.include_vars: "{{ __vars_file }}" |
16 | | - loop: "{{ __var_files }}" |
| 8 | +- name: Examine the OS minor version |
| 9 | + ansible.builtin.set_fact: |
| 10 | + __sap_hana_preconfigure_fact_ansible_distribution_minor_version: '{{ ansible_distribution_version.split(".")[1] }}' |
| 11 | + |
| 12 | +# Load variable files in the following order (example for SLES and SLES_SAP 15.6 and RHEL 9.2): |
| 13 | +# 1. Suse.yml / RedHat.yml - Specific to OS family. |
| 14 | +# 2. SLES_15.yml / RedHat_9.yml - Specific to distribution major release. |
| 15 | +# 3. (SLES_SAP only) SLES_SAP_15.yml - Specific to distribution SLES_SAP major release. |
| 16 | +# 4. (RHEL only) RedHat_9.1.plus.yml - Valid for RHEL release 9.1 and all later minor releases. |
| 17 | +# 5. (RHEL only) RedHat_9.2.plus.yml - Valid for RHEL release 9.2 and all later minor releases. |
| 18 | +# 6. SLES_15.6.yml / RedHat_9.2.yml - Specific to distribution major + minor release. |
| 19 | +# 7. (SLES_SAP only) SLES_SAP_15.6.yml - Specific to distribution SLES_SAP major and minor release. |
| 20 | + |
| 21 | +# Step 1: Include any vars files which apply to the OS family and the OS major release |
| 22 | +- name: Include OS major specific vars |
| 23 | + ansible.builtin.include_vars: "{{ __vars_file_major }}" |
| 24 | + loop: "{{ __vars_files_major }}" |
17 | 25 | vars: |
18 | | - __vars_file: "{{ role_path }}/vars/{{ item }}" |
| 26 | + __vars_file_major: "{{ role_path }}/vars/{{ item }}" |
19 | 27 | __distribution_major: "{{ ansible_distribution ~ '_' ~ ansible_distribution_major_version }}" |
20 | | - __distribution_major_minor: "{{ ansible_distribution ~ '_' ~ ansible_distribution_version }}" |
21 | 28 | # Enables loading of shared vars between SLES and SLES_SAP |
22 | 29 | __distribution_split_major: "{{ ansible_distribution.split('_')[0] ~ '_' ~ ansible_distribution_major_version }}" |
23 | | - __distribution_split_major_minor: "{{ ansible_distribution.split('_')[0] ~ '_' ~ ansible_distribution_version }}" |
24 | | - __var_files: >- |
| 30 | + __vars_files_major: >- |
25 | 31 | {{ |
26 | 32 | [ |
27 | 33 | ansible_os_family ~ '.yml', |
28 | 34 | (ansible_distribution ~ '.yml') if ansible_distribution != ansible_os_family else None, |
29 | 35 | (__distribution_split_major ~ '.yml') if __distribution_split_major != __distribution_major else None, |
30 | | - (__distribution_split_major_minor ~ '.yml') if __distribution_split_major_minor != __distribution_major_minor else None, |
31 | 36 | __distribution_major ~ '.yml', |
32 | | - __distribution_major_minor ~ '.yml', |
33 | 37 | ] | select('defined') | select('string') | list |
34 | 38 | }} |
35 | | - when: __vars_file is file |
| 39 | + when: __vars_file_major is file |
36 | 40 |
|
37 | | -- name: Include RHEL minor release specific vars files |
38 | | - ansible.builtin.include_tasks: 'RedHat/include_vars.yml' |
39 | | - when: ansible_distribution == 'RedHat' |
| 41 | +# Step 2 (RHEL only): Include any vars files which are valid for all RHEL minor and later minor releases up to the current one. |
| 42 | +- name: Include minor plus specific vars, RHEL only |
| 43 | + ansible.builtin.include_vars: "{{ __vars_file_plus }}" |
| 44 | + loop: "{{ __vars_files_plus }}" |
| 45 | + vars: |
| 46 | + __vars_file_plus: "{{ role_path }}/vars/{{ item }}" |
| 47 | + __distribution_major_minor_plus_yml: | |
| 48 | + {%- set major_minor_plus = [] -%} |
| 49 | + {%- for minor_number in range(1, __sap_hana_preconfigure_fact_ansible_distribution_minor_version | int + 1, 1) -%} |
| 50 | + {%- set _ = major_minor_plus.append( |
| 51 | + ansible_distribution ~ '_' ~ |
| 52 | + ansible_distribution_major_version ~ '.' ~ |
| 53 | + (minor_number | string) ~ '.plus' ~ '.yml') |
| 54 | + -%} |
| 55 | + {%- endfor -%} |
| 56 | + {{ major_minor_plus }} |
| 57 | + __vars_files_plus: >- |
| 58 | + {{ __distribution_major_minor_plus_yml | list }} |
| 59 | + when: |
| 60 | + - __vars_file_plus is file |
| 61 | + - ansible_distribution == 'RedHat' |
| 62 | + |
| 63 | +# Step 3: Include any vars files which are valid only for the OS minor release |
| 64 | +- name: Include OS minor specific vars |
| 65 | + ansible.builtin.include_vars: "{{ __vars_file_minor }}" |
| 66 | + loop: "{{ __vars_files_minor }}" |
| 67 | + vars: |
| 68 | + __vars_file_minor: "{{ role_path }}/vars/{{ item }}" |
| 69 | + __distribution_major_minor: "{{ ansible_distribution ~ '_' ~ ansible_distribution_version }}" |
| 70 | + # Enables loading of shared vars between SLES and SLES_SAP |
| 71 | + __distribution_split_major_minor: "{{ ansible_distribution.split('_')[0] ~ '_' ~ ansible_distribution_version }}" |
| 72 | + __vars_files_minor: >- |
| 73 | + {{ |
| 74 | + [ |
| 75 | + (__distribution_split_major_minor ~ '.yml') if __distribution_split_major_minor != __distribution_major_minor else None, |
| 76 | + __distribution_major_minor ~ '.yml', |
| 77 | + ] | select('defined') | select('string') | list |
| 78 | + }} |
| 79 | + when: __vars_file_minor is file |
40 | 80 |
|
41 | 81 | - name: Set filename prefix to empty string if role is run in normal mode |
42 | 82 | ansible.builtin.set_fact: |
|
0 commit comments