-
Notifications
You must be signed in to change notification settings - Fork 653
Update playbooks_error_handling.rst #2095
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
Update playbooks_error_handling.rst #2095
Conversation
Add example for using own variables in conditions
356a5b8
to
473045a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks very much for adding this to the docs @S1ructure - I've made a few suggestions. I'd also wonder if this should go into the variables section of the docs, maybe here: https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_variables.html#referencing-simple-variables
As I mentioned in one of my suggestions, I think putting this in the error handling section focuses too much on resolving a warning rather than promoting the best way to do something, if that makes sense.
|
||
Just like ``when`` these two conditionals do not require templating delimiters (``{{ }}``) as they are implied. | ||
If you still use them, ansible will raise a warning ``[WARNING]: conditional statements should not include jinja2 templating delimiters such as {{ }} or {% %}.`` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should include the exact warning text here. Granted this might be helpful to users who search for the warning but it adds maintenance overhead to the docs. I also don't believe it's good practice to document errors and warnings - better to document just the behaviour.
Co-authored-by: Don Naro <[email protected]>
Backport to stable-2.16: 💚 backport PR created✅ Backport PR branch: Backported as #2452 🤖 @patchback |
* Update playbooks_error_handling.rst Add example for using own variables in conditions * Apply suggestions from code review Co-authored-by: Don Naro <[email protected]> --------- Co-authored-by: Sandra McCann <[email protected]> Co-authored-by: Don Naro <[email protected]> (cherry picked from commit 19c3ffa)
Backport to stable-2.17: 💚 backport PR created✅ Backport PR branch: Backported as #2453 🤖 @patchback |
* Update playbooks_error_handling.rst Add example for using own variables in conditions * Apply suggestions from code review Co-authored-by: Don Naro <[email protected]> --------- Co-authored-by: Sandra McCann <[email protected]> Co-authored-by: Don Naro <[email protected]> (cherry picked from commit 19c3ffa)
Backport to stable-2.18: 💚 backport PR created✅ Backport PR branch: Backported as #2454 🤖 @patchback |
* Update playbooks_error_handling.rst Add example for using own variables in conditions * Apply suggestions from code review Co-authored-by: Don Naro <[email protected]> --------- Co-authored-by: Sandra McCann <[email protected]> Co-authored-by: Don Naro <[email protected]> (cherry picked from commit 19c3ffa)
* Update playbooks_error_handling.rst Add example for using own variables in conditions * Apply suggestions from code review Co-authored-by: Don Naro <[email protected]> --------- Co-authored-by: Sandra McCann <[email protected]> Co-authored-by: Don Naro <[email protected]> (cherry picked from commit 19c3ffa) Co-authored-by: S1ructure <[email protected]>
* Update playbooks_error_handling.rst Add example for using own variables in conditions * Apply suggestions from code review Co-authored-by: Don Naro <[email protected]> --------- Co-authored-by: Sandra McCann <[email protected]> Co-authored-by: Don Naro <[email protected]> (cherry picked from commit 19c3ffa) Co-authored-by: S1ructure <[email protected]>
* Update playbooks_error_handling.rst Add example for using own variables in conditions * Apply suggestions from code review Co-authored-by: Don Naro <[email protected]> --------- Co-authored-by: Sandra McCann <[email protected]> Co-authored-by: Don Naro <[email protected]> (cherry picked from commit 19c3ffa) Co-authored-by: S1ructure <[email protected]>
* Add yamllint check for RST code listings. * Address review comments. * Sort languages and remove no longer needed duplicates. * Enable warnings, but disable all failing rules. * Improve formulation. Co-authored-by: Don Naro <[email protected]> * Show allowed languages when no or invalid language is supplied. Improve line lengths. * Make sure that 'yamllint .' passes. * Fix indentation issues introduced in #2095. --------- Co-authored-by: Don Naro <[email protected]>
Add example for using own variables in conditions
Related: https://forum.ansible.com/t/using-variables-in-changed-when-failed-when-directives/10652/3
From my point of view this information was not clear yet, that
a) custom variables can be used in conditionals as well
b) the
{{ }}
annotation has to be avoided