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!
cd ~/workspace/ndfclab/ansible
ansible-galaxy init roles/create_fabric
You should see the following output:
- Role roles/create_fabric was created successfully
ansible-galaxy init roles/add_inventory
ansible-galaxy init roles/manage_overlay
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
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 {} \;
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.