ansible.builtin.template (v2.8.18) — lookup

retrieve contents of file after templating with Jinja2

| "added in version" 0.9 of ansible.builtin"

Authors: Michael DeHaan <michael.dehaan@gmail.com>

Install Ansible via pip

Install with pip install ansible==2.8.18

Description

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.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: show templating results
  debug:
    msg: "{{ lookup('template', './some_template.j2') }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: show templating results with different variable start and end string
  debug:
    msg: "{{ lookup('template', './some_template.j2', variable_start_string='[%', variable_end_string='%]') }}"

Inputs

    
_terms:
    description: list of files to template

convert_data:
    description: whether to convert YAML into data. If False, strings that are YAML will
      be left untouched.
    type: bool

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

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

Outputs

_raw:
  description: file(s) content after templating