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_general_preconfigure/RHEL: Add FQCN to include_role tasks #826

Closed
marcelmamula opened this issue Jul 24, 2024 · 5 comments
Closed

sap_general_preconfigure/RHEL: Add FQCN to include_role tasks #826

marcelmamula opened this issue Jul 24, 2024 · 5 comments
Assignees

Comments

@marcelmamula
Copy link
Contributor

Current implementation of include_role call for sap_maintain_etc_hosts is calling without fully qualified collection name, resulting in failure when executed locally without collection.

Solution: Change to either

  1. community.sap_install.sap_maintain_etc_hosts
  2. "{{ sap_ha_pacemaker_cluster_system_roles_collection }}.ha_cluster" << This is example from sap_ha_pacemaker_cluster role.
@berndfinger
Copy link
Member

@marcelmamula I ran some tests and I think we should not use the FQCN here and also we do not need to do so. Maybe we can add a specific failure handling or message?

We have to consider at least the following different scenarios:

  • The GitHub repo community.sap_install is installed via git clone and available in one of the Ansible collection(s) search paths. In this case, there is no need to add the collection name in the task Import role sap_maintain_etc_hosts because the role will be found - similar to the calling role sap_general_preconfigure.
  • The collection community.sap_install is installed via Ansible Galaxy, in one of the Ansible collection(s) search paths. So there is no need to add the collection name in the task Import role sap_maintain_etc_hosts.
  • If someone wants to use the roles of this repo separately (although it's probably outside of the scope of this project), it is still possible, for example as follows:

1 - Run git clone of the repo community.sap_install in a directory of your choice, e.g. /var/tmp
2 - Recursively copy the roles of your choice from /var/tmp/community.sap_install/roles to one of the roles search paths. Example:

 # cp -pr /var/tmp/community.sap_install/roles/sap_general_preconfigure ~/.ansible/roles/
 # cp -pr /var/tmp/community.sap_install/roles/sap_maintain_etc_hosts ~/.ansible/roles/

3 - Call the role sap_general_preconfigure in the roles: section of your playbook.

But it might be that I missed some important aspects of your issue. In this case, can you please explain how you would like to install the role sap_general_preconfigure, how you called it, and which error message you got?

@marcelmamula
Copy link
Contributor Author

@berndfinger I have raised this issue because my test plays are structured to run every AP4S play step with switch so I can always test latest git clone before submitting PR changes.

Below is example for my local git clone inside of location in WSL2: /mnt/c/scripts

    - name: Execute Ansible Role sap_general_preconfigure
      ansible.builtin.include_role:
        name: "{{ '/mnt/c/scripts/community.sap_install/roles/sap_general_preconfigure' if run_local
          else 'community.sap_install.sap_general_preconfigure' }}"  # noqa role-name[path]

This is first occasion where it failed because role itself attempted to find role in my execution folder, which failed since I am not running it from cloned repository.

TASK [/mnt/c/scripts/community.sap_install/roles/sap_general_preconfigure : Configure - Include configuration actions for required sapnotes] ****************
fatal: [h01hana0]: FAILED! => {"reason": "the role 'sap_maintain_etc_hosts' was not found in /mnt/c/scripts/sap_hana_ha/roles

@berndfinger
Copy link
Member

@berndfinger I have raised this issue because my test plays are structured to run every AP4S play step with switch so I can always test latest git clone before submitting PR changes.

Below is example for my local git clone inside of location in WSL2: /mnt/c/scripts

    - name: Execute Ansible Role sap_general_preconfigure
      ansible.builtin.include_role:
        name: "{{ '/mnt/c/scripts/community.sap_install/roles/sap_general_preconfigure' if run_local
          else 'community.sap_install.sap_general_preconfigure' }}"  # noqa role-name[path]

This is first occasion where it failed because role itself attempted to find role in my execution folder, which failed since I am not running it from cloned repository.

I am trying to understand what you described, and combine it with the playbook and the output. So I am rephrasing and I'd like to ask you if my understanding is correct.

1 - You are cloning the GitHub repo community.sap_install (or installing the Galaxy collection with the same name) at a certain point in time, and it is then available in one of the Ansible collection search paths, in the subtree community/sap_install.

2 - You are also cloning the latest dev tree of the GitHub repo community.sap_install to the special location /mnt/c/scripts.

3 - You are then switching to using the latest dev version of a role of the GitHub repo community.sap_install for the task in which the role is used for which you have updated code.

If this is a correct description, I see one problem if you are calling sap_maintain_etc_hosts from within sap_general_preconfigure using the fully qualified collection name: You would be using the latest dev version of the calling role sap_general_preconfigure but this version might depend on recent changes of the called role sap_maintain_etc_hosts. So it is likely better that you install the latest dev version of a role in community.sap_install together with the latest version of any dependent role in this collection, both of course residing in one of the directories of the role search paths. Meaning you should better also get the latest dev version of sap_maintain_etc_hosts in this case.

BTW. What I don't understand is why the failing task searches the dependent role in the path /mnt/c/scripts/sap_hana_ha/roles. Is that directory the first one in your role search path?

@marcelmamula
Copy link
Contributor Author

@berndfinger
My scenario playbook is in /mnt/c/scripts/sap_hana_ha/ and not using FQCN with role name forces ansible to attempt to search in my {{playbook_dir}}/roles/ which does not exist because I did not clone roles into my folder of course.

/mnt/c/scripts/sap_hana_ha/build.yml - my scenario playbook, executed with local switch to source all roles locally.
/mnt/c/scripts/community.sap_install - local clone of my current latest fork
community.sap_install:1.4.1 - installed by galaxy

/mnt/c/scripts/sap_hana_ha/roles - non-existent folder, most likely generated by missing FQCN and {{playbook_dir}

This is my setup that worked for every role we have except sap_general_preconfigure on RHEL because of FQCN.

berndfinger added a commit to berndfinger/community.sap_install that referenced this issue Jul 29, 2024
We need to use the FQCN when importing the role sap_maintain_etc_hosts.

Solves issue sap-linuxlab#826.

Signed-off-by: Bernd Finger <bfinger@redhat.com>
@berndfinger
Copy link
Member

Solved in #827 .

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

No branches or pull requests

2 participants