Skip to content

ansible-collections/ansible.snmp

CI

Ansible SNMP Collection

The Ansible ansible.snmp collection includes a variety of plugins for using SNMP on the control node to make SNMP connections to a device.

Ansible version compatibility

This collection has been tested against following Ansible versions: >=2.15.0.

For collections that support Ansible 2.9, please ensure you update your network_os to use the fully qualified collection name (for example, cisco.ios.ios). Plugins and modules within a collection may be tested with only specific Ansible versions. A collection may contain metadata that identifies these versions. PEP440 is the schema used to describe the versions of Ansible.

Included content

Connection plugins

Name Description
ansible.snmp.v1 Make SNMP v1 connections to a device
ansible.snmp.v2c Make SNMP v2c connections to a device
ansible.snmp.v3_usm Make SNMP v3 user-based security model (USM) connections to a device.

Modules

Name Description
ansible.snmp.get Perform an SNMP get against a remote device for one or more OIDs
ansible.snmp.set Perform an SNMP set against a remote device for one or more OIDs
ansible.snmp.walk Perform an SNMP walk against a remote device for one or more OIDs

Installing this collection

You can install the ansible.snmp collection with the Ansible Galaxy CLI:

ansible-galaxy collection install ansible.snmp

You can also include it in a requirements.yml file and install it with ansible-galaxy collection install -r requirements.yml, using the format:

---
collections:
  - name: ansible.snmp

Using this collection

You can call modules by their Fully Qualified Collection Namespace (FQCN), such as ansible.snmp.get. The most common use case for this collection is to retrieve operation state information from a device using SNMP get or SNMP walk The following example task gets the existing configuration on an SNMP-enabled device, using the FQCN:

---
- name: Retrieve several individual OIDs
  ansible.snmp.get:
    oids:
      - oid: "SNMPv2-MIB::sysDescr.0"
      - oid: "SNMPv2-MIB::sysDescr"
        iid: "0"
    numeric: false
    long_names: True

NOTE: For Ansible 2.9, you may not see deprecation warnings when you run your playbooks with this collection. Use this documentation to track when a module is deprecated.

See Also:

Contributing to this collection

This collection is intended for plugins that are not platform or discipline-specific. Simple plugin examples should be generic in nature. More complex examples can include real-world platform modules to demonstrate the utility of the plugin in a playbook.

We welcome community contributions to this collection. If you find problems, please open an issue or create a PR against the ansible.utils collection repository. See Contributing to Ansible-maintained collections for complete details.

See the Ansible Community Guide for details on contributing to Ansible.

Code of Conduct

This collection follows the Ansible project's Code of Conduct. Please read and familiarize yourself with this document.

Release notes

Release notes are available here For automated release announcements refer here.

Roadmap

For information on releasing, versioning and deprecation see the strategy document.

In general, major versions can contain breaking changes, while minor versions only contain new features (like new plugin addition) and bug fixes. The releases will be done on an as-needed basis when new features and/or bug fixes are done.

More information

Licensing

GNU General Public License v3.0 or later.

See LICENSE to see the full text.

Installing the python binding for net-snmp

Using dnf

sudo dnf install net-snmp net-snmp-libs net-snmp-utils net-snmp-python

or

Using source (fedora)

more /etc/ld.so.conf.d/netsnmp.conf
/usr/local/lib
  • cd python
  • build python setup.py build
  • install python setup.py install or python setup.py install --user
  • confirm python -c 'import netsnmp'
  • It's installed in system python

Configuring netsnmp

  • sudo dnf install perl-Term-ReadLine-Gnu
  • snmpconf -p
    • 1: snmp.conf
    • 4: Textual mib parsing
    • 1: Specifies directory to be searched for mibs
    • Enter the list of directories to search through for mibs: +/home/ftp_site/cisco_mibs
    • finished
    • finished
    • quit
  • review ~/.snmp/snmp.conf

Using the net-snmp python bindings with a python virtual environment

  • python3 -m venv venv --system-site-packages

or install again after sourcing venv

  • python3 -m venv venv
  • source venv/bin/activate
  • pip install net-snmp-5.9.1/python

Additional information

Licensing

GNU General Public License v3.0 or later.

See LICENSE to see the full text.