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

Documentation on requirements.yml is confusing or misleading #73347

Closed
ssbarnea opened this issue Jan 25, 2021 · 16 comments
Closed

Documentation on requirements.yml is confusing or misleading #73347

ssbarnea opened this issue Jan 25, 2021 · 16 comments
Labels
affects_2.15 docs This issue/PR relates to or includes documentation. has_pr This issue has an associated PR. support:core This issue/PR relates to code supported by the Ansible Engineering Team.

Comments

@ssbarnea
Copy link
Member

SUMMARY

Please clarify this documentation and assure that it answers these questions:

  • documents if requirements.yml at collection level is using the safe format as the one inside roles (meta/requirements.yml).
  • document the deprecation of the old format and indicate when is going away
  • preferably mention which is the minimal version of ansible that supports the newer format
  • if examples are given using both formats, they should start with a comment mentioning the format they use, like "# v1 requirements format", or # v2 requirements format (ansible 2.x+)
ISSUE TYPE
  • Documentation Report
COMPONENT NAME

documentation

ANSIBLE VERSION
devel
@ansibot
Copy link
Contributor

ansibot commented Jan 25, 2021

Files identified in the description:
None

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibot ansibot added affects_2.11 docs This issue/PR relates to or includes documentation. needs_triage Needs a first human triage before being processed. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Jan 25, 2021
@sivel
Copy link
Member

sivel commented Jan 25, 2021

meta/requirements.yml only supports the v1 requirements format. We do not support dependencies between stand alone roles and collections (nor between collections and stand alone roles).

The v1 format is not deprecated.

The v2 requirements.yml format was introduced in 2.9, the ability to install both collections and roles from a single command was introduced in 2.10.

@ssbarnea
Copy link
Member Author

ssbarnea commented Jan 25, 2021

To double check, please correct me if needed:

  • root reqs supports both formats
  • role-reqs supports only v1
  • side-effect: a standalone-role cannot depend on collections
  • side-effect: a collection can depend on a standalone-role, if you add it to your v2 file inside roles:.... still, it is up to the user to install them using current command as they are not automatically installed.
  • adding meta/requirements.yml to roles from within a collection does not make sense as they are not processed or part of the installation.
  • work done at Replace the inhouse collection dependency resolver with resolvelib #72591 is supposed to improve how ansible dependencies are installed

AFAIK galaxy-ng has zero support for bare roles and there are no plans to add it. To me it does not make sense, why to add so much complexity for a packaging format that presents no benefits over the newer collections one. I do understand that the v1 is not deprecated, but based on what I hear, is a matter of time until it will happen. I really doubt there is even one Ansible user that enjoys the idea that he needs to run install twice in order to install the deps.

@webknjaz
Copy link
Member

webknjaz commented Jan 25, 2021

  • side-effect: a collection can depend on a standalone-role, if you add it to your v2 file inside roles:.... still, it is up to the user to install them using current command as they are not automatically installed.

Sounds like you confuse environment and package (role or collection) dependencies. Collection dependencies are only specified in galaxy.yml in source and are then moved to MANIFEST.json inside the built artifact, they only have a mapping of FQCN to version, that's it.

Another thing is requirements.yml (could be called anything, actually) that one must use via ansible-galaxy collection install -r requirements.yml. It's a user-side environment dependencies list that their playbooks need, nothing to do with a specific collection dependencies whatsoever.

The difference is the same as between setup.cfg (setup.py) and requirements.txt in pip ecosystem.

@s-hertel
Copy link
Contributor

side-effect: a collection can depend on a standalone-role, if you add it to your v2 file inside roles:.... still, it is up to the user to install them using current command as they are not automatically installed.

Well, couldn't you also use a FQCN in a standalone role's deps and have the side-effect of a standalone role depending upon a collection and needing to manually install that too?

A collection's roles should only depend on other roles in the collection or roles of its dependencies. A collection's dependencies are in the format {collection_identifier: version} in the MANIFEST.json/galaxy.yml and standalone roles are not supported. Collection dependencies are installed with the collection itself unless --no-deps is used.

Standalone roles should depend on standalone roles, collections should depend on other collections. We should clarify this in the documentation.

work done at #72591 is supposed to improve how ansible dependencies are installed

for collections, but it isn't really a behavioral change

@Shrews Shrews removed the needs_triage Needs a first human triage before being processed. label Jan 26, 2021
@jhampson-dbre
Copy link

jhampson-dbre commented Feb 1, 2021

I stumbled here while following the instructions Migrating a role to a collection.
Step 4 is "Update galaxy.yml to include any role dependencies."

Based on the thread above, it sounds like role dependencies should not be in the galaxy.yml unless they are a collection? Error message when importing collection to galaxy is:

ERROR! Galaxy import process failed: Invalid collection metadata. Dependency collection not in galaxy: geerlingguy.docker (Code: GLW0002)

with the dependencies defined in galaxy.yml

dependencies:
  "geerlingguy.docker": ">=3.0.0"

Using ansible-2.10.6 ansible-base-2.10.5

@jborean93
Copy link
Contributor

Dependencies in a galaxy.yml is just for Collection dependencies. There is no cross dependency support to have a collection dependent on a role and vice versa. They are completely separate artifacts and should be treated as such.

@jhampson-dbre
Copy link

I realize that now, but I thought it was a good example of how the documentation around requirements.yml, meta/requirements.yml, meta/main.yml, galaxy.yml and dependency management in general between roles and collections is confusing.

@jhampson-dbre
Copy link

Standalone roles should depend on standalone roles, collections should depend on other collections. We should clarify this in the documentation.

What is the appropriate dependency management solution for moving a standalone role to a collection if it has a dependency on another standalone role? It sounds like there isn't one?

@sivel
Copy link
Member

sivel commented Feb 2, 2021

What is the appropriate dependency management solution for moving a standalone role to a collection if it has a dependency on another standalone role? It sounds like there isn't one?

You are correct, there isn't one. Stand alone roles, and collections (as well as roles in collections) cannot depend on each other. Only collection<->collection, and standalone-role<->standalone-role. To get dep auto installation, both would have to be stand alone roles, or both would have to live in collections.

Otherwise users are on their own to install the deps.

@JensHeinrich
Copy link
Contributor

Can this please be added to to documentation explicitely (or an apropriate error be added to the ansible-galaxy CLI) ?

eg: check if there is a collections: key in meta/requirements.yml and print out a warning?
(and maybe install roles listed in roles?)

@kombinatgmbh
Copy link

There is also another inconsistency. https://docs.ansible.com/ansible/latest/galaxy/user_guide.html#installing-roles-and-collections-from-the-same-requirements-yml-file says

While both roles and collections can be specified in one requirements file, they need to be installed separately. The ansible-galaxy role install -r requirements.yml will only install roles and ansible-galaxy collection install -r requirements.yml -p ./ will only install collections.

At the same time https://docs.ansible.com/ansible/latest/user_guide/collections_using.html states

To install both roles and collections at the same time with one command, run the following: $ ansible-galaxy install -r requirements.yml

@ansibot ansibot added the has_pr This issue has an associated PR. label Mar 30, 2021
@ehudkaldor

This comment has been minimized.

@ssbarnea
Copy link
Member Author

ssbarnea commented Jun 1, 2021

I do really hope we endup with a single galaxy command for installing both types of dependencies. It makes no sense to have two different commands for installing deps declared inside the same file.

What if we add another dependency type? Are we going to add a 3rd command for those?

PS. I know that this observation is bit outside the original issue, but is closely related to it.

@ehudkaldor

This comment has been minimized.

@bcoca bcoca removed the support:core This issue/PR relates to code supported by the Ansible Engineering Team. label May 11, 2022
@ansibot ansibot added the support:core This issue/PR relates to code supported by the Ansible Engineering Team. label May 11, 2022
@sivel
Copy link
Member

sivel commented Sep 14, 2022

This commit 400475a added additional handling to enforce and provide friendly errors that meta/requirements.yml must be v1 format.

I do really hope we endup with a single galaxy command for installing both types of dependencies.

The ansible-galaxy install command can handle both, whereas the role install and collection install are specific.

I'm going to proceed with closing this.

If you have further questions please stop by IRC or the mailing list:

@sivel sivel closed this as completed Sep 14, 2022
@ansible ansible locked and limited conversation to collaborators Sep 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.15 docs This issue/PR relates to or includes documentation. has_pr This issue has an associated PR. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
Status: Done
Development

No branches or pull requests