community.general.snmp_facts module – Retrieve facts for a device using SNMP
Note
This module is part of the community.general collection (version 8.6.8).
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.snmp_facts
.
Synopsis
Retrieve facts for a device using SNMP, the facts will be inserted to the ansible_facts key.
Aliases: net_tools.snmp_facts
Requirements
The below requirements are needed on the host that executes this module.
pysnmp
Parameters
Parameter |
Comments |
---|---|
Authentication key. Required |
|
The SNMP community string, required if |
|
Set to target SNMP server (normally |
|
Encryption key. Required if |
|
Maximum number of request retries, 0 retries means just a single request. |
|
Response timeout in seconds. |
|
Username for SNMPv3. Required if |
|
SNMP Version to use, Choices:
|
Attributes
Attribute |
Support |
Description |
---|---|---|
Support: full added in community.general 3.3.0 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: Gather facts with SNMP version 2
community.general.snmp_facts:
host: '{{ inventory_hostname }}'
version: v2c
community: public
delegate_to: local
- 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
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
List of all IPv4 addresses. Returned: success Sample: |
|
Dictionary of each network interface and its metadata. Returned: success Sample: |
|
The textual identification of the contact person for this managed node, together with information on how to contact this person. Returned: success Sample: |
|
A textual description of the entity. Returned: success Sample: |
|
The physical location of this node (for example, Returned: success Sample: |
|
An administratively-assigned name for this managed node. Returned: success Sample: |
|
The vendor’s authoritative identification of the network management subsystem contained in the entity. Returned: success Sample: |
|
The time (in hundredths of a second) since the network management portion of the system was last re-initialized. Returned: success Sample: |