Enabling SNMP (the Simple Network Monitoring Protocol) makes it possible to monitor the health of your network with a wide selection of tools.
In this exercise, you will enable SNMP on your network devices.
Outcomes
You should be able to:
Add a variable to the network group variables file to support template-driven configuration that enables SNMP.
Update NOS-specific device configuration templates to provide parameterized configuration statements that enable SNMP.
Perform a multivendor play that configures network devices from the updated Jinja2 templates.
Open a terminal window on the workstation VM and change to the ~/proj/ directory.
Add a variable to the network group variables file to support template-driven configuration that enables SNMP.
Add another variable, named ro_community, and set the value of this variable to redhat.
The updated group_vars/network/vars.yml variable file should have the following content:
ansible_connection: network_cli domain_name: lab.example.com nameservers: - 8.8.8.8 - 8.8.4.4 syslog_ipv4: 172.25.250.254ro_community: redhatsnmp_clients:- 172.25.250.254- 172.25.250.9
Update NOS-specific device configuration templates to provide parameterized configuration statements that enable SNMP.
Add a line to the device configuration Jinja2 template for VyOS devices.
It should map appropriate variables to the VyOS statements that enable SNMP.
The updated j2/vyos-config.j2 template should have the following content:
set system host-name {{ inventory_hostname }}
set system domain-name {{ domain_name }}
{% for nameserver in nameservers %}
set system name-server {{ nameserver }}
{% endfor %}
set system syslog host {{ syslog_ipv4 }} facility local7 level {{ vyos_loglevel }}
set service snmp community {{ ro_community }} authorization ro
{% for snmp_client in snmp_clients %}
set service snmp community {{ ro_community }} client {{ snmp_client }}
{% endfor %}
Add lines to the device configuration Jinja2 template for IOS devices.
It should map appropriate variables to the IOS statements that enable SNMP.
The updated j2/ios-config.j2 template should have the following content:
hostname {{ inventory_hostname }}
ip domain-name {{ domain_name }}
{% for nameserver in nameservers %}
ip name-server {{ nameserver }}
{% endfor %}
service timestamps log datetime
service timestamps debug datetime
logging {{ syslog_ipv4 }}
logging trap {{ ios_loglevel }}
access-list 1 permit {{ workstation_ipv4 | ipaddr('address') }} log
access-list 1 permit {{ tower_ipv4 | ipaddr('address') }} log
snmp-server community {{ ro_community }} RO 1
The snmp-server command only supports standard access lists.
Perform a multivendor play that configures network devices from the updated Jinja2 templates.
Perform the play found in the j2cfg.yml file.
You already created the j2cfg.yml playbook, which sources configuration statements from the VyOS and IOS Jinja2 templates.
[student@workstation proj]$ansible-playbook j2cfg.yml
Install the SNMP network management utilities on workstation.
[student@workstation proj]$sudo yum install net-snmp-utils
Verify that SNMP is now enabled and working properly.
On workstation, run snmpwalk using the read-only community string you defined (redhat).
Filter the results based on the pattern sysName.
[student@workstation proj]$snmpwalk -v1 -c redhat spine01 sysNameSNMPv2-MIB::sysName.0 = STRING: spine01[student@workstation proj]$snmpwalk -v1 -c redhat spine02 sysNameSNMPv2-MIB::sysName.0 = STRING: spine02[student@workstation proj]$snmpwalk -v1 -c redhat leaf01 sysNameSNMPv2-MIB::sysName.0 = STRING: leaf01[student@workstation proj]$snmpwalk -v1 -c redhat leaf02 sysNameSNMPv2-MIB::sysName.0 = STRING: leaf02[student@workstation proj]$snmpwalk -v1 -c redhat cs01 sysNameSNMPv2-MIB::sysName.0 = STRING: cs01.lab.example.com
This concludes the guided exercise.