Skip to content
This repository has been archived by the owner on Aug 22, 2023. It is now read-only.
/ ansible Public archive

Snapshot of a Batfish Ansible integration from 2020

License

Notifications You must be signed in to change notification settings

batfish/ansible

Repository files navigation

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.

About

Snapshot of a Batfish Ansible integration from 2020

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published