From adc128fd2db746a788496a5fc416203c833fa78c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Mass=C3=A9?= Date: Mon, 9 Jul 2018 14:54:20 +0200 Subject: [PATCH] defining values from a template --- value-from-template/output.j2 | 1 + value-from-template/value-from-template.yaml | 14 ++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 value-from-template/output.j2 create mode 100644 value-from-template/value-from-template.yaml 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