community.general.usb_facts module – Allows listing information about USB devices
Note
This module is part of the community.general collection (version 8.6.7).
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.general
.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: community.general.usb_facts
.
New in community.general 8.5.0
Synopsis
Allows retrieving information about available USB devices through
lsusb
.
Requirements
The below requirements are needed on the host that executes this module.
lsusb binary on PATH (usually installed through the package usbutils and preinstalled on many systems)
Attributes
Attribute |
Support |
Description |
---|---|---|
Support: full This action does not modify state. |
Can run in |
|
Support: N/A This action does not modify state. |
Will return details on what has changed (or possibly needs changing in |
|
Support: full |
Action returns an |
Examples
- name: Get information about USB devices
community.general.usb_facts:
- name: Print information about USB devices
ansible.builtin.debug:
msg: "On bus {{ item.bus }} device {{ item.device }} with id {{ item.id }} is {{ item.name }}"
loop: "{{ ansible_facts.usb_devices }}"
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 |
---|---|
A list of USB devices available. Returned: always |
|
The bus the usb device is connected to. Returned: always Sample: |
|
The device number occupied on the bus. Returned: always Sample: |
|
ID of the USB device. Returned: always Sample: |
|
Human readable name of the device. Returned: always Sample: |