I was too fast with my answer.
/roles/defaults/main.yml
---
applicationname: ""
description: ""
required_vars:
- applicationname
This workes:
- name: check required vars empty
fail: msg="Variable '{{ item }}' is empty"
when: vars[item] == ""
with_items: "{{ required_vars }}"
This too:
- name: check required vars null
fail: msg="Variable '{{ item }}' is null"
when: vars[item] is none
with_items: "{{ required_vars }}"
But this doesn't work:
- name: check required vars undefined
fail: msg="Variable '{{ item }}' is null"
when: vars[item] is not defined
with_items: "{{ required_vars }}"
TASK [role1 : check required undefined]
**********************************************
skipping: [server1] => (item=applicationname) => {"changed": false,
"item": "applicationname", "skip_reason": "Conditional result was False"}
I think
vars[item] is not defined
does not work because the variable "applicationname" in fact does have a
value: "{{ APPLICATIONNAME }}"
TASK [role1 : debug] *******************************************************
ok: [server1] => {
"vars": {
"applicationname": "{{ APPLICATIONNAME }}"
}
}
TASK [role1 : debug]
*****************************************************************************************************************************************************************************************
ok: [server1] => {
"applicationname": "VARIABLE IS NOT DEFINED!"
}
Any suggestions?
--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/59c89301-3552-45d6-9e44-bbeb4ec0611c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.