NDFC Roles
Ansible Setup

Using Ansible + NDFC to Build EVPN Fabric

Now that Ansible has been installed on your development server you will focus on creating the playbooks to build out an entire VXLAN EVPN Fabric using the Ansible NDFC collection. The following Ansible NDFC collection modules will be the focus of this lab.

High Level List Of Steps for This Ansible Lab Section

  1. First you will configure Ansible to connect and authenticate with the NDFC contoller.
  2. Before you start to build out the VXLAN EVPN Fabric you will create a playbook to cleanup from previous sections.
  3. Finally you will use various Ansible modules from the NDFC collection to create a fabric, add devices, configure interfaces and apply policies.

Let's Get Started!

Step 1 - Create Ansible Roles For Building EVPN Fabric

Create all of the Ansible roles that will be used to build the Fabric.

Roles let you automatically load related vars, files, tasks, handlers, and other Ansible artifacts based on a known file structure. After you group your content in roles, you can easily reuse them and share them with other users.

Reference: Ansible Roles Documentation

Step 2 - Change into the root project directory


cd ~/workspace/ndfclab/ansible

Step 3 - Create Ansible Role: create_fabric


ansible-galaxy init roles/create_fabric

You should see the following output:

    - Role roles/create_fabric was created successfully

Step 4 - Create Ansible Role: add_inventory


ansible-galaxy init roles/add_inventory

Step 5 - Create Ansible Role: setup_vpc


ansible-galaxy init roles/setup_vpc

Step 6 - Create Ansible Role: manage_interfaces


ansible-galaxy init roles/manage_interfaces

Step 7 - Create Ansible Role: manage_overlay


ansible-galaxy init roles/manage_overlay

Step 8 - Create Ansible Role: deploy


ansible-galaxy init roles/deploy

Right now these roles are just generally empty directory folders with some boiler plate context and files but each have a specific purpose within the role. you will only focus on populating the main tasks folder in each role but here is a link to more documentation about how roles are used and how each directory within a role can be used.

Reference: Roles Directory Structure

Step 9 - Remove Unused Role Directories

You are only going to focus on the tasks directory in the role directory, roles/[role_name]/tasks, in this lab so go ahead and remove the other folders.


find ~/workspace/ndfclab/ansible/roles/*/ 2>/dev/null -mindepth 1 -name tasks -prune -o -exec rm -rf {} \;

Step 10 - Verify Ansible NDFC Directory Structure

View the structure by issuing the tree command on the roles parent directory.


tree roles/

    roles/
    ├── add_inventory
    │   └── tasks
    │       └── main.yml
    ├── create_fabric
    │   └── tasks
    │       └── main.yml
    ├── deploy
    │   └── tasks
    │       └── main.yml
    ├── manage_interfaces
    │   └── tasks
    │       └── main.yml
    ├── manage_overlay
    │   └── tasks
    │       └── main.yml
    └── setup_vpc
        └── tasks
            └── main.yml
    
    12 directories, 6 files

You should see 12 directories, 6 files.

Move to the next section where you will define the variables used to connect and authenticate to NDFC and variables used in the roles you just created in this section.