community.general.snmp_facts (8.5.0) — module

Retrieve facts for a device using SNMP

Authors: Patrick Ogenstad (@ogenstad)

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

Retrieve facts for a device using SNMP, the facts will be inserted to the ansible_facts key.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Gather facts with SNMP version 2
  community.general.snmp_facts:
    host: '{{ inventory_hostname }}'
    version: v2c
    community: public
  delegate_to: local
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Gather facts using SNMP version 3
  community.general.snmp_facts:
    host: '{{ inventory_hostname }}'
    version: v3
    level: authPriv
    integrity: sha
    privacy: aes
    username: snmp-user
    authkey: abc12345
    privkey: def6789
  delegate_to: localhost

Inputs

    
host:
    description:
    - Set to target SNMP server (normally C({{ inventory_hostname }})).
    required: true
    type: str

level:
    choices:
    - authNoPriv
    - authPriv
    description:
    - Authentication level.
    - Required if O(version=v3).
    type: str

authkey:
    description:
    - Authentication key.
    - Required O(version=v3).
    type: str

privacy:
    choices:
    - aes
    - des
    description:
    - Encryption algorithm.
    - Required if O(level=authPriv).
    type: str

privkey:
    description:
    - Encryption key.
    - Required if O(level=authPriv).
    type: str

retries:
    description:
    - Maximum number of request retries, 0 retries means just a single request.
    type: int
    version_added: 2.3.0
    version_added_collection: community.general

timeout:
    description:
    - Response timeout in seconds.
    type: int
    version_added: 2.3.0
    version_added_collection: community.general

version:
    choices:
    - v2
    - v2c
    - v3
    description:
    - SNMP Version to use, V(v2), V(v2c) or V(v3).
    required: true
    type: str

username:
    description:
    - Username for SNMPv3.
    - Required if O(version=v3).
    type: str

community:
    description:
    - The SNMP community string, required if O(version) is V(v2) or V(v2c).
    type: str

integrity:
    choices:
    - md5
    - sha
    description:
    - Hashing algorithm.
    - Required if O(version=v3).
    type: str

Outputs

ansible_all_ipv4_addresses:
  description: List of all IPv4 addresses.
  returned: success
  sample:
  - 127.0.0.1
  - 172.17.0.1
  type: list
ansible_interfaces:
  description: Dictionary of each network interface and its metadata.
  returned: success
  sample:
    '1':
      adminstatus: up
      description: ''
      ifindex: '1'
      ipv4:
      - address: 127.0.0.1
        netmask: 255.0.0.0
      mac: ''
      mtu: '65536'
      name: lo
      operstatus: up
      speed: '65536'
    '2':
      adminstatus: up
      description: ''
      ifindex: '2'
      ipv4:
      - address: 192.168.213.128
        netmask: 255.255.255.0
      mac: 000a305a52a1
      mtu: '1500'
      name: Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
      operstatus: up
      speed: '1500'
  type: dict
ansible_syscontact:
  description: The textual identification of the contact person for this managed node,
    together with information on how to contact this person.
  returned: success
  sample: Me <me@example.org>
  type: str
ansible_sysdescr:
  description: A textual description of the entity.
  returned: success
  sample: Linux ubuntu-user 4.4.0-93-generic
  type: str
ansible_syslocation:
  description: The physical location of this node (for example, V(telephone closet,
    3rd floor)).
  returned: success
  sample: Sitting on the Dock of the Bay
  type: str
ansible_sysname:
  description: An administratively-assigned name for this managed node.
  returned: success
  sample: ubuntu-user
  type: str
ansible_sysobjectid:
  description: The vendor's authoritative identification of the network management
    subsystem contained in the entity.
  returned: success
  sample: 1.3.6.1.4.1.8072.3.2.10
  type: str
ansible_sysuptime:
  description: The time (in hundredths of a second) since the network management portion
    of the system was last re-initialized.
  returned: success
  sample: 42388
  type: int