Note
This module is part of the community.general collection (version 10.7.3).
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.
ansible_facts key.The below requirements are needed on the host that executes this module.
Parameter | Comments |
|---|---|
authkey string | Authentication key. Required |
community string | The SNMP community string, required if |
host string / required | Set to target SNMP server (normally |
integrity string | |
level string | |
privacy string | |
privkey string | Encryption key. Required if |
retries integer added in community.general 2.3.0 | Maximum number of request retries, 0 retries means just a single request. |
timeout integer added in community.general 2.3.0 | Response timeout in seconds. |
username string | Username for SNMPv3. Required if |
version string / required | SNMP Version to use, Choices:
|
Attribute | Support | Description |
|---|---|---|
check_mode | Support: full added in community.general 3.3.0 This action does not modify state. | Can run in |
diff_mode | Support: N/A This action does not modify state. | Will return details on what has changed (or possibly needs changing in |
facts | Support: full | Action returns an |
- 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
Common return values are documented here, the following are the fields unique to this module:
Key | Description |
|---|---|
ansible_all_ipv4_addresses list / elements=string | List of all IPv4 addresses. Returned: success Sample: |
ansible_interfaces dictionary | Dictionary of each network interface and its metadata. Returned: success Sample: |
ansible_syscontact string | The textual identification of the contact person for this managed node, together with information on how to contact this person. Returned: success Sample: |
ansible_sysdescr string | A textual description of the entity. Returned: success Sample: |
ansible_syslocation string | The physical location of this node (for example, Returned: success Sample: |
ansible_sysname string | An administratively-assigned name for this managed node. Returned: success Sample: |
ansible_sysobjectid string | The vendor’s authoritative identification of the network management subsystem contained in the entity. Returned: success Sample: |
ansible_sysuptime integer | The time (in hundredths of a second) since the network management portion of the system was last re-initialized. Returned: success Sample: |
© 2012–2018 Michael DeHaan
© 2018–2025 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/community/general/snmp_facts_module.html