New in version 1.9.2.
ansible_managed
(configurable via the defaults
section of 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, template_host
contains the node name of the template’s machine, template_uid
the owner, template_path
the absolute path of the template, template_fullpath
is the absolute path of the template, and template_run_date
is the date that the template was rendered. Note that including a string that uses a date in the template will result in the template being marked ‘changed’ each time.parameter | required | default | choices | comments |
---|---|---|---|---|
block_end_string (added in 2.4)
| no | %} | The string marking the end of a block. | |
block_start_string (added in 2.4)
| no | {% | The string marking the beginning of a block. | |
dest | yes | Location to render the template to on the remote machine. | ||
force (added in 2.4)
| no | yes |
| the default is yes , which will replace the remote file when contents are different than the source. If no , the file will only be transferred if the destination does not exist. |
newline_sequence (added in 2.4)
| no | \r\n |
| Specify the newline sequence to use for templating files. |
src | yes | Path of a Jinja2 formatted template on the local server. This can be a relative or absolute path. | ||
trim_blocks (added in 2.4)
| no | no | If this is set to True the first newline after a block is removed (block, not variable tag!). | |
variable_end_string (added in 2.4)
| no | }} | The string marking the end of a print statement. | |
variable_start_string (added in 2.4)
| no | {{ | The string marking the beginning of a print statement. |
- name: Create a file from a Jinja2 template win_template: src: /mytemplates/file.conf.j2 dest: C:\temp\file.conf - name: Create a Unix-style file from a Jinja2 template win_template: src: unix/config.conf.j2 dest: C:\share\unix\config.conf newline_sequence: '\n'
Note
newline_sequence
.trim_blocks=True
.Format-Hex <file> -Count 16
on Windows, and use od -a -t x1 -N 16 <file>
on Linux.#jinja2:variable_start_string:'[%', variable_end_string:'%]', trim_blocks: False
which changes the variable interpolation markers to [% var %] instead of {{ var }}. This is the best way to prevent evaluation of things that look like, but should not be Jinja2. raw/endraw in Jinja2 will not work as you expect because templates in Ansible are recursively evaluated.This module is flagged as stableinterface which means that the maintainers for this module guarantee that no backward incompatible interface changes will be made.
For more information about Red Hat’s this support of this module, please refer to this knowledge base article<https://access.redhat.com/articles/rhel-top-support-policies>
For help in developing on modules, should you be so inclined, please read Community Information & Contributing, Testing Ansible and Developing Modules.
© 2012–2017 Michael DeHaan
© 2017 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/win_template_module.html