community.windows.win_disk_facts module – Show the attached disks and disk information of the target host
Note
This module is part of the community.windows collection (version 1.13.0).
You might already have this collection installed if you are using the ansible
package.
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 community.windows
.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: community.windows.win_disk_facts
.
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)
Parameters
Parameter |
Comments |
---|---|
Allows to filter returned facts by type of disk information. If volumes are selected partitions will be returned as well. Choices:
Default: |
Notes
Note
In order to understand all the returned properties and values please visit the following site and open the respective MSFT class https://msdn.microsoft.com/en-us/library/windows/desktop/hh830612.aspx
Examples
- name: Get disk facts
community.windows.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[1].serial_number
- name: get disk physical_disk and partition facts on the target
win_disk_facts:
filter:
- physical_disk
- partitions
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.
Key |
Description |
---|---|
Detailed information about one particular disk. Returned: if disks were found |
|
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: if existent Sample: |
|
Location of the particular disk on the target. Returned: always Sample: |
|
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: |
|
Detailed information about one particular partition on the specified disk. Returned: if existent |
|
Access paths of the particular partition. Returned: if existent 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 particular partition. Returned: if existent 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: if existent 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: |
|
Detailed information about one particular volume on the specified partition. Returned: if existent |
|
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: |
|
Detailed information about physical disk properties of the particular disk. Returned: if existent |
|
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: |
|
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 |
|
Count of supported usage types. Returned: always Sample: |
|
List of supported usage types. Returned: always Sample: |
|
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: |
|
Detailed information about virtual disk properties of the particular disk. Returned: if existent |
|
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: if existent 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: if existent 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. Returned: if existent |
|
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: |