Skip to content

Commit

Permalink
fix: add omit for duplicate var combinations
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelmamula committed Dec 9, 2024
1 parent bb0e982 commit a3fc8dc
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 64 deletions.
25 changes: 10 additions & 15 deletions roles/sap_general_preconfigure/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,18 @@
ansible.builtin.include_vars: "{{ __vars_file }}"
loop:
- "{{ ansible_os_family }}.yml"
- "{{ ansible_distribution }}.yml"
# Enables loading of shared vars between SLES and SLES_SAP
- >-
{{ ansible_distribution.split("_")[0] ~ '_' ~
ansible_distribution_major_version }}.yml
- >-
{{ ansible_distribution.split("_")[0] ~ '_' ~
ansible_distribution_version }}.yml
- >-
{{ ansible_distribution ~ '_' ~
ansible_distribution_major_version }}.yml
- >-
{{ ansible_distribution ~ '_' ~
ansible_distribution_version }}.yml
- "{{ ansible_distribution ~ '.yml' if ansible_distribution != ansible_os_family else omit }}"
- "{{ __distribution_major_split ~ '.yml' if __distribution_major_split != __distribution_major else omit }}"
- "{{ __distribution_minor_split ~ '.yml' if __distribution_minor_split != __distribution_minor else omit }}"
- "{{ __distribution_major }}.yml"
- "{{ __distribution_minor }}.yml"
vars:
__vars_file: "{{ role_path }}/vars/{{ item }}"
__distribution_major: "{{ ansible_distribution ~ '_' ~ ansible_distribution_major_version }}"
__distribution_minor: "{{ ansible_distribution ~ '_' ~ ansible_distribution_version }}"
# Enables loading of shared vars between SLES and SLES_SAP
__distribution_major_split: "{{ ansible_distribution.split('_')[0] ~ '_' ~ ansible_distribution_major_version }}"
__distribution_minor_split: "{{ ansible_distribution.split('_')[0] ~ '_' ~ ansible_distribution_version }}"
when: __vars_file is file
tags:
- always
Expand Down
31 changes: 13 additions & 18 deletions roles/sap_ha_pacemaker_cluster/tasks/include_vars_common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,19 @@
# 4. SLES_SAP_15.yml - Specific to distribution SLES_SAP and major release.
# 5. SLES_SAP_15.6.yml - Specific to distribution SLES_SAP and minor release.
- name: "SAP HA Prepare Pacemaker - Include environment specific variables"
when: __sap_ha_pacemaker_cluster_vars_file is file
ansible.builtin.include_vars: "{{ __sap_ha_pacemaker_cluster_vars_file }}"
ansible.builtin.include_vars: "{{ __vars_file }}"
loop:
- "{{ ansible_os_family }}.yml"
- "{{ ansible_distribution }}.yml"
# Enables loading of shared vars between SLES and SLES_SAP
- >-
{{ ansible_distribution.split("_")[0] ~ '_' ~
ansible_distribution_major_version }}.yml
- >-
{{ ansible_distribution.split("_")[0] ~ '_' ~
ansible_distribution_version }}.yml
- >-
{{ ansible_distribution ~ '_' ~
ansible_distribution_major_version }}.yml
- >-
{{ ansible_distribution ~ '_' ~
ansible_distribution_version }}.yml
- "{{ ansible_distribution ~ '.yml' if ansible_distribution != ansible_os_family else omit }}"
- "{{ __distribution_major_split ~ '.yml' if __distribution_major_split != __distribution_major else omit }}"
- "{{ __distribution_minor_split ~ '.yml' if __distribution_minor_split != __distribution_minor else omit }}"
- "{{ __distribution_major }}.yml"
- "{{ __distribution_minor }}.yml"
vars:
__sap_ha_pacemaker_cluster_vars_file: "{{ role_path }}/vars/{{ item }}"
__vars_file: "{{ role_path }}/vars/{{ item }}"
__distribution_major: "{{ ansible_distribution ~ '_' ~ ansible_distribution_major_version }}"
__distribution_minor: "{{ ansible_distribution ~ '_' ~ ansible_distribution_version }}"
# Enables loading of shared vars between SLES and SLES_SAP
__distribution_major_split: "{{ ansible_distribution.split('_')[0] ~ '_' ~ ansible_distribution_major_version }}"
__distribution_minor_split: "{{ ansible_distribution.split('_')[0] ~ '_' ~ ansible_distribution_version }}"
when: __vars_file is file
25 changes: 10 additions & 15 deletions roles/sap_hana_preconfigure/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,18 @@
ansible.builtin.include_vars: "{{ __vars_file }}"
loop:
- "{{ ansible_os_family }}.yml"
- "{{ ansible_distribution }}.yml"
# Enables loading of shared vars between SLES and SLES_SAP
- >-
{{ ansible_distribution.split("_")[0] ~ '_' ~
ansible_distribution_major_version }}.yml
- >-
{{ ansible_distribution.split("_")[0] ~ '_' ~
ansible_distribution_version }}.yml
- >-
{{ ansible_distribution ~ '_' ~
ansible_distribution_major_version }}.yml
- >-
{{ ansible_distribution ~ '_' ~
ansible_distribution_version }}.yml
- "{{ ansible_distribution ~ '.yml' if ansible_distribution != ansible_os_family else omit }}"
- "{{ __distribution_major_split ~ '.yml' if __distribution_major_split != __distribution_major else omit }}"
- "{{ __distribution_minor_split ~ '.yml' if __distribution_minor_split != __distribution_minor else omit }}"
- "{{ __distribution_major }}.yml"
- "{{ __distribution_minor }}.yml"
vars:
__vars_file: "{{ role_path }}/vars/{{ item }}"
__distribution_major: "{{ ansible_distribution ~ '_' ~ ansible_distribution_major_version }}"
__distribution_minor: "{{ ansible_distribution ~ '_' ~ ansible_distribution_version }}"
# Enables loading of shared vars between SLES and SLES_SAP
__distribution_major_split: "{{ ansible_distribution.split('_')[0] ~ '_' ~ ansible_distribution_major_version }}"
__distribution_minor_split: "{{ ansible_distribution.split('_')[0] ~ '_' ~ ansible_distribution_version }}"
when: __vars_file is file


Expand Down
2 changes: 1 addition & 1 deletion roles/sap_netweaver_preconfigure/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Perform an assertion run:
sap_netweaver_preconfigure_assert: false

# In case of an assertion run, if set to "true", the role will abort for any assertion error:
# In case of an assertion run, if set to true, the role will abort for any assertion error:
sap_netweaver_preconfigure_assert_ignore_errors: false

sap_netweaver_preconfigure_min_swap_space_mb: '20480'
Expand Down
27 changes: 12 additions & 15 deletions roles/sap_netweaver_preconfigure/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,21 @@
ansible.builtin.include_vars: "{{ __vars_file }}"
loop:
- "{{ ansible_os_family }}.yml"
- "{{ ansible_distribution }}.yml"
# Enables loading of shared vars between SLES and SLES_SAP
- >-
{{ ansible_distribution.split("_")[0] ~ '_' ~
ansible_distribution_major_version }}.yml
- >-
{{ ansible_distribution.split("_")[0] ~ '_' ~
ansible_distribution_version }}.yml
- >-
{{ ansible_distribution ~ '_' ~
ansible_distribution_major_version }}.yml
- >-
{{ ansible_distribution ~ '_' ~
ansible_distribution_version }}.yml
- "{{ ansible_distribution ~ '.yml' if ansible_distribution != ansible_os_family else omit }}"
- "{{ __distribution_major_split ~ '.yml' if __distribution_major_split != __distribution_major else omit }}"
- "{{ __distribution_minor_split ~ '.yml' if __distribution_minor_split != __distribution_minor else omit }}"
- "{{ __distribution_major }}.yml"
- "{{ __distribution_minor }}.yml"
vars:
__vars_file: "{{ role_path }}/vars/{{ item }}"
__distribution_major: "{{ ansible_distribution ~ '_' ~ ansible_distribution_major_version }}"
__distribution_minor: "{{ ansible_distribution ~ '_' ~ ansible_distribution_version }}"
# Enables loading of shared vars between SLES and SLES_SAP
__distribution_major_split: "{{ ansible_distribution.split('_')[0] ~ '_' ~ ansible_distribution_major_version }}"
__distribution_minor_split: "{{ ansible_distribution.split('_')[0] ~ '_' ~ ansible_distribution_version }}"
when: __vars_file is file
tags:
- always


- name: Set filename prefix to empty string if role is run in normal mode
Expand Down

0 comments on commit a3fc8dc

Please sign in to comment.