win_disk_facts - Show the attached disks and disk information of the target host

New in version 2.5.

Synopsis

  • With the module you can retrieve and output detailed information about the attached disks of the target and its volumes and partitions if existent.

Requirements

The below requirements are needed on the host that executes this module.

  • Windows 8.1 / Windows 2012 (NT 6.2)

Notes

Note

Examples

- name: Get disk facts
  win_disk_facts:

- name: Output first disk size
  debug:
    var: ansible_facts.disks[0].size

- name: Convert first system disk into various formats
  debug:
    msg: '{{ disksize_gib }} vs {{ disksize_gib_human }}'
  vars:
    # Get first system disk
    disk: '{{ ansible_facts.disks|selectattr("system_disk")|first }}'

    # Show disk size in Gibibytes
    disksize_gib_human: '{{ disk.size|filesizeformat(True) }}'   # returns "223.6 GiB" (human readable)
    disksize_gib: '{{ (disk.size/1024|pow(3))|round|int }} GiB'  # returns "224 GiB" (value in GiB)

    # Show disk size in Gigabytes
    disksize_gb_human: '{{ disk.size|filesizeformat }}'        # returns "240.1 GB" (human readable)
    disksize_gb: '{{ (disk.size/1000|pow(3))|round|int }} GB'  # returns "240 GB" (value in GB)

- name: Output second disk serial number
  debug:
    var: ansible_facts.disks[0].serial_number

Returned Facts

Facts returned by this module are added/updated in the hostvars host facts and can be referenced by name just like any other host fact. They do not need to be registered in order to use them.

Fact Returned Description
ansible_disks
list
if disks were found
Detailed information about one particular disk.

bus_type
string
always
Bus type of the particular disk.

Sample:
SCSI
physical_disk
complex
if existent
Detailed information about physical disk properties of the particular disk.

bus_type
string
always
Bus type of the particular physical disk.

Sample:
SCSI
operational_status
string
always
Operational status of the particular physical disk.

Sample:
OK
partial
bool
always
Information whether the particular physical disk is partial.

cannot_pool_reason
string
if can_pool property has value false
Information why the particular physical disk can not be added to a storage pool.

Sample:
Insufficient Capacity
media_type
string
always
Media type of the particular physical disk.

Sample:
UnSpecified
supported_usages
complex
always
Supported usage types of the particular physical disk.

Count
int
always
Count of supported usage types.

Sample:
5
value
string
always
List of supported usage types.

Sample:
Auto-Select, Hot Spare
usage_type
string
always
Usage type of the particular physical disk.

Sample:
Auto-Select
size
int
always
Size in bytes of the particular physical disk.

Sample:
240057409536
can_pool
bool
always
Information whether the particular physical disk can be added to a storage pool.

allocated_size
int
always
Allocated size in bytes of the particular physical disk.

Sample:
240057409536
friendly_name
string
always
Friendly name of the particular physical disk.

Sample:
PhysicalDisk0
object_id
string
always
Object ID of the particular physical disk.

Sample:
{1}\\\\HOST\\root/Microsoft/Windows/Storage/Providers_v2\\SPACES_PhysicalDisk.ObjectId=\"{<object_id>}:PD:{<pd>}\"
health_status
string
always
Health status of the particular physical disk.

Sample:
Healthy
indication_enabled
bool
always
Information whether indication is enabled for the particular physical disk.

Sample:
True
physical_location
string
always
Physical location of the particular physical disk.

Sample:
Integrated : Adapter 3 : Port 0 : Target 0 : LUN 0
serial_number
string
always
Serial number of the particular physical disk.

Sample:
b62beac80c3645e5877f
model
string
always
Model of the particular physical disk.

Sample:
Xen Block
manufacturer
string
always
Manufacturer of the particular physical disk.

Sample:
SUSE
spindle_speed
int
always
Spindle speed in rpm of the particular physical disk.

Sample:
4294967295
device_id
string
always
Device ID of the particular physical disk.

Sample:
0
unique_id
string
always
Unique ID of the particular physical disk.

Sample:
3141463431303031
virtual_disk
complex
if existent
Detailed information about virtual disk properties of the particular disk.

operational_status
string
always
Operational status of the particular virtual disk.

Sample:
OK
available_copies
int
if existent
Number of the available copies of the particular virtual disk.

Sample:
1
size
int
always
Size in bytes of the particular virtual disk.

Sample:
240057409536
physical_sector_size
int
always
Physical sector size in bytes of the particular virtual disk.

Sample:
4096
inter_leave
int
always
Inter leave in bytes of the particular virtual disk.

Sample:
102400
request_no_spof
bool
always
Information whether the particular virtual disk requests no single point of failure.

Sample:
True
object_id
string
always
Object ID of the particular virtual disk.

Sample:
{1}\\\\HOST\\root/Microsoft/Windows/Storage/Providers_v2\\SPACES_VirtualDisk.ObjectId=\"{<object_id>}:VD:{<vd>}\"
access
string
always
Access of the particular virtual disk.

Sample:
Read/Write
deduplication_enabled
bool
always
Information whether deduplication is enabled for the particular virtual disk.

Sample:
True
footprint_on_pool
int
always
Footprint on pool in bytes of the particular virtual disk.

Sample:
240057409536
provisioning_type
string
always
Provisioning type of the particular virtual disk.

Sample:
Thin
media_type
string
always
Media type of the particular virtual disk.

Sample:
Unspecified
logical_sector_size
int
always
Logical sector size in byte of the particular virtual disk.

Sample:
512
columns
int
always
Number of the columns of the particular virtual disk.

Sample:
2
manual_attach
bool
always
Information whether the particular virtual disk is manual attached.

Sample:
True
enclosure_aware
bool
always
Information whether the particular virtual disk is enclosure aware.

read_cache_size
int
always
Read cache size in byte of the particular virtual disk.

physical_disk_redundancy
int
always
Type of the physical disk redundancy of the particular virtual disk.

Sample:
1
groups
int
always
Number of the groups of the particular virtual disk.

Sample:
1
detached_reason
string
always
Detached reason of the particular virtual disk.

Sample:
None
write_cache_size
int
always
Write cache size in byte of the particular virtual disk.

Sample:
100
name
string
always
Name of the particular virtual disk.

Sample:
vDisk1
allocated_size
int
always
Allocated size in bytes of the particular virtual disk.

Sample:
240057409536
resiliency_setting_name
int
always
Type of the physical disk redundancy of the particular virtual disk.

Sample:
1
friendly_name
string
always
Friendly name of the particular virtual disk.

Sample:
Prod2 Virtual Disk
allocation_unit_size
int
always
Allocation unit size in bytes of the particular virtual disk.

Sample:
4096
unique_id_format
string
always
Unique ID format of the particular virtual disk.

Sample:
Vendor Specific
tiered
bool
always
Information whether the particular virtual disk is tiered.

Sample:
True
health_status
string
always
Health status of the particular virtual disk.

Sample:
Healthy
snapshot
bool
always
Information whether the particular virtual disk is a snapshot.

parity_layout
int
if existent
Parity layout of the particular virtual disk.

Sample:
1
unique_id
string
always
Unique ID of the particular virtual disk.

Sample:
260542E4C6B01D47A8FA7630FD90FFDE
fault_domain_awareness
string
always
Fault domain awareness of the particular virtual disk.

Sample:
PhysicalDisk
partition_style
string
always
Partition style of the particular disk.

Sample:
MBR
unique_id
string
always
Unique ID of the particular disk on the target.

Sample:
3141463431303031
number
int
always
Disk number of the particular disk.

clustered
bool
always
Information whether the particular disk is clustered (part of a failover cluster).

path
string
always
Path of the particular disk on the target.

Sample:
\\?\scsi#disk&ven_red_hat&prod_virtio#4&23208fd0&1&000000#{<id>}
firmware_version
string
always
Firmware version of the particular disk.

Sample:
0001
guid
string
if existent
GUID of the particular disk on the target.

Sample:
{efa5f928-57b9-47fc-ae3e-902e85fbe77f}
size
int
always
Size in bytes of the particular disk.

Sample:
227727638528
read_only
bool
always
Read only status of the particular disk.

Sample:
True
sector_size
int
always
Sector size in bytes of the particular disk.

Sample:
4096
bootable
bool
always
Information whether the particular disk is a bootable disk.

partitions
list
if existent
Detailed information about one particular partition on the specified disk.

transition_state
int
always
Transition state of the particular partition.

Sample:
1
no_default_driveletter
bool
if partition_style property of the particular disk has value "GPT"
Information whether the particular partition has a default drive letter or not.

Sample:
True
gpt_type
string
if partition_style property of the particular disk has value "GPT"
gpt type of the particular partition.

Sample:
{e3c9e316-0b5c-4db8-817d-f92df00215ae}
number
int
always
Number of the particular partition.

Sample:
1
access_paths
string
if existent
Access paths of the particular partition.

Sample:
\\?\Volume{85bdc4a8-f8eb-11e6-80fa-806e6f6e6963}\
shadow_copy
bool
always
Information whether the particular partition is a shadow copy of another partition.

mbr_type
int
if partition_style property of the particular disk has value "MBR"
mbr type of the particular partition.

Sample:
7
drive_letter
string
if existent
Drive letter of the particular partition.

Sample:
C
volumes
list
if existent
Detailed information about one particular volume on the specified partition.

allocation_unit_size
int
always
Allocation unit size in bytes of the particular volume.

Sample:
4096
object_id
string
always
Object ID of the particular volume.

Sample:
\\?\Volume{85bdc4a9-f8eb-11e6-80fa-806e6f6e6963}\
label
string
always
File system label of the particular volume.

Sample:
System Reserved
size_remaining
int
always
Remaining size in bytes of the particular volume.

Sample:
395620352
health_status
string
always
Health status of the particular volume.

Sample:
Healthy
drive_type
string
always
Drive type of the particular volume.

Sample:
Fixed
path
string
always
Path of the particular volume.

Sample:
\\?\Volume{85bdc4a9-f8eb-11e6-80fa-806e6f6e6963}\
type
string
always
File system type of the particular volume.

Sample:
NTFS
size
int
always
Size in bytes of the particular volume.

Sample:
838856704
offset
int
always
Offset of the particular partition.

Sample:
368050176
active
bool
if partition_style property of the particular disk has value "MBR"
Information whether the particular partition is an active partition or not.

Sample:
True
hidden
bool
always
Information whether the particular partition is hidden or not.

Sample:
True
guid
string
if existent
GUID of the particular partition.

Sample:
{302e475c-6e64-4674-a8e2-2f1c7018bf97}
type
string
always
Type of the particular partition.

Sample:
IFS
size
int
always
Size in bytes of the particular partition.

Sample:
838860800
operational_status
string
always
Operational status of the particular disk.

Sample:
Online
friendly_name
string
always
Friendly name of the particular disk.

Sample:
Red Hat VirtIO SCSI Disk Device
partition_count
int
always
Number of partitions on the particular disk.

Sample:
4
location
string
always
Location of the particular disk on the target.

Sample:
PCIROOT(0)#PC0400#SCSP00T00L00
serial_number
string
always
Serial number of the particular disk on the target.

Sample:
b62beac80c3645e5877f
model
string
always
Model specification of the particular disk.

Sample:
VirtIO
manufacturer
string
always
Manufacturer of the particular disk.

Sample:
Red Hat
system_disk
bool
always
Information whether the particular disk is a system disk.

Sample:
True


Status

This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.

Author

  • Marc Tschapek (@marqelme)

Hint

If you notice any issues in this documentation you can edit this document to improve it.

© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.5/modules/win_disk_facts_module.html