Add now() jinja2 global func for getting the date/time (#43792)

* Add now() jinja2 global func for getting the date/time

* Docs and changelog

* now isn't a lookup, it doesn't need disabled
This commit is contained in:
Matt Martz 2018-12-07 11:25:53 -06:00 committed by GitHub
commit 3a4d476512
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 0 deletions

View file

@ -18,6 +18,24 @@ Please note that all templating happens on the Ansible controller before the tas
playbooks_lookups
playbooks_python_version
.. _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
.. seealso::