title: Ansible: Using ansible facts, how can I get a disk device based on the storage controller value and then set the device as a variable
body: <p>Context: I have a system that has a combination of disks from different storage controllers, so each type of disk has different purpose. I'm new to ansible and learning as I go. Writing a playbook that gets the disk from each type of controller so I can set them up.</p>
  
  <p>Ex. Below is sample output from #'filter=ansible_devices*' ... sdz device is from SATA controller. On my other hosts it might not always be sdz.. so I want to get the device name and store in a variable if in the facts the device has "host": "SATA controller". I'm thinking maybe I need to traverse through ansible_devices dictionaries, find the key that matches ("host": "SATA controller") and then get the parent dict for it which would be the device. Is there a way to do that.. or easier way? :)</p>
  
  <pre><code>"sdz": {
              "holders": [
                  "mpathz"
              ],
              "host": "SATA controller: Intel Corporation C610/X99 series chipset 6-Port SATA Controller [AHCI mode] (rev 05)",
              "links": {
                  "ids": [
                      "ata-SAMSUNG_MZ7GE960HMHP-00003_S1Y2NYAFC02269",
                      "wwn-0x50025388003aeb2a"
                  ],
                  "labels": [],
                  "masters": [
                      "dm-19"
                  ],
                  "uuids": []
              },
              "model": "SAMSUNG MZ7GE960",
              "partitions": {},
              "removable": "0",
              "rotational": "0",
              "sas_address": null,
              "sas_device_handle": null,
              "scheduler_mode": "cfq",
              "sectors": "1875385008",
              "sectorsize": "512",
              "serial": "S1Y2NYAFC02269",
              "size": "894.25 GB",
              "support_discard": "512",
              "vendor": "ATA",
              "virtual": 1,
              "wwn": "0x50025388003aeb2a"
  </code></pre>