Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement 'this' from proposals#74 #30957

Closed
wants to merge 1 commit into from
Closed

Conversation

dagwieers
Copy link
Contributor

@dagwieers dagwieers commented Sep 27, 2017

SUMMARY

As discussed in ansible/proposals#74 it is very convenient to be able to access the task result directly from changed_when, failed_when and until.

For this we reserve the keyword this.

Examples:

  # Wait until file exists
  - stat:
      path: /tmp/some.file
    until: this.stat.exists

  # Fail task when both files are identical
  - raw: diff foo/file1 bar/file2
    failed_when: this.rc == 0

  # Report a change when rc is not 2
  - shell: /usr/bin/billybass --mode="take me to the river"
    changed_when: this.rc != 2
ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

task_executor

ANSIBLE VERSION

v2.5

@dagwieers dagwieers changed the title Implement 'this' from proposals#73 Implement 'this' from proposal 73 Sep 27, 2017
@dagwieers dagwieers changed the title Implement 'this' from proposal 73 Implement 'this' from proposals#74 Sep 27, 2017
@ansibot ansibot added affects_2.5 This issue/PR affects Ansible v2.5 executor/task_executor feature_pull_request needs_triage Needs a first human triage before being processed. playbook/conditional support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Sep 27, 2017
@bcoca bcoca removed the needs_triage Needs a first human triage before being processed. label Sep 27, 2017
@mattclay
Copy link
Member

Please include some integration tests that make use of this feature.

@amenonsen
Copy link
Contributor

Reads and works well, but also needs a few words in the documentation.

@dagwieers
Copy link
Contributor Author

@mattclay @amenonsen Not before the proposal is accepted.

@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Oct 5, 2017
@ansibot ansibot added 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. labels Jan 9, 2018
@ansibot ansibot added feature This issue/PR relates to a feature request. and removed feature_pull_request labels Mar 2, 2018
@ansibot ansibot removed 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. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Jul 13, 2018
@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Jul 21, 2018
@ansibot ansibot added 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. labels Oct 12, 2018
As discussed in ansible/proposals#74 it is very convenient to be able to access the task result directly from `changed_when`, `failed_when` and `until`.

For this we reserve the keyword 'this'.

Examples:

```yaml
  # Wait until file exists
  - stat:
      path: /tmp/some.file
    until: this.stat.exists

  # Fail task when both files are identical
  - raw: diff foo/file1 bar/file2
    failed_when: this.rc == 0

  # Report a change when rc is not 2
  - shell: /usr/bin/billybass --mode="take me to the river"
    changed_when: this.rc != 2
```
@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. and removed 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. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Apr 9, 2019
@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Apr 17, 2019
@ansibot ansibot added 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. and removed core_review In order to be merged, this PR must follow the core review workflow. labels Jun 4, 2019
@samdoran
Copy link
Contributor

samdoran commented Oct 2, 2020

After reevaluating this (no pun intended), we have decided it's a bit too magical and no longer want to add this feature.

To discuss this further, please reach out on IRC or the mailing list:

   * IRC: #ansible-devel on irc.freenode.net  
   * mailing list: https://groups.google.com/forum/#!forum/ansible-devel

@samdoran samdoran closed this Oct 2, 2020
@ansible ansible locked and limited conversation to collaborators Oct 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.5 This issue/PR affects Ansible v2.5 executor/task_executor feature This issue/PR relates to a feature request. has_issue 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. playbook/conditional stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants