Added additional template variables

Added two additional template variables
* template_fullpath - absolute path to the template
* template_run_date - date that the template was rendered
Documented these additional variables in the module documentation
pull/1826/head
willthames 12 years ago
parent caee51e90e
commit 411b2bf7d9

@ -303,6 +303,8 @@ def template_from_file(basedir, path, vars):
vars['template_path'] = realpath
vars['template_mtime'] = datetime.datetime.fromtimestamp(os.path.getmtime(realpath))
vars['template_uid'] = template_uid
vars['template_fullpath'] = os.path.abspath(realpath)
vars['template_run_date'] = datetime.datetime.now()
managed_default = C.DEFAULT_MANAGED_STR
managed_str = managed_default.format(

@ -9,12 +9,13 @@ description:
(U(http://jinja.pocoo.org/docs/)) - documentation on the template
formatting can be found in the Template Designer Documentation
(U(http://jinja.pocoo.org/docs/templates/)).
- "Four additional variables can be used in templates: C(ansible_managed)
- "Six additional variables can be used in templates: C(ansible_managed)
(configurable via the C(defaults) section of C(ansible.cfg)) contains a string
which can be used to describe the template name, host, modification time of the
template file and the owner uid, C(template_host) contains the node name of
the template's machine, C(template_uid) the owner, and C(template_path) the
file name."
the template's machine, C(template_uid) the owner, C(template_path) the
relative path of the template, C(template_fullpath) is the absolute path of the
template, and C(template_run_date) is the date that the template was rendered."
options:
src:
description:

Loading…
Cancel
Save