Skip to content

Document register projections - #3752

Open
pkingstonxyz wants to merge 12 commits into
ansible:develfrom
pkingstonxyz:document-register-projections
Open

Document register projections#3752
pkingstonxyz wants to merge 12 commits into
ansible:develfrom
pkingstonxyz:document-register-projections

Conversation

@pkingstonxyz

@pkingstonxyz pkingstonxyz commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

This PR documents the new functionality of the register keyword introduced by ansible/ansible#86241. I am confident that this is incomplete and needs adjustments/examples, but these seemed to be the most obvious places that register functionality needed updating.

I was torn on including a separate page/section by the name of 'register projections' but I opted to instead disperse the various pieces of register across the existing documentation points.

One candidate for getting its own section is the implicit variable _task for documenting the accessible properties, but I'm unsure where this should be placed (maybe here? docs/docsite/rst/reference_appendices/common_return_values.rst).


Forgot to add it to commit 4dce38a
Co-authored-by: claude code

(Note: I closed that last PR because I was accidentally working from a branch in ansible/ansible-documentation and not in my own fork. lessons learned)

@s-hertel s-hertel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good to me, just had a couple small suggestions.

Comment thread docs/docsite/rst/playbook_guide/playbooks_variables.rst
Comment thread docs/docsite/rst/playbook_guide/playbooks_conditionals.rst Outdated
@oraNod

oraNod commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

@pkingstonxyz Hey, CI failures here are unrelated and have been fixed with #3743 and #3757 Could you please rebase your changes against devel and push to your branch? Cheers.

Comment thread docs/docsite/rst/playbook_guide/playbooks_conditionals.rst Outdated
Comment thread docs/docsite/rst/playbook_guide/playbooks_variables.rst Outdated
@pkingstonxyz
pkingstonxyz force-pushed the document-register-projections branch from 0ae49e8 to 9e05dd6 Compare June 9, 2026 17:28
@briantist

Copy link
Copy Markdown
Contributor

Looks like code review suggestions have been addressed, CI is passing, anything else blocking this from being merged?

 - Avoid personal pronouns
 - Fix voice issues
 - Clarify example a bit
 - Add cross references for compatibility
@pkingstonxyz

Copy link
Copy Markdown
Contributor Author

Okay I gave it another pass to fix a few straggling grammar issues, my use of personal pronouns, odd passive voice, and added a couple cross references to aid in discoverability. I think it's good to go @nitzmahone @oraNod

@oraNod oraNod left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A couple of minors but overall LGTM. Thanks @pkingstonxyz

I was thinking about your question:

One candidate for getting its own section is the implicit variable _task for documenting the accessible properties, but I'm unsure where this should be placed (maybe here? docs/docsite/rst/reference_appendices/common_return_values.rst).

I think this could be placed before the note in playbooks_variables.rst here: https://github.com/ansible/ansible-documentation/pull/3752/changes#diff-8edddbcc8bdfa833720c87eadf77339500b78fe9ecf561bd680b20f279aa0395R253

Although I'd say do that as a follow up. This PR looks good to go and we've had a couple of queries about these docs on the forum already. Cheers!

Comment thread docs/docsite/rst/playbook_guide/playbooks_loops.rst Outdated
Comment thread docs/docsite/rst/playbook_guide/playbooks_variables.rst Outdated
@oraNod
oraNod requested a review from s-hertel July 9, 2026 11:36

@s-hertel s-hertel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good to me, just had a few small suggestions I missed the first time (sorry).


.. note::

The ``_task`` implicit variable can be used in all conditional keywords, including ``when``, ``until``, ``failed_when``, ``changed_when``, and ``break_when``.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe it would be useful to note somewhere that ignore_errors/ignore_unreachable are similar to when, in that the result for the current task/loop item is not available (only previous loop item results).

Comment thread docs/docsite/rst/playbook_guide/playbooks_error_handling.rst Outdated
Comment thread docs/docsite/rst/playbook_guide/playbooks_loops.rst Outdated
Comment thread docs/docsite/rst/playbook_guide/playbooks_variables.rst Outdated
whitespace nits

Co-authored-by: Don Naro <dnaro@redhat.com>
- Add notes to clarify the necessity of default
- Make examples cleaner
Add note about defining a variable called _task

Co-authored-by: Sloane Hertel <19572925+s-hertel@users.noreply.github.com>
Comment on lines +268 to +269
command_duration: _task.result.dt
capitalized_command_output: _task.result.stdout | capitalize

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

shell doesn't include dt in the result, so this example might be clearer if it calculates the duration from available keys

Suggested change
command_duration: _task.result.dt
capitalized_command_output: _task.result.stdout | capitalize
command_duration: (command_end - command_start).total_seconds()
command_start: _task.result.start | to_datetime(time_format)
command_end: _task.result.end | to_datetime(time_format)
vars:
time_format: '%Y-%m-%d %H:%M:%S.%f'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants