From a3fc8dc3f43468d296b808a428eb92d9f07609db Mon Sep 17 00:00:00 2001 From: Marcel Mamula Date: Mon, 9 Dec 2024 13:34:19 +0100 Subject: [PATCH] fix: add omit for duplicate var combinations --- roles/sap_general_preconfigure/tasks/main.yml | 25 ++++++--------- .../tasks/include_vars_common.yml | 31 ++++++++----------- roles/sap_hana_preconfigure/tasks/main.yml | 25 ++++++--------- .../defaults/main.yml | 2 +- .../sap_netweaver_preconfigure/tasks/main.yml | 27 +++++++--------- 5 files changed, 46 insertions(+), 64 deletions(-) diff --git a/roles/sap_general_preconfigure/tasks/main.yml b/roles/sap_general_preconfigure/tasks/main.yml index 69a8ece3..3a6fcb94 100644 --- a/roles/sap_general_preconfigure/tasks/main.yml +++ b/roles/sap_general_preconfigure/tasks/main.yml @@ -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 diff --git a/roles/sap_ha_pacemaker_cluster/tasks/include_vars_common.yml b/roles/sap_ha_pacemaker_cluster/tasks/include_vars_common.yml index a122d2af..172022f2 100644 --- a/roles/sap_ha_pacemaker_cluster/tasks/include_vars_common.yml +++ b/roles/sap_ha_pacemaker_cluster/tasks/include_vars_common.yml @@ -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 diff --git a/roles/sap_hana_preconfigure/tasks/main.yml b/roles/sap_hana_preconfigure/tasks/main.yml index 38404abb..07bae981 100644 --- a/roles/sap_hana_preconfigure/tasks/main.yml +++ b/roles/sap_hana_preconfigure/tasks/main.yml @@ -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 diff --git a/roles/sap_netweaver_preconfigure/defaults/main.yml b/roles/sap_netweaver_preconfigure/defaults/main.yml index 1e735b95..a1bea12c 100644 --- a/roles/sap_netweaver_preconfigure/defaults/main.yml +++ b/roles/sap_netweaver_preconfigure/defaults/main.yml @@ -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' diff --git a/roles/sap_netweaver_preconfigure/tasks/main.yml b/roles/sap_netweaver_preconfigure/tasks/main.yml index 451e1c52..702e5106 100644 --- a/roles/sap_netweaver_preconfigure/tasks/main.yml +++ b/roles/sap_netweaver_preconfigure/tasks/main.yml @@ -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