### Install AVD Examples with Ansible Source: https://avd.arista.com/6.1/ansible_collections/arista/avd/examples/l2ls-fabric/index.html This playbook installs the AVD examples, including the L2LS fabric, to the current working directory. It ensures all necessary example files are present for further customization. Rerunning the playbook will not overwrite modified files but will re-create deleted ones. ```bash ansible-playbook arista.avd.install_examples ``` ```text PLAY [Install Examples]********************************************************************************************** TASK [Copy all examples to ~/ansible-avd-examples]******************************************************************* changed: [localhost] PLAY RECAP ********************************************************************************************************************* localhost : ok=1 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 ``` -------------------------------- ### Install AVD Examples via Ansible Source: https://avd.arista.com/6.1/ansible_collections/arista/avd/examples/dual-dc-l3ls/index.html Executes the Ansible playbook to copy the AVD example files into the local working directory. This is the initial step for setting up the environment to follow the dual data center L3LS guide. ```bash ansible-playbook arista.avd.install_examples ``` -------------------------------- ### PyAVD Build Script Migration Example Source: https://avd.arista.com/6.1/docs/porting-guides/6.x.x.html Illustrates the migration of a build script from PyAVD 5.x to PyAVD 6.0.0. This example focuses on the changes in how AVD facts, structured configurations, and device configurations are retrieved and processed. ```python #!/usr/bin/env python3 # Copyright (c) 2026 Arista Networks, Inc. from __future__ import annotations from pathlib import Path from typing import TYPE_CHECKING, Any from pyavd import ( get_avd_facts, get_device_config, get_device_doc, get_device_structured_config, validate_inputs, validate_structured_config, ) if TYPE_CHECKING: # Importing internal objects only for type hinting to improve script readability. from pyavd._eos_designs.eos_facts.schema import EosDesignsFacts from pyavd import ValidationResult # 'generate_inventory' is a module which generates a test inventory. # This should be replaced with something that reads a proper inventory like the Ansible inventory. from generate_inventory import generate_hostvars def main() -> None: # Prepare output directories config_dir = Path(__file__).parent / "configs" config_dir.mkdir(exist_ok=True) [file.unlink() for file in config_dir.glob("*")] docs_dir = Path(__file__).parent / "docs" docs_dir.mkdir(exist_ok=True) [file.unlink() for file in docs_dir.glob("*")] inventory: dict[str, dict[str, Any]] = generate_hostvars(spine_count=2, l3leaf_count=2, l2leaf_count=2, vrf_count=2, per_vrf_svi_count=2) # Validating and inplace update with coerced types for device, hostvars in inventory.items(): validation_result: ValidationResult = validate_inputs(inputs=hostvars) if validation_result.failed: msg: str = f"Validation of hostvars failed for {device}: {validation_result.validation_errors}" raise ValueError(msg) # Get AVD Facts avd_facts: dict[str, EosDesignsFacts] = get_avd_facts(all_inputs=inventory) # Get Device Structured Configs for device, hostvars in inventory.items(): structured_config: dict = get_device_structured_config(hostname=device, inputs=hostvars, avd_facts=avd_facts) # Validating and inplace update with coerced types validation_result: ValidationResult = validate_structured_config(structured_config=structured_config) if validation_result.failed: msg: str = f"Validation of structured config failed for {device}: {validation_result.validation_errors}" raise ValueError(msg) # Get Device Configs config: str = get_device_config(structured_config=structured_config) config_dir.joinpath(f"{device}.cfg").write_text(data=config) # Get Device Documentation documentation: str = get_device_doc(structured_config=structured_config) docs_dir.joinpath(f"{device}.md").write_text(data=documentation) print(".", end="", flush=True) print("") if __name__ == "__main__": main() ``` -------------------------------- ### Configure VTEP Loopback and L3 Leaf Settings Source: https://avd.arista.com/6.1/docs/howto/ip_addressing/index.html Example YAML configuration for defining VTEP loopback pools and L3 leaf node groups in AVD. This setup includes platform defaults, uplink switch definitions, and specific node configurations. ```yaml l3leaf: defaults: platform: vEOS-lab loopback_ipv4_pool: 10.255.0.0/27 loopback_ipv4_offset: 2 vtep_loopback_ipv4_pool: 10.255.3.0/27 uplink_switches: ['htipa-spine1', 'htipa-spine2'] uplink_ipv4_pool: 10.255.255.0/26 mlag_peer_ipv4_pool: 10.255.3.64/27 mlag_peer_l3_ipv4_pool: 10.255.3.96/27 virtual_router_mac_address: 00:1c:73:00:00:99 spanning_tree_priority: 4096 spanning_tree_mode: mstp node_groups: - group: HTIPA_L3_LEAFS bgp_as: 65101 loopback_ipv4_pool: 10.255.1.0/24 nodes: - name: htipa-leaf1 id: 1 mgmt_ip: 172.16.2.101/24 uplink_switch_interfaces: [Ethernet1, Ethernet1] loopback_ipv4_pool: 10.255.2.0/24 - name: htipa-leaf2 id: 2 uplink_switch_interfaces: [Ethernet2, Ethernet2] mgmt_ip: 172.16.2.102/24 ``` -------------------------------- ### Ansible Playbook Execution Output Source: https://avd.arista.com/6.1/ansible_collections/arista/avd/examples/single-dc-l3ls/index.html This is the expected output when running the 'arista.avd.install_examples' playbook. It indicates that the task to copy all examples has completed successfully. ```text PLAY [Install Examples]********************************************************************************************** TASK [Copy all examples to ~/ansible-avd-examples]******************************************************************* changed: [localhost] PLAY RECAP ********************************************************************************************************************* localhost : ok=1 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 ``` -------------------------------- ### Install Ansible Utils Collection Source: https://avd.arista.com/6.1/docs/porting-guides/6.x.x.html Command to manually install the ansible.utils collection, which is no longer a direct dependency of arista.avd. ```bash ansible-galaxy collection install ansible.utils ``` -------------------------------- ### Ansible Playbook Example for Build Output Folders Source: https://avd.arista.com/6.1/ansible_collections/arista/avd/roles/build_output_folders/index.html An example Ansible playbook demonstrating how to use the `arista.avd.build_output_folders` role. It shows the basic structure for importing the role and executing it against specified hosts, utilizing default role variables. ```yaml - name: Build Switch configuration hosts: DC1_FABRIC connection: local gather_facts: false tasks: - name: 'Build local folders for output' ansible.builtin.import_role: name: arista.avd.build_output_folders ``` -------------------------------- ### Example Custom Template Structure Source: https://avd.arista.com/6.1/ansible_collections/arista/avd/roles/eos_designs/docs/how-to/custom-templates.html This example shows the basic structure of a custom configuration variable within a Jinja2 template. It demonstrates how to define a variable name and its value, including Jinja2 templating. ```yaml _structured_configuration_variable_name: structured_configuration_variable_value {{ some_variable }} ``` -------------------------------- ### Configure WAN Management Settings Source: https://avd.arista.com/6.1/ansible_collections/arista/avd/examples/cv-pathfinder/index.html Example YAML configuration for WAN management, including gateway, NTP, CloudVision integration, and local user authentication settings. ```yaml --- # WAN Management settings mgmt_gateway: 192.168.17.1 # NTP ntp_settings: servers: - name: 0.pool.ntp.org # CloudVision/TerminAttr cv_settings: cvaas: enabled: true # For each local user in this example, password == username aaa_settings: authorization: exec: default: local local_users: - name: admin privilege: 15 role: network-admin no_password: true - name: arista privilege: 15 role: network-admin sha512_password: "$6$Enl0WfE32FthwyiJ$yTyGaEJ2uPKLU.F7314YtB7J1jrzrMi7ogXIRTEHQfLdLgKWWmr1UvNlZLN6AyuxET7G5aH3AI9OYRzxVTkB1." - name: cvpadmin privilege: 15 role: network-admin sha512_password: $6$a7LdQWHxWzYHpvVt$n62q.1mbm4kzQ5oBr0lhXCE9ntnTn.SNa16DovZHahFQLH.iPcPMZa5JUSFtncrDW4EDQ3oSWgP8G0S4FtOFx1 ``` -------------------------------- ### Example Ansible Playbook for eos_snapshot Source: https://avd.arista.com/6.1/ansible_collections/arista/avd/roles/eos_snapshot/index.html An example Ansible playbook that demonstrates how to use the eos_snapshot role. It specifies the target hosts, connection method, and imports the arista.avd.eos_snapshot role to execute the command collection tasks. ```yaml --- - name: Collect commands hosts: DC1_FABRIC connection: local gather_facts: false collections: - arista.avd tasks: - name: Collect commands ansible.builtin.import_role: name: eos_snapshot ``` -------------------------------- ### Run Playbook with Global Vars (ansible.cfg) Source: https://avd.arista.com/6.1/docs/plugins/Vars_plugins/global_vars.html This example demonstrates how to execute an Ansible playbook after configuring the global_vars plugin in ansible.cfg. The plugin will load variables based on the paths specified. ```bash ansible-playbook -i inventory.yml playbook.yml ``` -------------------------------- ### Node ID Assignment: Static Assignment Example Source: https://avd.arista.com/6.1/docs/howto/ip_addressing/index.html Demonstrates static node ID assignment where IDs are manually assigned to each node in the configuration. ```yaml spine: nodes: - name: htipa-spine1 id: 1 - name: htipa-spine2 id: 2 ``` -------------------------------- ### AVD Examples Directory Structure Source: https://avd.arista.com/6.1/ansible_collections/arista/avd/examples/single-dc-l3ls/index.html This shows the typical directory structure created after successfully running the 'arista.avd.install_examples' playbook. It includes configuration files, group variables, intended state, and deployment scripts. ```bash ansible-avd-examples/ (or wherever the playbook was run) |-- single-dc-l3ls ├── ansible.cfg ├── documentation ├── group_vars ├── images ├── intended ├── inventory.yml ├── build.yml ├── deploy.yml ├── deploy-cvp.yml ├── README.md └── switch-basic-configurations ``` -------------------------------- ### Get MLAG VTEP IPv6 Address (Python) Source: https://avd.arista.com/6.1/docs/pyavd/pyavd.html Generates the IPv6 address for a VTEP specifically for MLAG Leaf devices. Similar to the standard VTEP function, it checks for a pre-configured address or calculates it from a pool using the MLAG primary ID and an offset. This ensures correct IP assignment in redundant MLAG setups. ```Python def vtep_ipv6_mlag(self) -> str: """ Return IP address for VTEP for MLAG Leaf. If "vtep_loopback_ipv6_address" is set, it is used. Default pool is "vtep_loopback_ipv6_pool" Default offset from pool is `mlag_primary_id + loopback_ipv6_offset` """ if self._vtep_loopback_ipv6_address: return self._vtep_loopback_ipv6_address offset = self._mlag_primary_id + self._loopback_ipv6_offset return get_ip_from_pool(self._vtep_loopback_ipv6_pool, 64, offset, 0) ``` -------------------------------- ### Interface Range Syntax Examples Source: https://avd.arista.com/6.1/docs/howto/fabric_topology/index.html Demonstrates AVD's flexible interface range notation for configuring multiple interfaces efficiently. Supports hyphenated ranges, slash notation for sub-interfaces, and explicit lists. ```text Ethernet1-4 Ethernet49-52/1 [Ethernet1, Ethernet2] ``` -------------------------------- ### Install PyAVD Source: https://avd.arista.com/6.1/docs/pyavd/pyavd.html Installs the pyavd Python package. Python dependencies are automatically installed. To include Ansible AVD collection Python requirements, install with the 'ansible' extra. ```bash pip install pyavd ``` ```bash pip install pyavd[ansible] ``` -------------------------------- ### Basic Configuration and Tag Deployment to CloudVision Source: https://avd.arista.com/6.1/ansible_collections/arista/avd/roles/cv_deploy/index.html This example demonstrates a basic playbook to deploy configurations and tags for devices in the 'FABRIC' inventory group to CloudVision. It utilizes the arista.avd.cv_deploy role, specifying the CloudVision server URL and a service account token for authentication. The change control created by this process will remain in a 'pending approval' state. ```yaml - name: Configuration deployment hosts: FABRIC # <-- Targeted devices connection: local gather_facts: false tasks: - name: Deploy configurations and tags to CloudVision ansible.builtin.import_role: name: arista.avd.cv_deploy vars: cv_server: www.arista.io cv_token: ``` -------------------------------- ### Configure RADIUS Servers with Custom Structured Configuration Source: https://avd.arista.com/6.1/ansible_collections/arista/avd/roles/eos_designs/docs/how-to/custom-structured-configuration.html This example demonstrates how RADIUS servers are configured, showing the append behavior when the schema lacks a primary key. It illustrates how servers from AVD designs and custom configurations are merged, including handling duplicate hosts with different configurations like TLS. ```yaml --- aaa_settings: radius: servers: - host: 10.10.10.1 key: - host: 10.10.10.2 key: custom_structured_configuration_radius_server: servers: - host: 10.10.10.1 tls: enabled: true ssl_profile: RADIUS_TLS_PROFILE port: 2083 - host: 10.10.10.3 key: timeout: 5 - host: 10.10.10.4 key: retransmit: 3 ``` ```eos radius-server host 10.10.10.1 key 7 radius-server host 10.10.10.1 ssl-profile RADIUS_TLS_PROFILE port 2083 radius-server host 10.10.10.2 key 7 radius-server host 10.10.10.3 key 7 timeout 5 radius-server host 10.10.10.4 key 7 retransmit 3 ``` -------------------------------- ### Install arista.avd Collection in a Specific Directory Source: https://avd.arista.com/6.1/docs/installation/collection-installation.html Installs the arista.avd collection into a specified directory within your project, using the `-p` option with `ansible-galaxy`. It also shows how to configure Ansible to recognize this custom collection path. ```bash # Install collection under ${PWD}/collections/ $ ansible-galaxy collection install arista.avd -p collections/ ``` ```ini # Update ansible.cfg file [defaults] collections_path = ${PWD}/collections:~/.ansible/collections:/usr/share/ansible/collections ``` -------------------------------- ### Build and Push Execution Environment Image Source: https://avd.arista.com/6.1/docs/user-manual/avd-aap.html Commands to build the custom Execution Environment image using Podman and push it to a container registry for use in AAP. ```bash ansible-builder build --container-runtime podman -v 3 --tag username/image-name podman push IMAGEID docker://docker.io/username/image-name ``` -------------------------------- ### Install Latest Development Version of arista.avd from GitHub Source: https://avd.arista.com/6.1/docs/installation/collection-installation.html Installs the latest development version of pyavd from the AVD GitHub repository and the corresponding development branch of the arista.avd collection. This is typically used for testing or contributing to the project. ```bash pip install "pyavd[ansible] @ git+https://github.com/aristanetworks/avd.git@devel#subdirectory=python-avd" ansible-galaxy collection install git+https://github.com/aristanetworks/avd.git#/ansible_collections/arista/avd/,devel ``` -------------------------------- ### Install Latest arista.avd Collection and Python Requirements Source: https://avd.arista.com/6.1/docs/installation/collection-installation.html Installs the latest pyavd package with Ansible dependencies and the latest arista.avd Ansible collection from Ansible Galaxy. This ensures all necessary Python and Ansible components are up-to-date. ```bash pip install "pyavd[ansible]" ansible-galaxy collection install arista.avd ``` -------------------------------- ### AVD String Formatter Syntax Example Source: https://avd.arista.com/6.1/ansible_collections/arista/avd/roles/eos_designs/docs/how-to/custom-descriptions-names.html Demonstrates the AVD string formatter syntax for creating dynamic descriptions based on template fields. It supports prefixes, suffixes, optional fields, and case conversion. ```text {endpoint_type!u}_{endpoint}{endpoint_port_channel?<_} ``` -------------------------------- ### Python Script for Network Device Configuration and Documentation Source: https://avd.arista.com/6.1/docs/porting-guides/6.x.x.html This Python script, 'generate_inventory.py', prepares output directories, generates host variables from an inventory, validates inputs, retrieves AVD facts, and generates device-specific configurations and documentation. It handles directory creation, file cleanup, input validation, and config/doc generation for each device. ```Python from pathlib import Path from typing import Any # Assuming generate_hostvars, validate_inputs, get_avd_facts, get_device_structured_config, get_device_config, get_device_doc are imported from other modules # from generate_inventory import generate_hostvars # from validation import ValidationResult, ValidatedDataResult # from facts import EosDesignsFacts # from structured_config import EOSConfig def main() -> None: # Prepare output directories config_dir = Path(__file__).parent / "configs" config_dir.mkdir(exist_ok=True) [file.unlink() for file in config_dir.glob("*")] docs_dir = Path(__file__).parent / "docs" docs_dir.mkdir(exist_ok=True) [file.unlink() for file in docs_dir.glob("*")] # Placeholder for actual inventory generation # inventory: dict[str, dict[str, Any]] = generate_hostvars(spine_count=2, l3leaf_count=2, l2leaf_count=2, vrf_count=2, per_vrf_svi_count=2) inventory: dict[str, dict[str, Any]] = {} # Validating and get back the validated inputs with coerced types for device, hostvars in inventory.items(): # validated_data_result: ValidatedDataResult = validate_inputs(inputs=hostvars) validated_data_result = None # Placeholder if validated_data_result.validated_data is None: msg: str = f"Validation of hostvars failed for {device}: {validated_data_result.validation_result.violations}" raise ValueError(msg) inventory[device] = validated_data_result.validated_data # Get AVD Facts # We may be using custom Python modules for IP addressing or Descriptions, so we need to pass the hostvars as well since they can be used there. # avd_facts: dict[str, EosDesignsFacts] = get_avd_facts(all_inputs=inventory, all_hostvars=inventory) avd_facts = {} # Get Device Structured Configs for device, hostvars in inventory.items(): # We may be using custom Python modules for IP addressing or Descriptions, so we need to pass the hostvars as well since they can be used there. # structured_config: EOSConfig = get_device_structured_config(hostname=device, inputs=hostvars, hostvars=hostvars, avd_facts=avd_facts) structured_config = {} # Get Device Configs # config: str = get_device_config(structured_config=structured_config) config = "" config_dir.joinpath(f"{device}.cfg").write_text(data=config) # Get Device Documentation # documentation: str = get_device_doc(structured_config=structured_config) documentation = "" docs_dir.joinpath(f"{device}.md").write_text(data=documentation) print(".", end="", flush=True) print("") if __name__ == "__main__": main() ``` -------------------------------- ### Ansible Inventory Example for eos_snapshot Source: https://avd.arista.com/6.1/ansible_collections/arista/avd/roles/eos_snapshot/index.html An example Ansible inventory file (inventory.ini) showing the structure for defining network devices and their hierarchical organization. This is used by the eos_snapshot role to connect to and collect data from specified devices. ```ini --- all: children: DC1: children: DC1_FABRIC: children: DC1_SPINES: hosts: switch2: ansible_host: 10.83.28.190 DC1_L3LEAFS: children: DC1_LEAF1: hosts: switch1: ansible_host: 10.83.28.216 DC1_LEAF2: hosts: switch3: ansible_host: 10.83.28.191 ``` -------------------------------- ### Install Specific Version of arista.avd Collection and Python Requirements Source: https://avd.arista.com/6.1/docs/installation/collection-installation.html Installs a specific version of the pyavd package with Ansible dependencies and the arista.avd Ansible collection from Ansible Galaxy. This is useful for maintaining compatibility with specific project requirements. ```bash pip install "pyavd[ansible]==5.7.3" ansible-galaxy collection install arista.avd:==5.7.3 ``` -------------------------------- ### Configure DNS Servers using custom_structured_configuration prefix Source: https://avd.arista.com/6.1/docs/user-manual/ansible-usage-patterns.html Demonstrates how to apply custom EOS configuration using the custom_structured_configuration_ prefix. This approach allows for a flatter variable structure and can be defined at various inventory levels. ```yaml custom_structured_configuration_ip_name_server: vrfs: - name: MGMT servers: - ip_address: 10.20.20.10 - ip_address: 10.10.128.10 priority: 2 ``` -------------------------------- ### Install and Run Pre-commit Hooks Source: https://avd.arista.com/6.1/docs/contribution/development-tooling.html Commands to initialize and execute pre-commit git hooks to ensure code quality before commits. These hooks automatically detect changed files and run validation tests. ```bash cd avd pre-commit install pre-commit run pre-commit run --all pre-commit run schemas --all ``` -------------------------------- ### Upgrade Installed arista.avd Collection Source: https://avd.arista.com/6.1/docs/installation/collection-installation.html Upgrades an already installed arista.avd collection to the latest available version using the `-U` flag with `ansible-galaxy`. It also provides the corresponding pip command to update the Python requirements to match the upgraded collection. ```bash $ ansible-galaxy collection install -U arista.avd Process install dependency map Starting collection install process Installing 'arista.avd:6.0.0' to '/home/arista/.ansible/collections/ansible_collections/arista/avd' ``` ```bash pip install "pyavd[ansible]==6.0.0" ``` -------------------------------- ### Install AVD Python Dependencies Source: https://avd.arista.com/6.1/docs/contribution/development-tooling.html This command installs the development requirements and the 'pyavd' package in the activated Python virtual environment. It must be executed from the root of the cloned AVD repository. Ensure your pip version is 25.1 or later for `--group` support. ```bash # Install AVD project dev requirements and `pyavd` in your Python Virtual environment. # The installation _must_ be performed from the root of the cloned avd repository. cd avd pip3 install --group dev --upgrade make pyavd-editable-install ``` -------------------------------- ### Build AVD Configurations and Documentation Source: https://avd.arista.com/6.1/ansible_collections/arista/avd/examples/single-dc-l3ls/index.html Ansible playbook to generate structured configurations and EOS CLI outputs using the arista.avd roles. ```yaml --- - name: Build Configurations and Documentation hosts: FABRIC gather_facts: false tasks: - name: Generate AVD Structured Configurations and Fabric Documentation ansible.builtin.import_role: name: arista.avd.eos_designs - name: Generate Device Configurations and Documentation ansible.builtin.import_role: name: arista.avd.eos_cli_config_gen ``` -------------------------------- ### AVD IP Addressing Configuration Example (YAML) Source: https://avd.arista.com/6.1/docs/howto/ip_addressing/index.html This YAML snippet demonstrates how to configure IP pools and offsets for different device types (spine and l3leaf) within AVD. It shows the hierarchy of pool definitions from node type defaults to node-specific settings. ```yaml --- l3leaf: defaults: platform: vEOS-lab loopback_ipv4_pool: 10.255.0.0/27 loopback_ipv4_offset: 2 vtep_loopback_ipv4_pool: 10.255.3.0/27 uplink_switches: ['htipa-spine1', 'htipa-spine2'] uplink_ipv4_pool: 10.255.255.0/26 mlag_peer_ipv4_pool: 10.255.3.64/27 mlag_peer_l3_ipv4_pool: 10.255.3.96/27 virtual_router_mac_address: 00:1c:73:00:00:99 spanning_tree_priority: 4096 spanning_tree_mode: mstp node_groups: - group: HTIPA_L3_LEAFS bgp_as: 65101 loopback_ipv4_pool: 10.255.1.0/24 nodes: - name: htipa-leaf1 id: 1 mgmt_ip: 172.16.2.101/24 uplink_switch_interfaces: [Ethernet1, Ethernet1] loopback_ipv4_pool: 10.255.2.0/24 - name: htipa-leaf2 id: 2 uplink_switch_interfaces: [Ethernet2, Ethernet2] mgmt_ip: 172.16.2.102/24 --- spine: defaults: platform: vEOS-lab loopback_ipv4_pool: 10.255.0.0/27 bgp_as: 65100 nodes: - name: htipa-spine1 id: 1 mgmt_ip: 172.16.2.11/24 - name: htipa-spine2 id: 2 mgmt_ip: 172.16.2.12/24 ``` -------------------------------- ### Ansible Group Variables Example for eos_snapshot Source: https://avd.arista.com/6.1/ansible_collections/arista/avd/roles/eos_snapshot/index.html Example Ansible group variables (DC1.yml) for defining connection parameters and network OS details. This includes the Ansible user, password, network OS, and privilege escalation method, which are essential for the eos_snapshot role to connect to Arista EOS devices. ```yaml ansible_user: 'arista' ansible_password: 'arista' ansible_network_os: eos ansible_become: true ansible_become_method: enable ``` -------------------------------- ### GET /api/ip_addressing/mlag_ip_secondary Source: https://avd.arista.com/6.1/docs/pyavd/pyavd.html Retrieves the secondary IP address for MLAG configurations, defaulting to the mlag_peer_ipv4_pool. ```APIDOC ## GET /api/ip_addressing/mlag_ip_secondary ### Description Returns the calculated IP address for the MLAG Secondary node. It supports both IPv4 and IPv6 address families based on the node configuration. ### Method GET ### Endpoint /api/ip_addressing/mlag_ip_secondary ### Response #### Success Response (200) - **ip_address** (string) - The calculated IP address for the MLAG secondary peer. #### Response Example { "ip_address": "10.0.0.2" } ``` -------------------------------- ### Build Configurations with Arista AVD Source: https://avd.arista.com/6.1/ansible_collections/arista/avd/examples/cv-pathfinder/index.html This example shows the execution of an Ansible playbook named 'build.yml' which is part of the Arista AVD framework. The playbook performs tasks like verifying requirements and creating necessary directories for configuration building. ```bash user@ubuntu:~/cv-pathfinder$ ansible-playbook build.yml PLAY [Build Configs] *************************************************************************** TASK [arista.avd.eos_designs : Verify Requirements] ******************************************** AVD version 5.0.0 ok: [pf1 -> localhost] TASK [arista.avd.eos_designs : Create required output directories if not present] ************** ok: [pf1 -> localhost] => (item=//home/user/Documents/git_projects/ansible-avd-examples/cv-pathfinder/intended/structured_configs) ok: [pf1 -> localhost] => (item=/home/user/Documents/git_projects/ansible-avd-examples/cv-pathfinder/documentation/fabric) (...) ``` -------------------------------- ### POST /pyavd/get_device_doc Source: https://avd.arista.com/6.1/docs/pyavd/pyavd.html Generates device documentation in Markdown format based on provided structured configuration data. ```APIDOC ## POST /pyavd/get_device_doc ### Description Render and return the device documentation using AVD eos_cli_config_gen templates. This function takes a validated structured configuration and returns a Markdown string. ### Method POST ### Endpoint /pyavd/get_device_doc ### Parameters #### Request Body - **structured_config** (EOSConfig | dict) - Required - EOSConfig instance or dictionary with the validated structured configuration. - **add_md_toc** (bool) - Optional - Add a table of contents for markdown headings. Defaults to False. ### Request Example { "structured_config": { "hostname": "leaf1", "interfaces": [...] }, "add_md_toc": true } ### Response #### Success Response (200) - **body** (string) - Device documentation in Markdown format. #### Response Example { "documentation": "# Device: leaf1\n## Interfaces\n..." } ``` -------------------------------- ### GET /api/ip_addressing/mlag_ip_primary Source: https://avd.arista.com/6.1/docs/pyavd/pyavd.html Retrieves the primary IP address for MLAG configurations, defaulting to the mlag_peer_ipv4_pool. ```APIDOC ## GET /api/ip_addressing/mlag_ip_primary ### Description Returns the calculated IP address for the MLAG Primary node. It supports both IPv4 and IPv6 address families based on the node configuration. ### Method GET ### Endpoint /api/ip_addressing/mlag_ip_primary ### Response #### Success Response (200) - **ip_address** (string) - The calculated IP address for the MLAG primary peer. #### Response Example { "ip_address": "10.0.0.1" } ``` -------------------------------- ### GET /api/ip_addressing/mlag_l3_ip_secondary Source: https://avd.arista.com/6.1/docs/pyavd/pyavd.html Retrieves the secondary L3 peering IP address for MLAG, using the mlag_peer_l3_ipv4_pool. ```APIDOC ## GET /api/ip_addressing/mlag_l3_ip_secondary ### Description Returns the L3 peering IP address for the MLAG Secondary node. ### Method GET ### Endpoint /api/ip_addressing/mlag_l3_ip_secondary ### Response #### Success Response (200) - **ip_address** (string) - The calculated L3 peering IP address for the MLAG secondary peer. #### Response Example { "ip_address": "192.168.0.2" } ``` -------------------------------- ### Configure Custom Structured Configuration Prefixes Source: https://avd.arista.com/6.1/ansible_collections/arista/avd/roles/eos_designs/docs/how-to/custom-structured-configuration.html Demonstrates how to define custom prefixes for structured configuration variables. This allows users to inject or override configuration elements by prefixing variable names in their input files. ```yaml custom_structured_configuration_static_routes: - prefix: 42.42.42.0/24 vrf: MGMT next_hop: 42.42.42.42 custom_structured_configuration_ethernet_interfaces: - name: Ethernet4000 description: My test ip_address: 10.1.2.3/12 shutdown: false type: routed mtu: 1500 peer: MY-own-peer peer_interface: Ethernet123 peer_type: my_precious ``` -------------------------------- ### GET /api/ip_addressing/mlag_l3_ip_primary Source: https://avd.arista.com/6.1/docs/pyavd/pyavd.html Retrieves the primary L3 peering IP address for MLAG, using the mlag_peer_l3_ipv4_pool. ```APIDOC ## GET /api/ip_addressing/mlag_l3_ip_primary ### Description Returns the L3 peering IP address for the MLAG Primary node. ### Method GET ### Endpoint /api/ip_addressing/mlag_l3_ip_primary ### Response #### Success Response (200) - **ip_address** (string) - The calculated L3 peering IP address for the MLAG primary peer. #### Response Example { "ip_address": "192.168.0.1" } ``` -------------------------------- ### AVD Tenant VRF and SVI Configuration Source: https://avd.arista.com/6.1/ansible_collections/arista/avd/examples/cv-pathfinder/index.html This example configures tenants with VRFs and SVIs for network segmentation and testing. It specifies VRF names, VNI mappings, and SVI details including node assignments and IP addresses. ```yaml --- # WAN Tenants network services tenants: - name: WAN-EXAMPLE-TENANT mac_vrf_vni_base: 10000 vrfs: - name: BLUE vrf_vni: 100 svis: - id: 666 name: BLUE-TEST enabled: true nodes: - node: site1-border1 ip_address: 10.66.1.1/24 - node: site1-border2 ip_address: 10.66.11.1/24 - node: site2-leaf1 ip_address: 10.66.2.1/24 - node: site2-leaf2 ip_address: 10.66.22.1/24 - node: site3-wan1 ip_address: 10.66.3.1/24 - node: site4-border1 ip_address: 10.66.4.1/24 - node: site4-border2 ip_address: 10.66.44.1/24 - name: RED vrf_vni: 101 svis: - id: 42 name: RED-TEST enabled: true nodes: - node: site1-border1 ip_address: 10.42.1.1/24 - node: site1-border2 ip_address: 10.42.11.1/24 - node: site2-leaf1 ip_address: 10.42.2.1/24 - node: site2-leaf2 ip_address: 10.42.22.1/24 - node: site3-wan1 ip_address: 10.42.3.1/24 - node: site4-border1 ip_address: 10.42.4.1/24 - node: site4-border2 ip_address: 10.42.44.1/24 ``` -------------------------------- ### Define Ansible Galaxy Requirements Source: https://avd.arista.com/6.1/docs/user-manual/avd-aap.html Specifies the required Arista AVD collection version to be installed within the Execution Environment. ```yaml --- collections: - name: arista.avd version: 4.9.0 ``` -------------------------------- ### Define AVD Global Variables Source: https://avd.arista.com/6.1/ansible_collections/arista/avd/examples/cv-pathfinder/index.html Sets global AVD variables such as BGP installation behavior within the group_vars/all.yml file. ```yaml bgp_update_wait_install: false ``` -------------------------------- ### Generate Device Configs and Docs with pyavd Source: https://avd.arista.com/6.1/docs/porting-guides/6.x.x.html This Python script utilizes the pyavd library to generate network device configurations and Markdown documentation. It prepares output directories, generates a host inventory, validates input data, retrieves AVD facts, and then generates structured configurations, device configs, and documentation for each device. Dependencies include the pyavd library and a custom 'generate_inventory' module. ```Python from __future__ import annotations from pathlib import Path from typing import TYPE_CHECKING, Any from pyavd import ( get_avd_facts, get_device_config, get_device_doc, get_device_structured_config, validate_inputs, ) if TYPE_CHECKING: # Importing internal objects only for type hinting to improve script readability. from pyavd._eos_designs.eos_designs_facts.schema import EosDesignsFacts from pyavd.api.schemas import EOSConfig from pyavd.api.validation import ValidatedDataResult # 'generate_inventory' is a module which generates a test inventory. # This should be replaced with something that reads a proper inventory like the Ansible inventory. from generate_inventory import generate_hostvars def main() -> None: # Prepare output directories config_dir = Path(__file__).parent / "configs" config_dir.mkdir(exist_ok=True) [file.unlink() for file in config_dir.glob("*")] docs_dir = Path(__file__).parent / "docs" docs_dir.mkdir(exist_ok=True) [file.unlink() for file in docs_dir.glob("*")] inventory: dict[str, dict[str, Any]] = generate_hostvars(spine_count=2, l3leaf_count=2, l2leaf_count=2, vrf_count=2, per_vrf_svi_count=2) # Validating and get back the validated inputs with coerced types for device, hostvars in inventory.items(): validated_data_result: ValidatedDataResult = validate_inputs(inputs=hostvars) if validated_data_result.validated_data is None: msg: str = f"Validation of hostvars failed for {device}: {validated_data_result.validation_result.violations}" raise ValueError(msg) inventory[device] = validated_data_result.validated_data # Get AVD Facts # We may be using custom Python modules for IP addressing or Descriptions, so we need to pass the hostvars as well since they can be used there. avd_facts: dict[str, EosDesignsFacts] = get_avd_facts(all_inputs=inventory, all_hostvars=inventory) # Get Device Structured Configs for device, hostvars in inventory.items(): # We may be using custom Python modules for IP addressing or Descriptions, so we need to pass the hostvars as well since they can be used there. structured_config: EOSConfig = get_device_structured_config(hostname=device, inputs=hostvars, hostvars=hostvars, avd_facts=avd_facts) # Get Device Configs config: str = get_device_config(structured_config=structured_config) config_dir.joinpath(f"{device}.cfg").write_text(data=config) # Get Device Documentation documentation: str = get_device_doc(structured_config=structured_config) docs_dir.joinpath(f"{device}.md").write_text(data=documentation) print(".", end="", flush=True) print("") if __name__ == "__main__": main() ``` -------------------------------- ### GET /api/ip_addressing/mlag_ibgp_peering Source: https://avd.arista.com/6.1/docs/pyavd/pyavd.html Retrieves the IP addresses for MLAG iBGP peering for both primary and secondary nodes, supporting both IPv4 and IPv6. ```APIDOC ## GET /api/ip_addressing/mlag_ibgp_peering ### Description Retrieves the L3 peering IP address for MLAG configurations. ### Method GET ### Parameters #### Query Parameters - **mlag_ibgp_peering_pool** (string) - Required - The IP pool string. - **role** (string) - Required - 'primary' or 'secondary'. - **address_family** (string) - Optional - 'ipv4' or 'ipv6' (default: ipv4). ### Response #### Success Response (200) - **ip_address** (string) - The calculated peering IP address. ``` -------------------------------- ### Verify Transceivers Manufacturers Source: https://avd.arista.com/6.1/ansible_collections/arista/avd/roles/anta_runner/index.html Verifies that all installed transceivers are from approved manufacturers, as specified in the hardware requirements. This test ensures compatibility and reliability. ```yaml VerifyTransceiversManufacturers: metadata: hardware_requirements: transceiver_manufacturers: ["", ""] ``` -------------------------------- ### Method: underlay_ethernet_interface Source: https://avd.arista.com/6.1/docs/pyavd/pyavd.html Builds an underlay Ethernet interface description based on provided interface data and configured templates. ```APIDOC ## POST /api/interface/underlay ### Description Builds an underlay Ethernet interface description. If a Jinja template is configured, it will be used; otherwise, default Python logic is applied. ### Method POST ### Endpoint /api/interface/underlay ### Parameters #### Request Body - **data** (InterfaceDescriptionData) - Required - Object containing link_type, description, peer, peer_interface, mpls_overlay_role, mpls_lsr, overlay_routing_protocol, type, vrf, wan_carrier, wan_circuit_id, and main_interface_wan_carrier. ### Request Example { "data": { "link_type": "core_interface", "description": "CORE_LINK", "peer": "spine01", "peer_interface": "Ethernet1" } } ### Response #### Success Response (200) - **description** (string) - The rendered interface description string. #### Response Example { "description": "CORE_LINK" } ``` -------------------------------- ### GET /api/ip_addressing/evpn_underlay_l3_multicast_group Source: https://avd.arista.com/6.1/docs/pyavd/pyavd.html Retrieves the IPv4 address for an EVPN underlay L3 multicast group based on the provided pool and VRF identifiers. ```APIDOC ## GET /api/ip_addressing/evpn_underlay_l3_multicast_group ### Description Calculates and returns the IP address to be used for the EVPN underlay L3 multicast group. ### Method GET ### Parameters #### Query Parameters - **underlay_l3_multicast_group_ipv4_pool** (string) - Required - The IPv4 pool string. - **vrf_vni** (integer) - Required - The VRF VNI. - **vrf_id** (integer) - Required - The VRF ID. - **evpn_underlay_l3_multicast_group_ipv4_pool_offset** (integer) - Required - The offset value. ### Response #### Success Response (200) - **ip_address** (string) - The calculated IPv4 address. ``` -------------------------------- ### Configure DNS Servers using structured_config Source: https://avd.arista.com/6.1/docs/user-manual/ansible-usage-patterns.html Demonstrates how to define DNS server settings within the structured_config block in host_vars. This method nests configuration directly under the device definition. ```yaml l3leaf: nodes: - name: leaf1 structured_config: ip_name_server: vrfs: - name: MGMT servers: - ip_address: 10.20.20.10 - ip_address: 10.10.128.10 priority: 2 ``` -------------------------------- ### Build Router ID Loopback Interface Description (Python) Source: https://avd.arista.com/6.1/docs/pyavd/pyavd.html Creates a description for a router ID loopback interface. It prioritizes a configured Jinja template path; if none is found, it returns the provided description directly. Available data includes the description itself and overlay networking details. Dependencies include InterfaceDescriptionData and shared_utils. ```python def router_id_loopback_interface(self, data: InterfaceDescriptionData) -> str | None: """ Build Router ID loopback interface description. Available data: - description - mpls_overlay_role - mpls_lsr - overlay_routing_protocol - type. """ if template_path := self.shared_utils.node_type_key_data.interface_descriptions.router_id_loopback_interface: return self._template(template_path, router_id_loopback_description=data.description) return data.description ``` -------------------------------- ### Override Root Directory Path Source: https://avd.arista.com/6.1/ansible_collections/arista/avd/roles/eos_designs/docs/role-configuration.html Example of how to redirect the AVD output directory to a location outside of the inventory directory using a relative path. ```yaml root_dir: '{{ inventory_dir}}/../outputs' ``` -------------------------------- ### Configure AVD WAN Interfaces with YAML Source: https://avd.arista.com/6.1/ansible_collections/arista/avd/roles/eos_designs/docs/how-to/wan.html This YAML snippet demonstrates the configuration of WAN interfaces in AVD. It shows how to define WAN interfaces under `l3_interfaces` and `l3_port_channels` by setting the `wan_carrier` key. Optional parameters like `wan_circuit_id`, bandwidth, ACLs, and DHCP settings are also illustrated. It also shows a non-WAN interface for contrast. ```yaml wan_router: defaults: loopback_ipv4_pool: 192.168.42.0/24 vtep_loopback_ipv4_pool: 192.168.142.0/24 uplink_ipv4_pool: 172.17.0.0/16 bgp_as: 65000 cv_pathfinder_region: Region_1 cv_pathfinder_site: Site11 nodes: - name: cv-pathfinder-edge id: 1 uplink_switch_interfaces: [Ethernet1] l3_interfaces: # This is a WAN interface because `wan_carrier` is defined - name: Ethernet1 peer: peer3 peer_interface: Ethernet42 wan_carrier: ISP-1 wan_circuit_id: 666 ipv4_acl_in: TEST-IPV4-ACL-WITH-IP-FIELDS-IN ipv4_acl_out: TEST-IPV4-ACL-WITH-IP-FIELDS-OUT dhcp_accept_default_route: true receive_bandwidth: 10000 transmit_bandwidth: 1000 ip_address: dhcp dhcp_ip: 7.7.7.7 - name: Ethernet2 wan_carrier: MPLS-1 wan_circuit_id: 10555 ip_address: 172.15.5.5/31 peer_ip: 172.16.5.4 static_routes: - prefix: 172.16.0.0/16 connected_to_pathfinder: false # Configure BGP peering with peer bgp: peer_as: 65042 ipv4_prefix_list_in: ALLOW-DEFAULT # This is NOT a WAN interface - name: Ethernet3 ip_address: 172.20.20.20/31 l3_port_channels: # This is a WAN interface because `wan_carrier` is defined - name: Port-Channel1 mode: active peer: peer4 peer_interface: Port-Channel12 wan_carrier: ISP-3 ipv4_acl_in: TEST-IPV4-ACL-WITH-IP-FIELDS-IN ipv4_acl_out: TEST-IPV4-ACL-WITH-IP-FIELDS-OUT dhcp_accept_default_route: true ip_address: dhcp dhcp_ip: 42.42.42.42 member_interfaces: - name: Ethernet4 - name: Ethernet5 ipv4_prefix_list_catalog: - name: ALLOW-DEFAULT sequence_numbers: - sequence: 10 ```