Skip to content
No description, website, or topics provided.
Python Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.buildkite
action_plugins
defaults
docs
handlers
library ability to pass extra_args to snapshot init (#87) Dec 21, 2019
meta
module_utils
tasks
tests
tutorials
vars
CONTRIBUTING.md
LICENSE
README.md
requirements.txt

README.md

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 documentation.

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.

---
- 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

Check out the tutorials for additional examples.

Dependencies

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

  • Python >= 2.7

  • Ansible 2.7 or later

  • Batfish module requirements listed in requirements.txt

    • To install these requirements, run:
      python -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:

      docker pull batfish/allinone
      docker run -v batfish-data:/data -p 8888:8888 -p 9997:9997 -p 9996:9996 batfish/allinone
      python -m pip install --upgrade git+https://github.com/batfish/pybatfish.git
      
    • 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.

You can’t perform that action at this time.