Learning Ansible by Madhurranjan Mohaan & Ramesh Raithatha

Learning Ansible by Madhurranjan Mohaan & Ramesh Raithatha

Author:Madhurranjan Mohaan & Ramesh Raithatha [Mohaan, Madhurranjan]
Language: eng
Format: epub
Publisher: Packt Publishing
Published: 2014-11-26T22:00:00+00:00


Using filters with conditionals

You can use Jinja2 filters with conditionals for checking if the status of a task is failed, changed, success, or skipped. Let's start looking at examples:

In the preceding example, we first checked whether the httpd service was running and stored the output of that module in the httpd_result variable. We then checked whether the previous task failed using the Jinja2 filter, httpd_result|failed. Ansible will skip this task if the when condition fails, that is, if the previous task passed. Likewise, you can use changed, success, or skipped filters.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.