snmp_facts - Retrieve facts for a device using SNMP.

New in version 1.9.

Synopsis

Requirements

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

  • pysnmp

Parameters

Parameter Choices/Defaults Comments
authkey
Authentication key, required if version is v3
community
The SNMP community string, required if version is v2/v2c
host
required
Set to target snmp server (normally {{inventory_hostname}})
integrity
    Choices:
  • md5
  • sha
Hashing algorithm, required if version is v3
level
    Choices:
  • authPriv
  • authNoPriv
Authentication level, required if version is v3
privacy
    Choices:
  • des
  • aes
Encryption algorithm, required if level is authPriv
privkey
Encryption key, required if version is authPriv
username
Username for SNMPv3, required if version is v3
version
required
    Choices:
  • v2
  • v2c
  • v3
SNMP Version to use, v2/v2c or v3

Examples

# Gather facts with SNMP version 2
- snmp_facts:
    host: '{{ inventory_hostname }}'
    version: v2c
    community: public
  delegate_to: local

# Gather facts using SNMP version 3
- snmp_facts:
    host: '{{ inventory_hostname }}'
    version: v3
    level: authPriv
    integrity: sha
    privacy: aes
    username: snmp-user
    authkey: abc12345
    privkey: def6789
  delegate_to: localhost

Return Values

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

Key Returned Description
ansible_all_ipv4_addresses
list
success
List of all IPv4 addresses.

Sample:
['127.0.0.1', '172.17.0.1']
ansible_interfaces
dict
success
Dictionary of each network interface and its metadata.

Sample:
{'1': {'adminstatus': 'up', 'description': '', 'operstatus': 'up', 'mtu': '65536', 'mac': '', 'ipv4': [{'netmask': '255.0.0.0', 'address': '127.0.0.1'}], 'ifindex': '1', 'speed': '65536', 'name': 'lo'}, '2': {'adminstatus': 'up', 'description': '', 'operstatus': 'up', 'mtu': '1500', 'mac': '000a305a52a1', 'ipv4': [{'netmask': '255.255.255.0', 'address': '192.168.213.128'}], 'ifindex': '2', 'speed': '1500', 'name': 'Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)'}}
ansible_syscontact
string
success
The textual identification of the contact person for this managed node, together with information on how to contact this person.

Sample:
ansible_sysdescr
string
success
A textual description of the entity.

Sample:
Linux ubuntu-user 4.4.0-93-generic
ansible_syslocation
string
success
The physical location of this node (e.g., `telephone closet, 3rd floor').

Sample:
Sitting on the Dock of the Bay
ansible_sysname
string
success
An administratively-assigned name for this managed node.

Sample:
ubuntu-user
ansible_sysobjectid
string
success
The vendor's authoritative identification of the network management subsystem contained in the entity.

Sample:
1.3.6.1.4.1.8072.3.2.10
ansible_sysuptime
int
success
The time (in hundredths of a second) since the network management portion of the system was last re-initialized.

Sample:
42388


Status

This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.

Maintenance

This module is flagged as community which means that it is maintained by the Ansible Community. See Module Maintenance & Support for more info.

For a list of other modules that are also maintained by the Ansible Community, see here.

Author

  • Patrick Ogenstad (@ogenstad)

Hint

If you notice any issues in this documentation you can edit this document to improve it.