Looping through win_disk_facts to detect drives and init them

I am trying to come up with a task that will step through the drives it finds from win_disk_facts and init them. This is my attempt so far. Any help would be appreciated.

  • name: Get disk facts
    community.windows.win_disk_facts:

  • name: Print out disks!
    community.windows.win_initialize_disk:
    loop: “{{ ansible_facts.disks }}”
    loop_control:
    loop_var: disk.number

  • AJ

It looks like this works!

  • name: Get disk facts
    community.windows.win_disk_facts:

  • name: Print out disks!
    community.windows.win_initialize_disk:
    disk_number: “{{ disk.number }}”
    loop: “{{ ansible_facts.disks }}”
    loop_control:
    loop_var: disk
    when: ansible_disks[disk_number].guid is none

However, the output seems to be a large block of unused values. Is there a way to clean that up?

  • AJ