On 28. feb. 2017 19:38, Brian Coca wrote:
> As long as project_config is defined, if not you'll get an attribute
> error exception
I don't get any errors, here is the full playbook.
---
- name: project_config not set
hosts: localhost
tasks:
- debug: var=project_config
- name: "[] []"
debug: msg="This will not print {{ item }}"
with_items: " {{ (project_config | default([])).apt | default([]) }}"
- name: "{} []"
debug: msg="This will not print {{ item }}"
with_items: " {{ (project_config | default({})).apt | default([]) }}"
- name: "[] {}"
debug: msg="This will not print {{ item }}"
with_items: " {{ (project_config | default([])).apt | default({}) }}"
- name: "{} {}"
debug: msg="This will not print {{ item }}"
with_items: " {{ (project_config | default({})).apt | default({}) }}"
$ ansible-playbook --version
ansible-playbook 2.2.1.0
$ ansible-playbook test.yml
PLAY [project_config not set]
**************************************************
TASK [debug]
*******************************************************************
ok: [localhost] => {
"project_config": "VARIABLE IS NOT DEFINED!"
}
TASK [[] []]
*******************************************************************
TASK [{} []]
*******************************************************************
TASK [[] {}]
*******************************************************************
TASK [{} {}]
*******************************************************************
PLAY RECAP
*********************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=0
As you can see I don't get any errors.
--
Kai Stian Olstad