community.general.usb_facts (8.5.0) — module

Allows listing information about USB devices

| "added in version" 8.5.0 of community.general"

Authors: Max Maxopoly (@maxopoly)

Install collection

Install with ansible-galaxy collection install community.general:==8.5.0


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

Description

Allows retrieving information about available USB devices through C(lsusb).


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Get information about USB devices
  community.general.usb_facts:
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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 }}"

Outputs

ansible_facts:
  contains:
    usb_devices:
      contains:
        bus:
          description: The bus the usb device is connected to.
          returned: always
          sample: '001'
          type: str
        device:
          description: The device number occupied on the bus.
          returned: always
          sample: '002'
          type: str
        id:
          description: ID of the USB device.
          returned: always
          sample: 1d6b:0002
          type: str
        name:
          description: Human readable name of the device.
          returned: always
          sample: Linux Foundation 2.0 root hub
          type: str
      description: A list of USB devices available.
      elements: dict
      returned: always
      type: list
  description: Dictionary containing details of connected USB devices.
  returned: always
  type: dict