ansible.builtin.template – retrieve contents of file after templating with Jinja2¶
Note
This module is part of ansible-base
and included in all Ansible
installations. In most cases, you can use the short module name
template even without specifying the collections:
keyword.
Despite that, we recommend you use the FQCN for easy linking to the module
documentation and to avoid conflicting with other collections that may have
the same module name.
New in version 0.9: of ansible.builtin
Synopsis¶
Returns a list of strings; for each template in the list of templates you pass in, returns a string containing the results of processing that template.
Parameters¶
Examples¶
- name: show templating results
debug:
msg: "{{ lookup('template', './some_template.j2') }}"
- name: show templating results with different variable start and end string
debug:
msg: "{{ lookup('template', './some_template.j2', variable_start_string='[%', variable_end_string='%]') }}"
Return Values¶
Common return values are documented here, the following are the fields unique to this lookup:
Key | Returned | Description |
---|---|---|
_raw
list
/ elements=any
|
success |
file(s) content after templating
|
Authors¶
Michael DeHaan