batfish.base

Ansible Roles for Batfish

Intentionet has created this Ansible role to help users include Batfish or Batfish Enterprise for checking network configurations before deployment within any Ansible playbook. This role is available on Ansible Galaxy as batfish.base. It features a set of Ansible modules that examine the configuration files of a network or a part of it, allowing users to gather configuration data and conduct network checks without relying on any specific vendor.

Overview of Modules

The role includes several key modules:

For a complete list of modules and their documentation, check the docs, and see how to package your network snapshots.

Examples

The example playbook below shows how to use the batfish.base role to get a list of interfaces from all devices in the network. You can also refer to the tutorials for more examples.

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

  tasks:

  - name: Set up 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 Batfish Enterprise, just add session_type: bfe in the setup task like this:

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

Dependencies

You need the following packages 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 the requirements, run:
      python3 -m pip install -r https://raw.githubusercontent.com/batfish/ansible/master/requirements.txt
      
  • Batfish service and client

    • For open-source users: Install Batfish and Pybatfish using the batfish setup playbook or run these 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 that come with Batfish Enterprise.

Installation

Ensure you have the dependencies above installed, 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 or feature requests, you can:

Contributors

This repository is contributed to and maintained by Intentionet.

Informazioni sul progetto

Ansible modules for Batfish (www.batfish.org)

Installa
ansible-galaxy install batfish.base
Licenza
apache-2.0
Download
8.8k
Proprietario