Files
b1323f3ab1 ansible-galaxy - only install/download collections which support ansible-core by default (#86183)
* ansible-galaxy - only install/download collections with compatible requires_ansible metadata

inject requires_ansible as a dependency of the collection

add a hack to preserve the collection origin in the error message in get_dependencies and find_matches

* yield requires_ansible requirement before dependencies

* Fix error handling and broken test

Fix getting requires_ansible dependency after the metadata is available

Allow 3rd party servers to provide this metadata lazily for individual versions

Rename the candidate attr name for the error handling hack

* fix diff

* clarify code comments

refactor a bit

* Don't duplicate error message. Before:

[ERROR]: Failed to resolve the requested dependencies map. Could not satisfy the following requirements:
* ns.col2:1.0.0 (dependency of ns.col3:1.0.0) requires ansible-core <2.19.1
Hint: To disregard whether the collection supports the current version of ansible-core, configure COLLECTIONS_ON_ANSIBLE_VERSION_MISMATCH as "ignore".
Hint: Pre-releases hosted on Galaxy or Automation Hub are not installed by default unless a specific version is requested. To enable pre-releases globally, use --pre: [RequirementInformation(requirement=<ansible-core:<2.19.1 of type 'requires_ansible' from Galaxy>, parent=<ns.col2:1.0.0 of type 'galaxy' from cmd_arg>)]

Failed to resolve the requested dependencies map. Could not satisfy the following requirements:
* ns.col2:1.0.0 (dependency of ns.col3:1.0.0) requires ansible-core <2.19.1
Hint: To disregard whether the collection supports the current version of ansible-core, configure COLLECTIONS_ON_ANSIBLE_VERSION_MISMATCH as "ignore".
Hint: Pre-releases hosted on Galaxy or Automation Hub are not installed by default unless a specific version is requested. To enable pre-releases globally, use --pre.

<<< caused by >>>

[RequirementInformation(requirement=<ansible-core:<2.19.1 of type 'requires_ansible' from Galaxy>, parent=<ns.col2:1.0.0 of type 'galaxy' from cmd_arg>)]

After:

[ERROR]: Failed to resolve the requested dependencies map. Could not satisfy the following requirements:
* ns.col2:1.0.0 (dependency of ns.col3:1.0.0) requires ansible-core <2.19.1
Hint: To disregard whether the collection supports the current version of ansible-core, configure COLLECTIONS_ON_ANSIBLE_VERSION_MISMATCH as "ignore".
Hint: Pre-releases hosted on Galaxy or Automation Hub are not installed by default unless a specific version is requested. To enable pre-releases globally, use --pre.

* appease CI

fix type hints

* Update changelogs/fragments/install-ansible-core-compatible-collections.yml

Co-authored-by: sivel / Matt Martz <matt@sivel.net>

* Hardcode unsupported requires_ansible version to make maintaining the tests easier

Add a test for failed backtracking

Co-authored-by: sivel / Matt Martz <matt@sivel.net>

---------

Co-authored-by: sivel / Matt Martz <matt@sivel.net>
2026-03-05 11:08:51 -06:00
..
2025-03-01 03:11:46 +00:00