diff --git a/value-from-template/output.j2 b/value-from-template/output.j2 new file mode 100644 index 0000000..bb609a7 --- /dev/null +++ b/value-from-template/output.j2 @@ -0,0 +1 @@ +Hello {{ myname }}, foo = {{ foo }} \ No newline at end of file diff --git a/value-from-template/value-from-template.yaml b/value-from-template/value-from-template.yaml new file mode 100644 index 0000000..a5848be --- /dev/null +++ b/value-from-template/value-from-template.yaml @@ -0,0 +1,14 @@ + +- name: The value of a variable can be computed from a Jinja template, stored in a file + gather_facts: no + hosts: localhost + vars: + foo: 'bar' + myname: 'Nicolas' + output: '{{ lookup(''template'', ''output.j2'') }}' + tasks: + - debug: + var: 'output' + - assert: + that: + - output == 'Hello Nicolas, foo = bar' \ No newline at end of file