GithubHelp home page GithubHelp logo

junos_genius's Introduction

What to find on this repo:

Chatops for network engineers.
Initially inspired by this demo https://www.dravetech.com/blog/2016/03/30/chatops-demo.html
Actually based on slack and hubot and ansible for junos automation

Bot capabilties:

The bot can execute junos commands (set/delete/show) to a device or a group of devices.
It can also backup the junos configuration, rollback the junos configuration, load a jinja2 template, apply a playbook to junos devices.
This is easily extensible.

Syntax:

Here’s the chat syntax to delegate tasks to the bot, with some help:

  • myhubot target <target> set <junos_command> - Execute a junos set command on device/group <target>
  • myhubot target <target> delete <junos_command> - Execute a junos delete command on device/group <target>
  • myhubot target <target> rollback <rb_id> - Rollback <rb_id> the configuration of device/group <target>
  • myhubot target <target> template <template> - Backup the configuration of device/group <target>, and apply the jinja2 template <template> to the device/group <target>
  • myhubot target <target> backup - Backup the configuration of the device/group <target>
  • myhubot target <target> show <junos_command> - Execute a junos show command on device/group <target> and print the command output
  • myhubot target <target> playbook <playbook> - Execute the ansible playbook <playbook> on device/group <target>
  • hubot list playbooks - Print the list of Ansible playbooks
  • hubot list templates - Print the list of Jinja2 templates
  • hubot display - Print an Ansible file (playbook, template, ...)

Note: <target> is a device or a group of devices. <target> has to exist in the ansible inventory file (https://github.com/ksator/chatops_junos/blob/master/ansible/hosts).

Chat examples:
@myhubot help

@myhubot help template
@myhubot list templates
@myhubot display openconfig_bgp.j2
@myhubot list hosts
@myhubot target Openconfig_Routers template openconfig_bgp.j2
@myhubot target FR-MX80-214 show bgp summary 
@myhubot target Openconfig_Routers rollback 1

@myhubot target all backup

@myhubot target MX240-04 set system login message newbanner
@myhubot target MX240-04 delete system login message newbanner

@myhubot list playbooks
@myhubot target FR-MX80-214 playbook pb.check.physical.topology.yml

How does it work:

The bot configuration is this file: https://github.com/ksator/chatops_junos/blob/master/scripts/junos.coffee. This is where we define the various actions the bot has to take based on the slack messages in the chat room. So the bot is configured to execute Ansible playbooks.

The bot uses Ansible under the hood. Here's the Ansible content (playbooks, variables, inventory ....) https://github.com/ksator/chatops_junos/tree/master/ansible

So, as example, the slack message:

myhubot target <target> template <template>    

or

@myhubot target <target> template <template>  

triggers the ansible playbook pb.template.yml with some variable definitions (using the --extra-vars option to pass the variables definition to the playbook):
Actually, the bot will execute this command:

ansible-playbook $PWD/ansible/pb.template.yml --extra-vars = "{'device': <target>, 'template': <template>}"

Which is the equivalent of:

ansible-playbook $PWD/ansible/pb.template.yml --extra-vars "device=<target> template=<template>"  

The steps to reproduce are:

ksator@ubuntu:~/myhubot$ HUBOT_SLACK_TOKEN=xoxb-90946701733-BTJh5QnUdQrTMcbtjgawmvjo ./bin/hubot -a slack

Contributions, bugs, questions, suggestions, enhancement requests

They are more than welcome. Please submit github issues or pull requests.

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.