validate_inputs¶
Note
Always use the FQCN (Fully Qualified Collection Name) arista.avd.validate_inputs when using this plugin.
Validate variables against AVD schemas
Synopsis¶
The arista.avd.validate_inputs module is an Ansible Action Plugin designed to validate device variables against Arista AVD schemas.
The plugin performs two phases:
- Templating Phase: Resolves Ansible hostvars and writes the templated data as JSON files to the AVD temporary directory.
This phase is skipped if
input_diris provided, treating the input files as already templated. - Validation Phase: Validates the inputs against the specified AVD schema using
pyavd-utilsand writes the validated data as JSON files to the AVD temporary directory.
Parameters¶
| Argument | Type | Required | Default | Value Restrictions | Description |
|---|---|---|---|---|---|
| tmp_dir | str | True | None | - | Path to use as the AVD temporary directory for storing templated and validated data used internally by plugins. Must be the same across all plugins. |
| device_list | list | False | None | - | Optional list of hostnames to process. If not provided, fallback to all hosts in the current play. For eos_config and cv_deploy schemas, only these hosts will be validated.For avd_design, these hosts must be a subset of the fabric_name group and the entire group will be processed. |
| schema_name | str | optional | avd_design | Valid values: - avd_design- eos_config- cv_deploy |
The AVD schema to validate against. If set to avd_design, the plugin will validate the inputs for the entire fabric (requiring fabric_name to be set).If set to eos_config or cv_deploy, the plugin will validate the inputs for the devices in the device_list if provided, otherwise all hosts in the current play. |
| input_dir | str | False | None | - | Optional path to a directory containing input files to validate directly. If provided, the templating phase is skipped and files are read from this directory. Files must be named device_name.input_suffix. |
| input_suffix | str | optional | json | Valid values: - yml- yaml- json |
File suffix for files located in input_dir.Only used when input_dir is provided. |
| read_from_input_dir | bool | optional | False | - | If true, the templating phase is skipped and input files are read directly from input_dir.If false, the plugin resolves Ansible hostvars and writes templated data before validation.Requires input_dir to be set when true. |
| fail_on_missing_input_files | bool | optional | True | - | If true, the task will fail if any device input files are missing.If false, devices with missing input files will be skipped with an informational log message. |
| fail_on_validation_errors | bool | optional | False | - | If true, the task will fail if any validation errors are detected.If false, errors will be reported but the task will succeed. |
| batch_size | int | optional | 10 | - | The number of devices to process per child process during the templating phase. |
| validation_configuration | dict | False | None | - | Optional dictionary containing configuration options to control validation behavior. |
| warn_eos_config_keys | bool | optional | False | - | Enable warnings for EOS Config keys used in AVD Design input data. When enabled, warnings will be emitted during validation if any top-level keys from the EOS Config schema are found at the top level of AVD Design input data. |
| vault_id | str | False | None | - | Vault ID used for encrypting temporary files generated by the plugin. When Ansible Vault is not configured, this parameter has no effect and files are written as plain JSON. When Ansible Vault is configured, AVD encrypts files containing templated and validated data to prevent sensitive information from being exposed in the temporary directories. * When vault_id is not specified, AVD uses the first Vault ID in the list for encryption.* When vault_id is specified, AVD uses the specified Vault ID for encryption. |
Examples¶
---
- name: Validate eos_designs inputs for the fabric
arista.avd.validate_inputs:
tmp_dir: "intended/tmp_eos_designs"
schema_name: avd_design
fail_on_validation_errors: true
- name: Validate eos_designs inputs with custom validation configuration
arista.avd.validate_inputs:
tmp_dir: "intended/tmp_eos_designs"
schema_name: avd_design
fail_on_validation_errors: true
validation_configuration:
warn_eos_config_keys: true
- name: Validate eos_cli_config_gen inputs from structured config files
arista.avd.validate_inputs:
tmp_dir: "intended/tmp_eos_cli_config_gen"
schema_name: eos_config
input_dir: "{{ inventory_dir }}/intended/structured_configs"
input_suffix: "yml"
fail_on_validation_errors: false
- name: Validate inputs with specific vault identity (when multiple vault identities are configured)
arista.avd.validate_inputs:
tmp_dir: "intended/tmp_eos_designs"
schema_name: avd_design
vault_id: prod
fail_on_validation_errors: true
# This example assumes vault_identity_list is configured in ansible.cfg:
# [defaults]
# vault_identity_list = dev@.vault_dev, prod@.vault_prod
# The 'prod' vault identity will be used to encrypt temporary files.
- name: Validate cv_deploy inputs from structured config files
arista.avd.validate_inputs:
tmp_dir: "intended/tmp_cv_deploy"
schema_name: cv_deploy
input_dir: "{{ inventory_dir }}/intended/structured_configs"
input_suffix: "yml"
read_from_input_dir: true
fail_on_missing_input_files: false
fail_on_validation_errors: true
- name: Validate cv_deploy inputs from Ansible hostvars
arista.avd.validate_inputs:
tmp_dir: "intended/tmp_cv_deploy"
schema_name: cv_deploy
read_from_input_dir: false
fail_on_validation_errors: true
Authors¶
- Arista Ansible Team (@aristanetworks)