I want to do something like this below:

  - name: Create Simple list from Connection Dict
    set_fact:
      connections: "{{ connections | default([]) + [ {
        'switchid': item.id,
        'connectionid': item.connections[0].id
        } ] }}"
    when: item.connections                                     #only want 
to create facts if connections exist
    loop: "{{ connections_result.json.0.switchPorts | flatten }}"
    when: connections_result is defined                        #depending 
on the host,connection_result.json may not be defined so need  to check
When I run the playbook, I get the following warning at the top

[WARNING]: While constructing a mapping from /home/xxx/xxxxx.yml, line 245, 
column 5, found a duplicate dict key (when). Using last defined value only.

Is there a way to get both when to work?

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/22ccb77e-eeea-4f09-92d8-13cee35fcb48%40googlegroups.com.

Reply via email to