Skip to content

Creating RunBlock#84032

Closed
jimi-c wants to merge 4 commits intoansible:develfrom
jimi-c:functions
Closed

Creating RunBlock#84032
jimi-c wants to merge 4 commits intoansible:develfrom
jimi-c:functions

Conversation

@jimi-c
Copy link
Member

@jimi-c jimi-c commented Oct 1, 2024

This feature adds the ability to created pre-defined "named blocks" in the play, and then run them as if they were named functions anywhere in the play.

This is a proof-of-concept idea only, currently.

This feature adds the ability to created pre-defined "named blocks"
in the play, and then run them as if they were named functions anywhere
in the play.
@ansibot ansibot added the needs_triage Needs a first human triage before being processed. label Oct 1, 2024
This allows vars to be specified to the run_block task, which
function like variables passed to an include (so they will override
the variables defined locally).
if nb.name == target_name:
nb_copy = nb.copy()
nb_copy.parent = original_task
nb_copy.vars.update(original_task.vars)
Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure if there should be a deep copy of task vars here or not.

Copy link
Member

Choose a reason for hiding this comment

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

it should be pretty safe to use the vars as is

@bcoca bcoca removed the needs_triage Needs a first human triage before being processed. label Oct 1, 2024
@ansibot ansibot added the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. label Oct 1, 2024
@ansibot
Copy link
Contributor

ansibot commented Oct 1, 2024

The test ansible-test sanity --test pep8 [explain] failed with 2 errors:

lib/ansible/playbook/helpers.py:31:161: E501: line too long (162 > 160 characters)
lib/ansible/playbook/play.py:188:161: E501: line too long (185 > 160 characters)

click here for bot help

@ansibot ansibot added the ci_verified Changes made in this PR are causing tests to fail. label Oct 1, 2024
@ansibot
Copy link
Contributor

ansibot commented Oct 1, 2024

The test ansible-test sanity --test pep8 [explain] failed with 3 errors:

lib/ansible/playbook/helpers.py:31:161: E501: line too long (162 > 160 characters)
lib/ansible/playbook/play.py:188:161: E501: line too long (185 > 160 characters)
lib/ansible/plugins/strategy/__init__.py:787:17: E303: too many blank lines (2)

click here for bot help

@ansibot ansibot added needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. labels Oct 11, 2024
@ansibot ansibot added the stale_pr This PR has not been pushed to for more than one year. label Oct 3, 2025
@ansibot ansibot removed the ci_verified Changes made in this PR are causing tests to fail. label Nov 13, 2025
@jimi-c jimi-c closed this Jan 15, 2026
@ansible ansible locked and limited conversation to collaborators Feb 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. stale_pr This PR has not been pushed to for more than one year.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants