I have the following files:
roles/test/defaults/main.yml
---
test_var1: foo
test_var2: bar
roles/test/handlers/main.yml
---
- name: "Testing handler - {{ test_var1 }} {{ test_var2 }}"
debug: var=test_var2
roles/test/tasks/main.yml
---
- name: "Testing task - {{ test_var1 }}"
debug: var=test_var1
changed_when: True
notify:
- "Testing handler - {{ test_var1 }} {{ test_var2 }}"
playbooks/test.yml
---
- hosts: all
roles:
- role: test
test_var1: FOO
test_var2: BAR
And running the test.yml playbook gives the following output:
TASK: [test | Testing task - FOO] *********************************************
changed: [127.0.0.1] => {
"changed": true,
"var": {
"test_var": "FOO"
}
}
NOTIFIED: [test | Testing handler - FOO BAR] **********************************
ok: [127.0.0.1] => {
"var": {
"test_var2": "BAR"
}
}
However, if I comment out the test_var2 instance in playbooks/test.yml, like this:
---
- hosts: all
roles:
- role: test
test_var1: FOO
#test_var2: BAR
Then the output looks like this:
TASK: [test | Testing task - FOO] *********************************************
changed: [127.0.0.1] => {
"changed": true,
"var": {
"test_var": "FOO"
}
}
NOTIFIED: [test | Testing handler - {{ test_var1 }} {{ test_var2 }}] **********
ok: [127.0.0.1] => {
"var": {
"test_var2": "bar"
}
}
In the NOTIFIED output the test variables don't actually get filled in, but in the previous output they were. Am I doing something wrong here or is this some kind of bug with ansible?
This is all on ansible 1.9.1, on CentOS7