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.

number
int
always
Disk number of the particular disk.

size
int
always
Size in bytes of the particular disk.

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

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

Sample:
Red Hat VirtIO SCSI Disk Device
partition_style
string
always
Partition style of the particular disk.

Sample:
MBR
partition_count
int
always
Number of partitions on the particular disk.

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

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

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

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

system_disk
bool
always
Information whether the particular disk is a system disk.

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

manufacturer
string
always
Manufacturer of the particular disk.

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

Sample:
VirtIO
firmware_version
string
always
Firmware version of the particular disk.

Sample:
0001
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
unique_id
string
always
Unique ID of the particular disk on the target.

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

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

Sample:
\\?\scsi#disk&ven_red_hat&prod_virtio#4&23208fd0&1&000000#{<id>}
partitions
list
if existent
Detailed information about one particular partition on the specified disk.

number
int
always
Number of the particular partition.

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

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

Sample:
IFS
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}
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
mbr_type
int
if partition_style property of the particular disk has value "MBR"
mbr type of the particular partition.

Sample:
7
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
drive_letter
string
if existent
Drive letter of the particular partition.

Sample:
C
transition_state
int
always
Transition state of the particular partition.

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

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

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

guid
string
if existent
GUID of the particular partition.

Sample:
{302e475c-6e64-4674-a8e2-2f1c7018bf97}
access_paths
string
if existent
Access paths of the particular partition.

Sample:
\\?\Volume{85bdc4a8-f8eb-11e6-80fa-806e6f6e6963}\
volumes
list
if existent
Detailed information about one particular volume on the specified partition.

size
int
always
Size in bytes of the particular volume.

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

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

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

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

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

Sample:
Fixed
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}\
path
string
always
Path of the particular volume.

Sample:
\\?\Volume{85bdc4a9-f8eb-11e6-80fa-806e6f6e6963}\
physical_disk
complex
if existent
Detailed information about physical disk properties of the particular disk.

media_type
string
always
Media type of the particular physical disk.

Sample:
UnSpecified
size
int
always
Size in bytes of the particular physical disk.

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

Sample:
240057409536
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
operational_status
string
always
Operational status of the particular physical disk.

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

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

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

Sample:
Auto-Select
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
spindle_speed
int
always
Spindle speed in rpm of the particular physical disk.

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

Sample:
Integrated : Adapter 3 : Port 0 : Target 0 : LUN 0
manufacturer
string
always
Manufacturer of the particular physical disk.

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

Sample:
Xen Block
can_pool
bool
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
indication_enabled
bool
always
Information whether indication is enabled for the particular physical disk.

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

serial_number
string
always
Serial number of the particular physical disk.

Sample:
b62beac80c3645e5877f
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>}\"
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.

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

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

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

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

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

Sample:
Prod2 Virtual Disk
operational_status
string
always
Operational status of the particular virtual disk.

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

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

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

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

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

Sample:
1
access
string
always
Access of the particular virtual disk.

Sample:
Read/Write
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
fault_domain_awareness
string
always
Fault domain awareness of the particular virtual disk.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Sample:
1
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>}\"
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


Status

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

Maintenance

This module is flagged as community which means that it is maintained by the Ansible Community. See Module Maintenance & Support for more info.

For a list of other modules that are also maintained by the Ansible Community, see here.

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.6/modules/win_disk_facts_module.html