From 4d72da26978ee5857a031383428caf076f65c876 Mon Sep 17 00:00:00 2001 From: Claus Holbech Date: Fri, 2 Aug 2024 15:43:42 +0200 Subject: [PATCH] Cut: Remove deprecated Ansible plugins (#4291) Co-authored-by: Guillaume Mulocher --- .github/ISSUE_TEMPLATE/bug-report.yml | 14 +- .../plugins/Filter_plugins/generate_esi.md | 47 --- .../Filter_plugins/generate_lacp_id.md | 46 --- .../Filter_plugins/generate_route_target.md | 46 --- .../_emit_warning.md | 44 --- .../batch_template.md | 50 --- .../emit_warning.md | 44 --- .../validate_and_template.md | 66 ---- .../yaml_templates_to_facts.md | 77 ----- .../arista/avd/docs/porting-guides/5.x.x.md | 10 +- .../arista/avd/docs/release-notes/5.x.x.md | 21 ++ .../arista/avd/docs/semantic-versioning.md | 7 - .../arista/avd/meta/runtime.yml | 35 +- .../documentation/devices/host1.md | 9 - .../intended/configs/host1.cfg | 8 - .../host1/port-channel-interfaces.yml | 7 - .../avd/plugins/action/_emit_warning.py | 27 -- .../avd/plugins/action/batch_template.py | 127 ------- .../plugins/action/validate_and_template.py | 148 -------- .../plugins/action/yaml_templates_to_facts.py | 319 ------------------ .../avd/plugins/filter/deprecated_filters.py | 47 --- .../avd/plugins/filter/generate_esi.yml | 31 -- .../avd/plugins/filter/generate_lacp_id.yml | 27 -- .../plugins/filter/generate_route_target.yml | 29 -- .../avd/plugins/modules/_emit_warning.py | 28 -- .../avd/plugins/modules/batch_template.py | 43 --- .../plugins/modules/validate_and_template.py | 104 ------ .../modules/yaml_templates_to_facts.py | 154 --------- .../cv_zscaler_endpoints/tasks/main.yml | 62 ---- .../defaults/main.yaml | 5 - .../yaml_templates_to_facts/tasks/main.yml | 3 - .../yaml_templates_to_facts/tasks/test.j2 | 9 - .../yaml_templates_to_facts/tasks/test.yml | 16 - .../tests/error_invalid_merge_option.txt | 1 - .../tests/templates/inline_jinja.j2 | 16 - .../tests/templates/template.j2 | 12 - .../tests/templates/template1.j2 | 12 - .../tests/test_with_debug.yml | 28 -- .../tests/test_with_debug_dest.yml | 27 -- .../tests/test_with_debug_template_output.yml | 24 -- .../tests/test_with_dest_changed.yml | 31 -- .../tests/test_with_dest_json.yml | 25 -- .../tests/test_with_dest_no_change.yml | 37 -- .../tests/test_with_list_merge_append.yml | 29 -- .../tests/test_with_list_merge_append_rp.yml | 29 -- .../tests/test_with_list_merge_invalid.yml | 22 -- .../tests/test_with_list_merge_keep.yml | 30 -- .../tests/test_with_list_merge_prepend.yml | 29 -- .../tests/test_with_list_merge_prepend_rp.yml | 29 -- .../tests/test_with_list_merge_replace.yml | 29 -- .../tests/test_with_root_key.yml | 24 -- .../tests/test_with_strip_empty_false.yml | 24 -- .../tests/test_with_strip_empty_invalid.yml | 24 -- .../tests/test_with_template_output.yml | 17 - .../tests/test_with_template_output_false.yml | 21 -- .../tests/test_without_root_key.yml | 22 -- .../test_without_templates_parameter.yml | 10 - ...aml_templates_to_facts_test_with_dest.json | 1 - ...yaml_templates_to_facts_test_with_dest.yml | 8 - .../arista/avd/tests/sanity/ignore-2.15.txt | 5 +- .../arista/avd/tests/sanity/ignore-2.16.txt | 5 +- .../arista/avd/tests/sanity/ignore-2.17.txt | 5 +- python-avd/pyavd/j2filters/__init__.py | 6 - python-avd/pyavd/j2filters/generate_esi.py | 16 - .../pyavd/j2filters/generate_lacp_id.py | 17 - .../pyavd/j2filters/generate_route_target.py | 28 -- python-avd/pyavd/templater.py | 6 - .../pyavd/j2filters/test_generate_esi.py | 24 -- .../pyavd/j2filters/test_generate_lacp_id.py | 32 -- .../j2filters/test_generate_route_target.py | 25 -- 70 files changed, 57 insertions(+), 2383 deletions(-) delete mode 100644 ansible_collections/arista/avd/docs/plugins/Filter_plugins/generate_esi.md delete mode 100644 ansible_collections/arista/avd/docs/plugins/Filter_plugins/generate_lacp_id.md delete mode 100644 ansible_collections/arista/avd/docs/plugins/Filter_plugins/generate_route_target.md delete mode 100644 ansible_collections/arista/avd/docs/plugins/Modules_and_action_plugins/_emit_warning.md delete mode 100644 ansible_collections/arista/avd/docs/plugins/Modules_and_action_plugins/batch_template.md delete mode 100644 ansible_collections/arista/avd/docs/plugins/Modules_and_action_plugins/emit_warning.md delete mode 100644 ansible_collections/arista/avd/docs/plugins/Modules_and_action_plugins/validate_and_template.md delete mode 100644 ansible_collections/arista/avd/docs/plugins/Modules_and_action_plugins/yaml_templates_to_facts.md delete mode 100644 ansible_collections/arista/avd/plugins/action/_emit_warning.py delete mode 100644 ansible_collections/arista/avd/plugins/action/batch_template.py delete mode 100644 ansible_collections/arista/avd/plugins/action/validate_and_template.py delete mode 100644 ansible_collections/arista/avd/plugins/action/yaml_templates_to_facts.py delete mode 100644 ansible_collections/arista/avd/plugins/filter/deprecated_filters.py delete mode 100644 ansible_collections/arista/avd/plugins/filter/generate_esi.yml delete mode 100644 ansible_collections/arista/avd/plugins/filter/generate_lacp_id.yml delete mode 100644 ansible_collections/arista/avd/plugins/filter/generate_route_target.yml delete mode 100644 ansible_collections/arista/avd/plugins/modules/_emit_warning.py delete mode 100644 ansible_collections/arista/avd/plugins/modules/batch_template.py delete mode 100644 ansible_collections/arista/avd/plugins/modules/validate_and_template.py delete mode 100644 ansible_collections/arista/avd/plugins/modules/yaml_templates_to_facts.py delete mode 100644 ansible_collections/arista/avd/tests/integration/targets/cv_zscaler_endpoints/tasks/main.yml delete mode 100644 ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/defaults/main.yaml delete mode 100644 ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tasks/main.yml delete mode 100644 ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tasks/test.j2 delete mode 100644 ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tasks/test.yml delete mode 100644 ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/error_invalid_merge_option.txt delete mode 100644 ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/templates/inline_jinja.j2 delete mode 100644 ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/templates/template.j2 delete mode 100644 ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/templates/template1.j2 delete mode 100644 ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_debug.yml delete mode 100644 ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_debug_dest.yml delete mode 100644 ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_debug_template_output.yml delete mode 100644 ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_dest_changed.yml delete mode 100644 ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_dest_json.yml delete mode 100644 ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_dest_no_change.yml delete mode 100644 ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_list_merge_append.yml delete mode 100644 ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_list_merge_append_rp.yml delete mode 100644 ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_list_merge_invalid.yml delete mode 100644 ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_list_merge_keep.yml delete mode 100644 ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_list_merge_prepend.yml delete mode 100644 ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_list_merge_prepend_rp.yml delete mode 100644 ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_list_merge_replace.yml delete mode 100644 ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_root_key.yml delete mode 100644 ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_strip_empty_false.yml delete mode 100644 ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_strip_empty_invalid.yml delete mode 100644 ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_template_output.yml delete mode 100644 ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_template_output_false.yml delete mode 100644 ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_without_root_key.yml delete mode 100644 ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_without_templates_parameter.yml delete mode 100644 ansible_collections/arista/avd/tests/inventory/yaml_templates_to_facts/expected_output/yaml_templates_to_facts_test_with_dest.json delete mode 100644 ansible_collections/arista/avd/tests/inventory/yaml_templates_to_facts/expected_output/yaml_templates_to_facts_test_with_dest.yml delete mode 100644 python-avd/pyavd/j2filters/generate_esi.py delete mode 100644 python-avd/pyavd/j2filters/generate_lacp_id.py delete mode 100644 python-avd/pyavd/j2filters/generate_route_target.py delete mode 100644 python-avd/tests/pyavd/j2filters/test_generate_esi.py delete mode 100644 python-avd/tests/pyavd/j2filters/test_generate_lacp_id.py delete mode 100644 python-avd/tests/pyavd/j2filters/test_generate_route_target.py diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml index 6943f884f8b..873aa1dbdd8 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yml +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -32,17 +32,6 @@ body: - eos_config_deploy_eapi - eos_snapshot - eos_validate_state - - yaml_template_to_facts - - arista.avd.default - - arista.avd.esi_management - - arista.avd.is_in_filter - - arista.avd.list_compress - - arista.avd.markdown_rendering - - arista.avd.natural_sort - - arista.avd.add_md_toc - - arista.avd.configlet_build_config - - arista.avd.inventory_to_container - - arista.avd.yaml_templates_to_facts - new components - others @@ -54,7 +43,8 @@ body: options: - Ansible CLI (with virtual-env or native python) - Ansible CLI with AVD Runner - - Ansible AWX + - Ansible AWX/Tower/AAP + - PyAVD - type: textarea id: step-to-reproduce diff --git a/ansible_collections/arista/avd/docs/plugins/Filter_plugins/generate_esi.md b/ansible_collections/arista/avd/docs/plugins/Filter_plugins/generate_esi.md deleted file mode 100644 index 88002d72bb1..00000000000 --- a/ansible_collections/arista/avd/docs/plugins/Filter_plugins/generate_esi.md +++ /dev/null @@ -1,47 +0,0 @@ ---- -# This title is used for search results -title: arista.avd.generate_esi ---- - - -# generate_esi - -!!! note - Always use the FQCN (Fully Qualified Collection Name) `arista.avd.generate_esi` when using this plugin. - -!!! danger "This plugin is **deprecated**" - This will be removed in version 5.0.0. - -Transforms short_esi `0303:0202:0101` to EVPN ESI format `0000:0000:0303:0202:0101` - -## Synopsis - -Concatenates the given `esi_prefix` and `short_esi`. - -## Parameters - -| Argument | Type | Required | Default | Value Restrictions | Description | -| -------- | ---- | -------- | ------- | ------------------ | ----------- | -| _input | string | True | None | | Short ESI value as per AVD definition in eos_designs. | -| esi_prefix | string | optional | 0000:0000: | | ESI prefix value. Will be concatenated with the `short_esi`. | - -## Examples - -```yaml ---- -esi: "{{ short_esi | arista.avd.generate_esi('deaf:beed:') }}" -``` - -## Return Values - -| Name | Type | Description | -| ---- | ---- | ----------- | -| _value | string | Concatenated string of `esi_prefix` and `short_esi` like `0000:0000:0303:0202:0101` | - -## Authors - -- Arista Ansible Team (@aristanetworks) diff --git a/ansible_collections/arista/avd/docs/plugins/Filter_plugins/generate_lacp_id.md b/ansible_collections/arista/avd/docs/plugins/Filter_plugins/generate_lacp_id.md deleted file mode 100644 index 207c53c23e2..00000000000 --- a/ansible_collections/arista/avd/docs/plugins/Filter_plugins/generate_lacp_id.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -# This title is used for search results -title: arista.avd.generate_lacp_id ---- - - -# generate_lacp_id - -!!! note - Always use the FQCN (Fully Qualified Collection Name) `arista.avd.generate_lacp_id` when using this plugin. - -!!! danger "This plugin is **deprecated**" - This will be removed in version 5.0.0. - -Transforms short_esi `0303:0202:0101` to LACP ID format `0303.0202.0101` - -## Synopsis - -Replaces `:` with `.` - -## Parameters - -| Argument | Type | Required | Default | Value Restrictions | Description | -| -------- | ---- | -------- | ------- | ------------------ | ----------- | -| _input | string | True | None | | Short ESI value as per AVD definition in eos_designs. | - -## Examples - -```yaml ---- -lacp_id: "{{ short_esi | arista.avd.generate_lacp_id }}" -``` - -## Return Values - -| Name | Type | Description | -| ---- | ---- | ----------- | -| _value | string | String based on LACP ID format like 0303.0202.0101 | - -## Authors - -- Arista Ansible Team (@aristanetworks) diff --git a/ansible_collections/arista/avd/docs/plugins/Filter_plugins/generate_route_target.md b/ansible_collections/arista/avd/docs/plugins/Filter_plugins/generate_route_target.md deleted file mode 100644 index 4e39caff853..00000000000 --- a/ansible_collections/arista/avd/docs/plugins/Filter_plugins/generate_route_target.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -# This title is used for search results -title: arista.avd.generate_route_target ---- - - -# generate_route_target - -!!! note - Always use the FQCN (Fully Qualified Collection Name) `arista.avd.generate_route_target` when using this plugin. - -!!! danger "This plugin is **deprecated**" - This will be removed in version 5.0.0. - -Transforms short_esi `0303:0202:0101` to route-target format `03:03:02:02:01:01` - -## Synopsis - -Removes `:` and inserts new `:` for each two characters. - -## Parameters - -| Argument | Type | Required | Default | Value Restrictions | Description | -| -------- | ---- | -------- | ------- | ------------------ | ----------- | -| _input | string | True | None | | Short ESI value as per AVD definition in eos_designs. | - -## Examples - -```yaml ---- -rt: "{{ short_esi | arista.avd.generate_route_target }}" -``` - -## Return Values - -| Name | Type | Description | -| ---- | ---- | ----------- | -| _value | string | String based on route-target format like 03:03:02:02:01:01 | - -## Authors - -- Arista Ansible Team (@aristanetworks) diff --git a/ansible_collections/arista/avd/docs/plugins/Modules_and_action_plugins/_emit_warning.md b/ansible_collections/arista/avd/docs/plugins/Modules_and_action_plugins/_emit_warning.md deleted file mode 100644 index 0a48ad9071c..00000000000 --- a/ansible_collections/arista/avd/docs/plugins/Modules_and_action_plugins/_emit_warning.md +++ /dev/null @@ -1,44 +0,0 @@ ---- -# This title is used for search results -title: arista.avd._emit_warning ---- - - -# _emit_warning - -!!! note - Always use the FQCN (Fully Qualified Collection Name) `arista.avd._emit_warning` when using this plugin. - -Internal module - DO NOT USE - Emit a warning in a task. - -## Synopsis - -Emit a warning in a task. - -## Parameters - -| Argument | Type | Required | Default | Value Restrictions | Description | -| -------- | ---- | -------- | ------- | ------------------ | ----------- | -| message | str | optional | None | | The warning message to emit. | - -## Examples - -```yaml ---- -- name: Emit a warning - arista.avd._emit_warning: - message |- - The warning message. - delegate_to: localhost - check_mode: false - run_once: true - changed_when: false -``` - -## Authors - -- Arista Networks (@aristanetworks) diff --git a/ansible_collections/arista/avd/docs/plugins/Modules_and_action_plugins/batch_template.md b/ansible_collections/arista/avd/docs/plugins/Modules_and_action_plugins/batch_template.md deleted file mode 100644 index 807dadffb7d..00000000000 --- a/ansible_collections/arista/avd/docs/plugins/Modules_and_action_plugins/batch_template.md +++ /dev/null @@ -1,50 +0,0 @@ ---- -# This title is used for search results -title: arista.avd.batch_template ---- - - -# batch_template - -!!! note - Always use the FQCN (Fully Qualified Collection Name) `arista.avd.batch_template` when using this plugin. - -!!! danger "This plugin is **deprecated**" - This module will be removed in version 5.0.0. - -Render Jinja2 template on multiple items and write result to individual files. - -## Synopsis - -Render Jinja2 template on multiple items and write result to individual files. - -Destination file mode is hardcoded to 0o664. - -## Parameters - -| Argument | Type | Required | Default | Value Restrictions | Description | -| -------- | ---- | -------- | ------- | ------------------ | ----------- | -| template | str | True | None | | Path to Jinja2 Template file | -| dest_format_string | str | True | None | | Format string used to specify target file for each item. 'item' is the current item from 'items'. Like "mypath/{item}.md" | -| items | list | True | None | | List of strings. Each list item is passed to 'dest_format_string' as 'item' and passed to templater as 'item' | - -## Examples - -```yaml -- name: Output eos_cli_config_gen Documentation - tags: [eos_cli_config_gen] - delegate_to: localhost - run_once: true - arista.avd.batch_template: - template: avd_schema_documentation.j2 - dest_format_str: "{{ role_documentation_dir }}/{item}.md" - items: "{{ data_in_list_form }}" -``` - -## Authors - -- Arista Ansible Team (@aristanetworks) diff --git a/ansible_collections/arista/avd/docs/plugins/Modules_and_action_plugins/emit_warning.md b/ansible_collections/arista/avd/docs/plugins/Modules_and_action_plugins/emit_warning.md deleted file mode 100644 index 78c432a45fb..00000000000 --- a/ansible_collections/arista/avd/docs/plugins/Modules_and_action_plugins/emit_warning.md +++ /dev/null @@ -1,44 +0,0 @@ ---- -# This title is used for search results -title: arista.avd.emit_warning ---- - - -# emit_warning - -!!! note - Always use the FQCN (Fully Qualified Collection Name) `arista.avd.emit_warning` when using this plugin. - -Emit a warning in a task. - -## Synopsis - -Emit a warning in a task. - -## Parameters - -| Argument | Type | Required | Default | Value Restrictions | Description | -| -------- | ---- | -------- | ------- | ------------------ | ----------- | -| message | str | optional | None | | The warning message to emit. | - -## Examples - -```yaml ---- -- name: Enit a warning - arista.avd.emit_warning: - message |- - The warning message. - delegate_to: localhost - check_mode: false - run_once: true - changed_when: false -``` - -## Authors - -- EMEA AS Team (@aristanetworks) diff --git a/ansible_collections/arista/avd/docs/plugins/Modules_and_action_plugins/validate_and_template.md b/ansible_collections/arista/avd/docs/plugins/Modules_and_action_plugins/validate_and_template.md deleted file mode 100644 index d6b5dbef5a4..00000000000 --- a/ansible_collections/arista/avd/docs/plugins/Modules_and_action_plugins/validate_and_template.md +++ /dev/null @@ -1,66 +0,0 @@ ---- -# This title is used for search results -title: arista.avd.validate_and_template ---- - - -# validate_and_template - -!!! note - Always use the FQCN (Fully Qualified Collection Name) `arista.avd.validate_and_template` when using this plugin. - -!!! danger "This plugin is **deprecated**" - This module will be removed in version 5.0.0. - -Validate input data according to Schema, render Jinja2 template and write result to a file. - -## Synopsis - -The `arista.avd.validate_and_template` Action Plugin performs data conversions and validation according to the supplied Schema. - -The converted data is then used to render a Jinja2 template and writing the result to a file. - -The Action Plugin supports different modes for conversion and validation, to either block the playbook or just warn the user if the input data is not valid. - -For Markdown files the plugin can also run md_toc on the output before writing to the file. - -## Parameters - -| Argument | Type | Required | Default | Value Restrictions | Description | -| -------- | ---- | -------- | ------- | ------------------ | ----------- | -| template | str | True | None | | Path to Jinja2 Template file | -| dest | str | True | None | | Destination path. The rendered template will be written to this file | -| mode | str | False | None | | File mode for dest file. | -| schema | dict | False | None | | Schema conforming to "AVD Meta Schema". Either schema or schema_id must be set. | -| schema_id | str | False | None | Valid values:
- eos_cli_config_gen
- eos_designs | ID of Schema conforming to "AVD Meta Schema". Either schema or schema_id must be set. | -| add_md_toc | bool | False | None | | Run md_toc on the output before writing to the file. | -| md_toc_skip_lines | int | False | 0 | | Pass this value as skip_lines to add_md_toc. | -| conversion_mode | str | False | debug | Valid values:
- warning
- info
- debug
- quiet
- disabled | Run data conversion in either "warning", "info", "debug", "quiet" or "disabled" mode.
Conversion will perform type conversion of input variables as defined in the schema.
Conversion is intended to help the user to identify minor issues with the input data, while still allowing the data to be validated.
During conversion, messages will generated with information about the host(s) and key(s) which required conversion.
conversion_mode:disabled means that conversion will not run.
conversion_mode:error will produce error messages and fail the task.
conversion_mode:warning will produce warning messages.
conversion_mode:info will produce regular log messages.
conversion_mode:debug will produce hidden messages viewable with -v.
conversion_mode:quiet will not produce any messages. | -| validation_mode | str | False | warning | Valid values:
- error
- warning
- info
- debug
- disabled | Run validation in either "error", "warning", "info", "debug" or "disabled" mode.
Validation will validate the input variables according to the schema.
During validation, messages will generated with information about the host(s) and key(s) which failed validation.
validation_mode:disabled means that validation will not run.
validation_mode:error will produce error messages and fail the task.
validation_mode:warning will produce warning messages.
validation_mode:info will produce regular log messages.
validation_mode:debug will produce hidden messages viewable with -v. | -| cprofile_file | str | False | None | | Filename for storing cprofile data used to debug performance issues.
Running cprofile will slow down performance in itself, so only set this while troubleshooting. | - -## Examples - -```yaml -- name: Generate device documentation - tags: [build, provision, documentation] - arista.avd.validate_and_template: - template: "eos-device-documentation.j2" - dest: "{{ devices_dir }}/{{ inventory_hostname }}.md" - mode: "0o664" - schema: "{{ lookup('ansible.builtin.file', role_schema_path) | from_yaml }}" - conversion_mode: "{{ avd_data_conversion_mode }}" - validation_mode: "{{ avd_data_validation_mode }}" - add_md_toc: true - md_toc_skip_lines: 3 - delegate_to: localhost - when: generate_device_documentation | arista.avd.default(true) -``` - -## Authors - -- Arista Ansible Team (@aristanetworks) diff --git a/ansible_collections/arista/avd/docs/plugins/Modules_and_action_plugins/yaml_templates_to_facts.md b/ansible_collections/arista/avd/docs/plugins/Modules_and_action_plugins/yaml_templates_to_facts.md deleted file mode 100644 index d71a89c6a52..00000000000 --- a/ansible_collections/arista/avd/docs/plugins/Modules_and_action_plugins/yaml_templates_to_facts.md +++ /dev/null @@ -1,77 +0,0 @@ ---- -# This title is used for search results -title: arista.avd.yaml_templates_to_facts ---- - - -# yaml_templates_to_facts - -!!! note - Always use the FQCN (Fully Qualified Collection Name) `arista.avd.yaml_templates_to_facts` when using this plugin. - -!!! danger "This plugin is **deprecated**" - This module will be removed in version 5.0.0. - -Set facts from YAML via Jinja2 templates - -## Synopsis - -Set facts from YAML produced by Jinja2 templates - -## Parameters - -| Argument | Type | Required | Default | Value Restrictions | Description | -| -------- | ---- | -------- | ------- | ------------------ | ----------- | -| root_key | str | False | None | | Root key under which the facts will be defined. If not set the facts well be set directly on root level. | -| schema | dict | False | None | | Schema conforming to "AVD Meta Schema". Either schema or schema_id must be set. | -| schema_id | str | False | None | Valid values:
- eos_cli_config_gen
- eos_designs | ID of Schema conforming to "AVD Meta Schema". Either schema or schema_id must be set. | -| templates | list | True | None | | List of dicts for Jinja templates to be run. | -|     template | str | False | None | | Template file. Either template or python_module must be set. | -|     python_module | str | False | None | | Python module to import. Either template or python_module must be set. | -|     python_class_name | str | False | AvdStructuredConfig | | Name of Python Class to import. | -|     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. Only applies to templates. | -| debug | bool | False | None | | Output list 'avd_yaml_templates_to_facts_debug' with timestamps of each performed action. | -| dest | str | False | None | | Destination path. If set, the output facts will also be written to this path.
Autodetects data format based on file suffix. '.yml', '.yaml' -> YAML, default -> JSON | -| mode | str | False | None | | File mode (ex. "0o664") 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.
This is to resolve any input values with inline jinja using variables/facts set by the input templates. | -| conversion_mode | str | False | debug | Valid values:
- error
- warning
- info
- debug
- quiet
- disabled | Run data conversion in either "error", "warning", "info", "debug", "quiet" or "disabled" mode.
Conversion will perform type conversion of input variables as defined in the schema.
Conversion is intended to help the user to identify minor issues with the input data, while still allowing the data to be validated.
During conversion, messages will be generated with information about the host(s) and key(s) which required conversion.
conversion_mode:disabled means that conversion will not run.
conversion_mode:error will produce error messages and fail the task.
conversion_mode:warning will produce warning messages.
conversion_mode:info will produce regular log messages.
conversion_mode:debug will produce hidden messages viewable with -v.
conversion_mode:quiet will not produce any messages. | -| validation_mode | str | False | warning | Valid values:
- error
- warning
- info
- debug
- disabled | Run validation in either "error", "warning", "info", "debug" or "disabled" mode.
Validation will validate the input variables according to the schema.
During validation, messages will be generated with information about the host(s) and key(s) which failed validation.
validation_mode:disabled means that validation will not run.
validation_mode:error will produce error messages and fail the task.
validation_mode:warning will produce warning messages.
validation_mode:info will produce regular log messages.
validation_mode:debug will produce hidden messages viewable with -v. | -| output_schema | dict | False | None | | AVD Schema for output data. Used for automatic merge of data. | -| output_schema_id | str | False | None | Valid values:
- eos_cli_config_gen
- eos_designs | ID of AVD Schema for output data. Used for automatic merge of data. | -| set_switch_fact | bool | False | True | | Set "switch" fact from on "avd_switch_facts.<inventory_hostname>.switch" | - -## Examples - -```yaml ---- -- name: Generate device configuration in structured format - arista.avd.yaml_templates_to_facts: - root_key: structured_config - templates: - - python_module: "pyavd._eos_designs.structured_config.base" - python_class_name: "AvdStructuredConfig" - - template: "mlag/main.j2" - - template: "designs/underlay/main.j2" - - template: "designs/overlay/main.j2" - - template: "l3_edge/main.j2" - - template: "designs/network_services/main.j2" - - template: "connected_endpoints/main.j2" - - template: "custom-structured-configuration-from-var.j2" - options: - list_merge: "{{ custom_structured_configuration_list_merge }}" - strip_empty_keys: false - schema_id: eos_designs - output_schema_id: eos_cli_config_gen - check_mode: no - changed_when: False -``` - -## Authors - -- EMEA AS Team (@aristanetworks) diff --git a/ansible_collections/arista/avd/docs/porting-guides/5.x.x.md b/ansible_collections/arista/avd/docs/porting-guides/5.x.x.md index 949777674ab..3695b091e2d 100644 --- a/ansible_collections/arista/avd/docs/porting-guides/5.x.x.md +++ b/ansible_collections/arista/avd/docs/porting-guides/5.x.x.md @@ -32,7 +32,15 @@ The following ansible plugins have been removed from the `arista.avd` Ansible co | Plugin type | Plugin name | Replacement | | ----------- | ----------- | ----------- | -| TODO: list out the removed plugins and replacements (take from deprecation docs) | | | +| Filter | `arista.avd.hash_passphrase` | Use `arista.avd.snmp_hash` instead | +| Filter | `arista.avd.generate_esi` | Use Jinja string concatenation instead like `{{ ~ }}` | +| Filter | `arista.avd.generate_lacp_id` | Use the builtin `replace` filter instead like `{{ \| replace(':', '.') }}` | +| Filter | `arista.avd.generate_route_target` | Use the builtin `ansible.builtin.regex_replace` filter instead like `{{ \| ansible.builtin.regex_replace('(\\d{2})(\\d{2}):(\\d{2})(\\d{2}):(\\d{2})(\\d{2})', '\\1:\\2:\\3:\\4:\\5:\\6') }}` | +| Action plugin/Module | `arista.avd.deploy_to_cv` | Use `arista.avd.cv_workflow` instead | +| Action plugin/Module | `arista.avd.batch_template` | The internal `arista.avd.batch_template` action plugin is no longer used by AVD. The plugin is released as open source, so it can be copied and reused according to the license and copyright. | +| Action plugin/Module | `arista.avd.validate_and_template` | The internal `arista.avd.validate_and_template` action plugin is no longer used by AVD. The plugin is released as open source, so it can be copied and reused according to the license and copyright. | +| Action plugin/Module | `arista.avd.yaml_templates_to_facts` | The internal `arista.avd.yaml_templates_to_facts` action plugin is no longer used by AVD. The plugin is released as open source, so it can be copied and reused according to the license and copyright. | +| Action plugin/Module | `arista.avd._emit_warning` | The internal `arista.avd._emit_warning` action plugin is no longer used by AVD. The plugin is released as open source, so it can be copied and reused according to the license and copyright. | ## Changes to role arista.avd.eos_designs diff --git a/ansible_collections/arista/avd/docs/release-notes/5.x.x.md b/ansible_collections/arista/avd/docs/release-notes/5.x.x.md index fe515ef0d9d..23c70cfc0bc 100644 --- a/ansible_collections/arista/avd/docs/release-notes/5.x.x.md +++ b/ansible_collections/arista/avd/docs/release-notes/5.x.x.md @@ -18,6 +18,27 @@ title: Release Notes for AVD 5.x.x - AVD v.5.0.0 requires Python version 3.10 or newer. +### Removal of Ansible plugins + +The following ansible plugins have been removed from the `arista.avd` Ansible collection in v5.0.0. + +Filters: + +- `arista.avd.hash_passphrase` +- `arista.avd.generate_esi` +- `arista.avd.generate_lacp_id` +- `arista.avd.generate_route_target` + +Action plugins / Modules: + +- `arista.avd.deploy_to_cv` +- `arista.avd.batch_template` +- `arista.avd.validate_and_template` +- `arista.avd.yaml_templates_to_facts` +- `arista.avd._emit_warning + +See the [porting guide](../porting-guides/5.x.x.md#removal-of-ansible-plugins) for details. + ### Data model changes from "dict-of-dicts" to "list-of-dicts" TODO: Removed type conversion diff --git a/ansible_collections/arista/avd/docs/semantic-versioning.md b/ansible_collections/arista/avd/docs/semantic-versioning.md index 36c0e700b17..cfd684dec53 100644 --- a/ansible_collections/arista/avd/docs/semantic-versioning.md +++ b/ansible_collections/arista/avd/docs/semantic-versioning.md @@ -41,9 +41,6 @@ All roles input variables follow SemVer. Any breaking changes will, at a minimum | Filter: `decrypt` | ✅ | ✅ | | | Filter: `default` | ✅ | ✅ | | | Filter: `encrypt` | ✅ | ✅ | | -| Filter: `generate_esi` | ✅ | ✅ | | -| Filter: `generate_lacp_id` | ✅ | ✅ | | -| Filter: `generate_route_target` | ✅ | ✅ | | | Filter: `hide_passwords` | ✅ | ✅ | | | Filter: `is_in_filter` | ✅ | ✅ | | | Filter: `list_compress` | ✅ | ✅ | | @@ -51,7 +48,6 @@ All roles input variables follow SemVer. Any breaking changes will, at a minimum | Filter: `range_expand` | ✅ | ✅ | | | Filter: `snmp_hash` | ✅ | ✅ | | | Filter: `status_render` | ✅ | ✅ | | -| Action: `batch_template` | ✅ | ✅ | | | Action: `configlet_build_config` | ✘ | ✘ | Internal plugin, not intended for external use. | | Action: `cv_workflow` | ✅ | ✅ | The resulting CloudVision configuration will be maintained, unless in rare cases, when addressing a bug. | | Action: `eos_designs_facts` | ✘ | ✘ | Internal plugin, not intended for external use. | @@ -60,10 +56,7 @@ All roles input variables follow SemVer. Any breaking changes will, at a minimum | Action: `eos_validate_state_runner` | ✘ | ✘ | Internal plugin, not intended for external use. | | Action: `inventory_to_container` | ✘ | ✘ | Internal plugin, not intended for external use. | | Action: `set_vars` | ✅ | ✅ | | -| Action: `validate_and_template` | ✘ | ✘ | Internal plugin, not intended for external use. | | Action: `verify_requirements` | ✘ | ✘ | Internal plugin, not intended for external use. | -| Action: `yaml_templates_to_facts` | ✘ | ✘ | Internal plugin, not intended for external use. | -| Action: `_emit_warning` | ✘ | ✘ | Internal plugin, not intended for external use. | | Test: `contains` | ✅ | ✅ | | | Test: `defined` | ✅ | ✅ | | | Test: `global_vars` | ✅ | ✅ | | diff --git a/ansible_collections/arista/avd/meta/runtime.yml b/ansible_collections/arista/avd/meta/runtime.yml index 615455effa5..6d7a667f200 100644 --- a/ansible_collections/arista/avd/meta/runtime.yml +++ b/ansible_collections/arista/avd/meta/runtime.yml @@ -4,71 +4,80 @@ plugin_routing: filter: hash_passphrase: redirect: arista.avd.snmp_hash - deprecation: + tombstone: removal_version: 5.0.0 warning_text: Use arista.avd.snmp_hash instead generate_esi: - deprecation: + tombstone: removal_version: 5.0.0 warning_text: Use Jinja string concatenation instead like `{{ ~ }}` generate_lacp_id: - deprecation: + tombstone: removal_version: 5.0.0 warning_text: Use the builtin `replace` filter instead like `{{ | replace(':', '.') }}` generate_route_target: - deprecation: + tombstone: removal_version: 5.0.0 warning_text: >- Use the builtin `ansible.builtin.regex_replace` filter instead like `{{ | ansible.builtin.regex_replace('(\\d{2})(\\d{2}):(\\d{2})(\\d{2}):(\\d{2})(\\d{2})', '\\1:\\2:\\3:\\4:\\5:\\6') }}` modules: + _emit_warning: + tombstone: + removal_version: 5.0.0 + warning_text: |- + The internal 'arista.avd._emit_warning' action plugin is not longer used by AVD. deploy_to_cv: - deprecation: + tombstone: removal_version: 5.0.0 warning_text: |- The preview module 'arista.avd.deploy_to_cv' has been released under the new name 'arista.avd.cv_workflow'. - The module will be redirected automatically until AVD version 5.0.0 after which it will be removed. redirect: arista.avd.cv_workflow batch_template: - deprecation: + tombstone: removal_version: 5.0.0 warning_text: |- The internal 'arista.avd.batch_template' action plugin is no longer used by AVD. The plugin is released as open source, so it can be copied and reused according to the license and copyright. validate_and_template: - deprecation: + tombstone: removal_version: 5.0.0 warning_text: |- The internal 'arista.avd.validate_and_template' action plugin is no longer used by AVD. The plugin is released as open source, so it can be copied and reused according to the license and copyright. yaml_templates_to_facts: - deprecation: + tombstone: removal_version: 5.0.0 warning_text: |- The internal 'arista.avd.yaml_templates_to_facts' action plugin is no longer used by AVD. The plugin is released as open source, so it can be copied and reused according to the license and copyright. action: + _emit_warning: + tombstone: + removal_version: 5.0.0 + warning_text: |- + The internal 'arista.avd._emit_warning' action plugin is not longer used by AVD. deploy_to_cv: - deprecation: + tombstone: removal_version: 5.0.0 warning_text: |- The preview module 'arista.avd.deploy_to_cv' has been released under the new name 'arista.avd.cv_workflow'. The module will be redirected automatically until AVD version 5.0.0 after which it will be removed. redirect: arista.avd.cv_workflow batch_template: - deprecation: + tombstone: removal_version: 5.0.0 warning_text: |- The internal 'arista.avd.batch_template' action plugin is no longer used by AVD. The plugin is released as open source, so it can be copied and reused according to the license and copyright. validate_and_template: - deprecation: + tombstone: removal_version: 5.0.0 warning_text: |- The internal 'arista.avd.validate_and_template' action plugin is no longer used by AVD. The plugin is released as open source, so it can be copied and reused according to the license and copyright. yaml_templates_to_facts: - deprecation: + tombstone: removal_version: 5.0.0 warning_text: |- The internal 'arista.avd.yaml_templates_to_facts' action plugin is no longer used by AVD. diff --git a/ansible_collections/arista/avd/molecule/eos_cli_config_gen_deprecated_vars/documentation/devices/host1.md b/ansible_collections/arista/avd/molecule/eos_cli_config_gen_deprecated_vars/documentation/devices/host1.md index 49c0954fa24..7ba6e2a4595 100644 --- a/ansible_collections/arista/avd/molecule/eos_cli_config_gen_deprecated_vars/documentation/devices/host1.md +++ b/ansible_collections/arista/avd/molecule/eos_cli_config_gen_deprecated_vars/documentation/devices/host1.md @@ -616,7 +616,6 @@ interface Ethernet47 | Interface | Description | Type | Mode | VLANs | Native VLAN | Trunk Group | LACP Fallback Timeout | LACP Fallback Mode | MLAG ID | EVPN ESI | | --------- | ----------- | ---- | ---- | ----- | ----------- | ------------| --------------------- | ------------------ | ------- | -------- | | Port-Channel1 | SRV01_bond0 | switched | trunk | 2-3000 | - | - | - | - | - | 0000:0000:0404:0404:0303 | -| Port-Channel30 | deprecate_filters_testing | switched | access | - | - | - | - | - | - | deaf:beed:0303:0202:0101 | | Port-Channel51 | ipv6_prefix | switched | trunk | 1-500 | - | - | - | - | - | - | ##### Flexible Encapsulation Interfaces @@ -653,14 +652,6 @@ interface Port-Channel2.1000 route-target import 03:03:02:02:01:01 lacp system-id 0303.0202.0101 ! -interface Port-Channel30 - description deprecate_filters_testing - switchport - evpn ethernet-segment - identifier deaf:beed:0303:0202:0101 - route-target import 03:03:02:02:01:01 - lacp system-id 0303.0202.0101 -! interface Port-Channel51 description ipv6_prefix switchport diff --git a/ansible_collections/arista/avd/molecule/eos_cli_config_gen_deprecated_vars/intended/configs/host1.cfg b/ansible_collections/arista/avd/molecule/eos_cli_config_gen_deprecated_vars/intended/configs/host1.cfg index 1fd68b1dc9a..d6490ae5416 100644 --- a/ansible_collections/arista/avd/molecule/eos_cli_config_gen_deprecated_vars/intended/configs/host1.cfg +++ b/ansible_collections/arista/avd/molecule/eos_cli_config_gen_deprecated_vars/intended/configs/host1.cfg @@ -146,14 +146,6 @@ interface Port-Channel2.1000 route-target import 03:03:02:02:01:01 lacp system-id 0303.0202.0101 ! -interface Port-Channel30 - description deprecate_filters_testing - switchport - evpn ethernet-segment - identifier deaf:beed:0303:0202:0101 - route-target import 03:03:02:02:01:01 - lacp system-id 0303.0202.0101 -! interface Port-Channel51 description ipv6_prefix switchport diff --git a/ansible_collections/arista/avd/molecule/eos_cli_config_gen_deprecated_vars/inventory/host_vars/host1/port-channel-interfaces.yml b/ansible_collections/arista/avd/molecule/eos_cli_config_gen_deprecated_vars/inventory/host_vars/host1/port-channel-interfaces.yml index c30ffebf312..78720cb676a 100644 --- a/ansible_collections/arista/avd/molecule/eos_cli_config_gen_deprecated_vars/inventory/host_vars/host1/port-channel-interfaces.yml +++ b/ansible_collections/arista/avd/molecule/eos_cli_config_gen_deprecated_vars/inventory/host_vars/host1/port-channel-interfaces.yml @@ -30,13 +30,6 @@ port_channel_interfaces: rt: 03:03:02:02:01:01 lacp_id: 0303.0202.0101 - # Testing deprecated filter plugins to be remove in AVD 5.0.0 - Port-Channel30: - description: deprecate_filters_testing - esi: "{{ '0303:0202:0101' | arista.avd.generate_esi('deaf:beed:') }}" - rt: "{{ '0303:0202:0101' | arista.avd.generate_route_target }}" - lacp_id: "{{ '0303:0202:0101' | arista.avd.generate_lacp_id }}" - Port-Channel51: description: ipv6_prefix vlans: 1-500 diff --git a/ansible_collections/arista/avd/plugins/action/_emit_warning.py b/ansible_collections/arista/avd/plugins/action/_emit_warning.py deleted file mode 100644 index c52eb00472b..00000000000 --- a/ansible_collections/arista/avd/plugins/action/_emit_warning.py +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (c) 2024 Arista Networks, Inc. -# Use of this source code is governed by the Apache License 2.0 -# that can be found in the LICENSE file. -"""Temporary file to emit a warning.""" - -from ansible.plugins.action import ActionBase -from ansible.utils.display import Display - -display = Display() - -__metaclass__ = type - - -class ActionModule(ActionBase): - def run(self, tmp=None, task_vars=None): - if task_vars is None: - task_vars = {} - - result = super().run(tmp, task_vars) - del tmp - - if self._task.args: - message = self._task.args.get("message") - - display.warning(message) - - return result diff --git a/ansible_collections/arista/avd/plugins/action/batch_template.py b/ansible_collections/arista/avd/plugins/action/batch_template.py deleted file mode 100644 index a9d8029e870..00000000000 --- a/ansible_collections/arista/avd/plugins/action/batch_template.py +++ /dev/null @@ -1,127 +0,0 @@ -# Copyright (c) 2023-2024 Arista Networks, Inc. -# Use of this source code is governed by the Apache License 2.0 -# that can be found in the LICENSE file. -from __future__ import absolute_import, division, print_function - -__metaclass__ = type - -from collections import ChainMap -from concurrent.futures import ProcessPoolExecutor -from multiprocessing import get_context -from os import open as os_open - -from ansible.errors import AnsibleActionFail -from ansible.plugins.action import ActionBase, display - -from ansible_collections.arista.avd.plugins.plugin_utils.utils import get_templar, template - -# Leveraging copy on write from fork -GLOBALS = {} - - -def opener(path, flags): - return os_open(path, flags, 0o664) - - -# def _template_process(item: str, task_vars: dict, templatefile: str, dest_format_str: str, templar) -> dict: -def _template_process(item: str) -> dict: - """ - This function runs as a separate fork. - - Perform Jinja templating and write output to a file. - - Parameters - ---------- - item : str - One string from the list of strings given to the module. Could be used as key in the template. - Also used to build destination filename - task_vars : dict - Ansible task vars - templatefile : str - Filename of template file - dest_format_str : str - Format string used to build destination filename inserting item value - templar : object - Instance of Ansible templar - - Returns - ------- - dict - Ansible result dictionary with any errors caught during writing of the output file. - """ - dest_format_str = GLOBALS["dest_format_str"] - task_vars = GLOBALS["task_vars"] - templatefile = GLOBALS["templatefile"] - templar = GLOBALS["templar"] - dest = str(dest_format_str).format(item=item) - - template_vars = ChainMap({"item": item}, task_vars) - output = template(templatefile, template_vars, templar) - - result = {} - try: - with open(dest, "w", encoding="UTF-8", opener=opener) as file: - file.write(output) - except Exception as e: - result["failed"] = True - result["msg"] = str(e) - result["exception"] = e - - return result - - -class ActionModule(ActionBase): - """ - Arguments: - template: - Path to jinja2 template used for all items - items: - List of strings. Each list item is passed to 'dest_format_string' as 'item' and passed to templater as 'item' - dest_format_str: - Format string used to specify target file for each item. 'item' is the current item from 'items' - Example: "mypath/{item}.md" - """ - - def run(self, tmp=None, task_vars=None): - if task_vars is None: - task_vars = {} - - GLOBALS["task_vars"] = task_vars - - result = super().run(tmp, task_vars) - del tmp # tmp no longer has any effect - - # Validate Arguments - templatefile = self._task.args["template"] - if not isinstance(templatefile, str): - raise AnsibleActionFail("The argument 'template' must be a string") - GLOBALS["templatefile"] = templatefile - - items = self._task.args.get("items") - if not isinstance(items, list): - raise AnsibleActionFail("The argument 'items' must be a list") - - dest_format_str = self._task.args.get("dest_format_str") - if not isinstance(dest_format_str, str): - raise AnsibleActionFail("The argument 'dest_format_str' must be a string") - GLOBALS["dest_format_str"] = dest_format_str - - forks = task_vars["ansible_forks"] - - # Get updated templar instance to be passed along to our simplified "templater" - templar = get_templar(self, task_vars) - GLOBALS["templar"] = templar - - context = get_context("fork") - with ProcessPoolExecutor(max_workers=forks, mp_context=context) as executor: - return_values = executor.map( - _template_process, - items, - ) - - for return_value in return_values: - if isinstance(return_value, Exception): - display.error(return_value) - result["failed"] = True - - return result diff --git a/ansible_collections/arista/avd/plugins/action/validate_and_template.py b/ansible_collections/arista/avd/plugins/action/validate_and_template.py deleted file mode 100644 index 112d9b2a0f1..00000000000 --- a/ansible_collections/arista/avd/plugins/action/validate_and_template.py +++ /dev/null @@ -1,148 +0,0 @@ -# Copyright (c) 2023-2024 Arista Networks, Inc. -# Use of this source code is governed by the Apache License 2.0 -# that can be found in the LICENSE file. -from __future__ import absolute_import, division, print_function - -__metaclass__ = type - -import cProfile -import pstats - -from ansible.errors import AnsibleActionFail -from ansible.plugins.action import ActionBase, display - -from ansible_collections.arista.avd.plugins.plugin_utils.pyavd_wrappers import RaiseOnUse -from ansible_collections.arista.avd.plugins.plugin_utils.schema.avdschematools import AvdSchemaTools -from ansible_collections.arista.avd.plugins.plugin_utils.utils import get_templar - -PLUGIN_NAME = "arista.avd.validate_and_template" - -try: - from pyavd._utils import template - from pyavd.j2filters import add_md_toc -except ImportError as e: - add_md_toc = template = RaiseOnUse( - AnsibleActionFail( - f"The '{PLUGIN_NAME}' plugin requires the 'pyavd' Python library. Got import error", - orig_exc=e, - ) - ) - - -class ActionModule(ActionBase): - def run(self, tmp=None, task_vars=None): - if task_vars is None: - task_vars = {} - - result = super().run(tmp, task_vars) - del tmp # tmp no longer has any effect - - cprofile_file = self._task.args.get("cprofile_file") - if cprofile_file: - profiler = cProfile.Profile() - profiler.enable() - - # Validate Arguments - self.templatefile = self._task.args.get("template") - if not isinstance(self.templatefile, str): - raise AnsibleActionFail("The argument 'template' must be a string") - - schema = self._task.args.get("schema") - schema_id = self._task.args.get("schema_id") - conversion_mode = self._task.args.get("conversion_mode") - validation_mode = self._task.args.get("validation_mode") - - dest = self._task.args.get("dest") - if dest is not None and not isinstance(dest, str): - raise AnsibleActionFail("The argument 'dest' must be a string if set") - - self.add_md_toc = self._task.args.get("add_md_toc", False) - if not isinstance(self.add_md_toc, bool): - raise AnsibleActionFail("The argument 'add_md_toc' must be a boolean") - - self.md_toc_skip_lines = self._task.args.get("md_toc_skip_lines", 0) - if not isinstance(self.md_toc_skip_lines, int): - raise AnsibleActionFail("The argument 'md_toc_skip_lines' must be an integer") - - # Build data from hostvars and role default vars - hostname = task_vars["inventory_hostname"] - - # Read ansible variables and perform templating to support inline jinja2 - for var in task_vars: - if str(var).startswith(("ansible", "molecule", "hostvars", "vars", "avd_switch_facts")): - continue - if self._templar.is_template(task_vars[var]): - # Var contains a jinja2 template. - try: - task_vars[var] = self._templar.template(task_vars[var], fail_on_undefined=False) - except Exception as e: - raise AnsibleActionFail(f"Exception during templating of task_var '{var}'") from e - - if not isinstance(task_vars, dict): - # Corner case for ansible-test where the passed task_vars is a nested chain-map - task_vars = dict(task_vars) - - # Load schema tools and perform conversion and validation - avdschematools = AvdSchemaTools( - hostname=hostname, - ansible_display=display, - schema=schema, - schema_id=schema_id, - conversion_mode=conversion_mode, - validation_mode=validation_mode, - plugin_name=task_vars["ansible_role_name"], - ) - result.update(avdschematools.convert_and_validate_data(task_vars)) - - # Template to file - # Update result from Ansible "copy" operation (setting 'changed' flag accordingly) - if not result.get("failed"): - result.update(self.template(task_vars, dest)) - - if cprofile_file: - profiler.disable() - stats = pstats.Stats(profiler).sort_stats("cumtime") - stats.dump_stats(cprofile_file) - - return result - - def template(self, task_vars, dest): - # Get updated templar instance to be passed along to our simplified "templater" - templar = get_templar(self, task_vars) - - output = template(self.templatefile, task_vars, templar) - if self.add_md_toc: - output = add_md_toc(output, skip_lines=self.md_toc_skip_lines) - - if dest is None: - # Return dict with template output in 'output' key for fileless operation - return {"output": output} - - write_file_result = self.write_file(output, dest, task_vars) - - # Return result with the result from the copy operation - return write_file_result - - def write_file(self, content, dest, task_vars): - """ - This function implements the Ansible 'copy' action_module, to benefit from Ansible builtin functionality like 'changed'. - Reuse task data - """ - new_task = self._task.copy() - new_task.args = { - "dest": dest, - "mode": self._task.args.get("mode"), - "content": content, - } - - copy_action = self._shared_loader_obj.action_loader.get( - "ansible.legacy.copy", - task=new_task, - connection=self._connection, - play_context=self._play_context, - loader=self._loader, - templar=self._templar, - shared_loader_obj=self._shared_loader_obj, - ) - - return copy_action.run(task_vars=task_vars) diff --git a/ansible_collections/arista/avd/plugins/action/yaml_templates_to_facts.py b/ansible_collections/arista/avd/plugins/action/yaml_templates_to_facts.py deleted file mode 100644 index e3b7aa103d0..00000000000 --- a/ansible_collections/arista/avd/plugins/action/yaml_templates_to_facts.py +++ /dev/null @@ -1,319 +0,0 @@ -# Copyright (c) 2023-2024 Arista Networks, Inc. -# Use of this source code is governed by the Apache License 2.0 -# that can be found in the LICENSE file. -from __future__ import absolute_import, division, print_function - -__metaclass__ = type - -import cProfile -import pstats -from collections import ChainMap -from datetime import datetime - -import yaml -from ansible.errors import AnsibleActionFail -from ansible.parsing.yaml.dumper import AnsibleDumper -from ansible.plugins.action import ActionBase, display -from ansible.utils.vars import isidentifier - -from ansible_collections.arista.avd.plugins.plugin_utils.pyavd_wrappers import RaiseOnUse -from ansible_collections.arista.avd.plugins.plugin_utils.schema.avdschematools import AvdSchemaTools -from ansible_collections.arista.avd.plugins.plugin_utils.utils import get_templar - -DEFAULT_PYTHON_CLASS_NAME = "AvdStructuredConfig" - -PLUGIN_NAME = "arista.avd.yaml_templates_to_facts" - -try: - from pyavd._eos_designs.avdfacts import AvdFacts - from pyavd._eos_designs.shared_utils import SharedUtils - from pyavd._errors import AristaAvdMissingVariableError - from pyavd._utils import get, load_python_class, merge, strip_null_from_data - from pyavd._utils import template as templater -except ImportError as e: - AvdFacts = SharedUtils = get = load_python_class = merge = RaiseOnUse( - AnsibleActionFail( - f"The '{PLUGIN_NAME}' plugin requires the 'pyavd' Python library. Got import error", - orig_exc=e, - ) - ) - - -class ActionModule(ActionBase): - def run(self, tmp=None, task_vars=None): - if task_vars is None: - task_vars = {} - - result = super().run(tmp, task_vars) - del tmp # tmp no longer has any effect - - root_key = "" - - if self._task.args: - cprofile_file = self._task.args.get("cprofile_file") - if cprofile_file: - profiler = cProfile.Profile() - profiler.enable() - - if "root_key" in self._task.args: - n = self._task.args.get("root_key") - n = self._templar.template(n) - if not isidentifier(n): - raise AnsibleActionFail( - f"The argument 'root_key' value of '{n}' is not valid. Keys must start with a letter or underscore character, " - "and contain only letters, numbers and underscores." - ) - root_key = n - - template_list = self._task.args.get("templates") - if not isinstance(template_list, list): - raise AnsibleActionFail("The argument 'templates' must be set as a list") - - schema = self._task.args.get("schema") - schema_id = self._task.args.get("schema_id") - self.dest = self._task.args.get("dest", False) - template_output = self._task.args.get("template_output", False) - debug = self._task.args.get("debug", False) - conversion_mode = self._task.args.get("conversion_mode") - validation_mode = self._task.args.get("validation_mode") - output_schema = self._task.args.get("output_schema") - output_schema_id = self._task.args.get("output_schema_id") - set_switch_fact = self._task.args.get("set_switch_fact", True) - - else: - raise AnsibleActionFail("The argument 'templates' must be set") - - hostname = task_vars["inventory_hostname"] - - if set_switch_fact: - task_vars["switch"] = get(task_vars, f"avd_switch_facts..{hostname}..switch", separator="..", default={}) - - # Read ansible variables and perform templating to support inline jinja2 - for var in task_vars: - if str(var).startswith(("ansible", "molecule", "hostvars", "vars", "avd_switch_facts")): - continue - if self._templar.is_template(task_vars[var]): - # Var contains a jinja2 template. - try: - task_vars[var] = self._templar.template(task_vars[var], fail_on_undefined=False) - except Exception as e: - raise AnsibleActionFail(f"Exception during templating of task_var '{var}'") from e - - # Get updated templar instance to be passed along to our simplified "templater" - self.templar = get_templar(self, task_vars) - - # If the argument 'root_key' is set, output will be assigned to this variable. If not set, the output will be set at as "root" variables. - # We use ChainMap to avoid copying large amounts of data around, mapping in - # - output or { root_key: output } - # - templated version of all other vars - # Any var assignments will end up in output, so all other objects are protected. - output = {} - if root_key: - template_vars = ChainMap({root_key: output}, task_vars) - else: - template_vars = ChainMap(output, task_vars) - - # Initialize SharedUtils class to be passed to each python_module below. - shared_utils = SharedUtils(hostvars=template_vars, templar=self.templar) - - if schema or schema_id: - # Insert dynamic keys into the input data if not set. - # These keys are required by the schema, but the default values are set inside shared_utils. - task_vars.setdefault("node_type_keys", shared_utils.node_type_keys) - task_vars.setdefault("connected_endpoints_keys", shared_utils.connected_endpoints_keys) - task_vars.setdefault("network_services_keys", shared_utils.network_services_keys) - - # Load schema tools and perform conversion and validation - avdschematools = AvdSchemaTools( - hostname=hostname, - ansible_display=display, - schema=schema, - schema_id=schema_id, - conversion_mode=conversion_mode, - validation_mode=validation_mode, - plugin_name=task_vars["ansible_role_name"], - ) - result.update(avdschematools.convert_and_validate_data(task_vars)) - if result.get("failed"): - # Input data validation failed so return errors. - return result - - if output_schema or output_schema_id: - output_avdschematools = AvdSchemaTools( - hostname=hostname, - ansible_display=display, - schema=output_schema, - schema_id=output_schema_id, - conversion_mode=conversion_mode, - validation_mode=validation_mode, - plugin_name=task_vars["ansible_role_name"], - ) - output_avdschema = output_avdschematools.avdschema - else: - output_avdschema = None - - # If the argument 'debug' is set, a 'avd_yaml_templates_to_facts_debug' list will be added to the output. - # This list contains timestamps from every step for every template. This is useful for identifying slow templates. - # Here we pull in the list from any previous tasks, so we can just add to the list. - if debug: - avd_yaml_templates_to_facts_debug = task_vars.get("avd_yaml_templates_to_facts_debug", []) - - # template_list can contain templates or python modules - for template_item in template_list: - if debug: - debug_item = template_item - debug_item["timestamps"] = {"starting": datetime.now()} - - template_options = template_item.get("options", {}) - list_merge = template_options.get("list_merge", "append_rp") - - strip_empty_keys = template_options.get("strip_empty_keys", True) - - if "template" in template_item: - template = template_item["template"] - - if debug: - debug_item["timestamps"]["run_template"] = datetime.now() - - # Here we parse the template, expecting the result to be a YAML formatted string - template_result = templater(template, template_vars, self.templar) - - if debug: - debug_item["timestamps"]["load_yaml"] = datetime.now() - - # Load data from the template result. - template_result_data = yaml.safe_load(template_result) - - # If the argument 'strip_empty_keys' is set, remove keys with value of null / None from the resulting dict (recursively). - if strip_empty_keys: - if debug: - debug_item["timestamps"]["strip_empty_keys"] = datetime.now() - - template_result_data = strip_null_from_data(template_result_data) - - elif "python_module" in template_item: - module_path = template_item.get("python_module") - class_name = template_item.get("python_class_name", DEFAULT_PYTHON_CLASS_NAME) - try: - cls = load_python_class(module_path, class_name, AvdFacts) - except AristaAvdMissingVariableError as exc: - raise AnsibleActionFail(f"Missing module_path or class_name in {template_item}") from exc - - cls_instance = cls(hostvars=template_vars, shared_utils=shared_utils) - - if debug: - debug_item["timestamps"]["render_python_class"] = datetime.now() - - if not (getattr(cls_instance, "render")): - raise AnsibleActionFail(f"{cls_instance} has no attribute render") - - try: - template_result_data = cls_instance.render() - except Exception as error: - raise AnsibleActionFail(message=str(error)) from error - - else: - raise AnsibleActionFail("Invalid template data") - - # If there is any data produced by the template, convert and merge it on top of previous output. - if template_result_data: - # Some modules/templates return a list of dicts, others only return a dict. Here we normalize to list. - if not isinstance(template_result_data, list): - template_result_data = [template_result_data] - - # If output_schema is set, perform inplace conversion of each returned dict according to output_schema - # to normalize the data to correct format before merging - if output_avdschema: - if debug: - debug_item["timestamps"]["data_conversion_from_schema"] = datetime.now() - - for result_item in template_result_data: - output_avdschematools.convert_data(result_item) - - if debug: - debug_item["timestamps"]["combine_data"] = datetime.now() - - merge(output, *template_result_data, list_merge=list_merge, schema=output_avdschema) - - if debug: - debug_item["timestamps"]["done"] = datetime.now() - avd_yaml_templates_to_facts_debug.append(debug_item) - - # If the argument 'template_output' is set, run the output data through another jinja2 rendering. - # This is to resolve any input values with inline jinja using variables/facts set by the input templates. - if template_output: - if debug: - debug_item = {"action": "template_output", "timestamps": {"templating": datetime.now()}} - - with self._templar.set_temporary_context(available_variables=template_vars): - output = self._templar.template(output, fail_on_undefined=False) - - if debug: - debug_item["timestamps"]["done"] = datetime.now() - avd_yaml_templates_to_facts_debug.append(debug_item) - - # If the argument 'dest' is set, write the output data to a file. - if self.dest: - if debug: - debug_item = {"action": "dest", "dest": self.dest, "timestamps": {"write_file": datetime.now()}} - - # Depending on the file suffix of 'dest' (default: 'json') we will format the data to yaml or just write the output data directly. - # The Copy module used in 'write_file' will convert the output data to json automatically. - if self.dest.split(".")[-1] in ["yml", "yaml"]: - write_file_result = self.write_file(yaml.dump(output, Dumper=AnsibleDumper, indent=2, sort_keys=False, width=130), task_vars) - else: - write_file_result = self.write_file(output, task_vars) - - # Overwrite result with the result from the copy operation (setting 'changed' flag accordingly) - result.update(write_file_result) - - if debug: - debug_item["timestamps"]["done"] = datetime.now() - avd_yaml_templates_to_facts_debug.append(debug_item) - - # If 'dest' is not set, hardcode 'changed' to true, since we don't know if something changed and later tasks may depend on this. - else: - result["changed"] = True - - if debug: - output["avd_yaml_templates_to_facts_debug"] = avd_yaml_templates_to_facts_debug - - # If the argument 'root_key' is set, output will be assigned to this variable. If not set, the output will be set at as "root" variables. - if root_key: - result["ansible_facts"] = {root_key: output} - else: - result["ansible_facts"] = output - - if set_switch_fact: - result["ansible_facts"]["switch"] = task_vars.get("switch") - - if cprofile_file: - profiler.disable() - stats = pstats.Stats(profiler).sort_stats("cumtime") - stats.dump_stats(cprofile_file) - - return result - - def write_file(self, content, task_vars): - """ - This function implements the Ansible 'copy' action_module, to benefit from Ansible builtin functionality like 'changed'. - Reuse task data - """ - new_task = self._task.copy() - new_task.args = { - "dest": self.dest, - "mode": self._task.args.get("mode"), - "content": content, - } - - copy_action = self._shared_loader_obj.action_loader.get( - "ansible.legacy.copy", - task=new_task, - connection=self._connection, - play_context=self._play_context, - loader=self._loader, - templar=self._templar, - shared_loader_obj=self._shared_loader_obj, - ) - - return copy_action.run(task_vars=task_vars) diff --git a/ansible_collections/arista/avd/plugins/filter/deprecated_filters.py b/ansible_collections/arista/avd/plugins/filter/deprecated_filters.py deleted file mode 100644 index 2d587cf139f..00000000000 --- a/ansible_collections/arista/avd/plugins/filter/deprecated_filters.py +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright (c) 2023-2024 Arista Networks, Inc. -# Use of this source code is governed by the Apache License 2.0 -# that can be found in the LICENSE file. -# -# deprecated filters - grouped together to avoid Ansible to generate warning on loading the module name... -# - -__metaclass__ = type - -from ansible.errors import AnsibleFilterError - -from ansible_collections.arista.avd.plugins.plugin_utils.pyavd_wrappers import RaiseOnUse, wrap_filter - -PLUGIN_NAME_1 = "arista.avd.generate_lacp_id" -PLUGIN_NAME_2 = "arista.avd.generate_esi" -PLUGIN_NAME_3 = "arista.avd.generate_route_target" - -try: - from pyavd.j2filters import generate_esi, generate_lacp_id, generate_route_target -except ImportError as e: - generate_lacp_id = RaiseOnUse( - AnsibleFilterError( - f"The '{PLUGIN_NAME_1}' plugin requires the 'pyavd' Python library. Got import error", - orig_exc=e, - ) - ) - generate_esi = RaiseOnUse( - AnsibleFilterError( - f"The '{PLUGIN_NAME_2}' plugin requires the 'pyavd' Python library. Got import error", - orig_exc=e, - ) - ) - generate_route_target = RaiseOnUse( - AnsibleFilterError( - f"The '{PLUGIN_NAME_3}' plugin requires the 'pyavd' Python library. Got import error", - orig_exc=e, - ) - ) - - -class FilterModule(object): - def filters(self): - return { - "generate_lacp_id": wrap_filter(PLUGIN_NAME_1)(generate_lacp_id), - "generate_esi": wrap_filter(PLUGIN_NAME_2)(generate_esi), - "generate_route_target": wrap_filter(PLUGIN_NAME_3)(generate_route_target), - } diff --git a/ansible_collections/arista/avd/plugins/filter/generate_esi.yml b/ansible_collections/arista/avd/plugins/filter/generate_esi.yml deleted file mode 100644 index f4acbd5508b..00000000000 --- a/ansible_collections/arista/avd/plugins/filter/generate_esi.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- -DOCUMENTATION: - name: generate_esi - collection: arista.avd - author: Arista Ansible Team (@aristanetworks) - version_added: "1.1" - short_description: Transforms short_esi `0303:0202:0101` to EVPN ESI format `0000:0000:0303:0202:0101` - description: Concatenates the given `esi_prefix` and `short_esi`. - positional: _input - options: - _input: - description: Short ESI value as per AVD definition in eos_designs. - type: string - required: true - esi_prefix: - description: ESI prefix value. Will be concatenated with the `short_esi`. - type: string - default: "0000:0000:" - deprecated: - removed_in: "5.0.0" - why: This filter is no longer used by AVD and is very simple to replace with generic Jinja syntax. - alternative: Use Jinja string concatenation instead like `{{ ~ }}` - -EXAMPLES: | - --- - esi: "{{ short_esi | arista.avd.generate_esi('deaf:beed:') }}" - -RETURN: - _value: - description: Concatenated string of `esi_prefix` and `short_esi` like `0000:0000:0303:0202:0101` - type: string diff --git a/ansible_collections/arista/avd/plugins/filter/generate_lacp_id.yml b/ansible_collections/arista/avd/plugins/filter/generate_lacp_id.yml deleted file mode 100644 index 2d19f51297f..00000000000 --- a/ansible_collections/arista/avd/plugins/filter/generate_lacp_id.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -DOCUMENTATION: - name: generate_lacp_id - collection: arista.avd - author: Arista Ansible Team (@aristanetworks) - version_added: "1.1" - short_description: Transforms short_esi `0303:0202:0101` to LACP ID format `0303.0202.0101` - description: Replaces `:` with `.` - positional: _input - options: - _input: - description: Short ESI value as per AVD definition in eos_designs. - type: string - required: true - deprecated: - removed_in: "5.0.0" - why: This filter is no longer used by AVD and is very simple to replace with a generic Jinja filter. - alternative: Use the builtin `replace` filter instead like `{{ | replace(':', '.') }}` - -EXAMPLES: |- - --- - lacp_id: "{{ short_esi | arista.avd.generate_lacp_id }}" - -RETURN: - _value: - description: String based on LACP ID format like 0303.0202.0101 - type: string diff --git a/ansible_collections/arista/avd/plugins/filter/generate_route_target.yml b/ansible_collections/arista/avd/plugins/filter/generate_route_target.yml deleted file mode 100644 index 0dbe48afda9..00000000000 --- a/ansible_collections/arista/avd/plugins/filter/generate_route_target.yml +++ /dev/null @@ -1,29 +0,0 @@ ---- -DOCUMENTATION: - name: generate_route_target - collection: arista.avd - author: Arista Ansible Team (@aristanetworks) - version_added: "1.1" - short_description: Transforms short_esi `0303:0202:0101` to route-target format `03:03:02:02:01:01` - description: Removes `:` and inserts new `:` for each two characters. - positional: _input - options: - _input: - description: Short ESI value as per AVD definition in eos_designs. - type: string - required: true - deprecated: - removed_in: "5.0.0" - why: This filter is no longer used by AVD and is very simple to replace with a generic Jinja filter. - alternative: |- - Use the builtin `ansible.builtin.regex_replace` filter instead like - `{{ | ansible.builtin.regex_replace('(\\d{2})(\\d{2}):(\\d{2})(\\d{2}):(\\d{2})(\\d{2})', '\\1:\\2:\\3:\\4:\\5:\\6') }}` - -EXAMPLES: |- - --- - rt: "{{ short_esi | arista.avd.generate_route_target }}" - -RETURN: - _value: - description: String based on route-target format like 03:03:02:02:01:01 - type: string diff --git a/ansible_collections/arista/avd/plugins/modules/_emit_warning.py b/ansible_collections/arista/avd/plugins/modules/_emit_warning.py deleted file mode 100644 index 5acc1ab983b..00000000000 --- a/ansible_collections/arista/avd/plugins/modules/_emit_warning.py +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright (c) 2024 Arista Networks, Inc. -# Use of this source code is governed by the Apache License 2.0 -# that can be found in the LICENSE file. -DOCUMENTATION = r""" ---- -module: _emit_warning -version_added: "4.9.0" -author: Arista Networks (@aristanetworks) -short_description: Internal module - DO NOT USE - Emit a warning in a task. -description: - - Emit a warning in a task. -options: - message: - description: The warning message to emit. - type: str -""" - -EXAMPLES = r""" ---- -- name: Emit a warning - arista.avd._emit_warning: - message |- - The warning message. - delegate_to: localhost - check_mode: false - run_once: true - changed_when: false -""" diff --git a/ansible_collections/arista/avd/plugins/modules/batch_template.py b/ansible_collections/arista/avd/plugins/modules/batch_template.py deleted file mode 100644 index 60c196845d9..00000000000 --- a/ansible_collections/arista/avd/plugins/modules/batch_template.py +++ /dev/null @@ -1,43 +0,0 @@ -# Copyright (c) 2021-2024 Arista Networks, Inc. -# Use of this source code is governed by the Apache License 2.0 -# that can be found in the LICENSE file. - -DOCUMENTATION = r""" ---- -module: batch_template -version_added: "4.0.0" -author: Arista Ansible Team (@aristanetworks) -short_description: Render Jinja2 template on multiple items and write result to individual files. -description: - - Render Jinja2 template on multiple items and write result to individual files. - - Destination file mode is hardcoded to 0o664. -options: - template: - description: Path to Jinja2 Template file - required: true - type: str - dest_format_string: - description: Format string used to specify target file for each item. 'item' is the current item from 'items'. Like "mypath/{item}.md" - required: true - type: str - items: - description: List of strings. Each list item is passed to 'dest_format_string' as 'item' and passed to templater as 'item' - required: true - type: list - elements: str -deprecated: - removed_in: "5.0.0" - why: The internal 'arista.avd.batch_template' action plugin is no longer used by AVD. - alternative: The plugin is released as open source, so it can be copied and reused according to the license and copyright. -""" - -EXAMPLES = r""" -- name: Output eos_cli_config_gen Documentation - tags: [eos_cli_config_gen] - delegate_to: localhost - run_once: true - arista.avd.batch_template: - template: avd_schema_documentation.j2 - dest_format_str: "{{ role_documentation_dir }}/{item}.md" - items: "{{ data_in_list_form }}" -""" diff --git a/ansible_collections/arista/avd/plugins/modules/validate_and_template.py b/ansible_collections/arista/avd/plugins/modules/validate_and_template.py deleted file mode 100644 index f8a7a53b64b..00000000000 --- a/ansible_collections/arista/avd/plugins/modules/validate_and_template.py +++ /dev/null @@ -1,104 +0,0 @@ -# Copyright (c) 2021-2024 Arista Networks, Inc. -# Use of this source code is governed by the Apache License 2.0 -# that can be found in the LICENSE file. - -DOCUMENTATION = r""" ---- -module: validate_and_template -version_added: "3.8.0" -author: Arista Ansible Team (@aristanetworks) -short_description: Validate input data according to Schema, render Jinja2 template and write result to a file. -description: - - The `arista.avd.validate_and_template` Action Plugin performs data conversions and validation according to the supplied Schema. - - The converted data is then used to render a Jinja2 template and writing the result to a file. - - The Action Plugin supports different modes for conversion and validation, to either block the playbook or just warn the user if - the input data is not valid. - - For Markdown files the plugin can also run md_toc on the output before writing to the file. -options: - template: - description: Path to Jinja2 Template file - required: true - type: str - dest: - description: Destination path. The rendered template will be written to this file - required: true - type: str - mode: - description: File mode for dest file. - required: false - type: str - schema: - description: Schema conforming to "AVD Meta Schema". Either schema or schema_id must be set. - required: false - type: dict - schema_id: - description: ID of Schema conforming to "AVD Meta Schema". Either schema or schema_id must be set. - required: false - type: str - choices: [ "eos_cli_config_gen", "eos_designs" ] - add_md_toc: - description: Run md_toc on the output before writing to the file. - required: false - type: bool - md_toc_skip_lines: - description: Pass this value as skip_lines to add_md_toc. - default: 0 - type: int - required: false - conversion_mode: - description: - - Run data conversion in either "warning", "info", "debug", "quiet" or "disabled" mode. - - Conversion will perform type conversion of input variables as defined in the schema. - - Conversion is intended to help the user to identify minor issues with the input data, while still allowing the data to be validated. - - During conversion, messages will generated with information about the host(s) and key(s) which required conversion. - - conversion_mode:disabled means that conversion will not run. - - conversion_mode:error will produce error messages and fail the task. - - conversion_mode:warning will produce warning messages. - - conversion_mode:info will produce regular log messages. - - conversion_mode:debug will produce hidden messages viewable with -v. - - conversion_mode:quiet will not produce any messages. - required: false - default: "debug" - type: str - choices: [ "warning", "info", "debug", "quiet", "disabled" ] - validation_mode: - description: - - Run validation in either "error", "warning", "info", "debug" or "disabled" mode. - - Validation will validate the input variables according to the schema. - - During validation, messages will generated with information about the host(s) and key(s) which failed validation. - - validation_mode:disabled means that validation will not run. - - validation_mode:error will produce error messages and fail the task. - - validation_mode:warning will produce warning messages. - - validation_mode:info will produce regular log messages. - - validation_mode:debug will produce hidden messages viewable with -v. - required: false - default: "warning" - type: str - choices: [ "error", "warning", "info", "debug", "disabled" ] - cprofile_file: - description: - - Filename for storing cprofile data used to debug performance issues. - - Running cprofile will slow down performance in itself, so only set this while troubleshooting. - required: false - type: str -deprecated: - removed_in: "5.0.0" - why: The internal 'arista.avd.validate_and_template' action plugin is no longer used by AVD. - alternative: The plugin is released as open source, so it can be copied and reused according to the license and copyright. -""" - -EXAMPLES = r""" -- name: Generate device documentation - tags: [build, provision, documentation] - arista.avd.validate_and_template: - template: "eos-device-documentation.j2" - dest: "{{ devices_dir }}/{{ inventory_hostname }}.md" - mode: "0o664" - schema: "{{ lookup('ansible.builtin.file', role_schema_path) | from_yaml }}" - conversion_mode: "{{ avd_data_conversion_mode }}" - validation_mode: "{{ avd_data_validation_mode }}" - add_md_toc: true - md_toc_skip_lines: 3 - delegate_to: localhost - when: generate_device_documentation | arista.avd.default(true) -""" diff --git a/ansible_collections/arista/avd/plugins/modules/yaml_templates_to_facts.py b/ansible_collections/arista/avd/plugins/modules/yaml_templates_to_facts.py deleted file mode 100644 index 727701625c9..00000000000 --- a/ansible_collections/arista/avd/plugins/modules/yaml_templates_to_facts.py +++ /dev/null @@ -1,154 +0,0 @@ -# Copyright (c) 2021-2024 Arista Networks, Inc. -# Use of this source code is governed by the Apache License 2.0 -# that can be found in the LICENSE file. - -DOCUMENTATION = r""" ---- -module: yaml_templates_to_facts -version_added: "1.0.0" -author: EMEA AS Team (@aristanetworks) -short_description: Set facts from YAML via Jinja2 templates -description: - - Set facts from YAML produced by Jinja2 templates -options: - root_key: - description: Root key under which the facts will be defined. If not set the facts well be set directly on root level. - required: false - type: str - schema: - description: Schema conforming to "AVD Meta Schema". Either schema or schema_id must be set. - required: false - type: dict - schema_id: - description: ID of Schema conforming to "AVD Meta Schema". Either schema or schema_id must be set. - required: false - type: str - choices: [ "eos_cli_config_gen", "eos_designs" ] - templates: - description: List of dicts for Jinja templates to be run. - required: true - type: list - elements: dict - suboptions: - template: - description: Template file. Either template or python_module must be set. - required: false - type: str - python_module: - description: Python module to import. Either template or python_module must be set. - required: false - type: str - python_class_name: - description: Name of Python Class to import. - required: false - type: str - default: "AvdStructuredConfig" - options: - description: Template options. - required: false - type: dict - suboptions: - list_merge: - description: Merge strategy for lists - required: false - default: 'append' - type: str - strip_empty_keys: - description: Filter out keys from the generated output if value is null/none/undefined. Only applies to templates. - required: false - default: true - type: bool - debug: - description: Output list 'avd_yaml_templates_to_facts_debug' with timestamps of each performed action. - required: false - type: bool - dest: - description: - - Destination path. If set, the output facts will also be written to this path. - - Autodetects data format based on file suffix. '.yml', '.yaml' -> YAML, default -> JSON - required: false - type: str - mode: - description: File mode (ex. "0o664") for dest file. See 'ansible.builtin.copy' module for details. - required: false - type: str - template_output: - description: - - If true, the output data will be run through another jinja2 rendering before returning. - - This is to resolve any input values with inline jinja using variables/facts set by the input templates. - required: false - type: bool - conversion_mode: - description: - - Run data conversion in either "error", "warning", "info", "debug", "quiet" or "disabled" mode. - - Conversion will perform type conversion of input variables as defined in the schema. - - Conversion is intended to help the user to identify minor issues with the input data, while still allowing the data to be validated. - - During conversion, messages will be generated with information about the host(s) and key(s) which required conversion. - - conversion_mode:disabled means that conversion will not run. - - conversion_mode:error will produce error messages and fail the task. - - conversion_mode:warning will produce warning messages. - - conversion_mode:info will produce regular log messages. - - conversion_mode:debug will produce hidden messages viewable with -v. - - conversion_mode:quiet will not produce any messages. - required: false - default: "debug" - type: str - choices: [ "error", "warning", "info", "debug", "quiet", "disabled" ] - validation_mode: - description: - - Run validation in either "error", "warning", "info", "debug" or "disabled" mode. - - Validation will validate the input variables according to the schema. - - During validation, messages will be generated with information about the host(s) and key(s) which failed validation. - - validation_mode:disabled means that validation will not run. - - validation_mode:error will produce error messages and fail the task. - - validation_mode:warning will produce warning messages. - - validation_mode:info will produce regular log messages. - - validation_mode:debug will produce hidden messages viewable with -v. - required: false - default: "warning" - type: str - choices: [ "error", "warning", "info", "debug", "disabled" ] - output_schema: - description: AVD Schema for output data. Used for automatic merge of data. - required: false - type: dict - output_schema_id: - description: ID of AVD Schema for output data. Used for automatic merge of data. - required: false - type: str - choices: [ "eos_cli_config_gen", "eos_designs" ] - set_switch_fact: - description: - - Set "switch" fact from on "avd_switch_facts..switch" - required: false - type: bool - default: true -deprecated: - removed_in: "5.0.0" - why: The internal 'arista.avd.yaml_templates_to_facts' action plugin is no longer used by AVD. - alternative: The plugin is released as open source, so it can be copied and reused according to the license and copyright. -""" - -EXAMPLES = r""" ---- -- name: Generate device configuration in structured format - arista.avd.yaml_templates_to_facts: - root_key: structured_config - templates: - - python_module: "pyavd._eos_designs.structured_config.base" - python_class_name: "AvdStructuredConfig" - - template: "mlag/main.j2" - - template: "designs/underlay/main.j2" - - template: "designs/overlay/main.j2" - - template: "l3_edge/main.j2" - - template: "designs/network_services/main.j2" - - template: "connected_endpoints/main.j2" - - template: "custom-structured-configuration-from-var.j2" - options: - list_merge: "{{ custom_structured_configuration_list_merge }}" - strip_empty_keys: false - schema_id: eos_designs - output_schema_id: eos_cli_config_gen - check_mode: no - changed_when: False -""" diff --git a/ansible_collections/arista/avd/tests/integration/targets/cv_zscaler_endpoints/tasks/main.yml b/ansible_collections/arista/avd/tests/integration/targets/cv_zscaler_endpoints/tasks/main.yml deleted file mode 100644 index 19797c0b9dd..00000000000 --- a/ansible_collections/arista/avd/tests/integration/targets/cv_zscaler_endpoints/tasks/main.yml +++ /dev/null @@ -1,62 +0,0 @@ ---- -- name: Test cv_zscaler_endpoints lookup plugin - tags: [always] - delegate_to: localhost - when: cv_token is arista.avd.defined - vars: - # This is not working with ansible-test, so adjust for manual testing. - cv_token: "{{ lookup(ansible.builtin.env, 'CV_TOKEN') }}" - cv_server: "www.cv-play.corp.arista.io" - serial_number: ABCD1234 - fabric_name: Test - type: wan_router - wan_router: - nodes: - - name: testhost - cv_pathfinder_region: REGION1 - cv_pathfinder_site: SITE1 - cv_pathfinder_regions: - - name: REGION1 - id: 1 - sites: - - name: SITE1 - id: 1 - location: Copenhagen, Denmark - expected_output: - cloud_name: zscalerbeta - device_location: - city: "" - country: "" - latitude: 55.67531204223633 - longitude: 12.569733619689941 - primary: - city: Frankfurt - country: Germany - datacenter: FRA4 - ip_address: 165.225.72.39 - latitude: 50.0 - longitude: 9.0 - secondary: - city: Washington, DC - country: United States - datacenter: WAS1 - ip_address: 104.129.194.39 - latitude: 39.0 - longitude: -77.0 - tertiary: - city: Fremont, CA - country: United States - datacenter: FMT1 - ip_address: 199.168.148.132 - latitude: 37.0 - longitude: -121.0 - - block: - - name: Print output - ansible.builtin.debug: - msg: "{{ lookup('arista.avd.cv_zscaler_endpoints') }}" - - - name: Assert output - ansible.builtin.assert: - that: - - lookup('arista.avd.cv_zscaler_endpoints') == expected_output diff --git a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/defaults/main.yaml b/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/defaults/main.yaml deleted file mode 100644 index 6508c396048..00000000000 --- a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/defaults/main.yaml +++ /dev/null @@ -1,5 +0,0 @@ ---- -testcase: '*' -collection_path: "{{ lookup('env', 'ANSIBLE_COLLECTIONS_PATH') }}/ansible_collections/arista/avd/tests" -expected_output_dir: "{{ collection_path }}/inventory/yaml_templates_to_facts/expected_output" -actual_output_dir: "{{ collection_path }}/output" diff --git a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tasks/main.yml b/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tasks/main.yml deleted file mode 100644 index f8e0714120c..00000000000 --- a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tasks/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -- name: Include test.yml - ansible.builtin.include_tasks: test.yml diff --git a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tasks/test.j2 b/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tasks/test.j2 deleted file mode 100644 index f4775b66425..00000000000 --- a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tasks/test.j2 +++ /dev/null @@ -1,9 +0,0 @@ -{# - Copyright (c) 2023-2024 Arista Networks, Inc. - Use of this source code is governed by the Apache License 2.0 - that can be found in the LICENSE file. -#} -{% if timezone is defined %} -clock: - timezone: {{ timezone }} -{% endif %} diff --git a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tasks/test.yml b/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tasks/test.yml deleted file mode 100644 index 044f572f9fc..00000000000 --- a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tasks/test.yml +++ /dev/null @@ -1,16 +0,0 @@ -- name: Collect all test cases - ansible.builtin.find: - paths: '{{ role_path }}/tests/' - patterns: '{{ testcase }}.yml' - register: test_cases - delegate_to: localhost - -- name: Set test_items - ansible.builtin.set_fact: - test_items: "{{ test_cases.files | map(attribute='path') | list }}" - -- name: Run test cases - ansible.builtin.include_tasks: '{{ test_case_to_run }}' - with_items: '{{ test_items }}' - loop_control: - loop_var: test_case_to_run diff --git a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/error_invalid_merge_option.txt b/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/error_invalid_merge_option.txt deleted file mode 100644 index 59791608a28..00000000000 --- a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/error_invalid_merge_option.txt +++ /dev/null @@ -1 +0,0 @@ -"Unexpected failure during module execution: merge: 'list_merge' argument can only be equal to one of ['replace', 'keep', 'append', 'prepend', 'append_rp', 'prepend_rp']" diff --git a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/templates/inline_jinja.j2 b/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/templates/inline_jinja.j2 deleted file mode 100644 index 1b6d1d53c88..00000000000 --- a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/templates/inline_jinja.j2 +++ /dev/null @@ -1,16 +0,0 @@ -{# - Copyright (c) 2023-2024 Arista Networks, Inc. - Use of this source code is governed by the Apache License 2.0 - that can be found in the LICENSE file. -#} -{# This is an attempt to emulate the case we have in eos_designs, #} -{# where you can supply inline jinja as a custom_structured_configuration_ group_var. #} -{# This is not the exact same scenario, but it has not been possible to find another #} - -{% set inline_jinja = "{{ key_1 }}" %} - -key_1: "value_1" - -key_2: "{{ inline_jinja }}" - -{# The output will be the jinja expression, so we need to run this through another templater. #} diff --git a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/templates/template.j2 b/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/templates/template.j2 deleted file mode 100644 index 87dbab242d2..00000000000 --- a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/templates/template.j2 +++ /dev/null @@ -1,12 +0,0 @@ -{# - Copyright (c) 2023-2024 Arista Networks, Inc. - Use of this source code is governed by the Apache License 2.0 - that can be found in the LICENSE file. -#} -{% set mylist = [1, 1, 2, 3] %} -{% if timezone is defined %} -clock: - timezone: {{ timezone }} - hours: {{ hours }} - seconds: {{ mylist }} -{% endif %} diff --git a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/templates/template1.j2 b/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/templates/template1.j2 deleted file mode 100644 index 2a3922f45f4..00000000000 --- a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/templates/template1.j2 +++ /dev/null @@ -1,12 +0,0 @@ -{# - Copyright (c) 2023-2024 Arista Networks, Inc. - Use of this source code is governed by the Apache License 2.0 - that can be found in the LICENSE file. -#} -{% set mylist = [3, 4, 5, 5] %} -{% if timezone is defined %} -clock: - timezone: "test1" - minutes: 30 - seconds: {{ mylist }} -{% endif %} diff --git a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_debug.yml b/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_debug.yml deleted file mode 100644 index bfc5886f23b..00000000000 --- a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_debug.yml +++ /dev/null @@ -1,28 +0,0 @@ -- name: Test with debug - ignore_errors: no - vars: - timezone: "test" - hours: 36 - register: result - arista.avd.yaml_templates_to_facts: - debug: true - templates: - - template: "templates/template.j2" - -- assert: - that: - - result is success - - result.changed == true - - result.ansible_facts is defined - - result.ansible_facts.avd_yaml_templates_to_facts_debug is defined - # avd_yaml_templates_to_facts_debug could have been set by a previous test, so we accept a longer list and test only on the last element - - result.ansible_facts.avd_yaml_templates_to_facts_debug | length >= 1 - - result.ansible_facts.avd_yaml_templates_to_facts_debug[-1].timestamps is defined - - result.ansible_facts.avd_yaml_templates_to_facts_debug[-1].template is defined - - result.ansible_facts.avd_yaml_templates_to_facts_debug[-1].template == "templates/template.j2" - - result.ansible_facts.avd_yaml_templates_to_facts_debug[-1].timestamps.starting is defined - - result.ansible_facts.avd_yaml_templates_to_facts_debug[-1].timestamps.run_template is defined - - result.ansible_facts.avd_yaml_templates_to_facts_debug[-1].timestamps.load_yaml is defined - - result.ansible_facts.avd_yaml_templates_to_facts_debug[-1].timestamps.strip_empty_keys is defined - - result.ansible_facts.avd_yaml_templates_to_facts_debug[-1].timestamps.combine_data is defined - - result.ansible_facts.avd_yaml_templates_to_facts_debug[-1].timestamps.done is defined diff --git a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_debug_dest.yml b/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_debug_dest.yml deleted file mode 100644 index 7b2748abbad..00000000000 --- a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_debug_dest.yml +++ /dev/null @@ -1,27 +0,0 @@ -- name: Test with debug and dest - ignore_errors: no - vars: - timezone: "test" - hours: 36 - register: result - arista.avd.yaml_templates_to_facts: - dest: "{{ actual_output_dir }}/yaml_templates_to_facts_test_with_dest.yml" - debug: true - templates: - - template: "templates/template.j2" - -- ansible.builtin.assert: - that: - - result is success - - result.ansible_facts is defined - - result.ansible_facts.clock is defined - - result.ansible_facts.avd_yaml_templates_to_facts_debug is defined - # avd_yaml_templates_to_facts_debug could have been set by a previous test, so we accept a longer list and test only on the last element - - result.ansible_facts.avd_yaml_templates_to_facts_debug | length >= 2 - - result.ansible_facts.avd_yaml_templates_to_facts_debug[-1].action is defined - - result.ansible_facts.avd_yaml_templates_to_facts_debug[-1].action == 'dest' - - result.ansible_facts.avd_yaml_templates_to_facts_debug[-1].dest is defined - - result.ansible_facts.avd_yaml_templates_to_facts_debug[-1].dest == actual_output_dir ~ "/yaml_templates_to_facts_test_with_dest.yml" - - result.ansible_facts.avd_yaml_templates_to_facts_debug[-1].timestamps is defined - - result.ansible_facts.avd_yaml_templates_to_facts_debug[-1].timestamps.write_file is defined - - result.ansible_facts.avd_yaml_templates_to_facts_debug[-1].timestamps.done is defined diff --git a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_debug_template_output.yml b/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_debug_template_output.yml deleted file mode 100644 index d452bbf3488..00000000000 --- a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_debug_template_output.yml +++ /dev/null @@ -1,24 +0,0 @@ -- name: Test with debug and template_output - ignore_errors: no - register: result - arista.avd.yaml_templates_to_facts: - template_output: true - debug: true - templates: - - template: "templates/inline_jinja.j2" - -- assert: - that: - - result is success - - result.changed == true - - result.ansible_facts is defined - - result.ansible_facts.key_1 is defined - - result.ansible_facts.key_2 is defined - - result.ansible_facts.avd_yaml_templates_to_facts_debug is defined - # avd_yaml_templates_to_facts_debug could have been set by a previous test, so we accept a longer list and test only on the last element - - result.ansible_facts.avd_yaml_templates_to_facts_debug | length >= 2 - - result.ansible_facts.avd_yaml_templates_to_facts_debug[-1].action is defined - - result.ansible_facts.avd_yaml_templates_to_facts_debug[-1].action == 'template_output' - - result.ansible_facts.avd_yaml_templates_to_facts_debug[-1].timestamps is defined - - result.ansible_facts.avd_yaml_templates_to_facts_debug[-1].timestamps.templating is defined - - result.ansible_facts.avd_yaml_templates_to_facts_debug[-1].timestamps.done is defined diff --git a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_dest_changed.yml b/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_dest_changed.yml deleted file mode 100644 index e11e83aa26b..00000000000 --- a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_dest_changed.yml +++ /dev/null @@ -1,31 +0,0 @@ -- name: Test with dest (no change) - Remove test file to force change in template action - ansible.builtin.file: - path: "{{ actual_output_dir }}/yaml_templates_to_facts_test_with_dest.yml" - state: absent - -- name: Test with dest (changing) - ignore_errors: no - vars: - timezone: "test" - hours: 36 - register: result - arista.avd.yaml_templates_to_facts: - dest: "{{ actual_output_dir }}/yaml_templates_to_facts_test_with_dest.yml" - templates: - - template: "templates/template.j2" - -- name: Compare actual output with expected output - ansible.builtin.shell: >- - diff "{{ expected_output_dir }}/yaml_templates_to_facts_test_with_dest.yml" - "{{ actual_output_dir }}/yaml_templates_to_facts_test_with_dest.yml" - failed_when: "diff_output.rc > 1" - register: diff_output - delegate_to: localhost - -- name: Validate result - ansible.builtin.assert: - that: - - result is success - - result.changed == true - - result.ansible_facts is defined - - result.ansible_facts.clock is defined diff --git a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_dest_json.yml b/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_dest_json.yml deleted file mode 100644 index 862b48893a8..00000000000 --- a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_dest_json.yml +++ /dev/null @@ -1,25 +0,0 @@ -- name: Test with dest and changed - ignore_errors: no - vars: - timezone: "test" - hours: 36 - register: result - arista.avd.yaml_templates_to_facts: - dest: "{{ actual_output_dir }}/yaml_templates_to_facts_test_with_dest.json" - templates: - - template: "templates/template.j2" - -- name: Compare actual output with expected output - ansible.builtin.shell: >- - diff "{{ expected_output_dir }}/yaml_templates_to_facts_test_with_dest.json" - "{{ actual_output_dir }}/yaml_templates_to_facts_test_with_dest.json" - failed_when: "diff_output.rc > 1" - register: diff_output - delegate_to: localhost - -- name: Validate result - ansible.builtin.assert: - that: - - result is success - - result.ansible_facts is defined - - result.ansible_facts.clock is defined diff --git a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_dest_no_change.yml b/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_dest_no_change.yml deleted file mode 100644 index e8a77efa136..00000000000 --- a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_dest_no_change.yml +++ /dev/null @@ -1,37 +0,0 @@ -- name: Test with dest (no change) - first run to ensure no change - ignore_errors: no - vars: - timezone: "test" - hours: 36 - register: result - arista.avd.yaml_templates_to_facts: - dest: "{{ actual_output_dir }}/yaml_templates_to_facts_test_with_dest.yml" - templates: - - template: "templates/template.j2" - -- name: Test with dest (no change) - ignore_errors: no - vars: - timezone: "test" - hours: 36 - register: result - arista.avd.yaml_templates_to_facts: - dest: "{{ actual_output_dir }}/yaml_templates_to_facts_test_with_dest.yml" - templates: - - template: "templates/template.j2" - -- name: Compare actual output with expected output - ansible.builtin.shell: >- - diff "{{ expected_output_dir }}/yaml_templates_to_facts_test_with_dest.yml" - "{{ actual_output_dir }}/yaml_templates_to_facts_test_with_dest.yml" - failed_when: "diff_output.rc > 1" - register: diff_output - delegate_to: localhost - -- name: Validate result - ansible.builtin.assert: - that: - - result is success - - result.changed == false - - result.ansible_facts is defined - - result.ansible_facts.clock is defined diff --git a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_list_merge_append.yml b/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_list_merge_append.yml deleted file mode 100644 index 7b5bc158c43..00000000000 --- a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_list_merge_append.yml +++ /dev/null @@ -1,29 +0,0 @@ -- name: Test with list_merge append option - ignore_errors: yes - register: result - vars: - timezone: "test" - hours: 84 - arista.avd.yaml_templates_to_facts: - templates: - - template: "templates/template.j2" - - template: "templates/template1.j2" - options: - strip_empty_keys: false - list_merge: 'append' - -- assert: - that: - - result is success - - result.changed == true - - result.ansible_facts is defined - - result.ansible_facts.clock is defined - - result.ansible_facts.clock.timezone is defined - - result.ansible_facts.clock.timezone == 'test1' - - result.ansible_facts.clock.hours is defined - - result.ansible_facts.clock.hours == 84 - - result.ansible_facts.clock.minutes is defined - - result.ansible_facts.clock.minutes == 30 - - result.ansible_facts.clock.seconds is defined - - result.ansible_facts.clock.seconds == [1, 1, 2, 3, 3, 4, 5, 5] - # TODO: Add checks for dictionary keys ordering diff --git a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_list_merge_append_rp.yml b/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_list_merge_append_rp.yml deleted file mode 100644 index 6b570236680..00000000000 --- a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_list_merge_append_rp.yml +++ /dev/null @@ -1,29 +0,0 @@ -- name: Test with list_merge append_rp option - ignore_errors: no - register: result - vars: - timezone: "test" - hours: 84 - arista.avd.yaml_templates_to_facts: - templates: - - template: "templates/template.j2" - - template: "templates/template1.j2" - options: - strip_empty_keys: false - list_merge: "append_rp" - -- assert: - that: - - result is success - - result.changed == true - - result.ansible_facts is defined - - result.ansible_facts.clock is defined - - result.ansible_facts.clock.timezone is defined - - result.ansible_facts.clock.timezone == 'test1' - - result.ansible_facts.clock.hours is defined - - result.ansible_facts.clock.hours == 84 - - result.ansible_facts.clock.minutes is defined - - result.ansible_facts.clock.minutes == 30 - - result.ansible_facts.clock.seconds is defined - - result.ansible_facts.clock.seconds == [1, 1, 2, 3, 4, 5, 5] - # TODO: Add checks for dictionary keys ordering diff --git a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_list_merge_invalid.yml b/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_list_merge_invalid.yml deleted file mode 100644 index 1b25dce4d17..00000000000 --- a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_list_merge_invalid.yml +++ /dev/null @@ -1,22 +0,0 @@ -- name: Test with list_merge invalid option - ignore_errors: yes - register: result - vars: - timezone: "test" - hours: 84 - arista.avd.yaml_templates_to_facts: - templates: - - template: "templates/template.j2" - - template: "templates/template1.j2" - options: - strip_empty_keys: false - list_merge: "append12" - -- vars: - error_msg: >- - Unexpected failure during module execution: merge: 'list_merge' argument can only be equal to one of - ['replace', 'keep', 'append', 'prepend', 'append_rp', 'prepend_rp'] - assert: - that: - - result.failed == True - - result.msg == error_msg diff --git a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_list_merge_keep.yml b/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_list_merge_keep.yml deleted file mode 100644 index afb50076d3c..00000000000 --- a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_list_merge_keep.yml +++ /dev/null @@ -1,30 +0,0 @@ -# Doubts in keep -- name: Test with list_merge keep option - ignore_errors: yes - register: result - vars: - timezone: "test" - hours: 84 - arista.avd.yaml_templates_to_facts: - templates: - - template: "templates/template.j2" - - template: "templates/template1.j2" - options: - strip_empty_keys: false - list_merge: 'keep' - -- assert: - that: - - result is success - - result.changed == true - - result.ansible_facts is defined - - result.ansible_facts.clock is defined - - result.ansible_facts.clock.timezone is defined - - result.ansible_facts.clock.timezone == 'test1' - - result.ansible_facts.clock.hours is defined - - result.ansible_facts.clock.hours == 84 - - result.ansible_facts.clock.minutes is defined - - result.ansible_facts.clock.minutes == 30 - - result.ansible_facts.clock.seconds is defined - - result.ansible_facts.clock.seconds == [1, 1, 2, 3] - # TODO: Add checks for dictionary keys ordering diff --git a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_list_merge_prepend.yml b/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_list_merge_prepend.yml deleted file mode 100644 index f9af2e43549..00000000000 --- a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_list_merge_prepend.yml +++ /dev/null @@ -1,29 +0,0 @@ -- name: Test with list_merge prepend option - ignore_errors: yes - register: result - vars: - timezone: "test" - hours: 84 - arista.avd.yaml_templates_to_facts: - templates: - - template: "templates/template.j2" - - template: "templates/template1.j2" - options: - strip_empty_keys: false - list_merge: "prepend" - -- assert: - that: - - result is success - - result.changed == true - - result.ansible_facts is defined - - result.ansible_facts.clock is defined - - result.ansible_facts.clock.timezone is defined - - result.ansible_facts.clock.timezone == 'test1' - - result.ansible_facts.clock.hours is defined - - result.ansible_facts.clock.hours == 84 - - result.ansible_facts.clock.minutes is defined - - result.ansible_facts.clock.minutes == 30 - - result.ansible_facts.clock.seconds is defined - - result.ansible_facts.clock.seconds == [3, 4, 5, 5, 1, 1, 2, 3] - # TODO: Add checks for dictionary keys ordering diff --git a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_list_merge_prepend_rp.yml b/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_list_merge_prepend_rp.yml deleted file mode 100644 index 16241fe13ff..00000000000 --- a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_list_merge_prepend_rp.yml +++ /dev/null @@ -1,29 +0,0 @@ -- name: Test with list_merge prepend_rp option - ignore_errors: no - register: result - vars: - timezone: "test" - hours: 84 - arista.avd.yaml_templates_to_facts: - templates: - - template: "templates/template.j2" - - template: "templates/template1.j2" - options: - strip_empty_keys: false - list_merge: "prepend_rp" - -- assert: - that: - - result is success - - result.changed == true - - result.ansible_facts is defined - - result.ansible_facts.clock is defined - - result.ansible_facts.clock.timezone is defined - - result.ansible_facts.clock.timezone == 'test1' - - result.ansible_facts.clock.hours is defined - - result.ansible_facts.clock.hours == 84 - - result.ansible_facts.clock.minutes is defined - - result.ansible_facts.clock.minutes == 30 - - result.ansible_facts.clock.seconds is defined - - result.ansible_facts.clock.seconds == [3, 4, 5, 5, 1, 1, 2] - # TODO: Add checks for dictionary keys ordering diff --git a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_list_merge_replace.yml b/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_list_merge_replace.yml deleted file mode 100644 index 0510a2dda9d..00000000000 --- a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_list_merge_replace.yml +++ /dev/null @@ -1,29 +0,0 @@ -- name: Test with list_merge replace option - ignore_errors: yes - register: result - vars: - timezone: "test" - hours: 84 - arista.avd.yaml_templates_to_facts: - templates: - - template: "templates/template.j2" - - template: "templates/template1.j2" - options: - strip_empty_keys: false - list_merge: 'replace' - -- assert: - that: - - result is success - - result.changed == true - - result.ansible_facts is defined - - result.ansible_facts.clock is defined - - result.ansible_facts.clock.timezone is defined - - result.ansible_facts.clock.timezone == 'test1' - - result.ansible_facts.clock.hours is defined - - result.ansible_facts.clock.hours == 84 - - result.ansible_facts.clock.minutes is defined - - result.ansible_facts.clock.minutes == 30 - - result.ansible_facts.clock.seconds is defined - - result.ansible_facts.clock.seconds == [3, 4, 5, 5] - # TODO: Add checks for dictionary keys ordering diff --git a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_root_key.yml b/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_root_key.yml deleted file mode 100644 index 146f4f3b0e3..00000000000 --- a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_root_key.yml +++ /dev/null @@ -1,24 +0,0 @@ -- name: Test with root_key parameter - ignore_errors: no - vars: - timezone: "test" - hours: - register: result - arista.avd.yaml_templates_to_facts: - root_key: structured_config - templates: - - template: "templates/template.j2" - -- assert: - that: - - result is success - - result.changed == true - - result.ansible_facts is defined - - result.ansible_facts.structured_config is defined - - result.ansible_facts.structured_config.clock is defined - - result.ansible_facts.structured_config.clock.timezone is defined - - result.ansible_facts.structured_config.clock.timezone == 'test' - - result.ansible_facts.structured_config.clock.hours is not defined - - result.ansible_facts.structured_config.clock.minutes is not defined - - result.ansible_facts.structured_config.clock.seconds is defined - - result.ansible_facts.structured_config.clock.seconds == [1, 1, 2, 3] diff --git a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_strip_empty_false.yml b/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_strip_empty_false.yml deleted file mode 100644 index 36c187b6eba..00000000000 --- a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_strip_empty_false.yml +++ /dev/null @@ -1,24 +0,0 @@ -- name: Test with strip_empty false - ignore_errors: yes - register: result - vars: - timezone: "test" - hours: - arista.avd.yaml_templates_to_facts: - templates: - - template: "templates/template.j2" - options: - strip_empty_keys: false - -- assert: - that: - - result is success - - result.changed == true - - result.ansible_facts is defined - - result.ansible_facts.clock is defined - - result.ansible_facts.clock.timezone is defined - - result.ansible_facts.clock.timezone == 'test' - - result.ansible_facts.clock.hours is defined - - result.ansible_facts.clock.hours == None - - result.ansible_facts.clock.seconds is defined - - result.ansible_facts.clock.seconds == [1, 1, 2, 3] diff --git a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_strip_empty_invalid.yml b/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_strip_empty_invalid.yml deleted file mode 100644 index 97bb84808f1..00000000000 --- a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_strip_empty_invalid.yml +++ /dev/null @@ -1,24 +0,0 @@ -- name: Test with strip_empty invalid - ignore_errors: no - register: result - vars: - timezone: "test" - hours: - arista.avd.yaml_templates_to_facts: - templates: - - template: "templates/template.j2" - options: - strip_empty_keys: "test" - -- assert: - that: - - result is success - - result.changed == true - - result.ansible_facts is defined - - result.ansible_facts.clock is defined - - result.ansible_facts.clock.timezone is defined - - result.ansible_facts.clock.timezone == 'test' - - result.ansible_facts.clock.hours is not defined - - result.ansible_facts.clock.minutes is not defined - - result.ansible_facts.clock.seconds is defined - - result.ansible_facts.clock.seconds == [1, 1, 2, 3] diff --git a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_template_output.yml b/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_template_output.yml deleted file mode 100644 index da44a7b864b..00000000000 --- a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_template_output.yml +++ /dev/null @@ -1,17 +0,0 @@ -- name: Test with template_output - ignore_errors: no - register: result - arista.avd.yaml_templates_to_facts: - template_output: true - templates: - - template: "templates/inline_jinja.j2" - -- assert: - that: - - result is success - - result.changed == true - - result.ansible_facts is defined - - result.ansible_facts.key_1 is defined - - result.ansible_facts.key_1 == "value_1" - - result.ansible_facts.key_2 is defined - - result.ansible_facts.key_2 == "value_1" diff --git a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_template_output_false.yml b/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_template_output_false.yml deleted file mode 100644 index 11a78fa1fcd..00000000000 --- a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_with_template_output_false.yml +++ /dev/null @@ -1,21 +0,0 @@ -- name: Test with template_output false - ignore_errors: no - register: result - arista.avd.yaml_templates_to_facts: - template_output: false - templates: - - template: "templates/inline_jinja.j2" - -- assert: - that: - - result is success - - result.changed == true - - result.ansible_facts is defined - - result.ansible_facts.key_1 is defined - - result.ansible_facts.key_1 == "value_1" - - result.ansible_facts.key_2 is defined - - result.ansible_facts.key_2[0] == '{' - - result.ansible_facts.key_2[1] == '{' - - result.ansible_facts.key_2[2:9] == ' key_1 ' - - result.ansible_facts.key_2[9] == '}' - - result.ansible_facts.key_2[10] == '}' diff --git a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_without_root_key.yml b/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_without_root_key.yml deleted file mode 100644 index c9e03f5952b..00000000000 --- a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_without_root_key.yml +++ /dev/null @@ -1,22 +0,0 @@ -- name: Test without root_key parameters - ignore_errors: no - vars: - timezone: "test" - hours: 36 - register: result - arista.avd.yaml_templates_to_facts: - templates: - - template: "templates/template.j2" - -- assert: - that: - - result is success - - result.changed == true - - result.ansible_facts is defined - - result.ansible_facts.clock is defined - - result.ansible_facts.clock.timezone is defined - - result.ansible_facts.clock.timezone == 'test' - - result.ansible_facts.clock.hours is defined - - result.ansible_facts.clock.hours == 36 - - result.ansible_facts.clock.seconds is defined - - result.ansible_facts.clock.seconds == [1, 1, 2, 3] diff --git a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_without_templates_parameter.yml b/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_without_templates_parameter.yml deleted file mode 100644 index 5a260967ec0..00000000000 --- a/ansible_collections/arista/avd/tests/integration/targets/yaml_templates_to_facts/tests/test_without_templates_parameter.yml +++ /dev/null @@ -1,10 +0,0 @@ -- name: Test without 'templates' parameter - ignore_errors: yes - register: result - arista.avd.yaml_templates_to_facts: - -- assert: - that: - - result is failed - - result.changed == false - - result.msg == "The argument 'templates' must be set" diff --git a/ansible_collections/arista/avd/tests/inventory/yaml_templates_to_facts/expected_output/yaml_templates_to_facts_test_with_dest.json b/ansible_collections/arista/avd/tests/inventory/yaml_templates_to_facts/expected_output/yaml_templates_to_facts_test_with_dest.json deleted file mode 100644 index 6ff268638d0..00000000000 --- a/ansible_collections/arista/avd/tests/inventory/yaml_templates_to_facts/expected_output/yaml_templates_to_facts_test_with_dest.json +++ /dev/null @@ -1 +0,0 @@ -{"clock": {"timezone": "test", "hours": 36, "seconds": [1, 1, 2, 3]}} diff --git a/ansible_collections/arista/avd/tests/inventory/yaml_templates_to_facts/expected_output/yaml_templates_to_facts_test_with_dest.yml b/ansible_collections/arista/avd/tests/inventory/yaml_templates_to_facts/expected_output/yaml_templates_to_facts_test_with_dest.yml deleted file mode 100644 index 223fe2b50df..00000000000 --- a/ansible_collections/arista/avd/tests/inventory/yaml_templates_to_facts/expected_output/yaml_templates_to_facts_test_with_dest.yml +++ /dev/null @@ -1,8 +0,0 @@ -clock: - timezone: test - hours: 36 - seconds: - - 1 - - 1 - - 2 - - 3 diff --git a/ansible_collections/arista/avd/tests/sanity/ignore-2.15.txt b/ansible_collections/arista/avd/tests/sanity/ignore-2.15.txt index 1deb7156eb1..b90f14fba84 100644 --- a/ansible_collections/arista/avd/tests/sanity/ignore-2.15.txt +++ b/ansible_collections/arista/avd/tests/sanity/ignore-2.15.txt @@ -1,15 +1,12 @@ -plugins/modules/batch_template.py validate-modules:missing-gplv3-license plugins/modules/configlet_build_config.py validate-modules:missing-gplv3-license plugins/modules/eos_designs_facts.py validate-modules:missing-gplv3-license plugins/modules/eos_designs_structured_config.py validate-modules:missing-gplv3-license plugins/modules/inventory_to_container.py validate-modules:missing-gplv3-license plugins/modules/set_vars.py validate-modules:missing-gplv3-license -plugins/modules/validate_and_template.py validate-modules:missing-gplv3-license plugins/modules/verify_requirements.py validate-modules:missing-gplv3-license -plugins/modules/yaml_templates_to_facts.py validate-modules:missing-gplv3-license plugins/vars/global_vars.py validate-modules:missing-gplv3-license plugins/modules/eos_validate_state_runner.py validate-modules:missing-gplv3-license plugins/modules/eos_validate_state_reports.py validate-modules:missing-gplv3-license plugins/modules/cv_workflow.py validate-modules:missing-gplv3-license plugins/modules/eos_cli_config_gen.py validate-modules:missing-gplv3-license -plugins/modules/_emit_warning.py validate-modules:missing-gplv3-license +meta/runtime.yml runtime-metadata # TODO Clean this when releasing 5.0.0 diff --git a/ansible_collections/arista/avd/tests/sanity/ignore-2.16.txt b/ansible_collections/arista/avd/tests/sanity/ignore-2.16.txt index 1deb7156eb1..b90f14fba84 100644 --- a/ansible_collections/arista/avd/tests/sanity/ignore-2.16.txt +++ b/ansible_collections/arista/avd/tests/sanity/ignore-2.16.txt @@ -1,15 +1,12 @@ -plugins/modules/batch_template.py validate-modules:missing-gplv3-license plugins/modules/configlet_build_config.py validate-modules:missing-gplv3-license plugins/modules/eos_designs_facts.py validate-modules:missing-gplv3-license plugins/modules/eos_designs_structured_config.py validate-modules:missing-gplv3-license plugins/modules/inventory_to_container.py validate-modules:missing-gplv3-license plugins/modules/set_vars.py validate-modules:missing-gplv3-license -plugins/modules/validate_and_template.py validate-modules:missing-gplv3-license plugins/modules/verify_requirements.py validate-modules:missing-gplv3-license -plugins/modules/yaml_templates_to_facts.py validate-modules:missing-gplv3-license plugins/vars/global_vars.py validate-modules:missing-gplv3-license plugins/modules/eos_validate_state_runner.py validate-modules:missing-gplv3-license plugins/modules/eos_validate_state_reports.py validate-modules:missing-gplv3-license plugins/modules/cv_workflow.py validate-modules:missing-gplv3-license plugins/modules/eos_cli_config_gen.py validate-modules:missing-gplv3-license -plugins/modules/_emit_warning.py validate-modules:missing-gplv3-license +meta/runtime.yml runtime-metadata # TODO Clean this when releasing 5.0.0 diff --git a/ansible_collections/arista/avd/tests/sanity/ignore-2.17.txt b/ansible_collections/arista/avd/tests/sanity/ignore-2.17.txt index 1deb7156eb1..b90f14fba84 100644 --- a/ansible_collections/arista/avd/tests/sanity/ignore-2.17.txt +++ b/ansible_collections/arista/avd/tests/sanity/ignore-2.17.txt @@ -1,15 +1,12 @@ -plugins/modules/batch_template.py validate-modules:missing-gplv3-license plugins/modules/configlet_build_config.py validate-modules:missing-gplv3-license plugins/modules/eos_designs_facts.py validate-modules:missing-gplv3-license plugins/modules/eos_designs_structured_config.py validate-modules:missing-gplv3-license plugins/modules/inventory_to_container.py validate-modules:missing-gplv3-license plugins/modules/set_vars.py validate-modules:missing-gplv3-license -plugins/modules/validate_and_template.py validate-modules:missing-gplv3-license plugins/modules/verify_requirements.py validate-modules:missing-gplv3-license -plugins/modules/yaml_templates_to_facts.py validate-modules:missing-gplv3-license plugins/vars/global_vars.py validate-modules:missing-gplv3-license plugins/modules/eos_validate_state_runner.py validate-modules:missing-gplv3-license plugins/modules/eos_validate_state_reports.py validate-modules:missing-gplv3-license plugins/modules/cv_workflow.py validate-modules:missing-gplv3-license plugins/modules/eos_cli_config_gen.py validate-modules:missing-gplv3-license -plugins/modules/_emit_warning.py validate-modules:missing-gplv3-license +meta/runtime.yml runtime-metadata # TODO Clean this when releasing 5.0.0 diff --git a/python-avd/pyavd/j2filters/__init__.py b/python-avd/pyavd/j2filters/__init__.py index 0b422cbe014..3c2d5ff8b17 100644 --- a/python-avd/pyavd/j2filters/__init__.py +++ b/python-avd/pyavd/j2filters/__init__.py @@ -6,9 +6,6 @@ from .decrypt import decrypt from .default import default from .encrypt import encrypt -from .generate_esi import generate_esi -from .generate_lacp_id import generate_lacp_id -from .generate_route_target import generate_route_target from .hide_passwords import hide_passwords from .is_in_filter import is_in_filter from .list_compress import list_compress @@ -23,9 +20,6 @@ "decrypt", "default", "encrypt", - "generate_esi", - "generate_lacp_id", - "generate_route_target", "hide_passwords", "is_in_filter", "list_compress", diff --git a/python-avd/pyavd/j2filters/generate_esi.py b/python-avd/pyavd/j2filters/generate_esi.py deleted file mode 100644 index 7153ccb5b37..00000000000 --- a/python-avd/pyavd/j2filters/generate_esi.py +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright (c) 2024 Arista Networks, Inc. -# Use of this source code is governed by the Apache License 2.0 -# that can be found in the LICENSE file. -def generate_esi(short_esi: str, esi_prefix: str = "0000:0000:") -> str: - """ - Transforms short_esi to EVPN ESI format. - 0303:0202:0101 (short_esi) -> 0000:0000:0303:0202:0101 (EVPN ESI). - - Args: - esi_short: Short ESI value as per AVD definition in eos_designs - esi_prefix: ESI prefix value, will be concatenated with the `short_esi` - Returns: - Concatenated string of `esi_prefix` and `short_esi` like `0000:0000:0303:0202:0101` - - """ - return esi_prefix + short_esi diff --git a/python-avd/pyavd/j2filters/generate_lacp_id.py b/python-avd/pyavd/j2filters/generate_lacp_id.py deleted file mode 100644 index 4b71fc04939..00000000000 --- a/python-avd/pyavd/j2filters/generate_lacp_id.py +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright (c) 2023-2024 Arista Networks, Inc. -# Use of this source code is governed by the Apache License 2.0 -# that can be found in the LICENSE file. -from __future__ import annotations - - -def generate_lacp_id(esi_short: str) -> str: - """ - Transforms short_esi `0303:0202:0101` to LACP ID format `0303.0202.0101` - - Args: - esi_short (str): Short ESI value as per AVD definition in eos_designs - Returns: - str: LACP ID - - """ - return esi_short.replace(":", ".") diff --git a/python-avd/pyavd/j2filters/generate_route_target.py b/python-avd/pyavd/j2filters/generate_route_target.py deleted file mode 100644 index a8a8a9d1a0b..00000000000 --- a/python-avd/pyavd/j2filters/generate_route_target.py +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright (c) 2024 Arista Networks, Inc. -# Use of this source code is governed by the Apache License 2.0 -# that can be found in the LICENSE file. -from __future__ import annotations - -import re - - -def generate_route_target(esi_short: str | None) -> str | None: - """ - generate_route_target transforms 3 octets ESI like 0303:0202:0101 to route-target - - Parameters - ---------- - esi : str - Short ESI value as per AVD definition in eos_designs - - Returns - ------- - str: - String based on route-target format like 03:03:02:02:01:01 - """ - if esi_short is None: - return None - delimiter = ":" - esi = esi_short.replace(delimiter, "") - esi_split = re.findall("..", esi) - return delimiter.join(esi_split) diff --git a/python-avd/pyavd/templater.py b/python-avd/pyavd/templater.py index c6f58b30781..baa39a818b7 100644 --- a/python-avd/pyavd/templater.py +++ b/python-avd/pyavd/templater.py @@ -72,9 +72,6 @@ def import_filters_and_tests(self) -> None: decrypt, default, encrypt, - generate_esi, - generate_lacp_id, - generate_route_target, hide_passwords, is_in_filter, list_compress, @@ -95,9 +92,6 @@ def import_filters_and_tests(self) -> None: "arista.avd.decrypt": decrypt, "arista.avd.default": default, "arista.avd.encrypt": encrypt, - "arista.avd.generate_esi": generate_esi, - "arista.avd.generate_lacp_id": generate_lacp_id, - "arista.avd.generate_route_target": generate_route_target, "arista.avd.hide_passwords": hide_passwords, "arista.avd.is_in_filter": is_in_filter, "arista.avd.list_compress": list_compress, diff --git a/python-avd/tests/pyavd/j2filters/test_generate_esi.py b/python-avd/tests/pyavd/j2filters/test_generate_esi.py deleted file mode 100644 index e322ded3ee0..00000000000 --- a/python-avd/tests/pyavd/j2filters/test_generate_esi.py +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (c) 2023-2024 Arista Networks, Inc. -# Use of this source code is governed by the Apache License 2.0 -# that can be found in the LICENSE file. -from __future__ import absolute_import, division, print_function - -__metaclass__ = type - -import pytest -from pyavd.j2filters import generate_esi - -DEFAULT_ESI_PREFIX = "0000:0000:" -GENERATE_ESI_TEST_CASES = [ - # (, , ) - ("0303:0202:0101", "", "0000:0000:0303:0202:0101"), # without prefix - ("0303:0202:0101", "1111:1111:", "1111:1111:0303:0202:0101"), # with prefix -] - - -class TestGenerateEsiFilter: - @pytest.mark.parametrize("esi_short, esi_prefix, esi", GENERATE_ESI_TEST_CASES) - def test_generate_esi(self, esi_short, esi_prefix, esi): - esi_prefix = esi_prefix or DEFAULT_ESI_PREFIX - resp = generate_esi(esi_short, esi_prefix) - assert resp == esi diff --git a/python-avd/tests/pyavd/j2filters/test_generate_lacp_id.py b/python-avd/tests/pyavd/j2filters/test_generate_lacp_id.py deleted file mode 100644 index eb124727dae..00000000000 --- a/python-avd/tests/pyavd/j2filters/test_generate_lacp_id.py +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright (c) 2023-2024 Arista Networks, Inc. -# Use of this source code is governed by the Apache License 2.0 -# that can be found in the LICENSE file. -import pytest -from pyavd.j2filters import generate_lacp_id - -ESI_SHORT_VALID_INPUT = [ - ("0404:0202:0101", "0404.0202.0101"), - ("000:000:0303:0202:0101", "000.000.0303.0202.0101"), - ("", ""), -] - -ESI_SHORT_INVALID_INPUT = [ - (10, "'int' object has no attribute 'replace'"), - (None, "'NoneType' object has no attribute 'replace'"), - ({}, "'dict' object has no attribute 'replace'"), - ([], "'list' object has no attribute 'replace'"), -] - - -class TestGenerateLacpIdFilter: - - @pytest.mark.parametrize("esi_short, lacp_id", ESI_SHORT_VALID_INPUT) - def test_generate_lacp_id_valid(self, esi_short, lacp_id): - resp = generate_lacp_id(esi_short) - assert resp == lacp_id - - @pytest.mark.parametrize("esi_short, error_msg", ESI_SHORT_INVALID_INPUT) - def test_generate_lacp_id_invalid(self, esi_short, error_msg): - with pytest.raises(AttributeError) as exc_info: - generate_lacp_id(esi_short) - assert str(exc_info.value) == error_msg diff --git a/python-avd/tests/pyavd/j2filters/test_generate_route_target.py b/python-avd/tests/pyavd/j2filters/test_generate_route_target.py deleted file mode 100644 index 9cc45c8c678..00000000000 --- a/python-avd/tests/pyavd/j2filters/test_generate_route_target.py +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright (c) 2023-2024 Arista Networks, Inc. -# Use of this source code is governed by the Apache License 2.0 -# that can be found in the LICENSE file. -from __future__ import absolute_import, division, print_function - -__metaclass__ = type - -import pytest -from pyavd.j2filters import generate_route_target - -ESI_TO_RT_TEST_CASES = [ - # (, ) - ("0303:0202:0101", "03:03:02:02:01:01"), - (None, None), - ("ESI_SHORT", "ES:I_:SH:OR"), - ("", ""), - ("3", ""), -] - - -class TestGenerateRouteTargetFilter: - @pytest.mark.parametrize("esi_short, route_target", ESI_TO_RT_TEST_CASES) - def test_generate_route_target(self, esi_short, route_target): - resp = generate_route_target(esi_short) - assert resp == route_target