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

Clarifies how Ansible processes multiple failed_when conditions #55941

Merged
merged 4 commits into from
May 1, 2019

Conversation

acozine
Copy link
Contributor

@acozine acozine commented Apr 30, 2019

SUMMARY

Supersedes #55870. The original branch/fork for that PR disappeared.

Clarifies that lists of conditions for failed_when are connected with an implicit AND operator. Adds an example of a task with multiple failed_when conditions connected by an explicit OR operator.

ISSUE TYPE
  • Docs Pull Request
COMPONENT NAME

docs.ansible.com

Matthew Davis and others added 2 commits April 29, 2019 12:48
It is not immediately obvious that multiple `failed_when` conditions are joined with `AND`. 
I assumed they would be joined with `OR`. (Since that would be more useful.) Also, there are multiple third party pages online incorrectly stating that it uses `OR`. ([example](https://groups.google.com/d/msg/ansible-project/cIaQTmY3ZLE/c5w8rlmdHWIJ)). So it's worth clarifying.

+label: docsite_pr
@acozine acozine added the docs This issue/PR relates to or includes documentation. label Apr 30, 2019
@acozine acozine changed the title Pr55870 Clarifies how Ansible processes multiple failed_when conditions Apr 30, 2019
@acozine
Copy link
Contributor Author

acozine commented Apr 30, 2019

Thanks again to @mlda065 for suggesting (and starting) this improvement!

@ansibot ansibot added affects_2.9 This issue/PR affects Ansible v2.9 core_review In order to be merged, this PR must follow the core review workflow. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Apr 30, 2019
@mdavis-xyz
Copy link
Contributor

Yeah sorry about messing up that other PR. I deleted and recreated my fork for some other PR, but forgot that it would break this one.

So now I'm not sure how to add more to this PR.

For the multiline example, how about this?

If you which to create a task with multiple conditions joined with a logical OR, you should wrap each condition in parenthesis, and put them on one line joined with or.
If that line is too long, you can split it into a multi-line yaml value with >. For example:

- name: example of many failed_when conditions with OR
  shell: "./myBinary"
  register: ret
  failed_when: >
    ("No such file or directory" in ret.stdout) or
    ("Cannot open" in ret.stdout) or
    ("Operation not supported" in ret.stdout) or
    ("File Exists" in ret.stdout) or
    ("command not found" in ret.stderr)

@acozine
Copy link
Contributor Author

acozine commented May 1, 2019

@mlda065 ah, thanks for chiming in - okay if i merge this PR and let you add your multi-line example in a separate PR?

@mdavis-xyz
Copy link
Contributor

Yes, go ahead and merge. I'll add that other example after the merge.

@acozine acozine merged commit 5439eb8 into ansible:devel May 1, 2019
acozine added a commit to acozine/ansible that referenced this pull request May 10, 2019
…sible#55941)

Docs: Clarify that multiple failed_when conditions join with AND not OR to counter third-party pages online incorrectly stating that it uses `OR`. ([example](https://groups.google.com/d/msg/ansible-project/cIaQTmY3ZLE/c5w8rlmdHWIJ)).
(cherry picked from commit 5439eb8)
@acozine acozine deleted the PR55870 branch May 10, 2019 21:52
acozine added a commit that referenced this pull request May 13, 2019
* Update windows_setup.rst (#55535): Wrong protocol and port in command.

(cherry picked from commit 6ea3eca)

* Clarify the two targets of vault encryption, with notes about advantages and drawbacks of each

Co-Authored-By: tacatac <taca@kadisius.eu>
(cherry picked from commit 79198ca)

* Improve consistency of loop documentation (#55674)

(cherry picked from commit a5cb47d)

* Add Microsoft Document URL for WinRM Memory Hotfix (#55680)

Co-Authored-By: hiyokotaisa <thel.vadam2485@gmail.com>
(cherry picked from commit 7b86208)

* Clarify the documentation for `async` and `poll`; describe the behavior when `poll` = 0 and when it does not.

Co-Authored-By: tacatac <taca@kadisius.eu>
(cherry picked from commit dbc64ae)

* Add security group info and example to AWS guide (#55783): expand documentation on how to use lookup plugin aws_service_ip_ranges with ec2_group module

(cherry picked from commit bb5059f)

* correct description of modules vs plugins (#55784)

(cherry picked from commit 9d5b5d7)

* Fix var naming (#55795): Make vars match tasks in Google Compute guide.

(cherry picked from commit 943f733)

* Clarifies how Ansible processes multiple `failed_when` conditions (#55941): multiple failed_when conditions join with AND not OR to counter third-party pages online incorrectly stating that it uses `OR`. ([example](https://groups.google.com/d/msg/ansible-project/cIaQTmY3ZLE/c5w8rlmdHWIJ)).

(cherry picked from commit 5439eb8)

* Docs: edits & expands module_utils & search path info in dev guide (#55931)

(cherry picked from commit 8542459)

* Add faq note about ssh ServerAliveInterval (#55568)

(cherry picked from commit 76dba7a)

* docsite: correct path, list requirements for testing module docs, etc. (#52008)

* dev_guide: correct path, list requirements, etc.; module HTML docs are in '_build/html/module' subdir

(cherry picked from commit b14f477)

* Developer documentation update involving module invocation (#55747)

* Update docs for the 2.7 change to AnsiballZ which invokes modules with one
  less Python interpreter

* Add a section on how module results are returned and on trust between modules, action plugins, and the executor.

* Update docs/docsite/rst/dev_guide/developing_program_flow_modules.rst

Co-Authored-By: abadger <a.badger@gmail.com>
(cherry picked from commit edafa71)

* add doc example of multiline failed_when with OR (#56007)
* add variety to multiple OR failed_when doc example

(cherry picked from commit 7d5ada7)

* Note that by default the regex test is identical to match, but can do much more (#50205)

* Note that the regex test behaves like 'match', with default settings

(cherry picked from commit 86e98c5)

* more info on how vaults work (#56183)

also add warning about what it covers.

(cherry picked from commit 8ff27c4)

* Fix var naming in GCE guide

(cherry picked from commit dae5564)

* dev_guide: Various small updates (#53273)

* Document the clarifications that I usually remark when doing reviews
* Update docs/docsite/rst/dev_guide/developing_modules_documenting.rst

Co-Authored-By: dagwieers <dag@wieers.com>
(cherry picked from commit eac7f1f)

* Lack of "--update" flag in older Ubuntu distros (#56283): when installing on older Ubuntu distributions be aware of the lack of ``-u`` or ``--update`` flag.

(cherry picked from commit dd0b0ae)

* should have gone into 52373 (#56306)

(cherry picked from commit 3c8d8b1)
@ansible ansible locked and limited conversation to collaborators Jul 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.9 This issue/PR affects Ansible v2.9 core_review In order to be merged, this PR must follow the core review workflow. docs This issue/PR relates to or includes documentation. 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

4 participants