ansiblejinja2ansible-template

Rendering Ansible template into the fact variable


Is there a way to render Ansible template into the fact? I tried to find a solution but it looks like temp file is the the only way.


Solution

  • I think you might be just looking for the template lookup plugin:

    - set_fact:
        rendered_template: "{{ lookup('template', './template.j2') }}"
    

    Usage example: