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

Determine best location for role dependencies #153

Open
jsf9k opened this issue Jun 28, 2023 · 4 comments
Open

Determine best location for role dependencies #153

jsf9k opened this issue Jun 28, 2023 · 4 comments
Labels
breaking change This issue or pull request involves changes to existing functionality improvement This issue or pull request will add or improve functionality, maintainability, or ease of use need info This issue or pull request requires further information

Comments

@jsf9k
Copy link
Member

jsf9k commented Jun 28, 2023

💡 Summary

We should determine whether all role dependencies should be listed in meta/requirements.yml or both meta/requirements.yml and meta/main.yml.

Motivation and context

Ansible Galaxy currently allows role dependencies to be listed in both meta/requirements.yml and meta/main.yml. The former allows for both collection and role dependencies, while the latter allows for only role dependencies. A key difference is that dependencies listed in meta/main.yml are installed before the role is installed, while the dependencies listed in meta/requirements.yml are made available to the role but not automatically installed.

Right now we are defaulting to listing dependencies in meta/main.yml, and listing dependencies in meta/requirements.yml in cases where

  • The installation of a dependency is conditional based upon the values on role variables, or
  • The dependency's role variables must be assigned dynamic values.

One can imagine a world in which all dependencies are listed in meta/requirements.yml and we manually install the dependencies in the role tasks for maximum control and flexibility. It is currently unclear if this is The Way Forward, so we should keep an eye on ansible-galaxy changes and recommended best practices until the situation becomes clearer.

@jsf9k jsf9k added breaking change This issue or pull request involves changes to existing functionality improvement This issue or pull request will add or improve functionality, maintainability, or ease of use on hold This pull request is awaiting an action or decision to move forward labels Jun 28, 2023
@jsf9k
Copy link
Member Author

jsf9k commented Jun 28, 2023

Note also that it is possible to list both collections and roles in meta/requirements.yml, but unfortunately ansible-galaxy attempts to naively merge the dependencies listed in meta/main.yml with those listed in meta/requirements.yml. That means that both sets of dependencies must be arrays, so as long as we are using both files we can only list roles in meta/requirements.yml. This is one argument for moving wholesale to meta/requirements.yml.

@jsf9k jsf9k added need info This issue or pull request requires further information and removed on hold This pull request is awaiting an action or decision to move forward labels Jun 28, 2023
@jsf9k
Copy link
Member Author

jsf9k commented Jun 28, 2023

Also note that an ansible-galaxy requirements file allows for including one such file from another. If we defined all dependencies in the meta/requirements.yml file then we should be able to include that file from molecule/default/requirements.yml and avoid keeping track of role dependencies in two places. DRYness is next to godliness.

@jsf9k
Copy link
Member Author

jsf9k commented Oct 30, 2023

There is a fly in the ointment: ansible/proposals#57 (comment)

It appears that collections are not really supported as dependencies in meta/requirements.yml, although ansible-lint thinks so. 😞

This causes us a major problem, since in some cases ansible-lint insists that we list collection dependencies for modules, yet Ansible stubbornly refuses to support this. See, for example, this failing build.

@jsf9k
Copy link
Member Author

jsf9k commented Oct 31, 2023

ansible/ansible#76030 is also of note, particularly ansible/ansible#76030 (comment).

jsf9k added a commit to cisagov/ansible-role-vnc-server that referenced this issue Nov 1, 2023
ansible-galaxy does not appear to allow them there.  See here for more
details:
cisagov/skeleton-ansible-role#153 (comment)
jsf9k added a commit that referenced this issue Nov 1, 2023
ansible-galaxy does not appear to allow roles to depend on
collections.  See here for more details:
#153 (comment)
jsf9k added a commit to cisagov/ansible-role-amazon-efs-utils that referenced this issue Nov 1, 2023
ansible-galaxy does not appear to allow them there.  See here for more
details:
cisagov/skeleton-ansible-role#153 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change This issue or pull request involves changes to existing functionality improvement This issue or pull request will add or improve functionality, maintainability, or ease of use need info This issue or pull request requires further information
Projects
None yet
Development

No branches or pull requests

1 participant