Git Product home page Git Product logo

ansible's Introduction

Ansible roles for Batfish

Intentionet has created this Ansible role to allow users to embed Batfish or Batfish Enterprise pre-deployment validation into any Ansible playbook. This role is hosted on Ansible Galaxy as batfish.base. The role includes a set of Ansible modules that analyze configuration files for an entire (or subset of a) network, allowing users to extract configuration data and perform network-wide validation tests in a completely vendor agnostic manner.

Overview of Modules

Some of the modules included in the role are:

See docs for a complete list of modules and their documentation, and instructions for packaging your network snapshots

Examples

The example playbook below outlines how to use the batfish.base role to extract the list of interfaces for all devices in the network. Check out the tutorials for additional examples.

---
- name: Extract network device facts using Batfish and Ansible
  hosts: localhost
  connection: local
  gather_facts: no
  roles:
    - batfish.base

  tasks:

  - name: Setup connection to Batfish service
    bf_session:
      host: localhost
      name: local_batfish

  - name: Initialize the example network
    bf_init_snapshot:
      network: example_network
      snapshot: example_snapshot
      snapshot_data: ../networks/example
      overwrite: true

  - name: Retrieve Batfish Facts
    bf_extract_facts:
      output_directory: data/bf_facts
    register: bf_facts

  - name: Display configuration for all interfaces on all nodes
    debug: msg=" {{item.value.Interfaces}} "
    with_dict: "{{bf_facts.result.nodes}}"
    loop_control:
      label: " {{item.key}}.Interfaces "
    when: bf_facts.failed|bool == false

Note: to connect to a Batfish Enterprise service, just add session_type: bfe under parameters: in the setup task, e.g.:

  - name: Setup connection to Batfish Enterprise service
    bf_session:
      host: localhost
      name: local_batfish
      parameters:
        session_type: bfe

Dependencies

This module requires the following packages to be installed on the Ansible control machine:

  • Python 3.6 or 3.7

  • Ansible >=2.7 <=2.9.9

  • Batfish module requirements listed in requirements.txt

    • To install these requirements, run:
      python3 -m pip install -r https://raw.githubusercontent.com/batfish/ansible/master/requirements.txt
      
  • Batfish service and client

    • For open-source users: to install Batfish and Pybatfish, you may use the batfish setup playbook or run the following commands to update and run Batfish:

      python3 -m pip install --upgrade pybatfish
      docker pull batfish/allinone
      docker run -v batfish-data:/data -p 8888:8888 -p 9997:9997 -p 9996:9996 batfish/allinone
      
    • For enterprise users: follow the instructions delivered with Batfish Enterprise

Installation

Ensure that the dependencies above are met, and then get the latest version of the role from Ansible galaxy.

ansible-galaxy install --force batfish.base

License

Apache 2.0

Support

For bug reports and feature requests, you may:

Contributors

Intentionet is contributing to and maintaining this repository.

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.