• jcnetworking
  • LONDON
ANSIBLE / PYTHON
PRACTICSE Netconf, Ansible with ubuntu in AWS/ REST API in postman FOR Cisco IOS XE

PRACTICSE Netconf, Ansible with ubuntu in AWS/ REST API in postman FOR Cisco IOS XE

First – Let’s go to AWS as they have 12 months free tier. Create an Account and VM under ubuntu machine. OR you can run linux VM on your PC …etc

 1  sudo update
 2  sudo apt update
 3  sudo apt upgrade -y
 4  sudo apt install software-properties-common
 5  sudo apt autoremove
 6  sudo add-apt-repository --yes --update ppa:ansible/ansible
 7  sudo apt install ansible

 8  ansible --version  ( you can check your version, if it is installed)
 9  cd /etc/ansible/

10  sudo apt install pip ( in case you need to install some library for python in the future )
11  sudo apt install git ( you can git clone some example in git  from cisco or others  )

12  sudo apt install python3

When All is ready, you can see the version of ansible & python as below

NETCONF, ANSIBLE

NETCONF / Ansible

In Cisco DevNet Sandbox, they already have one ready for you to use.

Figure 2.1

NETCONF – I’m using ubuntu VM in AWS to speak with IOS-XE.

  • Create Python script with file .py as below ( “ncclient is a library in python, if you don’t have it. You may need to install it “)
  • Run the command ‘python3 (file name).py’ then you will have long text as figure 2.2
  • Create another Python script with file .py
  • on Figure 2.2, you can see module name ‘Cisco-IOS-XE-icmp’, so you will create another python script and use this schema
Figure 2.2

With the second python script you create with module “Name” .

You will have a result, which you you can use pyang -f tree to view as a pretty format.

Figure 2.3

Ansible, as previous blog how to setup. configurate the file “ansible.cfg” & “hosts”, or you can create vars for password.

PING
Ansible-playbook
script
Result

RESTCONF in POSTMAN

First – install postman.

Second – on url, enter “https://sandbox-iosxe-recomm-1.cisco.com.

on “Authorization”, select “Basic Auth”. Put the login credential

Select GET and Hit “Send”, Then you should see pic as below. with 200 code which mean successful

Now, we want to get some information from the IOS XE router,

How is the interfaces information, We put ” restconf/data/ietf-interfaces:interfaces” after the Url.

Then you will see the information on pretty Body which shown interface information as GigaEthernet, Loopback, what is the ip address / mask

Leave a Reply

Your email address will not be published. Required fields are marked *