Looping through win_disk_facts to detect drives and init them

66 views
Skip to first unread message

A J

unread,
Apr 20, 2021, 10:51:56 AM4/20/21
to Ansible Project
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

A J

unread,
Apr 20, 2021, 12:01:13 PM4/20/21
to Ansible Project
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
Reply all
Reply to author
Forward
0 new messages