template
Collection: builtin
Full Name: parallax.builtin.template
Aliases: ansible.builtin.template, template
Synopsis
Render a Jinja2 template on the controller and install the result
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| src | string | yes | Template file on the controller | |
| dest | string | yes | Path on the target the rendered template is written to | |
| vars | map[string]any | map[] | Extra variables layered on top of the host namespace for this render | |
| mode | string | Permission mode of the rendered file | ||
| owner | string | Name or numeric id of the user that should own the file | ||
| group | string | Name or numeric id of the group that should own the file | ||
| backup | bool | false | Create a timestamped backup of the destination before overwriting it | |
| force | bool | true | Replace the destination when it exists and differs | |
| follow | bool | false | Follow symlinks on the destination when applying ownership | |
| validate | string | Command run against the staged file before it is moved into place; %s is replaced with the staged path | ||
| newline_sequence | string | ` | ||
| ` | Line ending of the rendered file: “\n”, “\r” or “\r\n” | |||
| block_start_string | string | {% | String marking the start of a block | |
| block_end_string | string | %} | String marking the end of a block | |
| variable_start_string | string | {{ | String marking the start of an expression | |
| variable_end_string | string | }} | String marking the end of an expression | |
| comment_start_string | string | {# | String marking the start of a comment | |
| comment_end_string | string | #} | String marking the end of a comment | |
| trim_blocks | bool | true | Remove the first newline after a block tag | |
| lstrip_blocks | bool | false | Strip leading whitespace from the start of a line to a block tag |
Example
- name: Render the vhost from a template
template:
src: templates/vhost.conf.j2
dest: /etc/nginx/conf.d/app.conf
owner: root
mode: "0644"
validate: nginx -t -c %s