Skip to content

Conversation

@s-hertel
Copy link
Contributor

Adding some documentation for ansible/ansible#85763.

I'm not sure if the playbook introduction is the best place to document this. I'm guessing we might want to reference this feature on multiple pages.

The 'Specification Format' section is largely copied from the role argument specification documentation, but I removed fields that are strictly for documentation purposes (other than description) since ansible-doc doesn't do anything with this feature yet.

@s-hertel
Copy link
Contributor Author

I could make this a snippet, and include it in the playbooks intro and any additional locations.

Facts gathered at the play level (i.e. gather_facts: true) can be validated, so maybe https://github.com/ansible/ansible-documentation/blob/devel/docs/docsite/rst/playbook_guide/playbooks_vars_facts.rst could reference it even though the documentation is a little more general than that.

A variety of variable sources can be validated, so https://github.com/ansible/ansible-documentation/blob/devel/docs/docsite/rst/playbook_guide/playbooks_variables.rst could reference it even though the documentation covers additional variable sources.

... anywhere else? None of the pages seems like a perfect fit, so any suggestions are welcome.

@samccann
Copy link
Contributor

Asking the hivemind for advice - https://forum.ansible.com/t/where-should-we-document-the-new-play-argspec/44588

:-)

@samccann
Copy link
Contributor

My initial suggestion is to not use snippets. Most contributors don't know how to use them and it makes it unsustainable over the long term. We have a hodgepodge of them now in the docs that we should actually remove.

So far, where you have it documented in this PR makes sense to me and we could put links to this section from the other places you mention in your comments. But let's see if we get other ideas from the forum post.

@StSchnell
Copy link

Hello Sandra [@samccann],
I'm not quite sure what you mean by saying that snippets should no longer be used. Do you mean the examples? If yes, from my perspective I can only say that the snippets/examples often help me understand how to use something. I would consider it a loss if these were to disappear.
Best regards
Stefan

@s-hertel
Copy link
Contributor Author

s-hertel commented Oct 1, 2025

@StSchnell When I used the word 'snippet', I just meant the organization of the documentation (https://github.com/ansible/ansible-documentation/tree/devel/docs/docsite/rst/shared_snippets), and nothing to do with the contents of the documentation.

@s-hertel
Copy link
Contributor Author

s-hertel commented Oct 1, 2025

@samccann I grep for everything, so I'm just trying to figure out where people organically will look for documentation for this feature. I'd love to not reference it on multiple pages because then I really have to use grep to find what I'm looking for. If this is a fine location to document it, I'm happy with it.

@s-hertel s-hertel marked this pull request as ready for review October 1, 2025 13:14
@s-hertel s-hertel requested a review from samccann October 1, 2025 13:15
Copy link
Contributor

@oraNod oraNod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@s-hertel 👋 Thanks for the patience as I've been trying to get round to reviewing this in a bit more detail. I'll add some more comments soon but wanted to provide my thoughts on where this info might fit.

After looking again, I think maybe somewhere between the "Interactive input: prompts" and "Using variables" sections.

I guess both prompts and arg validation are kind of related. And, like the "Module defaults" section, these docs are about a play-level keyword. So it keeps things together conceptually.

Copy link
Contributor

@oraNod oraNod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggestions for the top part of the docs for a bit more clarity.

I think it might be worth explaining some of the benefits to the play argument validation here too. Does this sound correct?

Play argument validation takes place immediately after fact gathering and lets you check if you've passed incorrect values before executing your playbook. By defining specifications for arguments, such as required versus optional arguments, data types, and parameter options, you describe the expected arguments for playbooks in a structured format.

@oraNod
Copy link
Contributor

oraNod commented Nov 5, 2025

@s-hertel Hi, should we go ahead and merge this since 2.20.0 is now available? https://github.com/ansible/ansible/blob/v2.20.0/changelogs/CHANGELOG-v2.20.rst

@s-hertel
Copy link
Contributor Author

s-hertel commented Nov 5, 2025

After looking again, I think maybe somewhere between the "Interactive input: prompts" and "Using variables" sections.

How about adding this after the following in https://docs.ansible.com/ansible/devel/playbook_guide/:

Interactive input: prompts
Using variables
Discovering variables: facts and magic variables

All of those sections include ways of providing variables that can be validated using validate_argspec play keyword.

@oraNod
Copy link
Contributor

oraNod commented Nov 5, 2025

After looking again, I think maybe somewhere between the "Interactive input: prompts" and "Using variables" sections.

How about adding this after the following in https://docs.ansible.com/ansible/devel/playbook_guide/:

Interactive input: prompts Using variables Discovering variables: facts and magic variables

All of those sections include ways of providing variables that can be validated using validate_argspec play keyword.

@s-hertel That sounds good to me!

@oraNod oraNod added the backport-2.20 Automatically create a backport for the stable-2.20 branch label Nov 5, 2025
Copy link
Contributor

@oraNod oraNod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks @s-hertel

@oraNod oraNod merged commit efcffed into ansible:devel Nov 6, 2025
12 checks passed
@patchback
Copy link

patchback bot commented Nov 6, 2025

Backport to stable-2.20: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-2.20/efcffedf864d018b015e6ace5f5c91f347630670/pr-3079

Backported as #3227

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request Nov 6, 2025
* Document play argument spec validation

* Update docs/docsite/rst/playbook_guide/playbooks_intro.rst

Co-authored-by: Don Naro <[email protected]>

* Move the play-level argument spec validation following the sections on variables

---------

Co-authored-by: Don Naro <[email protected]>
(cherry picked from commit efcffed)
oraNod added a commit that referenced this pull request Nov 6, 2025
* Document play argument spec validation

* Update docs/docsite/rst/playbook_guide/playbooks_intro.rst



* Move the play-level argument spec validation following the sections on variables

---------


(cherry picked from commit efcffed)

Co-authored-by: Sloane Hertel <[email protected]>
Co-authored-by: Don Naro <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-2.20 Automatically create a backport for the stable-2.20 branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants