In ansible 1.9, I have some roles in which I can use undefined variables (error_on_undefined_vars = False at ansible.cfg) in templates without problems on the way:
template.yml:
{{ var1 }}{{ var2 }}{{ var3 }}
If any of these vars is not defined, then nothing is replaced. Thus, you can simply indicate in your notebook some of these vars, and not others, as desired.
But after updating to version 2.2.0.0, I found that if any of these vars is not defined, they do not replace any of the template vars, but the given template: {{var1}} {{var2}} {{var3} }
eg:.
Playbook:
- hosts: myhost
vars:
var1=1
var3=3
roles:
- myrole
tasks:
- name: copy template
become: true
template: src=test.j2 dest=/tmp/test owner=user group=user
After starting this play, the final / tmp / test run with 1.9 available will be
13
and with available 2.2.0.0
{{ var1 }}{{ var2 }}{{ var3 }}
Thus, no varna is replaced.
But if:
Playbook:
- hosts: myhost
vars:
var1=1
var2=2
var3=3
roles:
- myrole
/tmp/ 1.9/2.2.0.0
123
- ?