Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: New anta_workflow plugin using PyAVD #4196

Draft
wants to merge 6 commits into
base: devel
Choose a base branch
from

Conversation

carl-baillargeon
Copy link
Contributor

@carl-baillargeon carl-baillargeon commented Jul 9, 2024

Change Summary

  • anta_workflow Ansible action plugin
  • get_device_anta_catalog public function in PyAVD to generate the ANTA catalogs
  • get_fabric_data public function in PyAVD to generate the fabric mappings used to generate the catalogs
  • Refactor existing eos_validate_state generated tests and copy them to PyAVD

Related Issue(s)

Needs:

Component(s) name

PyAVD

Proposed changes

Example playbook:

---
- name: ANTA Workflow
  hosts: GLOBAL
  tasks:
    - name: Run ANTA Workflow
      run_once: true
      delegate_to: localhost
      arista.avd.anta_workflow:
        # Takes precedence over the filters
        device_list: "{{ ansible_play_hosts }}"
          # - DC1-LEAF1A
          # - DC1-LEAF1B
        anta_catalogs:
            avd_catalog_dir: "{{ inventory_dir }}/intended/test_catalogs"
            structured_config_dir: "{{ inventory_dir }}/intended/structured_configs"
            structured_config_suffix: yml
            # Support inline jinja
            avd_catalog_filters:
              - device_list: "{{ groups['DC1'] }}"  # Also support `all` group
                run_tests:
                  - VerifyBGPSpecificPeers
                # Higher precedence than tests_to_run
                skip_tests:
                  - VerifyLLDPNeighbors
  
            user_catalog_dir: "{{ inventory_dir }}/custom_anta_catalogs"
        anta_logging:
            log_level: INFO
            log_file: "{{ inventory_dir }}/anta.log"
        anta_runner_settings:
            timeout: 30
            disable_cache: false
            tags: []
        report:
            test_results_dir: "{{ inventory_dir }}/reports/test_results"
            csv_output: "{{ inventory_dir }}/reports/anta_report.csv"
            md_output: "{{ inventory_dir }}/reports/anta_report.md"
            filters:
              hide_statuses:
                - success
                - error

To-do list

  • Add reporting using anta.reporter.csv_reporter and anta.reporter.md_reporter. We should also be able to filter statuses (from plugin arguments) using ResultManager.filter()
  • Input factory for VerifyAVTRole
  • Input factory for VerifyMlagStatus
  • Input factory for VerifyRoutingProtocolModel
  • Input factory for VerifyAPIHttpsSSL
  • Input factory for VerifySpecificIPSecConn
  • Input factory for VerifyStunClient
  • Input factory for VerifyNTP
  • Input factory for VerifyReloadCause
  • VerifyLLDP factory: Add support for validate_state: false configuration
  • VerifyReachability factory: Add WAN VTEPs support - DPS to DPS reachability
  • VerifyEnvironmentPower factory: accepted_pwr_supply_states is not yet implemented in the AVD structured config schema
  • VerifyEnvrionmentCooling factory: accepted_fan_states is not yet implemented in the AVD structured config schema
  • VerifyTransceiversManufacturers: accepted_xcvr_manufacturers is not yet implemented in the AVD structured config schema
  • Update FabricData to add DPS mappings (investigate if we can improve FabricData logic)
  • Create the Ansible role (anta_runner) that will run the action plugin anta_workflows - Similar to cv_deploy & cv_workflows
  • Create anta_workflow plugin documentation under plugins.modules
  • Create README.md for anta_runner role
  • VerifyBGPSpecificPeers factory: Add support for BGP VRFs (seperate PR after - see Feat(eos_validate_state): Add validation for BGP IPv4 peers in VRFs #4538)
  • Molecule tests (seperate PR maybe?)
  • Unit tests in PyAVD (seperate PR maybe?)

Some tests don't require any inputs, in that case we just update PYAVD_TEST_INDEX

Phase 2: Add all ANTA tests 🥇

Copy link

github-actions bot commented Jul 9, 2024

Review docs on Read the Docs

To test this pull request:

# Create virtual environment for this testing below the current directory
python -m venv test-avd-pr-4196
# Activate the virtual environment
source test-avd-pr-4196/bin/activate
# Install all requirements including PyAVD
pip install "pyavd[ansible] @ git+https://github.com/carl-baillargeon/avd.git@feat/move_anta_to_pyavd#subdirectory=python-avd" --force
# Install Ansible collection
ansible-galaxy collection install git+https://github.com/carl-baillargeon/avd.git#/ansible_collections/arista/avd/,feat/move_anta_to_pyavd --force
# Optional: Install AVD examples
cd test-avd-pr-4196
ansible-playbook arista.avd.install_examples

@gmuloc gmuloc added this to the v5.0.0 milestone Jul 25, 2024
@carl-baillargeon carl-baillargeon force-pushed the feat/move_anta_to_pyavd branch 2 times, most recently from 8853a02 to da57595 Compare August 13, 2024 18:18
@carl-baillargeon carl-baillargeon changed the title Feat: ANTA Integration to PyAVD Feat: New anta_workflow plugin and anta_runner role to Ansible AVD collection using PyAVD Aug 13, 2024
Copy link

sonarcloud bot commented Aug 17, 2024

@ClausHolbechArista ClausHolbechArista removed this from the v5.0.0 milestone Sep 20, 2024
@carl-baillargeon carl-baillargeon changed the title Feat: New anta_workflow plugin and anta_runner role to Ansible AVD collection using PyAVD Feat: New anta_workflow plugin using PyAVD Oct 31, 2024
Copy link

sonarcloud bot commented Nov 4, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants