I'm seeing strange behavior in ansible 2.5.5 (on centos 6.10)
`facts_help.yml
---
- debug:
var: fake_fact
- debug:
var: new_fact
- set_fact:
new_fact: fake_fact
when: fake_fact is defined
- debug:
var: fake_fact
- debug:
var: new_fact`
I see this output:
PLAY [localhost]
*********************************************************************
TASK [Gathering Facts]
***************************************************************
ok: [localhost]
TASK [include_tasks]
*****************************************************************
included: /etc/ansible/facts_help.yml for localhost
TASK [debug]
*************************************************************************
ok: [localhost] => {
"fake_fact": "VARIABLE IS NOT DEFINED!"
}
TASK [debug]
*************************************************************************
ok: [localhost] => {
"new_fact": "VARIABLE IS NOT DEFINED!"
}
TASK [set_fact]
**********************************************************************
ok: [localhost]
TASK [debug]
*************************************************************************
ok: [localhost] => {
"fake_fact": "VARIABLE IS NOT DEFINED!"
}
TASK [debug]
*************************************************************************
ok: [localhost] => {
"new_fact": "fake_fact"
}
PLAY RECAP
***************************************************************************
localhost : ok=7 changed=0 unreachable=0 failed=0
As you can see, fake_fact is undefined, and debug validates that. The when: clause evaluates to true, and allows new_fact to be set (that's my problem)..
Afterwards, a repeat of the debug on fake_fact still appears undefined.
So I'm not sure if this really a feature that I don't understand, a bug, or just a user error?
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/d0f5ff3f-e5f9-4645-83e4-c564cc7f378b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.