knowledge/technology/tools/Ansible/lookups/ansible.builtin.template.md

23 lines
1.1 KiB
Markdown
Raw Permalink Normal View History

2023-12-04 10:02:23 +00:00
# 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
```yml
- 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='#]') }}"
```