mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Add changes to succeeded/failed tests to the 2.4 porting guide (#33201)
* Add changes to succeeded/failed tests to the 2.4 porting guide * Edit for grammar and clarity
This commit is contained in:
parent
d8ae4dfbf2
commit
673ec2cb78
1 changed files with 25 additions and 0 deletions
|
@ -156,6 +156,31 @@ If you have a template lookup like this::
|
|||
|
||||
{{ "name surname" | regex_replace("^[^\\s]+\\s+(.*)", "\\1") }}
|
||||
|
||||
Tests
|
||||
=====
|
||||
|
||||
Tests succeeded/failed
|
||||
-----------------------
|
||||
|
||||
Prior to Ansible version 2.4, a task return code of ``rc`` would override a return code of ``failed``. In version 2.4, both ``rc`` and ``failed`` are used to calculate the state of the task. Because of this, test plugins ``succeeded``/``failed``` have also been changed. This means that overriding a task failure with ``failed_when: no`` will result in ``succeeded``/``failed`` returning ``True``/``False``. For example:
|
||||
|
||||
- command: /bin/false
|
||||
register: result
|
||||
failed_when: no
|
||||
|
||||
- debug:
|
||||
msg: 'This is printed on 2.3'
|
||||
when: result|failed
|
||||
|
||||
- debug:
|
||||
msg: 'This is printed on 2.4'
|
||||
when: result|succeeded
|
||||
|
||||
- debug:
|
||||
msg: 'This is always printed'
|
||||
when: result.rc != 0
|
||||
|
||||
As we can see from the example above, in Ansible 2.3 ``succeeded``/``failed`` only checked the value of ``rc``.
|
||||
|
||||
Networking
|
||||
==========
|
||||
|
|
Loading…
Reference in a new issue