Note
This plugin is part of the community.windows collection.
To install it use: ansible-galaxy collection install community.windows
.
To use it in a playbook, specify: community.windows.win_disk_facts
.
The below requirements are needed on the host that executes this module.
Note
- 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
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 / elements=string | if disks were found | Detailed information about one particular disk. | |||
bootable boolean / elements=string | always | Information whether the particular disk is a bootable disk. | |||
bus_type string / elements=string | always | Bus type of the particular disk. Sample: SCSI | |||
clustered boolean / elements=string | always | Information whether the particular disk is clustered (part of a failover cluster). | |||
firmware_version string / elements=string | always | Firmware version of the particular disk. Sample: 0001 | |||
friendly_name string / elements=string | always | Friendly name of the particular disk. Sample: Red Hat VirtIO SCSI Disk Device | |||
guid string / elements=string | if existent | GUID of the particular disk on the target. Sample: {efa5f928-57b9-47fc-ae3e-902e85fbe77f} | |||
location string / elements=string | always | Location of the particular disk on the target. Sample: PCIROOT(0)#PCI(0400)#SCSI(P00T00L00) | |||
manufacturer string / elements=string | always | Manufacturer of the particular disk. Sample: Red Hat | |||
model string / elements=string | always | Model specification of the particular disk. Sample: VirtIO | |||
number integer / elements=string | always | Disk number of the particular disk. | |||
operational_status string / elements=string | always | Operational status of the particular disk. Sample: Online | |||
partition_count integer / elements=string | always | Number of partitions on the particular disk. Sample: 4 | |||
partition_style string / elements=string | always | Partition style of the particular disk. Sample: MBR | |||
partitions list / elements=string | if existent | Detailed information about one particular partition on the specified disk. | |||
access_paths string / elements=string | if existent | Access paths of the particular partition. Sample: \\?\Volume{85bdc4a8-f8eb-11e6-80fa-806e6f6e6963}\ | |||
active boolean / elements=string | 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 / elements=string | if existent | Drive letter of the particular partition. Sample: C | |||
gpt_type string / elements=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 / elements=string | if existent | GUID of the particular partition. Sample: {302e475c-6e64-4674-a8e2-2f1c7018bf97} | |||
hidden boolean / elements=string | always | Information whether the particular partition is hidden or not. Sample: True | |||
mbr_type integer / elements=string | if partition_style property of the particular disk has value "MBR" | mbr type of the particular partition. Sample: 7 | |||
no_default_driveletter boolean / elements=string | 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 / elements=string | always | Number of the particular partition. Sample: 1 | |||
offset integer / elements=string | always | Offset of the particular partition. Sample: 368050176 | |||
shadow_copy boolean / elements=string | always | Information whether the particular partition is a shadow copy of another partition. | |||
size integer / elements=string | always | Size in bytes of the particular partition. Sample: 838860800 | |||
transition_state integer / elements=string | always | Transition state of the particular partition. Sample: 1 | |||
type string / elements=string | always | Type of the particular partition. Sample: IFS | |||
volumes list / elements=string | if existent | Detailed information about one particular volume on the specified partition. | |||
allocation_unit_size integer / elements=string | always | Allocation unit size in bytes of the particular volume. Sample: 4096 | |||
drive_type string / elements=string | always | Drive type of the particular volume. Sample: Fixed | |||
health_status string / elements=string | always | Health status of the particular volume. Sample: Healthy | |||
label string / elements=string | always | File system label of the particular volume. Sample: System Reserved | |||
object_id string / elements=string | always | Object ID of the particular volume. Sample: \\?\Volume{85bdc4a9-f8eb-11e6-80fa-806e6f6e6963}\ | |||
path string / elements=string | always | Path of the particular volume. Sample: \\?\Volume{85bdc4a9-f8eb-11e6-80fa-806e6f6e6963}\ | |||
size integer / elements=string | always | Size in bytes of the particular volume. Sample: 838856704 | |||
size_remaining integer / elements=string | always | Remaining size in bytes of the particular volume. Sample: 395620352 | |||
type string / elements=string | always | File system type of the particular volume. Sample: NTFS | |||
path string / elements=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 / elements=string | if existent | Detailed information about physical disk properties of the particular disk. | |||
allocated_size integer / elements=string | always | Allocated size in bytes of the particular physical disk. Sample: 240057409536 | |||
bus_type string / elements=string | always | Bus type of the particular physical disk. Sample: SCSI | |||
can_pool boolean / elements=string | always | Information whether the particular physical disk can be added to a storage pool. | |||
cannot_pool_reason string / elements=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 / elements=string | always | Device ID of the particular physical disk. Sample: 0 | |||
friendly_name string / elements=string | always | Friendly name of the particular physical disk. Sample: PhysicalDisk0 | |||
health_status string / elements=string | always | Health status of the particular physical disk. Sample: Healthy | |||
indication_enabled boolean / elements=string | always | Information whether indication is enabled for the particular physical disk. Sample: True | |||
manufacturer string / elements=string | always | Manufacturer of the particular physical disk. Sample: SUSE | |||
media_type string / elements=string | always | Media type of the particular physical disk. Sample: UnSpecified | |||
model string / elements=string | always | Model of the particular physical disk. Sample: Xen Block | |||
object_id string / elements=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 / elements=string | always | Operational status of the particular physical disk. Sample: OK | |||
partial boolean / elements=string | always | Information whether the particular physical disk is partial. | |||
physical_location string / elements=string | always | Physical location of the particular physical disk. Sample: Integrated : Adapter 3 : Port 0 : Target 0 : LUN 0 | |||
serial_number string / elements=string | always | Serial number of the particular physical disk. Sample: b62beac80c3645e5877f | |||
size integer / elements=string | always | Size in bytes of the particular physical disk. Sample: 240057409536 | |||
spindle_speed integer / elements=string | always | Spindle speed in rpm of the particular physical disk. Sample: 4294967295 | |||
supported_usages complex / elements=string | always | Supported usage types of the particular physical disk. | |||
Count integer / elements=string | always | Count of supported usage types. Sample: 5 | |||
value string / elements=string | always | List of supported usage types. Sample: Auto-Select, Hot Spare | |||
unique_id string / elements=string | always | Unique ID of the particular physical disk. Sample: 3141463431303031 | |||
usage_type string / elements=string | always | Usage type of the particular physical disk. Sample: Auto-Select | |||
read_only boolean / elements=string | always | Read only status of the particular disk. Sample: True | |||
sector_size integer / elements=string | always | Sector size in bytes of the particular disk. Sample: 4096 | |||
serial_number string / elements=string | always | Serial number of the particular disk on the target. Sample: b62beac80c3645e5877f | |||
size integer / elements=string | always | Size in bytes of the particular disk. Sample: 227727638528 | |||
system_disk boolean / elements=string | always | Information whether the particular disk is a system disk. Sample: True | |||
unique_id string / elements=string | always | Unique ID of the particular disk on the target. Sample: 3141463431303031 | |||
virtual_disk complex / elements=string | if existent | Detailed information about virtual disk properties of the particular disk. | |||
access string / elements=string | always | Access of the particular virtual disk. Sample: Read/Write | |||
allocated_size integer / elements=string | always | Allocated size in bytes of the particular virtual disk. Sample: 240057409536 | |||
allocation_unit_size integer / elements=string | always | Allocation unit size in bytes of the particular virtual disk. Sample: 4096 | |||
available_copies integer / elements=string | if existent | Number of the available copies of the particular virtual disk. Sample: 1 | |||
columns integer / elements=string | always | Number of the columns of the particular virtual disk. Sample: 2 | |||
deduplication_enabled boolean / elements=string | always | Information whether deduplication is enabled for the particular virtual disk. Sample: True | |||
detached_reason string / elements=string | always | Detached reason of the particular virtual disk. Sample: None | |||
enclosure_aware boolean / elements=string | always | Information whether the particular virtual disk is enclosure aware. | |||
fault_domain_awareness string / elements=string | always | Fault domain awareness of the particular virtual disk. Sample: PhysicalDisk | |||
footprint_on_pool integer / elements=string | always | Footprint on pool in bytes of the particular virtual disk. Sample: 240057409536 | |||
friendly_name string / elements=string | always | Friendly name of the particular virtual disk. Sample: Prod2 Virtual Disk | |||
groups integer / elements=string | always | Number of the groups of the particular virtual disk. Sample: 1 | |||
health_status string / elements=string | always | Health status of the particular virtual disk. Sample: Healthy | |||
inter_leave integer / elements=string | always | Inter leave in bytes of the particular virtual disk. Sample: 102400 | |||
logical_sector_size integer / elements=string | always | Logical sector size in byte of the particular virtual disk. Sample: 512 | |||
manual_attach boolean / elements=string | always | Information whether the particular virtual disk is manual attached. Sample: True | |||
media_type string / elements=string | always | Media type of the particular virtual disk. Sample: Unspecified | |||
name string / elements=string | always | Name of the particular virtual disk. Sample: vDisk1 | |||
object_id string / elements=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 / elements=string | always | Operational status of the particular virtual disk. Sample: OK | |||
parity_layout integer / elements=string | if existent | Parity layout of the particular virtual disk. Sample: 1 | |||
physical_disk_redundancy integer / elements=string | always | Type of the physical disk redundancy of the particular virtual disk. Sample: 1 | |||
physical_sector_size integer / elements=string | always | Physical sector size in bytes of the particular virtual disk. Sample: 4096 | |||
provisioning_type string / elements=string | always | Provisioning type of the particular virtual disk. Sample: Thin | |||
read_cache_size integer / elements=string | always | Read cache size in byte of the particular virtual disk. | |||
request_no_spof boolean / elements=string | always | Information whether the particular virtual disk requests no single point of failure. Sample: True | |||
resiliency_setting_name integer / elements=string | always | Type of the physical disk redundancy of the particular virtual disk. Sample: 1 | |||
size integer / elements=string | always | Size in bytes of the particular virtual disk. Sample: 240057409536 | |||
snapshot boolean / elements=string | always | Information whether the particular virtual disk is a snapshot. | |||
tiered boolean / elements=string | always | Information whether the particular virtual disk is tiered. Sample: True | |||
unique_id string / elements=string | always | Unique ID of the particular virtual disk. Sample: 260542E4C6B01D47A8FA7630FD90FFDE | |||
unique_id_format string / elements=string | always | Unique ID format of the particular virtual disk. Sample: Vendor Specific | |||
write_cache_size integer / elements=string | always | Write cache size in byte of the particular virtual disk. Sample: 100 | |||
win32_disk_drive complex / elements=string | if existent | Representation of the Win32_DiskDrive class. | |||
availability integer / elements=string | always | Availability and status of the device. | |||
bytes_per_sector integer / elements=string | always | Number of bytes in each sector for the physical disk drive. Sample: 512 | |||
capabilities list / elements=string | 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 / elements=string | 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 / elements=string | always | Short description of the object. Sample: VMware Virtual disk SCSI Disk Device | |||
compression_method string / elements=string | always | Algorithm or tool used by the device to support compression. Sample: Compressed | |||
config_manager_error_code integer / elements=string | always | Windows Configuration Manager error code. | |||
config_manager_user_config boolean / elements=string | always | If True, the device is using a user-defined configuration. Sample: True | |||
creation_class_name string / elements=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 / elements=string | always | Default block size, in bytes, for this device. Sample: 512 | |||
description string / elements=string | always | Description of the object. Sample: Disk drive | |||
device_id string / elements=string | always | Unique identifier of the disk drive with other devices on the system. Sample: \\.\PHYSICALDRIVE0 | |||
error_cleared boolean / elements=string | always | If True, the error reported in LastErrorCode is now cleared. Sample: True | |||
error_description string / elements=string | always | More information about the error recorded in LastErrorCode, and information on any corrective actions that may be taken. | |||
error_methodology string / elements=string | always | Type of error detection and correction supported by this device. | |||
firmware_revision string / elements=string | always | Revision for the disk drive firmware that is assigned by the manufacturer. Sample: 1.0 | |||
index integer / elements=string | 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 / elements=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 / elements=string | always | Interface type of physical disk drive. Sample: SCSI | |||
last_error_code integer / elements=string | always | Last error code reported by the logical device. | |||
manufacturer string / elements=string | always | Name of the disk drive manufacturer. Sample: Seagate | |||
max_block_size integer / elements=string | always | Maximum block size, in bytes, for media accessed by this device. | |||
max_media_size integer / elements=string | always | Maximum media size, in kilobytes, of media supported by this device. | |||
media_loaded boolean / elements=string | 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 / elements=string | always | Type of media used or accessed by this device. Sample: Fixed hard disk media | |||
min_block_size integer / elements=string | always | Minimum block size, in bytes, for media accessed by this device. | |||
model string / elements=string | always | Manufacturer's model number of the disk drive. Sample: ST32171W | |||
name string / elements=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 / elements=string | 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 / elements=string | always | Maximum number of media which can be supported or inserted (when the media access device supports multiple individual media). | |||
partitions integer / elements=string | always | Number of partitions on this physical disk drive that are recognized by the operating system. Sample: 3 | |||
pnp_device_id string / elements=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 / elements=string | always | Array of the specific power-related capabilities of a logical device. | |||
power_management_supported boolean / elements=string | 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 / elements=string | always | SCSI bus number of the disk drive. | |||
scsi_logical_unit integer / elements=string | always | SCSI logical unit number (LUN) of the disk drive. | |||
scsi_port integer / elements=string | always | SCSI port number of the disk drive. | |||
scsi_target_id integer / elements=string | always | SCSI identifier number of the disk drive. | |||
sectors_per_track integer / elements=string | always | Number of sectors in each track for this physical disk drive. Sample: 63 | |||
serial_number string / elements=string | always | Number allocated by the manufacturer to identify the physical media. Sample: 6000c298f34101b38cb2b2508926b9de | |||
signature integer / elements=string | always | Disk identification. This property can be used to identify a shared resource. | |||
size integer / elements=string | 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 / elements=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 / elements=string | 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 / elements=string | always | Value of the scoping computer's CreationClassName property. Sample: Win32_ComputerSystem | |||
system_name string / elements=string | always | Name of the scoping system. Sample: WILMAR-TEST-123 | |||
total_cylinders integer / elements=string | 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 / elements=string | 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 / elements=string | 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 / elements=string | 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 / elements=string | 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 |
© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.10/collections/community/windows/win_disk_facts_module.html