Enable prettier via pre-commit (#188)

pull/194/head
Bradley A. Thornton 2022-05-26 07:02:52 -07:00 committed by GitHub
parent 6e25216d7a
commit 4fe771a95c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
71 changed files with 55932 additions and 55925 deletions

View File

@ -9,11 +9,38 @@ repos:
- id: no-commit-to-branch - id: no-commit-to-branch
args: [--branch, main] args: [--branch, main]
- id: trailing-whitespace - id: trailing-whitespace
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v2.6.2"
hooks:
- id: prettier
# Original hook implementation is flaky due to *several* bugs described
# in https://github.com/prettier/prettier/issues/12364
# a) CI=1 needed to avoid incomplete output
# b) two executions are needed because --list-different works correctly
# only when run with --check as with --write the output will also
# include other entries and logging level cannot be used to keep only
# modified files listed (any file is listed using the log level, regardless if
# is modified or not).
# c) We avoid letting pre-commit pass each filename in order to avoid
# running multiple instances in parallel. This also ensures that running
# prettier from the command line behaves identically with the pre-commit
# one. No real performance downsides.
# d) exit with the return code from list-different (0=none, 1=some)
# rather than the write (0=successfully rewrote files). pre-commit.ci
entry: env CI=1 bash -c "prettier --list-different . || ec=$? && prettier --loglevel=error --write . && exit $ec"
pass_filenames: false
args: []
additional_dependencies:
- prettier
- prettier-plugin-toml
- repo: https://github.com/psf/black - repo: https://github.com/psf/black
rev: 22.3.0 rev: 22.3.0
hooks: hooks:
- id: black - id: black
args: [-l, "79"] args: [-l, "79"]
- repo: https://github.com/ansible-network/collection_prep - repo: https://github.com/ansible-network/collection_prep
rev: 1.0.0 rev: 1.0.0
hooks: hooks:

17
.prettierignore Normal file
View File

@ -0,0 +1,17 @@
# Stuff we don't want priettier to ever to look into
.*/
coverage/
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# A linked collection directory created by pytest-ansible-units
collections/
README.md

View File

@ -3,259 +3,259 @@ releases:
1.0.0: 1.0.0:
changes: changes:
bugfixes: bugfixes:
- linting and formatting for CI - linting and formatting for CI
minor_changes: minor_changes:
- Add cli_parse module and plugins (https://github.com/ansible-collections/ansible.utils/pull/28) - Add cli_parse module and plugins (https://github.com/ansible-collections/ansible.utils/pull/28)
- Added fact_diff plugin and sub plugin - Added fact_diff plugin and sub plugin
- Added validate module/lookup/filter/test plugin to validate data based on - Added validate module/lookup/filter/test plugin to validate data based on
given criteria given criteria
fragments: fragments:
- 23 linting and formatting.yaml - 23 linting and formatting.yaml
- 28_cli_parse_plugins_add.yaml - 28_cli_parse_plugins_add.yaml
- 29-add_docs_for_Cli_parse.yaml - 29-add_docs_for_Cli_parse.yaml
- add_fact_diff.yaml - add_fact_diff.yaml
- docs_copyedit.yaml - docs_copyedit.yaml
- validate.yaml - validate.yaml
modules: modules:
- description: Parse cli output or text using a variety of parsers - description: Parse cli output or text using a variety of parsers
name: cli_parse name: cli_parse
namespace: '' namespace: ""
- description: Find the difference between currently set facts - description: Find the difference between currently set facts
name: fact_diff name: fact_diff
namespace: '' namespace: ""
- description: Update currently set facts - description: Update currently set facts
name: update_fact name: update_fact
namespace: '' namespace: ""
- description: Validate data with provided criteria
name: validate
namespace: ''
plugins:
lookup:
- description: Retrieve the value in a variable using a path
name: get_path
namespace: null
- description: Find the indices of items in a list matching some criteria
name: index_of
namespace: null
- description: Flatten a complex object into a dictionary of paths and values
name: to_paths
namespace: null
- description: Validate data with provided criteria - description: Validate data with provided criteria
name: validate name: validate
namespace: null namespace: ""
release_date: '2020-12-08' plugins:
lookup:
- description: Retrieve the value in a variable using a path
name: get_path
namespace: null
- description: Find the indices of items in a list matching some criteria
name: index_of
namespace: null
- description: Flatten a complex object into a dictionary of paths and values
name: to_paths
namespace: null
- description: Validate data with provided criteria
name: validate
namespace: null
release_date: "2020-12-08"
1.0.1: 1.0.1:
changes: changes:
minor_changes: minor_changes:
- Move CHANGELOG.rst file under changelogs folder as required - Move CHANGELOG.rst file under changelogs folder as required
fragments: fragments:
- fix_changelog_file_location.yaml - fix_changelog_file_location.yaml
release_date: '2020-12-08' release_date: "2020-12-08"
2.0.0: 2.0.0:
changes: changes:
breaking_changes: breaking_changes:
- If added custom sub plugins in your collection move from old location `plugins/<sub-plugin-name>` - If added custom sub plugins in your collection move from old location `plugins/<sub-plugin-name>`
to the new location `plugins/sub_plugins/<sub-plugin-name>` and update the to the new location `plugins/sub_plugins/<sub-plugin-name>` and update the
imports as required imports as required
- Move sub plugins cli_parsers, fact_diff and validate to `plugins/sub_plugins` - Move sub plugins cli_parsers, fact_diff and validate to `plugins/sub_plugins`
folder folder
- The `cli_parsers` sub plugins folder name is changed to `cli_parse` to have - The `cli_parsers` sub plugins folder name is changed to `cli_parse` to have
consistent naming convention, that is all the cli_parse subplugins will now consistent naming convention, that is all the cli_parse subplugins will now
be in `plugins/sub_plugins/cli_parse` folder be in `plugins/sub_plugins/cli_parse` folder
fragments: fragments:
- 32_doc_updates.yaml - 32_doc_updates.yaml
- sub_plugins_dir_change.yaml - sub_plugins_dir_change.yaml
- upcap_ansible.yaml - upcap_ansible.yaml
release_date: '2021-01-29' release_date: "2021-01-29"
2.0.1: 2.0.1:
changes: changes:
bugfixes: bugfixes:
- Fix ansible.utils.cli_parse action plugin to support old cli_parse sub-plugin - Fix ansible.utils.cli_parse action plugin to support old cli_parse sub-plugin
structure in ansible.netcommon collection. structure in ansible.netcommon collection.
fragments: fragments:
- ansible-doc.yaml - ansible-doc.yaml
- cli_parse_fix.yaml - cli_parse_fix.yaml
release_date: '2021-02-25' release_date: "2021-02-25"
2.0.2: 2.0.2:
changes: changes:
bugfixes: bugfixes:
- Fix cli_parse template_path read error (https://github.com/ansible-collections/ansible.utils/pull/51). - Fix cli_parse template_path read error (https://github.com/ansible-collections/ansible.utils/pull/51).
- Fix jsonschema input data format checking (https://github.com/ansible-collections/ansible.utils/pull/50). - Fix jsonschema input data format checking (https://github.com/ansible-collections/ansible.utils/pull/50).
fragments: fragments:
- cli_parse_errors_return.yaml - cli_parse_errors_return.yaml
- jsonschema_data_validation_fix.yaml - jsonschema_data_validation_fix.yaml
release_date: '2021-03-29' release_date: "2021-03-29"
2.1.0: 2.1.0:
changes: changes:
bugfixes: bugfixes:
- Add missing test requirements (https://github.com/ansible-collections/ansible.utils/pull/57). - Add missing test requirements (https://github.com/ansible-collections/ansible.utils/pull/57).
minor_changes: minor_changes:
- Add from_xml and to_xml fiter plugin (https://github.com/ansible-collections/ansible.utils/pull/56). - Add from_xml and to_xml fiter plugin (https://github.com/ansible-collections/ansible.utils/pull/56).
fragments: fragments:
- 63-add_ignore_txt.yml - 63-add_ignore_txt.yml
- add-xmltojson-and-jsontoxml-filter.yaml - add-xmltojson-and-jsontoxml-filter.yaml
- add_missing_test_requirements.yml - add_missing_test_requirements.yml
- fix_tests.yaml - fix_tests.yaml
release_date: '2021-04-27' release_date: "2021-04-27"
2.2.0: 2.2.0:
changes: changes:
minor_changes: minor_changes:
- Add in_any_network, in_network, in_one_network test plugins - Add in_any_network, in_network, in_one_network test plugins
- Add ip, ip_address test plugins - Add ip, ip_address test plugins
- Add ipv4, ipv4_address, ipv4_hostmask, ipv4_netmask test plugins - Add ipv4, ipv4_address, ipv4_hostmask, ipv4_netmask test plugins
- Add ipv6, ipv6_address, ipv6_ipv4_mapped, ipv6_sixtofour, ipv6_teredo test - Add ipv6, ipv6_address, ipv6_ipv4_mapped, ipv6_sixtofour, ipv6_teredo test
plugins plugins
- Add loopback, mac, multicast test plugins - Add loopback, mac, multicast test plugins
- Add private, public, reserved test plugins - Add private, public, reserved test plugins
- Add resolvable test plugins - Add resolvable test plugins
- Add subnet_of, supernet_of, unspecified test plugins - Add subnet_of, supernet_of, unspecified test plugins
fragments: fragments:
- add_netaddr_test_plugins_1.yml - add_netaddr_test_plugins_1.yml
- add_netaddr_test_plugins_2.yml - add_netaddr_test_plugins_2.yml
- add_netaddr_test_plugins_3.yml - add_netaddr_test_plugins_3.yml
- add_netaddr_test_plugins_4.yml - add_netaddr_test_plugins_4.yml
- add_netaddr_test_plugins_5.yml - add_netaddr_test_plugins_5.yml
- add_netaddr_test_plugins_6.yml - add_netaddr_test_plugins_6.yml
- add_netaddr_test_plugins_7.yml - add_netaddr_test_plugins_7.yml
- add_netaddr_test_plugins_8.yml - add_netaddr_test_plugins_8.yml
release_date: '2021-05-17' release_date: "2021-05-17"
2.3.0: 2.3.0:
changes: changes:
bugfixes: bugfixes:
- Also include empty lists and mappings into the output dictionary (https://github.com/ansible-collections/ansible.utils/pull/58). - Also include empty lists and mappings into the output dictionary (https://github.com/ansible-collections/ansible.utils/pull/58).
doc_changes: doc_changes:
- Update doc for usable_range filter plugin - Update doc for usable_range filter plugin
minor_changes: minor_changes:
- Add usable_range test plugin - Add usable_range test plugin
fragments: fragments:
- add_usable_range_filter_plugin.yml - add_usable_range_filter_plugin.yml
- empty_list_mapping.yml - empty_list_mapping.yml
- improve_coverage_for_filter_plugins.yaml - improve_coverage_for_filter_plugins.yaml
- update_doc_for_usable_range_filter_plugin.yml - update_doc_for_usable_range_filter_plugin.yml
release_date: '2021-06-22' release_date: "2021-06-22"
2.3.1: 2.3.1:
changes: changes:
bugfixes: bugfixes:
- Add support for the validation of formats to the jsonschema validator. - Add support for the validation of formats to the jsonschema validator.
- Improve test coverage - Improve test coverage
fragments: fragments:
- 81_add_support_for_format.yaml - 81_add_support_for_format.yaml
release_date: '2021-07-26' release_date: "2021-07-26"
2.4.0: 2.4.0:
changes: changes:
bugfixes: bugfixes:
- Update validate to use 2.11 ArgumentSpecValidator if available. - Update validate to use 2.11 ArgumentSpecValidator if available.
minor_changes: minor_changes:
- Add new plugin param_list_compare that generates the final param list after - Add new plugin param_list_compare that generates the final param list after
comparing base and provided/target param list. comparing base and provided/target param list.
fragments: fragments:
- 85_update_validate_plugin.yaml - 85_update_validate_plugin.yaml
- 88_compare_resource_list_filter_plugin.yaml - 88_compare_resource_list_filter_plugin.yaml
- param_list_compare_docs_added.yaml - param_list_compare_docs_added.yaml
release_date: '2021-08-28' release_date: "2021-08-28"
2.4.1: 2.4.1:
changes: changes:
release_summary: Rereleased 2.4.0 with trivial changes. release_summary: Rereleased 2.4.0 with trivial changes.
fragments: fragments:
- 2.4.1.yaml - 2.4.1.yaml
- fix_network_ee.yaml - fix_network_ee.yaml
release_date: '2021-09-24' release_date: "2021-09-24"
2.4.2: 2.4.2:
changes: changes:
release_summary: Rereleased 2.4.1 with valid requirement.txt. release_summary: Rereleased 2.4.1 with valid requirement.txt.
fragments: fragments:
- 2.4.2.yaml - 2.4.2.yaml
- add_ignore_2.13.yaml - add_ignore_2.13.yaml
- bugfix_100.yaml - bugfix_100.yaml
release_date: '2021-10-07' release_date: "2021-10-07"
2.4.3: 2.4.3:
changes: changes:
release_summary: Rereleased 2.4.2 with fix of network ee tests. release_summary: Rereleased 2.4.2 with fix of network ee tests.
fragments: fragments:
- 2.4.3.yaml - 2.4.3.yaml
- fix_network_ee.yaml - fix_network_ee.yaml
release_date: '2021-12-07' release_date: "2021-12-07"
2.5.0: 2.5.0:
changes: changes:
doc_changes: doc_changes:
- Enhancement in documentation and docstring. - Enhancement in documentation and docstring.
minor_changes: minor_changes:
- '''keep_keys'' filter plugin added.' - "'keep_keys' filter plugin added."
- '''remove_keys'' filter plugin added.' - "'remove_keys' filter plugin added."
- '''replace_keys'' filter plugin added.' - "'replace_keys' filter plugin added."
- Add cli_merge ipaddr filter plugin. - Add cli_merge ipaddr filter plugin.
- Add ip4_hex filter plugin. - Add ip4_hex filter plugin.
- Add ipaddr filter plugin. - Add ipaddr filter plugin.
- Add ipmath filter plugin. - Add ipmath filter plugin.
- Add ipsubnet filter plugin. - Add ipsubnet filter plugin.
- Add ipv4 filter plugin. - Add ipv4 filter plugin.
- Add ipv6 filter plugin. - Add ipv6 filter plugin.
- Add ipwrap filter plugin. - Add ipwrap filter plugin.
- Add network_in_network filter plugin. - Add network_in_network filter plugin.
- Add network_in_usable filter plugin. - Add network_in_usable filter plugin.
- Add next_nth_usable filter plugin. - Add next_nth_usable filter plugin.
- Add nthhost filter plugin. - Add nthhost filter plugin.
- Add previous_nth_usable filter plugin. - Add previous_nth_usable filter plugin.
- Add reduce_on_network filter plugin. - Add reduce_on_network filter plugin.
- Add slaac,hwaddr,mac filter plugin. - Add slaac,hwaddr,mac filter plugin.
- New validate sub-plugin "config" to validate device configuration against - New validate sub-plugin "config" to validate device configuration against
user-defined rules (https://github.com/ansible-collections/ansible.network/issues/15). user-defined rules (https://github.com/ansible-collections/ansible.network/issues/15).
fragments: fragments:
- 112-validate-config-plugin.yaml - 112-validate-config-plugin.yaml
- add_cli_merge_filter_plugin.yaml - add_cli_merge_filter_plugin.yaml
- add_ip4_hex_filter.yaml - add_ip4_hex_filter.yaml
- add_ipaddr_filter_plugin.yaml - add_ipaddr_filter_plugin.yaml
- add_ipmath_filter.yaml - add_ipmath_filter.yaml
- add_ipsubnet_filter_plugin.yaml - add_ipsubnet_filter_plugin.yaml
- add_ipv4_filter_plugin.yaml - add_ipv4_filter_plugin.yaml
- add_ipv6_filter_plugin.yaml - add_ipv6_filter_plugin.yaml
- add_ipwrap_filter_plugin.yaml - add_ipwrap_filter_plugin.yaml
- add_network_in_network_filter.yaml - add_network_in_network_filter.yaml
- add_network_in_usable_filter.yaml - add_network_in_usable_filter.yaml
- add_next_nth_usable_filter.yaml - add_next_nth_usable_filter.yaml
- add_nthhost_filter.yaml - add_nthhost_filter.yaml
- add_previous_nth_usable_filter.yaml - add_previous_nth_usable_filter.yaml
- add_reduce_on_network_filter.yaml - add_reduce_on_network_filter.yaml
- add_slaac_mac_hwaddr_filter.yaml - add_slaac_mac_hwaddr_filter.yaml
- docfix_minor_corrections.yaml - docfix_minor_corrections.yaml
- recursive_filter_plugins.yaml - recursive_filter_plugins.yaml
release_date: '2022-01-31' release_date: "2022-01-31"
2.5.1: 2.5.1:
changes: changes:
doc_changes: doc_changes:
- '`in_any_network` - plugin doc fix for redundant line.' - "`in_any_network` - plugin doc fix for redundant line."
fragments: fragments:
- Improve_test_covrage.yaml - Improve_test_covrage.yaml
- minor_doc_update.yaml - minor_doc_update.yaml
- unit_test_container_venv.yaml - unit_test_container_venv.yaml
release_date: '2022-03-01' release_date: "2022-03-01"
2.5.2: 2.5.2:
changes: changes:
bugfixes: bugfixes:
- Fix issue in ipaddr,ipv4,ipv6,ipwrap filters.(https://github.com/ansible-collections/ansible.utils/issues/148). - Fix issue in ipaddr,ipv4,ipv6,ipwrap filters.(https://github.com/ansible-collections/ansible.utils/issues/148).
- ipaddr - Add valid network for link-local (https://github.com/ansible-collections/ansible.netcommon/issues/350). - ipaddr - Add valid network for link-local (https://github.com/ansible-collections/ansible.netcommon/issues/350).
- ipaddr - Fix issue of breaking ipaddr filter with netcommon 2.6.0(https://github.com/ansible-collections/ansible.netcommon/issues/375). - ipaddr - Fix issue of breaking ipaddr filter with netcommon 2.6.0(https://github.com/ansible-collections/ansible.netcommon/issues/375).
fragments: fragments:
- bugfix_ipaddr_filter.yaml - bugfix_ipaddr_filter.yaml
release_date: '2022-03-04' release_date: "2022-03-04"
2.6.0: 2.6.0:
changes: changes:
minor_changes: minor_changes:
- '''consolidate'' filter plugin added.' - "'consolidate' filter plugin added."
fragments: fragments:
- 0-ignore.yml - 0-ignore.yml
- consolidate_filter_plugin.yml - consolidate_filter_plugin.yml
- enable_upgrade_black.yml - enable_upgrade_black.yml
- pre-commit-enable.yml - pre-commit-enable.yml
- pre-commit-skip.yml - pre-commit-skip.yml
release_date: '2022-04-12' release_date: "2022-04-12"
2.6.1: 2.6.1:
changes: changes:
release_summary: Rereleased 2.6.0 with fixes for internal testing. release_summary: Rereleased 2.6.0 with fixes for internal testing.
fragments: fragments:
- 2.6.1-notes.yaml - 2.6.1-notes.yaml
- check_mode.yaml - check_mode.yaml
- pylint-black-flake.yml - pylint-black-flake.yml
- sanity_fix.yaml - sanity_fix.yaml
- test inits.yml - test inits.yml
release_date: '2022-04-25' release_date: "2022-04-25"

View File

@ -9,23 +9,23 @@ notesdir: fragments
prelude_section_name: release_summary prelude_section_name: release_summary
prelude_section_title: Release Summary prelude_section_title: Release Summary
sections: sections:
- - major_changes - - major_changes
- Major Changes - Major Changes
- - minor_changes - - minor_changes
- Minor Changes - Minor Changes
- - breaking_changes - - breaking_changes
- Breaking Changes / Porting Guide - Breaking Changes / Porting Guide
- - deprecated_features - - deprecated_features
- Deprecated Features - Deprecated Features
- - removed_features - - removed_features
- Removed Features (previously deprecated) - Removed Features (previously deprecated)
- - security_fixes - - security_fixes
- Security Fixes - Security Fixes
- - bugfixes - - bugfixes
- Bugfixes - Bugfixes
- - known_issues - - known_issues
- Known Issues - Known Issues
- - doc_changes - - doc_changes
- Documentation Changes - Documentation Changes
title: Ansible Utils Collection title: Ansible Utils Collection
trivial_section_name: trivial trivial_section_name: trivial

View File

@ -0,0 +1,3 @@
---
trivial:
- Enable prettier via pre-commit

View File

@ -1,2 +1,2 @@
--- ---
requires_ansible: '>=2.9.10' requires_ansible: ">=2.9.10"

View File

@ -3,14 +3,14 @@ line-length = 79
[tool.pytest.ini_options] [tool.pytest.ini_options]
addopts = [ addopts = [
"--integration-tests-path=tests/integration/targets", "--integration-tests-path=tests/integration/targets",
"-vvv", "-vvv",
"-n", "-n",
"2", "2",
"--log-level", "--log-level",
"WARNING", "WARNING",
"--color", "--color",
"yes" "yes"
] ]
testpaths = ["tests"] testpaths = ["tests"]
filterwarnings = ['ignore:AnsibleCollectionFinder has already been configured'] filterwarnings = ['ignore:AnsibleCollectionFinder has already been configured']

View File

@ -1,18 +1,18 @@
[ [
[
[ [
[ {
{ "admin_state": "up,",
"admin_state": "up,", "interface": "mgmt0",
"interface": "mgmt0", "state": "up",
"state": "up", "var": "extra_var"
"var": "extra_var" },
}, {
{ "admin_state": "up,",
"admin_state": "up,", "interface": "Ethernet1/1",
"interface": "Ethernet1/1", "state": "up",
"state": "up", "var": "extra_var"
"var": "extra_var" }
}
]
] ]
]
] ]

View File

@ -1,56 +1,56 @@
{ {
"nf:rpc-reply": { "nf:rpc-reply": {
"@xmlns": "http://www.cisco.com/nxos:1.0:if_manager", "@xmlns": "http://www.cisco.com/nxos:1.0:if_manager",
"@xmlns:nf": "urn:ietf:params:xml:ns:netconf:base:1.0", "@xmlns:nf": "urn:ietf:params:xml:ns:netconf:base:1.0",
"nf:data": { "nf:data": {
"show": { "show": {
"interface": { "interface": {
"__XML__OPT_Cmd_show_interface___readonly__": { "__XML__OPT_Cmd_show_interface___readonly__": {
"__readonly__": { "__readonly__": {
"TABLE_interface": { "TABLE_interface": {
"ROW_interface": { "ROW_interface": {
"admin_state": "up", "admin_state": "up",
"eth_autoneg": "on", "eth_autoneg": "on",
"eth_bia_addr": "5e00.000b.0000", "eth_bia_addr": "5e00.000b.0000",
"eth_bw": "1000000", "eth_bw": "1000000",
"eth_dly": "10", "eth_dly": "10",
"eth_duplex": "full", "eth_duplex": "full",
"eth_ethertype": "0x0000", "eth_ethertype": "0x0000",
"eth_hw_addr": "5e00.000b.0000", "eth_hw_addr": "5e00.000b.0000",
"eth_hw_desc": "Ethernet", "eth_hw_desc": "Ethernet",
"eth_ip_addr": "10.8.38.74", "eth_ip_addr": "10.8.38.74",
"eth_ip_mask": "24", "eth_ip_mask": "24",
"eth_ip_prefix": "10.8.38.0", "eth_ip_prefix": "10.8.38.0",
"eth_mdix": "off", "eth_mdix": "off",
"eth_mode": "routed", "eth_mode": "routed",
"eth_mtu": "1500", "eth_mtu": "1500",
"eth_reliability": "188", "eth_reliability": "188",
"eth_rxload": "1", "eth_rxload": "1",
"eth_speed": "1000 Mb/s", "eth_speed": "1000 Mb/s",
"eth_txload": "1", "eth_txload": "1",
"interface": "mgmt0", "interface": "mgmt0",
"medium": "broadcast", "medium": "broadcast",
"state": "up", "state": "up",
"vdc_lvl_in_avg_bytes": "816", "vdc_lvl_in_avg_bytes": "816",
"vdc_lvl_in_avg_pkts": "0", "vdc_lvl_in_avg_pkts": "0",
"vdc_lvl_in_bcast": "3124022", "vdc_lvl_in_bcast": "3124022",
"vdc_lvl_in_bytes": "966991855", "vdc_lvl_in_bytes": "966991855",
"vdc_lvl_in_mcast": "1743445", "vdc_lvl_in_mcast": "1743445",
"vdc_lvl_in_pkts": "7716327", "vdc_lvl_in_pkts": "7716327",
"vdc_lvl_in_ucast": "2848860", "vdc_lvl_in_ucast": "2848860",
"vdc_lvl_out_avg_bytes": "272", "vdc_lvl_out_avg_bytes": "272",
"vdc_lvl_out_avg_pkts": "0", "vdc_lvl_out_avg_pkts": "0",
"vdc_lvl_out_bcast": "3", "vdc_lvl_out_bcast": "3",
"vdc_lvl_out_bytes": "325131723", "vdc_lvl_out_bytes": "325131723",
"vdc_lvl_out_mcast": "155378", "vdc_lvl_out_mcast": "155378",
"vdc_lvl_out_pkts": "3004554", "vdc_lvl_out_pkts": "3004554",
"vdc_lvl_out_ucast": "2849173" "vdc_lvl_out_ucast": "2849173"
}
}
}
}
} }
}
} }
}
} }
}
} }
}
} }

View File

@ -1,7 +1,7 @@
{ {
"BOOT_IMAGE": "bootflash:///titanium-d1-kickstart.7.3.0.D1.1.bin", "BOOT_IMAGE": "bootflash:///titanium-d1-kickstart.7.3.0.D1.1.bin",
"LAST_REBOOT_REASON": "", "LAST_REBOOT_REASON": "",
"OS": "7.3(0)D1(1)", "OS": "7.3(0)D1(1)",
"PLATFORM": "OSv", "PLATFORM": "OSv",
"UPTIME": "110 day(s), 12 hour(s), 32 minute(s), 10 second(s)" "UPTIME": "110 day(s), 12 hour(s), 32 minute(s), 10 second(s)"
} }

View File

@ -45,7 +45,6 @@
vars: vars:
msg: "one of the following is required: command, text" msg: "one of the following is required: command, text"
- name: "{{ parser }} validate argspec" - name: "{{ parser }} validate argspec"
ansible.utils.cli_parse: ansible.utils.cli_parse:
text: "" text: ""

View File

@ -14,14 +14,13 @@
- name: "{{ parser }} Confirm response" - name: "{{ parser }} Confirm response"
assert: assert:
that: that:
- "{{ POpqMQoJWTiDpEW is defined }}" - "{{ POpqMQoJWTiDpEW is defined }}"
- "{{ nxos_ttp_text['parsed'][0][0] | selectattr('interface', 'search', 'mgmt0') | list | length }}" - "{{ nxos_ttp_text['parsed'][0][0] | selectattr('interface', 'search', 'mgmt0') | list | length }}"
- "{{ nxos_ttp_text['parsed'] == nxos_ttp_text_parsed }}" - "{{ nxos_ttp_text['parsed'] == nxos_ttp_text_parsed }}"
- name: "{{ parser }} Pass text and custom variable" - name: "{{ parser }} Pass text and custom variable"
ansible.utils.cli_parse: ansible.utils.cli_parse:
text: "{{ lookup('ansible.builtin.file', '{{ role_path }}/files/nxos_show_interface.txt') }}" text: "{{ lookup('ansible.builtin.file', '{{ role_path }}/files/nxos_show_interface.txt') }}"
parser: parser:
name: ansible.utils.ttp name: ansible.utils.ttp
template_path: "{{ role_path }}/templates/nxos_show_interface.ttp" template_path: "{{ role_path }}/templates/nxos_show_interface.ttp"
@ -38,7 +37,7 @@
- name: "{{ parser }} Pass text and ttp_results modified" - name: "{{ parser }} Pass text and ttp_results modified"
ansible.utils.cli_parse: ansible.utils.cli_parse:
text: "{{ lookup('ansible.builtin.file', '{{ role_path }}/files/nxos_show_interface.txt') }}" text: "{{ lookup('ansible.builtin.file', '{{ role_path }}/files/nxos_show_interface.txt') }}"
parser: parser:
name: ansible.utils.ttp name: ansible.utils.ttp
template_path: "{{ role_path }}/templates/nxos_show_interface.ttp" template_path: "{{ role_path }}/templates/nxos_show_interface.ttp"

View File

@ -6,7 +6,7 @@
recurse: false recurse: false
use_regex: true use_regex: true
patterns: patterns:
- '^(?!_|main).+$' - "^(?!_|main).+$"
delegate_to: localhost delegate_to: localhost
register: found register: found

View File

@ -3,10 +3,7 @@
ansible.builtin.set_fact: ansible.builtin.set_fact:
data_sources: data_sources:
- data: - data:
[ [{ "name": "GigabitEthernet0/1" }, { "name": "GigabitEthernet0/2" }]
{ "name": "GigabitEthernet0/1" },
{ "name": "GigabitEthernet0/2" },
]
match_key: name match_key: name
name: acl_interfaces name: acl_interfaces
- data: - data:

View File

@ -59,7 +59,6 @@
ansible.utils.fact_diff: ansible.utils.fact_diff:
before: "{{ before|to_nice_yaml }}" before: "{{ before|to_nice_yaml }}"
after: "{{ after|to_nice_yaml }}" after: "{{ after|to_nice_yaml }}"
# TASK [ansible.utils.fact_diff] ************************************** # TASK [ansible.utils.fact_diff] **************************************
# --- before # --- before
# +++ after # +++ after
@ -74,7 +73,6 @@
# changed: [localhost] # changed: [localhost]
#### Show the difference between complex object using restconf #### Show the difference between complex object using restconf
# ansible_connection: ansible.netcommon.httpapi # ansible_connection: ansible.netcommon.httpapi
# ansible_httpapi_use_ssl: True # ansible_httpapi_use_ssl: True

View File

@ -6,7 +6,7 @@
recurse: false recurse: false
use_regex: true use_regex: true
patterns: patterns:
- '^(?!_|main).+$' - "^(?!_|main).+$"
delegate_to: localhost delegate_to: localhost
register: found register: found

View File

@ -6,7 +6,7 @@
plugin: plugin:
vars: vars:
skip_lines: skip_lines:
- '+' - "+"
ignore_errors: true ignore_errors: true
register: result register: result

View File

@ -6,7 +6,7 @@
recurse: false recurse: false
use_regex: true use_regex: true
patterns: patterns:
- '^(?!_|main).+$' - "^(?!_|main).+$"
delegate_to: localhost delegate_to: localhost
register: found register: found

View File

@ -1,20 +1,20 @@
--- ---
- name: Setup xml and expected json - name: Setup xml and expected json
ansible.builtin.set_fact: ansible.builtin.set_fact:
data: " data: '
<netconf-state xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\"><schemas><schema/></schemas></netconf-state> <netconf-state xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring"><schemas><schema/></schemas></netconf-state>
" '
output: { output:
"netconf-state": { {
"@xmlns": "urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring", "netconf-state":
"schemas": { {
"schema": null "@xmlns": "urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring",
} "schemas": { "schema": null },
},
} }
}
- debug: - debug:
msg: "{{ data|ansible.utils.from_xml() }}" msg: "{{ data|ansible.utils.from_xml() }}"
- name: Integration tests with and without default engine as xmltodict and - name: Integration tests with and without default engine as xmltodict and
assert: assert:
@ -25,7 +25,7 @@
- name: Setup invalid xml as input to ansible.utils.from_xml. - name: Setup invalid xml as input to ansible.utils.from_xml.
ansible.builtin.set_fact: ansible.builtin.set_fact:
data: "<netconf-state xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\">" data: '<netconf-state xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring">'
- name: validate input xml - name: validate input xml
ansible.builtin.set_fact: ansible.builtin.set_fact:

View File

@ -21,7 +21,6 @@
# ansible_facts: # ansible_facts:
# value: '0' # value: '0'
#### Working with hostvars #### Working with hostvars
- name: Retrieve a value deep inside all of the host's vars - name: Retrieve a value deep inside all of the host's vars
@ -37,7 +36,6 @@
# as_filter: '0' # as_filter: '0'
# as_lookup: '0' # as_lookup: '0'
#### Used alongside ansible.utils.to_paths #### Used alongside ansible.utils.to_paths
- name: Get the paths for the object - name: Get the paths for the object
@ -53,7 +51,6 @@
vars: vars:
path: "{{ item }}" path: "{{ item }}"
value: "{{ vars|ansible.utils.get_path(item) }}" value: "{{ vars|ansible.utils.get_path(item) }}"
# TASK [Get the paths for the object] ******************************* # TASK [Get the paths for the object] *******************************
# ok: [nxos101] => changed=false # ok: [nxos101] => changed=false
# ansible_facts: # ansible_facts:
@ -73,7 +70,6 @@
# ok: [nxos101] => (item=a.b.c.e[1]) => # ok: [nxos101] => (item=a.b.c.e[1]) =>
# msg: The value of path a.b.c.e[1] in vars is False # msg: The value of path a.b.c.e[1] in vars is False
#### Working with complex structures and transforming results #### Working with complex structures and transforming results
# - name: Retrieve the current interface config # - name: Retrieve the current interface config
@ -92,7 +88,6 @@
# - by_name['Ethernet1/2'].description|upper # - by_name['Ethernet1/2'].description|upper
# - by_name['Ethernet1/3'].description|default('') # - by_name['Ethernet1/3'].description|default('')
# TASK [Get the description of several interfaces] ****************** # TASK [Get the description of several interfaces] ******************
# ok: [nxos101] => (item=by_name['Ethernet1/1'].description) => changed=false # ok: [nxos101] => (item=by_name['Ethernet1/1'].description) => changed=false
# msg: Configured by ansible # msg: Configured by ansible

View File

@ -21,7 +21,6 @@
# ansible_facts: # ansible_facts:
# value: '0' # value: '0'
#### Working with hostvars #### Working with hostvars
- name: Retrieve a value deep inside all of the host's vars - name: Retrieve a value deep inside all of the host's vars
@ -37,7 +36,6 @@
# as_filter: '0' # as_filter: '0'
# as_lookup: '0' # as_lookup: '0'
#### Used alongside ansible.utils.to_paths #### Used alongside ansible.utils.to_paths
- name: Get the paths for the object - name: Get the paths for the object
@ -53,7 +51,6 @@
vars: vars:
path: "{{ item }}" path: "{{ item }}"
value: "{{ lookup('ansible.utils.get_path', hostvars[inventory_hostname], item) }}" value: "{{ lookup('ansible.utils.get_path', hostvars[inventory_hostname], item) }}"
# TASK [Get the paths for the object] ******************************* # TASK [Get the paths for the object] *******************************
# ok: [nxos101] => changed=false # ok: [nxos101] => changed=false
# ansible_facts: # ansible_facts:
@ -73,7 +70,6 @@
# ok: [nxos101] => (item=a.b.c.e[1]) => # ok: [nxos101] => (item=a.b.c.e[1]) =>
# msg: The value of path a.b.c.e[1] in vars is False # msg: The value of path a.b.c.e[1] in vars is False
#### Working with complex structures and transforming results #### Working with complex structures and transforming results
# - name: Retrieve the current interface config # - name: Retrieve the current interface config
@ -92,7 +88,6 @@
# - by_name['Ethernet1/2'].description|upper # - by_name['Ethernet1/2'].description|upper
# - by_name['Ethernet1/3'].description|default('') # - by_name['Ethernet1/3'].description|default('')
# TASK [Get the description of several interfaces] ****************** # TASK [Get the description of several interfaces] ******************
# ok: [nxos101] => (item=by_name['Ethernet1/1'].description) => changed=false # ok: [nxos101] => (item=by_name['Ethernet1/1'].description) => changed=false
# msg: Configured by ansible # msg: Configured by ansible

View File

@ -6,7 +6,7 @@
recurse: false recurse: false
use_regex: true use_regex: true
patterns: patterns:
- '^(?!_|main).+$' - "^(?!_|main).+$"
delegate_to: localhost delegate_to: localhost
register: found register: found

View File

@ -23,7 +23,7 @@
expected: "{{ a.b.c.d[0] }}" expected: "{{ a.b.c.d[0] }}"
- result: "{{ a|ansible.utils.get_path('b.c.d[1]') }}" - result: "{{ a|ansible.utils.get_path('b.c.d[1]') }}"
expected: "{{ a.b.c.d[1] }}" expected: "{{ a.b.c.d[1] }}"
- result: "{{ a|ansible.utils.get_path('b[\"c\"]') }}" - result: '{{ a|ansible.utils.get_path(''b["c"]'') }}'
expected: "{{ a.b.c }}" expected: "{{ a.b.c }}"
- result: "{{ lookup('ansible.utils.get_path', vars, 'a') }}" - result: "{{ lookup('ansible.utils.get_path', vars, 'a') }}"
expected: "{{ a }}" expected: "{{ a }}"
@ -37,7 +37,7 @@
expected: "{{ a.b.c.d[0] }}" expected: "{{ a.b.c.d[0] }}"
- result: "{{ lookup('ansible.utils.get_path', a, 'b.c.d[1]') }}" - result: "{{ lookup('ansible.utils.get_path', a, 'b.c.d[1]') }}"
expected: "{{ a.b.c.d[1] }}" expected: "{{ a.b.c.d[1] }}"
- result: "{{ lookup('ansible.utils.get_path', a, 'b[\"c\"]') }}" - result: '{{ lookup(''ansible.utils.get_path'', a, ''b["c"]'') }}'
expected: "{{ a.b.c }}" expected: "{{ a.b.c }}"
- ansible.builtin.set_fact: - ansible.builtin.set_fact:

View File

@ -51,7 +51,6 @@
# ok: [sw01] => (item=2) => # ok: [sw01] => (item=2) =>
# msg: 3 is > than 1 # msg: 3 is > than 1
#### Working with lists of dictionaries #### Working with lists of dictionaries
- ansible.builtin.set_fact: - ansible.builtin.set_fact:
@ -94,7 +93,7 @@
msg: "The device named {{ data[item].name }} is a {{ data[item].type }}" msg: "The device named {{ data[item].name }} is a {{ data[item].type }}"
loop: "{{ data|ansible.utils.index_of('regex', expression, 'name') }}" loop: "{{ data|ansible.utils.index_of('regex', expression, 'name') }}"
vars: vars:
expression: '\.corp$' # ends with .corp expression: '\.corp$' # ends with .corp
# TASK [Find the index of all devices with a .corp name] ********************* # TASK [Find the index of all devices with a .corp name] *********************
# ok: [nxos101] => (item=2) => # ok: [nxos101] => (item=2) =>
@ -102,7 +101,6 @@
# ok: [nxos101] => (item=3) => # ok: [nxos101] => (item=3) =>
# msg: The device named fw02.example.corp is a firewall # msg: The device named fw02.example.corp is a firewall
#### Working with complex structures from resource modules #### Working with complex structures from resource modules
# - name: Retrieve the current L3 interface configuration # - name: Retrieve the current L3 interface configuration
@ -153,7 +151,6 @@
# ok: [nxos101] => (item=[{'interface_idx': '128', 'address_idxs': [0]}, 0]) => # ok: [nxos101] => (item=[{'interface_idx': '128', 'address_idxs': [0]}, 0]) =>
# msg: mgmt0 has ip 192.168.101.14/24 # msg: mgmt0 has ip 192.168.101.14/24
#### Working with deeply nested data #### Working with deeply nested data
- ansible.builtin.set_fact: - ansible.builtin.set_fact:
@ -201,7 +198,6 @@
index: 3 index: 3
index: 3 index: 3
- name: Find the description of loopback111, subinterface index 10 - name: Find the description of loopback111, subinterface index 10
debug: debug:
msg: |- msg: |-

View File

@ -58,7 +58,7 @@
vars: vars:
params: params:
data: "{{ data }}" data: "{{ data }}"
test: '>' test: ">"
value: 1 value: 1
# TASK [Find numbers greater than 1, using with] ***************************** # TASK [Find numbers greater than 1, using with] *****************************
@ -67,7 +67,6 @@
# ok: [nxos101] => (item=2) => # ok: [nxos101] => (item=2) =>
# msg: 3 is > than 1 # msg: 3 is > than 1
#### Working with lists of dictionaries #### Working with lists of dictionaries
- ansible.builtin.set_fact: - ansible.builtin.set_fact:
@ -110,7 +109,7 @@
msg: "The device named {{ data[item].name }} is a {{ data[item].type }}" msg: "The device named {{ data[item].name }} is a {{ data[item].type }}"
loop: "{{ lookup('ansible.utils.index_of', data, 'regex', expression, 'name') }}" loop: "{{ lookup('ansible.utils.index_of', data, 'regex', expression, 'name') }}"
vars: vars:
expression: '\.corp$' # ends with .corp expression: '\.corp$' # ends with .corp
# TASK [Find the index of all devices with a .corp name] ********************* # TASK [Find the index of all devices with a .corp name] *********************
# ok: [nxos101] => (item=2) => # ok: [nxos101] => (item=2) =>
@ -118,7 +117,6 @@
# ok: [nxos101] => (item=3) => # ok: [nxos101] => (item=3) =>
# msg: The device named fw02.example.corp is a firewall # msg: The device named fw02.example.corp is a firewall
#### Working with complex structures from resource modules #### Working with complex structures from resource modules
# - name: Retrieve the current L3 interface configuration # - name: Retrieve the current L3 interface configuration
@ -169,7 +167,6 @@
# ok: [nxos101] => (item=[{'interface_idx': '128', 'address_idxs': [0]}, 0]) => # ok: [nxos101] => (item=[{'interface_idx': '128', 'address_idxs': [0]}, 0]) =>
# msg: mgmt0 has ip 192.168.101.14/24 # msg: mgmt0 has ip 192.168.101.14/24
#### Working with deeply nested data #### Working with deeply nested data
- ansible.builtin.set_fact: - ansible.builtin.set_fact:
@ -217,7 +214,6 @@
index: 3 index: 3
index: 3 index: 3
- name: Find the description of loopback111, subinterface index 10 - name: Find the description of loopback111, subinterface index 10
debug: debug:
msg: |- msg: |-

View File

@ -6,7 +6,7 @@
recurse: false recurse: false
use_regex: true use_regex: true
patterns: patterns:
- '^(?!_|main).+$' - "^(?!_|main).+$"
delegate_to: localhost delegate_to: localhost
register: found register: found

View File

@ -57,7 +57,6 @@
- test: "{{ lookup('ansible.utils.index_of', complex.d, 'match', '.*d$') }}" - test: "{{ lookup('ansible.utils.index_of', complex.d, 'match', '.*d$') }}"
result: [0, 1] result: [0, 1]
- ansible.builtin.set_fact: - ansible.builtin.set_fact:
complex: complex:
a: a:

View File

@ -7,7 +7,6 @@
assert: assert:
that: "{{ result1 == '1a:2b:3c:4d:5e:6f' }}" that: "{{ result1 == '1a:2b:3c:4d:5e:6f' }}"
- name: hwaddr filter test2 - name: hwaddr filter test2
ansible.builtin.set_fact: ansible.builtin.set_fact:
result1: "{{ '1a:2b:3c:4d:5e:6f'|ansible.utils.hwaddr('cisco') }}" result1: "{{ '1a:2b:3c:4d:5e:6f'|ansible.utils.hwaddr('cisco') }}"

View File

@ -26,7 +26,6 @@
assert: assert:
that: "{{ result2 == ipaddr_result2 }}" that: "{{ result2 == ipaddr_result2 }}"
- name: ipaddr filter with public network query - name: ipaddr filter with public network query
ansible.builtin.set_fact: ansible.builtin.set_fact:
result3: "{{ value|ansible.utils.ipaddr('public') }}" result3: "{{ value|ansible.utils.ipaddr('public') }}"

View File

@ -31,7 +31,6 @@
assert: assert:
that: "{{ result1 == '192.168.1.1' }}" that: "{{ result1 == '192.168.1.1' }}"
- name: Get the next tenth address in IPv6 with Ipmath filter - name: Get the next tenth address in IPv6 with Ipmath filter
ansible.builtin.set_fact: ansible.builtin.set_fact:
result1: "{{ '2001::1'|ansible.utils.ipmath('10') }}" result1: "{{ '2001::1'|ansible.utils.ipmath('10') }}"

View File

@ -4,7 +4,7 @@
value: value:
- 192.24.2.1 - 192.24.2.1
- ::ffff:192.168.32.0/120 - ::ffff:192.168.32.0/120
- '' - ""
- ::ffff:192.24.2.1/128 - ::ffff:192.24.2.1/128
- 192.168.32.0/24 - 192.168.32.0/24
- fe80::100/10 - fe80::100/10

View File

@ -7,7 +7,6 @@
assert: assert:
that: "{{ result1 == '1a:2b:3c:4d:5e:6f' }}" that: "{{ result1 == '1a:2b:3c:4d:5e:6f' }}"
- name: macaddr filter test2 - name: macaddr filter test2
ansible.builtin.set_fact: ansible.builtin.set_fact:
result1: "{{ '1a:2b:3c:4d:5e:6f'|ansible.utils.macaddr('cisco') }}" result1: "{{ '1a:2b:3c:4d:5e:6f'|ansible.utils.macaddr('cisco') }}"

View File

@ -6,7 +6,7 @@
recurse: false recurse: false
use_regex: true use_regex: true
patterns: patterns:
- '^(?!_|main).+$' - "^(?!_|main).+$"
delegate_to: localhost delegate_to: localhost
register: found register: found

View File

@ -15,7 +15,6 @@
assert: assert:
that: "{{ result1 == False }}" that: "{{ result1 == False }}"
- name: network_in_network filter test3 - name: network_in_network filter test3
ansible.builtin.set_fact: ansible.builtin.set_fact:
result1: "{{ '192.168.0.0/16'|ansible.utils.network_in_network('192.168.0.0/24') }}" result1: "{{ '192.168.0.0/16'|ansible.utils.network_in_network('192.168.0.0/24') }}"

View File

@ -15,7 +15,6 @@
assert: assert:
that: "{{ result1 == False }}" that: "{{ result1 == False }}"
- name: network_in_usable filter test3 - name: network_in_usable filter test3
ansible.builtin.set_fact: ansible.builtin.set_fact:
result1: "{{ '192.168.0.0/16'|ansible.utils.network_in_usable('192.168.0.255') }}" result1: "{{ '192.168.0.0/16'|ansible.utils.network_in_usable('192.168.0.255') }}"

View File

@ -1,23 +1,23 @@
--- ---
address: '192.168.144.5' address: "192.168.144.5"
subnet: '192.168.0.0/16' subnet: "192.168.0.0/16"
result1_val: result1_val:
- "192.24.2.1" - "192.24.2.1"
- "192.168.32.0/24" - "192.168.32.0/24"
result2_val: result2_val:
- "::ffff:192.24.2.1/128" - "::ffff:192.24.2.1/128"
- "::ffff:192.168.32.0/120" - "::ffff:192.168.32.0/120"
result3_val: result3_val:
- "192.24.2.1" - "192.24.2.1"
ipaddr_result1: ipaddr_result1:
- 192.24.2.1 - 192.24.2.1
- ::1 - ::1
- 192.168.32.0/24 - 192.168.32.0/24
- fe80::100/10 - fe80::100/10
- 2001:db8:32c:faad::/64 - 2001:db8:32c:faad::/64
ipaddr_result2: ipaddr_result2:
- 192.24.2.1/32 - 192.24.2.1/32
@ -33,29 +33,29 @@ ipaddr_result4:
- 2001:db8:32c:faad::/64 - 2001:db8:32c:faad::/64
ipwrap_result1: ipwrap_result1:
- "192.24.2.1" - "192.24.2.1"
- "host.fqdn" - "host.fqdn"
- "[::1]" - "[::1]"
- "192.168.32.0/24" - "192.168.32.0/24"
- "[fe80::100]/10" - "[fe80::100]/10"
- "[2001:db8:32c:faad::]/64" - "[2001:db8:32c:faad::]/64"
- True - True
ipv6_result1: ipv6_result1:
- "::ffff:192.168.32.0/120" - "::ffff:192.168.32.0/120"
- "::ffff:192.24.2.1/128" - "::ffff:192.24.2.1/128"
- "fe80::100/10" - "fe80::100/10"
ipv6_result2: ipv6_result2:
- "192.168.32.0/24" - "192.168.32.0/24"
- "192.24.2.1/32" - "192.24.2.1/32"
ipv6_result3: ipv6_result3:
- "::ffff:192.168.32.0" - "::ffff:192.168.32.0"
- "::ffff:192.24.2.1" - "::ffff:192.24.2.1"
- "fe80::100" - "fe80::100"
cidr_result1: cidr_result1:
- 192.168.0.0/16 - 192.168.0.0/16
cidr_result2: 192.168.1.0/29 cidr_result2: 192.168.1.0/29

View File

@ -6,7 +6,7 @@
recurse: false recurse: false
use_regex: true use_regex: true
patterns: patterns:
- '^(?!_|main).+$' - "^(?!_|main).+$"
delegate_to: localhost delegate_to: localhost
register: found register: found

View File

@ -13,20 +13,20 @@
duplex: auto duplex: auto
is_enabled: true is_enabled: true
vifs: vifs:
- vlan_id: 100 - vlan_id: 100
description: Eth1 - VIF 100 description: Eth1 - VIF 100
mtu: 400 mtu: 400
is_enabled: true is_enabled: true
- vlan_id: 101 - vlan_id: 101
description: Eth1 - VIF 101 description: Eth1 - VIF 101
is_enabled: true is_enabled: true
- interface_name: eth2 - interface_name: eth2
description: Configured by Ansible - Interface 2 (ADMIN DOWN) description: Configured by Ansible - Interface 2 (ADMIN DOWN)
mtu: 600 mtu: 600
is_enabled: false is_enabled: false
- debug: - debug:
msg: "{{ data|ansible.utils.keep_keys(target=['desc', 'interface_'], matching_parameter= 'starts_with') }}" msg: "{{ data|ansible.utils.keep_keys(target=['desc', 'interface_'], matching_parameter= 'starts_with') }}"
register: result register: result
- name: Assert result dicts - name: Assert result dicts
@ -48,20 +48,20 @@
duplex: auto duplex: auto
is_enabled: true is_enabled: true
vifs: vifs:
- vlan_id: 100 - vlan_id: 100
description: Eth1 - VIF 100 description: Eth1 - VIF 100
mtu: 400 mtu: 400
is_enabled: true is_enabled: true
- vlan_id: 101 - vlan_id: 101
description: Eth1 - VIF 101 description: Eth1 - VIF 101
is_enabled: true is_enabled: true
- interface_name: eth2 - interface_name: eth2
description: Configured by Ansible - Interface 2 (ADMIN DOWN) description: Configured by Ansible - Interface 2 (ADMIN DOWN)
mtu: 600 mtu: 600
is_enabled: false is_enabled: false
- debug: - debug:
msg: "{{ data|ansible.utils.keep_keys(target=['interface_name', 'is_enabled', 'vlan_id']) }}" msg: "{{ data|ansible.utils.keep_keys(target=['interface_name', 'is_enabled', 'vlan_id']) }}"
register: result register: result
- name: Assert result dicts - name: Assert result dicts

View File

@ -5,8 +5,8 @@ keep:
- interface_name: eth1 - interface_name: eth1
description: Configured by Ansible - Interface 1 description: Configured by Ansible - Interface 1
vifs: vifs:
- description: Eth1 - VIF 100 - description: Eth1 - VIF 100
- description: Eth1 - VIF 101 - description: Eth1 - VIF 101
- interface_name: eth2 - interface_name: eth2
description: Configured by Ansible - Interface 2 (ADMIN DOWN) description: Configured by Ansible - Interface 2 (ADMIN DOWN)
@ -16,9 +16,9 @@ keep_default:
- interface_name: eth1 - interface_name: eth1
is_enabled: true is_enabled: true
vifs: vifs:
- vlan_id: 100 - vlan_id: 100
is_enabled: true is_enabled: true
- vlan_id: 101 - vlan_id: 101
is_enabled: true is_enabled: true
- interface_name: eth2 - interface_name: eth2
is_enabled: false is_enabled: false

View File

@ -6,7 +6,7 @@
recurse: false recurse: false
use_regex: true use_regex: true
patterns: patterns:
- '^(?!_|main).+$' - "^(?!_|main).+$"
delegate_to: localhost delegate_to: localhost
register: found register: found

View File

@ -6,7 +6,7 @@
recurse: false recurse: false
use_regex: true use_regex: true
patterns: patterns:
- '^(?!_|main).+$' - "^(?!_|main).+$"
delegate_to: localhost delegate_to: localhost
register: found register: found

View File

@ -6,42 +6,42 @@
ansible.builtin.set_fact: ansible.builtin.set_fact:
network_resources: network_resources:
modules: modules:
- 'acl_interfaces' - "acl_interfaces"
- 'acls' - "acls"
- 'bgp_address_family' - "bgp_address_family"
- 'bgp_global' - "bgp_global"
- 'interfaces' - "interfaces"
- 'l2_interfaces' - "l2_interfaces"
- 'l3_interfaces' - "l3_interfaces"
- 'lacp' - "lacp"
- 'lacp_interfaces' - "lacp_interfaces"
- 'lag_interfaces' - "lag_interfaces"
- 'lldp_global' - "lldp_global"
- 'lldp_interfaces' - "lldp_interfaces"
- 'logging_global' - "logging_global"
- 'ospf_interfaces' - "ospf_interfaces"
- 'ospfv2' - "ospfv2"
- 'ospfv3' - "ospfv3"
- 'prefix_lists' - "prefix_lists"
- 'route_maps' - "route_maps"
- 'static_routes' - "static_routes"
- 'vlans' - "vlans"
- name: Setup target resources with bangs - name: Setup target resources with bangs
ansible.builtin.set_fact: ansible.builtin.set_fact:
provided_resources: provided_resources:
- '!all' - "!all"
- '!acl_interfaces' - "!acl_interfaces"
- 'acls' - "acls"
- 'bgp_address_family' - "bgp_address_family"
- 'bgp_global' - "bgp_global"
- name: Setup target resources with bangs - name: Setup target resources with bangs
ansible.builtin.set_fact: ansible.builtin.set_fact:
expected_network_resources: expected_network_resources:
- 'acls' - "acls"
- 'bgp_address_family' - "bgp_address_family"
- 'bgp_global' - "bgp_global"
- name: Get the final list of resources - name: Get the final list of resources
set_fact: set_fact:
@ -51,6 +51,6 @@
assert: assert:
that: that:
- "{{ expected_network_resources | symmetric_difference(final_network_resources['actionable']) |length\ - "{{ expected_network_resources | symmetric_difference(final_network_resources['actionable']) |length\
\ == 0 }}" \ == 0 }}"
- debug: - debug:
msg: "END param_list_compare integration tests on connection={{ ansible_connection }}" msg: "END param_list_compare integration tests on connection={{ ansible_connection }}"

View File

@ -6,7 +6,7 @@
recurse: false recurse: false
use_regex: true use_regex: true
patterns: patterns:
- '^(?!_|main).+$' - "^(?!_|main).+$"
delegate_to: localhost delegate_to: localhost
register: found register: found

View File

@ -14,23 +14,23 @@
duplex: auto duplex: auto
enabled: true enabled: true
vifs: vifs:
- vlan_id: 100 - vlan_id: 100
description: Eth1 - VIF 100 description: Eth1 - VIF 100
mtu: 400 mtu: 400
enabled: true enabled: true
notes: notes:
- note 1 - note 1
- note 2 - note 2
- vlan_id: 101 - vlan_id: 101
description: Eth1 - VIF 101 description: Eth1 - VIF 101
enabled: true enabled: true
- name: eth2 - name: eth2
description: Configured by Ansible - Interface 2 (ADMIN DOWN) description: Configured by Ansible - Interface 2 (ADMIN DOWN)
mtu: 600 mtu: 600
enabled: false enabled: false
- debug: - debug:
msg: "{{ data|ansible.utils.remove_keys(target=['notes', 'comment']) }}" msg: "{{ data|ansible.utils.remove_keys(target=['notes', 'comment']) }}"
register: result register: result
- name: Assert result dicts - name: Assert result dicts

View File

@ -1,25 +1,25 @@
--- ---
remove: remove:
default: default:
- name: eth0 - name: eth0
enabled: true
duplex: auto
speed: auto
- name: eth1
description: Configured by Ansible - Interface 1
mtu: 1500
speed: auto
duplex: auto
enabled: true
vifs:
- vlan_id: 100
description: Eth1 - VIF 100
mtu: 400
enabled: true enabled: true
- vlan_id: 101 duplex: auto
description: Eth1 - VIF 101 speed: auto
- name: eth1
description: Configured by Ansible - Interface 1
mtu: 1500
speed: auto
duplex: auto
enabled: true enabled: true
- name: eth2 vifs:
description: Configured by Ansible - Interface 2 (ADMIN DOWN) - vlan_id: 100
mtu: 600 description: Eth1 - VIF 100
enabled: false mtu: 400
enabled: true
- vlan_id: 101
description: Eth1 - VIF 101
enabled: true
- name: eth2
description: Configured by Ansible - Interface 2 (ADMIN DOWN)
mtu: 600
enabled: false

View File

@ -6,7 +6,7 @@
recurse: false recurse: false
use_regex: true use_regex: true
patterns: patterns:
- '^(?!_|main).+$' - "^(?!_|main).+$"
delegate_to: localhost delegate_to: localhost
register: found register: found

View File

@ -13,20 +13,20 @@
duplex: auto duplex: auto
enabled: true enabled: true
vifs: vifs:
- vlan_id: 100 - vlan_id: 100
description: Eth1 - VIF 100 description: Eth1 - VIF 100
mtu: 400 mtu: 400
enabled: true enabled: true
- vlan_id: 101 - vlan_id: 101
description: Eth1 - VIF 101 description: Eth1 - VIF 101
enabled: true enabled: true
- interface_name: eth2 - interface_name: eth2
description: Configured by Ansible - Interface 2 (ADMIN DOWN) description: Configured by Ansible - Interface 2 (ADMIN DOWN)
mtu: 600 mtu: 600
enabled: false enabled: false
- debug: - debug:
msg: "{{ data|ansible.utils.replace_keys(target=[{'before':'interface_name', 'after':'name'}]) }}" msg: "{{ data|ansible.utils.replace_keys(target=[{'before':'interface_name', 'after':'name'}]) }}"
register: result register: result
- name: Assert result dicts - name: Assert result dicts

View File

@ -1,25 +1,25 @@
--- ---
replace: replace:
default: default:
- name: eth0 - name: eth0
enabled: true
duplex: auto
speed: auto
- name: eth1
description: Configured by Ansible - Interface 1
mtu: 1500
speed: auto
duplex: auto
enabled: true
vifs:
- vlan_id: 100
description: Eth1 - VIF 100
mtu: 400
enabled: true enabled: true
- vlan_id: 101 duplex: auto
description: Eth1 - VIF 101 speed: auto
- name: eth1
description: Configured by Ansible - Interface 1
mtu: 1500
speed: auto
duplex: auto
enabled: true enabled: true
- name: eth2 vifs:
description: Configured by Ansible - Interface 2 (ADMIN DOWN) - vlan_id: 100
mtu: 600 description: Eth1 - VIF 100
enabled: false mtu: 400
enabled: true
- vlan_id: 101
description: Eth1 - VIF 101
enabled: true
- name: eth2
description: Configured by Ansible - Interface 2 (ADMIN DOWN)
mtu: 600
enabled: false

View File

@ -19,7 +19,6 @@
vars: vars:
msg: "'5' is not a valid boolean" msg: "'5' is not a valid boolean"
- name: Check argspec validation with lookup - name: Check argspec validation with lookup
ansible.builtin.set_fact: ansible.builtin.set_fact:
_result: "{{ lookup('ansible.utils.to_paths') }}" _result: "{{ lookup('ansible.utils.to_paths') }}"

View File

@ -26,7 +26,6 @@
- name: Use prepend to add the initial variable name - name: Use prepend to add the initial variable name
ansible.builtin.set_fact: ansible.builtin.set_fact:
paths: "{{ a|ansible.utils.to_paths(prepend='a') }}" paths: "{{ a|ansible.utils.to_paths(prepend='a') }}"
# TASK [Use prepend to add the initial variable name] ************************** # TASK [Use prepend to add the initial variable name] **************************
# ok: [nxos101] => changed=false # ok: [nxos101] => changed=false
# ansible_facts: # ansible_facts:
@ -36,7 +35,6 @@
# a.b.c.e[0]: true # a.b.c.e[0]: true
# a.b.c.e[1]: false # a.b.c.e[1]: false
#### Using a complex object #### Using a complex object
# - name: Make an API call # - name: Make an API call

View File

@ -26,7 +26,6 @@
- name: Use prepend to add the initial variable name - name: Use prepend to add the initial variable name
ansible.builtin.set_fact: ansible.builtin.set_fact:
paths: "{{ lookup('ansible.utils.to_paths', a, prepend='a') }}" paths: "{{ lookup('ansible.utils.to_paths', a, prepend='a') }}"
# TASK [Use prepend to add the initial variable name] ************************** # TASK [Use prepend to add the initial variable name] **************************
# ok: [nxos101] => changed=false # ok: [nxos101] => changed=false
# ansible_facts: # ansible_facts:
@ -36,7 +35,6 @@
# a.b.c.e[0]: true # a.b.c.e[0]: true
# a.b.c.e[1]: false # a.b.c.e[1]: false
#### Using a complex object #### Using a complex object
# - name: Make an API call # - name: Make an API call

View File

@ -6,7 +6,7 @@
recurse: false recurse: false
use_regex: true use_regex: true
patterns: patterns:
- '^(?!_|main).+$' - "^(?!_|main).+$"
delegate_to: localhost delegate_to: localhost
register: found register: found

View File

@ -6,7 +6,7 @@
recurse: false recurse: false
use_regex: true use_regex: true
patterns: patterns:
- '^(?!_|main).+$' - "^(?!_|main).+$"
delegate_to: localhost delegate_to: localhost
register: found register: found

View File

@ -8,7 +8,7 @@
output: "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<interface-configurations xmlns=\"http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg\">\n\t<interface-configuration></interface-configuration>\n</interface-configurations>" output: "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<interface-configurations xmlns=\"http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg\">\n\t<interface-configuration></interface-configuration>\n</interface-configurations>"
- debug: - debug:
msg: "{{ data|ansible.utils.to_xml() }}" msg: "{{ data|ansible.utils.to_xml() }}"
- name: Integration tests with and without default engine as xmltodict and - name: Integration tests with and without default engine as xmltodict and
assert: assert:

View File

@ -6,7 +6,7 @@
recurse: false recurse: false
use_regex: true use_regex: true
patterns: patterns:
- '^(?!_|main).+$' - "^(?!_|main).+$"
delegate_to: localhost delegate_to: localhost
register: found register: found

View File

@ -1,17 +1,15 @@
{ {
"definitions": {}, "definitions": {},
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://example.com/object1615264346.json", "$id": "https://example.com/object1615264346.json",
"title": "Root", "title": "Root",
"type": "array", "type": "array",
"default": [], "default": [],
"items":{ "items": {
"$id": "#root/items", "$id": "#root/items",
"title": "Items", "title": "Items",
"type": "integer", "type": "integer",
"examples": [ "examples": [1],
1 "default": 0
], }
"default": 0
}
} }

View File

@ -1,18 +1,18 @@
{ {
"type" : "object", "type": "object",
"patternProperties": { "patternProperties": {
"^.*": { "^.*": {
"type": "object", "type": "object",
"properties": { "properties": {
"counters": { "counters": {
"properties": { "properties": {
"in_crc_errors": { "in_crc_errors": {
"type": "number", "type": "number",
"maximum": 0 "maximum": 0
} }
} }
} }
} }
} }
} }
} }

View File

@ -1,13 +1,13 @@
{ {
"type" : "object", "type": "object",
"patternProperties": { "patternProperties": {
"^.*": { "^.*": {
"type": "object", "type": "object",
"properties": { "properties": {
"enabled": { "enabled": {
"enum": [true] "enum": [true]
} }
} }
} }
} }
} }

View File

@ -1,10 +1,10 @@
{ {
"$schema": "https://json-schema.org/schema#", "$schema": "https://json-schema.org/schema#",
"type": "object", "type": "object",
"properties": { "properties": {
"name": {"type": "string"}, "name": { "type": "string" },
"email": {"format": "email"} "email": { "format": "email" }
}, },
"required": ["email"] "required": ["email"]
} }

View File

@ -1,22 +1,22 @@
{ {
"type" : "object", "type": "object",
"patternProperties": { "patternProperties": {
"^.*": { "^.*": {
"type": "object", "type": "object",
"properties": { "properties": {
"counters": { "counters": {
"properties": { "properties": {
"rate": { "rate": {
"properties": { "properties": {
"in_rate": { "in_rate": {
"type": "number", "type": "number",
"maximum": 0 "maximum": 0
} }
} }
} }
} }
} }
} }
} }
} }
} }

View File

@ -1,14 +1,14 @@
{ {
"type" : "object", "type": "object",
"patternProperties": { "patternProperties": {
"^.*": { "^.*": {
"type": "object", "type": "object",
"properties": { "properties": {
"oper_status": { "oper_status": {
"type": "string", "type": "string",
"pattern": "up" "pattern": "up"
} }
} }
} }
} }
} }

View File

@ -1,4 +1,4 @@
{ {
"name": "ansible", "name": "ansible",
"email": "ansible@redhat.com" "email": "ansible@redhat.com"
} }

View File

@ -1,20 +1,20 @@
--- ---
- name: Set up data and criteria - name: Set up data and criteria
ansible.builtin.set_fact: ansible.builtin.set_fact:
fail_config: "{{ lookup('ansible.builtin.file', 'data/fail.cfg') }}" fail_config: "{{ lookup('ansible.builtin.file', 'data/fail.cfg') }}"
warn_config: "{{ lookup('ansible.builtin.file', 'data/warn.cfg') }}" warn_config: "{{ lookup('ansible.builtin.file', 'data/warn.cfg') }}"
pass_config: "{{ lookup('ansible.builtin.file', 'data/pass.cfg') }}" pass_config: "{{ lookup('ansible.builtin.file', 'data/pass.cfg') }}"
rules: "{{ lookup('ansible.builtin.file', 'criteria/rules.yaml') }}" rules: "{{ lookup('ansible.builtin.file', 'criteria/rules.yaml') }}"
bad_rules: bad_rules:
- name: Invalid action - name: Invalid action
action: flunge action: flunge
rule: Flunge it! rule: Flunge it!
- name: No action - name: No action
rule: Rule rule: Rule
- name: No rule - name: No rule
action: fail action: fail
- rule: No name - rule: No name
action: fail action: fail
- name: validate configuration using config (with errors) - name: validate configuration using config (with errors)
ansible.builtin.set_fact: ansible.builtin.set_fact:

View File

@ -1,20 +1,20 @@
--- ---
- name: Set up data and criteria - name: Set up data and criteria
ansible.builtin.set_fact: ansible.builtin.set_fact:
fail_config: "{{ lookup('ansible.builtin.file', 'data/fail.cfg') }}" fail_config: "{{ lookup('ansible.builtin.file', 'data/fail.cfg') }}"
warn_config: "{{ lookup('ansible.builtin.file', 'data/warn.cfg') }}" warn_config: "{{ lookup('ansible.builtin.file', 'data/warn.cfg') }}"
pass_config: "{{ lookup('ansible.builtin.file', 'data/pass.cfg') }}" pass_config: "{{ lookup('ansible.builtin.file', 'data/pass.cfg') }}"
rules: "{{ lookup('ansible.builtin.file', 'criteria/rules.yaml') }}" rules: "{{ lookup('ansible.builtin.file', 'criteria/rules.yaml') }}"
bad_rules: bad_rules:
- name: Invalid action - name: Invalid action
action: flunge action: flunge
rule: Flunge it! rule: Flunge it!
- name: No action - name: No action
rule: Rule rule: Rule
- name: No rule - name: No rule
action: fail action: fail
- rule: No name - rule: No name
action: fail action: fail
- name: validate configuration using config (with errors) - name: validate configuration using config (with errors)
ansible.builtin.set_fact: ansible.builtin.set_fact:

View File

@ -1,20 +1,20 @@
--- ---
- name: Set up data and criteria - name: Set up data and criteria
ansible.builtin.set_fact: ansible.builtin.set_fact:
fail_config: "{{ lookup('ansible.builtin.file', 'data/fail.cfg') }}" fail_config: "{{ lookup('ansible.builtin.file', 'data/fail.cfg') }}"
warn_config: "{{ lookup('ansible.builtin.file', 'data/warn.cfg') }}" warn_config: "{{ lookup('ansible.builtin.file', 'data/warn.cfg') }}"
pass_config: "{{ lookup('ansible.builtin.file', 'data/pass.cfg') }}" pass_config: "{{ lookup('ansible.builtin.file', 'data/pass.cfg') }}"
rules: "{{ lookup('ansible.builtin.file', 'criteria/rules.yaml') }}" rules: "{{ lookup('ansible.builtin.file', 'criteria/rules.yaml') }}"
bad_rules: bad_rules:
- name: Invalid action - name: Invalid action
action: flunge action: flunge
rule: Flunge it! rule: Flunge it!
- name: No action - name: No action
rule: Rule rule: Rule
- name: No rule - name: No rule
action: fail action: fail
- rule: No name - rule: No name
action: fail action: fail
- name: validate configuration using config (with errors) - name: validate configuration using config (with errors)
ansible.utils.validate: ansible.utils.validate:

View File

@ -1,20 +1,20 @@
--- ---
- name: Set up data and criteria - name: Set up data and criteria
ansible.builtin.set_fact: ansible.builtin.set_fact:
fail_config: "{{ lookup('ansible.builtin.file', 'data/fail.cfg') }}" fail_config: "{{ lookup('ansible.builtin.file', 'data/fail.cfg') }}"
warn_config: "{{ lookup('ansible.builtin.file', 'data/warn.cfg') }}" warn_config: "{{ lookup('ansible.builtin.file', 'data/warn.cfg') }}"
pass_config: "{{ lookup('ansible.builtin.file', 'data/pass.cfg') }}" pass_config: "{{ lookup('ansible.builtin.file', 'data/pass.cfg') }}"
rules: "{{ lookup('ansible.builtin.file', 'criteria/rules.yaml') }}" rules: "{{ lookup('ansible.builtin.file', 'criteria/rules.yaml') }}"
bad_rules: bad_rules:
- name: Invalid action - name: Invalid action
action: flunge action: flunge
rule: Flunge it! rule: Flunge it!
- name: No action - name: No action
rule: Rule rule: Rule
- name: No rule - name: No rule
action: fail action: fail
- rule: No name - rule: No name
action: fail action: fail
- name: validate configuration using config (with errors) - name: validate configuration using config (with errors)
ansible.builtin.set_fact: ansible.builtin.set_fact:

View File

@ -63,11 +63,11 @@
- name: read data and criteria from file - name: read data and criteria from file
ansible.builtin.set_fact: ansible.builtin.set_fact:
data: "{{ lookup('ansible.builtin.file', 'data/show_interface.json') }}" data: "{{ lookup('ansible.builtin.file', 'data/show_interface.json') }}"
oper_status_up_criteria: "{{ lookup('ansible.builtin.file', 'criteria/oper_status_up.json') }}" oper_status_up_criteria: "{{ lookup('ansible.builtin.file', 'criteria/oper_status_up.json') }}"
enabled_check_criteria: "{{ lookup('ansible.builtin.file', 'criteria/enabled_check.json') }}" enabled_check_criteria: "{{ lookup('ansible.builtin.file', 'criteria/enabled_check.json') }}"
crc_error_check_criteria: "{{ lookup('ansible.builtin.file', 'criteria/crc_error_check.json') }}" crc_error_check_criteria: "{{ lookup('ansible.builtin.file', 'criteria/crc_error_check.json') }}"
in_rate_check_criteria: "{{ lookup('ansible.builtin.file', 'criteria/in_rate_check.json') }}" in_rate_check_criteria: "{{ lookup('ansible.builtin.file', 'criteria/in_rate_check.json') }}"
- name: validate data using jsonschema engine (invalid data read from file) - name: validate data using jsonschema engine (invalid data read from file)
ansible.builtin.set_fact: ansible.builtin.set_fact:

View File

@ -81,11 +81,11 @@
- name: read data and criteria from file - name: read data and criteria from file
ansible.builtin.set_fact: ansible.builtin.set_fact:
data: "{{ lookup('ansible.builtin.file', 'data/show_interface.json') }}" data: "{{ lookup('ansible.builtin.file', 'data/show_interface.json') }}"
oper_status_up_criteria: "{{ lookup('ansible.builtin.file', 'criteria/oper_status_up.json') }}" oper_status_up_criteria: "{{ lookup('ansible.builtin.file', 'criteria/oper_status_up.json') }}"
enabled_check_criteria: "{{ lookup('ansible.builtin.file', 'criteria/enabled_check.json') }}" enabled_check_criteria: "{{ lookup('ansible.builtin.file', 'criteria/enabled_check.json') }}"
crc_error_check_criteria: "{{ lookup('ansible.builtin.file', 'criteria/crc_error_check.json') }}" crc_error_check_criteria: "{{ lookup('ansible.builtin.file', 'criteria/crc_error_check.json') }}"
in_rate_check_criteria: "{{ lookup('ansible.builtin.file', 'criteria/in_rate_check.json') }}" in_rate_check_criteria: "{{ lookup('ansible.builtin.file', 'criteria/in_rate_check.json') }}"
- name: validate data using jsonschema engine (invalid data read from file) - name: validate data using jsonschema engine (invalid data read from file)
ansible.builtin.set_fact: ansible.builtin.set_fact:

View File

@ -61,11 +61,11 @@
- name: read data and criteria from file - name: read data and criteria from file
ansible.builtin.set_fact: ansible.builtin.set_fact:
data: "{{ lookup('ansible.builtin.file', 'data/show_interface.json') }}" data: "{{ lookup('ansible.builtin.file', 'data/show_interface.json') }}"
oper_status_up_criteria: "{{ lookup('ansible.builtin.file', 'criteria/oper_status_up.json') }}" oper_status_up_criteria: "{{ lookup('ansible.builtin.file', 'criteria/oper_status_up.json') }}"
enabled_check_criteria: "{{ lookup('ansible.builtin.file', 'criteria/enabled_check.json') }}" enabled_check_criteria: "{{ lookup('ansible.builtin.file', 'criteria/enabled_check.json') }}"
crc_error_check_criteria: "{{ lookup('ansible.builtin.file', 'criteria/crc_error_check.json') }}" crc_error_check_criteria: "{{ lookup('ansible.builtin.file', 'criteria/crc_error_check.json') }}"
in_rate_check_criteria: "{{ lookup('ansible.builtin.file', 'criteria/in_rate_check.json') }}" in_rate_check_criteria: "{{ lookup('ansible.builtin.file', 'criteria/in_rate_check.json') }}"
- name: validate data using jsonschema engine (invalid data read from file) - name: validate data using jsonschema engine (invalid data read from file)
ansible.builtin.set_fact: ansible.builtin.set_fact:
@ -79,7 +79,6 @@
ansible.builtin.set_fact: ansible.builtin.set_fact:
is_data_valid: "{{ show_interfaces is ansible.utils.validate(criteria=in_rate_check_criteria) }}" is_data_valid: "{{ show_interfaces is ansible.utils.validate(criteria=in_rate_check_criteria) }}"
- name: validate data using jsonschema engine (valid data read from file) - name: validate data using jsonschema engine (valid data read from file)
ansible.builtin.set_fact: ansible.builtin.set_fact:
data_criteria_checks: "{{ data|ansible.utils.validate(in_rate_check_criteria) }}" data_criteria_checks: "{{ data|ansible.utils.validate(in_rate_check_criteria) }}"

View File

@ -23,7 +23,7 @@ show_interfaces:
rate: rate:
in_rate: 0 in_rate: 0
out_rate: 0 out_rate: 0
description: '# interface is configures with Ansible' description: "# interface is configures with Ansible"
duplex_mode: full duplex_mode: full
enabled: false enabled: false
line_protocol: up line_protocol: up

File diff suppressed because one or more lines are too long