Ansible Automation Example: JSNAPY PRE/POST Upgrade Validation

Overview

Ansible Automation Example: JSNAPY PRE/POST Upgrade Validation

N|Solid

Overview

This example will show how to validate the status of our firewall before and after a software upgrade. This project will leverage JSNAPY over NETCONF RPCs.

In addition to the Ansible playbok, this project also ships with additional tools to help you along your way. You will find a Dockerfile for running the project in an isolated environment, and a Makefile for those of us that hate typing out everything all the time.

🚀 Executing the playbook

This project provides two unique methods of executing the playbook:

  1. Docker
  2. Your own Python environment

🐳 Docker

With Invoke installed on your machine

If you have invoke installed, you can use these two commands to build the container and run the playbook.

  1. build the container image with
$ invoke container
  1. run the playbook to push the network configuration changes
$ invoke ansible

Without Invoke installed on your system

  1. build the container image with
$ docker build -t registry.gitlab.com/cremsburg/juniper-automation-container:jsnapy-ospf files/docker/
  1. run the playbook to push the network configuration changes
$ docker run -it --rm \
    -v $PWD/files/:/home/tmp/files \
    -v $PWD/files/:/home/tmp/files \
    -w /home/tmp/files/ansible/ \
    registry.gitlab.com/cremsburg/juniper-automation-container:jsnapy-ospf ansible-playbook pb.jsnapy.ospf.yaml

〰️ Notes about Docker

If you are unsure if Docker is installed on your computer, then it's probably safe to suggest that it's not. If you're interested in learning more about the product, I encourage you to read a few blogs on the topic. A personal recommendation would be Digital Ocean

Some of the goodies placed in the docker folder are not relevant to our use case with Python. Feel free to delete them as you see fit, I simply wanted to share with you my Docker build process for all Juniper automation projects (including those based on Ansible). The world is your oyster and I won't judge you on whatever direction you take.

🐍 Your own Python environment

I have included a Poetry file for anyone saavy enough to take advantage. For the uninitiated, Poetry helps replicate Python environments between users with a single file. You'll need to have Poetry installed on your machine, for most users that will be solved with pip install poetry.

This is optional, I will share the methods of going with Poetry or without

  1. install Python dependencies

1a. with Poetry

$ poetry install

1b. without Poetry

$ python3 -m venv venv
$ source venv/bin/activate
$ pip install -r files/docker/requirements.txt
  1. change into Ansible directory
$ cd files/ansible
  1. install official Ansible roles for Juniper devices
$ ansible-galaxy install juniper.junos
  1. run your Ansible playbook
$ ansible-playbook pb.jsnapy.ospf.yaml -i ../docker/inventory.yaml

⚠️ Running into an error about junos-eznc? ⚠️

There's an annoyance with Ansible and the way it interacts with your Python virtual environment. Do not let that frustrate you to the point that you ditch virtual environments altogether, instead use this quick technique to fix the problem.

From your terminal, find out the full path to Python within your virtual environment

$ which python
/home/cdot/.cache/pypoetry/virtualenvs/jsnapy-ospf-X7Chj_yD-py3.8/bin/python

Copy the output from your command and update the ansible.cfg file found in the same directory as the playbook. Do not update the ansible.cfg file in the root of this project, that won't accomplish anything.

add the following line to your ansible.cfg file, make sure to paste in the output of your clipboard rather than use my example

interpreter_python = /home/cdot/.cache/pypoetry/virtualenvs/jsnapy-ospf-X7Chj_yD-py3.8/bin/python

Sorry about that, one day Ansible will get it right. Until then, I recommend considering the Docker approach.

〰️ Notes about Python Virtual Environments

Similar to Docker, if you are unsure if you're using Python Virtual Environment features, it is safe to suggest that you're not. You are strongly recommended to using a Python Virtual Environment everywhere. You can really mess up your machine if you're too lazy and say "ehh, that seems like it's not important". It is. If it sounds like I'm speaking from experience, well I'll never admit to it.

If you're interested in learning more about setting up Virtual Environments, I encourage you to read a few blogs on the topic. A personal recommendation would be

📝 Dependencies

Refer to the Poetry Lock file located at poetry.lock for detailed descriptions on each package installed.

⚙️ How it works

Let's take a second to do a nice John Madden play-by-play by visiting the documentation in the files/docs/ directory.

Name Description
pb.jsnapy.ospf.rst Validate OSPF neighbors with JSNAPY

〰️ Just an FYI for Ansible AWX / Tower users

You'll note that there is an ansible.cfg file found in the root of the project's directory, as well as a folder roles/ to host the requirements.yml file.

The only purpose these serve is for Ansible Tower, which will look for these files when the project syncs from Gitlab/Github/Whatever, and Tower will auto-install the packages.

The ansible.cfg file will be the definitive for each Playbook (Template) execution, so super important to keep it here.

📸 Screenshot

pb.configure.yaml

Owner
Calvin Remsburg
Calvin Remsburg
Pytorch implementation of SenFormer: Efficient Self-Ensemble Framework for Semantic Segmentation

SenFormer: Efficient Self-Ensemble Framework for Semantic Segmentation Efficient Self-Ensemble Framework for Semantic Segmentation by Walid Bousselham

61 Dec 26, 2022
Playable Video Generation

Playable Video Generation Playable Video Generation Willi Menapace, Stéphane Lathuilière, Sergey Tulyakov, Aliaksandr Siarohin, Elisa Ricci Paper: ArX

Willi Menapace 136 Dec 31, 2022
Pip-package for trajectory benchmarking from "Be your own Benchmark: No-Reference Trajectory Metric on Registered Point Clouds", ECMR'21

Map Metrics for Trajectory Quality Map metrics toolkit provides a set of metrics to quantitatively evaluate trajectory quality via estimating consiste

Mobile Robotics Lab. at Skoltech 31 Oct 28, 2022
smc.covid is an R package related to the paper A sequential Monte Carlo approach to estimate a time varying reproduction number in infectious disease models: the COVID-19 case by Storvik et al

smc.covid smc.covid is an R package related to the paper A sequential Monte Carlo approach to estimate a time varying reproduction number in infectiou

0 Oct 15, 2021
Official repository for the CVPR 2021 paper "Learning Feature Aggregation for Deep 3D Morphable Models"

Deep3DMM Official repository for the CVPR 2021 paper Learning Feature Aggregation for Deep 3D Morphable Models. Requirements This code is tested on Py

38 Dec 27, 2022
Forecasting for knowable future events using Bayesian informative priors (forecasting with judgmental-adjustment).

What is judgyprophet? judgyprophet is a Bayesian forecasting algorithm based on Prophet, that enables forecasting while using information known by the

AstraZeneca 56 Oct 26, 2022
Viperdb - A tiny log-structured key-value database written in pure Python

ViperDB 🐍 ViperDB is a lightweight embedded key-value store written in pure Pyt

17 Oct 17, 2022
Receptive Field Block Net for Accurate and Fast Object Detection, ECCV 2018

Receptive Field Block Net for Accurate and Fast Object Detection By Songtao Liu, Di Huang, Yunhong Wang Updatas (2021/07/23): YOLOX is here!, stronger

Liu Songtao 1.4k Dec 21, 2022
FairMOT - A simple baseline for one-shot multi-object tracking

FairMOT - A simple baseline for one-shot multi-object tracking

Yifu Zhang 3.6k Jan 08, 2023
Awesome Weak-Shot Learning

Awesome Weak-Shot Learning In weak-shot learning, all categories are split into non-overlapped base categories and novel categories, in which base cat

BCMI 162 Dec 30, 2022
Official repository for MixFaceNets: Extremely Efficient Face Recognition Networks

MixFaceNets This is the official repository of the paper: MixFaceNets: Extremely Efficient Face Recognition Networks. (Accepted in IJCB2021) https://i

Fadi Boutros 51 Dec 13, 2022
A numpy-based implementation of RANSAC for fundamental matrix and homography estimation. The degeneracy updating and local optimization components are included and optional.

Description A numpy-based implementation of RANSAC for fundamental matrix and homography estimation. The degeneracy updating and local optimization co

AoxiangFan 9 Nov 10, 2022
Web-interface + rest API for classification and regression (https://jeff1evesque.github.io/machine-learning.docs)

Machine Learning This project provides a web-interface, as well as a programmatic-api for various machine learning algorithms. Supported algorithms: S

Jeff Levesque 252 Dec 11, 2022
Code base for "On-the-Fly Test-time Adaptation for Medical Image Segmentation"

On-the-Fly Adaptation Official Pytorch Code base for On-the-Fly Test-time Adaptation for Medical Image Segmentation Paper Introduction One major probl

Jeya Maria Jose 17 Nov 10, 2022
Python script that allows you to automatically setup your Growtopia server.

AutoSetup Python script that allows you to automatically setup your Growtopia server. How To Use Firstly, install all the required modules that used i

Aspire 3 Mar 06, 2022
Implementation of Bottleneck Transformer in Pytorch

Bottleneck Transformer - Pytorch Implementation of Bottleneck Transformer, SotA visual recognition model with convolution + attention that outperforms

Phil Wang 621 Jan 06, 2023
Deep learning with TensorFlow and earth observation data.

Deep Learning with TensorFlow and EO Data Complete file set for Jupyter Book Autor: Development Seed Date: 04 October 2021 ISBN: (to come) Notebook tu

Development Seed 20 Nov 16, 2022
Convenient tool for speeding up the intern/officer review process.

icpc-app-screen Convenient tool for speeding up the intern/officer applicant review process. Eliminates the pain from reading application responses of

1 Oct 30, 2021
Crowd-Kit is a powerful Python library that implements commonly-used aggregation methods for crowdsourced annotation and offers the relevant metrics and datasets

Crowd-Kit: Computational Quality Control for Crowdsourcing Documentation Crowd-Kit is a powerful Python library that implements commonly-used aggregat

Toloka 125 Dec 30, 2022
Exploring Relational Context for Multi-Task Dense Prediction [ICCV 2021]

Adaptive Task-Relational Context (ATRC) This repository provides source code for the ICCV 2021 paper Exploring Relational Context for Multi-Task Dense

David Brüggemann 35 Dec 05, 2022