ansible / ansible.builtin / v2.16.0 / lookup / template retrieve contents of file after templating with Jinja2 | "added in version" 0.9 of ansible.builtin" Authors: Michael DeHaanansible.builtin.template (v2.16.0) — lookup
pip
Install with pip install ansible-core==2.16.0
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.
- name: show templating results ansible.builtin.debug: msg: "{{ lookup('ansible.builtin.template', './some_template.j2') }}"
- name: show templating results with different variable start and end string ansible.builtin.debug: msg: "{{ lookup('ansible.builtin.template', './some_template.j2', variable_start_string='[%', variable_end_string='%]') }}"
- name: show templating results with different comment start and end string ansible.builtin.debug: msg: "{{ lookup('ansible.builtin.template', './some_template.j2', comment_start_string='[#', comment_end_string='#]') }}"
_terms: description: list of files to template convert_data: default: true description: - Whether to convert YAML into data. If False, strings that are YAML will be left untouched. - Mutually exclusive with the jinja2_native option. type: bool jinja2_native: default: false description: - Controls whether to use Jinja2 native types. - It is off by default even if global jinja2_native is True. - Has no effect if global jinja2_native is False. - This offers more flexibility than the template module which does not use Jinja2 native types at all. - Mutually exclusive with the convert_data option. type: bool version_added: '2.11' version_added_collection: ansible.builtin template_vars: default: {} description: A dictionary, the keys become additional variables available for templating. type: dict version_added: '2.3' version_added_collection: ansible.builtin comment_end_string: default: '#}' description: The string marking the end of a comment statement. type: str version_added: '2.12' version_added_collection: ansible.builtin variable_end_string: default: '}}' description: The string marking the end of a print statement. type: str version_added: '2.8' version_added_collection: ansible.builtin comment_start_string: default: '{#' description: The string marking the beginning of a comment statement. type: str version_added: '2.12' version_added_collection: ansible.builtin variable_start_string: default: '{{' description: The string marking the beginning of a print statement. type: str version_added: '2.8' version_added_collection: ansible.builtin
_raw: description: file(s) content after templating elements: raw type: list