Vars and Playbooks

Let's take a look at the group_vars, host_vars, and playbooks folders in the repository.

We'll cover the following

group_vars

The group_vars folder contains the data models applied to groups of devices found in the hosts file. This folder contains YAML files created to contain data models. group_vars folder matching the sample hosts file is as follows:

group_vars
|
 ---- ENTERPRISE.yml|
 ---- CAMPUS.yml
 ---- CAMPUS-CORE.yml
 ---- CAMPUS-DISTRIBUTION.yml
 ---- CAMPUS-ACCESS.yml
 ---- CAMPUS-ACCESS-3850.yml
 ---- CAMPUS-ACCESS-3750.yml
 ---- DATA-CENTER.yml
 ---- DATA-CENTER-7K.yml
 ---- DATA-CENTER-5K.yml
 ---- WAN.yml
 ---- WAN-ISR.yml
 ---- WAN-ACCESS.yml
 ---- DMZ.yml

host_vars

The hosts_vars, similar to the group_vars folder, contains the data models that apply to each device or host in the hosts file. This folder again contains YAML files. However a file using the device’s hostname is also created per device.

host_vars folder matching the sample hosts file is as follows:

hosts_vars
|
 ---- CORE.yml
 ---- DIST01.yml
 ---- DIST02.yml
 ---- ACCESS01.yml
 ---- ACCESS02.yml
 ---- ACCESS03.yml
 ---- DC01_7K.yml
 ---- DC02_7K.yml
 ---- DC01_5K.yml
 ---- DC02_5K.yml
 ---- WANISR01.yml
 ---- WANACCESS01.yml
 ---- DMZ01.yml
 ---- DMZ02.yml

playbooks

The playbooks folder is required in the Ansible framework. This is where YAML files that make up Ansible playbooks are stored. It is a good idea to have some structure, either by platform or function, as well as another level of folders for network reconnaissance playbooks, tactical playbooks, and network management playbooks. Think of these as executables. We can use ansible-playbook commands to run these playbooks.

playbooks
|
 ---- campus
      |
       ---- tactical
            |
             ---- ios_facts.yml
             ---- IOS_gather_facts.yml
             ---- ansible.cfg
             ---- banner.yml
             ---- campusaudit.yml
             ---- copyrunstart.yml
             ---- copyruntftp.yml
             ---- no-point-to-point.yml
             ---- ospfneighbors.yml
             ---- point-to-point.yml
        ---- ansible.cfg
        ---- assembled-config-campus.yml
        ---- config-campus.yml
        ---- documentation.yml
 ---- data_center

Get hands-on with 1400+ tech skills courses.