Restrict ansible-playbook's --limit option on specific operations
#683
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Which issue(s) this PR fixes
Alternative to #679 and #682
Additional comments
Introduce playbook metadata.
Metadata for a playbook can now be defined in any play, using the
vars.tdp_libdictionary. When multiple plays provide metadata, the lib will merges them.Example:
Resulting metadata:
Overriding rules will be defined on a per-metadata basis.
For now, only the
can_limitmetadata is supported. It defaults totrue.Setting
can_limit: falseindicates that the play must run on all hosts (i.e., cannot be restricted usingansible-playbook --limit). This is required for certain global operations (e.g. Kerberos initialization).Specifying
can_limit: falseon any play applies to the entire playbook. If another play within the same playbook explicitly setscan_limit: true, a warning will be logged.Refactored playbook reading and validation.
Playbook parsing and validation have been moved from
InventoryReaderto a newplaybook_validatemodule. This make validation reusable (notably for the metadata extraction). The validation logic now relies on Pydantic rather than manual checks.Clearer deployment error messages.
When running an operation with
--limit, error messages are now more explicit. They distinguish between:This will make it easier to introduce differentiated handling for these cases later.
Agreements