On Thu, 12 Mar 2020 19:12:56 -0700 (PDT) Shifa Shaikh <[email protected]> wrote:
> - name: Print custom conditional debug message
> fail:
> msg: >-
> {{
> command_result.rc == 0 |
> ternary(
> "This IP is already On-Boarded.",
> "The Database is not reachable."
> )
> }}
>
> Considering command_result.rc = 0; I was expecting "This IP is already
> On-Boarded." to be printed however it does not. Can you please tell me why.
> [...]
> TASK [Print custom conditional debug message]
> **********************************
> [1;30mtask path: /tmp/filegaurd.yml:28[0m
> [0;31mfatal: [localhost]: FAILED! => {[0m
> [0;31m "changed": false, [0m
> [0;31m "msg": "False "[0m
> [0;31m}[0m
Close the comparison into the parenthesis
(command_result.rc == 0) |
The filter "|" has higher precedence compared to the comparison "==". Without
the parenthesis the filter is evaluated first and ternary returns "The
Database is not reachable.". This string is compared to command_result.rc and
the result is "msg": "False"
HTH,
-vlado
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/20200313090507.5d2c5fbb%40gmail.com.
pgpNASrOh2M8p.pgp
Description: OpenPGP digital signature
