Get Key if value is true

Viewed 44

i have a Playbook that looks like this:

---
- hosts: localhost
  gather_facts: no
  vars:
    netapp_hostname: "hostname"
  tasks:
    - debug:
        msg: "{{ ontap_info.ontap_info.aggregate_info }}"
    - debug:
        msg: "{{ ontap_info.ontap_info.aggregate_info|list }}"
  roles:
   - get_aggr_max_free
...

i get a dict as output that looks like this:

        "aggr1_hyb_fas_01": { 
            "aggr_raid_attributes": { 
                ...
                "is_mirrored": "false" 
                ...  
            },  
        "aggr1_sl_fas_02": { 
            "aggr_raid_attributes": { 
                ...
                "is_mirrored": "false" 
                ...
        }

ok: [localhost] => {
    "msg": [
        "aggr0_sata_fas_01", 
        "aggr0_sata_fas_02", 
        "aggr1_hyb_fas_01", 
        "aggr1_sl_fas_02"
    ]
}

I want to print the aggregate name, for example aggr1_hyb_fas_01 only if "is_mirrored": "true" but i don't know the aggregate name before play. There are more aggr_raid_attributes but i had to cut them.

Ty for helping

0 Answers
Related