Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
06090b5c
Commit
06090b5c
authored
Sep 05, 2013
by
James Cammarata
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4040 from ngrilly/devel
Update documentation about Jinja2 expressions in playbooks
parents
4a30bac7
aaafd9b6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
4 deletions
+15
-4
docsite/latest/rst/playbooks.rst
+11
-1
docsite/latest/rst/playbooks2.rst
+4
-3
No files found.
docsite/latest/rst/playbooks.rst
View file @
06090b5c
...
...
@@ -149,7 +149,17 @@ These variables can be used later in the playbook like this::
{{
varname
}}
Variables
are
passed
through
the
Jinja2
templating
engine
,
and
support
the
use
of
filters
to
modify
the
variable
(
for
example
:
`{{
varname
|
int
}}`
ensures
the
variable
is
interpreted
as
an
integer
).
To
learn
more
about
Jinja2
,
you
can
optionally
see
the
`
Jinja2
docs
<
http
://
jinja
.
pocoo
.
org
/
docs
/>`
_
-
though
remember
that
Jinja2
loops
and
conditionals
are
only
for
'templates'
in
Ansible
,
in
playbooks
,
ansible
has
the
'when'
and
'with'
keywords
for
conditionals
and
loops
.
Variables
are
passed
through
the
Jinja2
templating
engine
.
Any
valid
Jinja2
expression
can
be
used
between
the
curly
braces
,
including
the
use
of
filters
to
modify
the
variable
(
for
example
,
`{{
varname
|
int
}}`
ensures
the
variable
is
interpreted
as
an
integer
).
Jinja2
expressions
are
very
similar
to
Python
and
even
if
you
are
not
working
with
Python
you
should
feel
comfortable
with
them
.
See
the
`
Jinja2
documentation
<
http
://
jinja
.
pocoo
.
org
/
docs
/
templates
/>`
_
to
learn
more
about
the
syntax
.
Please
note
that
Jinja2
loops
and
conditionals
are
only
useful
in
Ansible
templates
,
not
in
playbooks
.
Use
the
'when'
and
'with'
keywords
for
conditionals
and
loops
in
Ansible
playbooks
.
If
there
are
discovered
variables
about
the
system
,
called
'facts'
,
these
variables
bubble
up
back
into
the
playbook
,
and
can
be
used
on
each
system
just
like
explicitly
set
variables
.
Ansible
provides
several
of
these
,
prefixed
with
'ansible'
,
which
are
documented
under
'setup'
in
the
module
documentation
.
Additionally
,
...
...
docsite/latest/rst/playbooks2.rst
View file @
06090b5c
...
...
@@ -307,7 +307,8 @@ Sometimes you will want to skip a particular step on a particular host. This co
as simple as not installing a certain package if the operating system is a particular version,
or it could be something like performing some cleanup steps if a filesystem is getting full.
This is easy to do in Ansible, with the `when` clause, which actually is a Python expression.
This is easy to do in Ansible, with the `when` clause, which contains a Jinja2 expression (see chapter
`Playbooks <http://www.ansibleworks.com/docs/playbooks.html#vars-section>`_ for more info).
Don't panic -- it's actually pretty simple::
tasks:
...
...
@@ -1130,8 +1131,8 @@ Running a task in check mode
.. versionadded:: 1.3
Sometimes you may want to have a task to be executed even in check
mode. To achieve this use the `always_run` clause on the task. Its
value is a
Python
expression, just like the `when` clause. In simple
mode. To achieve this
,
use the `always_run` clause on the task. Its
value is a
Jinja2
expression, just like the `when` clause. In simple
cases a boolean YAML value would be sufficient as a value.
Example::
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment