Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sap_swpm: Use master password only when necessary #920

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

berndfinger
Copy link
Member

Solves issue #909.

Solves issue sap-linuxlab#909.

Signed-off-by: Bernd Finger <bfinger@redhat.com>
@@ -110,6 +110,7 @@
sap_swpm_sapadm_password: "{{ sap_swpm_master_password }}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should rather be like this to avoid overwrite. If you enable master, you still might want to use granular passwords.

    - name: SAP SWPM Pre Install - Set other user passwords using master password
      ansible.builtin.set_fact:
        sap_swpm_sapadm_password: "{{ sap_swpm_sapadm_password | d(sap_swpm_master_password) }}"
        sap_swpm_sap_sidadm_password: "{{ sap_swpm_sap_sidadm_password | d(sap_swpm_master_password) }}"
        sap_swpm_diagnostics_agent_password: "{{ sap_swpm_diagnostics_agent_password | d(sap_swpm_master_password) }}"
      when: sap_swpm_master_password is defined and sap_swpm_master_password

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marcelmamula Makes sense. However, as these passwords are set to an empty string in defaults/main.yml, the default behavior of this code would be to set the following entries in inifile.params:

nwUsers.sidadmPassword =
DiagnosticsAgent.dasidAdmPassword =
hostAgent.sapAdmPassword =

So we should better also comment out these three variables in defaults/main.yml.

@sean-freeman Can you please have a look? Do you see an issue if we comment out all the individual passwords in defaults/main.yml of this role?

BTW All the individual password variables in role sap_hana_install are commented out as well.

Copy link
Contributor

@marcelmamula marcelmamula Jan 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@berndfinger
You are right, so we can comment them out as you mentioned or switch to IF/ELSE j2.
This way it will ignore master if it is defined and not empty, while be replaced when it is empty or undefined.

Following snippet was tested locally.

  • when is not needed as it is incorporated
  • d() and truthy check will cleanup undefined
    - name: SAP SWPM Pre Install - Set other user passwords using master password
      ansible.builtin.set_fact:
        sap_swpm_sapadm_password: "{{ sap_swpm_master_password
          if not sap_swpm_sapadm_password | d('') and sap_swpm_master_password | d('')
          else sap_swpm_sapadm_password | d('') }}"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marcelmamula Thanks. I prefer having the master password condition first, and also added a small comment so that one can quickly understand the rationale behind this code.
@sean-freeman With this code, there is no need to have a look, and to discuss commenting out all the individual passwords in defaults/main.yml of this role, at this point in time.

Signed-off-by: Bernd Finger <bfinger@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants