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(eos_validate_state): Add ANTA integration to eos_validate_state role #3171

Merged
merged 42 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
cd40f50
Feat: action plugin ANTA
gmuloc Sep 25, 2023
960e6f8
Test: Make Sanity check pass
gmuloc Sep 26, 2023
3e7b3f8
Doc: WIP - modifying plugin doc templates
gmuloc Sep 26, 2023
0a76fd3
initial preview-anta documentation
carlbuchmann Sep 27, 2023
c6484e3
+ limitations in readme
carlbuchmann Sep 27, 2023
4091116
Test: Add missing root_dir
gmuloc Sep 27, 2023
41f9802
CI: Tshoot
gmuloc Sep 27, 2023
58c3b93
Test: Fix tags in molecule
gmuloc Sep 27, 2023
5ae489f
Fix: Previous tasks modification prevented to generate legacy reports
gmuloc Sep 27, 2023
874fa50
Refactor: Add support for 2.12 ansible
gmuloc Sep 27, 2023
151476e
Refactor: The idempotency was not strong in this one
gmuloc Sep 27, 2023
cf832f7
bump: Bump anta to 0.9.0
gmuloc Sep 28, 2023
13ee4b1
update documentation after review
carlbuchmann Sep 28, 2023
600e844
pin anta version to 0.9.0
carlbuchmann Sep 28, 2023
5563c0b
Refactor: Change skipped_tests structure
gmuloc Sep 28, 2023
aeb0cf7
Refactor: Address PR comments and fix tags issue in molecule
gmuloc Sep 28, 2023
71ff61b
CI: O yamllint I know thee name
gmuloc Sep 28, 2023
b4d7eb7
fix: Update connectiviy tests logging and error handling
carl-baillargeon Sep 26, 2023
8cbf4bd
fix: Update tests logging and error handling
carl-baillargeon Sep 26, 2023
d68901a
fix: Make ansible-test sanity happy
carl-baillargeon Sep 27, 2023
c6589ad
fix: change log level for certain tests
carl-baillargeon Sep 27, 2023
c05cdd6
Refactor: Address PR comments
gmuloc Sep 29, 2023
f09a42f
Fix: Add back wrongly deleted default
gmuloc Sep 29, 2023
63d3c1b
Doc: Remove anta tags mentions
gmuloc Sep 29, 2023
878239d
Fix: More fixing the blunders (and a bit of doc)
gmuloc Sep 29, 2023
869663f
Doc: Wording remove legacy
gmuloc Sep 29, 2023
1b0665b
update doc based on review
carlbuchmann Sep 29, 2023
edf428a
Fix: Missing always on some task
gmuloc Sep 29, 2023
9df0ced
fix: ansible_tests.yml
carl-baillargeon Sep 27, 2023
378ee3c
Fix: Argument spec is BROKEN
gmuloc Sep 29, 2023
e7461b8
Apply doc suggestions from code review
carlbuchmann Sep 29, 2023
cdf86f3
Fix: Correct expression for bool check
gmuloc Sep 29, 2023
075320e
Doc: Address PR comments
gmuloc Sep 29, 2023
698b9fa
CI: Make pre-commit great again
gmuloc Sep 29, 2023
7d73d82
Doc: Make ansible sane again
gmuloc Sep 29, 2023
1b2f079
fix: logging and exceptions handling
carl-baillargeon Sep 27, 2023
1e576d1
feat: Added strict_mode and update exceptions
carl-baillargeon Sep 28, 2023
aced63b
fix: Fix doc
carl-baillargeon Sep 28, 2023
e7f34ff
fix: rollback strict-mode
carl-baillargeon Sep 30, 2023
766981d
CI: Fix github workflow for eos_validate_state
gmuloc Oct 2, 2023
7efce44
CI: Fix workflow
gmuloc Oct 2, 2023
5a2f509
Doc: Remove excalidraw
gmuloc Oct 2, 2023
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
45 changes: 45 additions & 0 deletions .github/workflows/pull-request-management.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ jobs:
- '.github/workflows/pull-request-management.yml'
- 'ansible_collections/arista/avd/molecule/eos_cli_config_gen*/*'
- 'ansible_collections/arista/avd/molecule/eos_cli_config_gen*/**/*'
validate_state:
- 'ansible_collections/arista/avd/roles/eos_validate_state/*'
- 'ansible_collections/arista/avd/roles/eos_validate_state/**/*'
cloudvision:
- 'ansible_collections/arista/avd/roles/eos_config_deploy_cvp/*'
- 'ansible_collections/arista/avd/roles/eos_config_deploy_cvp/**/*'
Expand Down Expand Up @@ -327,6 +330,48 @@ jobs:
# with:
# name: molecule-${{ matrix.avd_scenario }}-artifacts
# path: ${PWD}/ansible_collections/arista/avd/molecule/${{ matrix.avd_scenario }}
#
# ----------------------------------- #
# EOS Validate State MOLECULE
# ----------------------------------- #
molecule_eos_validate_state:
name: Validate eos_validate_state
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
avd_scenario:
- 'eos_validate_state'
ansible_version:
- 'ansible-core<2.16.0 --upgrade'
include:
- avd_scenario: 'eos_validate_state'
ansible_version: 'ansible-core==2.12.6'
galaxy_server: 'https://old-galaxy.ansible.com'
needs: [ pre_commit ]
if: needs.file-changes.outputs.eos_design == 'true' || needs.file-changes.outputs.validate_state == 'true'
steps:
- name: 'Set environment variables'
run: |
echo "PY_COLORS=1" >> $GITHUB_ENV
echo "ANSIBLE_FORCE_COLOR=1" >> $GITHUB_ENV
- name: 'Set galaxy server'
if: ${{ matrix.galaxy_server }}
run: |
echo "ANSIBLE_GALAXY_SERVER=${{ matrix.galaxy_server }}" >> $GITHUB_ENV
- uses: actions/checkout@v3
- name: Run molecule action
uses: arista-netdevops-community/[email protected]
with:
molecule_parentdir: 'ansible_collections/arista/avd'
molecule_command: 'test'
molecule_args: '--scenario-name ${{ matrix.avd_scenario }}'
pip_file: ansible_collections/arista/avd/requirements.txt
galaxy_file: "ansible_collections/arista/avd/collections.yml"
ansible: ${{ matrix.ansible_version }}
check_git: true
check_git_enforced: true

# ----------------------------------- #
# Ansible tests
# ----------------------------------- #
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ tasks:
| ---- | ---- | ----------- |
| _value | string | Markdown with TOC inserted between the toc\_markers. |

## Status

## Authors

- Arista Ansible Team (@aristanetworks)
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ Note \- if there is a non\-dictionary value with no secondary key provided, it w
| ---- | ---- | ----------- |
| _value | any | Returns list of dictionaries or input variable untouched if not a nested dictionary/list. |

## Status

## Authors

- Arista Ansible Team (@aristanetworks)
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ Only for internal use.
| ---- | ---- | ----------- |
| _value | any | Schema of the requested type. |

## Status

## Authors

- Arista Ansible Team (@aristanetworks)
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ cleartext: "{{ encrypted_password | arista.avd.decrypt(passwd_type='ospf_message
| ---- | ---- | ----------- |
| _value | string | Decrypted cleartext password. |

## Status

## Authors

- Arista Ansible Team (@aristanetworks)
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ myvalue: "{{ variable | arista.avd.default(default_value_1, default_value_2) }}"
| ---- | ---- | ----------- |
| _value | any | Input value if <code>not undefined</code> and <code>not None</code>. Otherwise, return the first defined default value or <code>None</code>. |

## Status

## Authors

- Arista Ansible Team (@aristanetworks)
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ ethernet_interfaces:
| ---- | ---- | ----------- |
| _value | string | Encrypted EOS password string. |

## Status

## Authors

- Arista Ansible Team (@aristanetworks)
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ esi: "{{ short_esi | arista.avd.generate_esi('deaf:beed:') }}"
| ---- | ---- | ----------- |
| _value | string | Concatenated string of <em>esi\_prefix</em> and <em>short\_esi</em> like <code>0000\:0000\:0303\:0202\:0101</code> |

## Status

## Authors

- Arista Ansible Team (@aristanetworks)
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ lacp_id: "{{ short_esi | arista.avd.generate_lacp_id }}"
| ---- | ---- | ----------- |
| _value | string | String based on LACP ID format like 0303.0202.0101 |

## Status

## Authors

- Arista Ansible Team (@aristanetworks)
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ rt: "{{ short_esi | arista.avd.generate_route_target }}"
| ---- | ---- | ----------- |
| _value | string | String based on route\-target format like 03\:03\:02\:02\:01\:01 |

## Status

## Authors

- Arista Ansible Team (@aristanetworks)
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ cli_with_hidden_password: "ip ospf authentication-key 7 {{ vlan_interface.ospf_a
| ---- | ---- | ----------- |
| _value | string | The original input or \'\<removed\>\' |

## Status

## Authors

- Arista Ansible Team (@aristanetworks)
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ not_found_1: "{{ 'myhostname' | arista.avd.is_in_filter(['myhost1', 'MYhostname'
| ---- | ---- | ----------- |
| _value | boolean | <code>True</code> if the input hostname matches the <em>hostname\_filter</em>. Otherwise <code>False</code> |

## Status

## Authors

- Arista Ansible Team (@aristanetworks)
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ list2: "{{ [1,2,3,7,8] | arista.avd.list_compress }}" # -> "1-3,7-8"
| ---- | ---- | ----------- |
| _value | string | Range string like \"1\-3,7\-8\" |

## Status

## Authors

- Arista Ansible Team (@aristanetworks)
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ empty_list_2: "{{ some_undefined_var | natural_sort }}" # -> []
| ---- | ---- | ----------- |
| _value | list | Sorted list if the input was a list. Sorted keys if the input was a dictionary. Empty list if the input value was <code>None</code> or <code>undefined</code>. |

## Status

## Authors

- Arista Ansible Team (@aristanetworks)
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ Within a single range, prefixes \(ex. Ethernet, Eth, Po\) are carried over to it
| ---- | ---- | ----------- |
| _value | list | List of strings from all ranges. |

## Status

## Authors

- Arista Ansible Team (@aristanetworks)
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,17 @@ Key localization as described in [RFC 2574 section 2.6](https://www.rfc-editor.o
| Argument | Type | Required | Default | Value Restrictions | Description |
| -------- | ---- | -------- | ------- | ------------------ | ----------- |
| _input | dictionary | True | None | | Dictionary with SNMP passphrase details. |
| passphrase | string | True | None | | The passphrase to localize.<br>This is the \"auth\" passphrase when the <em>priv</em> argument is not set.<br>If <em>priv</em> is set, it is the \"priv\" passphrase. |
| auth | string | True | None | Valid values:<br>- <code>md5</code><br>- <code>sha</code><br>- <code>sha224</code><br>- <code>sha256</code><br>- <code>sha384</code><br>- <code>sha512</code> | Auth type |
| engine_id | string | True | None | | A hexadecimal string containing the engine\_id to be used to localize the passphrase |
| priv | string | optional | None | Valid values:<br>- <code>des</code><br>- <code>aes</code><br>- <code>aes192</code><br>- <code>aes256</code> | Priv type |
| passphrase | string | True | None | | The passphrase to localize.<br>This is the \"auth\" passphrase when the <em>priv</em> argument is not set.<br>If <em>priv</em> is set, it is the \"priv\" passphrase. |
| auth | string | True | None | Valid values:<br>- <code>md5</code><br>- <code>sha</code><br>- <code>sha224</code><br>- <code>sha256</code><br>- <code>sha384</code><br>- <code>sha512</code> | Auth type |
| engine_id | string | True | None | | A hexadecimal string containing the engine\_id to be used to localize the passphrase |
| priv | string | optional | None | Valid values:<br>- <code>des</code><br>- <code>aes</code><br>- <code>aes192</code><br>- <code>aes256</code> | Priv type |

## Return Values

| Name | Type | Description |
| ---- | ---- | ----------- |
| _value | string | The localized key generated from the passphrase using <em>auth</em> type.<br>If required the key is truncated to match the appropriate keylength for the <em>priv</em> type. |

## Status

## Authors

- Arista Ansible Team (@aristanetworks)
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ Returns <code>\:white\_check\_mark\:</code> if input status string is <code>PASS
| ---- | ---- | ----------- |
| _value | string | Input value or GitHub Markdown emoji code. |

## Status

## Authors

- Arista Ansible Team (@aristanetworks)
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ Destination file mode is hardcoded to 0o664.
documentation_schema: "{{ role_name | arista.avd.convert_schema(type='documentation') }}"
```

## Status

## Authors

- Arista Ansible Team (@aristanetworks)
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ Build configuration to publish configlets to Cloudvision.
configlet_extension: 'cfg'
```

## Status

## Authors

- EMEA AS Team (@aristanetworks)
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ The module is used in \`arista.avd.eos\_designs\` to set facts for devices, whic
changed_when: false
```

## Status

## Authors

- Arista Ansible Team (@aristanetworks)
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ The \`arista.avd.eos\_designs\_facts\` module is an Ansible Action Plugin provid
| Argument | Type | Required | Default | Value Restrictions | Description |
| -------- | ---- | -------- | ------- | ------------------ | ----------- |
| eos_designs_custom_templates | list | False | None | | List of dicts for Jinja2 templates to be run after generating the structured configuration |
| template | str | True | None | | Template file.
| template | str | True | None | | Template file.
|
| options | dict | False | None | | Template options |
| list_merge | str | False | append | | Merge strategy for lists |
| strip_empty_keys | bool | False | True | | Filter out keys from the generated output if value is null/none/undefined<br>Only applies to templates. |
| options | dict | False | None | | Template options |
| list_merge | str | False | append | | Merge strategy for lists |
| strip_empty_keys | bool | False | True | | Filter out keys from the generated output if value is null/none/undefined<br>Only applies to templates. |
| dest | str | False | None | | Destination path. If set, the output facts will also be written to this path.<br>Autodetects data format based on file suffix. \'.yml\', \'.yaml\' \-\> YAML, default \-\> JSON |
| mode | str | False | None | | File mode \(ex. 0664\) for dest file. See \'ansible.builtin.copy\' module for details. |
| template_output | bool | False | None | | If true, the output data will be run through another jinja2 rendering before returning.<br>This is to resolve any input values with inline jinja using variables/facts set by the input templates. |
Expand All @@ -55,8 +55,6 @@ The \`arista.avd.eos\_designs\_facts\` module is an Ansible Action Plugin provid
changed_when: False
```

## Status

## Authors

- Arista Ansible Team (@aristanetworks)
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<!--
~ Copyright (c) 2023 Arista Networks, Inc.
~ Use of this source code is governed by the Apache License 2.0
~ that can be found in the LICENSE file.
-->

# eos_validate_state_runner

!!! note
Always use the FQCN (Fully Qualified Collection Name) `arista.avd.eos_validate_state_runner` when using this plugin.

!!! warning "This module is in **preview** mode"
This module is not guaranteed to have a backwards compatible interface.

Leverage ANTA for eos\_validate\_state role
carlbuchmann marked this conversation as resolved.
Show resolved Hide resolved

## Synopsis

The <code>arista.avd.eos\_validate\_state\_runner</code> module is an Ansible Action Plugin leveraging the ANTA test framework to validate that the generated structured configurations by AVD are applied to the devices and that the deployed network is working correctly.

This plugin expects that the structued\_configs of each device is present in hostvars, otherwise no test will be generated.
carlbuchmann marked this conversation as resolved.
Show resolved Hide resolved

The plugin provides the following capabilities\:
\- Generate a per\-device test catalog based on the structured\_configs
\- Run the generated tests against each device and generate a report in Markdown and CSV format.
\- When using check\_mode, only generate the test catalog and generate a report to preview what would tests be run against each device
carlbuchmann marked this conversation as resolved.
Show resolved Hide resolved
\- Dumping the per\-device catalog to a file.
\- Backward compatibility with existing ansible tags behavior for eos\_validate\_state to filter categories of tests.

carlbuchmann marked this conversation as resolved.
Show resolved Hide resolved
## Parameters

| Argument | Type | Required | Default | Value Restrictions | Description |
| -------- | ---- | -------- | ------- | ------------------ | ----------- |
| logging_level | str | False | WARNING | Valid values:<br>- <code>CRITICAL</code><br>- <code>ERROR</code><br>- <code>WARNING</code><br>- <code>INFO</code><br>- <code>DEBUG</code> | Controls the log level for the ANTA library. If unset, the Action plugin will set it to \"WARNING\" |
| save_catalog | bool | optional | False | | A boolean to indicate whether or not the catalog should be saved for each device. |
| device_catalog_output_dir | str | optional | None | | When <code>save\_catalog</code> is True, this is the directory where the device catalogs will be saved.<br>Required if <em>save\_catalog\=True</em> |
| skipped_tests | list | optional | None | | A list of dictionaries containing the categories and tests to skip<br>The keys for the dictionnary are <code>categories</code> and <code>tests</code>. |
| category | str | True | None | | The name of one of the AvdTest categories. e.g., <code>AvdTestHardware</code> |
| tests | list | optional | None | | A list of tests in the category. e.g, <code>VerifyRoutingProtocolModel</code> for <code>AvdTestBGP</code> |

## Notes

- <code>check\_mode</code> is supported for this module and allows to generate a Test Report without running the tests.

## See Also

- ANTA website: [https://anta.ninja](https://anta.ninja)<br>ANTA documentation
gmuloc marked this conversation as resolved.
Show resolved Hide resolved

## Examples

```yaml
- name: Run eos_validate_state_runner leveraging ANTA
arista.avd.eos_validate_state_runner:
logging_level: ERROR
save_catalog: True
eos_validate_state_dir: "/tmp"
skipped_tests:
- category: AvdTestHardware
- category: AvdTestBGP
tests:
- VerifyRoutingProtocolModel
register: anta_results
```

## Authors

- Arista Ansible Team (@aristanetworks)
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ Transform information from ansible inventory to be able to provision CloudVision
save_topology: true
```

## Status

## Authors

- Ansible Arista Team (@aristanetworks)
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ Arguments are treated as one dict so all arguments will be set as vars.
check_mode: false
```

## Status

## Authors

- Arista Ansible Team (@aristanetworks)
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ For Markdown files the plugin can also run md\_toc on the output before writing
when: generate_device_documentation | arista.avd.default(true)
```

## Status

## Authors

- Arista Ansible Team (@aristanetworks)
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ The \`arista.avd.verify\_requirements\` module is an Ansible Action Plugin provi
run_once: true
```

## Status

## Authors

- Arista Ansible Team (@aristanetworks)
Loading