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(cv_deploy): Expose the details of the Workspace build validation errors #4629

Open
wants to merge 28 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c7c4a6a
Update NTP settings of CI EoS instances
alexeygorbunov Oct 23, 2024
d0345a6
Attempt to improve molecule report consistency
alexeygorbunov Oct 23, 2024
7601169
Enhance cv_deploy_results by covering details of config validation er…
alexeygorbunov Oct 23, 2024
842429f
Fix ansible-lint issues
alexeygorbunov Oct 23, 2024
abc6e3a
Merge branch 'devel' into cv_deploy_ci
alexeygorbunov Oct 23, 2024
a9043ed
Remove separate set_facts tasks
alexeygorbunov Oct 23, 2024
75c4de2
Add enhancements to ws details processing and exposing
alexeygorbunov Oct 29, 2024
9bc31a2
Merge branch 'devel' into cv_deploy_ci
alexeygorbunov Oct 29, 2024
5746041
+ Expose device details under build_details
alexeygorbunov Nov 4, 2024
7feca97
Merge branch 'devel' into cv_deploy_ci
ClausHolbechArista Nov 7, 2024
41cd149
Rollback proposed exposure of processing time for cv_deploy
alexeygorbunov Nov 18, 2024
ee5d70d
Add regex-based cv_deploy warning suppression
alexeygorbunov Nov 19, 2024
f21a0ca
Merge branch 'devel' into cv_deploy_ci
alexeygorbunov Nov 19, 2024
b990b06
Merge branch 'aristanetworks:devel' into cv_deploy_ci
alexeygorbunov Nov 22, 2024
d6bd744
Merge 'upstream/devel' into cv_deploy_ci
alexeygorbunov Dec 17, 2024
a77635a
fixing linting issues
alexeygorbunov Dec 17, 2024
a856cd0
Regenerate CloudVision API wrappers
alexeygorbunov Dec 18, 2024
a89b126
Address PR comments
alexeygorbunov Dec 18, 2024
fd1037b
Merge branch 'devel' into cv_deploy_ci
alexeygorbunov Dec 18, 2024
767312c
Merge branch 'devel' into cv_deploy_ci
alexeygorbunov Jan 2, 2025
f2395bd
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 2, 2025
0d9c4c9
Merge branch 'devel' into cv_deploy_ci
alexeygorbunov Jan 6, 2025
c09da96
PR comments - tag cv_deploy molecule play tasks for flexible scope co…
alexeygorbunov Jan 7, 2025
7dfca6b
PR comments - end-of-file-fixer for avd-ci-core1.cfg
alexeygorbunov Jan 7, 2025
7a46766
PR comments - Delete structure_config files containing only default s…
alexeygorbunov Jan 7, 2025
7cce419
PR Comments - normalize return of get_workspace_build_details func
alexeygorbunov Jan 8, 2025
e83e74f
Remove exsessive object type validation
alexeygorbunov Jan 8, 2025
be3b97c
Merge branch 'devel' into cv_deploy_ci
alexeygorbunov Jan 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ The `arista.avd.cv_workflow` module is an Ansible Action Plugin providing the fo
| <samp>&nbsp;&nbsp;&nbsp;&nbsp;id</samp> | str | optional | None | | Optional ID to use for the created Workspace. If there is already a workspace with the same ID, it must be in the &#39;pending&#39; state. |
| <samp>&nbsp;&nbsp;&nbsp;&nbsp;requested_state</samp> | str | optional | built | Valid values:<br>- <code>pending</code><br>- <code>built</code><br>- <code>submitted</code><br>- <code>abandoned</code><br>- <code>deleted</code> | The requested state for the Workspace.<br><br>- `pending`: Leave the Workspace in pending state.<br>- `built`: Build the Workspace but do not submit.<br>- `submitted` (default): Build and submit the Workspace.<br>- `abandoned`: Build and then abandon the Workspace.<br> Used for dry-run where no changes will be committed to CloudVision.<br>- `deleted`: Build, abort and then delete the Workspace.<br> Used for dry-run where no changes will be committed to CloudVision and the temporary Workspace will be removed to avoid &#34;clutter&#34;. |
| <samp>&nbsp;&nbsp;&nbsp;&nbsp;force</samp> | bool | optional | False | | Force submit the workspace even if some devices are not actively streaming to CloudVision. |
| <samp>&nbsp;&nbsp;&nbsp;&nbsp;build_warnings</samp> | bool | optional | True | | Fetch Workspace build warnings. |
| <samp>&nbsp;&nbsp;&nbsp;&nbsp;build_warnings_suppress_patterns</samp> | list | optional | [] | | List of the regex patterns. Matched EoS CLI warnings will be suppressed. |
| <samp>&nbsp;&nbsp;&nbsp;&nbsp;build_warnings_suppress_portfast</samp> | bool | optional | False | | Suppress Workspace build warnings related to the usage of the `portfast` feature on switchports. |
| <samp>change_control</samp> | dict | optional | None | | CloudVision Change Control to create for the deployment. |
| <samp>&nbsp;&nbsp;&nbsp;&nbsp;name</samp> | str | optional | None | | Optional name to use for the created Change Control. By default the name generated by CloudVision will be kept. |
| <samp>&nbsp;&nbsp;&nbsp;&nbsp;description</samp> | str | optional | None | | Optional description to use for the created Change Control. |
Expand Down Expand Up @@ -94,6 +97,9 @@ The `arista.avd.cv_workflow` module is an Ansible Action Plugin providing the fo
# id: <uuid or similar>
requested_state: submitted
force: True
# build_warnings: true
# build_warnings_suppress_patterns: []
# build_warnings_suppress_portfast: false
change_control:
# name:
# description:
Expand Down
46 changes: 27 additions & 19 deletions ansible_collections/arista/avd/molecule/cv_deploy/cc_false.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- name: Converge - cv_run_change_control = false
- name: "{{ test_id | upper }} Converge - cv_run_change_control = false"
hosts: SITE1_FABRIC
connection: local
gather_facts: false
Expand All @@ -12,46 +12,50 @@
structured_dir: "{{ playbook_dir }}/intended/structured_configs/test_configs"
intended_tag_device: avd-ci-leaf1
intended_tags: "{{ lookup('file', structured_dir ~ '/' ~ intended_tag_device ~ '.yml')| from_yaml }}"
test_id: "cc-false"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also add tags with this name on all the tasks related to this test? To make it easier to just run some of them?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added. See commit 'PR comments - tag cv_deploy molecule play tasks for flexible scope control'

cv_common_pattern: "avd-cv-deploy-{{ test_id }}"

tasks:
- name: Generate random string
ansible.builtin.set_fact:
r: "{{ lookup('password', '/dev/null chars=ascii_lowercase,digits length=4') }}"
- name: "{{ test_id | upper }} Banner"
run_once: true
ansible.builtin.debug:
msg:
- "######################################################################"
- "### STARTING MOLECULE TEST {{ '{:<38}'.format(test_id[:38]) | upper }} ####"
- "######################################################################"

- name: Set facts
ansible.builtin.set_fact:
cv_workspace_name: avd-cv-deploy-{{ r }}
cv_workspace_description: sample description
cv_change_control_name: cc_cv_deploy-{{ r }}
cv_change_control_description: sample description
cv_register_detailed_results: true
- name: "{{ test_id | upper }} Generate random string"
run_once: true
ansible.builtin.set_fact:
r: "{{ lookup('password', '/dev/null chars=ascii_lowercase,digits length=4') }}"

- name: Provision with cv_run_change_control = false
- name: "{{ test_id | upper }} Provision with cv_run_change_control = false"
run_once: true
delegate_to: localhost
ansible.builtin.import_role:
name: arista.avd.cv_deploy
vars:
cv_submit_workspace: true
cv_run_change_control: false
cv_workspace_name: "{{ cv_common_pattern }}-{{ r }}-converge"
cv_workspace_description: "{{ (cv_common_pattern + '-' + r + '-converge') | upper }}"
cv_change_control_name: "{{ cv_common_pattern }}-{{ r }}-converge"
cv_change_control_description: "{{ (cv_common_pattern + '-' + r + '-converge') | upper }}"
cv_register_detailed_results: true
cv_submit_workspace_force: true

- name: Display CVP result
- name: "{{ test_id | upper }} Display CVP result"
run_once: true
ansible.builtin.debug:
msg: '{{ cv_deploy_results }}'

- name: Check CVP returns
- name: "{{ test_id | upper }} Check CVP returns"
run_once: true
ansible.builtin.assert:
that:
# Change control
- cv_deploy_results.change_control.requested_state == "pending approval"
- cv_deploy_results.change_control.requested_state == cv_deploy_results.change_control.state

- name: Cleanup orphan CC
- name: "{{ test_id | upper }} Cleanup orphan CC"
run_once: true
ansible.legacy.uri:
url: https://{{ cv_server }}/api/resources/changecontrol/v1/ChangeControlConfig?key.id={{ cv_deploy_results.change_control.id }}
Expand All @@ -72,14 +76,18 @@
ignore_errors: True
when: cv_deploy_results.change_control.state | lower in ['pending approval', 'approved']

- name: Cleanup
- name: "{{ test_id | upper }} Cleanup"
run_once: true
delegate_to: localhost
ansible.builtin.import_role:
name: arista.avd.cv_deploy
vars:
cv_workspace_name: "{{ cv_common_pattern }}-{{ r }}-cleanup"
cv_workspace_description: "{{ cv_common_pattern + '-' + r + '-cleanup' | upper }}"
cv_change_control_name: "{{ cv_common_pattern }}-{{ r }}-cleanup"
cv_change_control_description: "{{ cv_common_pattern + '-' + r + '-cleanup' | upper }}"
cv_register_detailed_results: true
eos_config_dir: "{{ playbook_dir }}/intended/configs/base_configs"
structured_dir: "{{ playbook_dir }}/intended/structured_configs/base_configs"
cv_submit_workspace: true
cv_submit_workspace_force: true
cv_run_change_control: true
22 changes: 10 additions & 12 deletions ansible_collections/arista/avd/molecule/cv_deploy/cleanup.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- name: Cleanup - Configuration deployment with CVP
- name: "{{ test_id | upper }} Cleanup - Configuration deployment with CVP"
hosts: SITE1_FABRIC
connection: local
gather_facts: false
Expand All @@ -10,28 +10,26 @@
cv_skip_missing_devices: true
eos_config_dir: "{{ playbook_dir }}/intended/configs/base_configs"
structured_dir: "{{ playbook_dir }}/intended/structured_configs/base_configs"
test_id: "scenario-cleanup"
cv_common_pattern: "avd-cv-deploy-{{ test_id }}"

tasks:
- name: Generate random string
ansible.builtin.set_fact:
r: "{{ lookup('password', '/dev/null chars=ascii_lowercase,digits length=4') }}"
- name: "{{ test_id | upper }} Generate random string"
run_once: true

- name: Set facts
ansible.builtin.set_fact:
cv_workspace_name: avd-cv-deploy-cleanup-{{ r }}
cv_workspace_description: sample description
cv_change_control_name: cc_cv_deploy-cleanup-{{ r }}
cv_change_control_description: sample description
cv_register_detailed_results: true
run_once: true
r: "{{ lookup('password', '/dev/null chars=ascii_lowercase,digits length=4') }}"

- name: Cleanup
run_once: true
delegate_to: localhost
ansible.builtin.import_role:
name: arista.avd.cv_deploy
vars:
cv_workspace_name: "{{ cv_common_pattern }}-{{ r }}-cleanup"
cv_workspace_description: "{{ cv_common_pattern + '-' + r + '-cleanup' | upper }}"
cv_change_control_name: "{{ cv_common_pattern }}-{{ r }}-cleanup"
cv_change_control_description: "{{ cv_common_pattern + '-' + r + '-cleanup' | upper }}"
cv_register_detailed_results: true
cv_submit_workspace: true
cv_submit_workspace_force: true
cv_run_change_control: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@
- name: Test Workspace Force False
import_playbook: workspace_force_false.yml

- name: Test Workspace build with invalid Designed Config
import_playbook: invalid_config.yml

- name: Test Change Control False
import_playbook: cc_false.yml
71 changes: 41 additions & 30 deletions ansible_collections/arista/avd/molecule/cv_deploy/cv_deploy.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- name: Converge - Configuration deployment with CVP
- name: "{{ test_id | upper }} Converge - Configuration deployment with CVP"
hosts: SITE1_FABRIC
connection: local
gather_facts: false
Expand All @@ -12,48 +12,50 @@
structured_dir: "{{ playbook_dir }}/intended/structured_configs/test_configs"
intended_tag_device: avd-ci-leaf1
intended_tags: "{{ lookup('file', structured_dir ~ '/' ~ intended_tag_device ~ '.yml')| from_yaml }}"
test_id: "cv-deploy"
cv_common_pattern: "avd-cv-deploy-{{ test_id }}"

tasks:
- name: Generate random string
ansible.builtin.set_fact:
r: "{{ lookup('password', '/dev/null chars=ascii_lowercase,digits length=4') }}"
- name: "{{ test_id | upper }} Banner"
run_once: true
ansible.builtin.debug:
msg:
- "######################################################################"
- "### STARTING MOLECULE TEST {{ '{:<38}'.format(test_id[:38]) | upper }} ####"
- "######################################################################"

- name: Set facts
ansible.builtin.set_fact:
cv_workspace_name: avd-cv-deploy-{{ r }}
cv_workspace_description: sample description
cv_change_control_name: cc_cv_deploy-{{ r }}
cv_change_control_description: sample description
cv_register_detailed_results: true
- name: "{{ test_id | upper }} Generate random string"
run_once: true
ansible.builtin.set_fact:
r: "{{ lookup('password', '/dev/null chars=ascii_lowercase,digits length=4') }}"

###########################
######## cv_deploy ########
###########################
- name: Provision CVP with AVD configuration
- name: "{{ test_id | upper }} Provision CVP with AVD configuration"
run_once: true
delegate_to: localhost
ansible.builtin.import_role:
name: arista.avd.cv_deploy
vars:
cv_submit_workspace: true
cv_workspace_name: "{{ cv_common_pattern }}-{{ r }}-converge"
cv_workspace_description: "{{ (cv_common_pattern + '-' + r + '-converge') | upper }}"
cv_change_control_name: "{{ cv_common_pattern }}-{{ r }}-converge"
cv_change_control_description: "{{ (cv_common_pattern + '-' + r + '-converge') | upper }}"
cv_register_detailed_results: true
cv_submit_workspace_force: true
cv_run_change_control: true
cv_register_detailed_results: true

- name: Display CVP result
- name: "{{ test_id | upper }} Display CVP result"
run_once: true
ansible.builtin.debug:
msg: '{{ cv_deploy_results }}'

- name: Check CVP returns
- name: "{{ test_id | upper }} Check CVP returns"
run_once: true
ansible.builtin.assert:
that:
# workspace
- cv_deploy_results.workspace.name == cv_workspace_name
- cv_deploy_results.workspace.state == "submitted"
- cv_deploy_results.workspace.description == cv_workspace_description
- cv_deploy_results.workspace.state
# errors and warnings
- cv_deploy_results.errors == []
Expand All @@ -65,78 +67,87 @@
- cv_deploy_results.change_control.name == cv_change_control_name
- cv_deploy_results.change_control.requested_state == "completed"
- cv_deploy_results.change_control.description == cv_change_control_description
vars:
cv_workspace_name: "{{ cv_common_pattern }}-{{ r }}-converge"
cv_workspace_description: "{{ (cv_common_pattern + '-' + r + '-converge') | upper }}"
cv_change_control_name: "{{ cv_common_pattern }}-{{ r }}-converge"
cv_change_control_description: "{{ (cv_common_pattern + '-' + r + '-converge') | upper }}"

- name: Check tags from output
- name: "{{ test_id | upper }} Check tags from output"
run_once: true
ansible.builtin.assert:
that:
- item.0.label == item.1.label
- item.0.value == item.1.value
loop: "{{ cv_deploy_results.deployed_device_tags | zip(cv_deploy_results.device_tags) | list }}"

- name: Extract all device tags from structured configs
- name: "{{ test_id | upper }} Extract all device tags from structured configs"
run_once: true
ansible.builtin.set_fact:
expected_device_tags: "{{ intended_tags.metadata.cv_tags.device_tags }}"
output_device_tags: "{{ cv_deploy_results.deployed_device_tags }}"

- name: Check output device tags == intended device tags
- name: "{{ test_id | upper }} Check output device tags == intended device tags"
run_once: true
ansible.builtin.assert:
that:
- item.0.name == item.1.label
- item.0.value == item.1.value
loop: "{{ expected_device_tags | zip(output_device_tags) | list }}"

- name: Extract all interface tags from role output
- name: "{{ test_id | upper }} Extract all interface tags from role output"
run_once: true
ansible.builtin.set_fact:
output_interface_tags: "{{ cv_deploy_results.deployed_interface_tags }}"

- name: Extract all interface tags from structured configs
- name: "{{ test_id | upper }} Extract all interface tags from structured configs"
run_once: true
ansible.builtin.set_fact:
expected_interface_tags: "{{ expected_interface_tags | default([]) + [item.tags | list | first | combine({'interface': item.interface})] }}"
loop: "{{ intended_tags.metadata.cv_tags.interface_tags }}"
loop_control:
label: "{{ item.interface }}"

- name: Check output interface tags == intended interface tags
- name: "{{ test_id | upper }} Check output interface tags == intended interface tags"
run_once: true
ansible.builtin.assert:
that:
- item.0.name == item.1.label
- item.0.value == item.1.value
loop: "{{ expected_interface_tags | zip(output_interface_tags) | list }}"

- name: Convert unstructed data into yaml
- name: "{{ test_id | upper }} Convert unstructed data into yaml"
run_once: true
ansible.builtin.set_fact:
deivces_structure: '{{ cv_deploy_results.deployed_configs | from_yaml }}'
output_devices: []

- name: Extract devices from output
- name: "{{ test_id | upper }} Extract devices from output"
run_once: true
ansible.builtin.set_fact:
output_devices: "{{ output_devices + [item.device.hostname] }}"
loop: "{{ deivces_structure }}"
loop_control:
label: "{{ item.configlet_name }}"

- name: Check output devices == intended devices
- name: "{{ test_id | upper }} Check output devices == intended devices"
run_once: true
ansible.builtin.assert:
that:
- output_devices == cv_devices

- name: Cleanup
- name: "{{ test_id | upper }} Cleanup"
run_once: true
delegate_to: localhost
ansible.builtin.import_role:
name: arista.avd.cv_deploy
vars:
cv_workspace_name: "{{ cv_common_pattern }}-{{ r }}-cleanup"
cv_workspace_description: "{{ cv_common_pattern + '-' + r + '-cleanup' | upper }}"
cv_change_control_name: "{{ cv_common_pattern }}-{{ r }}-cleanup"
cv_change_control_description: "{{ cv_common_pattern + '-' + r + '-cleanup' | upper }}"
cv_register_detailed_results: true
eos_config_dir: "{{ playbook_dir }}/intended/configs/base_configs"
structured_dir: "{{ playbook_dir }}/intended/structured_configs/base_configs"
cv_submit_workspace: true
cv_submit_workspace_force: true
cv_run_change_control: true
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@ no ip routing vrf MGMT
!
ip route vrf MGMT 0.0.0.0/0 10.90.231.1
!
ntp server 1.pool.ntp.org iburst local-interface Management1
ntp server vrf MGMT 1.pool.ntp.org iburst local-interface Management1
!
end
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ service routing protocols model multi-agent
hostname avd-ci-leaf1
ip name-server vrf MGMT 10.90.231.26
!
ntp server 1.pool.ntp.org iburst local-interface Management1
ntp server vrf MGMT 1.pool.ntp.org iburst local-interface Management1
!
spanning-tree mode mstp
no spanning-tree vlan-id 4093-4094
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ service routing protocols model multi-agent
hostname avd-ci-leaf2
ip name-server vrf MGMT 10.90.231.26
!
ntp server 1.pool.ntp.org iburst local-interface Management1
ntp server vrf MGMT 1.pool.ntp.org iburst local-interface Management1
!
spanning-tree mode mstp
no spanning-tree vlan-id 4093-4094
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ service routing protocols model multi-agent
hostname avd-ci-leaf3
ip name-server vrf MGMT 10.90.231.26
!
ntp server 1.pool.ntp.org iburst local-interface Management1
ntp server vrf MGMT 1.pool.ntp.org iburst local-interface Management1
!
spanning-tree mode mstp
no spanning-tree vlan-id 4093-4094
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ service routing protocols model multi-agent
hostname avd-ci-leaf4
ip name-server vrf MGMT 10.90.231.26
!
ntp server 1.pool.ntp.org iburst local-interface Management1
ntp server vrf MGMT 1.pool.ntp.org iburst local-interface Management1
!
spanning-tree mode mstp
no spanning-tree vlan-id 4093-4094
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ service routing protocols model multi-agent
hostname avd-ci-spine1
ip name-server vrf MGMT 10.90.231.26
!
ntp server 1.pool.ntp.org iburst local-interface Management1
ntp server vrf MGMT 1.pool.ntp.org iburst local-interface Management1
!
spanning-tree mode none
!
Expand Down
Loading
Loading