Skip to content

validate_and_template

Note

Always use the FQCN (Fully Qualified Collection Name) arista.avd.validate_and_template when using this plugin.

This plugin is deprecated

This module will be removed in version 5.0.0.

Validate input data according to Schema, render Jinja2 template and write result to a file.

Synopsis

The arista.avd.validate_and_template Action Plugin performs data conversions and validation according to the supplied Schema.

The converted data is then used to render a Jinja2 template and writing the result to a file.

The Action Plugin supports different modes for conversion and validation, to either block the playbook or just warn the user if the input data is not valid.

For Markdown files the plugin can also run md_toc on the output before writing to the file.

Parameters

Argument Type Required Default Value Restrictions Description
template str True None Path to Jinja2 Template file
dest str True None Destination path. The rendered template will be written to this file
mode str False None File mode for dest file.
schema dict False None Schema conforming to "AVD Meta Schema". Either schema or schema_id must be set.
schema_id str False None Valid values:
- eos_cli_config_gen
- eos_designs
ID of Schema conforming to "AVD Meta Schema". Either schema or schema_id must be set.
add_md_toc bool False None Run md_toc on the output before writing to the file.
md_toc_skip_lines int False 0 Pass this value as skip_lines to add_md_toc.
conversion_mode str False debug Valid values:
- warning
- info
- debug
- quiet
- disabled
Run data conversion in either "warning", "info", "debug", "quiet" or "disabled" mode.
Conversion will perform type conversion of input variables as defined in the schema.
Conversion is intended to help the user to identify minor issues with the input data, while still allowing the data to be validated.
During conversion, messages will generated with information about the host(s) and key(s) which required conversion.
conversion_mode:disabled means that conversion will not run.
conversion_mode:error will produce error messages and fail the task.
conversion_mode:warning will produce warning messages.
conversion_mode:info will produce regular log messages.
conversion_mode:debug will produce hidden messages viewable with -v.
conversion_mode:quiet will not produce any messages.
validation_mode str False warning Valid values:
- error
- warning
- info
- debug
- disabled
Run validation in either "error", "warning", "info", "debug" or "disabled" mode.
Validation will validate the input variables according to the schema.
During validation, messages will generated with information about the host(s) and key(s) which failed validation.
validation_mode:disabled means that validation will not run.
validation_mode:error will produce error messages and fail the task.
validation_mode:warning will produce warning messages.
validation_mode:info will produce regular log messages.
validation_mode:debug will produce hidden messages viewable with -v.
cprofile_file str False None Filename for storing cprofile data used to debug performance issues.
Running cprofile will slow down performance in itself, so only set this while troubleshooting.

Examples

- name: Generate device documentation
  tags: [build, provision, documentation]
  arista.avd.validate_and_template:
    template: "eos-device-documentation.j2"
    dest: "{{ devices_dir }}/{{ inventory_hostname }}.md"
    mode: 0664
    schema: "{{ lookup('ansible.builtin.file', role_schema_path) | from_yaml }}"
    conversion_mode: "{{ avd_data_conversion_mode }}"
    validation_mode: "{{ avd_data_validation_mode }}"
    add_md_toc: true
    md_toc_skip_lines: 3
  delegate_to: localhost
  when: generate_device_documentation | arista.avd.default(true)

Authors

  • Arista Ansible Team (@aristanetworks)