aristanetworks / ansible-cvp

Ansible modules for Arista CloudVision
http://cvp.avd.sh
Apache License 2.0
66 stars 61 forks source link

Feat(cv_device_v3): add configlet validation support #552

Closed noredistribution closed 1 year ago

noredistribution commented 1 year ago

Enhancement summary

The use case is to validate configlets before/after task creation and listing the errors & warnings through the same Ansible playbook

Which component of AVD is impacted

cv_device_v3

Use case example

Running a playbook like this

---
- name: Device Image Management in Cloudvision
  hosts: cv_server
  connection: local
  gather_facts: false
  vars:
    CVP_DEVICES:
      - serialNumber: BAD032986065E8DC14CBB6472EC314A6
        fqdn: tp-avd-leaf1
        hostname: tp-avd-leaf1
        parentContainerName: TP_LEAF1
        configlets: #[]
         - net10
  tasks:
  - name: Validate configurations
    arista.cvp.cv_device_v3:
      devices: "{{CVP_DEVICES}}"
      state: validate
    register: CVP_DEVICES_RESULTS

where net10 configlet contains:

interface Ethernet10
  description test
!

ruter bgp 1111
  neighbor 1.1.1.1 remote-bs 10

would result in something like:

            "errorCount": 2,
            "errors": [
                {
                    "error": "> ruter bgp 1111% Invalid input (at token 0: 'ruter') at line 4",
                    "lineNo": " 4"
                },
                {
                    "error": ">   neighbor 1.1.1.1 remote-bs 10% Invalid input (at token 0: 'neighbor') at line 5",
                    "lineNo": " 5"
                }
            ],
            "warningCount": 1,
            "warnings": [
                "! Interface does not exist. The configuration will not take effect until the module is inserted. at line 1\\n\\n\\n\\n"
            ]

Describe the solution you'd like

leverage existing validate_config_for_device and validate_configlets_for_device functions from cvprac

Describe alternatives you've considered

No response

Additional context

No response

Code of Conduct

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 15 days