aristanetworks / avd

Arista Validated Designs
https://avd.arista.com
Apache License 2.0
290 stars 209 forks source link

provide more consequence in data format #2707

Closed pibjndata closed 1 year ago

pibjndata commented 1 year ago

Enhancement summary

is it possible to deliver more consequence in data format that is required in YAML files, e.g.:

image

profile and descriptions are strings and does not require quotes ( "" ) to configure them - just string provided while mode requires quotes (for "on" mode) to do the correct configuration on CVP.

or - is it possible to stop requiring quotes for mode: "on" in port_channel settings (currently mode: on is read as boolean value True , so it generates error on CVP when the configuration is sent)

Which component of AVD is impacted

eos_cli_config_gen

Use case example

as in summary

Describe the solution you would like

as in summary

Describe alternatives you have considered

No response

Additional context

No response

Contributing Guide

gmuloc commented 1 year ago

Hello - in general you don't need quotes for strings in YAML.

For your specific example sadly this is due to YAML specification: https://yaml.org/type/bool.html as you can see on has a special meaning and is parsed as a boolean. (cf ansible documentation: https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_variables.html#boolean-variables) so in this scenario we cannot provide much more consistency.

So you have to put the quotes for this specific usecase. We are currently introducing schemas and so this behavior would be caught up by schema at validation time when generating the configs:

    - name: Ethernet4
      peer: DC1-LEAF1B
      peer_interface: Ethernet4
      peer_type: mlag_peer
      description: MLAG_PEER_DC1-LEAF1B_Ethernet4
      channel_group:
        id: 3
       mode: on
TASK [arista.avd.eos_cli_config_gen : Generate eos intended configuration] *****
task path: /Users/users/.cache/ansible-compat/d1e355/collections/ansible_collections/arista/avd/roles/eos_cli_config_gen/tasks/main.yml:37
ERROR! [port-channel-interfaces]: 'Validation Error: ethernet_interfaces[2].channel_group.mode': True is not of type 'str'
ERROR! [port-channel-interfaces]: 'Validation Error: ethernet_interfaces[2].channel_group.mode': 'True' is not one of ['on', 'active', 'passive']

Which would allow an early alert.

An option could be to replace the on option with a static-on option to get around this issue

pibjndata commented 1 year ago

ok, got it, thanks for explanation!