Hi Team

I am calling a simple function

- name: Setting vm key value
      set_fact:
        vm_key: "{{ item.1.key }}"
      when: item.0.key == item.1.value.name
      with_nested:
      - "{{ ia_hosts_copy }}"
      - "{{ vm_copy }}"

where 
   - name: Creating list of sm_hosts
      set_fact:
        ia_hosts_copy: "{{ lookup('dict', sm_list) }}"

In case there is only 1 item is defined in the list, ansible gives the error

"ansible_facts": {
        "ia_hosts_copy": {
            "key": "j3chysr01stg05",
            "value": {
                "globalDeviceId": "",
                "vrrp": {
                    "associated_sm": [
                        "103"
                    ]
                }
            }
        }
    },

fatal: [j3chysr01stg05]: FAILED! => {"msg": "The task includes an option 
with an undefined variable. The error was: 
'ansible.utils.unsafe_proxy.AnsibleUnsafeText object' has no attribute 
'key'\n\nThe error appears to be in '/import/software/test.yml': line 35, 
column 7, but may\nbe elsewhere in the file depending on the exact syntax 
problem.\n\nThe offending line appears to be:\n\n\n    - name:  Setting vm 
key value  \n      ^ here\n"}

*The code works fine, if minimum 2 item are defined in ia_hosts_copy*

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-devel/30bc1e18-6df2-48fe-98a6-d34ce1531e16n%40googlegroups.com.

Reply via email to