knowledge/technology/tools/Ansible/lookups/ansible.builtin.template.md
2023-12-04 11:02:23 +01:00

1.1 KiB

ansible.builtin.template

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

Parameter Type Description
template_vars dictionary A dictionary, the keys become additional variables available for templating.

Examples

- 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='#]') }}"