ansible.windows.win_disk_info module – Gather disk, partition, and volume information on Windows
Note
This module is part of the ansible.windows collection (version 3.9.1).
It is not included in ansible-core.
To check whether it is installed, run ansible-galaxy collection list.
To install it, use: ansible-galaxy collection install ansible.windows.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: ansible.windows.win_disk_info.
New in ansible.windows 3.10.0
Synopsis
Gathers information about disks visible to the Windows Storage provider and their physical backing devices, virtual disks, partitions, and volumes.
Returns a
diskslist without setting Ansible facts or changing disk state.
Requirements
The below requirements are needed on the host that executes this module.
Windows Server 2016 or newer
Storage PowerShell module
An elevated administrator account
Parameters
Parameter |
Comments |
|---|---|
Select a disk by its operating-system disk number. Must be greater than or equal to zero. Mutually exclusive with unique_id and path. |
|
Selects which additional disk information is returned. Selecting Selecting Selecting An empty list returns only base disk properties. Choices:
Default: |
|
Select a disk by its device path using an exact match. Must not be empty or whitespace. Mutually exclusive with disk_number and unique_id. |
|
Select a disk by its unique ID using an exact match. Must not be empty or whitespace. Mutually exclusive with disk_number and path. |
Notes
Note
All disks with a local disk number are returned when no selector is supplied.
A selector matching no disk returns
exists=falseand an emptydiskslist.Dynamic disks are not returned by
Get-Disk. Storage providers can expose cluster-wide objects; disks without a local disk number are excluded.Unrequested optional sections are omitted. Requested partition and volume collections are lists, including when empty.
Requested physical and virtual information can be unavailable.
physical_diskscontains all unambiguously associated backing devices;physical_diskis null unless exactly one is associated.Provider errors fail the module rather than being reported as missing information.
Optional provider properties can be null. Array properties remain lists, including when empty.
See Also
See also
- ansible.windows.win_initialize_disk
Initializes disks on Windows Server.
- ansible.windows.win_initialize_disk_info
Gather information about disks on Windows Server.
- ansible.windows.win_partition_info
Gather information about Windows disk partitions.
Examples
- name: Gather detailed disk information
ansible.windows.win_disk_info:
register: disk_info
- name: Display discovered disks
ansible.builtin.debug:
var: disk_info.disks
- name: Query one disk with partition and volume information
ansible.windows.win_disk_info:
disk_number: 1
filter:
- volumes
register: selected_disk
- name: Query a disk by its stable unique ID
ansible.windows.win_disk_info:
unique_id: "60003979-3838-8288-1234-56789abcdef0"
filter: []
register: selected_disk
- name: Query virtual disk information independently
ansible.windows.win_disk_info:
filter:
- virtual_disk
register: virtual_disk_info
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
|---|---|
Detailed information about the disks visible to the target host. Returned: always |
|
Allocated size of the disk in bytes. Returned: always |
|
Information whether the particular disk is a bootable disk. Returned: always Sample: |
|
Bus type of the particular disk. Returned: always Sample: |
|
Information whether the particular disk is clustered (part of a failover cluster). Returned: always Sample: |
|
Firmware version of the particular disk. Returned: always Sample: |
|
Friendly name of the particular disk. Returned: always Sample: |
|
GUID of the particular disk on the target. Returned: always Sample: |
|
Health status reported by the Storage provider. Returned: always |
|
Whether the disk is offline. Returned: always |
|
Location of the particular disk on the target. Returned: always Sample: |
|
Logical sector size of the disk in bytes. Returned: always |
|
Manufacturer of the particular disk. Returned: always Sample: |
|
Model specification of the particular disk. Returned: always Sample: |
|
Disk number of the particular disk. Returned: always Sample: |
|
Operational status of the particular disk. Returned: always Sample: |
|
Number of partitions on the particular disk. Returned: always Sample: |
|
Partition style of the particular disk. Returned: always Sample: |
|
Partitions on the disk, ordered by partition number. Returned: when requested |
|
Access paths of the particular partition. Returned: always Sample: |
|
Information whether the particular partition is an active partition or not. Returned: if partition_style property of the particular disk has value “MBR” Sample: |
|
Drive letter of the partition, or null when no letter is assigned. Returned: always Sample: |
|
gpt type of the particular partition. Returned: if partition_style property of the particular disk has value “GPT” Sample: |
|
GUID of the particular partition. Returned: always Sample: |
|
Information whether the particular partition is hidden or not. Returned: always Sample: |
|
mbr type of the particular partition. Returned: if partition_style property of the particular disk has value “MBR” Sample: |
|
Information whether the particular partition has a default drive letter or not. Returned: if partition_style property of the particular disk has value “GPT” Sample: |
|
Number of the particular partition. Returned: always Sample: |
|
Offset of the particular partition. Returned: always Sample: |
|
Information whether the particular partition is a shadow copy of another partition. Returned: always Sample: |
|
Size in bytes of the particular partition. Returned: always Sample: |
|
Transition state of the particular partition. Returned: always Sample: |
|
Type of the particular partition. Returned: always Sample: |
|
Volumes associated with the partition, including an empty list when none are associated. Returned: when requested |
|
Allocation unit size in bytes of the particular volume. Returned: always Sample: |
|
Drive type of the particular volume. Returned: always Sample: |
|
Health status of the particular volume. Returned: always Sample: |
|
File system label of the particular volume. Returned: always Sample: |
|
Object ID of the particular volume. Returned: always Sample: |
|
Path of the particular volume. Returned: always Sample: |
|
Size in bytes of the particular volume. Returned: always Sample: |
|
Remaining size in bytes of the particular volume. Returned: always Sample: |
|
File system type of the particular volume. Returned: always Sample: |
|
Path of the particular disk on the target. Returned: always Sample: |
|
Physical disk properties when exactly one backing device is associated; otherwise null. Returned: when requested |
|
Allocated size in bytes of the particular physical disk. Returned: always Sample: |
|
Bus type of the particular physical disk. Returned: always Sample: |
|
Information whether the particular physical disk can be added to a storage pool. Returned: always Sample: |
|
Information why the particular physical disk can not be added to a storage pool. Returned: if can_pool property has value false Sample: |
|
Device ID of the particular physical disk. Returned: always Sample: |
|
Firmware version. Returned: always |
|
Friendly name of the particular physical disk. Returned: always Sample: |
|
Health status of the particular physical disk. Returned: always Sample: |
|
Information whether indication is enabled for the particular physical disk. Returned: always Sample: |
|
Manufacturer of the particular physical disk. Returned: always Sample: |
|
Media type of the particular physical disk. Returned: always Sample: |
|
Model of the particular physical disk. Returned: always Sample: |
|
Object ID of the particular physical disk. Returned: always Sample: |
|
Operational status of the particular physical disk. Returned: always Sample: |
|
Information whether the particular physical disk is partial. Returned: always Sample: |
|
Physical location of the particular physical disk. Returned: always Sample: |
|
Serial number of the particular physical disk. Returned: always Sample: |
|
Size in bytes of the particular physical disk. Returned: always Sample: |
|
Spindle speed in rpm of the particular physical disk. Returned: always Sample: |
|
Supported usage types of the particular physical disk. Returned: always |
|
Unique ID of the particular physical disk. Returned: always Sample: |
|
Usage type of the particular physical disk. Returned: always Sample: |
|
All physical backing devices associated with the disk. Empty when no association is available. Returned: when physical_disk is requested |
|
Allocated size in bytes of the particular physical disk. Returned: always Sample: |
|
Bus type of the particular physical disk. Returned: always Sample: |
|
Information whether the particular physical disk can be added to a storage pool. Returned: always Sample: |
|
Information why the particular physical disk can not be added to a storage pool. Returned: if can_pool property has value false Sample: |
|
Device ID of the particular physical disk. Returned: always Sample: |
|
Firmware version. Returned: always |
|
Friendly name of the particular physical disk. Returned: always Sample: |
|
Health status of the particular physical disk. Returned: always Sample: |
|
Information whether indication is enabled for the particular physical disk. Returned: always Sample: |
|
Manufacturer of the particular physical disk. Returned: always Sample: |
|
Media type of the particular physical disk. Returned: always Sample: |
|
Model of the particular physical disk. Returned: always Sample: |
|
Object ID of the particular physical disk. Returned: always Sample: |
|
Operational status of the particular physical disk. Returned: always Sample: |
|
Information whether the particular physical disk is partial. Returned: always Sample: |
|
Physical location of the particular physical disk. Returned: always Sample: |
|
Serial number of the particular physical disk. Returned: always Sample: |
|
Size in bytes of the particular physical disk. Returned: always Sample: |
|
Spindle speed in rpm of the particular physical disk. Returned: always Sample: |
|
Supported usage types of the particular physical disk. Returned: always |
|
Unique ID of the particular physical disk. Returned: always Sample: |
|
Usage type of the particular physical disk. Returned: always Sample: |
|
Read only status of the particular disk. Returned: always Sample: |
|
Sector size in bytes of the particular disk. Returned: always Sample: |
|
Serial number of the particular disk on the target. Returned: always Sample: |
|
Size in bytes of the particular disk. Returned: always Sample: |
|
Information whether the particular disk is a system disk. Returned: always Sample: |
|
Unique ID of the particular disk on the target. Returned: always Sample: |
|
Virtual disk properties, or null when no virtual disk is associated. Returned: when requested |
|
Access of the particular virtual disk. Returned: always Sample: |
|
Allocated size in bytes of the particular virtual disk. Returned: always Sample: |
|
Allocation unit size in bytes of the particular virtual disk. Returned: always Sample: |
|
Number of the available copies of the particular virtual disk. Returned: always Sample: |
|
Number of the columns of the particular virtual disk. Returned: always Sample: |
|
Information whether deduplication is enabled for the particular virtual disk. Returned: always Sample: |
|
Detached reason of the particular virtual disk. Returned: always Sample: |
|
Information whether the particular virtual disk is enclosure aware. Returned: always Sample: |
|
Fault domain awareness of the particular virtual disk. Returned: always Sample: |
|
Footprint on pool in bytes of the particular virtual disk. Returned: always Sample: |
|
Friendly name of the particular virtual disk. Returned: always Sample: |
|
Number of the groups of the particular virtual disk. Returned: always Sample: |
|
Health status of the particular virtual disk. Returned: always Sample: |
|
Inter leave in bytes of the particular virtual disk. Returned: always Sample: |
|
Logical sector size in byte of the particular virtual disk. Returned: always Sample: |
|
Information whether the particular virtual disk is manual attached. Returned: always Sample: |
|
Media type of the particular virtual disk. Returned: always Sample: |
|
Name of the particular virtual disk. Returned: always Sample: |
|
Object ID of the particular virtual disk. Returned: always Sample: |
|
Operational status of the particular virtual disk. Returned: always Sample: |
|
Parity layout of the particular virtual disk. Returned: always Sample: |
|
Type of the physical disk redundancy of the particular virtual disk. Returned: always Sample: |
|
Physical sector size in bytes of the particular virtual disk. Returned: always Sample: |
|
Provisioning type of the particular virtual disk. Returned: always Sample: |
|
Read cache size in byte of the particular virtual disk. Returned: always Sample: |
|
Information whether the particular virtual disk requests no single point of failure. Returned: always Sample: |
|
Type of the physical disk redundancy of the particular virtual disk. Returned: always Sample: |
|
Size in bytes of the particular virtual disk. Returned: always Sample: |
|
Information whether the particular virtual disk is a snapshot. Returned: always Sample: |
|
Information whether the particular virtual disk is tiered. Returned: always Sample: |
|
Unique ID of the particular virtual disk. Returned: always Sample: |
|
Unique ID format of the particular virtual disk. Returned: always Sample: |
|
Write cache size in byte of the particular virtual disk. Returned: always Sample: |
|
Representation of the Win32_DiskDrive class, or null when no drive is associated. Returned: when requested |
|
Availability and status of the device. Returned: always |
|
Number of bytes in each sector for the physical disk drive. Returned: always Sample: |
|
Array of capabilities of the media access device. For example, the device may support random access (3), removable media (7), and automatic cleaning (9). Returned: always Sample: |
|
List of more detailed explanations for any of the access device features indicated in the Capabilities array. Note, each entry of this array is related to the entry in the Capabilities array that is located at the same index. Returned: always Sample: |
|
Short description of the object. Returned: always Sample: |
|
Algorithm or tool used by the device to support compression. Returned: always Sample: |
|
Windows Configuration Manager error code. Returned: always Sample: |
|
If True, the device is using a user-defined configuration. Returned: always Sample: |
|
Name of the first concrete class to appear in the inheritance chain used in the creation of an instance. When used with the other key properties of the class, the property allows all instances of this class and its subclasses to be uniquely identified. Returned: always Sample: |
|
Default block size, in bytes, for this device. Returned: always Sample: |
|
Description of the object. Returned: always Sample: |
|
Unique identifier of the disk drive with other devices on the system. Returned: always Sample: |
|
If True, the error reported in LastErrorCode is now cleared. Returned: always Sample: |
|
More information about the error recorded in LastErrorCode, and information on any corrective actions that may be taken. Returned: always |
|
Type of error detection and correction supported by this device. Returned: always |
|
Revision for the disk drive firmware that is assigned by the manufacturer. Returned: always Sample: |
|
Physical drive number of the given drive. This property is filled by the STORAGE_DEVICE_NUMBER structure returned from the IOCTL_STORAGE_GET_DEVICE_NUMBER control code A value of 0xffffffff indicates that the given drive does not map to a physical drive. Returned: always Sample: |
|
Date and time the object was installed. This property does not need a value to indicate that the object is installed. Returned: always |
|
Interface type of physical disk drive. Returned: always Sample: |
|
Last error code reported by the logical device. Returned: always |
|
Name of the disk drive manufacturer. Returned: always Sample: |
|
Maximum block size, in bytes, for media accessed by this device. Returned: always |
|
Maximum media size, in kilobytes, of media supported by this device. Returned: always |
|
If True, the media for a disk drive is loaded, which means that the device has a readable file system and is accessible. For fixed disk drives, this property will always be TRUE. Returned: always Sample: |
|
Type of media used or accessed by this device. Returned: always Sample: |
|
Minimum block size, in bytes, for media accessed by this device. Returned: always |
|
Manufacturer’s model number of the disk drive. Returned: always Sample: |
|
Label by which the object is known. When subclassed, the property can be overridden to be a key property. Returned: always Sample: |
|
If True, the media access device needs cleaning. Whether manual or automatic cleaning is possible is indicated in the Capabilities property. Returned: always |
|
Maximum number of media which can be supported or inserted (when the media access device supports multiple individual media). Returned: always |
|
Number of partitions on this physical disk drive that are recognized by the operating system. Returned: always Sample: |
|
Windows Plug and Play device identifier of the logical device. Returned: always Sample: |
|
Array of the specific power-related capabilities of a logical device. Returned: always |
|
If True, the device can be power-managed (can be put into suspend mode, and so on). The property does not indicate that power management features are currently enabled, only that the logical device is capable of power management. Returned: always |
|
SCSI bus number of the disk drive. Returned: always Sample: |
|
SCSI logical unit number (LUN) of the disk drive. Returned: always Sample: |
|
SCSI port number of the disk drive. Returned: always Sample: |
|
SCSI identifier number of the disk drive. Returned: always Sample: |
|
Number of sectors in each track for this physical disk drive. Returned: always Sample: |
|
Number allocated by the manufacturer to identify the physical media. Returned: always Sample: |
|
Disk identification. This property can be used to identify a shared resource. Returned: always |
|
Size of the disk drive. It is calculated by multiplying the total number of cylinders, tracks in each cylinder, sectors in each track, and bytes in each sector. Returned: always Sample: |
|
Current status of the object. Various operational and nonoperational statuses can be defined. Operational statuses include: “OK”, “Degraded”, and “Pred Fail” (an element, such as a SMART-enabled hard disk drive, may be functioning properly but predicting a failure in the near future). Nonoperational statuses include: “Error”, “Starting”, “Stopping”, and “Service”. “Service”, could apply during mirror-resilvering of a disk, reload of a user permissions list, or other administrative work. Not all such work is online, yet the managed element is neither “OK” nor in one of the other states. Returned: always Sample: |
|
State of the logical device. If this property does not apply to the logical device, the value 5 (Not Applicable) should be used. Returned: always |
|
Value of the scoping computer’s CreationClassName property. Returned: always Sample: |
|
Name of the scoping system. Returned: always Sample: |
|
Total number of cylinders on the physical disk drive. Note: the value for this property is obtained through extended functions of BIOS interrupt 13h. The value may be inaccurate if the drive uses a translation scheme to support high-capacity disk sizes. Consult the manufacturer for accurate drive specifications. Returned: always Sample: |
|
Total number of heads on the disk drive. Note: the value for this property is obtained through extended functions of BIOS interrupt 13h. The value may be inaccurate if the drive uses a translation scheme to support high-capacity disk sizes. Consult the manufacturer for accurate drive specifications. Returned: always Sample: |
|
Total number of sectors on the physical disk drive. Note: the value for this property is obtained through extended functions of BIOS interrupt 13h. The value may be inaccurate if the drive uses a translation scheme to support high-capacity disk sizes. Consult the manufacturer for accurate drive specifications. Returned: always Sample: |
|
Total number of tracks on the physical disk drive. Note: the value for this property is obtained through extended functions of BIOS interrupt 13h. The value may be inaccurate if the drive uses a translation scheme to support high-capacity disk sizes. Consult the manufacturer for accurate drive specifications. Returned: always Sample: |
|
Number of tracks in each cylinder on the physical disk drive. Note: the value for this property is obtained through extended functions of BIOS interrupt 13h. The value may be inaccurate if the drive uses a translation scheme to support high-capacity disk sizes. Consult the manufacturer for accurate drive specifications. Returned: always Sample: |
|
Whether any disks matched the selector. Returned: always Sample: |