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

--
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/0323f606-efeb-623c-fba7-96f1bcbb43c0%40olstad.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to