Given string `'vivek'` to be search in below nested data structure & if string `'vivek'` present then I want outer `'id'` using ansible playbook:

```
{'results': [{'details': [{'id': '1', 'name': 'vivek'},
                          {'id': '2', 'name': 'ashwin'}],
              'id': '100'},
             {'details': [], 'id': '101'},
             {'details': [{'id': '1', 'name': 'vivek'},
                          {'id': '2', 'name': 'ashwin'}],
              'id': '102'}]}

```

Output required:

```
skipping: [localhost] => (item=['101'])
ok: [localhost] => (item=['100') => {
    "msg": "100"
}
ok: [localhost] => (item=['102') => {
    "msg": "102"
}

```

I tried:

```
- name: List IDs which contains 'vivek'
  hosts: localhost
  connection: local
  vars:
    results:
      - id: '100'
        details:
          - id: '1'
            name: 'vivek'
          - id: '2'
            name: 'ashwin'
      - id: '101'
        details:
          -
      - id: '102'
        details:
          - id: '1'
            name: 'vivek'
          - id: '2'
            name: 'ashwin'
  tasks:

    - debug:
        var: results

    - set_fact:
        all_details: "{{ results | map(attribute='details') | list }}"

    - debug:
        var: all_details

#    - name: List of IDs, contains 'vivek'
#      debug:
#        msg: "{{ item.id }}"
#      loop: "{{ all_details }}"
#      when: 'vivek' in items.names

```