Clone an existing Git repository that contains an Ansible Playbook, make edits to files in that repository, commit the changes to your local repository, and push them to the original repository.
Outcomes
Clone a Git repository to the workstation machine.
Create a playbook to configure the Simple Network Management Protocol (SNMP) on Cisco IOS XE managed nodes.
Stage the playbook file, commit the changes, and synchronize with the remote repository.
As the student user on the workstation machine, use the lab command to prepare your environment for this exercise, and to ensure that all required resources are available.
The command also removes any Simple Network Management Protocol (SNMP) configuration from the Cisco IOS XE managed nodes.
[student@workstation ~]$ lab start run-git
Instructions
Open a terminal and verify that SNMP is not configured on the iosxe1.lab.example.com managed node.
Connect to the iosxe1.lab.example.com managed node by using SSH:
[student@workstation ~]$ ssh student@iosxe1.lab.example.com
iosxe1.lab.example.com#Display the SNMP configuration for the iosxe1.lab.example.com managed node.
The command output indicates that the SNMP agent is not enabled:
iosxe1.lab.example.com#show snmp
%SNMP agent not enabled
iosxe1.lab.example.com#Return to the workstation machine:
iosxe1.lab.example.com#exit
Connection to iosxe1.lab.example.com closed by remote host.
Connection to iosxe1.lab.example.com closed.
[student@workstation ~]$Clone the git@git.lab.example.com:student/snmp Git repository to the /home/student/git-repos directory.
Create a branch named exercise and check out that branch.
Create the /home/student/git-repos directory if it does not exist, and then change to this directory:
[student@workstation ~]$mkdir -p ~/git-repos[student@workstation ~]$cd ~/git-repos[student@workstation git-repos]$
Clone the git@git.lab.example.com:student/snmp repository, and then change to the repository directory:
[student@workstation git-repos]$git clone \git@git.lab.example.com:student/snmp.gitCloning into 'snmp'... ...output omitted... [student@workstation git-repos]$cd snmp[student@workstation snmp]$
Create and check out the exercise branch:
[student@workstation snmp]$git branch exercise[student@workstation snmp]$git checkout exerciseSwitched to branch 'exercise'
You can also use the git checkout -b exercise command to create and check out the exercise branch by using a single command:
[student@workstation snmp]$ git checkout -b exercise
Switched to a new branch 'exercise'Open VS Code and create a playbook named cisco_snmp.yml in the /home/student/git-repos/snmp directory.
Open VS Code and click → . Navigate to → → and then click .
In VS Code, click → . Click and then click .
Create a playbook with the following content and save it as cisco_snmp.yml:
---
- name: Configure SNMP on Cisco IOS XE managed nodes
hosts: ios
gather_facts: false
tasks:
- name: Configure SNMP using the snmp_server resource module
cisco.ios.ios_snmp_server:
state: merged
config:
location: 'Raleigh, NC'
contact: 'Network Engineering | neteng@company.com'
communities:
- acl_v4: snmpaclro
name: rocommunity2n4g!
ro: true
- acl_v4: snmpaclrw
name: rwcommunityd7g$v
rw: true
hosts:
- community_string: 'm0n1t0r'
host: 172.25.1.10
informs: true
version: 2c
traps:
bgp:
enable: true
eigrp: true
hsrp: true
ospf:
cisco_specific:
error: true
lsa: true
retransmit: true
snmp:
authentication: true
coldstart: true
linkdown: true
linkup: true
warmstart: trueIn VS Code, stage and commit the SNMP playbook.
Click the icon in the left navigation menu, or click → to display the Source Control panel.
Hover over your mouse over the file. A plus (+) symbol next to the file appears. Click the plus symbol to add the file to the Staged Changes section.

In the Message field in the Primary Side Bar, enter "Cisco SNMP playbook for IOS XE managed nodes" as the commit message and click .

Return to the terminal and run the cisco_snmp.yml playbook.
Copy all files from the ~/run-git directory to the ~/snmp directory.
This copies the ansible-navigator.yml and inventory files to the repository directory so that the playbook runs.
Add and commit these files to complete the project:
[student@workstation snmp]$cp ~/run-git/* .[student@workstation snmp]$git add ansible-navigator.yml inventory[student@workstation snmp]$git commit -m "Add automation navigator config file and managed node inventory file"[exercise 08eb493] Add automation navigator config file and managed node inventory file 2 files changed, 5 insertions(+), 1 deletion(-) [student@workstation snmp]
Run the cisco_snmp.yml playbook:
[student@workstation snmp]$ ansible-navigator run cisco_snmp.yml
PLAY [Configure SNMP on Cisco IOS XE managed nodes] ***************************
TASK [Configure SNMP using the snmp_server resource module] *******************
changed: [iosxe1.lab.example.com]
changed: [iosxe2.lab.example.com]
PLAY RECAP ********************************************************************
iosxe1.lab.example.com : ok=1 changed=1 unreachable=0 failed=0 ...
iosxe2.lab.example.com : ok=1 changed=1 unreachable=0 failed=0 ...In a terminal, verify that the job successfully deployed SNMP.
Connect to the iosxe1.lab.example.com managed node as the student user:
[student@workstation snmp]$ ssh student@iosxe1.lab.example.com
iosxe1.lab.example.com#Display the SNMP configuration for the managed node:
iosxe1.lab.example.com#show snmp
...output omitted...
SNMP informs: enabled
Informs in flight 0/25 (current/max)
Logging to 172.25.1.10.162
0 sent, 0 in-flight, 0 retries, 0 failed, 0 droppedReturn to the workstation machine:
iosxe1.lab.example.com#exit
Connection to iosxe1.lab.example.com closed by remote host.
Connection to iosxe1.lab.example.com closed.
[student@workstation snmp]$In the VS Code panel, synchronize the local commits with the remote repository.
Click the icon (…) and then click .

You might see a message asking you to publish the exercise branch.
Click Ok.

You might see another message asking you to periodically run git fetch.
Click No.
![]() |
Merge the exercise branch into the main branch.
Click on the bottom status bar to display the menu to change branches. Select the branch.

Click the icon (…) and then click → .

Select the exercise branch.

Close the /home/student/git-repos/snmp directory in VS Code.
If you are using the GNOME terminal, return to the /home/student directory.
Click → to close the /home/student/git-repos/snmp directory.
If you are using the GNOME terminal, run the cd command to return to the student home directory:
[student@workstation snmp]$ cd