Code Monkey home page Code Monkey logo

netbox-nornir-graphql-webinar's Introduction

Automating Config Generation /w NetBox, Nornir and GraphQL

This repo contains the examples and scripts from the Packet Coders webinar:

Automating Config Generation /w NetBox, Nornir and GraphQL

Note

The recording for the webinar session can be viewed here.

Overview

This demo will:

  1. Use NetBox as dynamic inventory.
  2. Pull down host and interface data from NetBox via GraphQL.
  3. Render the a basic device config using Jinja templating and the GraphQL data.
  4. Write the rendered configuration to a file.

Setup

  1. Clone repo:
git clone [email protected]:packetcoders/netbox-nornir-graphql-webinar.git
  1. Create a .env.
cp .env.example .env
  1. Populate .env with NetBox FQDN and API token.
  2. Create virtual environment.
python -m venv .venv
source .venv/bin/activate
  1. Install dependancies
python -m pip install -r requirements.txt

Run the Demo

./demo/nr_build_w_graphql.py
# Output:
# ./demo/nr_build_w_graphql.py
# Build Configs /w NB + GraphQL**************************************************
# *
# * leaf1 ** changed : False *************************************************
# ****
# vvvv Build Configs /w NB + GraphQL ** changed : False vvvvvvvvvvvvvvvvvvvvvv
# vvvv INFO
# ---- task_graphql ** changed : False ---------------------------------------
# ---- INFO
# { 'custom_fields': { 'domain_name': 'packetcoders.lab',
#                      'ospf_area': '0',
#                      'router_id': '1.1.1.1'},
#   'device_type': {'model': 'Cisco IOSv', 'slug': 'cisco-iosv'},
#   'interfaces': [ { 'ip_addresses': [{'address': '10.1.1
# .2/30'}],
#                     'name': 'GigabitEthernet0/0'},
#                   { 'ip_addresses': [{'address': '10.2.1.2/30'}],
#                     'name': 'GigabitEthernet0/1'},
#                   { 'ip_addresses': [{'address': '172.29.151.103/24'}]
# ,
#                     'name': 'GigabitEthernet0/2'},
#                   {'ip_addresses': [], 'name': 'GigabitEthernet0/3'},
#                   {'ip_addresses': [], 'name': 'GigabitEthernet0/4'},
#                   {'ip_addresses': [], 'name': 'GigabitEthernet0/5'},
#                   {'ip_addresses': [], 'name': 'GigabitEthernet0/6'},
#                   {'ip_addresses': [], 'name': 'GigabitEthernet0/7'},
#                   {'ip_addresses': [], 'name': 'GigabitEthernet0/8'},
#                   {'ip_addresses': [], 'name': 'GigabitEthernet0/9'},
#                   { 'ip_addresses': [{'address': '1.1.1.1/32'}],
#                     'name': 'Loopback 0'}],
...

The rendered files can then be located within the rendered directory:

head -n 20 demo/rendered/leaf1.txt
# Output:
# service timestamps debug datetime msec
# service timestamps log datetime msec
# no service password-encryption
#
# hostname leaf1
#
# boot-start-marker
# boot-end-marker
#
# aaa new-model
# aaa authentication login default local
# aaa session-id common
#
# ip cef
# no ipv6 cef
#
# multilink bundle-name authenticated
#
# interface GigabitEthernet0/0
#   ip address 10.1.1.2 255.255.255.252

netbox-nornir-graphql-webinar's People

Contributors

rickdonato avatar

Stargazers

Rodrigo Sepúlveda Heerwagen avatar Cole Phillips avatar Michael Bear avatar net_zero avatar Jan Krupa avatar JR Miller avatar  avatar Bart Dorlandt avatar John Ojo avatar  avatar Erdem Sarıkuş avatar Saikrishna M avatar

Watchers

 avatar

Forkers

boxops cvlabsio

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.