2018-10-30 16:37:34 +01:00
.. _playbooks_templating:
2017-01-18 03:55:03 +01:00
Templating (Jinja2)
===================
As already referenced in the variables section, Ansible uses Jinja2 templating to enable dynamic expressions and access to variables.
2017-01-18 20:14:00 +01:00
Ansible greatly expands the number of filters and tests available, as well as adding a new plugin type: lookups.
2017-01-18 03:55:03 +01:00
Please note that all templating happens on the Ansible controller before the task is sent and executed on the target machine. This is done to minimize the requirements on the target (jinja2 is only required on the controller) and to be able to pass the minimal information needed for the task, so the target machine does not need a copy of all the data that the controller has access to.
.. contents :: Topics
.. toctree ::
:maxdepth: 2
playbooks_filters
playbooks_tests
playbooks_lookups
2017-04-10 20:22:06 +02:00
playbooks_python_version
2017-01-18 03:55:03 +01:00
2018-12-07 18:25:53 +01:00
.. _templating_now:
Get the current time
`` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ``
.. versionadded :: 2.8
The `` now() `` Jinja2 function, allows you to retrieve python datetime object or a string representation for the current time.
The `` now() `` function supports 2 arguments:
utc
Specify `` True `` to get the current time in UTC. Defaults to `` False ``
fmt
Accepts a `strftime <https://docs.python.org/3/library/datetime.html#strftime-strptime-behavior> `_ string that will be used
to return a formatted date time string
2017-01-18 03:55:03 +01:00
.. seealso ::
:doc: `playbooks`
An introduction to playbooks
:doc: `playbooks_conditionals`
Conditional statements in playbooks
:doc: `playbooks_loops`
Looping in playbooks
2017-06-06 23:39:48 +02:00
:doc: `playbooks_reuse_roles`
2017-01-18 03:55:03 +01:00
Playbook organization by roles
:doc: `playbooks_best_practices`
Best practices in playbooks
2018-07-21 15:48:47 +02:00
`User Mailing List <https://groups.google.com/group/ansible-devel> `_
2017-01-18 03:55:03 +01:00
Have a question? Stop by the google group!
`irc.freenode.net <http://irc.freenode.net> `_
#ansible IRC chat channel