Docsity

Use python to manage network devices, Thesis of Network Design

Partial preview of the text

Download Use python to manage network devices and more Thesis Network Design in PDF only on Docsity!

Devops for network engineerDevops for network engineer

Bouida Djelloul ITSS 2018 Part1 Médéa

Agenda  (^) Devops  (^) Network automation tools  (^) Use python to manage network devices  (^) Automate tasks with ansible.  (^) NAPALM and ansible

Devops

Devops tools

Use python to manage network devices

Python is an interpreted high-level programming language for general-purpose programming. Created by Guido van Rossum and first released in 1991 , Python has a design philosophy that emphasizes code readability

Use python to manage network devices

The libraries you need to know :

  • (^) Getpass: Hides the input when prompted for sensitive data
  • (^) Netmiko: Handles your SSH/Telnet connections

Use python to manage network devices

Examples : from getpass import getpass import netmiko password = getpass() net_connect=netmiko.ConnectHandler(device _type=’cisco_ios’, ip=ip, username=username, password=password) output = net_connect.send_command(“show ip ssh”)

Why Automation?

  • Avoid repeated task
  • Avoid typographical error (Typos)
  • Faster deployment
  • Identical configuration

Why ansible?

● It is a free open source application ● Agent-less – No need for agent installation and management ● Highly flexible and configuration management of systems. ● Large number of ready to use modules for system management ● Custom modules can be added if needed ● Configuration roll-back in case of error ● Simple and human readable ● Self documenting

Install ansible

RHEL, Centos … #yum install ansible Debian, ubuntu … #apt install ansible Fedora #dnf install ansible Gentoo **#emerge -av app-admin/ansible ***** Only LINUX,MAC,UNIX *******

Ansible terms

Ansible terms

YAML

  • Start with - - -
  • File extention .yml/.yaml
  • Easy for a human to read

    • hosts: ios-routers gather_facts: no connection: local tasks: - name: Save Configuration ios_command: commands: - write memory host: "{{ ansible_host }}"

Ansible terms

Inventory

  • Static lines of devices
  • Can be accessed across multiple roles [ios-switchs] S_1 ansible_host=192.168.122. S_2 ansible_host=192.168.122. [ios-router] R_1 ansible_host=2001:db7::1021::

Ansible terms

Module examples :

  • asa_acl : Manage access-lists on a Cisco ASA
  • asa_command : Run arbitrary commands on Cisco ASA devices
  • ios_banner : Manage multiline banners on Cisco IOS devices
  • ios_command: Run commands on remote devices running Cisco IOS
  • ios_config :Manage Cisco IOS configuration sections
  • iosxr_command : Run commands on remote devices running Cisco IOS XR
  • iosxr_config :Manage Cisco IOS XR configuration sections http://docs.ansible.com/ansible/list_of_network_modules.html