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 a playbook to build out parts of a VXLAN EVPN Fabric using the Ansible NDFC collection. This section will focus on introducing you to the NDFC Ansible collection and how to use it.

This section is important as in the next section you will build an entire fabric from scratch through a data model-driven abstraction layer, however, under the hood the same NDFC Ansible collection modules will actually be what is used.


To begin, you will create a set of Ansible roles that will contain procedural tasks to build and manage NDFC fabric(s).

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

Let's Get Started!


Step 1 - Change into the root project directory


cd ~/workspace/ndfclab/ansible


Step 2 - 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 3 - Create Ansible Role: add_inventory


ansible-galaxy init roles/add_inventory


Step 4 - Create Ansible Role: manage_overlay


ansible-galaxy init roles/manage_overlay


Step 5 - Create Ansible Role: deploy


ansible-galaxy init roles/deploy


Step 6 - Remove Unused Role Directories

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

Since 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 7 - 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_overlay
        └── tasks
            └── main.yml

    8 directories, 4 files

You should see 8 directories, 4 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.