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

Added an example for paretheses #9268

Merged
merged 1 commit into from
Apr 13, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions docsite/rst/playbooks_conditionals.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ It's actually pretty simple::
command: /sbin/shutdown -t now
when: ansible_os_family == "Debian"

You can also use parentheses to group conditions::

tasks:
- name: "shutdown CentOS 6 and 7 systems"
command: /sbin/shutdown -t now
when: ansible_distribution == "CentOS" and
(ansible_distribution_major_version == "6" or ansible_distribution_major_version == "7")

A number of Jinja2 "filters" can also be used in when statements, some of which are unique
and provided by Ansible. Suppose we want to ignore the error of one statement and then
decide to do something conditionally based on success or failure::
Expand Down