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[1].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.

bootable
boolean
always
Information whether the particular disk is a bootable disk.

bus_type
string
always
Bus type of the particular disk.

Sample:
SCSI
clustered
boolean
always
Information whether the particular disk is clustered (part of a failover cluster).

firmware_version
string
always
Firmware version of the particular disk.

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

Sample:
Red Hat VirtIO SCSI Disk Device
guid
string
if existent
GUID of the particular disk on the target.

Sample:
{efa5f928-57b9-47fc-ae3e-902e85fbe77f}
location
string
always
Location of the particular disk on the target.

Sample:
PCIROOT(0)#PC0400#SCSP00T00L00
manufacturer
string
always
Manufacturer of the particular disk.

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

Sample:
VirtIO
number
integer
always
Disk number of the particular disk.

operational_status
string
always
Operational status of the particular disk.

Sample:
Online
partition_count
integer
always
Number of partitions on the particular disk.

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

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

access_paths
string
if existent
Access paths of the particular partition.

Sample:
\\?\Volume{85bdc4a8-f8eb-11e6-80fa-806e6f6e6963}\
active
boolean
if partition_style property of the particular disk has value "MBR"
Information whether the particular partition is an active partition or not.

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

Sample:
C
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}
guid
string
if existent
GUID of the particular partition.

Sample:
{302e475c-6e64-4674-a8e2-2f1c7018bf97}
hidden
boolean
always
Information whether the particular partition is hidden or not.

Sample:
True
mbr_type
integer
if partition_style property of the particular disk has value "MBR"
mbr type of the particular partition.

Sample:
7
no_default_driveletter
boolean
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
number
integer
always
Number of the particular partition.

Sample:
1
offset
integer
always
Offset of the particular partition.

Sample:
368050176
shadow_copy
boolean
always
Information whether the particular partition is a shadow copy of another partition.

size
integer
always
Size in bytes of the particular partition.

Sample:
838860800
transition_state
integer
always
Transition state of the particular partition.

Sample:
1
type
string
always
Type of the particular partition.

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

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

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

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

Sample:
Healthy
label
string
always
File system label of the particular volume.

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

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

Sample:
\\?\Volume{85bdc4a9-f8eb-11e6-80fa-806e6f6e6963}\
size
integer
always
Size in bytes of the particular volume.

Sample:
838856704
size_remaining
integer
always
Remaining size in bytes of the particular volume.

Sample:
395620352
type
string
always
File system type of the particular volume.

Sample:
NTFS
path
string
always
Path of the particular disk on the target.

Sample:
\\?\scsi#disk&ven_red_hat&prod_virtio#4&23208fd0&1&000000#{<id>}
physical_disk
complex
if existent
Detailed information about physical disk properties of the particular disk.

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

Sample:
240057409536
bus_type
string
always
Bus type of the particular physical disk.

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

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
device_id
string
always
Device ID of the particular physical disk.

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

Sample:
PhysicalDisk0
health_status
string
always
Health status of the particular physical disk.

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

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

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

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

Sample:
Xen Block
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>}\"
operational_status
string
always
Operational status of the particular physical disk.

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

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
size
integer
always
Size in bytes of the particular physical disk.

Sample:
240057409536
spindle_speed
integer
always
Spindle speed in rpm of the particular physical disk.

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

Count
integer
always
Count of supported usage types.

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

Sample:
Auto-Select, Hot Spare
unique_id
string
always
Unique ID of the particular physical disk.

Sample:
3141463431303031
usage_type
string
always
Usage type of the particular physical disk.

Sample:
Auto-Select
read_only
boolean
always
Read only status of the particular disk.

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

Sample:
4096
serial_number
string
always
Serial number of the particular disk on the target.

Sample:
b62beac80c3645e5877f
size
integer
always
Size in bytes of the particular disk.

Sample:
227727638528
system_disk
boolean
always
Information whether the particular disk is a system disk.

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

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

access
string
always
Access of the particular virtual disk.

Sample:
Read/Write
allocated_size
integer
always
Allocated size in bytes of the particular virtual disk.

Sample:
240057409536
allocation_unit_size
integer
always
Allocation unit size in bytes of the particular virtual disk.

Sample:
4096
available_copies
integer
if existent
Number of the available copies of the particular virtual disk.

Sample:
1
columns
integer
always
Number of the columns of the particular virtual disk.

Sample:
2
deduplication_enabled
boolean
always
Information whether deduplication is enabled for the particular virtual disk.

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

Sample:
None
enclosure_aware
boolean
always
Information whether the particular virtual disk is enclosure aware.

fault_domain_awareness
string
always
Fault domain awareness of the particular virtual disk.

Sample:
PhysicalDisk
footprint_on_pool
integer
always
Footprint on pool in bytes of the particular virtual disk.

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

Sample:
Prod2 Virtual Disk
groups
integer
always
Number of the groups of the particular virtual disk.

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

Sample:
Healthy
inter_leave
integer
always
Inter leave in bytes of the particular virtual disk.

Sample:
102400
logical_sector_size
integer
always
Logical sector size in byte of the particular virtual disk.

Sample:
512
manual_attach
boolean
always
Information whether the particular virtual disk is manual attached.

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

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

Sample:
vDisk1
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>}\"
operational_status
string
always
Operational status of the particular virtual disk.

Sample:
OK
parity_layout
integer
if existent
Parity layout of the particular virtual disk.

Sample:
1
physical_disk_redundancy
integer
always
Type of the physical disk redundancy of the particular virtual disk.

Sample:
1
physical_sector_size
integer
always
Physical sector size in bytes of the particular virtual disk.

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

Sample:
Thin
read_cache_size
integer
always
Read cache size in byte of the particular virtual disk.

request_no_spof
boolean
always
Information whether the particular virtual disk requests no single point of failure.

Sample:
True
resiliency_setting_name
integer
always
Type of the physical disk redundancy of the particular virtual disk.

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

Sample:
240057409536
snapshot
boolean
always
Information whether the particular virtual disk is a snapshot.

tiered
boolean
always
Information whether the particular virtual disk is tiered.

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

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

Sample:
Vendor Specific
write_cache_size
integer
always
Write cache size in byte of the particular virtual disk.

Sample:
100
win32_disk_drive
complex
if existent
Representation of the Win32_DiskDrive class.

availability
integer
always
Availability and status of the device.

bytes_per_sector
integer
always
Number of bytes in each sector for the physical disk drive.

Sample:
512
capabilities
list
always
Array of capabilities of the media access device.
For example, the device may support random access (3), removable media (7), and automatic cleaning (9).

Sample:
[3, 4]
capability_descriptions
list
always
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.

Sample:
['Random Access', 'Supports Writing']
caption
string
always
Short description of the object.

Sample:
VMware Virtual disk SCSI Disk Device
compression_method
string
always
Algorithm or tool used by the device to support compression.

Sample:
Compressed
config_manager_error_code
integer
always
Windows Configuration Manager error code.

config_manager_user_config
boolean
always
If True, the device is using a user-defined configuration.

Sample:
True
creation_class_name
string
always
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.

Sample:
Win32_DiskDrive
default_block_size
integer
always
Default block size, in bytes, for this device.

Sample:
512
description
string
always
Description of the object.

Sample:
Disk drive
device_id
string
always
Unique identifier of the disk drive with other devices on the system.

Sample:
\\.\PHYSICALDRIVE0
error_cleared
boolean
always
If True, the error reported in LastErrorCode is now cleared.

Sample:
True
error_description
string
always
More information about the error recorded in LastErrorCode,
and information on any corrective actions that may be taken.

error_methodology
string
always
Type of error detection and correction supported by this device.

firmware_revision
string
always
Revision for the disk drive firmware that is assigned by the manufacturer.

Sample:
1.0
index
integer
always
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.

install_date
string
always
Date and time the object was installed. This property does not need a value to indicate that the object is installed.

interface_type
string
always
Interface type of physical disk drive.

Sample:
SCSI
last_error_code
integer
always
Last error code reported by the logical device.

manufacturer
string
always
Name of the disk drive manufacturer.

Sample:
Seagate
max_block_size
integer
always
Maximum block size, in bytes, for media accessed by this device.

max_media_size
integer
always
Maximum media size, in kilobytes, of media supported by this device.

media_loaded
boolean
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.

Sample:
True
media_type
string
always
Type of media used or accessed by this device.

Sample:
Fixed hard disk media
min_block_size
integer
always
Minimum block size, in bytes, for media accessed by this device.

model
string
always
Manufacturer's model number of the disk drive.

Sample:
ST32171W
name
string
always
Label by which the object is known. When subclassed, the property can be overridden to be a key property.

Sample:
\\\\.\\PHYSICALDRIVE0
needs_cleaning
boolean
always
If True, the media access device needs cleaning.
Whether manual or automatic cleaning is possible is indicated in the Capabilities property.

number_of_media_supported
integer
always
Maximum number of media which can be supported or inserted
(when the media access device supports multiple individual media).

partitions
integer
always
Number of partitions on this physical disk drive that are recognized by the operating system.

Sample:
3
pnp_device_id
string
always
Windows Plug and Play device identifier of the logical device.

Sample:
SCSI\DISK&VEN_VMWARE&PROD_VIRTUAL_DISK\5&1982005&0&000000
power_management_capabilities
list
always
Array of the specific power-related capabilities of a logical device.

power_management_supported
boolean
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.

scsi_bus
integer
always
SCSI bus number of the disk drive.

scsi_logical_unit
integer
always
SCSI logical unit number (LUN) of the disk drive.

scsi_port
integer
always
SCSI port number of the disk drive.

scsi_target_id
integer
always
SCSI identifier number of the disk drive.

sectors_per_track
integer
always
Number of sectors in each track for this physical disk drive.

Sample:
63
serial_number
string
always
Number allocated by the manufacturer to identify the physical media.

Sample:
6000c298f34101b38cb2b2508926b9de
signature
integer
always
Disk identification. This property can be used to identify a shared resource.

size
integer
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.

Sample:
53686402560
status
string
always
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.

Sample:
OK
status_info
integer
always
State of the logical device. If this property does not apply to the logical device, the value 5 (Not Applicable) should be used.

system_creation_class_name
string
always
Value of the scoping computer's CreationClassName property.

Sample:
Win32_ComputerSystem
system_name
string
always
Name of the scoping system.

Sample:
WILMAR-TEST-123
total_cylinders
integer
always
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.

Sample:
6527
total_heads
integer
always
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.

Sample:
255
total_sectors
integer
always
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.

Sample:
104856255
total_tracks
integer
always
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.

Sample:
1664385
tracks_per_cylinder
integer
always
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.

Sample:
255


Status

Authors

  • Marc Tschapek (@marqelme)

Hint

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