About this repository
Playbooks description
Repository structure
Network topology
This repository has Ansible playbooks examples to automate Arista EOS.
The playbooks are at the root of this repository. The playbooks name is playbook_*.yml
.
These playbooks update devices configuration:
-
playbook_enable_http_api.yml uses SSH to enable eAPI.
-
playbook_configure_using_files.yml generates the EOS configuration files conf_generated from the template config.j2 and loads the configuration generated on the EOS devices.
It is used to configure this lab (interfaces and BGP configuration). -
playbook_manage_vlans.yml manages VLANs and L2 interfaces in a declarative way.
-
playbook_configure_using_lines.yml shows how you can configure a device with a set of commands.
-
playbook_configure_login_banner.yml configures a multi lines login banner.
These playbooks collect data from devices:
-
playbook_print_version_and_model.yml executes a
show version
command and parses the command output and print the EOS version and device model. -
playbook_collect_commands.yml collects the EOS
show commands
defined in the file audit.yml and save the output in the directory cli.
The output can be used for a humans review.
To collect others EOSshow commands
, simply update the file audit.yml. -
playbook_backup_configuration.yml backups the running configuration in the directory backup.
-
playbook_collect_facts_config.yml backups the running configuration in the directory running_config.
-
playbook_collect_facts_hardware.yml returns the hardware facts (structured data about the device: SN, model, software version ...) and saves them in the directory hardware.
-
playbook_collect_facts_resources.yml returns some resources facts (structured data about the device: vlans, interfaces, ...) and saves them in the directory resources.
These playbooks validate the devices states:
-
playbook_validate_states.yml validates the devices states.
It is used to validate this lab.
The validation covers HW model, SW release, environment (cooling, temperature, power), interfaces status, LLDP topology, BGP sessions, IP reachability tests.
It compares the actual states with the desired states, and reports mismatches.- The desired states are described in variables (host_vars and group_vars directories). So we reuse the same variables we already used to generate the configuration files.
- The actual states are the states on the devices. To get the actual states, it runs
show commands
with a json output, and parses the output. - This playbook is interresting for CI because if a test fails, the pipeline will fail (either all the tests pass, or, the pipeline fails).
-
playbook_generate_audit_report.yml audits the devices and generates this humans readable report.
It is used to audit this lab.
The audit covers HW model, SW release, environment (cooling, temperature, power), interfaces status, LLDP topology, BGP sessions, IP reachability tests.
It compares the actual states with the desired states and generates a report:- The desired states are described in variables (host_vars and group_vars directories). So we reuse the same variables we already used to generate the configuration files.
- The actual states are the states on the devices.
- It runs
show commands
with a json representation and registers the outputs in variables. It doesnt process the data collected. - Then it renders a template to generate the report. The data processing (data parsing and data comparaison) is done by the template (not by the playbook).
- This playbook doesnt fail if a test fails (because this playbook doesn’t run the tests itself, the tests are ran by the template). So as example if a bgp session is not established the playbook will not fail but the report generated by the template will highlight this issue.
- The playbooks are at the root of this repository. The playbooks name is
playbook_*.yml
. - The inventory file is inventory.ini
- The variables are defined in the host_vars and group_vars directories
- The directory templates has the jinja templates used by the playbooks
- The directory roles has the roles used by the playbooks
- The directory outputs has the playbooks output
- The requirements file is requirements.txt
- The Ansible config file is ansible.cfg
3 EOS devices connected in a triangle topology and configured with EBGP