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.10.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
.
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: [“physical_disk”, “virtual_disk”, “win32_disk_drive”, “partitions”, “volumes”] |
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: false |
|
Bus type of the particular disk. Returned: always Sample: “SCSI” |
|
Information whether the particular disk is clustered (part of a failover cluster). Returned: always Sample: false |
|
Firmware version of the particular disk. Returned: always Sample: “0001” |
|
Friendly name of the particular disk. Returned: always Sample: “Red Hat VirtIO SCSI Disk Device” |
|
GUID of the particular disk on the target. Returned: if existent Sample: “{efa5f928-57b9-47fc-ae3e-902e85fbe77f}” |
|
Location of the particular disk on the target. Returned: always Sample: “PCIROOT(0)#PCI(0400)#SCSI(P00T00L00)” |
|
Manufacturer of the particular disk. Returned: always Sample: “Red Hat” |
|
Model specification of the particular disk. Returned: always Sample: “VirtIO” |
|
Disk number of the particular disk. Returned: always Sample: 0 |
|
Operational status of the particular disk. Returned: always Sample: “Online” |
|
Number of partitions on the particular disk. Returned: always Sample: 4 |
|
Partition style of the particular disk. Returned: always Sample: “MBR” |
|
Detailed information about one particular partition on the specified disk. Returned: if existent |
|
Access paths of the particular partition. Returned: if existent Sample: “\\\\?\\Volume{85bdc4a8-f8eb-11e6-80fa-806e6f6e6963}\\” |
|
Information whether the particular partition is an active partition or not. Returned: if partition_style property of the particular disk has value “MBR” Sample: true |
|
Drive letter of the particular partition. Returned: if existent Sample: “C” |
|
gpt type of the particular partition. Returned: if partition_style property of the particular disk has value “GPT” Sample: “{e3c9e316-0b5c-4db8-817d-f92df00215ae}” |
|
GUID of the particular partition. Returned: if existent Sample: “{302e475c-6e64-4674-a8e2-2f1c7018bf97}” |
|
Information whether the particular partition is hidden or not. Returned: always Sample: true |
|
mbr type of the particular partition. Returned: if partition_style property of the particular disk has value “MBR” Sample: 7 |
|
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: true |
|
Number of the particular partition. Returned: always Sample: 1 |
|
Offset of the particular partition. Returned: always Sample: 368050176 |
|
Information whether the particular partition is a shadow copy of another partition. Returned: always Sample: false |
|
Size in bytes of the particular partition. Returned: always Sample: 838860800 |
|
Transition state of the particular partition. Returned: always Sample: 1 |
|
Type of the particular partition. Returned: always Sample: “IFS” |
|
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: 4096 |
|
Drive type of the particular volume. Returned: always Sample: “Fixed” |
|
Health status of the particular volume. Returned: always Sample: “Healthy” |
|
File system label of the particular volume. Returned: always Sample: “System Reserved” |
|
Object ID of the particular volume. Returned: always Sample: “\\\\?\\Volume{85bdc4a9-f8eb-11e6-80fa-806e6f6e6963}\\” |
|
Path of the particular volume. Returned: always Sample: “\\\\?\\Volume{85bdc4a9-f8eb-11e6-80fa-806e6f6e6963}\\” |
|
Size in bytes of the particular volume. Returned: always Sample: 838856704 |
|
Remaining size in bytes of the particular volume. Returned: always Sample: 395620352 |
|
File system type of the particular volume. Returned: always Sample: “NTFS” |
|
Path of the particular disk on the target. Returned: always Sample: “\\\\?\\scsi#disk\u0026ven_red_hat\u0026prod_virtio#4\u002623208fd0\u00261\u0026000000#{\u003cid\u003e}” |
|
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: 240057409536 |
|
Bus type of the particular physical disk. Returned: always Sample: “SCSI” |
|
Information whether the particular physical disk can be added to a storage pool. Returned: always Sample: false |
|
Information why the particular physical disk can not be added to a storage pool. Returned: if can_pool property has value false Sample: “Insufficient Capacity” |
|
Device ID of the particular physical disk. Returned: always Sample: “0” |
|
Friendly name of the particular physical disk. Returned: always Sample: “PhysicalDisk0” |
|
Health status of the particular physical disk. Returned: always Sample: “Healthy” |
|
Information whether indication is enabled for the particular physical disk. Returned: always Sample: true |
|
Manufacturer of the particular physical disk. Returned: always Sample: “SUSE” |
|
Media type of the particular physical disk. Returned: always Sample: “UnSpecified” |
|
Model of the particular physical disk. Returned: always Sample: “Xen Block” |
|
Object ID of the particular physical disk. Returned: always Sample: “{1}\\\\\\\\HOST\\\\root/Microsoft/Windows/Storage/Providers_v2\\\\SPACES_PhysicalDisk.ObjectId=\\\”{\u003cobject_id\u003e}:PD:{\u003cpd\u003e}\\\”” |
|
Operational status of the particular physical disk. Returned: always Sample: “OK” |
|
Information whether the particular physical disk is partial. Returned: always Sample: false |
|
Physical location of the particular physical disk. Returned: always Sample: “Integrated : Adapter 3 : Port 0 : Target 0 : LUN 0” |
|
Serial number of the particular physical disk. Returned: always Sample: “b62beac80c3645e5877f” |
|
Size in bytes of the particular physical disk. Returned: always Sample: 240057409536 |
|
Spindle speed in rpm of the particular physical disk. Returned: always Sample: 4294967295 |
|
Supported usage types of the particular physical disk. Returned: always |
|
Count of supported usage types. Returned: always Sample: 5 |
|
List of supported usage types. Returned: always Sample: “Auto-Select, Hot Spare” |
|
Unique ID of the particular physical disk. Returned: always Sample: “3141463431303031” |
|
Usage type of the particular physical disk. Returned: always Sample: “Auto-Select” |
|
Read only status of the particular disk. Returned: always Sample: true |
|
Sector size in bytes of the particular disk. Returned: always Sample: 4096 |
|
Serial number of the particular disk on the target. Returned: always Sample: “b62beac80c3645e5877f” |
|
Size in bytes of the particular disk. Returned: always Sample: 227727638528 |
|
Information whether the particular disk is a system disk. Returned: always Sample: true |
|
Unique ID of the particular disk on the target. Returned: always Sample: “3141463431303031” |
|
Detailed information about virtual disk properties of the particular disk. Returned: if existent |
|
Access of the particular virtual disk. Returned: always Sample: “Read/Write” |
|
Allocated size in bytes of the particular virtual disk. Returned: always Sample: 240057409536 |
|
Allocation unit size in bytes of the particular virtual disk. Returned: always Sample: 4096 |
|
Number of the available copies of the particular virtual disk. Returned: if existent Sample: 1 |
|
Number of the columns of the particular virtual disk. Returned: always Sample: 2 |
|
Information whether deduplication is enabled for the particular virtual disk. Returned: always Sample: true |
|
Detached reason of the particular virtual disk. Returned: always Sample: “None” |
|
Information whether the particular virtual disk is enclosure aware. Returned: always Sample: false |
|
Fault domain awareness of the particular virtual disk. Returned: always Sample: “PhysicalDisk” |
|
Footprint on pool in bytes of the particular virtual disk. Returned: always Sample: 240057409536 |
|
Friendly name of the particular virtual disk. Returned: always Sample: “Prod2 Virtual Disk” |
|
Number of the groups of the particular virtual disk. Returned: always Sample: 1 |
|
Health status of the particular virtual disk. Returned: always Sample: “Healthy” |
|
Inter leave in bytes of the particular virtual disk. Returned: always Sample: 102400 |
|
Logical sector size in byte of the particular virtual disk. Returned: always Sample: 512 |
|
Information whether the particular virtual disk is manual attached. Returned: always Sample: true |
|
Media type of the particular virtual disk. Returned: always Sample: “Unspecified” |
|
Name of the particular virtual disk. Returned: always Sample: “vDisk1” |
|
Object ID of the particular virtual disk. Returned: always Sample: “{1}\\\\\\\\HOST\\\\root/Microsoft/Windows/Storage/Providers_v2\\\\SPACES_VirtualDisk.ObjectId=\\\”{\u003cobject_id\u003e}:VD:{\u003cvd\u003e}\\\”” |
|
Operational status of the particular virtual disk. Returned: always Sample: “OK” |
|
Parity layout of the particular virtual disk. Returned: if existent Sample: 1 |
|
Type of the physical disk redundancy of the particular virtual disk. Returned: always Sample: 1 |
|
Physical sector size in bytes of the particular virtual disk. Returned: always Sample: 4096 |
|
Provisioning type of the particular virtual disk. Returned: always Sample: “Thin” |
|
Read cache size in byte of the particular virtual disk. Returned: always Sample: 0 |
|
Information whether the particular virtual disk requests no single point of failure. Returned: always Sample: true |
|
Type of the physical disk redundancy of the particular virtual disk. Returned: always Sample: 1 |
|
Size in bytes of the particular virtual disk. Returned: always Sample: 240057409536 |
|
Information whether the particular virtual disk is a snapshot. Returned: always Sample: false |
|
Information whether the particular virtual disk is tiered. Returned: always Sample: true |
|
Unique ID of the particular virtual disk. Returned: always Sample: “260542E4C6B01D47A8FA7630FD90FFDE” |
|
Unique ID format of the particular virtual disk. Returned: always Sample: “Vendor Specific” |
|
Write cache size in byte of the particular virtual disk. Returned: always Sample: 100 |
|
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: 512 |
|
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: [3, 4] |
|
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: [“Random Access”, “Supports Writing”] |
|
Short description of the object. Returned: always Sample: “VMware Virtual disk SCSI Disk Device” |
|
Algorithm or tool used by the device to support compression. Returned: always Sample: “Compressed” |
|
Windows Configuration Manager error code. Returned: always Sample: 0 |
|
If True, the device is using a user-defined configuration. Returned: always Sample: true |
|
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: “Win32_DiskDrive” |
|
Default block size, in bytes, for this device. Returned: always Sample: 512 |
|
Description of the object. Returned: always Sample: “Disk drive” |
|
Unique identifier of the disk drive with other devices on the system. Returned: always Sample: “\\\\.\\PHYSICALDRIVE0” |
|
If True, the error reported in LastErrorCode is now cleared. Returned: always Sample: true |
|
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: 1.0 |
|
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: 0 |
|
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: “SCSI” |
|
Last error code reported by the logical device. Returned: always |
|
Name of the disk drive manufacturer. Returned: always Sample: “Seagate” |
|
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: true |
|
Type of media used or accessed by this device. Returned: always Sample: “Fixed hard disk media” |
|
Minimum block size, in bytes, for media accessed by this device. Returned: always |
|
Manufacturer’s model number of the disk drive. Returned: always Sample: “ST32171W” |
|
Label by which the object is known. When subclassed, the property can be overridden to be a key property. Returned: always Sample: “\\\\\\\\.\\\\PHYSICALDRIVE0” |
|
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: 3 |
|
Windows Plug and Play device identifier of the logical device. Returned: always Sample: “SCSI\\DISK\u0026VEN_VMWARE\u0026PROD_VIRTUAL_DISK\\5\u00261982005\u00260\u0026000000” |
|
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: 0 |
|
SCSI logical unit number (LUN) of the disk drive. Returned: always Sample: 0 |
|
SCSI port number of the disk drive. Returned: always Sample: 0 |
|
SCSI identifier number of the disk drive. Returned: always Sample: 0 |
|
Number of sectors in each track for this physical disk drive. Returned: always Sample: 63 |
|
Number allocated by the manufacturer to identify the physical media. Returned: always Sample: “6000c298f34101b38cb2b2508926b9de” |
|
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: 53686402560 |
|
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: “OK” |
|
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: “Win32_ComputerSystem” |
|
Name of the scoping system. Returned: always Sample: “WILMAR-TEST-123” |
|
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: 6527 |
|
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: 255 |
|
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: 104856255 |
|
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: 1664385 |
|
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: 255 |
Authors
Marc Tschapek (@marqelme)