ans2dev.general.udevadm_info module – Collect udevadm device information.

Note

This module is part of the ans2dev.general collection (version 0.2.0).

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 ans2dev.general. You need further requirements to be able to use this module, see Requirements for details.

To use it in a playbook, specify: ans2dev.general.udevadm_info.

New in ans2dev.general 0.2.0

Synopsis

  • Retrieves udevadm information using udevadm info commands.

  • Collects all properties avaible in udevadm for the selected device.

Requirements

The below requirements are needed on the host that executes this module.

  • udevadm info command with -x, --query, --property and --name options.

Parameters

Parameter

Comments

device

string / required

Device full name.

device is passed as an argument to the udevadm command, so the name must be complete.

For example for sda disk you must use the full name /dev/sda.

property

string

This option is used if you want to collect only a specific property of the specified device.

For example you can collect only the DEVTYPE property.

Notes

Note

  • Module requires register function in order to access to the collected info.

  • Some device properties, like DEVLINKS, can have multiple values, so the module will report the values of that specific property as a list rather than as a string.

Examples

---
# Get full udevadm info for /dev/sda
- name: Get full udevadm info for /dev/sda
  ans2dev.general.udevadm_info:
    device: "/dev/sda"
  register: result

# Print SCSI_VENDOR from example above
- name: Print SCSI_VENDOR of /dev/sda
  ansible.builtin.debug:
    var: result.udevinfo.SCSI_VENDOR

# Get only DEVPATH property from udevadm info for /dev/sda
- name: Get only DEVPATH property from udevadm info for /dev/sda
  ans2dev.general.udevadm_info:
    device: "/dev/sda"
    property: "DEVPATH"
  register: result

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

udevinfo

dictionary

Dictionary of udevadm info properties.

Additional fields will be returned depending on udevadm version or OS distribution.

Returned: success

CURRENT_TAGS

string

The set of currently active tags on the device, indicating its runtime state.

Returned: always

Sample: ":systemd:"

list / elements=string

A list of symlink paths generated by udev for stable device naming.

Returned: always

Sample: ["/dev/disk/by-path/pci-0000:00:03.0-scsi-0:0:1:0", "/dev/disk/by-id/scsi-0Google_PersistentDisk_workspace", "/dev/disk/by-diskseq/9", "/dev/disk/by-id/google-workspace"]

DEVNAME

string

The device node name in /dev used for interacting with the device.

Returned: always

Sample: "/dev/sda"

DEVPATH

string

The sysfs path of the device in the Linux device tree.

Indicates its physical location.

Returned: always

Sample: "/devices/pci0000:00/0000:00:03.0/virtio0/host0/target0:0:1/0:0:1:0/block/sda"

DEVTYPE

string

Specifies the type of device.

Returned: always

Sample: "disk"

DISKSEQ

string

A sequence number assigned to the disk, which can be used for ordering.

Returned: always

Sample: "9"

DM_MULTIPATH_DEVICE_PATH

string

Indicates the status or state of the device under device-mapper multipath management.

Returned: always

Sample: "0"

ID_BUS

string

Indicates the bus type used by the device.

Returned: always

Sample: "scsi"

ID_MODEL

string

Identifies the device model, analogous to udevinfo.SCSI_MODEL.

Returned: always

Sample: "PersistentDisk"

ID_MODEL_ENC

string

Encoded version of the device model, including escape sequences if necessary.

Returned: always

Sample: "PersistentDisk\\x20\\x20"

ID_PART_TABLE_TYPE

string

pecifies the type of partition table, such as GPT or MBR.

Returned: always

Sample: "gpt"

ID_PART_TABLE_UUID

string

The universally unique identifier UUID of the disk partition table, critical for GPT disks.

Returned: always

Sample: "942239ee-556f-4244-af35-7f6516dba76f"

ID_PATH

string

Provides a unique, stable path to the device based on its physical bus location.

Returned: always

Sample: "pci-0000:00:03.0-scsi-0:0:1:0"

ID_PATH_TAG

string

A sanitized version of udevinfo.ID_PATH that is safe for use as a tag or filename.

Returned: always

Sample: "pci-0000_00_03_0-scsi-0_0_1_0"

ID_REVISION

string

The revision number, firmware or hardware, of the device.

Returned: always

Sample: "1"

ID_SCSI

string

A flag confirming that the device was identified by the SCSI subsystem.

Returned: always

Sample: "1"

ID_SCSI_INQUIRY

string

Indicates that a SCSI inquiry command was successfully executed on the device.

Returned: always

Sample: "1"

ID_SERIAL

string

A unique serial number assigned to the device for identification purposes.

Returned: always

Sample: "0Google_PersistentDisk_workspace"

ID_SERIAL_SHORT

string

A shortened version of the device serial number for simpler reference.

Returned: always

Sample: "workspace"

ID_TYPE

string

Specifies the general type of the device.

Returned: always

Sample: "disk"

ID_VENDOR

string

Provides the vendor identifier for the device, similar to udevinfo.SCSI_VENDOR.

Returned: always

Sample: "Google"

ID_VENDOR_ENC

string

Encoded vendor identifier, with escape sequences for any special characters.

Returned: always

Sample: "Google\\x20\\x20"

MAJOR

string

The major device number identifying the kernel driver associated with the device.

Returned: always

Sample: "8"

MINOR

string

The minor device number that distinguishes between devices handled by the same driver.

Returned: always

Sample: "0"

MPATH_SBIN_PATH

string

Specifies the path to the multipath binaries, used in environments managing multipath storage.

Returned: always

Sample: "/sbin"

SCSI_IDENT_LUN_VENDOR

string

Combines SCSI identification details and LUN vendor information to aid in device grouping.

Returned: always

Sample: "workspace"

SCSI_MODEL

string

The model identifier of the SCSI device.

Returned: always

Sample: "PersistentDisk"

SCSI_MODEL_ENC

string

Encoded version of the SCSI model, including escape sequences where needed.

Returned: always

Sample: "PersistentDisk\\x20\\x20"

SCSI_REVISION

string

Specifies the hardware or firmware revision of the SCSI device.

Returned: always

Sample: "1"

SCSI_TPGS

string

Indicates SCSI Target Port Group Support.

Returned: always

Sample: "0"

SCSI_TYPE

string

Specifies the SCSI device type.

Returned: always

Sample: "disk"

SCSI_VENDOR

string

The vendor name of the SCSI device.

Returned: always

Sample: "Google"

SCSI_VENDOR_ENC

string

Encoded vendor name of the SCSI device, with escape sequences for special characters.

Returned: always

Sample: "Google\\x20\\x20"

SUBSYSTEM

string

Indicates the kernel subsystem to which the device belongs.

Returned: always

Sample: "block"

TAGS

string

Metadata tags applied to the device by udev, used for classification and rule matching.

Returned: always

Sample: ":systemd:"

USEC_INITIALIZED

string

A microsecond timestamp indicating when udev initialized the device.

Returned: always

Sample: "3900986"

Authors

  • Marco Noce (@NomakCooper)