diff options
409 files changed, 6247 insertions, 6427 deletions
diff --git a/.ansible-lint b/.ansible-lint new file mode 100644 index 0000000..8d9bb70 --- /dev/null +++ b/.ansible-lint @@ -0,0 +1,5 @@ +--- +profile: production + +exclude_paths: + - changelogs/changelog.yaml @@ -0,0 +1,67 @@ +[flake8] + +builtins = _ + +# Print the total number of errors: +count = true + +# Don't even try to analyze these: +extend-exclude = + # No need to traverse egg info dir + *.egg-info, + # tool cache dirs + *_cache + # project env vars + .env, + # GitHub configs + .github, + # Cache files of MyPy + .mypy_cache, + # Cache files of pytest + .pytest_cache, + # Temp dir of pytest-testmon + .tmontmp, + # Occasional virtualenv dir + .venv + # VS Code + .vscode, + # Temporary build dir + build, + # This contains sdists and wheels of ansible-navigator that we don't want to check + dist, + # Metadata of `pip wheel` cmd is autogenerated + pip-wheel-metadata, + # adjacent venv + venv + # ansible won't let me + __init__.py + +# IMPORTANT: avoid using ignore option, always use extend-ignore instead +# Completely and unconditionally ignore the following errors: +extend-ignore = + F841, + # line-length + E501, + # module level import not at top of file + E402 + +# Accessibility/large fonts and PEP8 unfriendly: +max-line-length = 120 + +# Allow certain violations in certain files: +# Please keep both sections of this list sorted, as it will be easier for others to find and add entries in the future +per-file-ignores = + # The following ignores have been researched and should be considered permanent + # each should be preceeded with an explanation of each of the error codes + # If other ignores are added for a specific file in the section following this, + # these will need to be added to that line as well. + + + # S101: Allow the use of assert within the tests directory, since tests require it. + tests/**.py: S101 + + # The following were present during the initial implementation. + # They are expected to be fixed and unignored over time. + +# Count the number of occurrences of each error/warning code and print a report: +statistics = true diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml new file mode 100644 index 0000000..66f19d7 --- /dev/null +++ b/.github/dependabot.yaml @@ -0,0 +1,10 @@ +--- +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: daily + open-pull-requests-limit: 3 + labels: + - skip-changelog diff --git a/.github/workflows/check_label.yaml b/.github/workflows/check_label.yaml new file mode 100644 index 0000000..000578b --- /dev/null +++ b/.github/workflows/check_label.yaml @@ -0,0 +1,11 @@ +--- +name: Check label +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true +on: # yamllint disable-line rule:truthy + pull_request_target: + types: [opened, labeled, unlabeled, synchronize] +jobs: + check_label: + uses: ansible/ansible-content-actions/.github/workflows/check_label.yaml@main diff --git a/.github/workflows/codecoverage.yml b/.github/workflows/codecoverage.yml index b425edc..6d8f153 100644 --- a/.github/workflows/codecoverage.yml +++ b/.github/workflows/codecoverage.yml @@ -1,11 +1,10 @@ --- name: Code Coverage -on: # yamllint disable-line rule:truthy +on: # yamllint disable-line rule:truthy push: pull_request: - branches: [ main ] - + branches: [main] jobs: codecoverage: uses: ansible-network/github_actions/.github/workflows/coverage_network_devices.yml@main diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..7a2c493 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,13 @@ +--- +name: Release collection +on: # yamllint disable-line rule:truthy + release: + types: [published] +jobs: + release: + uses: ansible/ansible-content-actions/.github/workflows/release.yaml@main + with: + environment: release + secrets: + ah_token: ${{ secrets.AH_TOKEN }} + ansible_galaxy_api_key: ${{ secrets.ANSIBLE_GALAXY_API_KEY }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index aae5ce9..dedbc9e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,28 +1,29 @@ --- -name: Test collection +name: CI concurrency: group: ${{ github.head_ref || github.run_id }} cancel-in-progress: true -on: # yamllint disable-line rule:truthy +on: # yamllint disable-line rule:truthy pull_request: branches: [main] workflow_dispatch: schedule: - - cron: '0 0 * * *' - + - cron: 0 0 * * * jobs: - ansible-lint: - uses: ansible-network/github_actions/.github/workflows/ansible-lint.yml@main changelog: - uses: ansible-network/github_actions/.github/workflows/changelog.yml@main - if: github.event_name != 'schedule' + uses: ansible/ansible-content-actions/.github/workflows/changelog.yaml@main + if: github.event_name == 'pull_request' + build-import: + uses: ansible/ansible-content-actions/.github/workflows/build_import.yaml@main + ansible-lint: + uses: ansible/ansible-content-actions/.github/workflows/ansible_lint.yaml@main sanity: - uses: ansible-network/github_actions/.github/workflows/sanity.yml@main + uses: ansible/ansible-content-actions/.github/workflows/sanity.yaml@main unit-galaxy: - uses: ansible-network/github_actions/.github/workflows/unit_galaxy.yml@main + uses: ansible/ansible-content-actions/.github/workflows/unit.yaml@main unit-source: uses: ansible-network/github_actions/.github/workflows/unit_source.yml@main with: @@ -30,20 +31,22 @@ jobs: git+https://github.com/ansible-collections/ansible.utils.git git+https://github.com/ansible-collections/ansible.netcommon.git all_green: - if: ${{ always() && (github.event_name != 'schedule') }} + if: ${{ always() }} needs: - - ansible-lint - changelog + - build-import - sanity - unit-galaxy - unit-source + - ansible-lint runs-on: ubuntu-latest steps: - run: >- - python -c "assert set([ - '${{ needs.ansible-lint.result }}', + python -c "assert 'failure' not in + set([ '${{ needs.changelog.result }}', '${{ needs.sanity.result }}', - '${{ needs.unit-galaxy.result }}', + '${{ needs.unit-galaxy.result }}' + '${{ needs.ansible-lint.result }}' '${{ needs.unit-source.result }}' - ]) == {'success'}" + ])" @@ -1,5 +1,9 @@ -/tests/output/ -/changelogs/.plugin-cache.yaml +# CML/virl lab cache +.virl/ + +# A collection directory, resulting from the use of the pytest-ansible-units plugin +collections/ + # Byte-compiled / optimized / DLL files __pycache__/ @@ -54,10 +58,6 @@ coverage.xml *.mo *.pot -#ide -.vscode -*.swp - # Django stuff: *.log local_settings.py @@ -109,3 +109,10 @@ venv.bak/ # mypy .mypy_cache/ + +# ide +*.code-workspace +.vscode/ +.DS_Store + +changelogs/.plugin-cache.yaml @@ -1,4 +1,6 @@ [settings] known_first_party=ansible_collections.vyos.vyos line_length=100 +lines_after_imports=2 +lines_between_types=1 profile=black diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1b7a2a2..b031daa 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,18 +1,39 @@ --- +ci: + # format compatible with commitlint + autoupdate_commit_msg: "chore: pre-commit autoupdate" + autoupdate_schedule: monthly + autofix_commit_msg: "chore: auto fixes from pre-commit.com hooks" + repos: + - repo: https://github.com/ansible-network/collection_prep + rev: 1.1.1 + hooks: + - id: update-docs + - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.6.0 hooks: - id: check-merge-conflict + - id: check-symlinks - id: debug-statements - id: end-of-file-fixer - id: no-commit-to-branch + args: [--branch, main] - id: trailing-whitespace + - repo: https://github.com/asottile/add-trailing-comma + rev: v3.1.0 + hooks: + - id: add-trailing-comma + - repo: https://github.com/pre-commit/mirrors-prettier - rev: "v4.0.0-alpha.8" + rev: v4.0.0-alpha.8 hooks: - id: prettier + 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 @@ -21,9 +42,15 @@ repos: rev: 5.13.2 hooks: - id: isort - args: ["--filter-files"] + name: Sort import statements using isort + args: [--filter-files] - repo: https://github.com/psf/black rev: 24.4.2 hooks: - id: black + + - repo: https://github.com/pycqa/flake8 + rev: 7.0.0 + hooks: + - id: flake8 diff --git a/.prettierignore b/.prettierignore index 3b7645e..107bbd2 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,6 +1,5 @@ # Stuff we don't want priettier to ever to look into .*/ -coverage/ # Environments .env @@ -12,6 +11,13 @@ env.bak/ venv.bak/ # A linked collection directory created by pytest-ansible-units + collections/ +# Tracked but not manually edited + +# Tracked but manually formatted + +# WIP +tests/integration/targets/vyos_config/templates/config.js README.md diff --git a/.yamllint b/.yamllint deleted file mode 100644 index 7b3f7a3..0000000 --- a/.yamllint +++ /dev/null @@ -1,17 +0,0 @@ ---- -extends: default - -ignore: | - .tox - changelogs/* - -rules: - comments: - min-spaces-from-content: 1 - braces: - max-spaces-inside: 1 - level: error - brackets: - max-spaces-inside: 1 - level: error - line-length: disable @@ -1,10 +1,8 @@ - # VyOS Collection -[](https://dashboard.zuul.ansible.com/t/ansible/project/github.com/ansible-collections/vyos.vyos) <!--[](https://codecov.io/gh/ansible-collections/vyos)--> -[](https://codecov.io/gh/ansible-collections/vyos.vyos) -⚠️ **The vyos.vyos collection has been [deprecated](https://forum.ansible.com/t/the-bullhorn-123/2568#project-updates-8) and will reach it's end-of-life on December, 2025. We are no longer accepting new pull requests, except for ones that fix critical bugs or security vulnerabilities. This collection is not supported with ansible-core>2.17.** +[](https://codecov.io/gh/ansible-collections/vyos.vyos) +[](https://github.com/ansible-collections/vyos.vyos/actions/workflows/tests.yml) The Ansible VyOS collection includes a variety of Ansible content to help automate the management of VyOS network appliances. @@ -13,7 +11,7 @@ This collection has been tested against VyOS 1.1.8 (helium). <!--start requires_ansible--> ## Ansible version compatibility -This collection has been tested against following Ansible versions: **<2.18.0,>=2.15.0**. +This collection has been tested against following Ansible versions: **>=2.15.0**. For collections that support Ansible 2.9, please ensure you update your `network_os` to use the fully qualified collection name (for example, `cisco.ios.ios`). @@ -2,8 +2,6 @@ # see https://docs.openstack.org/infra/bindep/ for additional information. gcc-c++ [doc test platform:rpm] -python3-devel [test platform:rpm] -python3 [test platform:rpm] libssh-devel [test platform:rpm] libffi-devel [test platform:rpm] openssl-devel [test platform:rpm] diff --git a/changelogs/config.yaml b/changelogs/config.yaml index 53e4399..d484cf3 100644 --- a/changelogs/config.yaml +++ b/changelogs/config.yaml @@ -1,3 +1,4 @@ +--- changelog_filename_template: ../CHANGELOG.rst changelog_filename_version_depth: 0 changes_file: changelog.yaml diff --git a/changelogs/fragments/undeprecate.yaml b/changelogs/fragments/undeprecate.yaml new file mode 100644 index 0000000..4180d3e --- /dev/null +++ b/changelogs/fragments/undeprecate.yaml @@ -0,0 +1,6 @@ +--- +minor_changes: + - "Removes deprecation notice for vyos.vyos." + - "All GHA workflows have been updated to use ones from ansible-content-actions." + - "Passes latest ansible-lint with production profile." + - "Uncaps supported ansible-core versions, this collection now supports ansible-core>=2.15." diff --git a/codecov.yml b/codecov.yml index 816cb44..c77c91a 100644 --- a/codecov.yml +++ b/codecov.yml @@ -1,7 +1,12 @@ --- codecov: require_ci_to_pass: true -comment: false +comment: + layout: " diff, flags, files" + behavior: default + require_changes: false + require_base: false + require_head: true coverage: status: patch: false diff --git a/docs/vyos.vyos.vyos_bgp_address_family_module.rst b/docs/vyos.vyos.vyos_bgp_address_family_module.rst index a213ff0..f860ab7 100644 --- a/docs/vyos.vyos.vyos_bgp_address_family_module.rst +++ b/docs/vyos.vyos.vyos_bgp_address_family_module.rst @@ -1177,39 +1177,39 @@ Examples # vyos@vyos:~$ show configuration commands | match "set protocols bgp" # vyos@vyos:~$ - - name: Merge provided configuration with device configuration - vyos.vyos.vyos_bgp_address_family: - config: - as_number: "100" - address_family: - - afi: "ipv4" - redistribute: - - protocol: "static" - metric: 50 - neighbors: - - neighbor_address: "20.33.1.1/24" - address_family: - - afi: "ipv4" - allowas_in: 4 - as_override: True - attribute_unchanged: - med: True - - afi: "ipv6" - default_originate: "map01" - distribute_list: - - action: "export" - acl: 10 - - neighbor_address: "100.11.34.12" - address_family: - - afi: "ipv4" - maximum_prefix: 45 - nexthop_self: True - route_map: - - action: "export" - route_map: "map01" - - action: "import" - route_map: "map01" - weight: 50 + - name: Merge provided configuration with device configuration + vyos.vyos.vyos_bgp_address_family: + config: + as_number: "100" + address_family: + - afi: "ipv4" + redistribute: + - protocol: "static" + metric: 50 + neighbors: + - neighbor_address: "20.33.1.1/24" + address_family: + - afi: "ipv4" + allowas_in: 4 + as_override: true + attribute_unchanged: + med: true + - afi: "ipv6" + default_originate: "map01" + distribute_list: + - action: "export" + acl: 10 + - neighbor_address: "100.11.34.12" + address_family: + - afi: "ipv4" + maximum_prefix: 45 + nexthop_self: true + route_map: + - action: "export" + route_map: "map01" + - action: "import" + route_map: "map01" + weight: 50 # After State: # vyos@vyos:~$ show configuration commands | match "set protocols bgp" @@ -1323,33 +1323,32 @@ Examples # set protocols bgp 100 neighbor 100.11.34.12 address-family ipv4-unicast weight '50' # vyos@vyos:~$ - - name: Replace provided configuration with device configuration - vyos.vyos.vyos_bgp_address_family: - config: - as_number: "100" - neighbors: - - neighbor_address: "100.11.34.12" - address_family: - - afi: "ipv4" - allowas_in: 4 - as_override: True - attribute_unchanged: - med: True - - afi: "ipv6" - default_originate: "map01" - distribute_list: - - action: "export" - acl: 10 - - neighbor_address: "20.33.1.1/24" - address_family: - - afi: "ipv6" - maximum_prefix: 45 - nexthop_self: True - - state: replaced + - name: Replace provided configuration with device configuration + vyos.vyos.vyos_bgp_address_family: + config: + as_number: "100" + neighbors: + - neighbor_address: "100.11.34.12" + address_family: + - afi: "ipv4" + allowas_in: 4 + as_override: true + attribute_unchanged: + med: true + - afi: "ipv6" + default_originate: "map01" + distribute_list: + - action: "export" + acl: 10 + - neighbor_address: "20.33.1.1/24" + address_family: + - afi: "ipv6" + maximum_prefix: 45 + nexthop_self: true + state: replaced # After State: - + # # vyos@vyos:~$ show configuration commands | match "set protocols bgp" # set protocols bgp 100 address-family ipv4-unicast redistribute static metric '50' # set protocols bgp 100 neighbor 20.33.1.1/24 address-family ipv4-unicast @@ -1513,31 +1512,31 @@ Examples # set protocols bgp 100 neighbor 100.11.34.12 address-family ipv6-unicast distribute-list export '10' # vyos@vyos:~$ - - name: Override - vyos.vyos.vyos_bgp_address_family: - config: - as_number: "100" - neighbors: - - neighbor_address: "100.11.34.12" - address_family: - - afi: "ipv6" - maximum_prefix: 45 - nexthop_self: True - route_map: - - action: "import" - route_map: "map01" - address_family: - - afi: "ipv4" - aggregate_address: - - prefix: "60.9.2.0/24" - summary_only: True - - afi: "ipv6" - redistribute: - - protocol: "static" - metric: 50 - state: overridden - - # Aft=validate-moduleser State + - name: Override + vyos.vyos.vyos_bgp_address_family: + config: + as_number: "100" + neighbors: + - neighbor_address: "100.11.34.12" + address_family: + - afi: "ipv6" + maximum_prefix: 45 + nexthop_self: true + route_map: + - action: "import" + route_map: "map01" + address_family: + - afi: "ipv4" + aggregate_address: + - prefix: "60.9.2.0/24" + summary_only: true + - afi: "ipv6" + redistribute: + - protocol: "static" + metric: 50 + state: overridden + + # After State # vyos@vyos:~$ show configuration commands | match "set protocols bgp" # set protocols bgp 100 address-family ipv4-unicast aggregate-address 60.9.2.0/24 summary-only @@ -1712,18 +1711,18 @@ Examples # set protocols bgp 100 neighbor 100.11.34.12 address-family ipv6-unicast route-map import 'map01' # vyos@vyos:~$ - - name: Delete - vyos.vyos.vyos_bgp_address_family: - config: - as_number: "100" - neighbors: - - neighbor_address: "20.33.1.1/24" - address_family: - - afi: "ipv6" - - neighbor_address: "100.11.34.12" - address_family: - - afi: "ipv4" - state: deleted + - name: Delete + vyos.vyos.vyos_bgp_address_family: + config: + as_number: "100" + neighbors: + - neighbor_address: "20.33.1.1/24" + address_family: + - afi: "ipv6" + - neighbor_address: "100.11.34.12" + address_family: + - afi: "ipv4" + state: deleted # After State: @@ -1874,12 +1873,13 @@ Examples # set protocols bgp 65536 neighbor 203.0.113.5 address-family ipv6-unicast attribute-unchanged next-hop - - name: parse configs - vyos.vyos.vyos_bgp_address_family: - running_config: "{{ lookup('file', './parsed.cfg') }}" - state: parsed + - name: parse configs + vyos.vyos.vyos_bgp_address_family: + running_config: "{{ lookup('file', './parsed.cfg') }}" + state: parsed - # Module Execution: + # Module execution result: + # # "parsed": { # "address_family": [ # { @@ -1957,12 +1957,12 @@ Examples # set protocols bgp 100 neighbor 20.33.1.1/24 address-family ipv4-unicast attribute-unchanged med # set protocols bgp 100 neighbor 100.11.34.12 - - name: gather configs - vyos.vyos.vyos_bgp_address_family: - state: gathered - - # Module Execution: + - name: gather configs + vyos.vyos.vyos_bgp_address_family: + state: gathered + # Module execution result: + # # "gathered": { # "address_family": [ # { @@ -2021,40 +2021,40 @@ Examples # Using rendered: - - name: Render - vyos.vyos.vyos_bgp_address_family: - config: - as_number: "100" - address_family: - - afi: "ipv4" - redistribute: - - protocol: "static" - metric: 50 - neighbors: - - neighbor_address: "20.33.1.1/24" - address_family: - - afi: "ipv4" - allowas_in: 4 - as_override: True - attribute_unchanged: - med: True - - afi: "ipv6" - default_originate: "map01" - distribute_list: - - action: "export" - acl: 10 - - neighbor_address: "100.11.34.12" - address_family: - - afi: "ipv4" - maximum_prefix: 45 - nexthop_self: True - route_map: - - action: "export" - route_map: "map01" - - action: "import" - route_map: "map01" - weight: 50 - state: rendered + - name: Render + vyos.vyos.vyos_bgp_address_family: + config: + as_number: "100" + address_family: + - afi: "ipv4" + redistribute: + - protocol: "static" + metric: 50 + neighbors: + - neighbor_address: "20.33.1.1/24" + address_family: + - afi: "ipv4" + allowas_in: 4 + as_override: true + attribute_unchanged: + med: true + - afi: "ipv6" + default_originate: "map01" + distribute_list: + - action: "export" + acl: 10 + - neighbor_address: "100.11.34.12" + address_family: + - afi: "ipv4" + maximum_prefix: 45 + nexthop_self: true + route_map: + - action: "export" + route_map: "map01" + - action: "import" + route_map: "map01" + weight: 50 + state: rendered # Module Execution: diff --git a/docs/vyos.vyos.vyos_bgp_global_module.rst b/docs/vyos.vyos.vyos_bgp_global_module.rst index 06bd918..a2e3db7 100644 --- a/docs/vyos.vyos.vyos_bgp_global_module.rst +++ b/docs/vyos.vyos.vyos_bgp_global_module.rst @@ -2091,63 +2091,62 @@ Examples # vyos@vyos:~$ show configuration commands | match "set protocols bgp" # vyos@vyos:~$ - - name: Merge provided configuration with device configuration - vyos.vyos.vyos_bgp_global: - config: - as_number: "65536" - aggregate_address: - - prefix: "203.0.113.0/24" - as_set: true - - prefix: "192.0.2.0/24" - summary_only: true - network: - - address: "192.1.13.0/24" - backdoor: true - redistribute: - - protocol: "kernel" - metric: 45 - - protocol: "connected" - route_map: "map01" - maximum_paths: - - path: "ebgp" - count: 20 - - path: "ibgp" - count: 55 - timers: - keepalive: 35 - bgp_params: - bestpath: - as_path: "confed" - compare_routerid: true - default: - no_ipv4_unicast: true - router_id: "192.1.2.9" - confederation: - - peers: 20 - - peers: 55 - - identifier: 66 - neighbor: - - address: "192.0.2.25" - disable_connected_check: true - timers: - holdtime: 30 - keepalive: 10 - - address: "203.0.113.5" - attribute_unchanged: - as_path: true - med: true - ebgp_multihop: 2 - remote_as: 101 - update_source: "192.0.2.25" - - address: "5001::64" - maximum_prefix: 34 - distribute_list: - - acl: 20 - action: "export" - - acl: 40 - action: "import" - - state: merged + - name: Merge provided configuration with device configuration + vyos.vyos.vyos_bgp_global: + config: + as_number: "65536" + aggregate_address: + - prefix: "203.0.113.0/24" + as_set: true + - prefix: "192.0.2.0/24" + summary_only: true + network: + - address: "192.1.13.0/24" + backdoor: true + redistribute: + - protocol: "kernel" + metric: 45 + - protocol: "connected" + route_map: "map01" + maximum_paths: + - path: "ebgp" + count: 20 + - path: "ibgp" + count: 55 + timers: + keepalive: 35 + bgp_params: + bestpath: + as_path: "confed" + compare_routerid: true + default: + no_ipv4_unicast: true + router_id: "192.1.2.9" + confederation: + - peers: 20 + - peers: 55 + - identifier: 66 + neighbor: + - address: "192.0.2.25" + disable_connected_check: true + timers: + holdtime: 30 + keepalive: 10 + - address: "203.0.113.5" + attribute_unchanged: + as_path: true + med: true + ebgp_multihop: 2 + remote_as: 101 + update_source: "192.0.2.25" + - address: "5001::64" + maximum_prefix: 34 + distribute_list: + - acl: 20 + action: "export" + - acl: 40 + action: "import" + state: merged # After State # vyos@vyos:~$ show configuration commands | match "set protocols bgp" @@ -2347,26 +2346,25 @@ Examples # set protocols bgp 65536 timers keepalive '35' # vyos@vyos:~$ - - name: Replace - vyos.vyos.vyos_bgp_global: - config: - as_number: "65536" - network: - - address: "203.0.113.0/24" - route_map: map01 - redistribute: - - protocol: "static" - route_map: "map01" - neighbor: - - address: "192.0.2.40" - advertisement_interval: 72 - capability: - orf: "receive" - bgp_params: - bestpath: - as_path: "confed" - - state: replaced + - name: Replace + vyos.vyos.vyos_bgp_global: + config: + as_number: "65536" + network: + - address: "203.0.113.0/24" + route_map: map01 + redistribute: + - protocol: "static" + route_map: "map01" + neighbor: + - address: "192.0.2.40" + advertisement_interval: 72 + capability: + orf: "receive" + bgp_params: + bestpath: + as_path: "confed" + state: replaced # After state: # vyos@vyos:~$ show configuration commands | match "set protocols bgp" @@ -2544,11 +2542,11 @@ Examples # set protocols bgp 65536 redistribute static route-map 'map01' # vyos@vyos:~$ - - name: Delete configuration - vyos.vyos.vyos_bgp_global: - config: - as_number: "65536" - state: deleted + - name: Delete configuration + vyos.vyos.vyos_bgp_global: + config: + as_number: "65536" + state: deleted # After state: @@ -2634,11 +2632,11 @@ Examples # vyos@vyos:~$ - - name: Purge configuration - vyos.vyos.vyos_bgp_global: - config: - as_number: "65536" - state: purged + - name: Purge configuration + vyos.vyos.vyos_bgp_global: + config: + as_number: "65536" + state: purged # After state: @@ -2779,12 +2777,11 @@ Examples # vyos@vyos:~$ ^C # vyos@vyos:~$ - - - name: Delete configuration - vyos.vyos.vyos_bgp_global: - config: - as_number: "65536" - state: deleted + - name: Delete configuration + vyos.vyos.vyos_bgp_global: + config: + as_number: "65536" + state: deleted # Module Execution: # @@ -2835,9 +2832,9 @@ Examples # set protocols bgp 65536 redistribute static route-map 'map01' # vyos@vyos:~$ ^C - - name: gather configs - vyos.vyos.vyos_bgp_global: - state: gathered + - name: gather configs + vyos.vyos.vyos_bgp_global: + state: gathered # Module Execution: # "gathered": { @@ -2927,12 +2924,12 @@ Examples # set protocols bgp 65536 parameters distance global local '10' # set protocols bgp 65536 redistribute static route-map 'map01' - - name: parse configs - vyos.vyos.vyos_bgp_global: - running_config: "{{ lookup('file', './parsed.cfg') }}" - state: parsed - tags: - - parsed + - name: parse configs + vyos.vyos.vyos_bgp_global: + running_config: "{{ lookup('file', './parsed.cfg') }}" + state: parsed + tags: + - parsed # Module execution: # "parsed": { @@ -2999,49 +2996,48 @@ Examples # Using rendered: # -------------- - - name: Render - vyos.vyos.vyos_bgp_global: - config: - as_number: "65536" - network: - - address: "203.0.113.0/24" - route_map: map01 - redistribute: - - protocol: "static" - route_map: "map01" - bgp_params: - always_compare_med: true - dampening: - start_suppress_time: 5 - max_suppress_time: 20 - half_life: 33 - re_use: 60 - distance: - - type: "internal" - value: 20 - - type: "local" - value: 10 - - type: "external" - value: 66 - bestpath: - as_path: "confed" - compare_routerid: true - default: - no_ipv4_unicast: true - neighbor: - - address: "192.0.2.43" - disable_connected_check: true - advertisement_interval: 72 - capability: - dynamic: true - timers: - holdtime: 30 - keepalive: 10 - - address: "203.0.113.0" - capability: - orf: "receive" - - state: rendered + - name: Render + vyos.vyos.vyos_bgp_global: + config: + as_number: "65536" + network: + - address: "203.0.113.0/24" + route_map: map01 + redistribute: + - protocol: "static" + route_map: "map01" + bgp_params: + always_compare_med: true + dampening: + start_suppress_time: 5 + max_suppress_time: 20 + half_life: 33 + re_use: 60 + distance: + - type: "internal" + value: 20 + - type: "local" + value: 10 + - type: "external" + value: 66 + bestpath: + as_path: "confed" + compare_routerid: true + default: + no_ipv4_unicast: true + neighbor: + - address: "192.0.2.43" + disable_connected_check: true + advertisement_interval: 72 + capability: + dynamic: true + timers: + holdtime: 30 + keepalive: 10 + - address: "203.0.113.0" + capability: + orf: "receive" + state: rendered # Module Execution: # "rendered": [ diff --git a/docs/vyos.vyos.vyos_command_module.rst b/docs/vyos.vyos.vyos_command_module.rst index 042624b..34506d4 100644 --- a/docs/vyos.vyos.vyos_command_module.rst +++ b/docs/vyos.vyos.vyos_command_module.rst @@ -145,26 +145,26 @@ Examples - name: show configuration on ethernet devices eth0 and eth1 vyos.vyos.vyos_command: commands: - - show interfaces ethernet {{ item }} + - show interfaces ethernet {{ item }} with_items: - - eth0 - - eth1 + - eth0 + - eth1 - name: run multiple commands and check if version output contains specific version string vyos.vyos.vyos_command: commands: - - show version - - show hardware cpu + - show version + - show hardware cpu wait_for: - - result[0] contains 'VyOS 1.1.7' + - result[0] contains 'VyOS 1.1.7' - name: run command that requires answering a prompt vyos.vyos.vyos_command: commands: - - command: rollback 1 - prompt: Proceed with reboot? [confirm][y] - answer: y + - command: rollback 1 + prompt: Proceed with reboot? [confirm][y] + answer: y diff --git a/docs/vyos.vyos.vyos_config_module.rst b/docs/vyos.vyos.vyos_config_module.rst index a99e264..999a3f5 100644 --- a/docs/vyos.vyos.vyos_config_module.rst +++ b/docs/vyos.vyos.vyos_config_module.rst @@ -223,14 +223,14 @@ Examples - name: configure the remote device vyos.vyos.vyos_config: lines: - - set system host-name {{ inventory_hostname }} - - set service lldp - - delete service dhcp-server + - set system host-name {{ inventory_hostname }} + - set service lldp + - delete service dhcp-server - name: backup and load from file vyos.vyos.vyos_config: src: vyos.cfg - backup: yes + backup: true - name: render a Jinja2 template onto the VyOS router vyos.vyos.vyos_config: @@ -240,11 +240,11 @@ Examples vyos.vyos.vyos_config: lines: # - set int eth eth2 description 'OUTSIDE' - - set interface ethernet eth2 description 'OUTSIDE' + - set interface ethernet eth2 description 'OUTSIDE' - name: configurable backup path vyos.vyos.vyos_config: - backup: yes + backup: true backup_options: filename: backup.cfg dir_path: /home/user diff --git a/docs/vyos.vyos.vyos_facts_module.rst b/docs/vyos.vyos.vyos_facts_module.rst index af39283..836224f 100644 --- a/docs/vyos.vyos.vyos_facts_module.rst +++ b/docs/vyos.vyos.vyos_facts_module.rst @@ -120,15 +120,15 @@ Examples # Collect only the interfaces facts - vyos.vyos.vyos_facts: gather_subset: - - '!all' - - '!min' + - '!all' + - '!min' gather_network_resources: - - interfaces + - interfaces # Do not collect interfaces facts - vyos.vyos.vyos_facts: gather_network_resources: - - '!interfaces' + - '!interfaces' # Collect interfaces and minimal default facts - vyos.vyos.vyos_facts: diff --git a/docs/vyos.vyos.vyos_firewall_global_module.rst b/docs/vyos.vyos.vyos_firewall_global_module.rst index e090e2e..34293b1 100644 --- a/docs/vyos.vyos.vyos_firewall_global_module.rst +++ b/docs/vyos.vyos.vyos_firewall_global_module.rst @@ -849,30 +849,30 @@ Examples all: true broadcast: true state_policy: - - connection_type: established - action: accept - log: true - - connection_type: invalid - action: reject + - connection_type: established + action: accept + log: true + - connection_type: invalid + action: reject route_redirects: - - afi: ipv4 - ip_src_route: true - icmp_redirects: - send: true - receive: false + - afi: ipv4 + ip_src_route: true + icmp_redirects: + send: true + receive: false group: address_group: - - name: MGMT-HOSTS - description: This group has the Management hosts address list - members: - - address: 192.0.1.1 - - address: 192.0.1.3 - - address: 192.0.1.5 + - name: MGMT-HOSTS + description: This group has the Management hosts address list + members: + - address: 192.0.1.1 + - address: 192.0.1.3 + - address: 192.0.1.5 network_group: - - name: MGMT - description: This group has the Management network addresses - members: - - address: 192.0.1.0/24 + - name: MGMT + description: This group has the Management network addresses + members: + - address: 192.0.1.0/24 state: merged # # @@ -1228,6 +1228,7 @@ Examples # ] # # "after": [] + # # After state # ------------ # vyos@192# run show configuration commands | grep firewall @@ -1259,7 +1260,7 @@ Examples # set firewall state-policy invalid action 'reject' # set firewall syn-cookies 'enable' # set firewall twa-hazards-protection 'enable' - # + - name: Replace firewall global attributes configuration. vyos.vyos.vyos_firewall_global: config: @@ -1268,39 +1269,39 @@ Examples log_martians: true syn_cookies: true twa_hazards_protection: true - ping: + ping: null all: true broadcast: true state_policy: - - connection_type: established - action: accept - log: true - - connection_type: invalid - action: reject + - connection_type: established + action: accept + log: true + - connection_type: invalid + action: reject route_redirects: - - afi: ipv4 - ip_src_route: true - icmp_redirects: - send: true - receive: false + - afi: ipv4 + ip_src_route: true + icmp_redirects: + send: true + receive: false group: address_group: - - name: SALES-HOSTS - description: Sales office hosts address list - members: - - address: 192.0.2.1 - - address: 192.0.2.2 - - address: 192.0.2.3 - - name: ENG-HOSTS - description: Sales office hosts address list - members: - - address: 192.0.3.1 - - address: 192.0.3.2 + - name: SALES-HOSTS + description: Sales office hosts address list + members: + - address: 192.0.2.1 + - address: 192.0.2.2 + - address: 192.0.2.3 + - name: ENG-HOSTS + description: Sales office hosts address list + members: + - address: 192.0.3.1 + - address: 192.0.3.2 network_group: - - name: MGMT - description: This group has the Management network addresses - members: - - address: 192.0.1.0/24 + - name: MGMT + description: This group has the Management network addresses + members: + - address: 192.0.1.0/24 state: replaced # # @@ -1518,7 +1519,6 @@ Examples # - name: Gather firewall global config with provided configurations vyos.vyos.vyos_firewall_global: - config: state: gathered # # @@ -1641,40 +1641,41 @@ Examples log_martians: true syn_cookies: true twa_hazards_protection: true - ping: + ping: null all: true broadcast: true state_policy: - - connection_type: established - action: accept - log: true - - connection_type: invalid - action: reject + - connection_type: established + action: accept + log: true + - connection_type: invalid + action: reject route_redirects: - - afi: ipv4 - ip_src_route: true - icmp_redirects: - send: true - receive: false + - afi: ipv4 + ip_src_route: true + icmp_redirects: null + send: true + receive: false group: address_group: - - name: SALES-HOSTS - description: Sales office hosts address list - members: - - address: 192.0.2.1 - - address: 192.0.2.2 - - address: 192.0.2.3 - - name: ENG-HOSTS - description: Sales office hosts address list - members: - - address: 192.0.3.1 - - address: 192.0.3.2 + - name: SALES-HOSTS + description: Sales office hosts address list + members: + - address: 192.0.2.1 + - address: 192.0.2.2 + - address: 192.0.2.3 + - name: ENG-HOSTS + description: Sales office hosts address list + members: + - address: 192.0.3.1 + - address: 192.0.3.2 network_group: - - name: MGMT - description: This group has the Management network addresses - members: - - address: 192.0.1.0/24 + - name: MGMT + description: This group has the Management network addresses + members: + - address: 192.0.1.0/24 state: rendered + # # # ------------------------- diff --git a/docs/vyos.vyos.vyos_firewall_interfaces_module.rst b/docs/vyos.vyos.vyos_firewall_interfaces_module.rst index 30e8c1d..8510812 100644 --- a/docs/vyos.vyos.vyos_firewall_interfaces_module.rst +++ b/docs/vyos.vyos.vyos_firewall_interfaces_module.rst @@ -232,34 +232,34 @@ Examples - name: Merge the provided configuration with the existing running configuration vyos.vyos.vyos_firewall_interfaces: config: - - access_rules: - - afi: ipv4 - rules: - - name: INBOUND - direction: in - - name: OUTBOUND - direction: out - - name: LOCAL - direction: local - - afi: ipv6 - rules: - - name: V6-LOCAL - direction: local - name: eth1 - - access_rules: - - afi: ipv4 - rules: - - name: INBOUND - direction: in - - name: OUTBOUND - direction: out - - name: LOCAL - direction: local - - afi: ipv6 - rules: - - name: V6-LOCAL - direction: local - name: eth3 + - access_rules: + - afi: ipv4 + rules: + - name: INBOUND + direction: in + - name: OUTBOUND + direction: out + - name: LOCAL + direction: local + - afi: ipv6 + rules: + - name: V6-LOCAL + direction: local + name: eth1 + - access_rules: + - afi: ipv4 + rules: + - name: INBOUND + direction: in + - name: OUTBOUND + direction: out + - name: LOCAL + direction: local + - afi: ipv6 + rules: + - name: V6-LOCAL + direction: local + name: eth3 state: merged # # @@ -404,15 +404,16 @@ Examples - name: Merge the provided configuration with the existing running configuration vyos.vyos.vyos_firewall_interfaces: config: - - access_rules: - - afi: ipv4 - rules: - - name: OUTBOUND - direction: in - - name: INBOUND - direction: out - name: eth1 + - access_rules: + - afi: ipv4 + rules: + - name: OUTBOUND + direction: in + - name: INBOUND + direction: out + name: eth1 state: merged + # # # ------------------------- @@ -603,27 +604,29 @@ Examples # set interfaces ethernet eth3 firewall local name 'LOCAL' # set interfaces ethernet eth3 firewall out name 'OUTBOUND' # - - name: Replace device configurations of listed firewall interfaces with provided + - name: >- + Replace device configurations of listed firewall interfaces with provided configurations vyos.vyos.vyos_firewall_interfaces: config: - - name: eth1 - access_rules: - - afi: ipv4 - rules: - - name: OUTBOUND - direction: out - - afi: ipv6 - rules: - - name: V6-LOCAL - direction: local - - name: eth3 - access_rules: - - afi: ipv4 - rules: - - name: INBOUND - direction: in + - name: eth1 + access_rules: + - afi: ipv4 + rules: + - name: OUTBOUND + direction: out + - afi: ipv6 + rules: + - name: V6-LOCAL + direction: local + - name: eth3 + access_rules: + - afi: ipv4 + rules: + - name: INBOUND + direction: in state: replaced + # # # ------------------------- @@ -791,12 +794,12 @@ Examples - name: Overrides all device configuration with provided configuration vyos.vyos.vyos_firewall_interfaces: config: - - name: eth3 - access_rules: - - afi: ipv4 - rules: - - name: INBOUND - direction: out + - name: eth3 + access_rules: + - afi: ipv4 + rules: + - name: INBOUND + direction: out state: overridden # # @@ -918,8 +921,8 @@ Examples - name: Delete firewall interfaces based on interface name. vyos.vyos.vyos_firewall_interfaces: config: - - name: eth1 - - name: eth3 + - name: eth1 + - name: eth3 state: deleted # # @@ -1047,10 +1050,10 @@ Examples - name: Delete firewall interfaces config per afi. vyos.vyos.vyos_firewall_interfaces: config: - - name: eth1 - access_rules: - - afi: ipv4 - - afi: ipv6 + - name: eth1 + access_rules: + - afi: ipv4 + - afi: ipv6 state: deleted # # @@ -1073,7 +1076,6 @@ Examples # set firewall name 'LOCAL' # set firewall name 'OUTBOUND' - # Using deleted without config # # Before state @@ -1095,7 +1097,6 @@ Examples # - name: Delete firewall interfaces config when empty config provided. vyos.vyos.vyos_firewall_interfaces: - config: state: deleted # # @@ -1119,7 +1120,6 @@ Examples # Using parsed # - # - name: Parse the provided configuration vyos.vyos.vyos_firewall_interfaces: running_config: @@ -1230,7 +1230,6 @@ Examples # - name: Gather listed firewall interfaces. vyos.vyos.vyos_firewall_interfaces: - config: state: gathered # # @@ -1307,17 +1306,18 @@ Examples - name: Render the commands for provided configuration vyos.vyos.vyos_firewall_interfaces: config: - - name: eth2 - access_rules: - - afi: ipv4 - rules: - - direction: in - name: INGRESS - - direction: out - name: OUTGRESS - - direction: local - name: DROP + - name: eth2 + access_rules: + - afi: ipv4 + rules: + - direction: in + name: INGRESS + - direction: out + name: OUTGRESS + - direction: local + name: DROP state: rendered + # # # ------------------------- diff --git a/docs/vyos.vyos.vyos_firewall_rules_module.rst b/docs/vyos.vyos.vyos_firewall_rules_module.rst index f35f1e7..246824b 100644 --- a/docs/vyos.vyos.vyos_firewall_rules_module.rst +++ b/docs/vyos.vyos.vyos_firewall_rules_module.rst @@ -1367,13 +1367,13 @@ Examples # set firewall name Downlink rule 502 action 'reject' # set firewall name Downlink rule 502 description 'Rule 502 is configured by Ansible' # set firewall name Downlink rule 502 ipsec 'match-ipsec' - # + - name: Delete attributes of given firewall rules. vyos.vyos.vyos_firewall_rules: config: - - afi: ipv4 - rule_sets: - - name: Downlink + - afi: ipv4 + rule_sets: + - name: Downlink state: deleted # # @@ -1444,11 +1444,10 @@ Examples # set firewall name Downlink rule 502 description 'Rule 502 is configured by Ansible' # set firewall name Downlink rule 502 ipsec 'match-ipsec' - # - name: Delete attributes of given firewall rules. vyos.vyos.vyos_firewall_rules: config: - - afi: ipv4 + - afi: ipv4 state: deleted # # @@ -1544,7 +1543,6 @@ Examples # - name: Delete attributes of given firewall rules. vyos.vyos.vyos_firewall_rules: - config: state: deleted # # @@ -1600,48 +1598,47 @@ Examples - name: Merge the provided configuration with the existing running configuration vyos.vyos.vyos_firewall_rules: config: - - afi: ipv6 - rule_sets: - - name: UPLINK - description: This is ipv6 specific rule-set - default_action: accept - rules: - - number: 1 - action: accept - description: Fwipv6-Rule 1 is configured by Ansible - ipsec: match-ipsec - - number: 2 - action: accept - description: Fwipv6-Rule 2 is configured by Ansible - ipsec: match-ipsec - - - afi: ipv4 - rule_sets: - - name: INBOUND - description: IPv4 INBOUND rule set - default_action: accept - rules: - - number: 101 - action: accept - description: Rule 101 is configured by Ansible - ipsec: match-ipsec - - number: 102 - action: reject - description: Rule 102 is configured by Ansible - ipsec: match-ipsec - - number: 103 - action: accept - description: Rule 103 is configured by Ansible - destination: - group: - address_group: inbound - source: - address: 192.0.2.0 - state: - established: true - new: false - invalid: false - related: true + - afi: ipv6 + rule_sets: + - name: UPLINK + description: This is ipv6 specific rule-set + default_action: accept + rules: + - number: 1 + action: accept + description: Fwipv6-Rule 1 is configured by Ansible + ipsec: match-ipsec + - number: 2 + action: accept + description: Fwipv6-Rule 2 is configured by Ansible + ipsec: match-ipsec + - afi: ipv4 + rule_sets: + - name: INBOUND + description: IPv4 INBOUND rule set + default_action: accept + rules: + - number: 101 + action: accept + description: Rule 101 is configured by Ansible + ipsec: match-ipsec + - number: 102 + action: reject + description: Rule 102 is configured by Ansible + ipsec: match-ipsec + - number: 103 + action: accept + description: Rule 103 is configured by Ansible + destination: + group: + address_group: inbound + source: + address: 192.0.2.0 + state: + established: true + new: false + invalid: false + related: true state: merged # # @@ -1816,28 +1813,30 @@ Examples # set firewall name INBOUND rule 103 state new 'disable' # set firewall name INBOUND rule 103 state related 'enable' # - - name: Replace device configurations of listed firewall rules with provided configurations + - name: >- + Replace device configurations of listed firewall rules with provided + configurations vyos.vyos.vyos_firewall_rules: config: - - afi: ipv6 - rule_sets: - - name: UPLINK - description: This is ipv6 specific rule-set - default_action: accept - - afi: ipv4 - rule_sets: - - name: INBOUND - description: IPv4 INBOUND rule set - default_action: accept - rules: - - number: 101 - action: accept - description: Rule 101 is configured by Ansible - ipsec: match-ipsec - - number: 104 - action: reject - description: Rule 104 is configured by Ansible - ipsec: match-none + - afi: ipv6 + rule_sets: + - name: UPLINK + description: This is ipv6 specific rule-set + default_action: accept + - afi: ipv4 + rule_sets: + - name: INBOUND + description: IPv4 INBOUND rule set + default_action: accept + rules: + - number: 101 + action: accept + description: Rule 101 is configured by Ansible + ipsec: match-ipsec + - number: 104 + action: reject + description: Rule 104 is configured by Ansible + ipsec: match-none state: replaced # # @@ -2001,21 +2000,22 @@ Examples - name: Overrides all device configuration with provided configuration vyos.vyos.vyos_firewall_rules: config: - - afi: ipv4 - rule_sets: - - name: Downlink - description: IPv4 INBOUND rule set - default_action: accept - rules: - - number: 501 - action: accept - description: Rule 501 is configured by Ansible - ipsec: match-ipsec - - number: 502 - action: reject - description: Rule 502 is configured by Ansible - ipsec: match-ipsec + - afi: ipv4 + rule_sets: + - name: Downlink + description: IPv4 INBOUND rule set + default_action: accept + rules: + - number: 501 + action: accept + description: Rule 501 is configured by Ansible + ipsec: match-ipsec + - number: 502 + action: reject + description: Rule 502 is configured by Ansible + ipsec: match-ipsec state: overridden + # # # ------------------------- @@ -2151,7 +2151,6 @@ Examples # - name: Gather listed firewall rules with provided configurations vyos.vyos.vyos_firewall_rules: - config: state: gathered # # @@ -2267,39 +2266,40 @@ Examples - name: Render the commands for provided configuration vyos.vyos.vyos_firewall_rules: config: - - afi: ipv6 - rule_sets: - - name: UPLINK - description: This is ipv6 specific rule-set - default_action: accept - - afi: ipv4 - rule_sets: - - name: INBOUND - description: IPv4 INBOUND rule set - default_action: accept - rules: - - number: 101 - action: accept - description: Rule 101 is configured by Ansible - ipsec: match-ipsec - - number: 102 - action: reject - description: Rule 102 is configured by Ansible - ipsec: match-ipsec - - number: 103 - action: accept - description: Rule 103 is configured by Ansible - destination: - group: - address_group: inbound - source: - address: 192.0.2.0 - state: - established: true - new: false - invalid: false - related: true + - afi: ipv6 + rule_sets: + - name: UPLINK + description: This is ipv6 specific rule-set + default_action: accept + - afi: ipv4 + rule_sets: + - name: INBOUND + description: IPv4 INBOUND rule set + default_action: accept + rules: + - number: 101 + action: accept + description: Rule 101 is configured by Ansible + ipsec: match-ipsec + - number: 102 + action: reject + description: Rule 102 is configured by Ansible + ipsec: match-ipsec + - number: 103 + action: accept + description: Rule 103 is configured by Ansible + destination: + group: + address_group: inbound + source: + address: 192.0.2.0 + state: + established: true + new: false + invalid: false + related: true state: rendered + # # # ------------------------- diff --git a/docs/vyos.vyos.vyos_hostname_module.rst b/docs/vyos.vyos.vyos_hostname_module.rst index 569017a..56bba4c 100644 --- a/docs/vyos.vyos.vyos_hostname_module.rst +++ b/docs/vyos.vyos.vyos_hostname_module.rst @@ -130,96 +130,104 @@ Examples .. code-block:: yaml - # Using state: merged + # Using merged + # # Before state: # ------------- # test#show configuration commands | grep host-name # set system host-name 'vyostest' - # Merged play: - # ------------ + - name: Apply the provided configuration vyos.vyos.vyos_hostname: config: hostname: vyos state: merged + # Commands Fired: # --------------- # "commands": [ # "hostname vyos", # ], + # # After state: # ------------ # test#show configuration commands | grep host-name # set system host-name 'vyos' - # Using state: deleted + # Using deleted + # # Before state: # ------------- # test#show configuration commands | grep host-name # set system host-name 'vyos' - # Deleted play: - # ------------- + # - name: Remove all existing configuration vyos.vyos.vyos_hostname: state: deleted + # Commands Fired: # --------------- # "commands": [ # "no hostname vyosTest", # ], + # # After state: # ------------ # test#show configuration commands | grep host-name - # Using state: overridden + # Using overridden + # # Before state: # ------------- # test#show configuration commands | grep host-name # set system host-name 'vyos' - # Overridden play: - # ---------------- + - name: Override commands with provided configuration vyos.vyos.vyos_hostname: config: hostname: vyosTest state: overridden + # Commands Fired: # --------------- # "commands": [ # "hostname vyosTest", # ], + # # After state: # ------------ # test#show configuration commands | grep host-name # set system host-name 'vyosTest' - # Using state: replaced + # Using replaced + # # Before state: # ------------- # test#show configuration commands | grep host-name # set system host-name 'vyosTest' - # Replaced play: - # -------------- + - name: Replace commands with provided configuration vyos.vyos.vyos_hostname: config: hostname: vyos state: replaced + # After state: # ------------ # test#show configuration commands | grep host-name # set system host-name 'vyos' - # Using state: gathered + # Using gathered + # # Before state: # ------------- - #test#show configuration commands | grep host-name + # test#show configuration commands | grep host-name # set system host-name 'vyos' - # Gathered play: - # -------------- + - name: Gather listed hostname config vyos.vyos.vyos_hostname: state: gathered + # Module Execution Result: # ------------------------ # "gathered": { diff --git a/docs/vyos.vyos.vyos_interfaces_module.rst b/docs/vyos.vyos.vyos_interfaces_module.rst index 1203c20..f5f6941 100644 --- a/docs/vyos.vyos.vyos_interfaces_module.rst +++ b/docs/vyos.vyos.vyos_interfaces_module.rst @@ -343,21 +343,21 @@ Examples - name: Merge provided configuration with device configuration vyos.vyos.vyos_interfaces: config: - - name: eth2 - description: Configured by Ansible - enabled: true - vifs: - - vlan_id: 200 - description: VIF 200 - ETH2 - - name: eth3 - description: Configured by Ansible - mtu: 1500 - - name: bond1 - description: Bond - 1 - mtu: 1200 - - name: vti2 - description: VTI - 2 - enabled: false + - name: eth2 + description: Configured by Ansible + enabled: true + vifs: + - vlan_id: 200 + description: VIF 200 - ETH2 + - name: eth3 + description: Configured by Ansible + mtu: 1500 + - name: bond1 + description: Bond - 1 + mtu: 1200 + - name: vti2 + description: VTI - 2 + enabled: false state: merged # Task Output @@ -475,12 +475,12 @@ Examples - name: Replace device configurations of listed interfaces with provided configurations vyos.vyos.vyos_interfaces: config: - - name: eth2 - description: Replaced by Ansible - - name: eth3 - description: Replaced by Ansible - - name: eth1 - description: Replaced by Ansible + - name: eth2 + description: Replaced by Ansible + - name: eth3 + description: Replaced by Ansible + - name: eth1 + description: Replaced by Ansible state: replaced # Task Output @@ -613,15 +613,15 @@ Examples - name: Overrides all device configuration with provided configuration vyos.vyos.vyos_interfaces: config: - - name: eth0 - description: Outbound Interface For The Appliance - speed: auto - duplex: auto - - name: eth2 - speed: auto - duplex: auto - - name: eth3 - mtu: 1200 + - name: eth0 + description: Outbound Interface For The Appliance + speed: auto + duplex: auto + - name: eth2 + speed: auto + duplex: auto + - name: eth3 + mtu: 1200 state: overridden # Task Output @@ -752,10 +752,10 @@ Examples themselves) vyos.vyos.vyos_interfaces: config: - - name: bond1 - - name: eth1 - - name: eth2 - - name: eth3 + - name: bond1 + - name: eth1 + - name: eth2 + - name: eth3 state: deleted # Task Output @@ -869,7 +869,6 @@ Examples # - name: Gather listed interfaces with provided configurations vyos.vyos.vyos_interfaces: - config: state: gathered # Task output @@ -906,30 +905,31 @@ Examples - name: Render the commands for provided configuration vyos.vyos.vyos_interfaces: config: - - 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 + - name: eth0 enabled: true - - vlan_id: 101 - description: Eth1 - VIF 101 + duplex: auto + speed: auto + - name: eth1 + description: Configured by Ansible - Interface 1 + mtu: 1500 + speed: auto + duplex: auto enabled: true - - name: eth2 - description: Configured by Ansible - Interface 2 (ADMIN DOWN) - mtu: 600 - enabled: false + vifs: + - vlan_id: 100 + description: Eth1 - VIF 100 + 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 state: rendered + # Task Output # ----------- # rendered: diff --git a/docs/vyos.vyos.vyos_l3_interfaces_module.rst b/docs/vyos.vyos.vyos_l3_interfaces_module.rst index 9e44116..4f93705 100644 --- a/docs/vyos.vyos.vyos_l3_interfaces_module.rst +++ b/docs/vyos.vyos.vyos_l3_interfaces_module.rst @@ -319,28 +319,28 @@ Examples - name: Merge provided configuration with device configuration vyos.vyos.vyos_l3_interfaces: config: - - name: eth2 - ipv4: - - address: 192.0.2.10/28 - - address: 198.51.100.40/27 - ipv6: - - address: 2001:db8:100::2/32 - - address: 2001:db8:400::10/32 - - - name: eth3 - ipv4: - - address: 203.0.113.65/26 - vifs: - - vlan_id: 101 + - name: eth2 ipv4: - - address: 192.0.2.71/28 - - address: 198.51.100.131/25 - - vlan_id: 102 + - address: 192.0.2.10/28 + - address: 198.51.100.40/27 ipv6: - - address: 2001:db8:1000::5/38 - - address: 2001:db8:1400::3/38 + - address: '2001:db8:100::2/32' + - address: '2001:db8:400::10/32' + - name: eth3 + ipv4: + - address: 203.0.113.65/26 + vifs: + - vlan_id: 101 + ipv4: + - address: 192.0.2.71/28 + - address: 198.51.100.131/25 + - vlan_id: 102 + ipv6: + - address: '2001:db8:1000::5/38' + - address: '2001:db8:1400::3/38' state: merged + # After state: # ------------- # @@ -387,13 +387,13 @@ Examples - name: Replace device configurations of listed interfaces with provided configurations vyos.vyos.vyos_l3_interfaces: config: - - name: eth2 - ipv4: - - address: 192.0.2.10/24 + - name: eth2 + ipv4: + - address: 192.0.2.10/24 - - name: eth3 - ipv6: - - address: 2001:db8::11/32 + - name: eth3 + ipv6: + - address: 2001:db8::11/32 state: replaced # After state: @@ -443,13 +443,14 @@ Examples - name: Overrides all device configuration with provided configuration vyos.vyos.vyos_l3_interfaces: config: - - name: eth0 - ipv4: - - address: dhcp - ipv6: - - address: dhcpv6 + - name: eth0 + ipv4: + - address: dhcp + ipv6: + - address: dhcpv6 state: overridden + # After state # ------------ # @@ -495,9 +496,9 @@ Examples itself) vyos.vyos.vyos_l3_interfaces: config: - - name: eth1 - - name: eth2 - - name: eth3 + - name: eth1 + - name: eth2 + - name: eth3 state: deleted # After state @@ -535,7 +536,6 @@ Examples # - name: Gather listed l3 interfaces with provided configurations vyos.vyos.vyos_l3_interfaces: - config: state: gathered # # @@ -604,17 +604,18 @@ Examples - name: Render the commands for provided configuration vyos.vyos.vyos_l3_interfaces: config: - - name: eth1 - ipv4: - - address: 192.0.2.14/24 - - name: eth2 - ipv4: - - address: 192.0.2.10/24 - - address: 192.0.2.11/24 - ipv6: - - address: 2001:db8::10/32 - - address: 2001:db8::12/32 + - name: eth1 + ipv4: + - address: 192.0.2.14/24 + - name: eth2 + ipv4: + - address: 192.0.2.10/24 + - address: 192.0.2.11/24 + ipv6: + - address: '2001:db8::10/32' + - address: '2001:db8::12/32' state: rendered + # # # ------------------------- diff --git a/docs/vyos.vyos.vyos_lag_interfaces_module.rst b/docs/vyos.vyos.vyos_lag_interfaces_module.rst index 4ccbcf9..e389654 100644 --- a/docs/vyos.vyos.vyos_lag_interfaces_module.rst +++ b/docs/vyos.vyos.vyos_lag_interfaces_module.rst @@ -287,21 +287,21 @@ Examples - name: Merge provided configuration with device configuration vyos.vyos.vyos_lag_interfaces: config: - - name: bond2 - mode: active-backup - members: - - member: eth2 - - member: eth1 - hash_policy: layer2 - primary: eth2 - - - name: bond3 - mode: active-backup - hash_policy: layer2+3 - members: - - member: eth3 - primary: eth3 + - name: bond2 + mode: active-backup + members: + - member: eth2 + - member: eth1 + hash_policy: layer2 + primary: eth2 + - name: bond3 + mode: active-backup + hash_policy: layer2+3 + members: + - member: eth3 + primary: eth3 state: merged + # # # ------------------------- @@ -391,11 +391,11 @@ Examples - name: Replace device configurations of listed LAGs with provided configurations vyos.vyos.vyos_lag_interfaces: config: - - name: bond3 - mode: 802.3ad - hash_policy: layer2 - members: - - member: eth3 + - name: bond3 + mode: 802.3ad + hash_policy: layer2 + members: + - member: eth3 state: replaced # # @@ -496,14 +496,14 @@ Examples - name: Overrides all device configuration with provided configuration vyos.vyos.vyos_lag_interfaces: config: - - name: bond3 - mode: active-backup - members: - - member: eth1 - - member: eth2 - - member: eth3 - primary: eth3 - hash_policy: layer2 + - name: bond3 + mode: active-backup + members: + - member: eth1 + - member: eth2 + - member: eth3 + primary: eth3 + hash_policy: layer2 state: overridden # # @@ -607,8 +607,8 @@ Examples itself) vyos.vyos.vyos_lag_interfaces: config: - - name: bond2 - - name: bond3 + - name: bond2 + - name: bond3 state: deleted # # @@ -686,9 +686,8 @@ Examples # set interfaces ethernet eth1 bond-group 'bond0' # set interfaces ethernet eth2 bond-group 'bond1' # - - name: Gather listed lag interfaces with provided configurations + - name: Gather listed lag interfaces with provided configurations vyos.vyos.vyos_lag_interfaces: - config: state: gathered # # @@ -787,19 +786,20 @@ Examples - name: Render the commands for provided configuration vyos.vyos.vyos_lag_interfaces: config: - - name: bond0 - hash_policy: layer2 - members: - - member: eth1 - mode: active-backup - primary: eth1 - - name: bond1 - hash_policy: layer2+3 - members: - - member: eth2 - mode: active-backup - primary: eth2 + - name: bond0 + hash_policy: layer2 + members: + - member: eth1 + mode: active-backup + primary: eth1 + - name: bond1 + hash_policy: layer2+3 + members: + - member: eth2 + mode: active-backup + primary: eth2 state: rendered + # # # ------------------------- diff --git a/docs/vyos.vyos.vyos_lldp_global_module.rst b/docs/vyos.vyos.vyos_lldp_global_module.rst index 8ecc900..f858003 100644 --- a/docs/vyos.vyos.vyos_lldp_global_module.rst +++ b/docs/vyos.vyos.vyos_lldp_global_module.rst @@ -193,8 +193,8 @@ Examples vyos.vyos.vyos_lldp_global: config: legacy_protocols: - - fdp - - cdp + - fdp + - cdp snmp: enable address: 192.0.2.11 state: merged @@ -255,9 +255,9 @@ Examples vyos.vyos.vyos_lldp_global: config: legacy_protocols: - - edp - - sonmp - - cdp + - edp + - sonmp + - cdp address: 192.0.2.14 state: replaced # @@ -484,7 +484,7 @@ Examples address: 192.0.2.17 enable: true legacy_protocols: - - cdp + - cdp state: rendered # # diff --git a/docs/vyos.vyos.vyos_lldp_interfaces_module.rst b/docs/vyos.vyos.vyos_lldp_interfaces_module.rst index fffa1c2..d46c506 100644 --- a/docs/vyos.vyos.vyos_lldp_interfaces_module.rst +++ b/docs/vyos.vyos.vyos_lldp_interfaces_module.rst @@ -382,22 +382,22 @@ Examples - name: Merge provided configuration with device configuration vyos.vyos.vyos_lldp_interfaces: config: - - name: eth1 - location: - civic_based: - country_code: US - ca_info: - - ca_type: 0 - ca_value: ENGLISH - - - name: eth2 - location: - coordinate_based: - altitude: 2200 - datum: WGS84 - longitude: 222.267255W - latitude: 33.524449N + - name: eth1 + location: + civic_based: + country_code: US + ca_info: + - ca_type: 0 + ca_value: ENGLISH + - name: eth2 + location: + coordinate_based: + altitude: 2200 + datum: WGS84 + longitude: 222.267255W + latitude: 33.524449N state: merged + # # # ------------------------- @@ -473,24 +473,25 @@ Examples # set service lldp interface eth2 location coordinate-based latitude '33.524449N' # set service lldp interface eth2 location coordinate-based longitude '222.267255W' # - - name: Replace device configurations of listed LLDP interfaces with provided configurations + - name: >- + Replace device configurations of listed LLDP interfaces with provided + configurations vyos.vyos.vyos_lldp_interfaces: config: - - name: eth2 - location: - civic_based: - country_code: US - ca_info: - - ca_type: 0 - ca_value: ENGLISH - - - name: eth1 - location: - coordinate_based: - altitude: 2200 - datum: WGS84 - longitude: 222.267255W - latitude: 33.524449N + - name: eth2 + location: + civic_based: + country_code: US + ca_info: + - ca_type: 0 + ca_value: ENGLISH + - name: eth1 + location: + coordinate_based: + altitude: 2200 + datum: WGS84 + longitude: 222.267255W + latitude: 33.524449N state: replaced # # @@ -599,9 +600,9 @@ Examples - name: Overrides all device configuration with provided configuration vyos.vyos.vyos_lldp_interfaces: config: - - name: eth2 - location: - elin: 0000000911 + - name: eth2 + location: + elin: 0000000911 state: overridden # @@ -674,7 +675,7 @@ Examples - name: Delete lldp interface attributes of given interfaces. vyos.vyos.vyos_lldp_interfaces: config: - - name: eth2 + - name: eth2 state: deleted # # @@ -765,21 +766,22 @@ Examples - name: Render the commands for provided configuration vyos.vyos.vyos_lldp_interfaces: config: - - name: eth1 - location: - civic_based: - country_code: US - ca_info: - - ca_type: 0 - ca_value: ENGLISH - - name: eth2 - location: - coordinate_based: - altitude: 2200 - datum: WGS84 - longitude: 222.267255W - latitude: 33.524449N + - name: eth1 + location: + civic_based: + country_code: US + ca_info: + - ca_type: 0 + ca_value: ENGLISH + - name: eth2 + location: + coordinate_based: + altitude: 2200 + datum: WGS84 + longitude: 222.267255W + latitude: 33.524449N state: rendered + # # # ------------------------- diff --git a/docs/vyos.vyos.vyos_logging_global_module.rst b/docs/vyos.vyos.vyos_logging_global_module.rst index 0ee2505..16a7722 100644 --- a/docs/vyos.vyos.vyos_logging_global_module.rst +++ b/docs/vyos.vyos.vyos_logging_global_module.rst @@ -1046,15 +1046,15 @@ Examples users: - username: vyos facilities: - - facility: local7 - severity: debug + - facility: local7 + severity: debug global_params: archive: file_num: 2 size: 111 facilities: - - facility: cron - severity: debug + - facility: cron + severity: debug marker_interval: 111 preserve_fqdn: true state: merged @@ -1222,10 +1222,11 @@ Examples users: - username: paul facilities: - - facility: local7 - severity: err + - facility: local7 + severity: err state: replaced + # Commands Fired: # --------------- diff --git a/docs/vyos.vyos.vyos_logging_module.rst b/docs/vyos.vyos.vyos_logging_module.rst index 969190b..b29b064 100644 --- a/docs/vyos.vyos.vyos_logging_module.rst +++ b/docs/vyos.vyos.vyos_logging_module.rst @@ -274,16 +274,29 @@ Examples - name: Add logging aggregate vyos.vyos.vyos_logging: aggregate: - - {dest: file, name: test1, facility: all, level: info} - - {dest: file, name: test2, facility: news, level: debug} + - dest: file + name: test1 + facility: all + level: info + - dest: file + name: test2 + facility: news + level: debug state: present - name: Remove logging aggregate vyos.vyos.vyos_logging: aggregate: - - {dest: console, facility: all, level: info} - - {dest: console, facility: daemon, level: warning} - - {dest: file, name: test2, facility: news, level: debug} + - dest: console + facility: all + level: info + - dest: console + facility: daemon + level: warning + - dest: file + name: test2 + facility: news + level: debug state: absent diff --git a/docs/vyos.vyos.vyos_ntp_global_module.rst b/docs/vyos.vyos.vyos_ntp_global_module.rst index aea39b1..d2606f8 100644 --- a/docs/vyos.vyos.vyos_ntp_global_module.rst +++ b/docs/vyos.vyos.vyos_ntp_global_module.rst @@ -220,18 +220,18 @@ Examples - name: Replace the existing ntp config with the new config vyos.vyos.vyos_ntp_global: config: - allow_clients: - - 10.6.6.0/24 - listen_addresses: - - 10.1.3.1 - servers: - - server: 203.0.113.0 - options: - - prefer - - - # # Task output: - # # ------------- + allow_clients: + - 10.6.6.0/24 + listen_addresses: + - 10.1.3.1 + servers: + - server: 203.0.113.0 + options: + - prefer + + + # Task output: + # ------------- # "after": { # "allow_clients": [ # "10.6.6.0/24" @@ -311,14 +311,14 @@ Examples - name: Replace the existing ntp config with the new config vyos.vyos.vyos_ntp_global: config: - allow_clients: - - 10.6.6.0/24 - listen_addresses: - - 10.1.3.1 - servers: - - server: 203.0.113.0 - options: - - prefer + allow_clients: + - 10.6.6.0/24 + listen_addresses: + - 10.1.3.1 + servers: + - server: 203.0.113.0 + options: + - prefer state: replaced @@ -424,8 +424,6 @@ Examples # set system ntp server time3.vyos.net # vyos@vyos:~$ - - # # ------------------- # # 3. Using overridden # # ------------------- @@ -441,30 +439,28 @@ Examples # set system ntp server time3.vyos.net # vyos@vyos:~$ - # # Task - # # ------------- + # Task + # ------------- - name: Override ntp config vyos.vyos.vyos_ntp_global: - config: - allow_clients: - - 10.3.3.0/24 - listen_addresses: - - 10.7.8.1 - servers: - - server: server1 - options: - - dynamic - - prefer - - - server: server2 - options: - - noselect - - preempt - - - server: serv - state: overridden - - + config: + allow_clients: + - 10.3.3.0/24 + listen_addresses: + - 10.7.8.1 + servers: + - server: server1 + options: + - dynamic + - prefer + + - server: server2 + options: + - noselect + - preempt + + - server: serv + state: overridden # # Task output: # # ------------- @@ -558,11 +554,8 @@ Examples # set system ntp server time3.vyos.net # vyos@vyos:~$ - - - # # ------------------- - # # 4. Using gathered - # # ------------------- + # 4. Using gathered + # ------------------- # # Before state: # # ------------- @@ -579,11 +572,11 @@ Examples # set system ntp server time3.vyos.net # vyos@vyos:~$ - # # Task - # # ------------- + # Task + # ------------- - name: Gather ntp config vyos.vyos.vyos_ntp_global: - state: gathered + state: gathered # # Task output: # # ------------- @@ -748,32 +741,27 @@ Examples # set system ntp server time3.vyos.net # vyos@vyos:~$ - # # Task - # # ------------- + # Task + # ------------- - name: Render ntp config vyos.vyos.vyos_ntp_global: - config: - allow_clients: - - 10.7.7.0/24 - - 10.8.8.0/24 - listen_addresses: - - 10.7.9.1 - servers: - - server: server7 - - - server: server45 - options: - - noselect - - prefer - - pool - - server: time1.vyos.net - - - server: time2.vyos.net - - - server: time3.vyos.net - - state: rendered - + config: + allow_clients: + - 10.7.7.0/24 + - 10.8.8.0/24 + listen_addresses: + - 10.7.9.1 + servers: + - server: server7 + - server: server45 + options: + - noselect + - prefer + - pool + - server: time1.vyos.net + - server: time2.vyos.net + - server: time3.vyos.net + state: rendered # # Task output: # # ------------- @@ -807,12 +795,12 @@ Examples # "set system ntp server time2.vyos.net", # "set system ntp server time3.vyos.net" - # # Task: - # # ------------- + # Task: + # ------------- - name: Parse externally provided ntp configuration vyos.vyos.vyos_ntp_global: - running_config: "{{ lookup('file', './sample_config.cfg') }}" - state: parsed + running_config: "{{ lookup('file', './sample_config.cfg') }}" + state: parsed # # Task output: # # ------------- diff --git a/docs/vyos.vyos.vyos_ospf_interfaces_module.rst b/docs/vyos.vyos.vyos_ospf_interfaces_module.rst index c2c5db6..1c4b226 100644 --- a/docs/vyos.vyos.vyos_ospf_interfaces_module.rst +++ b/docs/vyos.vyos.vyos_ospf_interfaces_module.rst @@ -471,29 +471,29 @@ Examples # @vyos:~$ show configuration commands | match "ospf" - - name: Merge provided configuration with device configuration - vyos.vyos.vyos_ospf_interfaces: - config: - - name: "eth1" - address_family: - - afi: "ipv4" - transmit_delay: 50 - priority: 26 - network: "point-to-point" - - afi: "ipv6" - dead_interval: 39 - - name: "bond2" - address_family: - - afi: "ipv4" - transmit_delay: 45 - bandwidth: 70 - authentication: - md5_key: - key_id: 10 - key: "1111111111232345" - - afi: "ipv6" - passive: True - state: merged + - name: Merge provided configuration with device configuration + vyos.vyos.vyos_ospf_interfaces: + config: + - name: "eth1" + address_family: + - afi: "ipv4" + transmit_delay: 50 + priority: 26 + network: "point-to-point" + - afi: "ipv6" + dead_interval: 39 + - name: "bond2" + address_family: + - afi: "ipv4" + transmit_delay: 45 + bandwidth: 70 + authentication: + md5_key: + key_id: 10 + key: "1111111111232345" + - afi: "ipv6" + passive: true + state: merged # After State: # -------------- @@ -580,9 +580,6 @@ Examples # "set interfaces bonding bond2 ipv6 ospfv3 passive" # ], - - - # Using replaced: # Before State: @@ -598,22 +595,22 @@ Examples # set interfaces ethernet eth1 ip ospf transmit-delay '50' # set interfaces ethernet eth1 ipv6 ospfv3 dead-interval '39' - - name: Replace provided configuration with device configuration - vyos.vyos.vyos_ospf_interfaces: - config: - - name: "eth1" - address_family: - - afi: "ipv4" - cost: 100 - - afi: "ipv6" - ifmtu: 33 - - name: "bond2" - address_family: - - afi: "ipv4" - transmit_delay: 45 - - afi: "ipv6" - passive: True - state: replaced + - name: Replace provided configuration with device configuration + vyos.vyos.vyos_ospf_interfaces: + config: + - name: "eth1" + address_family: + - afi: "ipv4" + cost: 100 + - afi: "ipv6" + ifmtu: 33 + - name: "bond2" + address_family: + - afi: "ipv4" + transmit_delay: 45 + - afi: "ipv6" + passive: true + state: replaced # After State: # ----------- @@ -742,17 +739,18 @@ Examples # set interfaces ethernet eth1 ipv6 ospfv3 ifmtu '33' # vyos@vyos:~$ - - name: Override device configuration with provided configuration - vyos.vyos.vyos_ospf_interfaces: - config: - - name: "eth0" - address_family: - - afi: "ipv4" - cost: 100 - - afi: "ipv6" - ifmtu: 33 - passive: True - state: overridden + - name: Override device configuration with provided configuration + vyos.vyos.vyos_ospf_interfaces: + config: + - name: "eth0" + address_family: + - afi: "ipv4" + cost: 100 + - afi: "ipv6" + ifmtu: 33 + passive: true + state: overridden + # After State: # ----------- @@ -871,11 +869,11 @@ Examples # set interfaces ethernet eth1 ipv6 ospfv3 dead-interval '39' # vyos@vyos:~$ - - name: Delete device configuration - vyos.vyos.vyos_ospf_interfaces: - config: - - name: "eth0" - state: deleted + - name: Delete device configuration + vyos.vyos.vyos_ospf_interfaces: + config: + - name: "eth0" + state: deleted # After State: # ----------- @@ -1018,10 +1016,10 @@ Examples # set interfaces ethernet eth1 ipv6 ospfv3 dead-interval '39' # - - name: parse configs - vyos.vyos.vyos_ospf_interfaces: - running_config: "{{ lookup('file', './parsed.cfg') }}" - state: parsed + - name: parse configs + vyos.vyos.vyos_ospf_interfaces: + running_config: "{{ lookup('file', './parsed.cfg') }}" + state: parsed # Module Execution: # ---------------- @@ -1082,29 +1080,29 @@ Examples # Using rendered: # -------------- - - name: Render - vyos.vyos.vyos_ospf_interfaces: - config: - - name: "eth1" - address_family: - - afi: "ipv4" - transmit_delay: 50 - priority: 26 - network: "point-to-point" - - afi: "ipv6" - dead_interval: 39 - - name: "bond2" - address_family: - - afi: "ipv4" - transmit_delay: 45 - bandwidth: 70 - authentication: - md5_key: - key_id: 10 - key: "1111111111232345" - - afi: "ipv6" - passive: True - state: rendered + - name: Render + vyos.vyos.vyos_ospf_interfaces: + config: + - name: "eth1" + address_family: + - afi: "ipv4" + transmit_delay: 50 + priority: 26 + network: "point-to-point" + - afi: "ipv6" + dead_interval: 39 + - name: "bond2" + address_family: + - afi: "ipv4" + transmit_delay: 45 + bandwidth: 70 + authentication: + md5_key: + key_id: 10 + key: "1111111111232345" + - afi: "ipv6" + passive: true + state: rendered # Module Execution: # ---------------- @@ -1137,9 +1135,9 @@ Examples # set interfaces ethernet eth1 ipv6 ospfv3 dead-interval '39' # vyos@vyos:~$ - - name: gather configs - vyos.vyos.vyos_ospf_interfaces: - state: gathered + - name: gather configs + vyos.vyos.vyos_ospf_interfaces: + state: gathered # Module Execution: # ----------------- diff --git a/docs/vyos.vyos.vyos_ospfv2_module.rst b/docs/vyos.vyos.vyos_ospfv2_module.rst index 5e71f11..a3270ed 100644 --- a/docs/vyos.vyos.vyos_ospfv2_module.rst +++ b/docs/vyos.vyos.vyos_ospfv2_module.rst @@ -1680,42 +1680,42 @@ Examples auto_cost: reference_bandwidth: 2 neighbor: - - neighbor_id: 192.0.11.12 - poll_interval: 10 - priority: 2 + - neighbor_id: 192.0.11.12 + poll_interval: 10 + priority: 2 redistribute: - - route_type: bgp - metric: 10 - metric_type: 2 + - route_type: bgp + metric: 10 + metric_type: 2 passive_interface: - - eth1 - - eth2 + - eth1 + - eth2 parameters: router_id: 192.0.1.1 opaque_lsa: true rfc1583_compatibility: true abr_type: cisco areas: - - area_id: '2' - area_type: - normal: true - authentication: plaintext-password - shortcut: enable - - area_id: '3' - area_type: - nssa: - set: true - - area_id: '4' - area_type: - stub: - default_cost: 20 - network: - - address: 192.0.2.0/24 - range: - - address: 192.0.3.0/24 - cost: 10 - - address: 192.0.4.0/24 - cost: 12 + - area_id: '2' + area_type: + normal: true + authentication: plaintext-password + shortcut: enable + - area_id: '3' + area_type: + nssa: + set: true + - area_id: '4' + area_type: + stub: + default_cost: 20 + network: + - address: 192.0.2.0/24 + range: + - address: 192.0.3.0/24 + cost: 10 + - address: 192.0.4.0/24 + cost: 12 state: merged # # @@ -1903,23 +1903,23 @@ Examples vyos.vyos.vyos_ospfv2: config: areas: - - area_id: '2' - area_type: - normal: true - authentication: plaintext-password - shortcut: enable - - area_id: '3' - area_type: - nssa: - set: false - - area_id: '4' - area_type: - stub: - default_cost: 20 - network: - - address: 192.0.2.0/24 - - address: 192.0.22.0/24 - - address: 192.0.32.0/24 + - area_id: '2' + area_type: + normal: true + authentication: plaintext-password + shortcut: enable + - area_id: '3' + area_type: + nssa: + set: false + - area_id: '4' + area_type: + stub: + default_cost: 20 + network: + - address: 192.0.2.0/24 + - address: 192.0.22.0/24 + - address: 192.0.32.0/24 state: merged # # @@ -2211,39 +2211,40 @@ Examples auto_cost: reference_bandwidth: 2 neighbor: - - neighbor_id: 192.0.11.12 - poll_interval: 10 - priority: 2 + - neighbor_id: 192.0.11.12 + poll_interval: 10 + priority: 2 redistribute: - - route_type: bgp - metric: 10 - metric_type: 2 + - route_type: bgp + metric: 10 + metric_type: 2 passive_interface: - - eth1 + - eth1 parameters: router_id: 192.0.1.1 opaque_lsa: true rfc1583_compatibility: true abr_type: cisco areas: - - area_id: '2' - area_type: - normal: true - authentication: plaintext-password - shortcut: enable - - area_id: '4' - area_type: - stub: - default_cost: 20 - network: - - address: 192.0.2.0/24 - - address: 192.0.12.0/24 - - address: 192.0.22.0/24 - - address: 192.0.32.0/24 - range: - - address: 192.0.42.0/24 - cost: 10 + - area_id: '2' + area_type: + normal: true + authentication: plaintext-password + shortcut: enable + - area_id: '4' + area_type: + stub: + default_cost: 20 + network: + - address: 192.0.2.0/24 + - address: 192.0.12.0/24 + - address: 192.0.22.0/24 + - address: 192.0.32.0/24 + range: + - address: 192.0.42.0/24 + cost: 10 state: replaced + # # # ------------------------- @@ -2504,42 +2505,42 @@ Examples auto_cost: reference_bandwidth: 2 neighbor: - - neighbor_id: 192.0.11.12 - poll_interval: 10 - priority: 2 + - neighbor_id: 192.0.11.12 + poll_interval: 10 + priority: 2 redistribute: - - route_type: bgp - metric: 10 - metric_type: 2 + - route_type: bgp + metric: 10 + metric_type: 2 passive_interface: - - eth1 - - eth2 + - eth1 + - eth2 parameters: router_id: 192.0.1.1 opaque_lsa: true rfc1583_compatibility: true abr_type: cisco areas: - - area_id: '2' - area_type: - normal: true - authentication: plaintext-password - shortcut: enable - - area_id: '3' - area_type: - nssa: - set: true - - area_id: '4' - area_type: - stub: - default_cost: 20 - network: - - address: 192.0.2.0/24 - range: - - address: 192.0.3.0/24 - cost: 10 - - address: 192.0.4.0/24 - cost: 12 + - area_id: '2' + area_type: + normal: true + authentication: plaintext-password + shortcut: enable + - area_id: '3' + area_type: + nssa: + set: true + - area_id: '4' + area_type: + stub: + default_cost: 20 + network: + - address: 192.0.2.0/24 + range: + - address: 192.0.3.0/24 + cost: 10 + - address: 192.0.4.0/24 + cost: 12 state: rendered # # diff --git a/docs/vyos.vyos.vyos_ospfv3_module.rst b/docs/vyos.vyos.vyos_ospfv3_module.rst index 5437f46..eb06234 100644 --- a/docs/vyos.vyos.vyos_ospfv3_module.rst +++ b/docs/vyos.vyos.vyos_ospfv3_module.rst @@ -362,21 +362,22 @@ Examples vyos.vyos.vyos_ospfv3: config: redistribute: - - route_type: bgp + - route_type: bgp parameters: router_id: 192.0.2.10 areas: - - area_id: '2' - export_list: export1 - import_list: import1 - range: - - address: 2001:db10::/32 - - address: 2001:db20::/32 - - address: 2001:db30::/32 - - area_id: '3' - range: - - address: 2001:db40::/32 + - area_id: '2' + export_list: export1 + import_list: import1 + range: + - address: '2001:db10::/32' + - address: '2001:db20::/32' + - address: '2001:db30::/32' + - area_id: '3' + range: + - address: '2001:db40::/32' state: merged + # # # ------------------------- @@ -468,21 +469,22 @@ Examples vyos.vyos.vyos_ospfv3: config: redistribute: - - route_type: bgp + - route_type: bgp parameters: router_id: 192.0.2.10 areas: - - area_id: '2' - export_list: export1 - import_list: import1 - range: - - address: 2001:db10::/32 - - address: 2001:db30::/32 - - address: 2001:db50::/32 - - area_id: '4' - range: - - address: 2001:db60::/32 + - area_id: '2' + export_list: export1 + import_list: import1 + range: + - address: '2001:db10::/32' + - address: '2001:db30::/32' + - address: '2001:db50::/32' + - area_id: '4' + range: + - address: '2001:db60::/32' state: replaced + # # # ------------------------- @@ -592,21 +594,22 @@ Examples vyos.vyos.vyos_ospfv3: config: redistribute: - - route_type: bgp + - route_type: bgp parameters: router_id: 192.0.2.10 areas: - - area_id: '2' - export_list: export1 - import_list: import1 - range: - - address: 2001:db10::/32 - - address: 2001:db20::/32 - - address: 2001:db30::/32 - - area_id: '3' - range: - - address: 2001:db40::/32 + - area_id: '2' + export_list: export1 + import_list: import1 + range: + - address: '2001:db10::/32' + - address: '2001:db20::/32' + - address: '2001:db30::/32' + - area_id: '3' + range: + - address: '2001:db40::/32' state: rendered + # # # ------------------------- diff --git a/docs/vyos.vyos.vyos_route_maps_module.rst b/docs/vyos.vyos.vyos_route_maps_module.rst index c548e9b..3135b60 100644 --- a/docs/vyos.vyos.vyos_route_maps_module.rst +++ b/docs/vyos.vyos.vyos_route_maps_module.rst @@ -1378,35 +1378,35 @@ Examples # vyos@vyos:~$ show configuration commands | match "set policy route-map" # vyos@vyos:~$ - - name: Merge the provided configuration with the existing running configuration - register: result - vyos.vyos.vyos_route_maps: &id001 - config: - - route_map: test1 - entries: - - sequence: 1 - description: "test" - action: permit - continue: 2 - on_match: - next: True - - route_map: test3 - entries: - - sequence: 1 - action: permit - match: - rpki: invalid - metric: 1 - peer: 192.0.2.32 - set: - local_preference: 4 - metric: 5 - metric_type: "type-1" - origin: egp - originator_id: 192.0.2.34 - tag: 5 - weight: 4 - state: merged + - name: Merge the provided configuration with the existing running configuration + register: result + vyos.vyos.vyos_route_maps: &id001 + config: + - route_map: test1 + entries: + - sequence: 1 + description: "test" + action: permit + continue: 2 + on_match: + next: true + - route_map: test3 + entries: + - sequence: 1 + action: permit + match: + rpki: invalid + metric: 1 + peer: 192.0.2.32 + set: + local_preference: 4 + metric: 5 + metric_type: "type-1" + origin: egp + originator_id: 192.0.2.34 + tag: 5 + weight: 4 + state: merged # After State # vyos@vyos:~$ show configuration commands | match "set policy route-maps" # set policy route-map test1 rule 1 description test @@ -2027,7 +2027,6 @@ Examples # "set policy route-map test3 rule 1 match metric 3", # "set policy route-map test3 rule 1 match peer 192.0.2.35" # ], - # diff --git a/docs/vyos.vyos.vyos_snmp_server_module.rst b/docs/vyos.vyos.vyos_snmp_server_module.rst index dfef282..325f413 100644 --- a/docs/vyos.vyos.vyos_snmp_server_module.rst +++ b/docs/vyos.vyos.vyos_snmp_server_module.rst @@ -1235,30 +1235,29 @@ Examples # vyos@vyos:~$ show configuration commands | grep snmp # vyos@vyos:~$ - - name: Merge provided configuration with device configuration - vyos.vyos.vyos_snmp_server: - config: - communities: - - name: "switches" - authorization_type: "rw" - - name: "bridges" - clients: ["1.1.1.1", "12.1.1.10"] - contact: "admin2@ex.com" - listen_addresses: - - address: "20.1.1.1" - - address: "100.1.2.1" - port: 33 - snmp_v3: - users: - - user: admin_user - authentication: - plaintext_key: "abc1234567" - type: "sha" - privacy: - plaintext_key: "abc1234567" - type: "aes" - - state: merged + - name: Merge provided configuration with device configuration + vyos.vyos.vyos_snmp_server: + config: + communities: + - name: "switches" + authorization_type: "rw" + - name: "bridges" + clients: ["1.1.1.1", "12.1.1.10"] + contact: "admin2@ex.com" + listen_addresses: + - address: "20.1.1.1" + - address: "100.1.2.1" + port: 33 + snmp_v3: + users: + - user: admin_user + authentication: + plaintext_key: "abc1234567" + type: "sha" + privacy: + plaintext_key: "abc1234567" + type: "aes" + state: merged # After State: @@ -1333,9 +1332,10 @@ Examples # ], # - # using Replaced: + # Using replaced # Before State + # ------------- # vyos@vyos:~$ show configuration commands | grep snmp # set service snmp community bridges client '1.1.1.1' # set service snmp community bridges client '12.1.1.10' @@ -1347,43 +1347,42 @@ Examples # set service snmp v3 user admin_user auth type 'sha' # set service snmp v3 user admin_user privacy plaintext-key 'abc1234567' # set service snmp v3 user admin_user privacy type 'aes' - # vyos@vyos:~$ - - name: Replace - vyos.vyos.vyos_snmp_server: - config: - communities: - - name: "bridges" - networks: ["1.1.1.0/24", "12.1.1.0/24"] - location: "RDU, NC" - listen_addresses: - - address: "100.1.2.1" - port: 33 - snmp_v3: - groups: - - group: "default" - view: "default" - users: - - user: admin_user - authentication: - plaintext_key: "abc1234567" - type: "sha" - privacy: - plaintext_key: "abc1234567" - type: "aes" - group: "default" - - user: guest_user2 - authentication: - plaintext_key: "opq1234567" - type: "sha" - privacy: - plaintext_key: "opq1234567" - type: "aes" - views: - - view: "default" - oid: 1 - - state: replaced + - name: Replace SNMP Server configuration + vyos.vyos.vyos_snmp_server: + config: + communities: + - name: "bridges" + networks: ["1.1.1.0/24", "12.1.1.0/24"] + location: "RDU, NC" + listen_addresses: + - address: "100.1.2.1" + port: 33 + snmp_v3: + groups: + - group: "default" + view: "default" + users: + - user: admin_user + authentication: + plaintext_key: "abc1234567" + type: "sha" + privacy: + plaintext_key: "abc1234567" + type: "aes" + group: "default" + - user: guest_user2 + authentication: + plaintext_key: "opq1234567" + type: "sha" + privacy: + plaintext_key: "opq1234567" + type: "aes" + views: + - view: "default" + oid: 1 + + state: replaced # After State: # vyos@vyos:~$ show configuration commands | grep snmp @@ -1539,43 +1538,41 @@ Examples # set service snmp v3 user admin_user auth type 'sha' # set service snmp v3 user admin_user privacy plaintext-key 'abc1234567' # set service snmp v3 user admin_user privacy type 'aes' - # vyos@vyos:~$ - - name: Override config - vyos.vyos.vyos_snmp_server: - config: - communities: - - name: "bridges" - networks: ["1.1.1.0/24", "12.1.1.0/24"] - location: "RDU, NC" - listen_addresses: - - address: "100.1.2.1" - port: 33 - snmp_v3: - groups: - - group: "default" - view: "default" - users: - - user: admin_user - authentication: - plaintext_key: "abc1234567" - type: "sha" - privacy: - plaintext_key: "abc1234567" - type: "aes" - group: "default" - - user: guest_user2 - authentication: - plaintext_key: "opq1234567" - type: "sha" - privacy: - plaintext_key: "opq1234567" - type: "aes" - views: - - view: "default" - oid: 1 - - state: overridden + - name: Override SNMP server config + vyos.vyos.vyos_snmp_server: + config: + communities: + - name: "bridges" + networks: ["1.1.1.0/24", "12.1.1.0/24"] + location: "RDU, NC" + listen_addresses: + - address: "100.1.2.1" + port: 33 + snmp_v3: + groups: + - group: "default" + view: "default" + users: + - user: admin_user + authentication: + plaintext_key: "abc1234567" + type: "sha" + privacy: + plaintext_key: "abc1234567" + type: "aes" + group: "default" + - user: guest_user2 + authentication: + plaintext_key: "opq1234567" + type: "sha" + privacy: + plaintext_key: "opq1234567" + type: "aes" + views: + - view: "default" + oid: 1 + state: overridden # After State: # vyos@vyos:~$ show configuration commands | grep snmp @@ -1738,11 +1735,10 @@ Examples # set service snmp v3 user guest_user2 privacy plaintext-key 'opq1234567' # set service snmp v3 user guest_user2 privacy type 'aes' # set service snmp v3 view default oid 1 - # vyos@vyos:~$ - - name: Delete Config - vyos.vyos.vyos_snmp_server: - state: deleted + - name: Delete Config + vyos.vyos.vyos_snmp_server: + state: deleted # After State: # vyos@vyos:~$ show configuration commands | grep snmp @@ -1816,30 +1812,29 @@ Examples # ], # Using rendered: - - name: Render provided configuration - vyos.vyos.vyos_snmp_server: - config: - communities: - - name: "switches" - authorization_type: "rw" - - name: "bridges" - clients: ["1.1.1.1", "12.1.1.10"] - contact: "admin2@ex.com" - listen_addresses: - - address: "20.1.1.1" - - address: "100.1.2.1" - port: 33 - snmp_v3: - users: - - user: admin_user - authentication: - plaintext_key: "abc1234567" - type: "sha" - privacy: - plaintext_key: "abc1234567" - type: "aes" - - state: rendered + - name: Render provided configuration + vyos.vyos.vyos_snmp_server: + config: + communities: + - name: "switches" + authorization_type: "rw" + - name: "bridges" + clients: ["1.1.1.1", "12.1.1.10"] + contact: "admin2@ex.com" + listen_addresses: + - address: "20.1.1.1" + - address: "100.1.2.1" + port: 33 + snmp_v3: + users: + - user: admin_user + authentication: + plaintext_key: "abc1234567" + type: "sha" + privacy: + plaintext_key: "abc1234567" + type: "aes" + state: rendered # Module Execution: # "rendered": [ @@ -1870,11 +1865,10 @@ Examples # set service snmp v3 user admin_user auth type 'sha' # set service snmp v3 user admin_user privacy plaintext-key 'abc1234567' # set service snmp v3 user admin_user privacy type 'aes' - # vyos@vyos:~$ - - name: gather configs - vyos.vyos.vyos_snmp_server: - state: gathered + - name: Gather SNMP server config + vyos.vyos.vyos_snmp_server: + state: gathered # Module Execution: # "gathered": { @@ -1941,10 +1935,10 @@ Examples # set service snmp v3 user vyos privacy type 'aes' # set service snmp v3 view default oid 1 - - name: parse configs - vyos.vyos.vyos_snmp_server: - running_config: "{{ lookup('file', './_parsed_snmp.cfg') }}" - state: parsed + - name: Parse SNMP server config + vyos.vyos.vyos_snmp_server: + running_config: "{{ lookup('file', './_parsed_snmp.cfg') }}" + state: parsed # Module Execution: # "parsed": { diff --git a/docs/vyos.vyos.vyos_static_routes_module.rst b/docs/vyos.vyos.vyos_static_routes_module.rst index d1ed834..4207add 100644 --- a/docs/vyos.vyos.vyos_static_routes_module.rst +++ b/docs/vyos.vyos.vyos_static_routes_module.rst @@ -355,25 +355,26 @@ Examples - name: Merge the provided configuration with the existing running configuration vyos.vyos.vyos_static_routes: config: - - address_families: - - afi: ipv4 - routes: - - dest: 192.0.2.32/28 - blackhole_config: - type: blackhole - next_hops: - - forward_router_address: 192.0.2.6 - - forward_router_address: 192.0.2.7 - - address_families: - - afi: ipv6 - routes: - - dest: 2001:db8:1000::/36 - blackhole_config: - distance: 2 - next_hops: - - forward_router_address: 2001:db8:2000:2::1 - - forward_router_address: 2001:db8:2000:2::2 + - address_families: + - afi: ipv4 + routes: + - dest: 192.0.2.32/28 + blackhole_config: + type: blackhole + next_hops: + - forward_router_address: 192.0.2.6 + - forward_router_address: 192.0.2.7 + - address_families: + - afi: ipv6 + routes: + - dest: '2001:db8:1000::/36' + blackhole_config: + distance: 2 + next_hops: + - forward_router_address: '2001:db8:2000:2::1' + - forward_router_address: '2001:db8:2000:2::2' state: merged + # # # ------------------------- @@ -469,16 +470,16 @@ Examples - name: Replace device configurations of listed static routes with provided configurations vyos.vyos.vyos_static_routes: config: - - address_families: - - afi: ipv4 - routes: - - dest: 192.0.2.32/28 - blackhole_config: - distance: 2 - next_hops: - - forward_router_address: 192.0.2.7 - enabled: false - - forward_router_address: 192.0.2.9 + - address_families: + - afi: ipv4 + routes: + - dest: 192.0.2.32/28 + blackhole_config: + distance: 2 + next_hops: + - forward_router_address: 192.0.2.7 + enabled: false + - forward_router_address: 192.0.2.9 state: replaced # # @@ -645,12 +646,12 @@ Examples - name: Overrides all device configuration with provided configuration vyos.vyos.vyos_static_routes: config: - - address_families: - - afi: ipv4 - routes: - - dest: 198.0.2.48/28 - next_hops: - - forward_router_address: 192.0.2.18 + - address_families: + - afi: ipv4 + routes: + - dest: 198.0.2.48/28 + next_hops: + - forward_router_address: 192.0.2.18 state: overridden # # @@ -755,9 +756,9 @@ Examples - name: Delete static route based on afi. vyos.vyos.vyos_static_routes: config: - - address_families: - - afi: ipv4 - - afi: ipv6 + - address_families: + - afi: ipv4 + - afi: ipv6 state: deleted # # @@ -906,24 +907,24 @@ Examples - name: Render the commands for provided configuration vyos.vyos.vyos_static_routes: config: - - address_families: - - afi: ipv4 - routes: - - dest: 192.0.2.32/28 - blackhole_config: - type: blackhole - next_hops: - - forward_router_address: 192.0.2.6 - - forward_router_address: 192.0.2.7 - - address_families: - - afi: ipv6 - routes: - - dest: 2001:db8:1000::/36 - blackhole_config: - distance: 2 - next_hops: - - forward_router_address: 2001:db8:2000:2::1 - - forward_router_address: 2001:db8:2000:2::2 + - address_families: + - afi: ipv4 + routes: + - dest: 192.0.2.32/28 + blackhole_config: + type: blackhole + next_hops: + - forward_router_address: 192.0.2.6 + - forward_router_address: 192.0.2.7 + - address_families: + - afi: ipv6 + routes: + - dest: 2001:db8:1000::/36 + blackhole_config: + distance: 2 + next_hops: + - forward_router_address: 2001:db8:2000:2::1 + - forward_router_address: 2001:db8:2000:2::2 state: rendered # # diff --git a/docs/vyos.vyos.vyos_system_module.rst b/docs/vyos.vyos.vyos_system_module.rst index b5524e7..ba0fd01 100644 --- a/docs/vyos.vyos.vyos_system_module.rst +++ b/docs/vyos.vyos.vyos_system_module.rst @@ -148,8 +148,8 @@ Examples - name: configure domain search suffixes vyos.vyos.vyos_system: domain_search: - - sub1.example.com - - sub2.example.com + - sub1.example.com + - sub2.example.com diff --git a/docs/vyos.vyos.vyos_user_module.rst b/docs/vyos.vyos.vyos_user_module.rst index 8fb47b8..5f0ad83 100644 --- a/docs/vyos.vyos.vyos_user_module.rst +++ b/docs/vyos.vyos.vyos_user_module.rst @@ -301,12 +301,12 @@ Examples state: present - name: remove all users except admin vyos.vyos.vyos_user: - purge: yes + purge: true - name: set multiple users to level operator vyos.vyos.vyos_user: aggregate: - - name: netop - - name: netend + - name: netop + - name: netend level: operator state: present - name: Change Password for User netop diff --git a/docs/vyos.vyos.vyos_vlan_module.rst b/docs/vyos.vyos.vyos_vlan_module.rst index 601cda9..1d5c877 100644 --- a/docs/vyos.vyos.vyos_vlan_module.rst +++ b/docs/vyos.vyos.vyos_vlan_module.rst @@ -331,8 +331,8 @@ Examples vyos.vyos.vyos_vlan: vlan_id: 100 interfaces: - - eth1 - - eth2 + - eth1 + - eth2 - name: Configure virtual interface address vyos.vyos.vyos_vlan: @@ -345,14 +345,14 @@ Examples vlan_id: 100 interfaces: eth0 associated_interfaces: - - eth0 + - eth0 - name: vlan intent check vyos.vyos.vyos_vlan: vlan_id: 100 associated_interfaces: - - eth3 - - eth4 + - eth3 + - eth4 - name: Delete vlan vyos.vyos.vyos_vlan: @@ -2,7 +2,7 @@ authors: - Ansible Network Community (ansible-network) dependencies: - "ansible.netcommon": ">=2.5.1" + ansible.netcommon: ">=2.5.1" license_file: LICENSE name: vyos description: Ansible Network Collection for VYOS devices. diff --git a/meta/runtime.yml b/meta/runtime.yml index 02e7896..1ee4fef 100644 --- a/meta/runtime.yml +++ b/meta/runtime.yml @@ -1,5 +1,5 @@ --- -requires_ansible: ">=2.9.10" +requires_ansible: ">=2.15.0" plugin_routing: modules: banner: diff --git a/plugins/action/vyos.py b/plugins/action/vyos.py index df8e712..148d7c6 100644 --- a/plugins/action/vyos.py +++ b/plugins/action/vyos.py @@ -18,6 +18,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type from ansible.utils.display import Display @@ -25,6 +26,7 @@ from ansible_collections.ansible.netcommon.plugins.action.network import ( ActionModule as ActionNetworkModule, ) + display = Display() diff --git a/plugins/cliconf/vyos.py b/plugins/cliconf/vyos.py index 4916d52..7e6b0b1 100644 --- a/plugins/cliconf/vyos.py +++ b/plugins/cliconf/vyos.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type DOCUMENTATION = """ @@ -85,7 +86,8 @@ class Cliconf(CliconfBase): reply = self.get("show host name") device_info["network_os_hostname"] = to_text( - reply, errors="surrogate_or_strict" + reply, + errors="surrogate_or_strict", ).strip() self._device_info = device_info @@ -98,7 +100,7 @@ class Cliconf(CliconfBase): if format not in option_values["format"]: raise ValueError( "'format' value %s is invalid. Valid values of format are %s" - % (format, ", ".join(option_values["format"])) + % (format, ", ".join(option_values["format"])), ) if not flags: @@ -213,7 +215,7 @@ class Cliconf(CliconfBase): if diff_match not in option_values["diff_match"]: raise ValueError( "'match' value %s in invalid, valid values are %s" - % (diff_match, ", ".join(option_values["diff_match"])) + % (diff_match, ", ".join(option_values["diff_match"])), ) if diff_replace: diff --git a/plugins/doc_fragments/vyos.py b/plugins/doc_fragments/vyos.py index 698d0f5..aaa7bf7 100644 --- a/plugins/doc_fragments/vyos.py +++ b/plugins/doc_fragments/vyos.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function + __metaclass__ = type # Copyright: (c) 2015, Peter Sprygada <psprygada@ansible.com> diff --git a/plugins/module_utils/network/vyos/argspec/bgp_address_family/bgp_address_family.py b/plugins/module_utils/network/vyos/argspec/bgp_address_family/bgp_address_family.py index 8cbbc50..9868fc6 100644 --- a/plugins/module_utils/network/vyos/argspec/bgp_address_family/bgp_address_family.py +++ b/plugins/module_utils/network/vyos/argspec/bgp_address_family/bgp_address_family.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type ############################################# diff --git a/plugins/module_utils/network/vyos/argspec/bgp_global/bgp_global.py b/plugins/module_utils/network/vyos/argspec/bgp_global/bgp_global.py index da56aa9..22af639 100644 --- a/plugins/module_utils/network/vyos/argspec/bgp_global/bgp_global.py +++ b/plugins/module_utils/network/vyos/argspec/bgp_global/bgp_global.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type ############################################# diff --git a/plugins/module_utils/network/vyos/argspec/facts/facts.py b/plugins/module_utils/network/vyos/argspec/facts/facts.py index 45a4cb4..b274c50 100644 --- a/plugins/module_utils/network/vyos/argspec/facts/facts.py +++ b/plugins/module_utils/network/vyos/argspec/facts/facts.py @@ -6,6 +6,7 @@ The arg spec for the vyos facts module. """ from __future__ import absolute_import, division, print_function + __metaclass__ = type diff --git a/plugins/module_utils/network/vyos/argspec/firewall_global/firewall_global.py b/plugins/module_utils/network/vyos/argspec/firewall_global/firewall_global.py index baafa89..2326bea 100644 --- a/plugins/module_utils/network/vyos/argspec/firewall_global/firewall_global.py +++ b/plugins/module_utils/network/vyos/argspec/firewall_global/firewall_global.py @@ -27,6 +27,7 @@ The arg spec for the vyos_firewall_global module from __future__ import absolute_import, division, print_function + __metaclass__ = type diff --git a/plugins/module_utils/network/vyos/argspec/firewall_interfaces/firewall_interfaces.py b/plugins/module_utils/network/vyos/argspec/firewall_interfaces/firewall_interfaces.py index 16e6615..a613ccd 100644 --- a/plugins/module_utils/network/vyos/argspec/firewall_interfaces/firewall_interfaces.py +++ b/plugins/module_utils/network/vyos/argspec/firewall_interfaces/firewall_interfaces.py @@ -27,6 +27,7 @@ The arg spec for the vyos_firewall_interfaces module from __future__ import absolute_import, division, print_function + __metaclass__ = type diff --git a/plugins/module_utils/network/vyos/argspec/firewall_rules/firewall_rules.py b/plugins/module_utils/network/vyos/argspec/firewall_rules/firewall_rules.py index 0e80031..eb285cf 100644 --- a/plugins/module_utils/network/vyos/argspec/firewall_rules/firewall_rules.py +++ b/plugins/module_utils/network/vyos/argspec/firewall_rules/firewall_rules.py @@ -27,6 +27,7 @@ The arg spec for the vyos_firewall_rules module from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -182,7 +183,7 @@ class Firewall_rulesArgs(object): # pylint: disable=R0903 "kazaa", ], "type": "str", - } + }, }, "type": "list", }, diff --git a/plugins/module_utils/network/vyos/argspec/hostname/hostname.py b/plugins/module_utils/network/vyos/argspec/hostname/hostname.py index 1a3cf91..b69f2f1 100644 --- a/plugins/module_utils/network/vyos/argspec/hostname/hostname.py +++ b/plugins/module_utils/network/vyos/argspec/hostname/hostname.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type ############################################# diff --git a/plugins/module_utils/network/vyos/argspec/interfaces/interfaces.py b/plugins/module_utils/network/vyos/argspec/interfaces/interfaces.py index 9ae4c65..fecfb48 100644 --- a/plugins/module_utils/network/vyos/argspec/interfaces/interfaces.py +++ b/plugins/module_utils/network/vyos/argspec/interfaces/interfaces.py @@ -25,6 +25,7 @@ The arg spec for the vyos_interfaces module from __future__ import absolute_import, division, print_function + __metaclass__ = type diff --git a/plugins/module_utils/network/vyos/argspec/l3_interfaces/l3_interfaces.py b/plugins/module_utils/network/vyos/argspec/l3_interfaces/l3_interfaces.py index d6d9e29..db33376 100644 --- a/plugins/module_utils/network/vyos/argspec/l3_interfaces/l3_interfaces.py +++ b/plugins/module_utils/network/vyos/argspec/l3_interfaces/l3_interfaces.py @@ -27,6 +27,7 @@ The arg spec for the vyos_l3_interfaces module from __future__ import absolute_import, division, print_function + __metaclass__ = type diff --git a/plugins/module_utils/network/vyos/argspec/lag_interfaces/lag_interfaces.py b/plugins/module_utils/network/vyos/argspec/lag_interfaces/lag_interfaces.py index 14ac795..dce4fb7 100644 --- a/plugins/module_utils/network/vyos/argspec/lag_interfaces/lag_interfaces.py +++ b/plugins/module_utils/network/vyos/argspec/lag_interfaces/lag_interfaces.py @@ -24,6 +24,7 @@ The arg spec for the vyos_lag_interfaces module """ from __future__ import absolute_import, division, print_function + __metaclass__ = type diff --git a/plugins/module_utils/network/vyos/argspec/lldp_global/lldp_global.py b/plugins/module_utils/network/vyos/argspec/lldp_global/lldp_global.py index 635322b..734274a 100644 --- a/plugins/module_utils/network/vyos/argspec/lldp_global/lldp_global.py +++ b/plugins/module_utils/network/vyos/argspec/lldp_global/lldp_global.py @@ -24,6 +24,7 @@ The arg spec for the vyos_lldp_global module """ from __future__ import absolute_import, division, print_function + __metaclass__ = type diff --git a/plugins/module_utils/network/vyos/argspec/lldp_interfaces/lldp_interfaces.py b/plugins/module_utils/network/vyos/argspec/lldp_interfaces/lldp_interfaces.py index b641aeb..672b7f0 100644 --- a/plugins/module_utils/network/vyos/argspec/lldp_interfaces/lldp_interfaces.py +++ b/plugins/module_utils/network/vyos/argspec/lldp_interfaces/lldp_interfaces.py @@ -27,6 +27,7 @@ The arg spec for the vyos_lldp_interfaces module from __future__ import absolute_import, division, print_function + __metaclass__ = type diff --git a/plugins/module_utils/network/vyos/argspec/logging_global/logging_global.py b/plugins/module_utils/network/vyos/argspec/logging_global/logging_global.py index 503f723..93b29f4 100644 --- a/plugins/module_utils/network/vyos/argspec/logging_global/logging_global.py +++ b/plugins/module_utils/network/vyos/argspec/logging_global/logging_global.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type ############################################# @@ -293,7 +294,7 @@ class Logging_globalArgs(object): # pylint: disable=R0903 "state": { "type": "str", "choices": ["enabled", "disabled"], - } + }, }, }, "users": { diff --git a/plugins/module_utils/network/vyos/argspec/ntp_global/ntp_global.py b/plugins/module_utils/network/vyos/argspec/ntp_global/ntp_global.py index 7ace5bb..fca9bf1 100644 --- a/plugins/module_utils/network/vyos/argspec/ntp_global/ntp_global.py +++ b/plugins/module_utils/network/vyos/argspec/ntp_global/ntp_global.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type ############################################# diff --git a/plugins/module_utils/network/vyos/argspec/ospf_interfaces/ospf_interfaces.py b/plugins/module_utils/network/vyos/argspec/ospf_interfaces/ospf_interfaces.py index 71ba63b..1fd3370 100644 --- a/plugins/module_utils/network/vyos/argspec/ospf_interfaces/ospf_interfaces.py +++ b/plugins/module_utils/network/vyos/argspec/ospf_interfaces/ospf_interfaces.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type ############################################# diff --git a/plugins/module_utils/network/vyos/argspec/ospfv2/ospfv2.py b/plugins/module_utils/network/vyos/argspec/ospfv2/ospfv2.py index 6c83372..bd7f94d 100644 --- a/plugins/module_utils/network/vyos/argspec/ospfv2/ospfv2.py +++ b/plugins/module_utils/network/vyos/argspec/ospfv2/ospfv2.py @@ -6,6 +6,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type ############################################# @@ -53,7 +54,7 @@ class Ospfv2Args(object): # pylint: disable=R0903 "route_map": {"type": "str"}, }, "type": "dict", - } + }, }, "type": "dict", }, @@ -85,7 +86,7 @@ class Ospfv2Args(object): # pylint: disable=R0903 "on_startup": {"type": "int"}, }, "type": "dict", - } + }, }, "type": "dict", }, @@ -253,7 +254,7 @@ class Ospfv2Args(object): # pylint: disable=R0903 "max_holdtime": {"type": "int"}, }, "type": "dict", - } + }, }, "type": "dict", }, diff --git a/plugins/module_utils/network/vyos/argspec/ospfv3/ospfv3.py b/plugins/module_utils/network/vyos/argspec/ospfv3/ospfv3.py index 7fac36c..4ea88b6 100644 --- a/plugins/module_utils/network/vyos/argspec/ospfv3/ospfv3.py +++ b/plugins/module_utils/network/vyos/argspec/ospfv3/ospfv3.py @@ -6,6 +6,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type ############################################# diff --git a/plugins/module_utils/network/vyos/argspec/prefix_lists/prefix_lists.py b/plugins/module_utils/network/vyos/argspec/prefix_lists/prefix_lists.py index c7d2e98..d274144 100644 --- a/plugins/module_utils/network/vyos/argspec/prefix_lists/prefix_lists.py +++ b/plugins/module_utils/network/vyos/argspec/prefix_lists/prefix_lists.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type ############################################# diff --git a/plugins/module_utils/network/vyos/argspec/route_maps/route_maps.py b/plugins/module_utils/network/vyos/argspec/route_maps/route_maps.py index 6baa434..b2038a4 100644 --- a/plugins/module_utils/network/vyos/argspec/route_maps/route_maps.py +++ b/plugins/module_utils/network/vyos/argspec/route_maps/route_maps.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type ############################################# diff --git a/plugins/module_utils/network/vyos/argspec/snmp_server/snmp_server.py b/plugins/module_utils/network/vyos/argspec/snmp_server/snmp_server.py index 2b10a51..7cea688 100644 --- a/plugins/module_utils/network/vyos/argspec/snmp_server/snmp_server.py +++ b/plugins/module_utils/network/vyos/argspec/snmp_server/snmp_server.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type ############################################# diff --git a/plugins/module_utils/network/vyos/argspec/static_routes/static_routes.py b/plugins/module_utils/network/vyos/argspec/static_routes/static_routes.py index f8602e3..916ad26 100644 --- a/plugins/module_utils/network/vyos/argspec/static_routes/static_routes.py +++ b/plugins/module_utils/network/vyos/argspec/static_routes/static_routes.py @@ -27,6 +27,7 @@ The arg spec for the vyos_static_routes module from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -77,7 +78,7 @@ class Static_routesArgs(object): # pylint: disable=R0903 }, }, "type": "list", - } + }, }, "type": "list", }, diff --git a/plugins/module_utils/network/vyos/config/bgp_address_family/bgp_address_family.py b/plugins/module_utils/network/vyos/config/bgp_address_family/bgp_address_family.py index 53defde..1b075ad 100644 --- a/plugins/module_utils/network/vyos/config/bgp_address_family/bgp_address_family.py +++ b/plugins/module_utils/network/vyos/config/bgp_address_family/bgp_address_family.py @@ -7,6 +7,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -143,7 +144,7 @@ class Bgp_address_family(ResourceModule): }, "address_family", True, - ) + ), ) for neigh, neigh_entry in iteritems(entry.get("neighbors", {})): if have.get("neighbors"): @@ -158,7 +159,7 @@ class Bgp_address_family(ResourceModule): }, "neighbors", True, - ) + ), ) else: for k in neigh_entry["address_family"].keys(): @@ -177,7 +178,7 @@ class Bgp_address_family(ResourceModule): }, "neighbors.address_family", True, - ) + ), ) def _compare_neighbors(self, want, have): @@ -248,7 +249,7 @@ class Bgp_address_family(ResourceModule): }, "neighbors", True, - ) + ), ) continue @@ -305,7 +306,7 @@ class Bgp_address_family(ResourceModule): + "address-family " + afi + " " - + attrib + + attrib, ) hdict = {} for key, entry in iteritems(hdict): diff --git a/plugins/module_utils/network/vyos/config/bgp_global/bgp_global.py b/plugins/module_utils/network/vyos/config/bgp_global/bgp_global.py index 55eca49..c4a8502 100644 --- a/plugins/module_utils/network/vyos/config/bgp_global/bgp_global.py +++ b/plugins/module_utils/network/vyos/config/bgp_global/bgp_global.py @@ -7,6 +7,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -201,12 +202,12 @@ class Bgp_global(ResourceModule): if name not in wneigh.keys(): if self._check_af(name): msg = "Use the _bgp_address_family module to delete the address_family under neighbor {0}, before replacing/deleting the neighbor.".format( - name + name, ) self._module.fail_json(msg=msg) else: self.commands.append( - "delete protocols bgp " + str(have["as_number"]) + " neighbor " + name + "delete protocols bgp " + str(have["as_number"]) + " neighbor " + name, ) continue for k, v in entry.items(): @@ -291,7 +292,7 @@ class Bgp_global(ResourceModule): for name, entry in iteritems(hbgp): if name == "confederation": self.commands.append( - "delete protocols bgp " + str(have["as_number"]) + " parameters confederation" + "delete protocols bgp " + str(have["as_number"]) + " parameters confederation", ) elif name == "distance": distance_parsers = [ @@ -339,7 +340,7 @@ class Bgp_global(ResourceModule): if not wdict and hdict: attrib = re.sub("_", "-", attrib) self.commands.append( - "delete protocols bgp " + str(have["as_number"]) + " " + attrib + "delete protocols bgp " + str(have["as_number"]) + " " + attrib, ) hdict = {} for key, entry in iteritems(hdict): @@ -402,5 +403,5 @@ class Bgp_global(ResourceModule): def _get_config(self, connection): return connection.get( - 'show configuration commands | match "set protocols bgp .* neighbor"' + 'show configuration commands | match "set protocols bgp .* neighbor"', ) diff --git a/plugins/module_utils/network/vyos/config/firewall_global/firewall_global.py b/plugins/module_utils/network/vyos/config/firewall_global/firewall_global.py index 079cba6..8694f11 100644 --- a/plugins/module_utils/network/vyos/config/firewall_global/firewall_global.py +++ b/plugins/module_utils/network/vyos/config/firewall_global/firewall_global.py @@ -12,6 +12,7 @@ created """ from __future__ import absolute_import, division, print_function + __metaclass__ = type from copy import deepcopy @@ -50,7 +51,9 @@ class Firewall_global(ConfigBase): :returns: The current configuration as a dictionary """ facts, _warnings = Facts(self._module).get_facts( - self.gather_subset, self.gather_network_resources, data=data + self.gather_subset, + self.gather_network_resources, + data=data, ) firewall_global_facts = facts["ansible_network_resources"].get("firewall_global") if not firewall_global_facts: @@ -91,7 +94,7 @@ class Firewall_global(ConfigBase): running_config = self._module.params["running_config"] if not running_config: self._module.fail_json( - msg="value of running_config parameter must not be empty for state parsed" + msg="value of running_config parameter must not be empty for state parsed", ) result["parsed"] = self.get_firewall_global_facts(data=running_config) else: @@ -132,7 +135,7 @@ class Firewall_global(ConfigBase): commands = [] if self.state in ("merged", "replaced", "rendered") and not w: self._module.fail_json( - msg="value of config parameter must not be empty for state {0}".format(self.state) + msg="value of config parameter must not be empty for state {0}".format(self.state), ) if self.state == "deleted": commands.extend(self._state_deleted(want=None, have=h)) @@ -242,12 +245,12 @@ class Firewall_global(ConfigBase): for key, val in iteritems(w_fg): if opr and key in l_set and not (h and self._is_w_same(w_fg, h, key)): commands.append( - self._form_attr_cmd(attr=key, val=self._bool_to_str(val), opr=opr) + self._form_attr_cmd(attr=key, val=self._bool_to_str(val), opr=opr), ) elif not opr: if key and self._is_del(l_set, h): commands.append( - self._form_attr_cmd(attr=key, key=self._bool_to_str(val), opr=opr) + self._form_attr_cmd(attr=key, key=self._bool_to_str(val), opr=opr), ) continue if ( @@ -256,7 +259,7 @@ class Firewall_global(ConfigBase): and not self._is_del(l_set, h) ): commands.append( - self._form_attr_cmd(attr=key, val=self._bool_to_str(val), opr=opr) + self._form_attr_cmd(attr=key, val=self._bool_to_str(val), opr=opr), ) else: commands.extend(self._render_attr_config(w_fg, h, key, opr)) @@ -290,7 +293,7 @@ class Firewall_global(ConfigBase): and not (h_ping and self._is_w_same(w[attr], h_ping, item)) ): commands.append( - self._form_attr_cmd(attr=item, val=self._bool_to_str(value), opr=opr) + self._form_attr_cmd(attr=item, val=self._bool_to_str(value), opr=opr), ) elif ( not opr @@ -361,19 +364,29 @@ class Firewall_global(ConfigBase): + key + " '" + str(want[key]) - + "'" + + "'", ) elif not opr and key in l_set: if key == "name" and self._is_grp_del(h, want, key): commands.append(cmd + " " + want["name"]) continue if not (h and self._in_target(h, key)) and not self._is_grp_del( - h, want, key + h, + want, + key, ): commands.append(cmd + " " + want["name"] + " " + key) elif key == "members": commands.extend( - self._render_ports_addrs(key, want, h, opr, cmd, want["name"], attr) + self._render_ports_addrs( + key, + want, + h, + opr, + cmd, + want["name"], + attr, + ), ) return commands @@ -407,7 +420,7 @@ class Firewall_global(ConfigBase): + " " + self._grp_type(type) + " " - + member[self._get_mem_type(type)] + + member[self._get_mem_type(type)], ) elif not opr and have: members = list_diff_want_only(want, have) @@ -419,7 +432,7 @@ class Firewall_global(ConfigBase): + " " + self._grp_type(type) + " " - + member[self._get_mem_type(type)] + + member[self._get_mem_type(type)], ) return commands @@ -462,18 +475,19 @@ class Firewall_global(ConfigBase): attr=key, val=self._bool_to_str(val), opr=opr, - ) + ), ) elif not opr and key in l_set: if not (h and self._in_target(h, key)) and not self._is_del( - l_set, h + l_set, + h, ): if key == "action": commands.append( self._form_attr_cmd( attr=attr + " " + w["connection_type"], opr=opr, - ) + ), ) else: commands.append( @@ -481,7 +495,7 @@ class Firewall_global(ConfigBase): attr=attr + " " + w["connection_type"], val=self._bool_to_str(val), opr=opr, - ) + ), ) return commands @@ -514,7 +528,7 @@ class Firewall_global(ConfigBase): attr=key, val=self._bool_to_str(val), opr=opr, - ) + ), ) elif not opr and key in l_set: if self._is_del(l_set, h): @@ -523,7 +537,7 @@ class Firewall_global(ConfigBase): attr=key, val=self._bool_to_str(val), opr=opr, - ) + ), ) continue if not (h and self._in_target(h, key)) and not self._is_del(l_set, h): @@ -532,7 +546,7 @@ class Firewall_global(ConfigBase): attr=key, val=self._bool_to_str(val), opr=opr, - ) + ), ) elif key == "icmp_redirects": commands.extend(self._render_icmp_redirects(key, w, h, opr)) @@ -557,7 +571,7 @@ class Firewall_global(ConfigBase): for item, value in iteritems(w[attr]): if opr and item in l_set and not (h_red and self._is_w_same(w[attr], h_red, item)): commands.append( - self._form_attr_cmd(attr=item, val=self._bool_to_str(value), opr=opr) + self._form_attr_cmd(attr=item, val=self._bool_to_str(value), opr=opr), ) elif ( not opr diff --git a/plugins/module_utils/network/vyos/config/firewall_interfaces/firewall_interfaces.py b/plugins/module_utils/network/vyos/config/firewall_interfaces/firewall_interfaces.py index 566bfeb..5c4db73 100644 --- a/plugins/module_utils/network/vyos/config/firewall_interfaces/firewall_interfaces.py +++ b/plugins/module_utils/network/vyos/config/firewall_interfaces/firewall_interfaces.py @@ -12,6 +12,7 @@ created """ from __future__ import absolute_import, division, print_function + __metaclass__ = type from copy import deepcopy @@ -52,7 +53,9 @@ class Firewall_interfaces(ConfigBase): :returns: The current configuration as a dictionary """ facts, _warnings = Facts(self._module).get_facts( - self.gather_subset, self.gather_network_resources, data=data + self.gather_subset, + self.gather_network_resources, + data=data, ) firewall_interfaces_facts = facts["ansible_network_resources"].get("firewall_interfaces") if not firewall_interfaces_facts: @@ -93,7 +96,7 @@ class Firewall_interfaces(ConfigBase): running_config = self._module.params["running_config"] if not running_config: self._module.fail_json( - msg="value of running_config parameter must not be empty for state parsed" + msg="value of running_config parameter must not be empty for state parsed", ) result["parsed"] = self.get_firewall_interfaces_facts(data=running_config) else: @@ -134,7 +137,7 @@ class Firewall_interfaces(ConfigBase): commands = [] if self.state in ("merged", "replaced", "overridden", "rendered") and not w: self._module.fail_json( - msg="value of config parameter must not be empty for state {0}".format(self.state) + msg="value of config parameter must not be empty for state {0}".format(self.state), ) if self.state == "overridden": commands.extend(self._state_overridden(w, h)) @@ -202,7 +205,7 @@ class Firewall_interfaces(ConfigBase): name=h_ar["name"], attrib=h[key], opr=False, - ) + ), ) commands.extend(self._state_merged(want, have)) @@ -290,7 +293,7 @@ class Firewall_interfaces(ConfigBase): for h in h_rules: if key in h: commands.append( - self._compute_command(afi=want["afi"], name=name, attrib=h[key], opr=opr) + self._compute_command(afi=want["afi"], name=name, attrib=h[key], opr=opr), ) for w in w_rules: h = search_obj_in_list(w[key], h_rules, key=key) @@ -309,7 +312,7 @@ class Firewall_interfaces(ConfigBase): attrib=w[key], value=w["name"], opr=opr, - ) + ), ) return commands @@ -362,11 +365,11 @@ class Firewall_interfaces(ConfigBase): name=name, attrib=w[key], value=w["name"], - ) + ), ) elif not (h and key in h): commands.append( - self._compute_command(afi=want["afi"], name=name, attrib=w[key]) + self._compute_command(afi=want["afi"], name=name, attrib=w[key]), ) elif not opr: if not h or key not in h or ("name" in w and h and "name" not in h): @@ -376,7 +379,7 @@ class Firewall_interfaces(ConfigBase): name=name, attrib=w[key], opr=opr, - ) + ), ) return commands diff --git a/plugins/module_utils/network/vyos/config/firewall_rules/firewall_rules.py b/plugins/module_utils/network/vyos/config/firewall_rules/firewall_rules.py index aa18a7e..09e19d7 100644 --- a/plugins/module_utils/network/vyos/config/firewall_rules/firewall_rules.py +++ b/plugins/module_utils/network/vyos/config/firewall_rules/firewall_rules.py @@ -12,9 +12,11 @@ created """ from __future__ import absolute_import, division, print_function + __metaclass__ = type import re + from copy import deepcopy from ansible.module_utils.six import iteritems @@ -56,7 +58,9 @@ class Firewall_rules(ConfigBase): :returns: The current configuration as a dictionary """ facts, _warnings = Facts(self._module).get_facts( - self.gather_subset, self.gather_network_resources, data=data + self.gather_subset, + self.gather_network_resources, + data=data, ) firewall_rules_facts = facts["ansible_network_resources"].get("firewall_rules") if not firewall_rules_facts: @@ -97,7 +101,7 @@ class Firewall_rules(ConfigBase): running_config = self._module.params["running_config"] if not running_config: self._module.fail_json( - msg="value of running_config parameter must not be empty for state parsed" + msg="value of running_config parameter must not be empty for state parsed", ) result["parsed"] = self.get_firewall_rules_facts(data=running_config) else: @@ -138,7 +142,7 @@ class Firewall_rules(ConfigBase): commands = [] if self.state in ("merged", "replaced", "overridden", "rendered") and not w: self._module.fail_json( - msg="value of config parameter must not be empty for state {0}".format(self.state) + msg="value of config parameter must not be empty for state {0}".format(self.state), ) if self.state == "overridden": commands.extend(self._state_overridden(w, h)) @@ -168,7 +172,10 @@ class Firewall_rules(ConfigBase): # already have (to be replaced by our desired # configuration's rule set). wanted_rule_set = self.search_r_sets_in_have( - want, rs["name"], "r_list", h["afi"] + want, + rs["name"], + "r_list", + h["afi"], ) if wanted_rule_set is not None: # Remove the rules that we already have if the wanted @@ -179,7 +186,7 @@ class Firewall_rules(ConfigBase): want=rs, have=wanted_rule_set, opr=False, - ) + ), ) # Merge the desired configuration into what we already have. commands.extend(self._state_merged(want, have)) @@ -467,7 +474,7 @@ class Firewall_rules(ConfigBase): commands.append(cmd + (" " + "icmpv6" + " " + param_name + " " + val)) else: commands.append( - cmd + (" " + attr + " " + item.replace("_", "-") + " " + val) + cmd + (" " + attr + " " + item.replace("_", "-") + " " + val), ) else: commands.append(cmd + (" " + attr + " " + item + " " + str(val))) @@ -588,7 +595,7 @@ class Firewall_rules(ConfigBase): + str(rate["number"]) + "/" + rate["unit"] - ) + ), ) if not opr and not ( h_limit @@ -619,7 +626,7 @@ class Firewall_rules(ConfigBase): and not (h and attr in h.keys() and self._is_w_same(w[attr], h[attr], key)) ): commands.append( - cmd + (" " + attr + " " + key.replace("_", "-") + " " + w[attr].get(key)) + cmd + (" " + attr + " " + key.replace("_", "-") + " " + w[attr].get(key)), ) elif ( not opr @@ -652,7 +659,7 @@ class Firewall_rules(ConfigBase): + item.replace("_", "-") + " " + val - ) + ), ) elif ( not opr @@ -660,7 +667,7 @@ class Firewall_rules(ConfigBase): and not (h_group and self._in_target(h_group, item)) ): commands.append( - cmd + (" " + attr + " " + key + " " + item.replace("_", "-")) + cmd + (" " + attr + " " + key + " " + item.replace("_", "-")), ) return commands @@ -779,7 +786,11 @@ class Firewall_rules(ConfigBase): :return: generated command. """ command = self._compute_command( - afi=afi, name=name, attrib=attrib, value=rule[attrib], opr=opr + afi=afi, + name=name, + attrib=attrib, + value=rule[attrib], + opr=opr, ) return command diff --git a/plugins/module_utils/network/vyos/config/hostname/hostname.py b/plugins/module_utils/network/vyos/config/hostname/hostname.py index 8b30a69..36aba74 100644 --- a/plugins/module_utils/network/vyos/config/hostname/hostname.py +++ b/plugins/module_utils/network/vyos/config/hostname/hostname.py @@ -7,6 +7,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ diff --git a/plugins/module_utils/network/vyos/config/interfaces/interfaces.py b/plugins/module_utils/network/vyos/config/interfaces/interfaces.py index 852db46..731014c 100644 --- a/plugins/module_utils/network/vyos/config/interfaces/interfaces.py +++ b/plugins/module_utils/network/vyos/config/interfaces/interfaces.py @@ -11,6 +11,7 @@ created from __future__ import absolute_import, division, print_function + __metaclass__ = type from copy import deepcopy @@ -55,7 +56,9 @@ class Interfaces(ConfigBase): :returns: The current configuration as a dictionary """ facts, _warnings = Facts(self._module).get_facts( - self.gather_subset, self.gather_network_resources, data=data + self.gather_subset, + self.gather_network_resources, + data=data, ) interfaces_facts = facts["ansible_network_resources"].get("interfaces") if not interfaces_facts: @@ -95,7 +98,7 @@ class Interfaces(ConfigBase): running_config = self._module.params["running_config"] if not running_config: self._module.fail_json( - msg="value of running_config parameter must not be empty for state parsed" + msg="value of running_config parameter must not be empty for state parsed", ) result["parsed"] = self.get_interfaces_facts(data=running_config) else: @@ -137,7 +140,7 @@ class Interfaces(ConfigBase): if self.state in ("merged", "replaced", "overridden", "rendered") and not want: self._module.fail_json( - msg="value of config parameter must not be empty for state {0}".format(self.state) + msg="value of config parameter must not be empty for state {0}".format(self.state), ) if self.state == "overridden": @@ -226,7 +229,7 @@ class Interfaces(ConfigBase): if updates: for key, value in iteritems(updates): commands.append( - self._compute_commands(key=key, value=value, interface=want_copy["name"]) + self._compute_commands(key=key, value=value, interface=want_copy["name"]), ) if want_vifs: @@ -247,7 +250,7 @@ class Interfaces(ConfigBase): value=value, interface=want_copy["name"], vif=want_vif["vlan_id"], - ) + ), ) return commands @@ -270,11 +273,11 @@ class Interfaces(ConfigBase): if key == "enabled": continue commands.append( - self._compute_commands(key=key, interface=want_copy["name"], remove=True) + self._compute_commands(key=key, interface=want_copy["name"], remove=True), ) if have_copy["enabled"] is False: commands.append( - self._compute_commands(key="enabled", value=True, interface=want_copy["name"]) + self._compute_commands(key="enabled", value=True, interface=want_copy["name"]), ) if have_vifs: @@ -295,7 +298,7 @@ class Interfaces(ConfigBase): interface=want_copy["name"], vif=want_vif["vlan_id"], remove=True, - ) + ), ) if have_vif["enabled"] is False: commands.append( @@ -304,7 +307,7 @@ class Interfaces(ConfigBase): value=True, interface=want_copy["name"], vif=want_vif["vlan_id"], - ) + ), ) return commands diff --git a/plugins/module_utils/network/vyos/config/l3_interfaces/l3_interfaces.py b/plugins/module_utils/network/vyos/config/l3_interfaces/l3_interfaces.py index 61dd1f4..6e0c005 100644 --- a/plugins/module_utils/network/vyos/config/l3_interfaces/l3_interfaces.py +++ b/plugins/module_utils/network/vyos/config/l3_interfaces/l3_interfaces.py @@ -13,6 +13,7 @@ created from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -59,7 +60,9 @@ class L3_interfaces(ConfigBase): :returns: The current configuration as a dictionary """ facts, _warnings = Facts(self._module).get_facts( - self.gather_subset, self.gather_network_resources, data=data + self.gather_subset, + self.gather_network_resources, + data=data, ) l3_interfaces_facts = facts["ansible_network_resources"].get("l3_interfaces") if not l3_interfaces_facts: @@ -100,7 +103,7 @@ class L3_interfaces(ConfigBase): running_config = self._module.params["running_config"] if not running_config: self._module.fail_json( - msg="value of running_config parameter must not be empty for state parsed" + msg="value of running_config parameter must not be empty for state parsed", ) result["parsed"] = self.get_l3_interfaces_facts(data=running_config) else: @@ -143,7 +146,7 @@ class L3_interfaces(ConfigBase): if state in ("merged", "replaced", "overridden", "rendered") and not want: self._module.fail_json( - msg="value of config parameter must not be empty for state {0}".format(state) + msg="value of config parameter must not be empty for state {0}".format(state), ) if state == "overridden": @@ -225,7 +228,7 @@ class L3_interfaces(ConfigBase): for update in self._get_updates(want_copy, have_copy): for key, value in iteritems(update): commands.append( - self._compute_commands(key=key, value=value, interface=want_copy["name"]) + self._compute_commands(key=key, value=value, interface=want_copy["name"]), ) if want_vifs: @@ -242,7 +245,7 @@ class L3_interfaces(ConfigBase): value=value, interface=want_copy["name"], vif=want_vif["vlan_id"], - ) + ), ) return commands @@ -269,7 +272,7 @@ class L3_interfaces(ConfigBase): value=value, interface=want_copy["name"], remove=True, - ) + ), ) if have_vifs: @@ -287,7 +290,7 @@ class L3_interfaces(ConfigBase): value=value, vif=want_vif["vlan_id"], remove=True, - ) + ), ) return commands diff --git a/plugins/module_utils/network/vyos/config/lag_interfaces/lag_interfaces.py b/plugins/module_utils/network/vyos/config/lag_interfaces/lag_interfaces.py index 314ff93..835615b 100644 --- a/plugins/module_utils/network/vyos/config/lag_interfaces/lag_interfaces.py +++ b/plugins/module_utils/network/vyos/config/lag_interfaces/lag_interfaces.py @@ -10,6 +10,7 @@ created """ from __future__ import absolute_import, division, print_function + __metaclass__ = type from ansible.module_utils.six import iteritems from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import ( @@ -62,7 +63,9 @@ class Lag_interfaces(ConfigBase): :returns: The current configuration as a dictionary """ facts, _warnings = Facts(self._module).get_facts( - self.gather_subset, self.gather_network_resources, data=data + self.gather_subset, + self.gather_network_resources, + data=data, ) lag_interfaces_facts = facts["ansible_network_resources"].get("lag_interfaces") if not lag_interfaces_facts: @@ -103,7 +106,7 @@ class Lag_interfaces(ConfigBase): running_config = self._module.params["running_config"] if not running_config: self._module.fail_json( - msg="value of running_config parameter must not be empty for state parsed" + msg="value of running_config parameter must not be empty for state parsed", ) result["parsed"] = self.get_lag_interfaces_facts(data=running_config) else: @@ -144,7 +147,7 @@ class Lag_interfaces(ConfigBase): commands = [] if self.state in ("merged", "replaced", "overridden", "rendered") and not want: self._module.fail_json( - msg="value of config parameter must not be empty for state {0}".format(self.state) + msg="value of config parameter must not be empty for state {0}".format(self.state), ) if self.state == "overridden": commands.extend(self._state_overridden(want, have)) @@ -301,7 +304,7 @@ class Lag_interfaces(ConfigBase): "bond-group", want["name"], type="ethernet", - ) + ), ) return commands @@ -316,7 +319,7 @@ class Lag_interfaces(ConfigBase): key=want["name"] + " arp-monitor", attrib="interval", value=str(arp_monitor["interval"]), - ) + ), ) if diff_targets: for target in diff_targets: @@ -325,7 +328,7 @@ class Lag_interfaces(ConfigBase): key=want["name"] + " arp-monitor", attrib="target", value=target, - ) + ), ) return commands @@ -339,7 +342,7 @@ class Lag_interfaces(ConfigBase): have["name"], remove=True, type="ethernet", - ) + ), ) return commands @@ -362,7 +365,7 @@ class Lag_interfaces(ConfigBase): key=have["name"] + " arp-monitor", attrib="interval", remove=True, - ) + ), ) if "target" in have_arp_monitor: target_diff = list_diff_have_only(want_arp_target, have_arp_target) @@ -374,7 +377,7 @@ class Lag_interfaces(ConfigBase): attrib="target", value=target, remove=True, - ) + ), ) return commands @@ -394,7 +397,7 @@ class Lag_interfaces(ConfigBase): have["name"], True, "ethernet", - ) + ), ) return commands diff --git a/plugins/module_utils/network/vyos/config/lldp_global/lldp_global.py b/plugins/module_utils/network/vyos/config/lldp_global/lldp_global.py index b2571e0..1afda78 100644 --- a/plugins/module_utils/network/vyos/config/lldp_global/lldp_global.py +++ b/plugins/module_utils/network/vyos/config/lldp_global/lldp_global.py @@ -10,6 +10,7 @@ created """ from __future__ import absolute_import, division, print_function + __metaclass__ = type from ansible.module_utils.six import iteritems from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import ( @@ -53,7 +54,9 @@ class Lldp_global(ConfigBase): :returns: The current configuration as a dictionary """ facts, _warnings = Facts(self._module).get_facts( - self.gather_subset, self.gather_network_resources, data=data + self.gather_subset, + self.gather_network_resources, + data=data, ) lldp_global_facts = facts["ansible_network_resources"].get("lldp_global") if not lldp_global_facts: @@ -94,7 +97,7 @@ class Lldp_global(ConfigBase): running_config = self._module.params["running_config"] if not running_config: self._module.fail_json( - msg="value of running_config parameter must not be empty for state parsed" + msg="value of running_config parameter must not be empty for state parsed", ) result["parsed"] = self.get_lldp_global_facts(data=running_config) else: @@ -135,7 +138,7 @@ class Lldp_global(ConfigBase): commands = [] if self.state in ("merged", "replaced", "rendered") and not want: self._module.fail_json( - msg="value of config parameter must not be empty for state {0}".format(self.state) + msg="value of config parameter must not be empty for state {0}".format(self.state), ) if self.state == "deleted": commands.extend(self._state_deleted(want=None, have=have)) diff --git a/plugins/module_utils/network/vyos/config/lldp_interfaces/lldp_interfaces.py b/plugins/module_utils/network/vyos/config/lldp_interfaces/lldp_interfaces.py index 11b950b..53e9aed 100644 --- a/plugins/module_utils/network/vyos/config/lldp_interfaces/lldp_interfaces.py +++ b/plugins/module_utils/network/vyos/config/lldp_interfaces/lldp_interfaces.py @@ -13,6 +13,7 @@ created from __future__ import absolute_import, division, print_function + __metaclass__ = type from ansible.module_utils.six import iteritems @@ -59,7 +60,9 @@ class Lldp_interfaces(ConfigBase): :returns: The current configuration as a dictionary """ facts, _warnings = Facts(self._module).get_facts( - self.gather_subset, self.gather_network_resources, data=data + self.gather_subset, + self.gather_network_resources, + data=data, ) lldp_interfaces_facts = facts["ansible_network_resources"].get("lldp_interfaces") if not lldp_interfaces_facts: @@ -100,7 +103,7 @@ class Lldp_interfaces(ConfigBase): running_config = self._module.params["running_config"] if not running_config: self._module.fail_json( - msg="value of running_config parameter must not be empty for state parsed" + msg="value of running_config parameter must not be empty for state parsed", ) result["parsed"] = self.get_lldp_interfaces_facts(data=running_config) else: @@ -141,7 +144,7 @@ class Lldp_interfaces(ConfigBase): commands = [] if self.state in ("merged", "replaced", "overridden", "rendered") and not want: self._module.fail_json( - msg="value of config parameter must not be empty for state {0}".format(self.state) + msg="value of config parameter must not be empty for state {0}".format(self.state), ) if self.state == "overridden": commands.extend(self._state_overridden(want=want, have=have)) @@ -300,7 +303,7 @@ class Lldp_interfaces(ConfigBase): set_cmd + location_type, "country-code", str(want_dict["country_code"]), - ) + ), ) else: commands.append( @@ -308,7 +311,7 @@ class Lldp_interfaces(ConfigBase): set_cmd + location_type, "country-code", str(want_dict["country_code"]), - ) + ), ) commands.extend(self._add_civic_address(name, want_ca, have_ca)) @@ -320,14 +323,14 @@ class Lldp_interfaces(ConfigBase): self._compute_command( set_cmd + location_type, value=str(want_location_type["elin"]), - ) + ), ) else: commands.append( self._compute_command( set_cmd + location_type, value=str(want_location_type["elin"]), - ) + ), ) return commands @@ -346,7 +349,7 @@ class Lldp_interfaces(ConfigBase): only_in_have = key_value_in_dict(key, value, want_dict) if not only_in_have: commands.append( - self._compute_command(del_cmd + location_type, key, str(value), True) + self._compute_command(del_cmd + location_type, key, str(value), True), ) else: commands.append(self._compute_command(del_cmd, remove=True)) @@ -381,7 +384,7 @@ class Lldp_interfaces(ConfigBase): key=name + " location civic-based ca-type", attrib=str(ca_type) + " ca-value", value=ca_value, - ) + ), ) return commands @@ -398,7 +401,7 @@ class Lldp_interfaces(ConfigBase): "location civic-based ca-type", str(ca_type), remove=True, - ) + ), ) return commands diff --git a/plugins/module_utils/network/vyos/config/logging_global/logging_global.py b/plugins/module_utils/network/vyos/config/logging_global/logging_global.py index 27c33b3..d8bfa18 100644 --- a/plugins/module_utils/network/vyos/config/logging_global/logging_global.py +++ b/plugins/module_utils/network/vyos/config/logging_global/logging_global.py @@ -7,6 +7,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -173,7 +174,7 @@ class Logging_global(ResourceModule): element: { "facilities": dat, self.pkey.get(element): v.get(self.pkey.get(element)), - } + }, } del v["facilities"] if len(list(v.keys())) > 1: diff --git a/plugins/module_utils/network/vyos/config/ntp_global/ntp_global.py b/plugins/module_utils/network/vyos/config/ntp_global/ntp_global.py index 3ce6ec2..106faac 100644 --- a/plugins/module_utils/network/vyos/config/ntp_global/ntp_global.py +++ b/plugins/module_utils/network/vyos/config/ntp_global/ntp_global.py @@ -7,6 +7,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -89,12 +90,12 @@ class Ntp_global(ResourceModule): for hk, hval in iteritems(have): if hk == "allow_clients" and hk in commandlist: self.commands.append( - self._tmplt.render({"": hk}, "allow_clients_delete", True) + self._tmplt.render({"": hk}, "allow_clients_delete", True), ) commandlist.remove(hk) elif hk == "listen_addresses" and hk in commandlist: self.commands.append( - self._tmplt.render({"": hk}, "listen_addresses_delete", True) + self._tmplt.render({"": hk}, "listen_addresses_delete", True), ) commandlist.remove(hk) elif hk == "server" and have["server"] in servernames: diff --git a/plugins/module_utils/network/vyos/config/ospf_interfaces/ospf_interfaces.py b/plugins/module_utils/network/vyos/config/ospf_interfaces/ospf_interfaces.py index 527f062..a7652a6 100644 --- a/plugins/module_utils/network/vyos/config/ospf_interfaces/ospf_interfaces.py +++ b/plugins/module_utils/network/vyos/config/ospf_interfaces/ospf_interfaces.py @@ -7,6 +7,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ The vyos_ospf_interfaces config file. diff --git a/plugins/module_utils/network/vyos/config/ospfv2/ospfv2.py b/plugins/module_utils/network/vyos/config/ospfv2/ospfv2.py index 3f9e4e6..a9c1de1 100644 --- a/plugins/module_utils/network/vyos/config/ospfv2/ospfv2.py +++ b/plugins/module_utils/network/vyos/config/ospfv2/ospfv2.py @@ -12,6 +12,7 @@ created """ from __future__ import absolute_import, division, print_function + __metaclass__ = type from copy import deepcopy @@ -54,7 +55,9 @@ class Ospfv2(ConfigBase): """ (facts, _warnings) = Facts(self._module).get_facts( - self.gather_subset, self.gather_network_resources, data=data + self.gather_subset, + self.gather_network_resources, + data=data, ) ospfv2_facts = facts["ansible_network_resources"].get("ospfv2", {}) return ospfv2_facts @@ -94,7 +97,7 @@ class Ospfv2(ConfigBase): running_config = self._module.params["running_config"] if not running_config: self._module.fail_json( - msg="value of running_config parameter must not be empty for state parsed" + msg="value of running_config parameter must not be empty for state parsed", ) result["parsed"] = self.get_ospfv2_facts(data=running_config) else: @@ -137,7 +140,7 @@ class Ospfv2(ConfigBase): commands = [] if self.state in ("merged", "replaced", "overridden", "rendered") and not w: self._module.fail_json( - msg="value of config parameter must not be empty for state {0}".format(self.state) + msg="value of config parameter must not be empty for state {0}".format(self.state), ) if self.state == "deleted": @@ -298,7 +301,7 @@ class Ospfv2(ConfigBase): commands.append(self._form_attr_cmd(key=attr, attr=item, opr=opr)) else: commands.append( - self._form_attr_cmd(key=attr, attr=item, val=value, opr=opr) + self._form_attr_cmd(key=attr, attr=item, val=value, opr=opr), ) elif not opr and item in leaf and not _in_target(h, item): if item == "enabled": @@ -342,7 +345,7 @@ class Ospfv2(ConfigBase): if attr == "network": if not self.search_obj_in_have(h, member, "address"): commands.append( - cmd + attr.replace("_", "-") + " " + member["address"] + cmd + attr.replace("_", "-") + " " + member["address"], ) elif member not in h: commands.append(cmd + attr.replace("_", "-") + " " + member) @@ -372,7 +375,7 @@ class Ospfv2(ConfigBase): "transmit_delay", "hello_interval", "retransmit_interval", - ) + ), } leaf = leaf_dict[attr] w = want.get(attr) or [] @@ -398,14 +401,14 @@ class Ospfv2(ConfigBase): + " " + key.replace("_", "-") + " " - + str(val) + + str(val), ) elif not opr and key in leaf and not _in_target(h_item, key): if key in "address": commands.append(cmd + attr.replace("_", "-") + " " + str(val)) else: commands.append( - cmd + attr.replace("_", "-") + " " + w_item[name[attr]] + " " + key + cmd + attr.replace("_", "-") + " " + w_item[name[attr]] + " " + key, ) elif key == "authentication": commands.extend( @@ -417,7 +420,7 @@ class Ospfv2(ConfigBase): w_item["address"], cmd, opr, - ) + ), ) return commands @@ -504,11 +507,11 @@ class Ospfv2(ConfigBase): commands.append(cmd + attr + " " + str(val)) elif key == "cost": commands.append( - cmd + attr + " " + w_item[name[attr]] + " " + key + " " + str(val) + cmd + attr + " " + w_item[name[attr]] + " " + key + " " + str(val), ) elif key == "not_advertise": commands.append( - cmd + attr + " " + w_item[name[attr]] + " " + key.replace("_", "-") + cmd + attr + " " + w_item[name[attr]] + " " + key.replace("_", "-"), ) elif key == "md5_key": commands.append( @@ -521,7 +524,7 @@ class Ospfv2(ConfigBase): + " " + key.replace("_", "-") + " " - + w_item[key] + + w_item[key], ) else: commands.append( @@ -532,7 +535,7 @@ class Ospfv2(ConfigBase): + " " + key.replace("_", "-") + " " - + str(val) + + str(val), ) elif not opr and key in leaf and not _in_target(h_item, key): if key in ( @@ -596,7 +599,7 @@ class Ospfv2(ConfigBase): + " " + key.replace("_", "-") + " " - + item.replace("_", "-") + + item.replace("_", "-"), ) elif item not in ("administrative", "always"): commands.append( @@ -607,7 +610,7 @@ class Ospfv2(ConfigBase): + " " + item.replace("_", "-") + " " - + str(val) + + str(val), ) elif not opr and item in leaf and not _in_target(h_attrib, item): commands.append(cmd + attr + " " + item) @@ -645,7 +648,7 @@ class Ospfv2(ConfigBase): h_area = self.search_obj_in_have(h_lst, w_area, "area_id") if not opr and not h_area: commands.append( - self._form_attr_cmd(key="area", attr=w_area["area_id"], opr=opr) + self._form_attr_cmd(key="area", attr=w_area["area_id"], opr=opr), ) else: for key, val in iteritems(w_area): @@ -656,11 +659,11 @@ class Ospfv2(ConfigBase): attr="area", val=_bool_to_str(val), opr=opr, - ) + ), ) else: commands.append( - cmd + key + " " + _bool_to_str(val).replace("_", "-") + cmd + key + " " + _bool_to_str(val).replace("_", "-"), ) elif not opr and key in l_set: if key == "area_id" and not _in_target(h_area, key): @@ -674,7 +677,7 @@ class Ospfv2(ConfigBase): commands.extend(self._render_list_param(key, w_area, h_area, cmd, opr)) elif key == "range": commands.extend( - self._render_list_dict_param(key, w_area, h_area, cmd, opr) + self._render_list_dict_param(key, w_area, h_area, cmd, opr), ) elif key == "virtual_link": commands.extend(self._render_vlink(key, w_area, h_area, cmd, opr)) @@ -704,7 +707,7 @@ class Ospfv2(ConfigBase): if opr and key in w_type.keys() and not _is_w_same(w_type, h_type, key): if not w_type[key] and h_type and h_type[key]: commands.append( - cmd.replace("set", "delete") + attr.replace("_", "-") + " " + key + cmd.replace("set", "delete") + attr.replace("_", "-") + " " + key, ) elif w_type[key]: commands.append(cmd + attr.replace("_", "-") + " " + key) @@ -734,7 +737,7 @@ class Ospfv2(ConfigBase): cmd.replace("set", "delete") + attr.replace("_", "-") + " " - + key + + key, ) elif item != "set": commands.append( @@ -745,7 +748,7 @@ class Ospfv2(ConfigBase): + " " + item.replace("_", "-") + " " - + str(val) + + str(val), ) elif not opr and item in a_type[key] and not (h_type and key in h_type): if item == "set": @@ -759,7 +762,7 @@ class Ospfv2(ConfigBase): + " " + key + " " - + item.replace("_", "-") + + item.replace("_", "-"), ) return commands diff --git a/plugins/module_utils/network/vyos/config/ospfv3/ospfv3.py b/plugins/module_utils/network/vyos/config/ospfv3/ospfv3.py index abafc90..25d9a0e 100644 --- a/plugins/module_utils/network/vyos/config/ospfv3/ospfv3.py +++ b/plugins/module_utils/network/vyos/config/ospfv3/ospfv3.py @@ -12,6 +12,7 @@ created """ from __future__ import absolute_import, division, print_function + __metaclass__ = type from copy import deepcopy @@ -58,7 +59,9 @@ class Ospfv3(ConfigBase): :returns: The current configuration as a dictionary """ facts, _warnings = Facts(self._module).get_facts( - self.gather_subset, self.gather_network_resources, data=data + self.gather_subset, + self.gather_network_resources, + data=data, ) ospfv3_facts = facts["ansible_network_resources"].get("ospfv3", {}) return ospfv3_facts @@ -97,7 +100,7 @@ class Ospfv3(ConfigBase): running_config = self._module.params["running_config"] if not running_config: self._module.fail_json( - msg="value of running_config parameter must not be empty for state parsed" + msg="value of running_config parameter must not be empty for state parsed", ) result["parsed"] = self.get_ospfv3_facts(data=running_config) else: @@ -138,7 +141,7 @@ class Ospfv3(ConfigBase): commands = [] if self.state in ("merged", "replaced", "overridden", "rendered") and not w: self._module.fail_json( - msg="value of config parameter must not be empty for state {0}".format(self.state) + msg="value of config parameter must not be empty for state {0}".format(self.state), ) if self.state == "deleted": commands.extend(self._state_deleted(w, h)) @@ -289,7 +292,7 @@ class Ospfv3(ConfigBase): commands.append(cmd + attr + " " + str(val)) elif key in leaf_dict["range"] and key != "address": commands.append( - cmd + attr + " " + w_item[name[attr]] + " " + key.replace("_", "-") + cmd + attr + " " + w_item[name[attr]] + " " + key.replace("_", "-"), ) elif key == "route_map": commands.append( @@ -300,7 +303,7 @@ class Ospfv3(ConfigBase): + " " + key.replace("_", "-") + " " - + str(val) + + str(val), ) elif not opr and key in leaf and not _in_target(h_item, key): if key in ("route_type", "address"): @@ -340,7 +343,7 @@ class Ospfv3(ConfigBase): h_area = search_obj_in_list(w_area["area_id"], h_lst, "area_id") if not opr and not h_area: commands.append( - self._form_attr_cmd(key="area", attr=w_area["area_id"], opr=opr) + self._form_attr_cmd(key="area", attr=w_area["area_id"], opr=opr), ) else: for key, val in iteritems(w_area): @@ -351,14 +354,14 @@ class Ospfv3(ConfigBase): attr="area", val=_bool_to_str(val), opr=opr, - ) + ), ) else: commands.append( cmd + key.replace("_", "-") + " " - + _bool_to_str(val).replace("_", "-") + + _bool_to_str(val).replace("_", "-"), ) elif not opr and key in l_set: if key == "area_id" and not _in_target(h_area, key): @@ -368,7 +371,7 @@ class Ospfv3(ConfigBase): commands.append(cmd + val + " " + key) elif key == "range": commands.extend( - self._render_list_dict_param(key, w_area, h_area, cmd, opr) + self._render_list_dict_param(key, w_area, h_area, cmd, opr), ) return commands diff --git a/plugins/module_utils/network/vyos/config/prefix_lists/prefix_lists.py b/plugins/module_utils/network/vyos/config/prefix_lists/prefix_lists.py index a8cc69e..9da27c1 100644 --- a/plugins/module_utils/network/vyos/config/prefix_lists/prefix_lists.py +++ b/plugins/module_utils/network/vyos/config/prefix_lists/prefix_lists.py @@ -7,6 +7,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -120,8 +121,9 @@ class Prefix_lists(ResourceModule): for h in hplists.values(): self.commands.append( "delete policy prefix-{0} {1}".format( - "list" if h["afi"] == "ipv4" else "list6", h["name"] - ) + "list" if h["afi"] == "ipv4" else "list6", + h["name"], + ), ) def _compare_plists(self, want, have): @@ -158,7 +160,7 @@ class Prefix_lists(ResourceModule): "list" if hr["afi"] == "ipv4" else "list6", hr["name"], hr["sequence"], - ) + ), ) def _prefix_list_list_to_dict(self, entry): diff --git a/plugins/module_utils/network/vyos/config/route_maps/route_maps.py b/plugins/module_utils/network/vyos/config/route_maps/route_maps.py index dd6fbf6..9b6c3e9 100644 --- a/plugins/module_utils/network/vyos/config/route_maps/route_maps.py +++ b/plugins/module_utils/network/vyos/config/route_maps/route_maps.py @@ -7,6 +7,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ diff --git a/plugins/module_utils/network/vyos/config/snmp_server/snmp_server.py b/plugins/module_utils/network/vyos/config/snmp_server/snmp_server.py index b942f8b..9497d7f 100644 --- a/plugins/module_utils/network/vyos/config/snmp_server/snmp_server.py +++ b/plugins/module_utils/network/vyos/config/snmp_server/snmp_server.py @@ -7,6 +7,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -137,7 +138,7 @@ class Snmp_server(ResourceModule): "communities": { k: hdict[key].pop(k, ""), "name": key, - } + }, } self.compare( parsers="communities", @@ -200,8 +201,8 @@ class Snmp_server(ResourceModule): attribute_dict[attrib]: hattrib[key][ attribute_dict[attrib] ], - } - } + }, + }, } self.compare( parsers=parsers, @@ -210,8 +211,8 @@ class Snmp_server(ResourceModule): attrib: { k: v, attribute_dict[attrib]: entry[attribute_dict[attrib]], - } - } + }, + }, }, have=h, ) @@ -252,16 +253,16 @@ class Snmp_server(ResourceModule): attrib: { key: entry, primary_key: wattrib[primary_key], - } - } + }, + }, }, have={ "snmp_v3": { attrib: { key: hattrib.pop(key, {}), primary_key: wattrib[primary_key], - } - } + }, + }, }, ) for key, entry in iteritems(hattrib): @@ -274,8 +275,8 @@ class Snmp_server(ResourceModule): attrib: { key: entry, primary_key: hattrib[primary_key], - } - } + }, + }, }, ) diff --git a/plugins/module_utils/network/vyos/config/static_routes/static_routes.py b/plugins/module_utils/network/vyos/config/static_routes/static_routes.py index 230a47c..9230bdd 100644 --- a/plugins/module_utils/network/vyos/config/static_routes/static_routes.py +++ b/plugins/module_utils/network/vyos/config/static_routes/static_routes.py @@ -13,6 +13,7 @@ created from __future__ import absolute_import, division, print_function + __metaclass__ = type from copy import deepcopy @@ -54,7 +55,9 @@ class Static_routes(ConfigBase): :returns: The current configuration as a dictionary """ facts, _warnings = Facts(self._module).get_facts( - self.gather_subset, self.gather_network_resources, data=data + self.gather_subset, + self.gather_network_resources, + data=data, ) static_routes_facts = facts["ansible_network_resources"].get("static_routes") if not static_routes_facts: @@ -95,7 +98,7 @@ class Static_routes(ConfigBase): running_config = self._module.params["running_config"] if not running_config: self._module.fail_json( - msg="value of running_config parameter must not be empty for state parsed" + msg="value of running_config parameter must not be empty for state parsed", ) result["parsed"] = self.get_static_routes_facts(data=running_config) else: @@ -136,7 +139,7 @@ class Static_routes(ConfigBase): commands = [] if self.state in ("merged", "replaced", "overridden", "rendered") and not want: self._module.fail_json( - msg="value of config parameter must not be empty for state {0}".format(self.state) + msg="value of config parameter must not be empty for state {0}".format(self.state), ) if self.state == "overridden": commands.extend(self._state_overridden(want=want, have=have)) @@ -290,7 +293,7 @@ class Static_routes(ConfigBase): attrib=attrib, remove=False, value=str(value), - ) + ), ) elif attrib == "type": commands.append(self._compute_command(dest=want["dest"], key="blackhole")) @@ -321,7 +324,7 @@ class Static_routes(ConfigBase): key="next-hop", value=hop[element], opr=opr, - ) + ), ) elif element == "enabled" and not hop[element]: commands.append( @@ -331,7 +334,7 @@ class Static_routes(ConfigBase): attrib=hop["forward_router_address"], value="disable", opr=opr, - ) + ), ) elif element == "admin_distance": commands.append( @@ -341,7 +344,7 @@ class Static_routes(ConfigBase): attrib=hop["forward_router_address"] + " " + "distance", value=str(hop[element]), opr=opr, - ) + ), ) elif element == "interface": commands.append( @@ -351,7 +354,7 @@ class Static_routes(ConfigBase): attrib=hop["forward_router_address"] + " " + "next-hop-interface", value=hop[element], opr=opr, - ) + ), ) return commands @@ -385,11 +388,11 @@ class Static_routes(ConfigBase): attrib=attrib, remove=True, value=str(value), - ) + ), ) elif attrib == "type" and "distance" not in want_blackhole.keys(): commands.append( - self._compute_command(dest=want["dest"], key="blackhole", remove=True) + self._compute_command(dest=want["dest"], key="blackhole", remove=True), ) return commands @@ -417,7 +420,7 @@ class Static_routes(ConfigBase): key="next-hop", value=hop[element], remove=True, - ) + ), ) elif element == "enabled": commands.append( @@ -427,7 +430,7 @@ class Static_routes(ConfigBase): attrib=hop["forward_router_address"], value="disable", remove=True, - ) + ), ) elif element == "admin_distance": commands.append( @@ -437,7 +440,7 @@ class Static_routes(ConfigBase): attrib=hop["forward_router_address"] + " " + "distance", value=str(hop[element]), remove=True, - ) + ), ) elif element == "interface": commands.append( @@ -447,7 +450,7 @@ class Static_routes(ConfigBase): attrib=hop["forward_router_address"] + " " + "next-hop-interface", value=hop[element], remove=True, - ) + ), ) return commands diff --git a/plugins/module_utils/network/vyos/facts/bgp_address_family/bgp_address_family.py b/plugins/module_utils/network/vyos/facts/bgp_address_family/bgp_address_family.py index 5d60184..629ffc5 100644 --- a/plugins/module_utils/network/vyos/facts/bgp_address_family/bgp_address_family.py +++ b/plugins/module_utils/network/vyos/facts/bgp_address_family/bgp_address_family.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -68,7 +69,8 @@ class Bgp_address_familyFacts(object): af["networks"] = sorted(af["networks"], key=lambda k: k["prefix"]) if "aggregate_address" in af: af["aggregate_address"] = sorted( - af["aggregate_address"], key=lambda k: k["prefix"] + af["aggregate_address"], + key=lambda k: k["prefix"], ) if "neighbors" in objs: objs["neighbors"] = list(objs["neighbors"].values()) diff --git a/plugins/module_utils/network/vyos/facts/bgp_global/bgp_global.py b/plugins/module_utils/network/vyos/facts/bgp_global/bgp_global.py index c6105a0..fe34135 100644 --- a/plugins/module_utils/network/vyos/facts/bgp_global/bgp_global.py +++ b/plugins/module_utils/network/vyos/facts/bgp_global/bgp_global.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -71,7 +72,7 @@ class Bgp_globalFacts(object): ansible_facts["ansible_network_resources"].pop("bgp_global", None) params = utils.remove_empties( - bgp_global_parser.validate_config(self.argument_spec, {"config": objs}, redact=True) + bgp_global_parser.validate_config(self.argument_spec, {"config": objs}, redact=True), ) facts["bgp_global"] = params.get("config", []) diff --git a/plugins/module_utils/network/vyos/facts/facts.py b/plugins/module_utils/network/vyos/facts/facts.py index f7b2b4e..74bbda7 100644 --- a/plugins/module_utils/network/vyos/facts/facts.py +++ b/plugins/module_utils/network/vyos/facts/facts.py @@ -8,6 +8,7 @@ calls the appropriate facts gathering function """ from __future__ import absolute_import, division, print_function + __metaclass__ = type from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts import ( @@ -80,6 +81,7 @@ from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.stati Static_routesFacts, ) + FACT_LEGACY_SUBSETS = dict(default=Default, neighbors=Neighbors, config=Config) FACT_RESOURCE_SUBSETS = dict( interfaces=InterfacesFacts, diff --git a/plugins/module_utils/network/vyos/facts/firewall_global/firewall_global.py b/plugins/module_utils/network/vyos/facts/firewall_global/firewall_global.py index 6441c26..5b47222 100644 --- a/plugins/module_utils/network/vyos/facts/firewall_global/firewall_global.py +++ b/plugins/module_utils/network/vyos/facts/firewall_global/firewall_global.py @@ -11,6 +11,7 @@ based on the configuration. """ from __future__ import absolute_import, division, print_function + __metaclass__ = type from copy import deepcopy @@ -80,7 +81,7 @@ class Firewall_globalFacts(object): filter( lambda x: ("firewall ipv6-name" and "firewall name" not in x), conf, - ) + ), ) a_lst = [ @@ -209,10 +210,12 @@ class Firewall_globalFacts(object): cfg_dict = {} cfg_dict["port_group"] = self.parse_group_lst(conf, "port-group", False) cfg_dict["address_group"] = self.parse_group_lst( - conf, "address-group" + conf, + "address-group", ) + self.parse_group_lst(conf, "ipv6-address-group") cfg_dict["network_group"] = self.parse_group_lst( - conf, "network-group" + conf, + "network-group", ) + self.parse_group_lst(conf, "ipv6-network-group") return cfg_dict diff --git a/plugins/module_utils/network/vyos/facts/firewall_interfaces/firewall_interfaces.py b/plugins/module_utils/network/vyos/facts/firewall_interfaces/firewall_interfaces.py index 3e0d323..b980469 100644 --- a/plugins/module_utils/network/vyos/facts/firewall_interfaces/firewall_interfaces.py +++ b/plugins/module_utils/network/vyos/facts/firewall_interfaces/firewall_interfaces.py @@ -11,6 +11,7 @@ based on the configuration. """ from __future__ import absolute_import, division, print_function + __metaclass__ = type from copy import deepcopy diff --git a/plugins/module_utils/network/vyos/facts/firewall_rules/firewall_rules.py b/plugins/module_utils/network/vyos/facts/firewall_rules/firewall_rules.py index 69daad9..ead038a 100644 --- a/plugins/module_utils/network/vyos/facts/firewall_rules/firewall_rules.py +++ b/plugins/module_utils/network/vyos/facts/firewall_rules/firewall_rules.py @@ -11,9 +11,11 @@ based on the configuration. """ from __future__ import absolute_import, division, print_function + __metaclass__ = type import re + from copy import deepcopy from re import M, findall, search diff --git a/plugins/module_utils/network/vyos/facts/hostname/hostname.py b/plugins/module_utils/network/vyos/facts/hostname/hostname.py index 77ecc8c..b4f7c52 100644 --- a/plugins/module_utils/network/vyos/facts/hostname/hostname.py +++ b/plugins/module_utils/network/vyos/facts/hostname/hostname.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -62,7 +63,7 @@ class HostnameFacts(object): ansible_facts["ansible_network_resources"].pop("hostname", None) params = utils.remove_empties( - hostname_parser.validate_config(self.argument_spec, {"config": objs}, redact=True) + hostname_parser.validate_config(self.argument_spec, {"config": objs}, redact=True), ) facts["hostname"] = params.get("config", {}) diff --git a/plugins/module_utils/network/vyos/facts/interfaces/interfaces.py b/plugins/module_utils/network/vyos/facts/interfaces/interfaces.py index 51c3a10..995be91 100644 --- a/plugins/module_utils/network/vyos/facts/interfaces/interfaces.py +++ b/plugins/module_utils/network/vyos/facts/interfaces/interfaces.py @@ -12,6 +12,7 @@ based on the configuration. from __future__ import absolute_import, division, print_function + __metaclass__ = type diff --git a/plugins/module_utils/network/vyos/facts/l3_interfaces/l3_interfaces.py b/plugins/module_utils/network/vyos/facts/l3_interfaces/l3_interfaces.py index 845d79e..be467a0 100644 --- a/plugins/module_utils/network/vyos/facts/l3_interfaces/l3_interfaces.py +++ b/plugins/module_utils/network/vyos/facts/l3_interfaces/l3_interfaces.py @@ -12,10 +12,12 @@ based on the configuration. from __future__ import absolute_import, division, print_function + __metaclass__ = type import re + from copy import deepcopy from ansible.module_utils.six import iteritems diff --git a/plugins/module_utils/network/vyos/facts/lag_interfaces/lag_interfaces.py b/plugins/module_utils/network/vyos/facts/lag_interfaces/lag_interfaces.py index 251178a..78638bb 100644 --- a/plugins/module_utils/network/vyos/facts/lag_interfaces/lag_interfaces.py +++ b/plugins/module_utils/network/vyos/facts/lag_interfaces/lag_interfaces.py @@ -11,6 +11,7 @@ based on the configuration. """ from __future__ import absolute_import, division, print_function + __metaclass__ = type from copy import deepcopy diff --git a/plugins/module_utils/network/vyos/facts/legacy/base.py b/plugins/module_utils/network/vyos/facts/legacy/base.py index 59666e1..30978e0 100644 --- a/plugins/module_utils/network/vyos/facts/legacy/base.py +++ b/plugins/module_utils/network/vyos/facts/legacy/base.py @@ -11,6 +11,7 @@ based on the configuration. from __future__ import absolute_import, division, print_function + __metaclass__ = type import platform import re diff --git a/plugins/module_utils/network/vyos/facts/lldp_global/lldp_global.py b/plugins/module_utils/network/vyos/facts/lldp_global/lldp_global.py index e563999..b2afe59 100644 --- a/plugins/module_utils/network/vyos/facts/lldp_global/lldp_global.py +++ b/plugins/module_utils/network/vyos/facts/lldp_global/lldp_global.py @@ -11,6 +11,7 @@ based on the configuration. """ from __future__ import absolute_import, division, print_function + __metaclass__ = type from copy import deepcopy diff --git a/plugins/module_utils/network/vyos/facts/lldp_interfaces/lldp_interfaces.py b/plugins/module_utils/network/vyos/facts/lldp_interfaces/lldp_interfaces.py index bfe684f..5f439e7 100644 --- a/plugins/module_utils/network/vyos/facts/lldp_interfaces/lldp_interfaces.py +++ b/plugins/module_utils/network/vyos/facts/lldp_interfaces/lldp_interfaces.py @@ -12,6 +12,7 @@ based on the configuration. from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -90,7 +91,8 @@ class Lldp_interfacesFacts(object): disable = "\n".join(filter(lambda x: ("disable" in x), conf)) coordinate_based_conf = self.parse_attribs( - ["altitude", "datum", "longitude", "latitude"], coordinate_conf + ["altitude", "datum", "longitude", "latitude"], + coordinate_conf, ) elin_based_conf = self.parse_lldp_elin_based(elin_conf) civic_based_conf = self.parse_lldp_civic_based(civic_conf) diff --git a/plugins/module_utils/network/vyos/facts/logging_global/logging_global.py b/plugins/module_utils/network/vyos/facts/logging_global/logging_global.py index e0434d9..8b60bef 100644 --- a/plugins/module_utils/network/vyos/facts/logging_global/logging_global.py +++ b/plugins/module_utils/network/vyos/facts/logging_global/logging_global.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -87,7 +88,11 @@ class Logging_globalFacts(object): objs = self.process_facts(objs) params = utils.remove_empties( - logging_global_parser.validate_config(self.argument_spec, {"config": objs}, redact=True) + logging_global_parser.validate_config( + self.argument_spec, + {"config": objs}, + redact=True, + ), ) facts["logging_global"] = params.get("config", {}) diff --git a/plugins/module_utils/network/vyos/facts/ntp_global/ntp_global.py b/plugins/module_utils/network/vyos/facts/ntp_global/ntp_global.py index cead241..880bc79 100644 --- a/plugins/module_utils/network/vyos/facts/ntp_global/ntp_global.py +++ b/plugins/module_utils/network/vyos/facts/ntp_global/ntp_global.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -81,7 +82,7 @@ class Ntp_globalFacts(object): ansible_facts["ansible_network_resources"].pop("ntp_global", None) params = utils.remove_empties( - ntp_parser.validate_config(self.argument_spec, {"config": objs}, redact=True) + ntp_parser.validate_config(self.argument_spec, {"config": objs}, redact=True), ) if params.get("config"): diff --git a/plugins/module_utils/network/vyos/facts/ospf_interfaces/ospf_interfaces.py b/plugins/module_utils/network/vyos/facts/ospf_interfaces/ospf_interfaces.py index c89e2bd..af6c577 100644 --- a/plugins/module_utils/network/vyos/facts/ospf_interfaces/ospf_interfaces.py +++ b/plugins/module_utils/network/vyos/facts/ospf_interfaces/ospf_interfaces.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -76,7 +77,8 @@ class Ospf_interfacesFacts(object): resources = self.get_config_set(data) for resource in resources: ospf_interfaces_parser = Ospf_interfacesTemplate( - lines=resource.split("\n"), module=self._module + lines=resource.split("\n"), + module=self._module, ) objs = ospf_interfaces_parser.parse() for key, sortv in [("address_family", "afi")]: @@ -91,7 +93,7 @@ class Ospf_interfacesFacts(object): self.argument_spec, {"config": ospf_interfaces_facts}, redact=True, - ) + ), ) if params.get("config"): for cfg in params["config"]: diff --git a/plugins/module_utils/network/vyos/facts/ospfv2/ospfv2.py b/plugins/module_utils/network/vyos/facts/ospfv2/ospfv2.py index 5121c98..bdc7c9f 100644 --- a/plugins/module_utils/network/vyos/facts/ospfv2/ospfv2.py +++ b/plugins/module_utils/network/vyos/facts/ospfv2/ospfv2.py @@ -11,6 +11,7 @@ based on the configuration. """ from __future__ import absolute_import, division, print_function + __metaclass__ = type from copy import deepcopy @@ -101,7 +102,8 @@ class Ospfv2Facts(object): config["passive_interface"] = self.parse_leaf_list(conf, "passive-interface") config["redistribute"] = self.parse_attrib_list(conf, "redistribute", "route_type") config["passive_interface_exclude"] = self.parse_leaf_list( - conf, "passive-interface-exclude" + conf, + "passive-interface-exclude", ) return config diff --git a/plugins/module_utils/network/vyos/facts/ospfv3/ospfv3.py b/plugins/module_utils/network/vyos/facts/ospfv3/ospfv3.py index d4b3e44..547ff79 100644 --- a/plugins/module_utils/network/vyos/facts/ospfv3/ospfv3.py +++ b/plugins/module_utils/network/vyos/facts/ospfv3/ospfv3.py @@ -11,6 +11,7 @@ based on the configuration. """ from __future__ import absolute_import, division, print_function + __metaclass__ = type from copy import deepcopy diff --git a/plugins/module_utils/network/vyos/facts/prefix_lists/prefix_lists.py b/plugins/module_utils/network/vyos/facts/prefix_lists/prefix_lists.py index 19004c8..17f63fb 100644 --- a/plugins/module_utils/network/vyos/facts/prefix_lists/prefix_lists.py +++ b/plugins/module_utils/network/vyos/facts/prefix_lists/prefix_lists.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -76,7 +77,7 @@ class Prefix_listsFacts(object): ansible_facts["ansible_network_resources"].pop("prefix_lists", None) params = utils.remove_empties( - prefix_lists_parser.validate_config(self.argument_spec, {"config": objs}, redact=True) + prefix_lists_parser.validate_config(self.argument_spec, {"config": objs}, redact=True), ) if params.get("config"): diff --git a/plugins/module_utils/network/vyos/facts/route_maps/route_maps.py b/plugins/module_utils/network/vyos/facts/route_maps/route_maps.py index 9f53264..2ad54e6 100644 --- a/plugins/module_utils/network/vyos/facts/route_maps/route_maps.py +++ b/plugins/module_utils/network/vyos/facts/route_maps/route_maps.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ diff --git a/plugins/module_utils/network/vyos/facts/snmp_server/snmp_server.py b/plugins/module_utils/network/vyos/facts/snmp_server/snmp_server.py index 54339f5..e70a15f 100644 --- a/plugins/module_utils/network/vyos/facts/snmp_server/snmp_server.py +++ b/plugins/module_utils/network/vyos/facts/snmp_server/snmp_server.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -104,7 +105,7 @@ class Snmp_serverFacts(object): ansible_facts["ansible_network_resources"].pop("snmp_server", None) params = utils.remove_empties( - snmp_server_parser.validate_config(self.argument_spec, {"config": objs}, redact=True) + snmp_server_parser.validate_config(self.argument_spec, {"config": objs}, redact=True), ) facts["snmp_server"] = params.get("config", {}) diff --git a/plugins/module_utils/network/vyos/facts/static_routes/static_routes.py b/plugins/module_utils/network/vyos/facts/static_routes/static_routes.py index 019706b..b8ffa30 100644 --- a/plugins/module_utils/network/vyos/facts/static_routes/static_routes.py +++ b/plugins/module_utils/network/vyos/facts/static_routes/static_routes.py @@ -12,6 +12,7 @@ based on the configuration. from __future__ import absolute_import, division, print_function + __metaclass__ = type from copy import deepcopy from re import M, findall, search diff --git a/plugins/module_utils/network/vyos/rm_templates/bgp_address_family.py b/plugins/module_utils/network/vyos/rm_templates/bgp_address_family.py index b1bb27c..c996a74 100644 --- a/plugins/module_utils/network/vyos/rm_templates/bgp_address_family.py +++ b/plugins/module_utils/network/vyos/rm_templates/bgp_address_family.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -27,11 +28,11 @@ def _tmplt_bgp_af_aggregate_address(config_data): config_data = config_data["address_family"] if config_data["aggregate_address"].get("as_set"): command += afi + " aggregate-address {prefix} as-set".format( - **config_data["aggregate_address"] + **config_data["aggregate_address"], ) if config_data["aggregate_address"].get("summary_only"): command += afi + " aggregate-address {prefix} summary-only".format( - **config_data["aggregate_address"] + **config_data["aggregate_address"], ) return command @@ -42,7 +43,7 @@ def _tmplt_bgp_af_redistribute_metric(config_data): command = "protocols bgp {as_number} address-family ".format(**config_data) if config_data["address_family"]["redistribute"].get("metric"): command += afi + " redistribute {protocol} metric {metric}".format( - **config_data["address_family"]["redistribute"] + **config_data["address_family"]["redistribute"], ) return command @@ -53,7 +54,7 @@ def _tmplt_bgp_af_redistribute_route_map(config_data): command = "protocols bgp {as_number} address-family ".format(**config_data) if config_data["address_family"]["redistribute"].get("route_map"): command += afi + " redistribute {protocol} route-map {route_map}".format( - **config_data["address_family"]["redistribute"] + **config_data["address_family"]["redistribute"], ) return command @@ -64,7 +65,7 @@ def _tmplt_bgp_af_redistribute_table(config_data): command = "protocols bgp {as_number} address-family ".format(**config_data) if config_data["address_family"]["redistribute"].get("table"): command += afi + " table {table}".format( - **config_data["address_family"]["redistribute"] + **config_data["address_family"]["redistribute"], ) return command @@ -85,7 +86,7 @@ def _tmplt_bgp_af_neighbor_distribute_list(config_data): config_data = config_data["neighbors"]["address_family"] for list_el in config_data["distribute_list"]: command.append( - cmd + afi + " distribute-list " + list_el["action"] + " " + str(list_el["acl"]) + cmd + afi + " distribute-list " + list_el["action"] + " " + str(list_el["acl"]), ) return command @@ -98,7 +99,7 @@ def _tmplt_bgp_af_neighbor_route_map(config_data): config_data = config_data["neighbors"]["address_family"] for list_el in config_data["route_map"]: command.append( - cmd + afi + " route-map " + list_el["action"] + " " + str(list_el["route_map"]) + cmd + afi + " route-map " + list_el["action"] + " " + str(list_el["route_map"]), ) return command @@ -111,7 +112,7 @@ def _tmplt_bgp_af_neighbor_prefix_list(config_data): config_data = config_data["neighbors"]["address_family"] for list_el in config_data["prefix_list"]: command.append( - cmd + afi + " prefix-list " + list_el["action"] + " " + str(list_el["prefix_list"]) + cmd + afi + " prefix-list " + list_el["action"] + " " + str(list_el["prefix_list"]), ) return command @@ -124,7 +125,7 @@ def _tmplt_bgp_af_neighbor_filter_list(config_data): config_data = config_data["neighbors"]["address_family"] for list_el in config_data["filter_list"]: command.append( - cmd + afi + " filter-list " + list_el["action"] + " " + str(list_el["path_list"]) + cmd + afi + " filter-list " + list_el["action"] + " " + str(list_el["path_list"]), ) return command @@ -237,7 +238,10 @@ class Bgp_address_familyTemplate(NetworkTemplate): def __init__(self, lines=None, module=None): prefix = {"set": "set", "remove": "delete"} super(Bgp_address_familyTemplate, self).__init__( - lines=lines, tmplt=self, prefix=prefix, module=module + lines=lines, + tmplt=self, + prefix=prefix, + module=module, ) # fmt: off @@ -262,9 +266,9 @@ class Bgp_address_familyTemplate(NetworkTemplate): "address_family": { "{{ afi }}": { "afi": "{{ afi }}", - } - } - } + }, + }, + }, }, { "name": "aggregate_address", @@ -296,12 +300,12 @@ class Bgp_address_familyTemplate(NetworkTemplate): { "prefix": "{{ address }}", "as_set": "{{ True if as_set is defined }}", - "summary_only": "{{ True if summary_only is defined }}" - } - ] - } - } - } + "summary_only": "{{ True if summary_only is defined }}", + }, + ], + }, + }, + }, }, { "name": "network.backdoor", @@ -330,12 +334,12 @@ class Bgp_address_familyTemplate(NetworkTemplate): "networks": [ { "prefix": "{{ address }}", - "backdoor": "{{ True }}" - } - ] - } - } - } + "backdoor": "{{ True }}", + }, + ], + }, + }, + }, }, { "name": "network.path_limit", @@ -366,12 +370,12 @@ class Bgp_address_familyTemplate(NetworkTemplate): "networks": [ { "prefix": "{{ address }}", - "path_limit": "{{ limit|int }}" - } - ] - } - } - } + "path_limit": "{{ limit|int }}", + }, + ], + }, + }, + }, }, { "name": "network.route_map", @@ -402,12 +406,12 @@ class Bgp_address_familyTemplate(NetworkTemplate): "networks": [ { "prefix": "{{ address }}", - "route_map": "{{ map }}" - } - ] - } - } - } + "route_map": "{{ map }}", + }, + ], + }, + }, + }, }, { "name": "redistribute.metric", @@ -437,12 +441,12 @@ class Bgp_address_familyTemplate(NetworkTemplate): "redistribute": [ { "protocol": "{{ proto }}", - "metric": "{{ val|int }}" - } - ] - } - } - } + "metric": "{{ val|int }}", + }, + ], + }, + }, + }, }, { "name": "redistribute.route_map", @@ -472,12 +476,12 @@ class Bgp_address_familyTemplate(NetworkTemplate): "redistribute": [ { "protocol": "{{ proto }}", - "route_map": "{{ map }}" - } - ] - } - } - } + "route_map": "{{ map }}", + }, + ], + }, + }, + }, }, { "name": "redistribute.table", @@ -505,12 +509,12 @@ class Bgp_address_familyTemplate(NetworkTemplate): "afi": "{{ afi }}", "redistribute": [ { - "table": "{{ tab }}" - } - ] - } - } - } + "table": "{{ tab }}", + }, + ], + }, + }, + }, }, { "name": "neighbors", @@ -533,9 +537,9 @@ class Bgp_address_familyTemplate(NetworkTemplate): "neighbors": { "{{ address }}": { "neighbor_address": "{{ address }}", - } - } - } + }, + }, + }, }, { "name": "neighbors.address_family", @@ -562,11 +566,11 @@ class Bgp_address_familyTemplate(NetworkTemplate): "address_family": { "{{ afi }}": { "afi": "{{ afi }}", - } - } - } - } - } + }, + }, + }, + }, + }, }, { "name": "neighbors.allowas_in", @@ -597,12 +601,12 @@ class Bgp_address_familyTemplate(NetworkTemplate): "address_family": { "{{ afi }}": { "afi": "{{ afi }}", - "allowas_in": "{{ num }}" - } - } - } - } - } + "allowas_in": "{{ num }}", + }, + }, + }, + }, + }, }, { "name": "neighbors.as_override", @@ -631,12 +635,12 @@ class Bgp_address_familyTemplate(NetworkTemplate): "address_family": { "{{ afi }}": { "afi": "{{ afi }}", - "as_override": "{{ True }}" - } - } - } - } - } + "as_override": "{{ True }}", + }, + }, + }, + }, + }, }, { "name": "neighbors.attribute_unchanged.as_path", @@ -667,13 +671,13 @@ class Bgp_address_familyTemplate(NetworkTemplate): "{{ afi }}": { "afi": "{{ afi }}", "attribute_unchanged": { - "as_path": "{{ True }}" - } - } - } - } - } - } + "as_path": "{{ True }}", + }, + }, + }, + }, + }, + }, }, { "name": "neighbors.attribute_unchanged.med", @@ -704,13 +708,13 @@ class Bgp_address_familyTemplate(NetworkTemplate): "{{ afi }}": { "afi": "{{ afi }}", "attribute_unchanged": { - "med": "{{ True }}" - } - } - } - } - } - } + "med": "{{ True }}", + }, + }, + }, + }, + }, + }, }, { "name": "neighbors.attribute_unchanged.next_hop", @@ -741,13 +745,13 @@ class Bgp_address_familyTemplate(NetworkTemplate): "{{ afi }}": { "afi": "{{ afi }}", "attribute_unchanged": { - "next_hop": "{{ True }}" - } - } - } - } - } - } + "next_hop": "{{ True }}", + }, + }, + }, + }, + }, + }, }, { "name": "neighbors.capability_dynamic", @@ -778,13 +782,13 @@ class Bgp_address_familyTemplate(NetworkTemplate): "{{ afi }}": { "afi": "{{ afi }}", "capability": { - "dynamic": "{{ true }}" - } - } - } - } - } - } + "dynamic": "{{ true }}", + }, + }, + }, + }, + }, + }, }, { "name": "neighbors.capability_orf", @@ -816,13 +820,13 @@ class Bgp_address_familyTemplate(NetworkTemplate): "{{ afi }}": { "afi": "{{ afi }}", "capability": { - "orf": "{{ orf }}" - } - } - } - } - } - } + "orf": "{{ orf }}", + }, + }, + }, + }, + }, + }, }, { "name": "neighbors.default_originate", @@ -853,12 +857,12 @@ class Bgp_address_familyTemplate(NetworkTemplate): "address_family": { "{{ afi }}": { "afi": "{{ afi }}", - "default_originate": "{{ map }}" - } - } - } - } - } + "default_originate": "{{ map }}", + }, + }, + }, + }, + }, }, { "name": "neighbors.distribute_list", @@ -892,14 +896,14 @@ class Bgp_address_familyTemplate(NetworkTemplate): "distribute_list": [ { "action": "{{ action }}", - "acl": "{{ list }}" - } - ] - } - } - } - } - } + "acl": "{{ list }}", + }, + ], + }, + }, + }, + }, + }, }, { "name": "neighbors.prefix_list", @@ -933,14 +937,14 @@ class Bgp_address_familyTemplate(NetworkTemplate): "prefix_list": [ { "action": "{{ action }}", - "prefix_list": "{{ list }}" - } - ] - } - } - } - } - } + "prefix_list": "{{ list }}", + }, + ], + }, + }, + }, + }, + }, }, { "name": "neighbors.filter_list", @@ -974,14 +978,14 @@ class Bgp_address_familyTemplate(NetworkTemplate): "filter_list": [ { "action": "{{ action }}", - "path_list": "{{ list }}" - } - ] - } - } - } - } - } + "path_list": "{{ list }}", + }, + ], + }, + }, + }, + }, + }, }, { "name": "neighbors.maximum_prefix", @@ -1011,12 +1015,12 @@ class Bgp_address_familyTemplate(NetworkTemplate): "address_family": { "{{ afi }}": { "afi": "{{ afi }}", - "maximum_prefix": "{{ num }}" - } - } - } - } - } + "maximum_prefix": "{{ num }}", + }, + }, + }, + }, + }, }, { "name": "neighbors.nexthop_local", @@ -1045,12 +1049,12 @@ class Bgp_address_familyTemplate(NetworkTemplate): "address_family": { "{{ afi }}": { "afi": "{{ afi }}", - "nexthop_local": "{{ True }}" - } - } - } - } - } + "nexthop_local": "{{ True }}", + }, + }, + }, + }, + }, }, { "name": "neighbors.nexthop_self", @@ -1079,12 +1083,12 @@ class Bgp_address_familyTemplate(NetworkTemplate): "address_family": { "{{ afi }}": { "afi": "{{ afi }}", - "nexthop_self": "{{ True }}" - } - } - } - } - } + "nexthop_self": "{{ True }}", + }, + }, + }, + }, + }, }, { "name": "neighbors.peer_group", @@ -1114,12 +1118,12 @@ class Bgp_address_familyTemplate(NetworkTemplate): "address_family": { "{{ afi }}": { "afi": "{{ afi }}", - "peer_group": "{{ name }}" - } - } - } - } - } + "peer_group": "{{ name }}", + }, + }, + }, + }, + }, }, { "name": "neighbors.remove_private_as", @@ -1148,12 +1152,12 @@ class Bgp_address_familyTemplate(NetworkTemplate): "address_family": { "{{ afi }}": { "afi": "{{ afi }}", - "remove_private_as": "{{ True }}" - } - } - } - } - } + "remove_private_as": "{{ True }}", + }, + }, + }, + }, + }, }, { "name": "neighbors.route_map", @@ -1187,14 +1191,14 @@ class Bgp_address_familyTemplate(NetworkTemplate): "route_map": [ { "action": "{{ action }}", - "route_map": "{{ map }}" - } - ] - } - } - } - } - } + "route_map": "{{ map }}", + }, + ], + }, + }, + }, + }, + }, }, { "name": "neighbors.route_reflector_client", @@ -1223,12 +1227,12 @@ class Bgp_address_familyTemplate(NetworkTemplate): "address_family": { "{{ afi }}": { "afi": "{{ afi }}", - "route_reflector_client": "{{ True }}" - } - } - } - } - } + "route_reflector_client": "{{ True }}", + }, + }, + }, + }, + }, }, { "name": "neighbors.route_server_client", @@ -1257,12 +1261,12 @@ class Bgp_address_familyTemplate(NetworkTemplate): "address_family": { "{{ afi }}": { "afi": "{{ afi }}", - "route_server_client": "{{ True }}" - } - } - } - } - } + "route_server_client": "{{ True }}", + }, + }, + }, + }, + }, }, { "name": "neighbors.soft_reconfiguration", @@ -1292,12 +1296,12 @@ class Bgp_address_familyTemplate(NetworkTemplate): "address_family": { "{{ afi }}": { "afi": "{{ afi }}", - "soft_reconfiguration": "{{ True }}" - } - } - } - } - } + "soft_reconfiguration": "{{ True }}", + }, + }, + }, + }, + }, }, { "name": "neighbors.unsuppress_map", @@ -1327,12 +1331,12 @@ class Bgp_address_familyTemplate(NetworkTemplate): "address_family": { "{{ afi }}": { "afi": "{{ afi }}", - "unsuppress_map": "{{ map }}" - } - } - } - } - } + "unsuppress_map": "{{ map }}", + }, + }, + }, + }, + }, }, { "name": "neighbors.weight", @@ -1362,12 +1366,12 @@ class Bgp_address_familyTemplate(NetworkTemplate): "address_family": { "{{ afi }}": { "afi": "{{ afi }}", - "weight": "{{ num }}" - } - } - } - } - } + "weight": "{{ num }}", + }, + }, + }, + }, + }, }, ] # fmt: on diff --git a/plugins/module_utils/network/vyos/rm_templates/bgp_global.py b/plugins/module_utils/network/vyos/rm_templates/bgp_global.py index 69cccce..bd95e08 100644 --- a/plugins/module_utils/network/vyos/rm_templates/bgp_global.py +++ b/plugins/module_utils/network/vyos/rm_templates/bgp_global.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -30,7 +31,7 @@ def _tmplt_bgp_params_confederation(config_data): "protocols bgp {as_number} parameters confederation ".format(**config_data) + k + " " - + str(v) + + str(v), ) return command @@ -43,7 +44,7 @@ def _tmplt_bgp_maximum_paths(config_data): "protocols bgp {as_number} maximum-paths ".format(**config_data) + list_el["path"] + " " - + str(list_el["count"]) + + str(list_el["count"]), ) return command @@ -88,7 +89,7 @@ def _tmplt_bgp_neighbor_timers(config_data): + " timers " + k + " " - + str(v) + + str(v), ) return command @@ -98,7 +99,7 @@ def _tmplt_bgp_timers(config_data): command = [] for k, v in iteritems(config_data["timers"]): command.append( - "protocols bgp {as_number} ".format(**config_data) + "timers " + k + " " + str(v) + "protocols bgp {as_number} ".format(**config_data) + "timers " + k + " " + str(v), ) return command @@ -106,21 +107,21 @@ def _tmplt_bgp_timers(config_data): def _tmplt_bgp_neighbor_attribute_unchanged_as_path(config_data): command = "protocols bgp {as_number} ".format( - **config_data + **config_data, ) + "neighbor {address} attribute-unchanged as-path".format(**config_data["neighbor"]) return command def _tmplt_bgp_neighbor_attribute_unchanged_med(config_data): command = "protocols bgp {as_number} ".format( - **config_data + **config_data, ) + "neighbor {address} attribute-unchanged med".format(**config_data["neighbor"]) return command def _tmplt_bgp_neighbor_attribute_unchanged_next_hop(config_data): command = "protocols bgp {as_number} ".format( - **config_data + **config_data, ) + "neighbor {address} attribute-unchanged next-hop".format(**config_data["neighbor"]) return command @@ -133,7 +134,7 @@ def _tmplt_bgp_neighbor_distribute_list(config_data): + "neighbor {address} distribute-list ".format(**config_data["neighbor"]) + list_el["action"] + " " - + str(list_el["acl"]) + + str(list_el["acl"]), ) return command @@ -146,7 +147,7 @@ def _tmplt_bgp_neighbor_route_map(config_data): + "neighbor {address} route-map ".format(**config_data["neighbor"]) + list_el["action"] + " " - + str(list_el["route_map"]) + + str(list_el["route_map"]), ) return command @@ -159,7 +160,7 @@ def _tmplt_bgp_neighbor_prefix_list(config_data): + "neighbor {address} prefix-list ".format(**config_data["neighbor"]) + list_el["action"] + " " - + str(list_el["prefix_list"]) + + str(list_el["prefix_list"]), ) return command @@ -172,7 +173,7 @@ def _tmplt_bgp_neighbor_filter_list(config_data): + "neighbor {address} filter-list ".format(**config_data["neighbor"]) + list_el["action"] + " " - + str(list_el["path_list"]) + + str(list_el["path_list"]), ) return command @@ -191,7 +192,10 @@ class Bgp_globalTemplate(NetworkTemplate): def __init__(self, lines=None, module=None): prefix = {"set": "set", "remove": "delete"} super(Bgp_globalTemplate, self).__init__( - lines=lines, tmplt=self, prefix=prefix, module=module + lines=lines, + tmplt=self, + prefix=prefix, + module=module, ) # fmt: off @@ -211,7 +215,7 @@ class Bgp_globalTemplate(NetworkTemplate): "compval": "as_number", "result": { "as_number": "{{ as_num }}", - } + }, }, { "name": "aggregate_address", @@ -237,10 +241,10 @@ class Bgp_globalTemplate(NetworkTemplate): { "prefix": "{{ address }}", "as_set": "{{ True if as_set is defined }}", - "summary_only": "{{ True if summary_only is defined }}" - } - ] - } + "summary_only": "{{ True if summary_only is defined }}", + }, + ], + }, }, { "name": "maximum_paths", @@ -265,9 +269,9 @@ class Bgp_globalTemplate(NetworkTemplate): { "path": "{{ path }}", "count": "{{ count }}", - } - ] - } + }, + ], + }, }, { "name": "neighbor.advertisement_interval", @@ -292,10 +296,10 @@ class Bgp_globalTemplate(NetworkTemplate): "neighbor": { "{{ address }}": { "address": "{{ address }}", - "advertisement_interval": "{{ interval }}" - } - } - } + "advertisement_interval": "{{ interval }}", + }, + }, + }, }, { "name": "neighbor.allowas_in", @@ -320,10 +324,10 @@ class Bgp_globalTemplate(NetworkTemplate): "neighbor": { "{{ address }}": { "address": "{{ address }}", - "allowas_in": "{{ count }}" - } - } - } + "allowas_in": "{{ count }}", + }, + }, + }, }, { "name": "neighbor.as_override", @@ -346,10 +350,10 @@ class Bgp_globalTemplate(NetworkTemplate): "neighbor": { "{{ address }}": { "address": "{{ address }}", - "as_override": "{{ True }}" - } - } - } + "as_override": "{{ True }}", + }, + }, + }, }, { "name": "neighbor.attribute_unchanged.as_path", @@ -374,11 +378,11 @@ class Bgp_globalTemplate(NetworkTemplate): "{{ address }}": { "address": "{{ address }}", "attribute_unchanged": { - "{{ 'as_path' }}": "{{ True }}" - } - } - } - } + "{{ 'as_path' }}": "{{ True }}", + }, + }, + }, + }, }, { "name": "neighbor.attribute_unchanged.med", @@ -403,11 +407,11 @@ class Bgp_globalTemplate(NetworkTemplate): "{{ address }}": { "address": "{{ address }}", "attribute_unchanged": { - "{{ 'med' }}": "{{ True }}" - } - } - } - } + "{{ 'med' }}": "{{ True }}", + }, + }, + }, + }, }, { "name": "neighbor.attribute_unchanged.next_hop", @@ -432,11 +436,11 @@ class Bgp_globalTemplate(NetworkTemplate): "{{ address }}": { "address": "{{ address }}", "attribute_unchanged": { - "{{ 'next_hop' }}": "{{ True }}" - } - } - } - } + "{{ 'next_hop' }}": "{{ True }}", + }, + }, + }, + }, }, { "name": "neighbor.capability_dynamic", @@ -461,11 +465,11 @@ class Bgp_globalTemplate(NetworkTemplate): "{{ address }}": { "address": "{{ address }}", "capability": { - "dynamic": "{{ True if dynamic is defined}}" - } - } - } - } + "dynamic": "{{ True if dynamic is defined}}", + }, + }, + }, + }, }, { "name": "neighbor.capability_orf", @@ -492,11 +496,11 @@ class Bgp_globalTemplate(NetworkTemplate): "{{ address }}": { "address": "{{ address }}", "capability": { - "orf": "{{ orf }}" - } - } - } - } + "orf": "{{ orf }}", + }, + }, + }, + }, }, { "name": "neighbor.default_originate", @@ -521,10 +525,10 @@ class Bgp_globalTemplate(NetworkTemplate): "neighbor": { "{{ address }}": { "address": "{{ address }}", - "default_originate": "{{ map }}" - } - } - } + "default_originate": "{{ map }}", + }, + }, + }, }, { "name": "neighbor.description", @@ -548,10 +552,10 @@ class Bgp_globalTemplate(NetworkTemplate): "neighbor": { "{{ address }}": { "address": "{{ address }}", - "description": "{{ desc }}" - } - } - } + "description": "{{ desc }}", + }, + }, + }, }, { "name": "neighbor.disable_capability_negotiation", @@ -574,10 +578,10 @@ class Bgp_globalTemplate(NetworkTemplate): "neighbor": { "{{ address }}": { "address": "{{ address }}", - "disable_capability_negotiation": "{{ True }}" - } - } - } + "disable_capability_negotiation": "{{ True }}", + }, + }, + }, }, { "name": "neighbor.disable_connected_check", @@ -600,10 +604,10 @@ class Bgp_globalTemplate(NetworkTemplate): "neighbor": { "{{ address }}": { "address": "{{ address }}", - "disable_connected_check": "{{ True }}" - } - } - } + "disable_connected_check": "{{ True }}", + }, + }, + }, }, { "name": "neighbor.disable_send_community", @@ -627,10 +631,10 @@ class Bgp_globalTemplate(NetworkTemplate): "neighbor": { "{{ address }}": { "address": "{{ address }}", - "disable_send_community": "{{ comm }}" - } - } - } + "disable_send_community": "{{ comm }}", + }, + }, + }, }, { "name": "neighbor.distribute_list", @@ -658,12 +662,12 @@ class Bgp_globalTemplate(NetworkTemplate): "distribute_list": [ { "action": "{{ action }}", - "acl": "{{ list }}" - } - ] - } - } - } + "acl": "{{ list }}", + }, + ], + }, + }, + }, }, { "name": "neighbor.ebgp_multihop", @@ -687,10 +691,10 @@ class Bgp_globalTemplate(NetworkTemplate): "neighbor": { "{{ address }}": { "address": "{{ address }}", - "ebgp_multihop": "{{ hop|int }}" - } - } - } + "ebgp_multihop": "{{ hop|int }}", + }, + }, + }, }, { "name": "neighbor.filter_list", @@ -718,12 +722,12 @@ class Bgp_globalTemplate(NetworkTemplate): "filter_list": [ { "action": "{{ action }}", - "path_list": "{{ list }}" - } - ] - } - } - } + "path_list": "{{ list }}", + }, + ], + }, + }, + }, }, { "name": "neighbor.local_as", @@ -748,10 +752,10 @@ class Bgp_globalTemplate(NetworkTemplate): "neighbor": { "{{ address }}": { "address": "{{ address }}", - "local_as": "{{ as }}" - } - } - } + "local_as": "{{ as }}", + }, + }, + }, }, { "name": "neighbor.maximum_prefix", @@ -775,10 +779,10 @@ class Bgp_globalTemplate(NetworkTemplate): "neighbor": { "{{ address }}": { "address": "{{ address }}", - "maximum_prefix": "{{ num }}" - } - } - } + "maximum_prefix": "{{ num }}", + }, + }, + }, }, { "name": "neighbor.nexthop_self", @@ -801,10 +805,10 @@ class Bgp_globalTemplate(NetworkTemplate): "neighbor": { "{{ address }}": { "address": "{{ address }}", - "nexthop_self": "{{ True }}" - } - } - } + "nexthop_self": "{{ True }}", + }, + }, + }, }, { "name": "neighbor.override_capability", @@ -827,10 +831,10 @@ class Bgp_globalTemplate(NetworkTemplate): "neighbor": { "{{ address }}": { "address": "{{ address }}", - "override_capability": "{{ True }}" - } - } - } + "override_capability": "{{ True }}", + }, + }, + }, }, { "name": "neighbor.passive", @@ -853,10 +857,10 @@ class Bgp_globalTemplate(NetworkTemplate): "neighbor": { "{{ address }}": { "address": "{{ address }}", - "passive": "{{ True }}" - } - } - } + "passive": "{{ True }}", + }, + }, + }, }, { "name": "neighbor.password", @@ -880,10 +884,10 @@ class Bgp_globalTemplate(NetworkTemplate): "neighbor": { "{{ address }}": { "address": "{{ address }}", - "password": "{{ pwd }}" - } - } - } + "password": "{{ pwd }}", + }, + }, + }, }, { "name": "neighbor.peer_group_name", @@ -907,10 +911,10 @@ class Bgp_globalTemplate(NetworkTemplate): "neighbor": { "{{ address }}": { "address": "{{ address }}", - "peer_group_name": "{{ name }}" - } - } - } + "peer_group_name": "{{ name }}", + }, + }, + }, }, { "name": "neighbor.port", @@ -934,10 +938,10 @@ class Bgp_globalTemplate(NetworkTemplate): "neighbor": { "{{ address }}": { "address": "{{ address }}", - "port": "{{ num|int }}" - } - } - } + "port": "{{ num|int }}", + }, + }, + }, }, { "name": "neighbor.prefix_list", @@ -965,12 +969,12 @@ class Bgp_globalTemplate(NetworkTemplate): "prefix_list": [ { "action": "{{ action }}", - "prefix_list": "{{ list }}" - } - ] - } - } - } + "prefix_list": "{{ list }}", + }, + ], + }, + }, + }, }, { "name": "neighbor.remote_as", @@ -994,10 +998,10 @@ class Bgp_globalTemplate(NetworkTemplate): "neighbor": { "{{ address }}": { "address": "{{ address }}", - "remote_as": "{{ num|int }}" - } - } - } + "remote_as": "{{ num|int }}", + }, + }, + }, }, { "name": "neighbor.remove_private_as", @@ -1020,10 +1024,10 @@ class Bgp_globalTemplate(NetworkTemplate): "neighbor": { "{{ address }}": { "address": "{{ address }}", - "remove_private_as": "{{ True }}" - } - } - } + "remove_private_as": "{{ True }}", + }, + }, + }, }, { "name": "neighbor.route_map", @@ -1051,12 +1055,12 @@ class Bgp_globalTemplate(NetworkTemplate): "route_map": [ { "action": "{{ action }}", - "route_map": "{{ map }}" - } - ] - } - } - } + "route_map": "{{ map }}", + }, + ], + }, + }, + }, }, { "name": "neighbor.route_reflector_client", @@ -1079,10 +1083,10 @@ class Bgp_globalTemplate(NetworkTemplate): "neighbor": { "{{ address }}": { "address": "{{ address }}", - "route_reflector_client": "{{ True }}" - } - } - } + "route_reflector_client": "{{ True }}", + }, + }, + }, }, { "name": "neighbor.route_server_client", @@ -1105,10 +1109,10 @@ class Bgp_globalTemplate(NetworkTemplate): "neighbor": { "{{ address }}": { "address": "{{ address }}", - "route_server_client": "{{ True }}" - } - } - } + "route_server_client": "{{ True }}", + }, + }, + }, }, { "name": "neighbor.shutdown", @@ -1131,10 +1135,10 @@ class Bgp_globalTemplate(NetworkTemplate): "neighbor": { "{{ address }}": { "address": "{{ address }}", - "shutdown": "{{ True }}" - } - } - } + "shutdown": "{{ True }}", + }, + }, + }, }, { "name": "neighbor.soft_reconfiguration", @@ -1158,10 +1162,10 @@ class Bgp_globalTemplate(NetworkTemplate): "neighbor": { "{{ address }}": { "address": "{{ address }}", - "soft_reconfiguration": "{{ True }}" - } - } - } + "soft_reconfiguration": "{{ True }}", + }, + }, + }, }, { "name": "neighbor.strict_capability_match", @@ -1184,10 +1188,10 @@ class Bgp_globalTemplate(NetworkTemplate): "neighbor": { "{{ address }}": { "address": "{{ address }}", - "strict_capability_match": "{{ True }}" - } - } - } + "strict_capability_match": "{{ True }}", + }, + }, + }, }, { "name": "neighbor.unsuppress_map", @@ -1211,10 +1215,10 @@ class Bgp_globalTemplate(NetworkTemplate): "neighbor": { "{{ address }}": { "address": "{{ address }}", - "unsuppress_map": "{{ map }}" - } - } - } + "unsuppress_map": "{{ map }}", + }, + }, + }, }, { "name": "neighbor.update_source", @@ -1238,10 +1242,10 @@ class Bgp_globalTemplate(NetworkTemplate): "neighbor": { "{{ address }}": { "address": "{{ address }}", - "update_source": "{{ src }}" - } - } - } + "update_source": "{{ src }}", + }, + }, + }, }, { "name": "neighbor.weight", @@ -1265,10 +1269,10 @@ class Bgp_globalTemplate(NetworkTemplate): "neighbor": { "{{ address }}": { "address": "{{ address }}", - "weight": "{{ num }}" - } - } - } + "weight": "{{ num }}", + }, + }, + }, }, { "name": "neighbor.ttl_security", @@ -1292,10 +1296,10 @@ class Bgp_globalTemplate(NetworkTemplate): "neighbor": { "{{ address }}": { "address": "{{ address }}", - "ttl_security": "{{ ttl|int }}" - } - } - } + "ttl_security": "{{ ttl|int }}", + }, + }, + }, }, { "name": "neighbor.timers", @@ -1322,11 +1326,11 @@ class Bgp_globalTemplate(NetworkTemplate): "{{ address }}": { "address": "{{ address }}", "timers": { - "{{ type }}": "{{ sec }}" - } - } - } - } + "{{ type }}": "{{ sec }}", + }, + }, + }, + }, }, { "name": "network.backdoor", @@ -1350,10 +1354,10 @@ class Bgp_globalTemplate(NetworkTemplate): "network": [ { "address": "{{ address }}", - "backdoor": "{{ True }}" - } - ] - } + "backdoor": "{{ True }}", + }, + ], + }, }, { "name": "network.route_map", @@ -1378,10 +1382,10 @@ class Bgp_globalTemplate(NetworkTemplate): "network": [ { "address": "{{ address }}", - "route_map": "{{ map }}" - } - ] - } + "route_map": "{{ map }}", + }, + ], + }, }, { "name": "redistribute.metric", @@ -1406,10 +1410,10 @@ class Bgp_globalTemplate(NetworkTemplate): "redistribute": [ { "protocol": "{{ proto }}", - "metric": "{{ val|int }}" - } - ] - } + "metric": "{{ val|int }}", + }, + ], + }, }, { "name": "redistribute.route_map", @@ -1434,10 +1438,10 @@ class Bgp_globalTemplate(NetworkTemplate): "redistribute": [ { "protocol": "{{ proto }}", - "route_map": "{{ val }}" - } - ] - } + "route_map": "{{ val }}", + }, + ], + }, }, { "name": "timers", @@ -1460,8 +1464,8 @@ class Bgp_globalTemplate(NetworkTemplate): "as_number": "{{ as_num }}", "timers": { "{{ type }}": "{{ val }}", - } - } + }, + }, }, { "name": "bgp_params.always_compare_med", @@ -1482,8 +1486,8 @@ class Bgp_globalTemplate(NetworkTemplate): "as_number": "{{ as_num }}", "bgp_params": { "always_compare_med": "{{ True }}", - } - } + }, + }, }, { "name": "bgp_params.bestpath.as_path", @@ -1507,9 +1511,9 @@ class Bgp_globalTemplate(NetworkTemplate): "bgp_params": { "bestpath": { "as_path": "{{ path }}", - } - } - } + }, + }, + }, }, { "name": "bgp_params.bestpath.compare_routerid", @@ -1532,9 +1536,9 @@ class Bgp_globalTemplate(NetworkTemplate): "bgp_params": { "bestpath": { "compare_routerid": "{{ True }}", - } - } - } + }, + }, + }, }, { "name": "bgp_params.bestpath.med", @@ -1558,9 +1562,9 @@ class Bgp_globalTemplate(NetworkTemplate): "bgp_params": { "bestpath": { "med": "{{ path }}", - } - } - } + }, + }, + }, }, { "name": "bgp_params.cluster_id", @@ -1582,8 +1586,8 @@ class Bgp_globalTemplate(NetworkTemplate): "as_number": "{{ as_num }}", "bgp_params": { "cluster_id": "{{ id }}", - } - } + }, + }, }, { "name": "bgp_params.confederation", @@ -1608,11 +1612,11 @@ class Bgp_globalTemplate(NetworkTemplate): "confederation": [ { "peers": "{{ val if type == 'peers' }}", - "identifier": "{{ val if type == 'identifier' }}" - } - ] - } - } + "identifier": "{{ val if type == 'identifier' }}", + }, + ], + }, + }, }, { "name": "bgp_params.dampening_half_life", @@ -1635,10 +1639,10 @@ class Bgp_globalTemplate(NetworkTemplate): "as_number": "{{ as_num }}", "bgp_params": { "dampening": { - "half_life": "{{ val }}" - } - } - } + "half_life": "{{ val }}", + }, + }, + }, }, { "name": "bgp_params.dampening_max_suppress_time", @@ -1661,10 +1665,10 @@ class Bgp_globalTemplate(NetworkTemplate): "as_number": "{{ as_num }}", "bgp_params": { "dampening": { - "max_suppress_time": "{{ val }}" - } - } - } + "max_suppress_time": "{{ val }}", + }, + }, + }, }, { "name": "bgp_params.dampening_re_use", @@ -1687,10 +1691,10 @@ class Bgp_globalTemplate(NetworkTemplate): "as_number": "{{ as_num }}", "bgp_params": { "dampening": { - "re_use": "{{ val }}" - } - } - } + "re_use": "{{ val }}", + }, + }, + }, }, { "name": "bgp_params.dampening_start_suppress_time", @@ -1713,10 +1717,10 @@ class Bgp_globalTemplate(NetworkTemplate): "as_number": "{{ as_num }}", "bgp_params": { "dampening": { - "start_suppress_time": "{{ val }}" - } - } - } + "start_suppress_time": "{{ val }}", + }, + }, + }, }, { "name": "bgp_params.default", @@ -1741,10 +1745,10 @@ class Bgp_globalTemplate(NetworkTemplate): "bgp_params": { "default": { "no_ipv4_unicast": "{{ True if no_ipv4_unicast is defined }}", - "local_pref": "{{ local_pref.split(" " )[1] if local_pref is defined }}" - } - } - } + "local_pref": "{{ local_pref.split(" " )[1] if local_pref is defined }}", + }, + }, + }, }, { "name": "bgp_params.deterministic_med", @@ -1765,8 +1769,8 @@ class Bgp_globalTemplate(NetworkTemplate): "as_number": "{{ as_num }}", "bgp_params": { "deterministic_med": "{{ True }}", - } - } + }, + }, }, { "name": "bgp_params.disbale_network_import_check", @@ -1787,8 +1791,8 @@ class Bgp_globalTemplate(NetworkTemplate): "as_number": "{{ as_num }}", "bgp_params": { "disable_network_import_check": "{{ True }}", - } - } + }, + }, }, { "name": "bgp_params.distance.prefix", @@ -1815,11 +1819,11 @@ class Bgp_globalTemplate(NetworkTemplate): "distance": [ { "prefix": "{{ prefix }}", - "value": "{{ val }}" - } - ] - } - } + "value": "{{ val }}", + }, + ], + }, + }, }, { "name": "bgp_params.distance.global", @@ -1845,11 +1849,11 @@ class Bgp_globalTemplate(NetworkTemplate): "distance": [ { "type": "{{ type }}", - "value": "{{ val }}" - } - ] - } - } + "value": "{{ val }}", + }, + ], + }, + }, }, { "name": "bgp_params.enforce_first_as", @@ -1870,8 +1874,8 @@ class Bgp_globalTemplate(NetworkTemplate): "as_number": "{{ as_num }}", "bgp_params": { "enforce_first_as": "{{ True }}", - } - } + }, + }, }, { "name": "bgp_params.graceful_restart", @@ -1893,8 +1897,8 @@ class Bgp_globalTemplate(NetworkTemplate): "as_number": "{{ as_num }}", "bgp_params": { "graceful_restart": "{{ val }}", - } - } + }, + }, }, { "name": "bgp_params.log_neighbor_changes", @@ -1915,8 +1919,8 @@ class Bgp_globalTemplate(NetworkTemplate): "as_number": "{{ as_num }}", "bgp_params": { "log_neighbor_changes": "{{ True }}", - } - } + }, + }, }, { "name": "bgp_params.no_client_to_client_reflection", @@ -1937,8 +1941,8 @@ class Bgp_globalTemplate(NetworkTemplate): "as_number": "{{ as_num }}", "bgp_params": { "no_client_to_client_reflection": "{{ True }}", - } - } + }, + }, }, { "name": "bgp_params.no_fast_external_failover", @@ -1959,8 +1963,8 @@ class Bgp_globalTemplate(NetworkTemplate): "as_number": "{{ as_num }}", "bgp_params": { "no_fast_external_failover": "{{ True }}", - } - } + }, + }, }, { "name": "bgp_params.routerid", @@ -1982,8 +1986,8 @@ class Bgp_globalTemplate(NetworkTemplate): "as_number": "{{ as_num }}", "bgp_params": { "router_id": "{{ id }}", - } - } + }, + }, }, { "name": "bgp_params.scan_time", @@ -2005,8 +2009,8 @@ class Bgp_globalTemplate(NetworkTemplate): "as_number": "{{ as_num }}", "bgp_params": { "scan_time": "{{ val }}", - } - } + }, + }, }, ] diff --git a/plugins/module_utils/network/vyos/rm_templates/hostname.py b/plugins/module_utils/network/vyos/rm_templates/hostname.py index 7352794..29ab00f 100644 --- a/plugins/module_utils/network/vyos/rm_templates/hostname.py +++ b/plugins/module_utils/network/vyos/rm_templates/hostname.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -25,7 +26,10 @@ class HostnameTemplate(NetworkTemplate): def __init__(self, lines=None, module=None): prefix = {"set": "set", "remove": "delete"} super(HostnameTemplate, self).__init__( - lines=lines, tmplt=self, prefix=prefix, module=module + lines=lines, + tmplt=self, + prefix=prefix, + module=module, ) # fmt: off @@ -38,11 +42,12 @@ class HostnameTemplate(NetworkTemplate): ^set\ssystem\shost-name \s+(?P<name>\S+) $""", - re.VERBOSE), + re.VERBOSE, + ), "setval": "system host-name {{ hostname }}", "result": { - "hostname": "{{ name }}" - } + "hostname": "{{ name }}", + }, }, ] # fmt: on diff --git a/plugins/module_utils/network/vyos/rm_templates/logging_global.py b/plugins/module_utils/network/vyos/rm_templates/logging_global.py index 82a4963..6c692cf 100644 --- a/plugins/module_utils/network/vyos/rm_templates/logging_global.py +++ b/plugins/module_utils/network/vyos/rm_templates/logging_global.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -66,7 +67,10 @@ class Logging_globalTemplate(NetworkTemplate): def __init__(self, lines=None, module=None): prefix = {"set": "set", "remove": "delete"} super(Logging_globalTemplate, self).__init__( - lines=lines, tmplt=self, prefix=prefix, module=module + lines=lines, + tmplt=self, + prefix=prefix, + module=module, ) # fmt: off @@ -77,13 +81,14 @@ class Logging_globalTemplate(NetworkTemplate): r""" ^set\ssystem (\s(?P<syslog>syslog)) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "system syslog", "result": { "syslog": { "state": "{{ 'enabled' if syslog is defined else 'disabled' }}", - } - } + }, + }, }, { "name": "console.facilities", @@ -92,17 +97,19 @@ class Logging_globalTemplate(NetworkTemplate): ^set\ssystem\ssyslog\sconsole\sfacility (\s(?P<facility>all|auth|authpriv|cron|daemon|kern|lpr|mail|mark|news|protocols|security|syslog|user|uucp|local[0-7]))? (\slevel\s(?P<level>'(emerg|alert|crit|err|warning|notice|info|debug|all)'))? - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": tmplt_params, "remval": "system syslog console facility {{ console.facilities.facility }}", "result": { "console": { - "facilities": [{ - "facility": "{{ facility }}", - "severity": "{{ level }}", - }, ] - } - } + "facilities": [ + { + "facility": "{{ facility }}", + "severity": "{{ level }}", + }, ], + }, + }, }, { "name": "console.state", @@ -110,13 +117,14 @@ class Logging_globalTemplate(NetworkTemplate): r""" ^set\ssystem\ssyslog (\s(?P<console>console)) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "system syslog console", "result": { "console": { "state": "{{ 'enabled' if console is defined else 'disabled' }}", - } - } + }, + }, }, { "name": "files.archive.state", @@ -125,7 +133,8 @@ class Logging_globalTemplate(NetworkTemplate): ^set\ssystem\ssyslog\sfile (\s(?P<path>\S+))? (\s(?P<archive>archive)) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "system syslog file {{ files.path }} archive", "result": { "files": { @@ -135,8 +144,8 @@ class Logging_globalTemplate(NetworkTemplate): "state": "{{ 'enabled' if archive is defined else 'disabled' }}", }, }, - } - } + }, + }, }, { "name": "files.archive.size", @@ -145,7 +154,8 @@ class Logging_globalTemplate(NetworkTemplate): ^set\ssystem\ssyslog\sfile (\s(?P<path>\S+))? (\sarchive\ssize\s(?P<size>'(\d+)'))? - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "system syslog file {{ files.path }} archive size {{ files.archive.size }}", "result": { "files": { @@ -155,8 +165,8 @@ class Logging_globalTemplate(NetworkTemplate): "size": "{{ size }}", }, }, - } - } + }, + }, }, { "name": "files.archive.file_num", @@ -165,7 +175,8 @@ class Logging_globalTemplate(NetworkTemplate): ^set\ssystem\ssyslog\sfile (\s(?P<path>\S+))? (\sarchive\sfile\s(?P<file_num>'(\d+)'))? - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "system syslog file {{ files.path }} archive file {{ files.archive.file_num }}", "result": { "files": { @@ -175,8 +186,8 @@ class Logging_globalTemplate(NetworkTemplate): "file_num": "{{ file_num }}", }, }, - } - } + }, + }, }, { "name": "files", @@ -186,20 +197,22 @@ class Logging_globalTemplate(NetworkTemplate): (\s(?P<path>\S+))? (\sfacility\s(?P<facility>all|auth|authpriv|cron|daemon|kern|lpr|mail|mark|news|protocols|security|syslog|user|uucp|local[0-7]))? (\slevel\s(?P<level>'(emerg|alert|crit|err|warning|notice|info|debug|all)'))? - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": tmplt_params, "remval": "system syslog file{{ (' ' + files.path) if files.path|d('') is defined else '' }}", "result": { "files": { "{{ path }}": { "path": "{{ path }}", - "facilities": [{ - "facility": "{{ facility }}", - "severity": "{{ level }}", - }, ] + "facilities": [ + { + "facility": "{{ facility }}", + "severity": "{{ level }}", + }, ], }, - } - } + }, + }, }, { "name": "global_params.state", @@ -207,13 +220,14 @@ class Logging_globalTemplate(NetworkTemplate): r""" ^set\ssystem\ssyslog (\s(?P<global>global)) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "system syslog global", "result": { "global_params": { "state": "{{ 'enabled' if global is defined else 'disabled' }}", - } - } + }, + }, }, { "name": "global_params.archive.state", @@ -221,15 +235,16 @@ class Logging_globalTemplate(NetworkTemplate): r""" ^set\ssystem\ssyslog\sglobal (\s(?P<archive>archive)) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "system syslog global archive", "result": { "global_params": { "archive": { "state": "{{ 'enabled' if archive is defined else 'disabled' }}", }, - } - } + }, + }, }, { "name": "global_params.archive.file_num", @@ -237,15 +252,16 @@ class Logging_globalTemplate(NetworkTemplate): r""" ^set\ssystem\ssyslog\sglobal\sarchive\sfile (\s(?P<file_num>'(\d+)'))? - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "system syslog global archive file {{ global_params.archive.file_num }}", "result": { "global_params": { "archive": { "file_num": "{{ file_num }}", }, - } - } + }, + }, }, { "name": "global_params.archive.size", @@ -253,15 +269,16 @@ class Logging_globalTemplate(NetworkTemplate): r""" ^set\ssystem\ssyslog\sglobal\sarchive\ssize (\s(?P<size>'(\d+)'))? - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "system syslog global archive size {{ global_params.archive.size }}", "result": { "global_params": { "archive": { "size": "{{ size }}", }, - } - } + }, + }, }, { "name": "global_params.marker_interval", @@ -269,14 +286,15 @@ class Logging_globalTemplate(NetworkTemplate): r""" ^set\ssystem\ssyslog\sglobal\smarker\sinterval (\s(?P<marker_interval>'(\d+)'))? - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "system syslog global marker interval {{ global_params.marker_interval }}", "remval": "system syslog global marker", "result": { "global_params": { "marker_interval": "{{ marker_interval }}", - } - } + }, + }, }, { "name": "global_params.preserve_fqdn", @@ -284,13 +302,14 @@ class Logging_globalTemplate(NetworkTemplate): r""" ^set\ssystem\ssyslog\sglobal (\s(?P<preserve_fqdn>preserve-fqdn)) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "system syslog global preserve-fqdn", "result": { "global_params": { "preserve_fqdn": "{{ True if preserve_fqdn is defined }}", - } - } + }, + }, }, { "name": "global_params.facilities", @@ -299,17 +318,19 @@ class Logging_globalTemplate(NetworkTemplate): ^set\ssystem\ssyslog\sglobal\sfacility (\s(?P<facility>all|auth|authpriv|cron|daemon|kern|lpr|mail|mark|news|protocols|security|syslog|user|uucp|local[0-7]))? (\slevel\s(?P<level>'(emerg|alert|crit|err|warning|notice|info|debug|all)'))? - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": tmplt_params, "remval": "system syslog global facility {{ global_params.facilities.facility }}", "result": { "global_params": { - "facilities": [{ - "facility": "{{ facility }}", - "severity": "{{ level }}", - }, ], - } - } + "facilities": [ + { + "facility": "{{ facility }}", + "severity": "{{ level }}", + }, ], + }, + }, }, { "name": "hosts.port", @@ -318,7 +339,8 @@ class Logging_globalTemplate(NetworkTemplate): ^set\ssystem\ssyslog\shost (\s(?P<hostname>\S+)) (\sport\s(?P<port>'(\d+)')) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "system syslog host {{ hosts.hostname }} port {{ hosts.port }}", "result": { "hosts": { @@ -326,8 +348,8 @@ class Logging_globalTemplate(NetworkTemplate): "hostname": "{{ hostname }}", "port": "{{ port }}", }, - } - } + }, + }, }, { "name": "hosts", @@ -338,21 +360,23 @@ class Logging_globalTemplate(NetworkTemplate): (\sfacility\s(?P<facility>all|auth|authpriv|cron|daemon|kern|lpr|mail|mark|news|protocols|security|syslog|user|uucp|local[0-7])) (\slevel\s(?P<level>'(emerg|alert|crit|err|warning|notice|info|debug|all)'))? (\sprotocol\s(?P<protocol>'(udp|tcp)'))? - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": tmplt_params, "remval": "system syslog host {{ hosts.hostname }}", "result": { "hosts": { "{{ hostname }}": { "hostname": "{{ hostname }}", - "facilities": [{ - "facility": "{{ facility }}", - "severity": "{{ level }}", - "protocol": "{{ protocol }}", - }, ] + "facilities": [ + { + "facility": "{{ facility }}", + "severity": "{{ level }}", + "protocol": "{{ protocol }}", + }, ], }, - } - } + }, + }, }, { "name": "users", @@ -362,20 +386,22 @@ class Logging_globalTemplate(NetworkTemplate): (\s(?P<username>\S+))? (\sfacility\s(?P<facility>all|auth|authpriv|cron|daemon|kern|lpr|mail|mark|news|protocols|security|syslog|user|uucp|local[0-7]))? (\slevel\s(?P<level>'(emerg|alert|crit|err|warning|notice|info|debug|all)'))? - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": tmplt_params, "remval": "system syslog user {{ users.username }}", "result": { "users": { "{{ username }}": { "username": "{{ username }}", - "facilities": [{ - "facility": "{{ facility }}", - "severity": "{{ level }}", - }, ] - } - } - } + "facilities": [ + { + "facility": "{{ facility }}", + "severity": "{{ level }}", + }, ], + }, + }, + }, }, ] # fmt: on diff --git a/plugins/module_utils/network/vyos/rm_templates/ntp_global.py b/plugins/module_utils/network/vyos/rm_templates/ntp_global.py index 5254035..33d173e 100644 --- a/plugins/module_utils/network/vyos/rm_templates/ntp_global.py +++ b/plugins/module_utils/network/vyos/rm_templates/ntp_global.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -36,11 +37,12 @@ class NtpTemplate(NetworkTemplate): r""" ^set\ssystem\sntp\sallow-clients\saddress (\s(?P<ipaddress>\S+))? $""", - re.VERBOSE), + re.VERBOSE, + ), "setval": "system ntp allow-clients address {{allow_clients}}", "result": { - "allow_clients": ["{{ipaddress}}"] - } + "allow_clients": ["{{ipaddress}}"], + }, }, # set system ntp allow_clients @@ -50,11 +52,12 @@ class NtpTemplate(NetworkTemplate): r""" ^set\ssystem\sntp\sallow-clients $""", - re.VERBOSE), + re.VERBOSE, + ), "setval": "system ntp allow-clients", "result": { - } + }, }, @@ -65,11 +68,12 @@ class NtpTemplate(NetworkTemplate): r""" ^set\ssystem\sntp\slisten-address (\s(?P<ip_address>\S+))? $""", - re.VERBOSE), + re.VERBOSE, + ), "setval": "system ntp listen-address {{listen_addresses}}", "result": { - "listen_addresses": ["{{ip_address}}"] - } + "listen_addresses": ["{{ip_address}}"], + }, }, # set system ntp listen_address @@ -79,10 +83,11 @@ class NtpTemplate(NetworkTemplate): r""" ^set\ssystem\sntp\slisten-address $""", - re.VERBOSE), + re.VERBOSE, + ), "setval": "system ntp listen-address", "result": { - } + }, }, # set system ntp server <name> @@ -92,16 +97,17 @@ class NtpTemplate(NetworkTemplate): r""" ^set\ssystem\sntp\sserver (\s(?P<name>\S+))? $""", - re.VERBOSE), + re.VERBOSE, + ), "setval": "system ntp server {{server}}", "result": { "servers": { "{{name}}": { - "server": "{{name}}" - } - } + "server": "{{name}}", + }, + }, - } + }, }, # set system ntp server <name> <options> @@ -113,16 +119,17 @@ class NtpTemplate(NetworkTemplate): \s(?P<name>\S+) \s(?P<options>noselect|dynamic|pool|preempt|prefer)? $""", - re.VERBOSE), + re.VERBOSE, + ), "setval": "system ntp server {{server}} {{options}}", "result": { "servers": { "{{name}}": { "server": "{{name}}", - "options": ["{{options}}"] - } - } - } - } + "options": ["{{options}}"], + }, + }, + }, + }, ] # fmt: on diff --git a/plugins/module_utils/network/vyos/rm_templates/ospf_interfaces.py b/plugins/module_utils/network/vyos/rm_templates/ospf_interfaces.py index de3beba..aaaf7ff 100644 --- a/plugins/module_utils/network/vyos/rm_templates/ospf_interfaces.py +++ b/plugins/module_utils/network/vyos/rm_templates/ospf_interfaces.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -70,7 +71,7 @@ def _tmplt_ospf_int_auth_password(config_data): + " " + params[0] + " authentication plaintext-password {plaintext_password}".format( - **config_data["address_family"]["authentication"] + **config_data["address_family"]["authentication"], ) ) return command @@ -87,7 +88,7 @@ def _tmplt_ospf_int_auth_md5(config_data): + " " + params[0] + " authentication md5 key-id {key_id} ".format( - **config_data["address_family"]["authentication"]["md5_key"] + **config_data["address_family"]["authentication"]["md5_key"], ) + "md5-key {key}".format(**config_data["address_family"]["authentication"]["md5_key"]) ) @@ -291,7 +292,10 @@ class Ospf_interfacesTemplate(NetworkTemplate): def __init__(self, lines=None, module=None): prefix = {"set": "set", "remove": "delete"} super(Ospf_interfacesTemplate, self).__init__( - lines=lines, tmplt=self, prefix=prefix, module=module + lines=lines, + tmplt=self, + prefix=prefix, + module=module, ) # fmt: off @@ -316,9 +320,9 @@ class Ospf_interfacesTemplate(NetworkTemplate): "address_family": { "{{ afi }}": { "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', - } - } - } + }, + }, + }, }, { "name": "authentication_password", @@ -344,11 +348,11 @@ class Ospf_interfacesTemplate(NetworkTemplate): "{{ afi }}": { "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', "authentication": { - "plaintext_password": "{{ text }}" - } - } - } - } + "plaintext_password": "{{ text }}", + }, + }, + }, + }, }, { "name": "authentication_md5", @@ -380,12 +384,12 @@ class Ospf_interfacesTemplate(NetworkTemplate): "authentication": { "md5_key": { "key_id": "{{ id }}", - "key": "{{ text }}" - } - } - } - } - } + "key": "{{ text }}", + }, + }, + }, + }, + }, }, { "name": "bandwidth", @@ -409,10 +413,10 @@ class Ospf_interfacesTemplate(NetworkTemplate): "address_family": { "{{ afi }}": { "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', - "bandwidth": "{{ bw }}" - } - } - } + "bandwidth": "{{ bw }}", + }, + }, + }, }, { "name": "cost", @@ -436,10 +440,10 @@ class Ospf_interfacesTemplate(NetworkTemplate): "address_family": { "{{ afi }}": { "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', - "cost": "{{ val }}" - } - } - } + "cost": "{{ val }}", + }, + }, + }, }, { "name": "hello_interval", @@ -463,10 +467,10 @@ class Ospf_interfacesTemplate(NetworkTemplate): "address_family": { "{{ afi }}": { "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', - "hello_interval": "{{ val }}" - } - } - } + "hello_interval": "{{ val }}", + }, + }, + }, }, { "name": "dead_interval", @@ -490,10 +494,10 @@ class Ospf_interfacesTemplate(NetworkTemplate): "address_family": { "{{ afi }}": { "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', - "dead_interval": "{{ val }}" - } - } - } + "dead_interval": "{{ val }}", + }, + }, + }, }, { "name": "mtu_ignore", @@ -516,10 +520,10 @@ class Ospf_interfacesTemplate(NetworkTemplate): "address_family": { "{{ afi }}": { "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', - "mtu_ignore": "{{ True if mtu is defined }}" - } - } - } + "mtu_ignore": "{{ True if mtu is defined }}", + }, + }, + }, }, { "name": "network", @@ -543,10 +547,10 @@ class Ospf_interfacesTemplate(NetworkTemplate): "address_family": { "{{ afi }}": { "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', - "network": "{{ val }}" - } - } - } + "network": "{{ val }}", + }, + }, + }, }, { "name": "priority", @@ -570,10 +574,10 @@ class Ospf_interfacesTemplate(NetworkTemplate): "address_family": { "{{ afi }}": { "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', - "priority": "{{ val }}" - } - } - } + "priority": "{{ val }}", + }, + }, + }, }, { "name": "retransmit_interval", @@ -597,10 +601,10 @@ class Ospf_interfacesTemplate(NetworkTemplate): "address_family": { "{{ afi }}": { "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', - "retransmit_interval": "{{ val }}" - } - } - } + "retransmit_interval": "{{ val }}", + }, + }, + }, }, { "name": "transmit_delay", @@ -624,10 +628,10 @@ class Ospf_interfacesTemplate(NetworkTemplate): "address_family": { "{{ afi }}": { "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', - "transmit_delay": "{{ val }}" - } - } - } + "transmit_delay": "{{ val }}", + }, + }, + }, }, { "name": "ifmtu", @@ -651,10 +655,10 @@ class Ospf_interfacesTemplate(NetworkTemplate): "address_family": { "{{ afi }}": { "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', - "ifmtu": "{{ val }}" - } - } - } + "ifmtu": "{{ val }}", + }, + }, + }, }, { "name": "instance", @@ -678,10 +682,10 @@ class Ospf_interfacesTemplate(NetworkTemplate): "address_family": { "{{ afi }}": { "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', - "instance": "{{ val }}" - } - } - } + "instance": "{{ val }}", + }, + }, + }, }, { "name": "passive", @@ -704,10 +708,10 @@ class Ospf_interfacesTemplate(NetworkTemplate): "address_family": { "{{ afi }}": { "afi": '{{ "ipv4" if afi == "ip" else "ipv6" }}', - "passive": "{{ True if pass is defined }}" - } - } - } + "passive": "{{ True if pass is defined }}", + }, + }, + }, }, { "name": "interface_name", @@ -723,7 +727,7 @@ class Ospf_interfacesTemplate(NetworkTemplate): "setval": "set interface {{ type }} {{ name }}", "result": { "name": "{{ name }}", - } + }, }, ] # fmt: on diff --git a/plugins/module_utils/network/vyos/rm_templates/prefix_lists.py b/plugins/module_utils/network/vyos/rm_templates/prefix_lists.py index 00a157e..0e99cfe 100644 --- a/plugins/module_utils/network/vyos/rm_templates/prefix_lists.py +++ b/plugins/module_utils/network/vyos/rm_templates/prefix_lists.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -25,7 +26,10 @@ class Prefix_listsTemplate(NetworkTemplate): def __init__(self, lines=None, module=None): prefix = {"set": "set", "remove": "delete"} super(Prefix_listsTemplate, self).__init__( - lines=lines, tmplt=self, module=module, prefix=prefix + lines=lines, + tmplt=self, + module=module, + prefix=prefix, ) # fmt: off @@ -39,7 +43,8 @@ class Prefix_listsTemplate(NetworkTemplate): \spolicy \sprefix-(?P<afi>\S+) \s(?P<name>\S+) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "policy prefix-{{ 'list' if afi == 'ipv4' else 'list6' }} {{ name }}", "result": { "{{ 'ipv4' if afi == 'list' else 'ipv6' }}": { @@ -47,9 +52,9 @@ class Prefix_listsTemplate(NetworkTemplate): "prefix_lists": { "{{ name }}": { "name": "{{ name }}", - } - } - } + }, + }, + }, }, }, @@ -63,7 +68,8 @@ class Prefix_listsTemplate(NetworkTemplate): \sprefix-(?P<afi>\S+) \s(?P<name>\S+) \sdescription\s'(?P<description>.+)' - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "policy prefix-{{ 'list' if afi == 'ipv4' else 'list6' }} {{ name }} description '{{ description }}'", "result": { "{{ 'ipv4' if afi == 'list' else 'ipv6' }}": { @@ -71,10 +77,10 @@ class Prefix_listsTemplate(NetworkTemplate): "prefix_lists": { "{{ name }}": { "name": "{{ name }}", - "description": "{{ description }}" - } - } - } + "description": "{{ description }}", + }, + }, + }, }, }, @@ -88,7 +94,8 @@ class Prefix_listsTemplate(NetworkTemplate): \sprefix-(?P<afi>\S+) \s(?P<name>\S+) \srule\s(?P<sequence>\d+) - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "policy prefix-{{ 'list' if afi == 'ipv4' else 'list6' }} {{ name }} rule {{ sequence }}", "result": { "{{ 'ipv4' if afi == 'list' else 'ipv6' }}": { @@ -98,12 +105,12 @@ class Prefix_listsTemplate(NetworkTemplate): "name": "{{ name }}", "entries": { "{{ sequence }}": { - "sequence": "{{ sequence }}" - } - } - } - } - } + "sequence": "{{ sequence }}", + }, + }, + }, + }, + }, }, }, @@ -118,7 +125,8 @@ class Prefix_listsTemplate(NetworkTemplate): \s(?P<name>\S+) \srule\s(?P<sequence>\d+) \saction\s'(?P<action>permit|deny)' - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "policy prefix-{{ 'list' if afi == 'ipv4' else 'list6' }} {{ name }} rule {{ sequence }} action '{{ action }}'", "result": { "{{ 'ipv4' if afi == 'list' else 'ipv6' }}": { @@ -129,12 +137,12 @@ class Prefix_listsTemplate(NetworkTemplate): "entries": { "{{ sequence }}": { "sequence": "{{ sequence }}", - "action": "{{ action }}" - } - } - } - } - } + "action": "{{ action }}", + }, + }, + }, + }, + }, }, }, @@ -149,7 +157,8 @@ class Prefix_listsTemplate(NetworkTemplate): \s(?P<name>\S+) \srule\s(?P<sequence>\d+) \sdescription\s'(?P<rule_description>.+)' - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "compval": "description", "setval": "policy prefix-{{ 'list' if afi == 'ipv4' else 'list6' }} {{ name }} rule {{ sequence }} description '{{ description }}'", "result": { @@ -161,12 +170,12 @@ class Prefix_listsTemplate(NetworkTemplate): "entries": { "{{ sequence }}": { "sequence": "{{ sequence }}", - "description": "{{ rule_description }}" - } - } - } - } - } + "description": "{{ rule_description }}", + }, + }, + }, + }, + }, }, }, @@ -181,7 +190,8 @@ class Prefix_listsTemplate(NetworkTemplate): \s(?P<name>\S+) \srule\s(?P<sequence>\d+) \sge\s'(?P<ge>\d+)' - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "policy prefix-{{ 'list' if afi == 'ipv4' else 'list6' }} {{ name }} rule {{ sequence }} ge '{{ ge }}'", "result": { "{{ 'ipv4' if afi == 'list' else 'ipv6' }}": { @@ -192,12 +202,12 @@ class Prefix_listsTemplate(NetworkTemplate): "entries": { "{{ sequence }}": { "sequence": "{{ sequence }}", - "ge": "{{ ge }}" - } - } - } - } - } + "ge": "{{ ge }}", + }, + }, + }, + }, + }, }, }, @@ -212,7 +222,8 @@ class Prefix_listsTemplate(NetworkTemplate): \s(?P<name>\S+) \srule\s(?P<sequence>\d+) \sle\s'(?P<le>\d+)' - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "policy prefix-{{ 'list' if afi == 'ipv4' else 'list6' }} {{ name }} rule {{ sequence }} le '{{ le }}'", "result": { "{{ 'ipv4' if afi == 'list' else 'ipv6' }}": { @@ -223,12 +234,12 @@ class Prefix_listsTemplate(NetworkTemplate): "entries": { "{{ sequence }}": { "sequence": "{{ sequence }}", - "le": "{{ le }}" - } - } - } - } - } + "le": "{{ le }}", + }, + }, + }, + }, + }, }, }, @@ -243,7 +254,8 @@ class Prefix_listsTemplate(NetworkTemplate): \s(?P<name>\S+) \srule\s(?P<sequence>\d+) \sprefix\s'(?P<prefix>\S+)' - $""", re.VERBOSE), + $""", re.VERBOSE, + ), "setval": "policy prefix-{{ 'list' if afi == 'ipv4' else 'list6' }} {{ name }} rule {{ sequence }} prefix '{{ prefix }}'", "result": { "{{ 'ipv4' if afi == 'list' else 'ipv6' }}": { @@ -254,12 +266,12 @@ class Prefix_listsTemplate(NetworkTemplate): "entries": { "{{ sequence }}": { "sequence": "{{ sequence }}", - "prefix": "{{ prefix }}" - } - } - } - } - } + "prefix": "{{ prefix }}", + }, + }, + }, + }, + }, }, }, ] diff --git a/plugins/module_utils/network/vyos/rm_templates/route_maps.py b/plugins/module_utils/network/vyos/rm_templates/route_maps.py index 1652a23..8f218a6 100644 --- a/plugins/module_utils/network/vyos/rm_templates/route_maps.py +++ b/plugins/module_utils/network/vyos/rm_templates/route_maps.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -42,8 +43,8 @@ class Route_mapsTemplate(NetworkTemplate): "route_maps": { "{{ route_map }}": { "route_map": '{{ route_map }}', - } - } + }, + }, }, }, { @@ -63,12 +64,12 @@ class Route_mapsTemplate(NetworkTemplate): "entries": { "{{sequence}}": { - "sequence": "{{sequence}}" - } - } - } - } - } + "sequence": "{{sequence}}", + }, + }, + }, + }, + }, }, { "name": "call", @@ -87,12 +88,12 @@ class Route_mapsTemplate(NetworkTemplate): "{{sequence}}": { "sequence": "{{sequence}}", - "call": "{{call}}" - } - } - } - } - } + "call": "{{call}}", + }, + }, + }, + }, + }, }, { "name": "description", @@ -111,12 +112,12 @@ class Route_mapsTemplate(NetworkTemplate): "{{sequence}}": { "sequence": "{{sequence}}", - "description": "{{description}}" - } - } - } - } - } + "description": "{{description}}", + }, + }, + }, + }, + }, }, { "name": "action", @@ -135,12 +136,12 @@ class Route_mapsTemplate(NetworkTemplate): "{{sequence}}": { "sequence": "{{sequence}}", - "action": "{{action}}" - } - } - } - } - } + "action": "{{action}}", + }, + }, + }, + }, + }, }, { "name": "continue_sequence", @@ -159,12 +160,12 @@ class Route_mapsTemplate(NetworkTemplate): "{{sequence}}": { "sequence": "{{sequence}}", - "continue_sequence": "{{continue}}" - } - } - } - } - } + "continue_sequence": "{{continue}}", + }, + }, + }, + }, + }, }, { "name": "on_match_next", @@ -185,13 +186,13 @@ class Route_mapsTemplate(NetworkTemplate): { "sequence": "{{sequence}}", "on_match": { - "next": "{{True if next is defined}}" - } - } - } - } - } - } + "next": "{{True if next is defined}}", + }, + }, + }, + }, + }, + }, }, { "name": "on_match_goto", @@ -212,13 +213,13 @@ class Route_mapsTemplate(NetworkTemplate): { "sequence": "{{sequence}}", "on_match": { - "goto": "{{goto}}" - } - } - } - } - } - } + "goto": "{{goto}}", + }, + }, + }, + }, + }, + }, }, { "name": "set_aggregator_ip", @@ -240,14 +241,14 @@ class Route_mapsTemplate(NetworkTemplate): "sequence": "{{sequence}}", "set": { "aggregator": { - "ip": "{{ip}}" - } - } - } - } - } - } - } + "ip": "{{ip}}", + }, + }, + }, + }, + }, + }, + }, }, { "name": "set_aggregator_as", @@ -269,14 +270,14 @@ class Route_mapsTemplate(NetworkTemplate): "sequence": "{{sequence}}", "set": { "aggregator": { - "as": "{{as}}" - } - } - } - } - } - } - } + "as": "{{as}}", + }, + }, + }, + }, + }, + }, + }, }, { "name": "set_as_path_exclude", @@ -297,13 +298,13 @@ class Route_mapsTemplate(NetworkTemplate): { "sequence": "{{sequence}}", "set": { - "as_path_exclude": "{{as}}" - } - } - } - } - } - } + "as_path_exclude": "{{as}}", + }, + }, + }, + }, + }, + }, }, { "name": "set_as_path_prepend", @@ -324,13 +325,13 @@ class Route_mapsTemplate(NetworkTemplate): { "sequence": "{{sequence}}", "set": { - "as_path_prepend": "{{as}}" - } - } - } - } - } - } + "as_path_prepend": "{{as}}", + }, + }, + }, + }, + }, + }, }, { "name": "set_atomic_aggregate", @@ -350,13 +351,13 @@ class Route_mapsTemplate(NetworkTemplate): { "sequence": "{{sequence}}", "set": { - "atomic_aggregate": "{{True if as is defined}}" - } - } - } - } - } - } + "atomic_aggregate": "{{True if as is defined}}", + }, + }, + }, + }, + }, + }, }, { "name": "set_bgp_extcommunity_rt", @@ -378,13 +379,13 @@ class Route_mapsTemplate(NetworkTemplate): { "sequence": "{{sequence}}", "set": { - "bgp_extcommunity_rt": "{{bgp}}" - } - } - } - } - } - } + "bgp_extcommunity_rt": "{{bgp}}", + }, + }, + }, + }, + }, + }, }, { "name": "set_comm_list", @@ -406,13 +407,13 @@ class Route_mapsTemplate(NetworkTemplate): { "sequence": "{{sequence}}", "set": { - "comm_list": {"comm_list": "{{comm_list}}"} - } - } - } - } - } - } + "comm_list": {"comm_list": "{{comm_list}}"}, + }, + }, + }, + }, + }, + }, }, { "name": "set_comm_list_delete", @@ -434,13 +435,13 @@ class Route_mapsTemplate(NetworkTemplate): { "sequence": "{{sequence}}", "set": { - "comm_list": {"delete": "{{True if delete is defined}}"} - } - } - } - } - } - } + "comm_list": {"delete": "{{True if delete is defined}}"}, + }, + }, + }, + }, + }, + }, }, { "name": "set_extcommunity_rt", @@ -462,13 +463,13 @@ class Route_mapsTemplate(NetworkTemplate): { "sequence": "{{sequence}}", "set": { - "extcommunity_rt": "{{extcommunity_rt}}" - } - } - } - } - } - } + "extcommunity_rt": "{{extcommunity_rt}}", + }, + }, + }, + }, + }, + }, }, { "name": "set_extcommunity_soo", @@ -490,13 +491,13 @@ class Route_mapsTemplate(NetworkTemplate): { "sequence": "{{sequence}}", "set": { - "extcommunity_soo": "{{set.extcommunity_soo}}" - } - } - } - } - } - } + "extcommunity_soo": "{{set.extcommunity_soo}}", + }, + }, + }, + }, + }, + }, }, { "name": "set_ip_next_hop", @@ -518,13 +519,13 @@ class Route_mapsTemplate(NetworkTemplate): { "sequence": "{{sequence}}", "set": { - "ip_next_hop": "{{ip_next_hop}}" - } - } - } - } - } - } + "ip_next_hop": "{{ip_next_hop}}", + }, + }, + }, + }, + }, + }, }, { "name": "set_ipv6_next_hop", @@ -550,14 +551,14 @@ class Route_mapsTemplate(NetworkTemplate): "set": { "ipv6_next_hop": { "ip_type": "{{type}}", - "value": "{{value}}" - } - } - } - } - } - } - } + "value": "{{value}}", + }, + }, + }, + }, + }, + }, + }, }, { "name": "set_large_community", @@ -579,13 +580,13 @@ class Route_mapsTemplate(NetworkTemplate): { "sequence": "{{sequence}}", "set": { - "large_community": "{{large_community}}" - } - } - } - } - } - } + "large_community": "{{large_community}}", + }, + }, + }, + }, + }, + }, }, { "name": "set_local_preference", @@ -607,13 +608,13 @@ class Route_mapsTemplate(NetworkTemplate): { "sequence": "{{sequence}}", "set": { - "local_preference": "{{local_preference}}" - } - } - } - } - } - } + "local_preference": "{{local_preference}}", + }, + }, + }, + }, + }, + }, }, { "name": "set_metric", @@ -635,13 +636,13 @@ class Route_mapsTemplate(NetworkTemplate): { "sequence": "{{sequence}}", "set": { - "metric": "{{metric}}" - } - } - } - } - } - } + "metric": "{{metric}}", + }, + }, + }, + }, + }, + }, }, { "name": "set_metric_type", @@ -663,13 +664,13 @@ class Route_mapsTemplate(NetworkTemplate): { "sequence": "{{sequence}}", "set": { - "metric_type": "{{metric_type}}" - } - } - } - } - } - } + "metric_type": "{{metric_type}}", + }, + }, + }, + }, + }, + }, }, { "name": "set_origin", @@ -691,13 +692,13 @@ class Route_mapsTemplate(NetworkTemplate): { "sequence": "{{sequence}}", "set": { - "origin": "{{origin}}" - } - } - } - } - } - } + "origin": "{{origin}}", + }, + }, + }, + }, + }, + }, }, { "name": "set_originator_id", @@ -719,13 +720,13 @@ class Route_mapsTemplate(NetworkTemplate): { "sequence": "{{sequence}}", "set": { - "originator_id": "{{originator_id}}" - } - } - } - } - } - } + "originator_id": "{{originator_id}}", + }, + }, + }, + }, + }, + }, }, { "name": "set_src", @@ -747,13 +748,13 @@ class Route_mapsTemplate(NetworkTemplate): { "sequence": "{{sequence}}", "set": { - "src": "{{src}}" - } - } - } - } - } - } + "src": "{{src}}", + }, + }, + }, + }, + }, + }, }, { "name": "set_tag", @@ -775,13 +776,13 @@ class Route_mapsTemplate(NetworkTemplate): { "sequence": "{{sequence}}", "set": { - "tag": "{{tag}}" - } - } - } - } - } - } + "tag": "{{tag}}", + }, + }, + }, + }, + }, + }, }, { "name": "set_weight", @@ -803,13 +804,13 @@ class Route_mapsTemplate(NetworkTemplate): { "sequence": "{{sequence}}", "set": { - "weight": "{{weight}}" - } - } - } - } - } - } + "weight": "{{weight}}", + }, + }, + }, + }, + }, + }, }, { "name": "set_community", @@ -833,13 +834,13 @@ class Route_mapsTemplate(NetworkTemplate): "set": { "community": { "value": "{{value}}", - } - } - } - } - } - } - } + }, + }, + }, + }, + }, + }, + }, }, { "name": "match_as_path", @@ -861,13 +862,13 @@ class Route_mapsTemplate(NetworkTemplate): { "sequence": "{{sequence}}", "match": { - "as_path": "{{as_path}}" - } - } - } - } - } - } + "as_path": "{{as_path}}", + }, + }, + }, + }, + }, + }, }, { "name": "match_community_community_list", @@ -889,13 +890,13 @@ class Route_mapsTemplate(NetworkTemplate): { "sequence": "{{sequence}}", "match": { - "community": {"community_list": "{{community_list}}"} - } - } - } - } - } - } + "community": {"community_list": "{{community_list}}"}, + }, + }, + }, + }, + }, + }, }, { "name": "match_community_exact_match", @@ -917,13 +918,13 @@ class Route_mapsTemplate(NetworkTemplate): { "sequence": "{{sequence}}", "match": { - "community": {"exact_match": "{{True if exact_match is defined}}"} - } - } - } - } - } - } + "community": {"exact_match": "{{True if exact_match is defined}}"}, + }, + }, + }, + }, + }, + }, }, { "name": "match_extcommunity", @@ -945,13 +946,13 @@ class Route_mapsTemplate(NetworkTemplate): { "sequence": "{{sequence}}", "match": { - "extcommunity": "{{extcommunity}}" - } - } - } - } - } - } + "extcommunity": "{{extcommunity}}", + }, + }, + }, + }, + }, + }, }, { "name": "match_interface", @@ -973,13 +974,13 @@ class Route_mapsTemplate(NetworkTemplate): { "sequence": "{{sequence}}", "match": { - "interface": "{{interface}}" - } - } - } - } - } - } + "interface": "{{interface}}", + }, + }, + }, + }, + }, + }, }, { "name": "match_large_community_large_community_list", @@ -1001,13 +1002,13 @@ class Route_mapsTemplate(NetworkTemplate): { "sequence": "{{sequence}}", "match": { - "large_community_large_community_list": "{{lc}}" - } - } - } - } - } - } + "large_community_large_community_list": "{{lc}}", + }, + }, + }, + }, + }, + }, }, { "name": "match_metric", @@ -1029,13 +1030,13 @@ class Route_mapsTemplate(NetworkTemplate): { "sequence": "{{sequence}}", "match": { - "metric": "{{metric}}" - } - } - } - } - } - } + "metric": "{{metric}}", + }, + }, + }, + }, + }, + }, }, { "name": "match_origin", @@ -1057,13 +1058,13 @@ class Route_mapsTemplate(NetworkTemplate): { "sequence": "{{sequence}}", "match": { - "origin": "{{origin}}" - } - } - } - } - } - } + "origin": "{{origin}}", + }, + }, + }, + }, + }, + }, }, { "name": "match_peer", @@ -1085,13 +1086,13 @@ class Route_mapsTemplate(NetworkTemplate): { "sequence": "{{sequence}}", "match": { - "peer": "{{peer}}" - } - } - } - } - } - } + "peer": "{{peer}}", + }, + }, + }, + }, + }, + }, }, { "name": "match_ip_address", @@ -1117,15 +1118,15 @@ class Route_mapsTemplate(NetworkTemplate): "ip": { "address": { "list_type": "{{list_type}}", - "value": "{{value}}" - } - } - } - } - } - } - } - } + "value": "{{value}}", + }, + }, + }, + }, + }, + }, + }, + }, }, { "name": "match_ip_next_hop", @@ -1151,15 +1152,15 @@ class Route_mapsTemplate(NetworkTemplate): "ip": { "next_hop": { "list_type": "{{list_type}}", - "value": "{{value}}" - } - } - } - } - } - } - } - } + "value": "{{value}}", + }, + }, + }, + }, + }, + }, + }, + }, }, { "name": "match_ip_route_source", @@ -1185,15 +1186,15 @@ class Route_mapsTemplate(NetworkTemplate): "ip": { "route_source": { "list_type": "{{list_type}}", - "value": "{{value}}" - } - } - } - } - } - } - } - } + "value": "{{value}}", + }, + }, + }, + }, + }, + }, + }, + }, }, { "name": "match_ipv6_address", @@ -1219,15 +1220,15 @@ class Route_mapsTemplate(NetworkTemplate): "ipv6": { "address": { "list_type": "{{list_type}}", - "value": "{{value}}" - } - } - } - } - } - } - } - } + "value": "{{value}}", + }, + }, + }, + }, + }, + }, + }, + }, }, { "name": "match_ipv6_nexthop", @@ -1250,14 +1251,14 @@ class Route_mapsTemplate(NetworkTemplate): "sequence": "{{sequence}}", "match": { "ipv6": { - "next_hop": "{{value}}" - } - } - } - } - } - } - } + "next_hop": "{{value}}", + }, + }, + }, + }, + }, + }, + }, }, { "name": "match_rpki", @@ -1279,13 +1280,13 @@ class Route_mapsTemplate(NetworkTemplate): "{{sequence}}": { "sequence": "{{sequence}}", "match": { - "rpki": "{{value}}" - } - } - } - } - } - } + "rpki": "{{value}}", + }, + }, + }, + }, + }, + }, }, ] diff --git a/plugins/module_utils/network/vyos/rm_templates/snmp_server.py b/plugins/module_utils/network/vyos/rm_templates/snmp_server.py index 15a0804..724be22 100644 --- a/plugins/module_utils/network/vyos/rm_templates/snmp_server.py +++ b/plugins/module_utils/network/vyos/rm_templates/snmp_server.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type """ @@ -124,7 +125,10 @@ class Snmp_serverTemplate(NetworkTemplate): def __init__(self, lines=None, module=None): prefix = {"set": "set", "remove": "delete"} super(Snmp_serverTemplate, self).__init__( - lines=lines, tmplt=self, prefix=prefix, module=module + lines=lines, + tmplt=self, + prefix=prefix, + module=module, ) # fmt: off @@ -140,7 +144,8 @@ class Snmp_serverTemplate(NetworkTemplate): \s*(client\s(?P<client>\S+))* \s*(network\s(?P<network>\S+))* $""", - re.VERBOSE), + re.VERBOSE, + ), "setval": _tmplt_snmp_server_communities, "result": { "communities": { @@ -148,10 +153,10 @@ class Snmp_serverTemplate(NetworkTemplate): "name": "{{ name }}", "clients": ['{{ client if client is defined else "None" }}'], "networks": ['{{ network if network is defined else "None" }}'], - "authorization_type": '{{ auth.split(" ")[1] if auth is defined else None }}' - } - } - } + "authorization_type": '{{ auth.split(" ")[1] if auth is defined else None }}', + }, + }, + }, }, # service snmp contact <> { @@ -161,11 +166,12 @@ class Snmp_serverTemplate(NetworkTemplate): ^set\sservice\ssnmp\scontact \s+(?P<name>\S+) *$""", - re.VERBOSE), + re.VERBOSE, + ), "setval": "service snmp contact {{ contact }}", "result": { - "contact": "{{ name }}" - } + "contact": "{{ name }}", + }, }, # service snmp description <> { @@ -175,11 +181,12 @@ class Snmp_serverTemplate(NetworkTemplate): ^set\sservice\ssnmp\sdescription \s+(?P<name>\S+) *$""", - re.VERBOSE), + re.VERBOSE, + ), "setval": "service snmp description {{ description }}", "result": { - "description": "{{ name }}" - } + "description": "{{ name }}", + }, }, # service snmp listen-address <> port <> { @@ -191,17 +198,18 @@ class Snmp_serverTemplate(NetworkTemplate): \s*(port)* \s*(?P<port>\d+)* $""", - re.VERBOSE), + re.VERBOSE, + ), "setval": "service snmp listen-address {{ listen_addresses.address }}" "{{ (' port ' + listen_addresses.port|string) if listen_addresses.port is defined else '' }}", "result": { "listen_addresses": { "{{ addr }}": { "address": "{{ addr }}", - "port": "{{ port }}" - } - } - } + "port": "{{ port }}", + }, + }, + }, }, # service snmp location <> { @@ -211,11 +219,12 @@ class Snmp_serverTemplate(NetworkTemplate): ^set\sservice\ssnmp\slocation \s(?P<name>.*) $""", - re.VERBOSE), + re.VERBOSE, + ), "setval": "service snmp location {{ '\\'' + location + '\\''}}", "result": { - "location": "{{ name }}" - } + "location": "{{ name }}", + }, }, # service snmp smux-peer <> { @@ -225,11 +234,12 @@ class Snmp_serverTemplate(NetworkTemplate): ^set\sservice\ssnmp\ssmux-peer \s+(?P<name>\S+) *$""", - re.VERBOSE), + re.VERBOSE, + ), "setval": "service snmp smux-peer {{ smux_peer }}", "result": { - "smux_peer": "{{ name }}" - } + "smux_peer": "{{ name }}", + }, }, # service snmp trap-source <> { @@ -239,11 +249,12 @@ class Snmp_serverTemplate(NetworkTemplate): ^set\sservice\ssnmp\strap-source \s+(?P<name>\S+) *$""", - re.VERBOSE), + re.VERBOSE, + ), "setval": "service snmp trap-source {{ trap_source }}", "result": { - "trap_source": "{{ name }}" - } + "trap_source": "{{ name }}", + }, }, # service snmp trap-target <> { @@ -255,15 +266,16 @@ class Snmp_serverTemplate(NetworkTemplate): \s*(?P<comm>community\s\S+)* \s*(?P<port>port\s\d+)* $""", - re.VERBOSE), + re.VERBOSE, + ), "setval": _tmplt_snmp_server_trap_target, "result": { "trap_target": { "address": "{{ name }}", "community": "{{ comm.split(" ")[1] if comm is defined else None }}", "port": "{{ port.split(" ")[1] if port is defined else None }}", - } - } + }, + }, }, # service snmp v3 engineid <> { @@ -273,13 +285,14 @@ class Snmp_serverTemplate(NetworkTemplate): ^set\sservice\ssnmp\sv3\sengineid \s+(?P<name>\S+) *$""", - re.VERBOSE), + re.VERBOSE, + ), "setval": "service snmp v3 engineid {{ snmp_v3.engine_id }}", "result": { "snmp_v3": { "engine_id": "{{ name }}", - } - } + }, + }, }, # service snmp v3 group <> { @@ -292,7 +305,8 @@ class Snmp_serverTemplate(NetworkTemplate): \s*(?P<sec>seclevel\s\S+)* \s*(?P<view>view\s\S+)* $""", - re.VERBOSE), + re.VERBOSE, + ), "setval": _tmplt_snmp_server_v3_groups, "result": { "snmp_v3": { @@ -302,10 +316,10 @@ class Snmp_serverTemplate(NetworkTemplate): "mode": '{{ mode.split(" ")[1] if mode is defined else None }}', "seclevel": '{{ sec.split(" ")[1] if sec is defined else None }}', "view": '{{ view.split(" ")[1] if view is defined else None }}', - } - } - } - } + }, + }, + }, + }, }, # service snmp v3 trap-target <> auth <> { @@ -319,7 +333,8 @@ class Snmp_serverTemplate(NetworkTemplate): \s*(?P<plain>plaintext-key\s\S+)* \s*(?P<type>type\s\S+)* $""", - re.VERBOSE), + re.VERBOSE, + ), "setval": _tmplt_snmp_server_v3_trap_target, "result": { "snmp_v3": { @@ -330,11 +345,11 @@ class Snmp_serverTemplate(NetworkTemplate): "encrypted_key": '{{ enc.split(" ")[1] if enc is defined else None }}', "plaintext_key": '{{ plain.split(" ")[1] if plain is defined else None }}', "type": '{{ type.split(" ")[1] if type is defined else None }}', - } - } - } - } - } + }, + }, + }, + }, + }, }, # service snmp v3 trap-target <> port <> { @@ -345,18 +360,19 @@ class Snmp_serverTemplate(NetworkTemplate): \s+(?P<name>\S+) \s+(?P<port>port\s\d+)* $""", - re.VERBOSE), + re.VERBOSE, + ), "setval": "service snmp v3 trap-target port {{ snmp_v3.trap_targets.port }}", "result": { "snmp_v3": { "trap_targets": { "{{ name }}": { "address": "{{ name }}", - "port": "{{ port }}" - } - } - } - } + "port": "{{ port }}", + }, + }, + }, + }, }, # service snmp v3 trap-target <> protocol <> { @@ -367,18 +383,19 @@ class Snmp_serverTemplate(NetworkTemplate): \s+(?P<name>\S+) \s+(?P<protocol>protocol\s\S+)* $""", - re.VERBOSE), + re.VERBOSE, + ), "setval": "service snmp v3 trap-target protocol {{ snmp_v3.trap_targets.protocol }}", "result": { "snmp_v3": { "trap_targets": { "{{ name }}": { "address": "{{ name }}", - "protocol": "{{ protocol }}" - } - } - } - } + "protocol": "{{ protocol }}", + }, + }, + }, + }, }, # service snmp v3 trap-target <> type <> { @@ -389,18 +406,19 @@ class Snmp_serverTemplate(NetworkTemplate): \s+(?P<name>\S+) \s+(?P<type>type\s\S+)* $""", - re.VERBOSE), + re.VERBOSE, + ), "setval": "service snmp v3 trap-target type {{ snmp_v3.trap_targets.type }}", "result": { "snmp_v3": { "trap_targets": { "{{ name }}": { "address": "{{ name }}", - "type": "{{ type }}" - } - } - } - } + "type": "{{ type }}", + }, + }, + }, + }, }, # service snmp v3 trap-target <> user <> { @@ -411,18 +429,19 @@ class Snmp_serverTemplate(NetworkTemplate): \s+(?P<name>\S+) \s+(?P<user>user\s\S+)* $""", - re.VERBOSE), + re.VERBOSE, + ), "setval": "service snmp v3 trap-target user {{ snmp_v3.trap_targets.user }}", "result": { "snmp_v3": { "trap_targets": { "{{ name }}": { "address": "{{ name }}", - "user": "{{ user }}" - } - } - } - } + "user": "{{ user }}", + }, + }, + }, + }, }, # service snmp v3 trap-target <> privacy <> { @@ -436,7 +455,8 @@ class Snmp_serverTemplate(NetworkTemplate): \s*(?P<plain>plaintext-key\s\S+)* \s*(?P<type>type\s\S+)* $""", - re.VERBOSE), + re.VERBOSE, + ), "setval": _tmplt_snmp_server_v3_trap_target, "result": { "snmp_v3": { @@ -447,11 +467,11 @@ class Snmp_serverTemplate(NetworkTemplate): "encrypted_key": '{{ enc.split(" ")[1] if enc is defined else None }}', "plaintext_key": '{{ plain.split(" ")[1] if plain is defined else None }}', "type": '{{ type.split(" ")[1] if type is defined else None }}', - } - } - } - } - } + }, + }, + }, + }, + }, }, # service snmp v3 user <> auth <> { @@ -465,7 +485,8 @@ class Snmp_serverTemplate(NetworkTemplate): \s*(?P<plain>plaintext-key\s\S+)* \s*(?P<type>type\s\S+)* $""", - re.VERBOSE), + re.VERBOSE, + ), "setval": _tmplt_snmp_server_v3_user, "result": { "snmp_v3": { @@ -476,11 +497,11 @@ class Snmp_serverTemplate(NetworkTemplate): "encrypted_key": '{{ enc.split(" ")[1] if enc is defined else None }}', "plaintext_key": '{{ plain.split(" ")[1] if plain is defined else None }}', "type": '{{ type.split(" ")[1] if type is defined else None }}', - } - } - } - } - } + }, + }, + }, + }, + }, }, # service snmp v3 user <> privacy <> { @@ -494,7 +515,8 @@ class Snmp_serverTemplate(NetworkTemplate): \s*(?P<plain>plaintext-key\s\S+)* \s*(?P<type>type\s\S+)* $""", - re.VERBOSE), + re.VERBOSE, + ), "setval": _tmplt_snmp_server_v3_user, "result": { "snmp_v3": { @@ -505,11 +527,11 @@ class Snmp_serverTemplate(NetworkTemplate): "encrypted_key": '{{ enc.split(" ")[1] if enc is defined else None }}', "plaintext_key": '{{ plain.split(" ")[1] if plain is defined else None }}', "type": '{{ type.split(" ")[1] if type is defined else None }}', - } - } - } - } - } + }, + }, + }, + }, + }, }, # service snmp v3 user <> group <> { @@ -520,18 +542,19 @@ class Snmp_serverTemplate(NetworkTemplate): \s+(?P<name>\S+) \s+(?P<group>group\s.+)* $""", - re.VERBOSE), + re.VERBOSE, + ), "setval": "service snmp v3 user {{ snmp_v3.users.user }} group {{ snmp_v3.users.group }}", "result": { "snmp_v3": { "users": { "{{ name }}": { "user": "{{ name }}", - "group": "{{ group.split(" ")[1] if group is defined else None }}" - } - } - } - } + "group": "{{ group.split(" ")[1] if group is defined else None }}", + }, + }, + }, + }, }, # service snmp v3 user <> mode <> { @@ -542,18 +565,19 @@ class Snmp_serverTemplate(NetworkTemplate): \s+(?P<name>\S+) \s+(?P<mode>mode\s\S+)* $""", - re.VERBOSE), + re.VERBOSE, + ), "setval": "service snmp v3 user {{ snmp_v3.users.user }} mode {{ snmp_v3.users.mode }}", "result": { "snmp_v3": { "users": { "{{ name }}": { "user": "{{ name }}", - "mode": "{{ mode }}" - } - } - } - } + "mode": "{{ mode }}", + }, + }, + }, + }, }, # service snmp v3 view <> { @@ -566,7 +590,8 @@ class Snmp_serverTemplate(NetworkTemplate): \s*(?P<ex>exclude\s\S+)* \s*(?P<mask>mask\s\S+)* $""", - re.VERBOSE), + re.VERBOSE, + ), "setval": _tmplt_snmp_server_v3_views, "result": { "snmp_v3": { @@ -576,10 +601,10 @@ class Snmp_serverTemplate(NetworkTemplate): "oid": '{{ oid.split(" ")[1] if oid is defined else None }}', "exclude": '{{ ex.split(" ")[1] if ex is defined else None }}', "mask": '{{ mask.split(" ")[1] if mask is defined else None }}', - } - } - } - } + }, + }, + }, + }, }, ] # fmt: on diff --git a/plugins/module_utils/network/vyos/utils/utils.py b/plugins/module_utils/network/vyos/utils/utils.py index d2ca703..8722251 100644 --- a/plugins/module_utils/network/vyos/utils/utils.py +++ b/plugins/module_utils/network/vyos/utils/utils.py @@ -6,10 +6,12 @@ # utils from __future__ import absolute_import, division, print_function + __metaclass__ = type from ansible.module_utils.basic import missing_required_lib from ansible.module_utils.six import iteritems + try: import ipaddress diff --git a/plugins/module_utils/network/vyos/vyos.py b/plugins/module_utils/network/vyos/vyos.py index da364f9..4fcb331 100644 --- a/plugins/module_utils/network/vyos/vyos.py +++ b/plugins/module_utils/network/vyos/vyos.py @@ -27,12 +27,14 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type import json from ansible.module_utils._text import to_text from ansible.module_utils.connection import Connection, ConnectionError + _DEVICE_CONFIGS = {} diff --git a/plugins/modules/vyos_banner.py b/plugins/modules/vyos_banner.py index 0ee10f5..6b1da84 100644 --- a/plugins/modules/vyos_banner.py +++ b/plugins/modules/vyos_banner.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function + __metaclass__ = type # (c) 2017, Ansible by Red Hat, inc diff --git a/plugins/modules/vyos_bgp_address_family.py b/plugins/modules/vyos_bgp_address_family.py index ba56309..d6f8925 100644 --- a/plugins/modules/vyos_bgp_address_family.py +++ b/plugins/modules/vyos_bgp_address_family.py @@ -28,6 +28,7 @@ The module file for vyos_bgp_address_family from __future__ import absolute_import, division, print_function + __metaclass__ = type DOCUMENTATION = """ @@ -264,39 +265,39 @@ EXAMPLES = """ # vyos@vyos:~$ show configuration commands | match "set protocols bgp" # vyos@vyos:~$ - - name: Merge provided configuration with device configuration - vyos.vyos.vyos_bgp_address_family: - config: - as_number: "100" - address_family: - - afi: "ipv4" - redistribute: - - protocol: "static" - metric: 50 - neighbors: - - neighbor_address: "20.33.1.1/24" - address_family: - - afi: "ipv4" - allowas_in: 4 - as_override: True - attribute_unchanged: - med: True - - afi: "ipv6" - default_originate: "map01" - distribute_list: - - action: "export" - acl: 10 - - neighbor_address: "100.11.34.12" - address_family: - - afi: "ipv4" - maximum_prefix: 45 - nexthop_self: True - route_map: - - action: "export" - route_map: "map01" - - action: "import" - route_map: "map01" - weight: 50 +- name: Merge provided configuration with device configuration + vyos.vyos.vyos_bgp_address_family: + config: + as_number: "100" + address_family: + - afi: "ipv4" + redistribute: + - protocol: "static" + metric: 50 + neighbors: + - neighbor_address: "20.33.1.1/24" + address_family: + - afi: "ipv4" + allowas_in: 4 + as_override: true + attribute_unchanged: + med: true + - afi: "ipv6" + default_originate: "map01" + distribute_list: + - action: "export" + acl: 10 + - neighbor_address: "100.11.34.12" + address_family: + - afi: "ipv4" + maximum_prefix: 45 + nexthop_self: true + route_map: + - action: "export" + route_map: "map01" + - action: "import" + route_map: "map01" + weight: 50 # After State: # vyos@vyos:~$ show configuration commands | match "set protocols bgp" @@ -410,33 +411,32 @@ EXAMPLES = """ # set protocols bgp 100 neighbor 100.11.34.12 address-family ipv4-unicast weight '50' # vyos@vyos:~$ - - name: Replace provided configuration with device configuration - vyos.vyos.vyos_bgp_address_family: - config: - as_number: "100" - neighbors: - - neighbor_address: "100.11.34.12" - address_family: - - afi: "ipv4" - allowas_in: 4 - as_override: True - attribute_unchanged: - med: True - - afi: "ipv6" - default_originate: "map01" - distribute_list: - - action: "export" - acl: 10 - - neighbor_address: "20.33.1.1/24" - address_family: - - afi: "ipv6" - maximum_prefix: 45 - nexthop_self: True - - state: replaced +- name: Replace provided configuration with device configuration + vyos.vyos.vyos_bgp_address_family: + config: + as_number: "100" + neighbors: + - neighbor_address: "100.11.34.12" + address_family: + - afi: "ipv4" + allowas_in: 4 + as_override: true + attribute_unchanged: + med: true + - afi: "ipv6" + default_originate: "map01" + distribute_list: + - action: "export" + acl: 10 + - neighbor_address: "20.33.1.1/24" + address_family: + - afi: "ipv6" + maximum_prefix: 45 + nexthop_self: true + state: replaced # After State: - +# # vyos@vyos:~$ show configuration commands | match "set protocols bgp" # set protocols bgp 100 address-family ipv4-unicast redistribute static metric '50' # set protocols bgp 100 neighbor 20.33.1.1/24 address-family ipv4-unicast @@ -600,31 +600,31 @@ EXAMPLES = """ # set protocols bgp 100 neighbor 100.11.34.12 address-family ipv6-unicast distribute-list export '10' # vyos@vyos:~$ - - name: Override - vyos.vyos.vyos_bgp_address_family: - config: - as_number: "100" - neighbors: - - neighbor_address: "100.11.34.12" - address_family: - - afi: "ipv6" - maximum_prefix: 45 - nexthop_self: True - route_map: - - action: "import" - route_map: "map01" - address_family: - - afi: "ipv4" - aggregate_address: - - prefix: "60.9.2.0/24" - summary_only: True - - afi: "ipv6" - redistribute: - - protocol: "static" - metric: 50 - state: overridden +- name: Override + vyos.vyos.vyos_bgp_address_family: + config: + as_number: "100" + neighbors: + - neighbor_address: "100.11.34.12" + address_family: + - afi: "ipv6" + maximum_prefix: 45 + nexthop_self: true + route_map: + - action: "import" + route_map: "map01" + address_family: + - afi: "ipv4" + aggregate_address: + - prefix: "60.9.2.0/24" + summary_only: true + - afi: "ipv6" + redistribute: + - protocol: "static" + metric: 50 + state: overridden -# Aft=validate-moduleser State +# After State # vyos@vyos:~$ show configuration commands | match "set protocols bgp" # set protocols bgp 100 address-family ipv4-unicast aggregate-address 60.9.2.0/24 summary-only @@ -799,18 +799,18 @@ EXAMPLES = """ # set protocols bgp 100 neighbor 100.11.34.12 address-family ipv6-unicast route-map import 'map01' # vyos@vyos:~$ - - name: Delete - vyos.vyos.vyos_bgp_address_family: - config: - as_number: "100" - neighbors: - - neighbor_address: "20.33.1.1/24" - address_family: - - afi: "ipv6" - - neighbor_address: "100.11.34.12" - address_family: - - afi: "ipv4" - state: deleted +- name: Delete + vyos.vyos.vyos_bgp_address_family: + config: + as_number: "100" + neighbors: + - neighbor_address: "20.33.1.1/24" + address_family: + - afi: "ipv6" + - neighbor_address: "100.11.34.12" + address_family: + - afi: "ipv4" + state: deleted # After State: @@ -961,12 +961,13 @@ EXAMPLES = """ # set protocols bgp 65536 neighbor 203.0.113.5 address-family ipv6-unicast attribute-unchanged next-hop - - name: parse configs - vyos.vyos.vyos_bgp_address_family: - running_config: "{{ lookup('file', './parsed.cfg') }}" - state: parsed +- name: parse configs + vyos.vyos.vyos_bgp_address_family: + running_config: "{{ lookup('file', './parsed.cfg') }}" + state: parsed -# Module Execution: +# Module execution result: +# # "parsed": { # "address_family": [ # { @@ -1044,12 +1045,12 @@ EXAMPLES = """ # set protocols bgp 100 neighbor 20.33.1.1/24 address-family ipv4-unicast attribute-unchanged med # set protocols bgp 100 neighbor 100.11.34.12 - - name: gather configs - vyos.vyos.vyos_bgp_address_family: - state: gathered - -# Module Execution: +- name: gather configs + vyos.vyos.vyos_bgp_address_family: + state: gathered +# Module execution result: +# # "gathered": { # "address_family": [ # { @@ -1108,40 +1109,40 @@ EXAMPLES = """ # Using rendered: - - name: Render - vyos.vyos.vyos_bgp_address_family: - config: - as_number: "100" - address_family: - - afi: "ipv4" - redistribute: - - protocol: "static" - metric: 50 - neighbors: - - neighbor_address: "20.33.1.1/24" - address_family: - - afi: "ipv4" - allowas_in: 4 - as_override: True - attribute_unchanged: - med: True - - afi: "ipv6" - default_originate: "map01" - distribute_list: - - action: "export" - acl: 10 - - neighbor_address: "100.11.34.12" - address_family: - - afi: "ipv4" - maximum_prefix: 45 - nexthop_self: True - route_map: - - action: "export" - route_map: "map01" - - action: "import" - route_map: "map01" - weight: 50 - state: rendered +- name: Render + vyos.vyos.vyos_bgp_address_family: + config: + as_number: "100" + address_family: + - afi: "ipv4" + redistribute: + - protocol: "static" + metric: 50 + neighbors: + - neighbor_address: "20.33.1.1/24" + address_family: + - afi: "ipv4" + allowas_in: 4 + as_override: true + attribute_unchanged: + med: true + - afi: "ipv6" + default_originate: "map01" + distribute_list: + - action: "export" + acl: 10 + - neighbor_address: "100.11.34.12" + address_family: + - afi: "ipv4" + maximum_prefix: 45 + nexthop_self: true + route_map: + - action: "export" + route_map: "map01" + - action: "import" + route_map: "map01" + weight: 50 + state: rendered # Module Execution: @@ -1158,8 +1159,6 @@ EXAMPLES = """ # "set protocols bgp 100 neighbor 100.11.34.12 address-family ipv4-unicast route-map import map01", # "set protocols bgp 100 neighbor 100.11.34.12 address-family ipv4-unicast weight 50" # ] - - """ from ansible.module_utils.basic import AnsibleModule diff --git a/plugins/modules/vyos_bgp_global.py b/plugins/modules/vyos_bgp_global.py index 1e3578d..f9c0eeb 100644 --- a/plugins/modules/vyos_bgp_global.py +++ b/plugins/modules/vyos_bgp_global.py @@ -28,6 +28,7 @@ The module file for vyos_bgp_global from __future__ import absolute_import, division, print_function + __metaclass__ = type DOCUMENTATION = """ @@ -432,63 +433,62 @@ EXAMPLES = """ # vyos@vyos:~$ show configuration commands | match "set protocols bgp" # vyos@vyos:~$ - - name: Merge provided configuration with device configuration - vyos.vyos.vyos_bgp_global: - config: - as_number: "65536" - aggregate_address: - - prefix: "203.0.113.0/24" - as_set: true - - prefix: "192.0.2.0/24" - summary_only: true - network: - - address: "192.1.13.0/24" - backdoor: true - redistribute: - - protocol: "kernel" - metric: 45 - - protocol: "connected" - route_map: "map01" - maximum_paths: - - path: "ebgp" - count: 20 - - path: "ibgp" - count: 55 - timers: - keepalive: 35 - bgp_params: - bestpath: - as_path: "confed" - compare_routerid: true - default: - no_ipv4_unicast: true - router_id: "192.1.2.9" - confederation: - - peers: 20 - - peers: 55 - - identifier: 66 - neighbor: - - address: "192.0.2.25" - disable_connected_check: true - timers: - holdtime: 30 - keepalive: 10 - - address: "203.0.113.5" - attribute_unchanged: - as_path: true - med: true - ebgp_multihop: 2 - remote_as: 101 - update_source: "192.0.2.25" - - address: "5001::64" - maximum_prefix: 34 - distribute_list: - - acl: 20 - action: "export" - - acl: 40 - action: "import" - - state: merged +- name: Merge provided configuration with device configuration + vyos.vyos.vyos_bgp_global: + config: + as_number: "65536" + aggregate_address: + - prefix: "203.0.113.0/24" + as_set: true + - prefix: "192.0.2.0/24" + summary_only: true + network: + - address: "192.1.13.0/24" + backdoor: true + redistribute: + - protocol: "kernel" + metric: 45 + - protocol: "connected" + route_map: "map01" + maximum_paths: + - path: "ebgp" + count: 20 + - path: "ibgp" + count: 55 + timers: + keepalive: 35 + bgp_params: + bestpath: + as_path: "confed" + compare_routerid: true + default: + no_ipv4_unicast: true + router_id: "192.1.2.9" + confederation: + - peers: 20 + - peers: 55 + - identifier: 66 + neighbor: + - address: "192.0.2.25" + disable_connected_check: true + timers: + holdtime: 30 + keepalive: 10 + - address: "203.0.113.5" + attribute_unchanged: + as_path: true + med: true + ebgp_multihop: 2 + remote_as: 101 + update_source: "192.0.2.25" + - address: "5001::64" + maximum_prefix: 34 + distribute_list: + - acl: 20 + action: "export" + - acl: 40 + action: "import" + state: merged # After State # vyos@vyos:~$ show configuration commands | match "set protocols bgp" @@ -688,26 +688,25 @@ EXAMPLES = """ # set protocols bgp 65536 timers keepalive '35' # vyos@vyos:~$ - - name: Replace - vyos.vyos.vyos_bgp_global: - config: - as_number: "65536" - network: - - address: "203.0.113.0/24" - route_map: map01 - redistribute: - - protocol: "static" - route_map: "map01" - neighbor: - - address: "192.0.2.40" - advertisement_interval: 72 - capability: - orf: "receive" - bgp_params: - bestpath: - as_path: "confed" - - state: replaced +- name: Replace + vyos.vyos.vyos_bgp_global: + config: + as_number: "65536" + network: + - address: "203.0.113.0/24" + route_map: map01 + redistribute: + - protocol: "static" + route_map: "map01" + neighbor: + - address: "192.0.2.40" + advertisement_interval: 72 + capability: + orf: "receive" + bgp_params: + bestpath: + as_path: "confed" + state: replaced # After state: # vyos@vyos:~$ show configuration commands | match "set protocols bgp" @@ -885,11 +884,11 @@ EXAMPLES = """ # set protocols bgp 65536 redistribute static route-map 'map01' # vyos@vyos:~$ - - name: Delete configuration - vyos.vyos.vyos_bgp_global: - config: - as_number: "65536" - state: deleted +- name: Delete configuration + vyos.vyos.vyos_bgp_global: + config: + as_number: "65536" + state: deleted # After state: @@ -975,11 +974,11 @@ EXAMPLES = """ # vyos@vyos:~$ - - name: Purge configuration - vyos.vyos.vyos_bgp_global: - config: - as_number: "65536" - state: purged +- name: Purge configuration + vyos.vyos.vyos_bgp_global: + config: + as_number: "65536" + state: purged # After state: @@ -1120,12 +1119,11 @@ EXAMPLES = """ # vyos@vyos:~$ ^C # vyos@vyos:~$ - - - name: Delete configuration - vyos.vyos.vyos_bgp_global: - config: - as_number: "65536" - state: deleted +- name: Delete configuration + vyos.vyos.vyos_bgp_global: + config: + as_number: "65536" + state: deleted # Module Execution: # @@ -1176,9 +1174,9 @@ EXAMPLES = """ # set protocols bgp 65536 redistribute static route-map 'map01' # vyos@vyos:~$ ^C - - name: gather configs - vyos.vyos.vyos_bgp_global: - state: gathered +- name: gather configs + vyos.vyos.vyos_bgp_global: + state: gathered # Module Execution: # "gathered": { @@ -1268,12 +1266,12 @@ EXAMPLES = """ # set protocols bgp 65536 parameters distance global local '10' # set protocols bgp 65536 redistribute static route-map 'map01' - - name: parse configs - vyos.vyos.vyos_bgp_global: - running_config: "{{ lookup('file', './parsed.cfg') }}" - state: parsed - tags: - - parsed +- name: parse configs + vyos.vyos.vyos_bgp_global: + running_config: "{{ lookup('file', './parsed.cfg') }}" + state: parsed + tags: + - parsed # Module execution: # "parsed": { @@ -1340,49 +1338,48 @@ EXAMPLES = """ # Using rendered: # -------------- - - name: Render - vyos.vyos.vyos_bgp_global: - config: - as_number: "65536" - network: - - address: "203.0.113.0/24" - route_map: map01 - redistribute: - - protocol: "static" - route_map: "map01" - bgp_params: - always_compare_med: true - dampening: - start_suppress_time: 5 - max_suppress_time: 20 - half_life: 33 - re_use: 60 - distance: - - type: "internal" - value: 20 - - type: "local" - value: 10 - - type: "external" - value: 66 - bestpath: - as_path: "confed" - compare_routerid: true - default: - no_ipv4_unicast: true - neighbor: - - address: "192.0.2.43" - disable_connected_check: true - advertisement_interval: 72 - capability: - dynamic: true - timers: - holdtime: 30 - keepalive: 10 - - address: "203.0.113.0" - capability: - orf: "receive" - - state: rendered +- name: Render + vyos.vyos.vyos_bgp_global: + config: + as_number: "65536" + network: + - address: "203.0.113.0/24" + route_map: map01 + redistribute: + - protocol: "static" + route_map: "map01" + bgp_params: + always_compare_med: true + dampening: + start_suppress_time: 5 + max_suppress_time: 20 + half_life: 33 + re_use: 60 + distance: + - type: "internal" + value: 20 + - type: "local" + value: 10 + - type: "external" + value: 66 + bestpath: + as_path: "confed" + compare_routerid: true + default: + no_ipv4_unicast: true + neighbor: + - address: "192.0.2.43" + disable_connected_check: true + advertisement_interval: 72 + capability: + dynamic: true + timers: + holdtime: 30 + keepalive: 10 + - address: "203.0.113.0" + capability: + orf: "receive" + state: rendered # Module Execution: # "rendered": [ @@ -1406,8 +1403,6 @@ EXAMPLES = """ # "set protocols bgp 65536 parameters bestpath compare-routerid", # "set protocols bgp 65536 parameters default no-ipv4-unicast" # ] - - """ from ansible.module_utils.basic import AnsibleModule diff --git a/plugins/modules/vyos_command.py b/plugins/modules/vyos_command.py index 2ed920c..bacbe26 100644 --- a/plugins/modules/vyos_command.py +++ b/plugins/modules/vyos_command.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -97,26 +98,26 @@ EXAMPLES = """ - name: show configuration on ethernet devices eth0 and eth1 vyos.vyos.vyos_command: commands: - - show interfaces ethernet {{ item }} + - show interfaces ethernet {{ item }} with_items: - - eth0 - - eth1 + - eth0 + - eth1 - name: run multiple commands and check if version output contains specific version string vyos.vyos.vyos_command: commands: - - show version - - show hardware cpu + - show version + - show hardware cpu wait_for: - - result[0] contains 'VyOS 1.1.7' + - result[0] contains 'VyOS 1.1.7' - name: run command that requires answering a prompt vyos.vyos.vyos_command: commands: - - command: rollback 1 - prompt: Proceed with reboot? [confirm][y] - answer: y + - command: rollback 1 + prompt: Proceed with reboot? [confirm][y] + answer: y """ RETURN = """ @@ -164,7 +165,7 @@ def parse_commands(module, warnings): if not item["command"].startswith("show"): warnings.append( "Only show commands are supported when using check mode, not " - "executing %s" % item["command"] + "executing %s" % item["command"], ) commands.remove(item) diff --git a/plugins/modules/vyos_config.py b/plugins/modules/vyos_config.py index 2a03d0c..bf5d421 100644 --- a/plugins/modules/vyos_config.py +++ b/plugins/modules/vyos_config.py @@ -17,6 +17,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -128,14 +129,14 @@ EXAMPLES = """ - name: configure the remote device vyos.vyos.vyos_config: lines: - - set system host-name {{ inventory_hostname }} - - set service lldp - - delete service dhcp-server + - set system host-name {{ inventory_hostname }} + - set service lldp + - delete service dhcp-server - name: backup and load from file vyos.vyos.vyos_config: src: vyos.cfg - backup: yes + backup: true - name: render a Jinja2 template onto the VyOS router vyos.vyos.vyos_config: @@ -145,11 +146,11 @@ EXAMPLES = """ vyos.vyos.vyos_config: lines: # - set int eth eth2 description 'OUTSIDE' - - set interface ethernet eth2 description 'OUTSIDE' + - set interface ethernet eth2 description 'OUTSIDE' - name: configurable backup path vyos.vyos.vyos_config: - backup: yes + backup: true backup_options: filename: backup.cfg dir_path: /home/user @@ -205,9 +206,12 @@ from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.vyos import run_commands, ) + DEFAULT_COMMENT = "configured by vyos_config" -CONFIG_FILTERS = [re.compile(r"set system login user \S+ authentication encrypted-password")] +CONFIG_FILTERS = [ + re.compile(r"set system login user \S+ authentication encrypted-password"), +] def get_candidate(module): @@ -312,7 +316,7 @@ def run(module, result): if result.get("filtered"): result["warnings"].append( - "Some configuration commands were removed, please see the filtered key" + "Some configuration commands were removed, please see the filtered key", ) result["changed"] = True diff --git a/plugins/modules/vyos_facts.py b/plugins/modules/vyos_facts.py index ae7543c..a999bd3 100644 --- a/plugins/modules/vyos_facts.py +++ b/plugins/modules/vyos_facts.py @@ -5,6 +5,7 @@ # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function + __metaclass__ = type """ The module file for vyos_facts @@ -75,15 +76,15 @@ EXAMPLES = """ # Collect only the interfaces facts - vyos.vyos.vyos_facts: gather_subset: - - '!all' - - '!min' + - '!all' + - '!min' gather_network_resources: - - interfaces + - interfaces # Do not collect interfaces facts - vyos.vyos.vyos_facts: gather_network_resources: - - '!interfaces' + - '!interfaces' # Collect interfaces and minimal default facts - vyos.vyos.vyos_facts: diff --git a/plugins/modules/vyos_firewall_global.py b/plugins/modules/vyos_firewall_global.py index 78db9f3..205ef13 100644 --- a/plugins/modules/vyos_firewall_global.py +++ b/plugins/modules/vyos_firewall_global.py @@ -28,6 +28,7 @@ The module file for vyos_firewall_global from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -297,30 +298,30 @@ EXAMPLES = """ all: true broadcast: true state_policy: - - connection_type: established - action: accept - log: true - - connection_type: invalid - action: reject + - connection_type: established + action: accept + log: true + - connection_type: invalid + action: reject route_redirects: - - afi: ipv4 - ip_src_route: true - icmp_redirects: - send: true - receive: false + - afi: ipv4 + ip_src_route: true + icmp_redirects: + send: true + receive: false group: address_group: - - name: MGMT-HOSTS - description: This group has the Management hosts address list - members: - - address: 192.0.1.1 - - address: 192.0.1.3 - - address: 192.0.1.5 + - name: MGMT-HOSTS + description: This group has the Management hosts address list + members: + - address: 192.0.1.1 + - address: 192.0.1.3 + - address: 192.0.1.5 network_group: - - name: MGMT - description: This group has the Management network addresses - members: - - address: 192.0.1.0/24 + - name: MGMT + description: This group has the Management network addresses + members: + - address: 192.0.1.0/24 state: merged # # @@ -676,6 +677,7 @@ EXAMPLES = """ # ] # # "after": [] +# # After state # ------------ # vyos@192# run show configuration commands | grep firewall @@ -707,7 +709,7 @@ EXAMPLES = """ # set firewall state-policy invalid action 'reject' # set firewall syn-cookies 'enable' # set firewall twa-hazards-protection 'enable' -# + - name: Replace firewall global attributes configuration. vyos.vyos.vyos_firewall_global: config: @@ -716,39 +718,39 @@ EXAMPLES = """ log_martians: true syn_cookies: true twa_hazards_protection: true - ping: + ping: null all: true broadcast: true state_policy: - - connection_type: established - action: accept - log: true - - connection_type: invalid - action: reject + - connection_type: established + action: accept + log: true + - connection_type: invalid + action: reject route_redirects: - - afi: ipv4 - ip_src_route: true - icmp_redirects: - send: true - receive: false + - afi: ipv4 + ip_src_route: true + icmp_redirects: + send: true + receive: false group: address_group: - - name: SALES-HOSTS - description: Sales office hosts address list - members: - - address: 192.0.2.1 - - address: 192.0.2.2 - - address: 192.0.2.3 - - name: ENG-HOSTS - description: Sales office hosts address list - members: - - address: 192.0.3.1 - - address: 192.0.3.2 + - name: SALES-HOSTS + description: Sales office hosts address list + members: + - address: 192.0.2.1 + - address: 192.0.2.2 + - address: 192.0.2.3 + - name: ENG-HOSTS + description: Sales office hosts address list + members: + - address: 192.0.3.1 + - address: 192.0.3.2 network_group: - - name: MGMT - description: This group has the Management network addresses - members: - - address: 192.0.1.0/24 + - name: MGMT + description: This group has the Management network addresses + members: + - address: 192.0.1.0/24 state: replaced # # @@ -966,7 +968,6 @@ EXAMPLES = """ # - name: Gather firewall global config with provided configurations vyos.vyos.vyos_firewall_global: - config: state: gathered # # @@ -1089,40 +1090,41 @@ EXAMPLES = """ log_martians: true syn_cookies: true twa_hazards_protection: true - ping: + ping: null all: true broadcast: true state_policy: - - connection_type: established - action: accept - log: true - - connection_type: invalid - action: reject + - connection_type: established + action: accept + log: true + - connection_type: invalid + action: reject route_redirects: - - afi: ipv4 - ip_src_route: true - icmp_redirects: - send: true - receive: false + - afi: ipv4 + ip_src_route: true + icmp_redirects: null + send: true + receive: false group: address_group: - - name: SALES-HOSTS - description: Sales office hosts address list - members: - - address: 192.0.2.1 - - address: 192.0.2.2 - - address: 192.0.2.3 - - name: ENG-HOSTS - description: Sales office hosts address list - members: - - address: 192.0.3.1 - - address: 192.0.3.2 + - name: SALES-HOSTS + description: Sales office hosts address list + members: + - address: 192.0.2.1 + - address: 192.0.2.2 + - address: 192.0.2.3 + - name: ENG-HOSTS + description: Sales office hosts address list + members: + - address: 192.0.3.1 + - address: 192.0.3.2 network_group: - - name: MGMT - description: This group has the Management network addresses - members: - - address: 192.0.1.0/24 + - name: MGMT + description: This group has the Management network addresses + members: + - address: 192.0.1.0/24 state: rendered + # # # ------------------------- diff --git a/plugins/modules/vyos_firewall_interfaces.py b/plugins/modules/vyos_firewall_interfaces.py index f651263..11f3e52 100644 --- a/plugins/modules/vyos_firewall_interfaces.py +++ b/plugins/modules/vyos_firewall_interfaces.py @@ -28,6 +28,7 @@ The module file for vyos_firewall_interfaces from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -123,34 +124,34 @@ EXAMPLES = """ - name: Merge the provided configuration with the existing running configuration vyos.vyos.vyos_firewall_interfaces: config: - - access_rules: - - afi: ipv4 - rules: - - name: INBOUND - direction: in - - name: OUTBOUND - direction: out - - name: LOCAL - direction: local - - afi: ipv6 - rules: - - name: V6-LOCAL - direction: local - name: eth1 - - access_rules: - - afi: ipv4 - rules: - - name: INBOUND - direction: in - - name: OUTBOUND - direction: out - - name: LOCAL - direction: local - - afi: ipv6 - rules: - - name: V6-LOCAL - direction: local - name: eth3 + - access_rules: + - afi: ipv4 + rules: + - name: INBOUND + direction: in + - name: OUTBOUND + direction: out + - name: LOCAL + direction: local + - afi: ipv6 + rules: + - name: V6-LOCAL + direction: local + name: eth1 + - access_rules: + - afi: ipv4 + rules: + - name: INBOUND + direction: in + - name: OUTBOUND + direction: out + - name: LOCAL + direction: local + - afi: ipv6 + rules: + - name: V6-LOCAL + direction: local + name: eth3 state: merged # # @@ -295,15 +296,16 @@ EXAMPLES = """ - name: Merge the provided configuration with the existing running configuration vyos.vyos.vyos_firewall_interfaces: config: - - access_rules: - - afi: ipv4 - rules: - - name: OUTBOUND - direction: in - - name: INBOUND - direction: out - name: eth1 + - access_rules: + - afi: ipv4 + rules: + - name: OUTBOUND + direction: in + - name: INBOUND + direction: out + name: eth1 state: merged + # # # ------------------------- @@ -494,27 +496,29 @@ EXAMPLES = """ # set interfaces ethernet eth3 firewall local name 'LOCAL' # set interfaces ethernet eth3 firewall out name 'OUTBOUND' # -- name: Replace device configurations of listed firewall interfaces with provided +- name: >- + Replace device configurations of listed firewall interfaces with provided configurations vyos.vyos.vyos_firewall_interfaces: config: - - name: eth1 - access_rules: - - afi: ipv4 - rules: - - name: OUTBOUND - direction: out - - afi: ipv6 - rules: - - name: V6-LOCAL - direction: local - - name: eth3 - access_rules: - - afi: ipv4 - rules: - - name: INBOUND - direction: in + - name: eth1 + access_rules: + - afi: ipv4 + rules: + - name: OUTBOUND + direction: out + - afi: ipv6 + rules: + - name: V6-LOCAL + direction: local + - name: eth3 + access_rules: + - afi: ipv4 + rules: + - name: INBOUND + direction: in state: replaced + # # # ------------------------- @@ -682,12 +686,12 @@ EXAMPLES = """ - name: Overrides all device configuration with provided configuration vyos.vyos.vyos_firewall_interfaces: config: - - name: eth3 - access_rules: - - afi: ipv4 - rules: - - name: INBOUND - direction: out + - name: eth3 + access_rules: + - afi: ipv4 + rules: + - name: INBOUND + direction: out state: overridden # # @@ -809,8 +813,8 @@ EXAMPLES = """ - name: Delete firewall interfaces based on interface name. vyos.vyos.vyos_firewall_interfaces: config: - - name: eth1 - - name: eth3 + - name: eth1 + - name: eth3 state: deleted # # @@ -938,10 +942,10 @@ EXAMPLES = """ - name: Delete firewall interfaces config per afi. vyos.vyos.vyos_firewall_interfaces: config: - - name: eth1 - access_rules: - - afi: ipv4 - - afi: ipv6 + - name: eth1 + access_rules: + - afi: ipv4 + - afi: ipv6 state: deleted # # @@ -964,7 +968,6 @@ EXAMPLES = """ # set firewall name 'LOCAL' # set firewall name 'OUTBOUND' - # Using deleted without config # # Before state @@ -986,7 +989,6 @@ EXAMPLES = """ # - name: Delete firewall interfaces config when empty config provided. vyos.vyos.vyos_firewall_interfaces: - config: state: deleted # # @@ -1010,7 +1012,6 @@ EXAMPLES = """ # Using parsed # -# - name: Parse the provided configuration vyos.vyos.vyos_firewall_interfaces: running_config: @@ -1121,7 +1122,6 @@ EXAMPLES = """ # - name: Gather listed firewall interfaces. vyos.vyos.vyos_firewall_interfaces: - config: state: gathered # # @@ -1198,17 +1198,18 @@ EXAMPLES = """ - name: Render the commands for provided configuration vyos.vyos.vyos_firewall_interfaces: config: - - name: eth2 - access_rules: - - afi: ipv4 - rules: - - direction: in - name: INGRESS - - direction: out - name: OUTGRESS - - direction: local - name: DROP + - name: eth2 + access_rules: + - afi: ipv4 + rules: + - direction: in + name: INGRESS + - direction: out + name: OUTGRESS + - direction: local + name: DROP state: rendered + # # # ------------------------- @@ -1222,8 +1223,6 @@ EXAMPLES = """ # "set interfaces ethernet eth2 firewall local name 'DROP'", # "set interfaces ethernet eth2 firewall local ipv6-name 'LOCAL'" # ] - - """ RETURN = """ before: diff --git a/plugins/modules/vyos_firewall_rules.py b/plugins/modules/vyos_firewall_rules.py index c219f54..06a300f 100644 --- a/plugins/modules/vyos_firewall_rules.py +++ b/plugins/modules/vyos_firewall_rules.py @@ -28,6 +28,7 @@ The module file for vyos_firewall_rules from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -440,13 +441,13 @@ EXAMPLES = """ # set firewall name Downlink rule 502 action 'reject' # set firewall name Downlink rule 502 description 'Rule 502 is configured by Ansible' # set firewall name Downlink rule 502 ipsec 'match-ipsec' -# + - name: Delete attributes of given firewall rules. vyos.vyos.vyos_firewall_rules: config: - - afi: ipv4 - rule_sets: - - name: Downlink + - afi: ipv4 + rule_sets: + - name: Downlink state: deleted # # @@ -517,11 +518,10 @@ EXAMPLES = """ # set firewall name Downlink rule 502 description 'Rule 502 is configured by Ansible' # set firewall name Downlink rule 502 ipsec 'match-ipsec' -# - name: Delete attributes of given firewall rules. vyos.vyos.vyos_firewall_rules: config: - - afi: ipv4 + - afi: ipv4 state: deleted # # @@ -617,7 +617,6 @@ EXAMPLES = """ # - name: Delete attributes of given firewall rules. vyos.vyos.vyos_firewall_rules: - config: state: deleted # # @@ -673,48 +672,47 @@ EXAMPLES = """ - name: Merge the provided configuration with the existing running configuration vyos.vyos.vyos_firewall_rules: config: - - afi: ipv6 - rule_sets: - - name: UPLINK - description: This is ipv6 specific rule-set - default_action: accept - rules: - - number: 1 - action: accept - description: Fwipv6-Rule 1 is configured by Ansible - ipsec: match-ipsec - - number: 2 - action: accept - description: Fwipv6-Rule 2 is configured by Ansible - ipsec: match-ipsec - - - afi: ipv4 - rule_sets: - - name: INBOUND - description: IPv4 INBOUND rule set - default_action: accept - rules: - - number: 101 - action: accept - description: Rule 101 is configured by Ansible - ipsec: match-ipsec - - number: 102 - action: reject - description: Rule 102 is configured by Ansible - ipsec: match-ipsec - - number: 103 - action: accept - description: Rule 103 is configured by Ansible - destination: - group: - address_group: inbound - source: - address: 192.0.2.0 - state: - established: true - new: false - invalid: false - related: true + - afi: ipv6 + rule_sets: + - name: UPLINK + description: This is ipv6 specific rule-set + default_action: accept + rules: + - number: 1 + action: accept + description: Fwipv6-Rule 1 is configured by Ansible + ipsec: match-ipsec + - number: 2 + action: accept + description: Fwipv6-Rule 2 is configured by Ansible + ipsec: match-ipsec + - afi: ipv4 + rule_sets: + - name: INBOUND + description: IPv4 INBOUND rule set + default_action: accept + rules: + - number: 101 + action: accept + description: Rule 101 is configured by Ansible + ipsec: match-ipsec + - number: 102 + action: reject + description: Rule 102 is configured by Ansible + ipsec: match-ipsec + - number: 103 + action: accept + description: Rule 103 is configured by Ansible + destination: + group: + address_group: inbound + source: + address: 192.0.2.0 + state: + established: true + new: false + invalid: false + related: true state: merged # # @@ -889,28 +887,30 @@ EXAMPLES = """ # set firewall name INBOUND rule 103 state new 'disable' # set firewall name INBOUND rule 103 state related 'enable' # -- name: Replace device configurations of listed firewall rules with provided configurations +- name: >- + Replace device configurations of listed firewall rules with provided + configurations vyos.vyos.vyos_firewall_rules: config: - - afi: ipv6 - rule_sets: - - name: UPLINK - description: This is ipv6 specific rule-set - default_action: accept - - afi: ipv4 - rule_sets: - - name: INBOUND - description: IPv4 INBOUND rule set - default_action: accept - rules: - - number: 101 - action: accept - description: Rule 101 is configured by Ansible - ipsec: match-ipsec - - number: 104 - action: reject - description: Rule 104 is configured by Ansible - ipsec: match-none + - afi: ipv6 + rule_sets: + - name: UPLINK + description: This is ipv6 specific rule-set + default_action: accept + - afi: ipv4 + rule_sets: + - name: INBOUND + description: IPv4 INBOUND rule set + default_action: accept + rules: + - number: 101 + action: accept + description: Rule 101 is configured by Ansible + ipsec: match-ipsec + - number: 104 + action: reject + description: Rule 104 is configured by Ansible + ipsec: match-none state: replaced # # @@ -1074,21 +1074,22 @@ EXAMPLES = """ - name: Overrides all device configuration with provided configuration vyos.vyos.vyos_firewall_rules: config: - - afi: ipv4 - rule_sets: - - name: Downlink - description: IPv4 INBOUND rule set - default_action: accept - rules: - - number: 501 - action: accept - description: Rule 501 is configured by Ansible - ipsec: match-ipsec - - number: 502 - action: reject - description: Rule 502 is configured by Ansible - ipsec: match-ipsec + - afi: ipv4 + rule_sets: + - name: Downlink + description: IPv4 INBOUND rule set + default_action: accept + rules: + - number: 501 + action: accept + description: Rule 501 is configured by Ansible + ipsec: match-ipsec + - number: 502 + action: reject + description: Rule 502 is configured by Ansible + ipsec: match-ipsec state: overridden + # # # ------------------------- @@ -1224,7 +1225,6 @@ EXAMPLES = """ # - name: Gather listed firewall rules with provided configurations vyos.vyos.vyos_firewall_rules: - config: state: gathered # # @@ -1340,39 +1340,40 @@ EXAMPLES = """ - name: Render the commands for provided configuration vyos.vyos.vyos_firewall_rules: config: - - afi: ipv6 - rule_sets: - - name: UPLINK - description: This is ipv6 specific rule-set - default_action: accept - - afi: ipv4 - rule_sets: - - name: INBOUND - description: IPv4 INBOUND rule set - default_action: accept - rules: - - number: 101 - action: accept - description: Rule 101 is configured by Ansible - ipsec: match-ipsec - - number: 102 - action: reject - description: Rule 102 is configured by Ansible - ipsec: match-ipsec - - number: 103 - action: accept - description: Rule 103 is configured by Ansible - destination: - group: - address_group: inbound - source: - address: 192.0.2.0 - state: - established: true - new: false - invalid: false - related: true + - afi: ipv6 + rule_sets: + - name: UPLINK + description: This is ipv6 specific rule-set + default_action: accept + - afi: ipv4 + rule_sets: + - name: INBOUND + description: IPv4 INBOUND rule set + default_action: accept + rules: + - number: 101 + action: accept + description: Rule 101 is configured by Ansible + ipsec: match-ipsec + - number: 102 + action: reject + description: Rule 102 is configured by Ansible + ipsec: match-ipsec + - number: 103 + action: accept + description: Rule 103 is configured by Ansible + destination: + group: + address_group: inbound + source: + address: 192.0.2.0 + state: + established: true + new: false + invalid: false + related: true state: rendered + # # # ------------------------- @@ -1454,8 +1455,6 @@ EXAMPLES = """ # ] # } # ] - - """ RETURN = """ before: diff --git a/plugins/modules/vyos_hostname.py b/plugins/modules/vyos_hostname.py index 46b692a..bc039b5 100644 --- a/plugins/modules/vyos_hostname.py +++ b/plugins/modules/vyos_hostname.py @@ -10,6 +10,7 @@ The module file for vyos_hostname from __future__ import absolute_import, division, print_function + __metaclass__ = type DOCUMENTATION = """ @@ -73,96 +74,104 @@ options: """ EXAMPLES = """ -# Using state: merged +# Using merged +# # Before state: # ------------- # test#show configuration commands | grep host-name # set system host-name 'vyostest' -# Merged play: -# ------------ + - name: Apply the provided configuration vyos.vyos.vyos_hostname: config: hostname: vyos state: merged + # Commands Fired: # --------------- # "commands": [ # "hostname vyos", # ], +# # After state: # ------------ # test#show configuration commands | grep host-name # set system host-name 'vyos' -# Using state: deleted +# Using deleted +# # Before state: # ------------- # test#show configuration commands | grep host-name # set system host-name 'vyos' -# Deleted play: -# ------------- +# - name: Remove all existing configuration vyos.vyos.vyos_hostname: state: deleted + # Commands Fired: # --------------- # "commands": [ # "no hostname vyosTest", # ], +# # After state: # ------------ # test#show configuration commands | grep host-name -# Using state: overridden +# Using overridden +# # Before state: # ------------- # test#show configuration commands | grep host-name # set system host-name 'vyos' -# Overridden play: -# ---------------- + - name: Override commands with provided configuration vyos.vyos.vyos_hostname: config: hostname: vyosTest state: overridden + # Commands Fired: # --------------- # "commands": [ # "hostname vyosTest", # ], +# # After state: # ------------ # test#show configuration commands | grep host-name # set system host-name 'vyosTest' -# Using state: replaced +# Using replaced +# # Before state: # ------------- # test#show configuration commands | grep host-name # set system host-name 'vyosTest' -# Replaced play: -# -------------- + - name: Replace commands with provided configuration vyos.vyos.vyos_hostname: config: hostname: vyos state: replaced + # After state: # ------------ # test#show configuration commands | grep host-name # set system host-name 'vyos' -# Using state: gathered +# Using gathered +# # Before state: # ------------- -#test#show configuration commands | grep host-name +# test#show configuration commands | grep host-name # set system host-name 'vyos' -# Gathered play: -# -------------- + - name: Gather listed hostname config vyos.vyos.vyos_hostname: state: gathered + # Module Execution Result: # ------------------------ # "gathered": { diff --git a/plugins/modules/vyos_interfaces.py b/plugins/modules/vyos_interfaces.py index f0772ab..c7a2168 100644 --- a/plugins/modules/vyos_interfaces.py +++ b/plugins/modules/vyos_interfaces.py @@ -28,6 +28,7 @@ The module file for vyos_interfaces from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -167,21 +168,21 @@ EXAMPLES = """ - name: Merge provided configuration with device configuration vyos.vyos.vyos_interfaces: config: - - name: eth2 - description: Configured by Ansible - enabled: true - vifs: - - vlan_id: 200 - description: VIF 200 - ETH2 - - name: eth3 - description: Configured by Ansible - mtu: 1500 - - name: bond1 - description: Bond - 1 - mtu: 1200 - - name: vti2 - description: VTI - 2 - enabled: false + - name: eth2 + description: Configured by Ansible + enabled: true + vifs: + - vlan_id: 200 + description: VIF 200 - ETH2 + - name: eth3 + description: Configured by Ansible + mtu: 1500 + - name: bond1 + description: Bond - 1 + mtu: 1200 + - name: vti2 + description: VTI - 2 + enabled: false state: merged # Task Output @@ -299,12 +300,12 @@ EXAMPLES = """ - name: Replace device configurations of listed interfaces with provided configurations vyos.vyos.vyos_interfaces: config: - - name: eth2 - description: Replaced by Ansible - - name: eth3 - description: Replaced by Ansible - - name: eth1 - description: Replaced by Ansible + - name: eth2 + description: Replaced by Ansible + - name: eth3 + description: Replaced by Ansible + - name: eth1 + description: Replaced by Ansible state: replaced # Task Output @@ -437,15 +438,15 @@ EXAMPLES = """ - name: Overrides all device configuration with provided configuration vyos.vyos.vyos_interfaces: config: - - name: eth0 - description: Outbound Interface For The Appliance - speed: auto - duplex: auto - - name: eth2 - speed: auto - duplex: auto - - name: eth3 - mtu: 1200 + - name: eth0 + description: Outbound Interface For The Appliance + speed: auto + duplex: auto + - name: eth2 + speed: auto + duplex: auto + - name: eth3 + mtu: 1200 state: overridden # Task Output @@ -576,10 +577,10 @@ EXAMPLES = """ themselves) vyos.vyos.vyos_interfaces: config: - - name: bond1 - - name: eth1 - - name: eth2 - - name: eth3 + - name: bond1 + - name: eth1 + - name: eth2 + - name: eth3 state: deleted # Task Output @@ -693,7 +694,6 @@ EXAMPLES = """ # - name: Gather listed interfaces with provided configurations vyos.vyos.vyos_interfaces: - config: state: gathered # Task output @@ -730,30 +730,31 @@ EXAMPLES = """ - name: Render the commands for provided configuration vyos.vyos.vyos_interfaces: config: - - 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 + - name: eth0 enabled: true - - vlan_id: 101 - description: Eth1 - VIF 101 + duplex: auto + speed: auto + - name: eth1 + description: Configured by Ansible - Interface 1 + mtu: 1500 + speed: auto + duplex: auto enabled: true - - name: eth2 - description: Configured by Ansible - Interface 2 (ADMIN DOWN) - mtu: 600 - enabled: false + vifs: + - vlan_id: 100 + description: Eth1 - VIF 100 + 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 state: rendered + # Task Output # ----------- # rendered: diff --git a/plugins/modules/vyos_l3_interfaces.py b/plugins/modules/vyos_l3_interfaces.py index cdf5842..0849c29 100644 --- a/plugins/modules/vyos_l3_interfaces.py +++ b/plugins/modules/vyos_l3_interfaces.py @@ -28,6 +28,7 @@ The module file for vyos_l3_interfaces from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -141,28 +142,28 @@ EXAMPLES = """ - name: Merge provided configuration with device configuration vyos.vyos.vyos_l3_interfaces: config: - - name: eth2 - ipv4: - - address: 192.0.2.10/28 - - address: 198.51.100.40/27 - ipv6: - - address: 2001:db8:100::2/32 - - address: 2001:db8:400::10/32 - - - name: eth3 - ipv4: - - address: 203.0.113.65/26 - vifs: - - vlan_id: 101 + - name: eth2 ipv4: - - address: 192.0.2.71/28 - - address: 198.51.100.131/25 - - vlan_id: 102 + - address: 192.0.2.10/28 + - address: 198.51.100.40/27 ipv6: - - address: 2001:db8:1000::5/38 - - address: 2001:db8:1400::3/38 + - address: '2001:db8:100::2/32' + - address: '2001:db8:400::10/32' + - name: eth3 + ipv4: + - address: 203.0.113.65/26 + vifs: + - vlan_id: 101 + ipv4: + - address: 192.0.2.71/28 + - address: 198.51.100.131/25 + - vlan_id: 102 + ipv6: + - address: '2001:db8:1000::5/38' + - address: '2001:db8:1400::3/38' state: merged + # After state: # ------------- # @@ -209,13 +210,13 @@ EXAMPLES = """ - name: Replace device configurations of listed interfaces with provided configurations vyos.vyos.vyos_l3_interfaces: config: - - name: eth2 - ipv4: - - address: 192.0.2.10/24 + - name: eth2 + ipv4: + - address: 192.0.2.10/24 - - name: eth3 - ipv6: - - address: 2001:db8::11/32 + - name: eth3 + ipv6: + - address: 2001:db8::11/32 state: replaced # After state: @@ -265,13 +266,14 @@ EXAMPLES = """ - name: Overrides all device configuration with provided configuration vyos.vyos.vyos_l3_interfaces: config: - - name: eth0 - ipv4: - - address: dhcp - ipv6: - - address: dhcpv6 + - name: eth0 + ipv4: + - address: dhcp + ipv6: + - address: dhcpv6 state: overridden + # After state # ------------ # @@ -317,9 +319,9 @@ EXAMPLES = """ itself) vyos.vyos.vyos_l3_interfaces: config: - - name: eth1 - - name: eth2 - - name: eth3 + - name: eth1 + - name: eth2 + - name: eth3 state: deleted # After state @@ -357,7 +359,6 @@ EXAMPLES = """ # - name: Gather listed l3 interfaces with provided configurations vyos.vyos.vyos_l3_interfaces: - config: state: gathered # # @@ -426,17 +427,18 @@ EXAMPLES = """ - name: Render the commands for provided configuration vyos.vyos.vyos_l3_interfaces: config: - - name: eth1 - ipv4: - - address: 192.0.2.14/24 - - name: eth2 - ipv4: - - address: 192.0.2.10/24 - - address: 192.0.2.11/24 - ipv6: - - address: 2001:db8::10/32 - - address: 2001:db8::12/32 + - name: eth1 + ipv4: + - address: 192.0.2.14/24 + - name: eth2 + ipv4: + - address: 192.0.2.10/24 + - address: 192.0.2.11/24 + ipv6: + - address: '2001:db8::10/32' + - address: '2001:db8::12/32' state: rendered + # # # ------------------------- @@ -510,8 +512,6 @@ EXAMPLES = """ # "name": "eth0" # } # ] - - """ RETURN = """ before: diff --git a/plugins/modules/vyos_lag_interfaces.py b/plugins/modules/vyos_lag_interfaces.py index fb36592..0605f06 100644 --- a/plugins/modules/vyos_lag_interfaces.py +++ b/plugins/modules/vyos_lag_interfaces.py @@ -28,6 +28,7 @@ The module file for vyos_lag_interfaces from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -136,21 +137,21 @@ EXAMPLES = """ - name: Merge provided configuration with device configuration vyos.vyos.vyos_lag_interfaces: config: - - name: bond2 - mode: active-backup - members: - - member: eth2 - - member: eth1 - hash_policy: layer2 - primary: eth2 - - - name: bond3 - mode: active-backup - hash_policy: layer2+3 - members: - - member: eth3 - primary: eth3 + - name: bond2 + mode: active-backup + members: + - member: eth2 + - member: eth1 + hash_policy: layer2 + primary: eth2 + - name: bond3 + mode: active-backup + hash_policy: layer2+3 + members: + - member: eth3 + primary: eth3 state: merged + # # # ------------------------- @@ -240,11 +241,11 @@ EXAMPLES = """ - name: Replace device configurations of listed LAGs with provided configurations vyos.vyos.vyos_lag_interfaces: config: - - name: bond3 - mode: 802.3ad - hash_policy: layer2 - members: - - member: eth3 + - name: bond3 + mode: 802.3ad + hash_policy: layer2 + members: + - member: eth3 state: replaced # # @@ -345,14 +346,14 @@ EXAMPLES = """ - name: Overrides all device configuration with provided configuration vyos.vyos.vyos_lag_interfaces: config: - - name: bond3 - mode: active-backup - members: - - member: eth1 - - member: eth2 - - member: eth3 - primary: eth3 - hash_policy: layer2 + - name: bond3 + mode: active-backup + members: + - member: eth1 + - member: eth2 + - member: eth3 + primary: eth3 + hash_policy: layer2 state: overridden # # @@ -456,8 +457,8 @@ EXAMPLES = """ itself) vyos.vyos.vyos_lag_interfaces: config: - - name: bond2 - - name: bond3 + - name: bond2 + - name: bond3 state: deleted # # @@ -535,9 +536,8 @@ EXAMPLES = """ # set interfaces ethernet eth1 bond-group 'bond0' # set interfaces ethernet eth2 bond-group 'bond1' # -- name: Gather listed lag interfaces with provided configurations +- name: Gather listed lag interfaces with provided configurations vyos.vyos.vyos_lag_interfaces: - config: state: gathered # # @@ -636,19 +636,20 @@ EXAMPLES = """ - name: Render the commands for provided configuration vyos.vyos.vyos_lag_interfaces: config: - - name: bond0 - hash_policy: layer2 - members: - - member: eth1 - mode: active-backup - primary: eth1 - - name: bond1 - hash_policy: layer2+3 - members: - - member: eth2 - mode: active-backup - primary: eth2 + - name: bond0 + hash_policy: layer2 + members: + - member: eth1 + mode: active-backup + primary: eth1 + - name: bond1 + hash_policy: layer2+3 + members: + - member: eth2 + mode: active-backup + primary: eth2 state: rendered + # # # ------------------------- @@ -714,8 +715,6 @@ EXAMPLES = """ # "primary": "eth2" # } # ] - - """ RETURN = """ before: diff --git a/plugins/modules/vyos_lldp_global.py b/plugins/modules/vyos_lldp_global.py index f59327a..5d215f6 100644 --- a/plugins/modules/vyos_lldp_global.py +++ b/plugins/modules/vyos_lldp_global.py @@ -28,6 +28,7 @@ The module file for vyos_lldp_global from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -104,8 +105,8 @@ EXAMPLES = """ vyos.vyos.vyos_lldp_global: config: legacy_protocols: - - fdp - - cdp + - fdp + - cdp snmp: enable address: 192.0.2.11 state: merged @@ -166,9 +167,9 @@ EXAMPLES = """ vyos.vyos.vyos_lldp_global: config: legacy_protocols: - - edp - - sonmp - - cdp + - edp + - sonmp + - cdp address: 192.0.2.14 state: replaced # @@ -395,7 +396,7 @@ EXAMPLES = """ address: 192.0.2.17 enable: true legacy_protocols: - - cdp + - cdp state: rendered # # @@ -438,8 +439,6 @@ EXAMPLES = """ # ] # } # - - """ RETURN = """ before: diff --git a/plugins/modules/vyos_lldp_interfaces.py b/plugins/modules/vyos_lldp_interfaces.py index 9260cb6..6628f65 100644 --- a/plugins/modules/vyos_lldp_interfaces.py +++ b/plugins/modules/vyos_lldp_interfaces.py @@ -28,6 +28,7 @@ The module file for vyos_lldp_interfaces from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -110,25 +111,25 @@ options: type: str running_config: description: - - This option is used only with state I(parsed). - - The value of this option should be the output received from the VyOS device - by executing the command B(show configuration commands | grep lldp). - - The state I(parsed) reads the configuration from C(running_config) option and - transforms it into Ansible structured data as per the resource module's argspec - and the value is then returned in the I(parsed) key within the result. + - This option is used only with state I(parsed). + - The value of this option should be the output received from the VyOS device + by executing the command B(show configuration commands | grep lldp). + - The state I(parsed) reads the configuration from C(running_config) option and + transforms it into Ansible structured data as per the resource module's argspec + and the value is then returned in the I(parsed) key within the result. type: str state: description: - - The state of the configuration after module completion. + - The state of the configuration after module completion. type: str choices: - - merged - - replaced - - overridden - - deleted - - rendered - - parsed - - gathered + - merged + - replaced + - overridden + - deleted + - rendered + - parsed + - gathered default: merged """ EXAMPLES = """ @@ -142,22 +143,22 @@ EXAMPLES = """ - name: Merge provided configuration with device configuration vyos.vyos.vyos_lldp_interfaces: config: - - name: eth1 - location: - civic_based: - country_code: US - ca_info: - - ca_type: 0 - ca_value: ENGLISH - - - name: eth2 - location: - coordinate_based: - altitude: 2200 - datum: WGS84 - longitude: 222.267255W - latitude: 33.524449N + - name: eth1 + location: + civic_based: + country_code: US + ca_info: + - ca_type: 0 + ca_value: ENGLISH + - name: eth2 + location: + coordinate_based: + altitude: 2200 + datum: WGS84 + longitude: 222.267255W + latitude: 33.524449N state: merged + # # # ------------------------- @@ -233,24 +234,25 @@ EXAMPLES = """ # set service lldp interface eth2 location coordinate-based latitude '33.524449N' # set service lldp interface eth2 location coordinate-based longitude '222.267255W' # -- name: Replace device configurations of listed LLDP interfaces with provided configurations +- name: >- + Replace device configurations of listed LLDP interfaces with provided + configurations vyos.vyos.vyos_lldp_interfaces: config: - - name: eth2 - location: - civic_based: - country_code: US - ca_info: - - ca_type: 0 - ca_value: ENGLISH - - - name: eth1 - location: - coordinate_based: - altitude: 2200 - datum: WGS84 - longitude: 222.267255W - latitude: 33.524449N + - name: eth2 + location: + civic_based: + country_code: US + ca_info: + - ca_type: 0 + ca_value: ENGLISH + - name: eth1 + location: + coordinate_based: + altitude: 2200 + datum: WGS84 + longitude: 222.267255W + latitude: 33.524449N state: replaced # # @@ -359,9 +361,9 @@ EXAMPLES = """ - name: Overrides all device configuration with provided configuration vyos.vyos.vyos_lldp_interfaces: config: - - name: eth2 - location: - elin: 0000000911 + - name: eth2 + location: + elin: 0000000911 state: overridden # @@ -434,7 +436,7 @@ EXAMPLES = """ - name: Delete lldp interface attributes of given interfaces. vyos.vyos.vyos_lldp_interfaces: config: - - name: eth2 + - name: eth2 state: deleted # # @@ -525,21 +527,22 @@ EXAMPLES = """ - name: Render the commands for provided configuration vyos.vyos.vyos_lldp_interfaces: config: - - name: eth1 - location: - civic_based: - country_code: US - ca_info: - - ca_type: 0 - ca_value: ENGLISH - - name: eth2 - location: - coordinate_based: - altitude: 2200 - datum: WGS84 - longitude: 222.267255W - latitude: 33.524449N + - name: eth1 + location: + civic_based: + country_code: US + ca_info: + - ca_type: 0 + ca_value: ENGLISH + - name: eth2 + location: + coordinate_based: + altitude: 2200 + datum: WGS84 + longitude: 222.267255W + latitude: 33.524449N state: rendered + # # # ------------------------- @@ -606,8 +609,6 @@ EXAMPLES = """ # "name": "eth1" # } # ] - - """ RETURN = """ before: diff --git a/plugins/modules/vyos_logging.py b/plugins/modules/vyos_logging.py index 7e1dea7..204e4f9 100644 --- a/plugins/modules/vyos_logging.py +++ b/plugins/modules/vyos_logging.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function + __metaclass__ = type # (c) 2017, Ansible by Red Hat, inc @@ -130,16 +131,29 @@ EXAMPLES = """ - name: Add logging aggregate vyos.vyos.vyos_logging: aggregate: - - {dest: file, name: test1, facility: all, level: info} - - {dest: file, name: test2, facility: news, level: debug} + - dest: file + name: test1 + facility: all + level: info + - dest: file + name: test2 + facility: news + level: debug state: present - name: Remove logging aggregate vyos.vyos.vyos_logging: aggregate: - - {dest: console, facility: all, level: info} - - {dest: console, facility: daemon, level: warning} - - {dest: file, name: test2, facility: news, level: debug} + - dest: console + facility: all + level: info + - dest: console + facility: daemon + level: warning + - dest: file + name: test2 + facility: news + level: debug state: absent """ @@ -153,6 +167,7 @@ commands: """ import re + from copy import deepcopy from ansible.module_utils._text import to_text @@ -184,23 +199,37 @@ def spec_to_commands(updates, module): if w["name"]: commands.append( "delete system syslog {0} {1} facility {2} level {3}".format( - dest, name, facility, level - ) + dest, + name, + facility, + level, + ), ) else: commands.append( - "delete system syslog {0} facility {1} level {2}".format(dest, facility, level) + "delete system syslog {0} facility {1} level {2}".format( + dest, + facility, + level, + ), ) elif state == "present" and w not in have: if w["name"]: commands.append( "set system syslog {0} {1} facility {2} level {3}".format( - dest, name, facility, level - ) + dest, + name, + facility, + level, + ), ) else: commands.append( - "set system syslog {0} facility {1} level {2}".format(dest, facility, level) + "set system syslog {0} facility {1} level {2}".format( + dest, + facility, + level, + ), ) return commands @@ -239,7 +268,7 @@ def config_to_dict(module): "name": name, "facility": facility, "level": level, - } + }, ) return obj @@ -272,7 +301,7 @@ def map_params_to_obj(module, required_if=None): "facility": module.params["facility"], "level": module.params["level"], "state": module.params["state"], - } + }, ) return obj @@ -293,7 +322,9 @@ def main(): # remove default in aggregate spec, to handle common arguments remove_default_spec(aggregate_spec) - argument_spec = dict(aggregate=dict(type="list", elements="dict", options=aggregate_spec)) + argument_spec = dict( + aggregate=dict(type="list", elements="dict", options=aggregate_spec), + ) argument_spec.update(element_spec) diff --git a/plugins/modules/vyos_logging_global.py b/plugins/modules/vyos_logging_global.py index 18248d6..06ebe48 100644 --- a/plugins/modules/vyos_logging_global.py +++ b/plugins/modules/vyos_logging_global.py @@ -10,6 +10,7 @@ The module file for vyos_logging_global from __future__ import absolute_import, division, print_function + __metaclass__ = type DOCUMENTATION = """ @@ -220,15 +221,15 @@ EXAMPLES = """ users: - username: vyos facilities: - - facility: local7 - severity: debug + - facility: local7 + severity: debug global_params: archive: file_num: 2 size: 111 facilities: - - facility: cron - severity: debug + - facility: cron + severity: debug marker_interval: 111 preserve_fqdn: true state: merged @@ -396,10 +397,11 @@ EXAMPLES = """ users: - username: paul facilities: - - facility: local7 - severity: err + - facility: local7 + severity: err state: replaced + # Commands Fired: # --------------- diff --git a/plugins/modules/vyos_ntp_global.py b/plugins/modules/vyos_ntp_global.py index 10a2170..0fe56ad 100644 --- a/plugins/modules/vyos_ntp_global.py +++ b/plugins/modules/vyos_ntp_global.py @@ -10,6 +10,7 @@ The module file for vyos_ntp_global from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -98,18 +99,18 @@ EXAMPLES = """ - name: Replace the existing ntp config with the new config vyos.vyos.vyos_ntp_global: config: - allow_clients: - - 10.6.6.0/24 - listen_addresses: - - 10.1.3.1 - servers: - - server: 203.0.113.0 - options: - - prefer - - -# # Task output: -# # ------------- + allow_clients: + - 10.6.6.0/24 + listen_addresses: + - 10.1.3.1 + servers: + - server: 203.0.113.0 + options: + - prefer + + +# Task output: +# ------------- # "after": { # "allow_clients": [ # "10.6.6.0/24" @@ -189,14 +190,14 @@ EXAMPLES = """ - name: Replace the existing ntp config with the new config vyos.vyos.vyos_ntp_global: config: - allow_clients: - - 10.6.6.0/24 - listen_addresses: - - 10.1.3.1 - servers: - - server: 203.0.113.0 - options: - - prefer + allow_clients: + - 10.6.6.0/24 + listen_addresses: + - 10.1.3.1 + servers: + - server: 203.0.113.0 + options: + - prefer state: replaced @@ -302,8 +303,6 @@ EXAMPLES = """ # set system ntp server time3.vyos.net # vyos@vyos:~$ - - # # ------------------- # # 3. Using overridden # # ------------------- @@ -319,30 +318,28 @@ EXAMPLES = """ # set system ntp server time3.vyos.net # vyos@vyos:~$ -# # Task -# # ------------- +# Task +# ------------- - name: Override ntp config vyos.vyos.vyos_ntp_global: - config: - allow_clients: - - 10.3.3.0/24 - listen_addresses: - - 10.7.8.1 - servers: - - server: server1 - options: - - dynamic - - prefer - - - server: server2 - options: - - noselect - - preempt - - - server: serv - state: overridden - - + config: + allow_clients: + - 10.3.3.0/24 + listen_addresses: + - 10.7.8.1 + servers: + - server: server1 + options: + - dynamic + - prefer + + - server: server2 + options: + - noselect + - preempt + + - server: serv + state: overridden # # Task output: # # ------------- @@ -436,11 +433,8 @@ EXAMPLES = """ # set system ntp server time3.vyos.net # vyos@vyos:~$ - - -# # ------------------- -# # 4. Using gathered -# # ------------------- +# 4. Using gathered +# ------------------- # # Before state: # # ------------- @@ -457,11 +451,11 @@ EXAMPLES = """ # set system ntp server time3.vyos.net # vyos@vyos:~$ -# # Task -# # ------------- +# Task +# ------------- - name: Gather ntp config vyos.vyos.vyos_ntp_global: - state: gathered + state: gathered # # Task output: # # ------------- @@ -626,32 +620,27 @@ EXAMPLES = """ # set system ntp server time3.vyos.net # vyos@vyos:~$ -# # Task -# # ------------- +# Task +# ------------- - name: Render ntp config vyos.vyos.vyos_ntp_global: - config: - allow_clients: - - 10.7.7.0/24 - - 10.8.8.0/24 - listen_addresses: - - 10.7.9.1 - servers: - - server: server7 - - - server: server45 - options: - - noselect - - prefer - - pool - - server: time1.vyos.net - - - server: time2.vyos.net - - - server: time3.vyos.net - - state: rendered - + config: + allow_clients: + - 10.7.7.0/24 + - 10.8.8.0/24 + listen_addresses: + - 10.7.9.1 + servers: + - server: server7 + - server: server45 + options: + - noselect + - prefer + - pool + - server: time1.vyos.net + - server: time2.vyos.net + - server: time3.vyos.net + state: rendered # # Task output: # # ------------- @@ -685,12 +674,12 @@ EXAMPLES = """ # "set system ntp server time2.vyos.net", # "set system ntp server time3.vyos.net" -# # Task: -# # ------------- +# Task: +# ------------- - name: Parse externally provided ntp configuration vyos.vyos.vyos_ntp_global: - running_config: "{{ lookup('file', './sample_config.cfg') }}" - state: parsed + running_config: "{{ lookup('file', './sample_config.cfg') }}" + state: parsed # # Task output: # # ------------- @@ -724,7 +713,6 @@ EXAMPLES = """ # # ] # } - """ RETURN = """ before: diff --git a/plugins/modules/vyos_ospf_interfaces.py b/plugins/modules/vyos_ospf_interfaces.py index 9a78ebd..c232689 100644 --- a/plugins/modules/vyos_ospf_interfaces.py +++ b/plugins/modules/vyos_ospf_interfaces.py @@ -28,6 +28,7 @@ The module file for vyos_ospf_interfaces from __future__ import absolute_import, division, print_function + __metaclass__ = type DOCUMENTATION = """ @@ -58,7 +59,7 @@ options: - Address Family Identifier (AFI) for OSPF settings on the interfaces. type: str choices: ['ipv4', 'ipv6'] - required: True + required: true authentication: description: - Authentication settings on the interface. @@ -161,29 +162,29 @@ EXAMPLES = """ # @vyos:~$ show configuration commands | match "ospf" - - name: Merge provided configuration with device configuration - vyos.vyos.vyos_ospf_interfaces: - config: - - name: "eth1" - address_family: - - afi: "ipv4" - transmit_delay: 50 - priority: 26 - network: "point-to-point" - - afi: "ipv6" - dead_interval: 39 - - name: "bond2" - address_family: - - afi: "ipv4" - transmit_delay: 45 - bandwidth: 70 - authentication: - md5_key: - key_id: 10 - key: "1111111111232345" - - afi: "ipv6" - passive: True - state: merged +- name: Merge provided configuration with device configuration + vyos.vyos.vyos_ospf_interfaces: + config: + - name: "eth1" + address_family: + - afi: "ipv4" + transmit_delay: 50 + priority: 26 + network: "point-to-point" + - afi: "ipv6" + dead_interval: 39 + - name: "bond2" + address_family: + - afi: "ipv4" + transmit_delay: 45 + bandwidth: 70 + authentication: + md5_key: + key_id: 10 + key: "1111111111232345" + - afi: "ipv6" + passive: true + state: merged # After State: # -------------- @@ -270,9 +271,6 @@ EXAMPLES = """ # "set interfaces bonding bond2 ipv6 ospfv3 passive" # ], - - - # Using replaced: # Before State: @@ -288,22 +286,22 @@ EXAMPLES = """ # set interfaces ethernet eth1 ip ospf transmit-delay '50' # set interfaces ethernet eth1 ipv6 ospfv3 dead-interval '39' - - name: Replace provided configuration with device configuration - vyos.vyos.vyos_ospf_interfaces: - config: - - name: "eth1" - address_family: - - afi: "ipv4" - cost: 100 - - afi: "ipv6" - ifmtu: 33 - - name: "bond2" - address_family: - - afi: "ipv4" - transmit_delay: 45 - - afi: "ipv6" - passive: True - state: replaced +- name: Replace provided configuration with device configuration + vyos.vyos.vyos_ospf_interfaces: + config: + - name: "eth1" + address_family: + - afi: "ipv4" + cost: 100 + - afi: "ipv6" + ifmtu: 33 + - name: "bond2" + address_family: + - afi: "ipv4" + transmit_delay: 45 + - afi: "ipv6" + passive: true + state: replaced # After State: # ----------- @@ -432,17 +430,18 @@ EXAMPLES = """ # set interfaces ethernet eth1 ipv6 ospfv3 ifmtu '33' # vyos@vyos:~$ - - name: Override device configuration with provided configuration - vyos.vyos.vyos_ospf_interfaces: - config: - - name: "eth0" - address_family: - - afi: "ipv4" - cost: 100 - - afi: "ipv6" - ifmtu: 33 - passive: True - state: overridden +- name: Override device configuration with provided configuration + vyos.vyos.vyos_ospf_interfaces: + config: + - name: "eth0" + address_family: + - afi: "ipv4" + cost: 100 + - afi: "ipv6" + ifmtu: 33 + passive: true + state: overridden + # After State: # ----------- @@ -561,11 +560,11 @@ EXAMPLES = """ # set interfaces ethernet eth1 ipv6 ospfv3 dead-interval '39' # vyos@vyos:~$ - - name: Delete device configuration - vyos.vyos.vyos_ospf_interfaces: - config: - - name: "eth0" - state: deleted +- name: Delete device configuration + vyos.vyos.vyos_ospf_interfaces: + config: + - name: "eth0" + state: deleted # After State: # ----------- @@ -708,10 +707,10 @@ EXAMPLES = """ # set interfaces ethernet eth1 ipv6 ospfv3 dead-interval '39' # - - name: parse configs - vyos.vyos.vyos_ospf_interfaces: - running_config: "{{ lookup('file', './parsed.cfg') }}" - state: parsed +- name: parse configs + vyos.vyos.vyos_ospf_interfaces: + running_config: "{{ lookup('file', './parsed.cfg') }}" + state: parsed # Module Execution: # ---------------- @@ -772,29 +771,29 @@ EXAMPLES = """ # Using rendered: # -------------- - - name: Render - vyos.vyos.vyos_ospf_interfaces: - config: - - name: "eth1" - address_family: - - afi: "ipv4" - transmit_delay: 50 - priority: 26 - network: "point-to-point" - - afi: "ipv6" - dead_interval: 39 - - name: "bond2" - address_family: - - afi: "ipv4" - transmit_delay: 45 - bandwidth: 70 - authentication: - md5_key: - key_id: 10 - key: "1111111111232345" - - afi: "ipv6" - passive: True - state: rendered +- name: Render + vyos.vyos.vyos_ospf_interfaces: + config: + - name: "eth1" + address_family: + - afi: "ipv4" + transmit_delay: 50 + priority: 26 + network: "point-to-point" + - afi: "ipv6" + dead_interval: 39 + - name: "bond2" + address_family: + - afi: "ipv4" + transmit_delay: 45 + bandwidth: 70 + authentication: + md5_key: + key_id: 10 + key: "1111111111232345" + - afi: "ipv6" + passive: true + state: rendered # Module Execution: # ---------------- @@ -827,9 +826,9 @@ EXAMPLES = """ # set interfaces ethernet eth1 ipv6 ospfv3 dead-interval '39' # vyos@vyos:~$ - - name: gather configs - vyos.vyos.vyos_ospf_interfaces: - state: gathered +- name: gather configs + vyos.vyos.vyos_ospf_interfaces: + state: gathered # Module Execution: # ----------------- @@ -880,11 +879,6 @@ EXAMPLES = """ # "name": "eth3" # } # ], - - - - - """ from ansible.module_utils.basic import AnsibleModule diff --git a/plugins/modules/vyos_ospfv2.py b/plugins/modules/vyos_ospfv2.py index 863bc6f..10e4974 100644 --- a/plugins/modules/vyos_ospfv2.py +++ b/plugins/modules/vyos_ospfv2.py @@ -28,6 +28,7 @@ The module file for vyos_ospfv2 from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -389,42 +390,42 @@ EXAMPLES = """ auto_cost: reference_bandwidth: 2 neighbor: - - neighbor_id: 192.0.11.12 - poll_interval: 10 - priority: 2 + - neighbor_id: 192.0.11.12 + poll_interval: 10 + priority: 2 redistribute: - - route_type: bgp - metric: 10 - metric_type: 2 + - route_type: bgp + metric: 10 + metric_type: 2 passive_interface: - - eth1 - - eth2 + - eth1 + - eth2 parameters: router_id: 192.0.1.1 opaque_lsa: true rfc1583_compatibility: true abr_type: cisco areas: - - area_id: '2' - area_type: - normal: true - authentication: plaintext-password - shortcut: enable - - area_id: '3' - area_type: - nssa: - set: true - - area_id: '4' - area_type: - stub: - default_cost: 20 - network: - - address: 192.0.2.0/24 - range: - - address: 192.0.3.0/24 - cost: 10 - - address: 192.0.4.0/24 - cost: 12 + - area_id: '2' + area_type: + normal: true + authentication: plaintext-password + shortcut: enable + - area_id: '3' + area_type: + nssa: + set: true + - area_id: '4' + area_type: + stub: + default_cost: 20 + network: + - address: 192.0.2.0/24 + range: + - address: 192.0.3.0/24 + cost: 10 + - address: 192.0.4.0/24 + cost: 12 state: merged # # @@ -612,23 +613,23 @@ EXAMPLES = """ vyos.vyos.vyos_ospfv2: config: areas: - - area_id: '2' - area_type: - normal: true - authentication: plaintext-password - shortcut: enable - - area_id: '3' - area_type: - nssa: - set: false - - area_id: '4' - area_type: - stub: - default_cost: 20 - network: - - address: 192.0.2.0/24 - - address: 192.0.22.0/24 - - address: 192.0.32.0/24 + - area_id: '2' + area_type: + normal: true + authentication: plaintext-password + shortcut: enable + - area_id: '3' + area_type: + nssa: + set: false + - area_id: '4' + area_type: + stub: + default_cost: 20 + network: + - address: 192.0.2.0/24 + - address: 192.0.22.0/24 + - address: 192.0.32.0/24 state: merged # # @@ -920,39 +921,40 @@ EXAMPLES = """ auto_cost: reference_bandwidth: 2 neighbor: - - neighbor_id: 192.0.11.12 - poll_interval: 10 - priority: 2 + - neighbor_id: 192.0.11.12 + poll_interval: 10 + priority: 2 redistribute: - - route_type: bgp - metric: 10 - metric_type: 2 + - route_type: bgp + metric: 10 + metric_type: 2 passive_interface: - - eth1 + - eth1 parameters: router_id: 192.0.1.1 opaque_lsa: true rfc1583_compatibility: true abr_type: cisco areas: - - area_id: '2' - area_type: - normal: true - authentication: plaintext-password - shortcut: enable - - area_id: '4' - area_type: - stub: - default_cost: 20 - network: - - address: 192.0.2.0/24 - - address: 192.0.12.0/24 - - address: 192.0.22.0/24 - - address: 192.0.32.0/24 - range: - - address: 192.0.42.0/24 - cost: 10 + - area_id: '2' + area_type: + normal: true + authentication: plaintext-password + shortcut: enable + - area_id: '4' + area_type: + stub: + default_cost: 20 + network: + - address: 192.0.2.0/24 + - address: 192.0.12.0/24 + - address: 192.0.22.0/24 + - address: 192.0.32.0/24 + range: + - address: 192.0.42.0/24 + cost: 10 state: replaced + # # # ------------------------- @@ -1213,42 +1215,42 @@ EXAMPLES = """ auto_cost: reference_bandwidth: 2 neighbor: - - neighbor_id: 192.0.11.12 - poll_interval: 10 - priority: 2 + - neighbor_id: 192.0.11.12 + poll_interval: 10 + priority: 2 redistribute: - - route_type: bgp - metric: 10 - metric_type: 2 + - route_type: bgp + metric: 10 + metric_type: 2 passive_interface: - - eth1 - - eth2 + - eth1 + - eth2 parameters: router_id: 192.0.1.1 opaque_lsa: true rfc1583_compatibility: true abr_type: cisco areas: - - area_id: '2' - area_type: - normal: true - authentication: plaintext-password - shortcut: enable - - area_id: '3' - area_type: - nssa: - set: true - - area_id: '4' - area_type: - stub: - default_cost: 20 - network: - - address: 192.0.2.0/24 - range: - - address: 192.0.3.0/24 - cost: 10 - - address: 192.0.4.0/24 - cost: 12 + - area_id: '2' + area_type: + normal: true + authentication: plaintext-password + shortcut: enable + - area_id: '3' + area_type: + nssa: + set: true + - area_id: '4' + area_type: + stub: + default_cost: 20 + network: + - address: 192.0.2.0/24 + range: + - address: 192.0.3.0/24 + cost: 10 + - address: 192.0.4.0/24 + cost: 12 state: rendered # # @@ -1754,7 +1756,6 @@ EXAMPLES = """ # ------------ # vyos@192# run show configuration commands | grep ospf # - """ RETURN = """ before: diff --git a/plugins/modules/vyos_ospfv3.py b/plugins/modules/vyos_ospfv3.py index 4ff6106..8dbaaee 100644 --- a/plugins/modules/vyos_ospfv3.py +++ b/plugins/modules/vyos_ospfv3.py @@ -28,6 +28,7 @@ The module file for vyos_ospfv3 from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -130,21 +131,22 @@ EXAMPLES = """ vyos.vyos.vyos_ospfv3: config: redistribute: - - route_type: bgp + - route_type: bgp parameters: router_id: 192.0.2.10 areas: - - area_id: '2' - export_list: export1 - import_list: import1 - range: - - address: 2001:db10::/32 - - address: 2001:db20::/32 - - address: 2001:db30::/32 - - area_id: '3' - range: - - address: 2001:db40::/32 + - area_id: '2' + export_list: export1 + import_list: import1 + range: + - address: '2001:db10::/32' + - address: '2001:db20::/32' + - address: '2001:db30::/32' + - area_id: '3' + range: + - address: '2001:db40::/32' state: merged + # # # ------------------------- @@ -236,21 +238,22 @@ EXAMPLES = """ vyos.vyos.vyos_ospfv3: config: redistribute: - - route_type: bgp + - route_type: bgp parameters: router_id: 192.0.2.10 areas: - - area_id: '2' - export_list: export1 - import_list: import1 - range: - - address: 2001:db10::/32 - - address: 2001:db30::/32 - - address: 2001:db50::/32 - - area_id: '4' - range: - - address: 2001:db60::/32 + - area_id: '2' + export_list: export1 + import_list: import1 + range: + - address: '2001:db10::/32' + - address: '2001:db30::/32' + - address: '2001:db50::/32' + - area_id: '4' + range: + - address: '2001:db60::/32' state: replaced + # # # ------------------------- @@ -360,21 +363,22 @@ EXAMPLES = """ vyos.vyos.vyos_ospfv3: config: redistribute: - - route_type: bgp + - route_type: bgp parameters: router_id: 192.0.2.10 areas: - - area_id: '2' - export_list: export1 - import_list: import1 - range: - - address: 2001:db10::/32 - - address: 2001:db20::/32 - - address: 2001:db30::/32 - - area_id: '3' - range: - - address: 2001:db40::/32 + - area_id: '2' + export_list: export1 + import_list: import1 + range: + - address: '2001:db10::/32' + - address: '2001:db20::/32' + - address: '2001:db30::/32' + - area_id: '3' + range: + - address: '2001:db40::/32' state: rendered + # # # ------------------------- @@ -602,8 +606,6 @@ EXAMPLES = """ # After state # ------------ # vyos@192# run show configuration commands | grep ospfv3 - - """ RETURN = """ before: diff --git a/plugins/modules/vyos_ping.py b/plugins/modules/vyos_ping.py index 8c0330d..9861939 100644 --- a/plugins/modules/vyos_ping.py +++ b/plugins/modules/vyos_ping.py @@ -21,6 +21,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -217,10 +218,10 @@ def build_ping(dest, count, size=None, interval=None, source=None, ttl=None): def parse_rate(rate_info): rate_re = re.compile( - r"(?P<tx>\d+) (?:\w+) (?:\w+), (?P<rx>\d+) (?:\w+), (?P<pkt_loss>\d+)% (?:\w+) (?:\w+), (?:\w+) (?P<time>\d+)" + r"(?P<tx>\d+) (?:\w+) (?:\w+), (?P<rx>\d+) (?:\w+), (?P<pkt_loss>\d+)% (?:\w+) (?:\w+), (?:\w+) (?P<time>\d+)", ) rate_err_re = re.compile( - r"(?P<tx>\d+) (?:\w+) (?:\w+), (?P<rx>\d+) (?:\w+), (?:[+-])(?P<err>\d+) (?:\w+), (?P<pkt_loss>\d+)% (?:\w+) (?:\w+), (?:\w+) (?P<time>\d+)" + r"(?P<tx>\d+) (?:\w+) (?:\w+), (?P<rx>\d+) (?:\w+), (?:[+-])(?P<err>\d+) (?:\w+), (?P<pkt_loss>\d+)% (?:\w+) (?:\w+), (?:\w+) (?P<time>\d+)", ) if rate_re.match(rate_info): @@ -233,7 +234,7 @@ def parse_rate(rate_info): def parse_rtt(rtt_info): rtt_re = re.compile( - r"rtt (?:.*)=(?:\s*)(?P<min>\d*).(?:\d*)/(?P<avg>\d*).(?:\d*)/(?P<max>\d+).(?:\d*)/(?P<mdev>\d*)" + r"rtt (?:.*)=(?:\s*)(?P<min>\d*).(?:\d*)/(?P<avg>\d*).(?:\d*)/(?P<max>\d+).(?:\d*)/(?P<mdev>\d*)", ) rtt = rtt_re.match(rtt_info) diff --git a/plugins/modules/vyos_prefix_lists.py b/plugins/modules/vyos_prefix_lists.py index ed190d4..c0d50d3 100644 --- a/plugins/modules/vyos_prefix_lists.py +++ b/plugins/modules/vyos_prefix_lists.py @@ -10,6 +10,7 @@ The module file for vyos_prefix_lists from __future__ import absolute_import, division, print_function + __metaclass__ = type DOCUMENTATION = """ @@ -1240,7 +1241,6 @@ EXAMPLES = """ # ] # } # ] - """ RETURN = """ diff --git a/plugins/modules/vyos_route_maps.py b/plugins/modules/vyos_route_maps.py index d49261c..bff6859 100644 --- a/plugins/modules/vyos_route_maps.py +++ b/plugins/modules/vyos_route_maps.py @@ -10,6 +10,7 @@ The module file for vyos_route_maps from __future__ import absolute_import, division, print_function + __metaclass__ = type DOCUMENTATION = """ @@ -264,35 +265,35 @@ EXAMPLES = """ # vyos@vyos:~$ show configuration commands | match "set policy route-map" # vyos@vyos:~$ - - name: Merge the provided configuration with the existing running configuration - register: result - vyos.vyos.vyos_route_maps: &id001 - config: - - route_map: test1 - entries: - - sequence: 1 - description: "test" - action: permit - continue: 2 - on_match: - next: True - - route_map: test3 - entries: - - sequence: 1 - action: permit - match: - rpki: invalid - metric: 1 - peer: 192.0.2.32 - set: - local_preference: 4 - metric: 5 - metric_type: "type-1" - origin: egp - originator_id: 192.0.2.34 - tag: 5 - weight: 4 - state: merged +- name: Merge the provided configuration with the existing running configuration + register: result + vyos.vyos.vyos_route_maps: &id001 + config: + - route_map: test1 + entries: + - sequence: 1 + description: "test" + action: permit + continue: 2 + on_match: + next: true + - route_map: test3 + entries: + - sequence: 1 + action: permit + match: + rpki: invalid + metric: 1 + peer: 192.0.2.32 + set: + local_preference: 4 + metric: 5 + metric_type: "type-1" + origin: egp + originator_id: 192.0.2.34 + tag: 5 + weight: 4 + state: merged # After State # vyos@vyos:~$ show configuration commands | match "set policy route-maps" # set policy route-map test1 rule 1 description test @@ -913,8 +914,6 @@ EXAMPLES = """ # "set policy route-map test3 rule 1 match metric 3", # "set policy route-map test3 rule 1 match peer 192.0.2.35" # ], -# - """ from ansible.module_utils.basic import AnsibleModule diff --git a/plugins/modules/vyos_snmp_server.py b/plugins/modules/vyos_snmp_server.py index 74bae3f..5eb69b8 100644 --- a/plugins/modules/vyos_snmp_server.py +++ b/plugins/modules/vyos_snmp_server.py @@ -10,6 +10,7 @@ The module file for vyos_snmp_server from __future__ import absolute_import, division, print_function + __metaclass__ = type DOCUMENTATION = """ @@ -268,30 +269,29 @@ EXAMPLES = """ # vyos@vyos:~$ show configuration commands | grep snmp # vyos@vyos:~$ - - name: Merge provided configuration with device configuration - vyos.vyos.vyos_snmp_server: - config: - communities: - - name: "switches" - authorization_type: "rw" - - name: "bridges" - clients: ["1.1.1.1", "12.1.1.10"] - contact: "admin2@ex.com" - listen_addresses: - - address: "20.1.1.1" - - address: "100.1.2.1" - port: 33 - snmp_v3: - users: - - user: admin_user - authentication: - plaintext_key: "abc1234567" - type: "sha" - privacy: - plaintext_key: "abc1234567" - type: "aes" - - state: merged +- name: Merge provided configuration with device configuration + vyos.vyos.vyos_snmp_server: + config: + communities: + - name: "switches" + authorization_type: "rw" + - name: "bridges" + clients: ["1.1.1.1", "12.1.1.10"] + contact: "admin2@ex.com" + listen_addresses: + - address: "20.1.1.1" + - address: "100.1.2.1" + port: 33 + snmp_v3: + users: + - user: admin_user + authentication: + plaintext_key: "abc1234567" + type: "sha" + privacy: + plaintext_key: "abc1234567" + type: "aes" + state: merged # After State: @@ -366,9 +366,10 @@ EXAMPLES = """ # ], # -# using Replaced: +# Using replaced # Before State +# ------------- # vyos@vyos:~$ show configuration commands | grep snmp # set service snmp community bridges client '1.1.1.1' # set service snmp community bridges client '12.1.1.10' @@ -380,43 +381,42 @@ EXAMPLES = """ # set service snmp v3 user admin_user auth type 'sha' # set service snmp v3 user admin_user privacy plaintext-key 'abc1234567' # set service snmp v3 user admin_user privacy type 'aes' -# vyos@vyos:~$ - - name: Replace - vyos.vyos.vyos_snmp_server: - config: - communities: - - name: "bridges" - networks: ["1.1.1.0/24", "12.1.1.0/24"] - location: "RDU, NC" - listen_addresses: - - address: "100.1.2.1" - port: 33 - snmp_v3: - groups: - - group: "default" - view: "default" - users: - - user: admin_user - authentication: - plaintext_key: "abc1234567" - type: "sha" - privacy: - plaintext_key: "abc1234567" - type: "aes" - group: "default" - - user: guest_user2 - authentication: - plaintext_key: "opq1234567" - type: "sha" - privacy: - plaintext_key: "opq1234567" - type: "aes" - views: - - view: "default" - oid: 1 +- name: Replace SNMP Server configuration + vyos.vyos.vyos_snmp_server: + config: + communities: + - name: "bridges" + networks: ["1.1.1.0/24", "12.1.1.0/24"] + location: "RDU, NC" + listen_addresses: + - address: "100.1.2.1" + port: 33 + snmp_v3: + groups: + - group: "default" + view: "default" + users: + - user: admin_user + authentication: + plaintext_key: "abc1234567" + type: "sha" + privacy: + plaintext_key: "abc1234567" + type: "aes" + group: "default" + - user: guest_user2 + authentication: + plaintext_key: "opq1234567" + type: "sha" + privacy: + plaintext_key: "opq1234567" + type: "aes" + views: + - view: "default" + oid: 1 - state: replaced + state: replaced # After State: # vyos@vyos:~$ show configuration commands | grep snmp @@ -572,43 +572,41 @@ EXAMPLES = """ # set service snmp v3 user admin_user auth type 'sha' # set service snmp v3 user admin_user privacy plaintext-key 'abc1234567' # set service snmp v3 user admin_user privacy type 'aes' -# vyos@vyos:~$ - - name: Override config - vyos.vyos.vyos_snmp_server: - config: - communities: - - name: "bridges" - networks: ["1.1.1.0/24", "12.1.1.0/24"] - location: "RDU, NC" - listen_addresses: - - address: "100.1.2.1" - port: 33 - snmp_v3: - groups: - - group: "default" - view: "default" - users: - - user: admin_user - authentication: - plaintext_key: "abc1234567" - type: "sha" - privacy: - plaintext_key: "abc1234567" - type: "aes" - group: "default" - - user: guest_user2 - authentication: - plaintext_key: "opq1234567" - type: "sha" - privacy: - plaintext_key: "opq1234567" - type: "aes" - views: - - view: "default" - oid: 1 - - state: overridden +- name: Override SNMP server config + vyos.vyos.vyos_snmp_server: + config: + communities: + - name: "bridges" + networks: ["1.1.1.0/24", "12.1.1.0/24"] + location: "RDU, NC" + listen_addresses: + - address: "100.1.2.1" + port: 33 + snmp_v3: + groups: + - group: "default" + view: "default" + users: + - user: admin_user + authentication: + plaintext_key: "abc1234567" + type: "sha" + privacy: + plaintext_key: "abc1234567" + type: "aes" + group: "default" + - user: guest_user2 + authentication: + plaintext_key: "opq1234567" + type: "sha" + privacy: + plaintext_key: "opq1234567" + type: "aes" + views: + - view: "default" + oid: 1 + state: overridden # After State: # vyos@vyos:~$ show configuration commands | grep snmp @@ -771,11 +769,10 @@ EXAMPLES = """ # set service snmp v3 user guest_user2 privacy plaintext-key 'opq1234567' # set service snmp v3 user guest_user2 privacy type 'aes' # set service snmp v3 view default oid 1 -# vyos@vyos:~$ - - name: Delete Config - vyos.vyos.vyos_snmp_server: - state: deleted +- name: Delete Config + vyos.vyos.vyos_snmp_server: + state: deleted # After State: # vyos@vyos:~$ show configuration commands | grep snmp @@ -849,30 +846,29 @@ EXAMPLES = """ # ], # Using rendered: - - name: Render provided configuration - vyos.vyos.vyos_snmp_server: - config: - communities: - - name: "switches" - authorization_type: "rw" - - name: "bridges" - clients: ["1.1.1.1", "12.1.1.10"] - contact: "admin2@ex.com" - listen_addresses: - - address: "20.1.1.1" - - address: "100.1.2.1" - port: 33 - snmp_v3: - users: - - user: admin_user - authentication: - plaintext_key: "abc1234567" - type: "sha" - privacy: - plaintext_key: "abc1234567" - type: "aes" - - state: rendered +- name: Render provided configuration + vyos.vyos.vyos_snmp_server: + config: + communities: + - name: "switches" + authorization_type: "rw" + - name: "bridges" + clients: ["1.1.1.1", "12.1.1.10"] + contact: "admin2@ex.com" + listen_addresses: + - address: "20.1.1.1" + - address: "100.1.2.1" + port: 33 + snmp_v3: + users: + - user: admin_user + authentication: + plaintext_key: "abc1234567" + type: "sha" + privacy: + plaintext_key: "abc1234567" + type: "aes" + state: rendered # Module Execution: # "rendered": [ @@ -903,11 +899,10 @@ EXAMPLES = """ # set service snmp v3 user admin_user auth type 'sha' # set service snmp v3 user admin_user privacy plaintext-key 'abc1234567' # set service snmp v3 user admin_user privacy type 'aes' -# vyos@vyos:~$ - - name: gather configs - vyos.vyos.vyos_snmp_server: - state: gathered +- name: Gather SNMP server config + vyos.vyos.vyos_snmp_server: + state: gathered # Module Execution: # "gathered": { @@ -974,10 +969,10 @@ EXAMPLES = """ # set service snmp v3 user vyos privacy type 'aes' # set service snmp v3 view default oid 1 - - name: parse configs - vyos.vyos.vyos_snmp_server: - running_config: "{{ lookup('file', './_parsed_snmp.cfg') }}" - state: parsed +- name: Parse SNMP server config + vyos.vyos.vyos_snmp_server: + running_config: "{{ lookup('file', './_parsed_snmp.cfg') }}" + state: parsed # Module Execution: # "parsed": { diff --git a/plugins/modules/vyos_static_routes.py b/plugins/modules/vyos_static_routes.py index 0761599..df9c501 100644 --- a/plugins/modules/vyos_static_routes.py +++ b/plugins/modules/vyos_static_routes.py @@ -28,6 +28,7 @@ The module file for vyos_static_routes from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -143,25 +144,26 @@ EXAMPLES = """ - name: Merge the provided configuration with the existing running configuration vyos.vyos.vyos_static_routes: config: - - address_families: - - afi: ipv4 - routes: - - dest: 192.0.2.32/28 - blackhole_config: - type: blackhole - next_hops: - - forward_router_address: 192.0.2.6 - - forward_router_address: 192.0.2.7 - - address_families: - - afi: ipv6 - routes: - - dest: 2001:db8:1000::/36 - blackhole_config: - distance: 2 - next_hops: - - forward_router_address: 2001:db8:2000:2::1 - - forward_router_address: 2001:db8:2000:2::2 + - address_families: + - afi: ipv4 + routes: + - dest: 192.0.2.32/28 + blackhole_config: + type: blackhole + next_hops: + - forward_router_address: 192.0.2.6 + - forward_router_address: 192.0.2.7 + - address_families: + - afi: ipv6 + routes: + - dest: '2001:db8:1000::/36' + blackhole_config: + distance: 2 + next_hops: + - forward_router_address: '2001:db8:2000:2::1' + - forward_router_address: '2001:db8:2000:2::2' state: merged + # # # ------------------------- @@ -257,16 +259,16 @@ EXAMPLES = """ - name: Replace device configurations of listed static routes with provided configurations vyos.vyos.vyos_static_routes: config: - - address_families: - - afi: ipv4 - routes: - - dest: 192.0.2.32/28 - blackhole_config: - distance: 2 - next_hops: - - forward_router_address: 192.0.2.7 - enabled: false - - forward_router_address: 192.0.2.9 + - address_families: + - afi: ipv4 + routes: + - dest: 192.0.2.32/28 + blackhole_config: + distance: 2 + next_hops: + - forward_router_address: 192.0.2.7 + enabled: false + - forward_router_address: 192.0.2.9 state: replaced # # @@ -433,12 +435,12 @@ EXAMPLES = """ - name: Overrides all device configuration with provided configuration vyos.vyos.vyos_static_routes: config: - - address_families: - - afi: ipv4 - routes: - - dest: 198.0.2.48/28 - next_hops: - - forward_router_address: 192.0.2.18 + - address_families: + - afi: ipv4 + routes: + - dest: 198.0.2.48/28 + next_hops: + - forward_router_address: 192.0.2.18 state: overridden # # @@ -543,9 +545,9 @@ EXAMPLES = """ - name: Delete static route based on afi. vyos.vyos.vyos_static_routes: config: - - address_families: - - afi: ipv4 - - afi: ipv6 + - address_families: + - afi: ipv4 + - afi: ipv6 state: deleted # # @@ -694,24 +696,24 @@ EXAMPLES = """ - name: Render the commands for provided configuration vyos.vyos.vyos_static_routes: config: - - address_families: - - afi: ipv4 - routes: - - dest: 192.0.2.32/28 - blackhole_config: - type: blackhole - next_hops: - - forward_router_address: 192.0.2.6 - - forward_router_address: 192.0.2.7 - - address_families: - - afi: ipv6 - routes: - - dest: 2001:db8:1000::/36 - blackhole_config: - distance: 2 - next_hops: - - forward_router_address: 2001:db8:2000:2::1 - - forward_router_address: 2001:db8:2000:2::2 + - address_families: + - afi: ipv4 + routes: + - dest: 192.0.2.32/28 + blackhole_config: + type: blackhole + next_hops: + - forward_router_address: 192.0.2.6 + - forward_router_address: 192.0.2.7 + - address_families: + - afi: ipv6 + routes: + - dest: 2001:db8:1000::/36 + blackhole_config: + distance: 2 + next_hops: + - forward_router_address: 2001:db8:2000:2::1 + - forward_router_address: 2001:db8:2000:2::2 state: rendered # # @@ -871,8 +873,6 @@ EXAMPLES = """ # set protocols static route6 2001:db8:1000::/36 blackhole distance '2' # set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::1' # set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::2' - - """ RETURN = """ before: diff --git a/plugins/modules/vyos_system.py b/plugins/modules/vyos_system.py index 66a3fd4..96a0e9b 100644 --- a/plugins/modules/vyos_system.py +++ b/plugins/modules/vyos_system.py @@ -18,6 +18,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -90,8 +91,8 @@ EXAMPLES = """ - name: configure domain search suffixes vyos.vyos.vyos_system: domain_search: - - sub1.example.com - - sub2.example.com + - sub1.example.com + - sub2.example.com """ from ansible.module_utils.basic import AnsibleModule diff --git a/plugins/modules/vyos_user.py b/plugins/modules/vyos_user.py index 5494df3..53c45c2 100644 --- a/plugins/modules/vyos_user.py +++ b/plugins/modules/vyos_user.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function + __metaclass__ = type # (c) 2017, Ansible by Red Hat, inc @@ -154,12 +155,12 @@ EXAMPLES = """ state: present - name: remove all users except admin vyos.vyos.vyos_user: - purge: yes + purge: true - name: set multiple users to level operator vyos.vyos.vyos_user: aggregate: - - name: netop - - name: netend + - name: netop + - name: netend level: operator state: present - name: Change Password for User netop @@ -181,6 +182,7 @@ commands: """ import re + from copy import deepcopy from functools import partial diff --git a/plugins/modules/vyos_vlan.py b/plugins/modules/vyos_vlan.py index f3e3dc8..49cc125 100644 --- a/plugins/modules/vyos_vlan.py +++ b/plugins/modules/vyos_vlan.py @@ -6,6 +6,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type @@ -122,8 +123,8 @@ EXAMPLES = """ vyos.vyos.vyos_vlan: vlan_id: 100 interfaces: - - eth1 - - eth2 + - eth1 + - eth2 - name: Configure virtual interface address vyos.vyos.vyos_vlan: @@ -136,14 +137,14 @@ EXAMPLES = """ vlan_id: 100 interfaces: eth0 associated_interfaces: - - eth0 + - eth0 - name: vlan intent check vyos.vyos.vyos_vlan: vlan_id: 100 associated_interfaces: - - eth3 - - eth4 + - eth3 + - eth4 - name: Delete vlan vyos.vyos.vyos_vlan: @@ -164,6 +165,7 @@ commands: """ import re import time + from copy import deepcopy from ansible.module_utils._text import to_text @@ -224,7 +226,7 @@ def map_obj_to_commands(updates, module): if not obj_in_want: for i in h["interfaces"]: commands.append( - "delete interfaces ethernet {0} vif {1}".format(i, h["vlan_id"]) + "delete interfaces ethernet {0} vif {1}".format(i, h["vlan_id"]), ) return commands @@ -260,7 +262,7 @@ def map_params_to_obj(module): "state": module.params["state"], "interfaces": module.params["interfaces"], "associated_interfaces": module.params["associated_interfaces"], - } + }, ) return obj @@ -325,7 +327,7 @@ def check_declarative_intent_params(want, module, result): for i in w["associated_interfaces"]: if (set(obj_interface) - set(w["associated_interfaces"])) != set([]): module.fail_json( - msg="Interface {0} not configured on vlan {1}".format(i, w["vlan_id"]) + msg="Interface {0} not configured on vlan {1}".format(i, w["vlan_id"]), ) diff --git a/plugins/terminal/vyos.py b/plugins/terminal/vyos.py index d5d57e7..cbe9893 100644 --- a/plugins/terminal/vyos.py +++ b/plugins/terminal/vyos.py @@ -18,6 +18,7 @@ # from __future__ import absolute_import, division, print_function + __metaclass__ = type import os @@ -61,7 +62,7 @@ class TerminalModule(TerminalBase): except ValueError: raise AnsibleConnectionFailure( "Invalid value set for vyos terminal length '%s', value should be a valid integer string" - % terminal_length + % terminal_length, ) def on_open_shell(self): diff --git a/requirements.txt b/requirements.txt index f3152c2..e4c0f75 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,3 @@ ansible-pylibssh -paramiko==2.8.1 -# paramiko 2.8.1 depends on six but does not install it -six +paramiko +scp diff --git a/tests/integration/targets/prepare_vyos_tests/tasks/main.yaml b/tests/integration/targets/prepare_vyos_tests/tasks/main.yaml index c5b0d54..2ed8d8c 100644 --- a/tests/integration/targets/prepare_vyos_tests/tasks/main.yaml +++ b/tests/integration/targets/prepare_vyos_tests/tasks/main.yaml @@ -1,10 +1,14 @@ --- - name: Ensure required interfaces are present in running-config vars: - lines: - "set interfaces ethernet eth0 address dhcp\nset interfaces ethernet eth0\ - \ speed auto\nset interfaces ethernet eth0 duplex auto\nset interfaces ethernet\ - \ eth1\nset interfaces ethernet eth2\ndelete interfaces loopback lo\n" - ignore_errors: true # noqa ignore-errors + lines: |- + set interfaces ethernet eth0 address dhcp + set interfaces ethernet eth0 speed auto + set interfaces ethernet eth0 duplex auto + set interfaces ethernet eth1 + set interfaces ethernet eth2 + delete interfaces loopback lo + ignore_errors: "{{ result.failed }}" + register: result ansible.netcommon.cli_config: config: "{{ lines }}" diff --git a/tests/integration/targets/vyos_bgp_address_family/tests/cli/deleted.yaml b/tests/integration/targets/vyos_bgp_address_family/tests/cli/deleted.yaml index 5d60f36..15bfe84 100644 --- a/tests/integration/targets/vyos_bgp_address_family/tests/cli/deleted.yaml +++ b/tests/integration/targets/vyos_bgp_address_family/tests/cli/deleted.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_bgp_address_family deleted integration tests on connection={{ - ansible_connection }} + msg: START vyos_bgp_address_family deleted integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -13,12 +11,12 @@ config: as_number: "65536" address_family: - - afi: "ipv6" + - afi: ipv6 neighbors: - - neighbor_address: "203.0.113.5" - - neighbor_address: "192.0.2.25" + - neighbor_address: 203.0.113.5 + - neighbor_address: 192.0.2.25 address_family: - - afi: "ipv6" + - afi: ipv6 state: deleted - vyos.vyos.vyos_facts: @@ -31,9 +29,7 @@ - result.commands|symmetric_difference(deleted.commands) == [] - result.after == ansible_facts['network_resources']['bgp_address_family'] - - name: - Delete the existing configuration with the provided running configuration - (IDEMPOTENT) + - name: Delete the existing configuration with the provided running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_bgp_address_family: *id001 diff --git a/tests/integration/targets/vyos_bgp_address_family/tests/cli/empty_config.yaml b/tests/integration/targets/vyos_bgp_address_family/tests/cli/empty_config.yaml index 04a6aac..9b6fa3a 100644 --- a/tests/integration/targets/vyos_bgp_address_family/tests/cli/empty_config.yaml +++ b/tests/integration/targets/vyos_bgp_address_family/tests/cli/empty_config.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_bgp_address_family empty_config integration tests on connection={{ - ansible_connection }} + msg: START vyos_bgp_address_family empty_config integration tests on connection={{ ansible_connection }} - name: Merged with empty config should give appropriate error message register: result @@ -46,8 +44,7 @@ - assert: that: - - result.msg == 'value of running_config parameter must not be empty for state - parsed' + - result.msg == 'value of running_config parameter must not be empty for state parsed' - name: Rendered with empty config should give appropriate error message register: result diff --git a/tests/integration/targets/vyos_bgp_address_family/tests/cli/gathered.yaml b/tests/integration/targets/vyos_bgp_address_family/tests/cli/gathered.yaml index a8f428f..a8a81d0 100644 --- a/tests/integration/targets/vyos_bgp_address_family/tests/cli/gathered.yaml +++ b/tests/integration/targets/vyos_bgp_address_family/tests/cli/gathered.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_bgp_address_family gathered integration tests on connection={{ - ansible_connection }} + msg: START vyos_bgp_address_family gathered integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml diff --git a/tests/integration/targets/vyos_bgp_address_family/tests/cli/merged.yaml b/tests/integration/targets/vyos_bgp_address_family/tests/cli/merged.yaml index cf0f821..4e66a78 100644 --- a/tests/integration/targets/vyos_bgp_address_family/tests/cli/merged.yaml +++ b/tests/integration/targets/vyos_bgp_address_family/tests/cli/merged.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_bgp_address_family merged integration tests on connection={{ - ansible_connection }} + msg: START vyos_bgp_address_family merged integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -14,31 +13,31 @@ config: as_number: "65536" address_family: - - afi: "ipv6" + - afi: ipv6 redistribute: - - protocol: "static" + - protocol: static metric: 50 neighbors: - - neighbor_address: "203.0.113.5" + - neighbor_address: 203.0.113.5 address_family: - - afi: "ipv6" + - afi: ipv6 allowas_in: 4 attribute_unchanged: med: true - default_originate: "map01" + default_originate: map01 distribute_list: - - action: "export" + - action: export acl: 10 - - neighbor_address: "192.0.2.25" + - neighbor_address: 192.0.2.25 address_family: - - afi: "ipv6" + - afi: ipv6 maximum_prefix: 45 nexthop_self: true route_map: - - action: "export" - route_map: "map01" - - action: "import" - route_map: "map01" + - action: export + route_map: map01 + - action: import + route_map: map01 state: merged - vyos.vyos.vyos_facts: @@ -53,9 +52,7 @@ - result.before == {} - result.after == merged.after - - name: - Merge the provided configuration with the existing running configuration - (IDEMPOTENT) + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_bgp_address_family: *id001 diff --git a/tests/integration/targets/vyos_bgp_address_family/tests/cli/overridden.yaml b/tests/integration/targets/vyos_bgp_address_family/tests/cli/overridden.yaml index 9414494..90b40de 100644 --- a/tests/integration/targets/vyos_bgp_address_family/tests/cli/overridden.yaml +++ b/tests/integration/targets/vyos_bgp_address_family/tests/cli/overridden.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_bgp_address_family overridden integration tests on connection={{ - ansible_connection }} + msg: START vyos_bgp_address_family overridden integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -13,20 +11,20 @@ config: as_number: "65536" address_family: - - afi: "ipv6" + - afi: ipv6 redistribute: - - protocol: "static" + - protocol: static metric: 50 neighbors: - - neighbor_address: "203.0.113.5" + - neighbor_address: 203.0.113.5 address_family: - - afi: "ipv6" + - afi: ipv6 allowas_in: 4 attribute_unchanged: med: true - default_originate: "map01" + default_originate: map01 distribute_list: - - action: "export" + - action: export acl: 10 state: overridden @@ -40,9 +38,7 @@ - result.commands|symmetric_difference(overridden.commands) == [] - result.after == ansible_facts['network_resources']['bgp_address_family'] - - name: - Replace the existing configuration with the provided running configuration - (IDEMPOTENT) + - name: Replace the existing configuration with the provided running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_bgp_address_family: *id001 diff --git a/tests/integration/targets/vyos_bgp_address_family/tests/cli/parsed.yaml b/tests/integration/targets/vyos_bgp_address_family/tests/cli/parsed.yaml index 6bd9c77..da9c141 100644 --- a/tests/integration/targets/vyos_bgp_address_family/tests/cli/parsed.yaml +++ b/tests/integration/targets/vyos_bgp_address_family/tests/cli/parsed.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_bgp_address_family parsed integration tests on connection={{ ansible_connection - }} + msg: START vyos_bgp_address_family parsed integration tests on connection={{ ansible_connection }} - name: Provide the running configuration for parsing (config to be parsed) register: result diff --git a/tests/integration/targets/vyos_bgp_address_family/tests/cli/rendered.yaml b/tests/integration/targets/vyos_bgp_address_family/tests/cli/rendered.yaml index 8c6ac5c..0ef116e 100644 --- a/tests/integration/targets/vyos_bgp_address_family/tests/cli/rendered.yaml +++ b/tests/integration/targets/vyos_bgp_address_family/tests/cli/rendered.yaml @@ -1,41 +1,39 @@ --- - debug: - msg: - START vyos_bgp_address_family rendered integration tests on connection={{ - ansible_connection }} + msg: START vyos_bgp_address_family rendered integration tests on connection={{ ansible_connection }} - block: - name: Render the given config in the form of native config. register: result - vyos.vyos.vyos_bgp_address_family: &id001 + vyos.vyos.vyos_bgp_address_family: config: as_number: "65536" address_family: - - afi: "ipv6" + - afi: ipv6 redistribute: - - protocol: "static" + - protocol: static metric: 50 neighbors: - - neighbor_address: "203.0.113.5" + - neighbor_address: 203.0.113.5 address_family: - - afi: "ipv6" + - afi: ipv6 allowas_in: 4 attribute_unchanged: med: true - default_originate: "map01" + default_originate: map01 distribute_list: - - action: "export" + - action: export acl: 10 - - neighbor_address: "192.0.2.25" + - neighbor_address: 192.0.2.25 address_family: - - afi: "ipv6" + - afi: ipv6 maximum_prefix: 45 nexthop_self: true route_map: - - action: "export" - route_map: "map01" - - action: "import" - route_map: "map01" + - action: export + route_map: map01 + - action: import + route_map: map01 state: rendered - assert: diff --git a/tests/integration/targets/vyos_bgp_address_family/tests/cli/replaced.yaml b/tests/integration/targets/vyos_bgp_address_family/tests/cli/replaced.yaml index 0a2ccd9..9b6f330 100644 --- a/tests/integration/targets/vyos_bgp_address_family/tests/cli/replaced.yaml +++ b/tests/integration/targets/vyos_bgp_address_family/tests/cli/replaced.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_bgp_address_family replaced integration tests on connection={{ - ansible_connection }} + msg: START vyos_bgp_address_family replaced integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -13,20 +11,20 @@ config: as_number: "65536" address_family: - - afi: "ipv6" + - afi: ipv6 redistribute: - - protocol: "static" + - protocol: static metric: 50 neighbors: - - neighbor_address: "203.0.113.5" + - neighbor_address: 203.0.113.5 address_family: - - afi: "ipv6" + - afi: ipv6 allowas_in: 4 attribute_unchanged: med: true - default_originate: "map01" + default_originate: map01 distribute_list: - - action: "export" + - action: export acl: 10 state: replaced @@ -40,9 +38,7 @@ - result.commands|symmetric_difference(replaced.commands) == [] - result.after == ansible_facts['network_resources']['bgp_address_family'] - - name: - Replace the existing configuration with the provided running configuration - (IDEMPOTENT) + - name: Replace the existing configuration with the provided running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_bgp_address_family: *id001 diff --git a/tests/integration/targets/vyos_bgp_address_family/tests/cli/rtt.yaml b/tests/integration/targets/vyos_bgp_address_family/tests/cli/rtt.yaml index e0c4131..baab61b 100644 --- a/tests/integration/targets/vyos_bgp_address_family/tests/cli/rtt.yaml +++ b/tests/integration/targets/vyos_bgp_address_family/tests/cli/rtt.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_bgp_address_family rtt integration tests on connection={{ - ansible_connection }} + msg: START vyos_bgp_address_family rtt integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -14,31 +13,31 @@ config: as_number: "65536" address_family: - - afi: "ipv6" + - afi: ipv6 redistribute: - - protocol: "static" + - protocol: static metric: 50 neighbors: - - neighbor_address: "203.0.113.5" + - neighbor_address: 203.0.113.5 address_family: - - afi: "ipv6" + - afi: ipv6 allowas_in: 4 attribute_unchanged: med: true - default_originate: "map01" + default_originate: map01 distribute_list: - - action: "export" + - action: export acl: 10 - - neighbor_address: "192.0.2.25" + - neighbor_address: 192.0.2.25 address_family: - - afi: "ipv6" + - afi: ipv6 maximum_prefix: 45 nexthop_self: true route_map: - - action: "export" - route_map: "map01" - - action: "import" - route_map: "map01" + - action: export + route_map: map01 + - action: import + route_map: map01 state: merged - vyos.vyos.vyos_facts: @@ -57,18 +56,18 @@ config: as_number: "65536" address_family: - - afi: "ipv6" + - afi: ipv6 aggregate_address: - summary_only: true - prefix: "21e0:1:1::/64" + prefix: 21e0:1:1::/64 networks: - - prefix: "21e0:1:1::/64" - route_map: "map01" + - prefix: 21e0:1:1::/64 + route_map: map01 neighbors: - address_family: - - afi: "ipv6" + - afi: ipv6 remove_private_as: true - neighbor_address: "203.0.113.5" + neighbor_address: 203.0.113.5 - name: Revert back to base config using facts round trip register: revert diff --git a/tests/integration/targets/vyos_bgp_address_family/vars/main.yaml b/tests/integration/targets/vyos_bgp_address_family/vars/main.yaml index aed6de6..448918a 100644 --- a/tests/integration/targets/vyos_bgp_address_family/vars/main.yaml +++ b/tests/integration/targets/vyos_bgp_address_family/vars/main.yaml @@ -12,32 +12,32 @@ merged: - set protocols bgp 65536 neighbor 192.0.2.25 address-family ipv6-unicast route-map import map01 after: address_family: - - afi: "ipv6" + - afi: ipv6 redistribute: - metric: 50 - protocol: "static" + protocol: static as_number: 65536 neighbors: - address_family: - - afi: "ipv6" + - afi: ipv6 maximum_prefix: 45 nexthop_self: true route_map: - - action: "export" - route_map: "map01" - - action: "import" - route_map: "map01" - neighbor_address: "192.0.2.25" + - action: export + route_map: map01 + - action: import + route_map: map01 + neighbor_address: 192.0.2.25 - address_family: - - afi: "ipv6" + - afi: ipv6 allowas_in: 4 attribute_unchanged: med: true - default_originate: "map01" + default_originate: map01 distribute_list: - acl: 10 - action: "export" - neighbor_address: "203.0.113.5" + action: export + neighbor_address: 203.0.113.5 replaced: commands: @@ -73,27 +73,27 @@ deleted: populate: config: address_family: - - afi: "ipv6" + - afi: ipv6 aggregate_address: - summary_only: true - prefix: "5000:1:1::/64" + prefix: 5000:1:1::/64 networks: - - prefix: "21e0:1:1::/64" - route_map: "map01" + - prefix: 21e0:1:1::/64 + route_map: map01 redistribute: - metric: 20 - protocol: "ripng" + protocol: ripng as_number: 65536 neighbors: - address_family: - - afi: "ipv6" + - afi: ipv6 route_map: - - action: "export" - route_map: "map01" + - action: export + route_map: map01 soft_reconfiguration: true - neighbor_address: "192.0.2.25" + neighbor_address: 192.0.2.25 - address_family: - - afi: "ipv6" + - afi: ipv6 attribute_unchanged: next_hop: true - neighbor_address: "203.0.113.5" + neighbor_address: 203.0.113.5 diff --git a/tests/integration/targets/vyos_bgp_global/tests/cli/deleted.yaml b/tests/integration/targets/vyos_bgp_global/tests/cli/deleted.yaml index 00a799e..5920c8f 100644 --- a/tests/integration/targets/vyos_bgp_global/tests/cli/deleted.yaml +++ b/tests/integration/targets/vyos_bgp_global/tests/cli/deleted.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_bgp_global deleted integration tests on connection={{ - ansible_connection }} + msg: START vyos_bgp_global deleted integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -23,9 +22,7 @@ - result.commands|symmetric_difference(deleted.commands) == [] - result.after == ansible_facts['network_resources']['bgp_global'] - - name: - Delete the existing configuration with the provided running configuration - (IDEMPOTENT) + - name: Delete the existing configuration with the provided running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_bgp_global: *id001 diff --git a/tests/integration/targets/vyos_bgp_global/tests/cli/deleted_af.yaml b/tests/integration/targets/vyos_bgp_global/tests/cli/deleted_af.yaml index edee16b..88e6be0 100644 --- a/tests/integration/targets/vyos_bgp_global/tests/cli/deleted_af.yaml +++ b/tests/integration/targets/vyos_bgp_global/tests/cli/deleted_af.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_bgp_global replaced integration tests on connection={{ - ansible_connection }} + msg: START vyos_bgp_global replaced integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -11,7 +10,7 @@ - name: Delete the existing configuration, in presence of an af under neighbor. register: result ignore_errors: true - vyos.vyos.vyos_bgp_global: &id001 + vyos.vyos.vyos_bgp_global: config: as_number: "65536" state: deleted diff --git a/tests/integration/targets/vyos_bgp_global/tests/cli/empty_config.yaml b/tests/integration/targets/vyos_bgp_global/tests/cli/empty_config.yaml index 7e52d1c..7be1f69 100644 --- a/tests/integration/targets/vyos_bgp_global/tests/cli/empty_config.yaml +++ b/tests/integration/targets/vyos_bgp_global/tests/cli/empty_config.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_bgp_global empty_config integration tests on connection={{ - ansible_connection }} + msg: START vyos_bgp_global empty_config integration tests on connection={{ ansible_connection }} - name: Merged with empty config should give appropriate error message register: result @@ -34,8 +33,7 @@ - assert: that: - - result.msg == 'value of running_config parameter must not be empty for state - parsed' + - result.msg == 'value of running_config parameter must not be empty for state parsed' - name: Rendered with empty config should give appropriate error message register: result diff --git a/tests/integration/targets/vyos_bgp_global/tests/cli/gathered.yaml b/tests/integration/targets/vyos_bgp_global/tests/cli/gathered.yaml index e5eca7a..82fead7 100644 --- a/tests/integration/targets/vyos_bgp_global/tests/cli/gathered.yaml +++ b/tests/integration/targets/vyos_bgp_global/tests/cli/gathered.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_bgp_global gathered integration tests on connection={{ - ansible_connection }} + msg: START vyos_bgp_global gathered integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml diff --git a/tests/integration/targets/vyos_bgp_global/tests/cli/merged.yaml b/tests/integration/targets/vyos_bgp_global/tests/cli/merged.yaml index ce332a0..388bbcc 100644 --- a/tests/integration/targets/vyos_bgp_global/tests/cli/merged.yaml +++ b/tests/integration/targets/vyos_bgp_global/tests/cli/merged.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_bgp_global merged integration tests on connection={{ - ansible_connection }} + msg: START vyos_bgp_global merged integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -14,32 +13,32 @@ config: as_number: "65536" aggregate_address: - - prefix: "203.0.113.0/24" + - prefix: 203.0.113.0/24 as_set: true - - prefix: "192.0.2.0/24" + - prefix: 192.0.2.0/24 summary_only: true network: - - address: "192.1.13.0/24" + - address: 192.1.13.0/24 backdoor: true redistribute: - - protocol: "kernel" + - protocol: kernel metric: 45 - - protocol: "connected" - route_map: "map01" + - protocol: connected + route_map: map01 maximum_paths: - - path: "ebgp" + - path: ebgp count: 20 - - path: "ibgp" + - path: ibgp count: 55 timers: keepalive: 35 bgp_params: bestpath: - as_path: "confed" + as_path: confed compare_routerid: true default: no_ipv4_unicast: true - router_id: "192.1.2.9" + router_id: 192.1.2.9 state: merged - vyos.vyos.vyos_facts: @@ -54,9 +53,7 @@ - result.before == {} - result.after == merged.after - - name: - Merge the provided configuration with the existing running configuration - (IDEMPOTENT) + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_bgp_global: *id001 diff --git a/tests/integration/targets/vyos_bgp_global/tests/cli/parsed.yaml b/tests/integration/targets/vyos_bgp_global/tests/cli/parsed.yaml index ef8856d..eca85ce 100644 --- a/tests/integration/targets/vyos_bgp_global/tests/cli/parsed.yaml +++ b/tests/integration/targets/vyos_bgp_global/tests/cli/parsed.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_bgp_global parsed integration tests on connection={{ ansible_connection - }} + msg: START vyos_bgp_global parsed integration tests on connection={{ ansible_connection }} - name: Provide the running configuration for parsing (config to be parsed) register: result diff --git a/tests/integration/targets/vyos_bgp_global/tests/cli/purged.yaml b/tests/integration/targets/vyos_bgp_global/tests/cli/purged.yaml index 239f748..71748f5 100644 --- a/tests/integration/targets/vyos_bgp_global/tests/cli/purged.yaml +++ b/tests/integration/targets/vyos_bgp_global/tests/cli/purged.yaml @@ -1,14 +1,13 @@ --- - debug: - msg: START vyos_bgp_global purged integration tests on connection={{ - ansible_connection }} + msg: START vyos_bgp_global purged integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml - block: - name: Purge the provided configuration register: result - vyos.vyos.vyos_bgp_global: &id001 + vyos.vyos.vyos_bgp_global: config: as_number: "65536" state: purged diff --git a/tests/integration/targets/vyos_bgp_global/tests/cli/rendered.yaml b/tests/integration/targets/vyos_bgp_global/tests/cli/rendered.yaml index 534227f..f37ef88 100644 --- a/tests/integration/targets/vyos_bgp_global/tests/cli/rendered.yaml +++ b/tests/integration/targets/vyos_bgp_global/tests/cli/rendered.yaml @@ -1,41 +1,40 @@ --- - debug: - msg: START vyos_bgp_global merged integration tests on connection={{ - ansible_connection }} + msg: START vyos_bgp_global merged integration tests on connection={{ ansible_connection }} - block: - name: Render given bgp_global configuration register: result - vyos.vyos.vyos_bgp_global: &id001 + vyos.vyos.vyos_bgp_global: config: as_number: "65536" aggregate_address: - - prefix: "203.0.113.0/24" + - prefix: 203.0.113.0/24 as_set: true - - prefix: "192.0.2.0/24" + - prefix: 192.0.2.0/24 summary_only: true network: - - address: "192.1.13.0/24" + - address: 192.1.13.0/24 backdoor: true redistribute: - - protocol: "kernel" + - protocol: kernel metric: 45 - - protocol: "connected" - route_map: "map01" + - protocol: connected + route_map: map01 maximum_paths: - - path: "ebgp" + - path: ebgp count: 20 - - path: "ibgp" + - path: ibgp count: 55 timers: keepalive: 35 bgp_params: bestpath: - as_path: "confed" + as_path: confed compare_routerid: true default: no_ipv4_unicast: true - router_id: "192.1.2.9" + router_id: 192.1.2.9 state: rendered - assert: diff --git a/tests/integration/targets/vyos_bgp_global/tests/cli/replaced.yaml b/tests/integration/targets/vyos_bgp_global/tests/cli/replaced.yaml index 99ea04d..ae2c5c7 100644 --- a/tests/integration/targets/vyos_bgp_global/tests/cli/replaced.yaml +++ b/tests/integration/targets/vyos_bgp_global/tests/cli/replaced.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_bgp_global replaced integration tests on connection={{ - ansible_connection }} + msg: START vyos_bgp_global replaced integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -12,11 +11,11 @@ config: as_number: "65536" network: - - address: "203.0.113.0/24" + - address: 203.0.113.0/24 route_map: map01 redistribute: - - protocol: "static" - route_map: "map01" + - protocol: static + route_map: map01 bgp_params: always_compare_med: true dampening: @@ -25,12 +24,12 @@ half_life: 33 re_use: 60 bestpath: - as_path: "confed" + as_path: confed compare_routerid: true default: no_ipv4_unicast: true neighbor: - - address: "192.0.2.43" + - address: 192.0.2.43 disable_connected_check: true advertisement_interval: 72 capability: @@ -38,9 +37,9 @@ timers: holdtime: 30 keepalive: 10 - - address: "203.0.113.0" + - address: 203.0.113.0 capability: - orf: "receive" + orf: receive state: replaced - vyos.vyos.vyos_facts: @@ -53,9 +52,7 @@ - result.commands|symmetric_difference(replaced.commands) == [] - result.after == ansible_facts['network_resources']['bgp_global'] - - name: - Replace the existing configuration with the provided running configuration - (IDEMPOTENT) + - name: Replace the existing configuration with the provided running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_bgp_global: *id001 diff --git a/tests/integration/targets/vyos_bgp_global/tests/cli/replaced_af.yaml b/tests/integration/targets/vyos_bgp_global/tests/cli/replaced_af.yaml index e66aae7..c9b2319 100644 --- a/tests/integration/targets/vyos_bgp_global/tests/cli/replaced_af.yaml +++ b/tests/integration/targets/vyos_bgp_global/tests/cli/replaced_af.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_bgp_global replaced integration tests on connection={{ - ansible_connection }} + msg: START vyos_bgp_global replaced integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -11,15 +10,15 @@ - name: Replace the existing af configuration with the provided running configuration register: result ignore_errors: true - vyos.vyos.vyos_bgp_global: &id001 + vyos.vyos.vyos_bgp_global: config: as_number: "65536" network: - - address: "203.0.113.0/24" + - address: 203.0.113.0/24 route_map: map01 redistribute: - - protocol: "static" - route_map: "map01" + - protocol: static + route_map: map01 bgp_params: always_compare_med: true dampening: @@ -28,12 +27,12 @@ half_life: 33 re_use: 60 bestpath: - as_path: "confed" + as_path: confed compare_routerid: true default: no_ipv4_unicast: true neighbor: - - address: "192.0.2.43" + - address: 192.0.2.43 disable_connected_check: true advertisement_interval: 72 capability: @@ -41,9 +40,9 @@ timers: holdtime: 30 keepalive: 10 - - address: "203.0.113.0" + - address: 203.0.113.0 capability: - orf: "receive" + orf: receive state: replaced - assert: diff --git a/tests/integration/targets/vyos_bgp_global/vars/main.yaml b/tests/integration/targets/vyos_bgp_global/vars/main.yaml index fec5e43..e195c2d 100644 --- a/tests/integration/targets/vyos_bgp_global/vars/main.yaml +++ b/tests/integration/targets/vyos_bgp_global/vars/main.yaml @@ -15,31 +15,31 @@ merged: - set protocols bgp 65536 timers keepalive 35 after: aggregate_address: - - prefix: "192.0.2.0/24" + - prefix: 192.0.2.0/24 summary_only: true - - prefix: "203.0.113.0/24" + - prefix: 203.0.113.0/24 as_set: true as_number: 65536 bgp_params: bestpath: - as_path: "confed" + as_path: confed compare_routerid: true default: no_ipv4_unicast: true - router_id: "192.1.2.9" + router_id: 192.1.2.9 maximum_paths: - count: 20 - path: "ebgp" + path: ebgp - count: 55 - path: "ibgp" + path: ibgp network: - - address: "192.1.13.0/24" + - address: 192.1.13.0/24 backdoor: true redistribute: - - protocol: "connected" - route_map: "map01" + - protocol: connected + route_map: map01 - metric: 45 - protocol: "kernel" + protocol: kernel timers: keepalive: 35 @@ -96,14 +96,14 @@ rendered: populate: global: aggregate_address: - - prefix: "192.0.2.0/24" + - prefix: 192.0.2.0/24 summary_only: true - - prefix: "203.0.113.0/24" + - prefix: 203.0.113.0/24 as_set: true as_number: 65536 bgp_params: bestpath: - as_path: "confed" + as_path: confed compare_routerid: true confederation: - identifier: 66 @@ -111,40 +111,40 @@ populate: - peers: 55 default: no_ipv4_unicast: true - router_id: "192.1.2.9" + router_id: 192.1.2.9 maximum_paths: - count: 20 - path: "ebgp" + path: ebgp - count: 55 - path: "ibgp" + path: ibgp neighbor: - - address: "192.0.2.25" + - address: 192.0.2.25 disable_connected_check: true timers: holdtime: 30 keepalive: 10 - - address: "203.0.113.5" + - address: 203.0.113.5 attribute_unchanged: as_path: true med: true next_hop: true ebgp_multihop: 2 remote_as: 101 - update_source: "192.0.2.25" - - address: "5001::64" + update_source: 192.0.2.25 + - address: 5001::64 distribute_list: - acl: 20 - action: "export" + action: export - acl: 40 - action: "import" + action: import maximum_prefix: 34 network: - - address: "192.1.13.0/24" + - address: 192.1.13.0/24 backdoor: true redistribute: - - protocol: "connected" - route_map: "map01" + - protocol: connected + route_map: map01 - metric: 45 - protocol: "kernel" + protocol: kernel timers: keepalive: 35 diff --git a/tests/integration/targets/vyos_config/tests/cli_config/cli_basic.yaml b/tests/integration/targets/vyos_config/tests/cli_config/cli_basic.yaml index 55a96aa..1523725 100644 --- a/tests/integration/targets/vyos_config/tests/cli_config/cli_basic.yaml +++ b/tests/integration/targets/vyos_config/tests/cli_config/cli_basic.yaml @@ -1,7 +1,5 @@ --- -- debug: - msg="START cli_config/cli_basic.yaml on connection={{ ansible_connection - }}" +- debug: msg="START cli_config/cli_basic.yaml on connection={{ ansible_connection }}" - name: setup - remove interface description ansible.netcommon.cli_config: &id002 @@ -27,5 +25,4 @@ - name: teardown ansible.netcommon.cli_config: *id002 -- debug: msg="END cli_config/cli_basic.yaml on connection={{ ansible_connection - }}" +- debug: msg="END cli_config/cli_basic.yaml on connection={{ ansible_connection }}" diff --git a/tests/integration/targets/vyos_config/tests/cli_config/cli_comment.yaml b/tests/integration/targets/vyos_config/tests/cli_config/cli_comment.yaml index 470553f..d6bfda6 100644 --- a/tests/integration/targets/vyos_config/tests/cli_config/cli_comment.yaml +++ b/tests/integration/targets/vyos_config/tests/cli_config/cli_comment.yaml @@ -1,7 +1,5 @@ --- -- debug: - msg="START cli_config/cli_comment.yaml on connection={{ ansible_connection - }}" +- debug: msg="START cli_config/cli_comment.yaml on connection={{ ansible_connection }}" - name: setup ansible.netcommon.cli_config: &id001 @@ -29,6 +27,4 @@ - name: teardown ansible.netcommon.cli_config: *id001 -- debug: - msg="END cli_config/cli_comment.yaml on connection={{ ansible_connection - }}" +- debug: msg="END cli_config/cli_comment.yaml on connection={{ ansible_connection }}" diff --git a/tests/integration/targets/vyos_config/tests/redirection/cli/shortname.yaml b/tests/integration/targets/vyos_config/tests/redirection/cli/shortname.yaml index e5bb8dd..33fb3be 100644 --- a/tests/integration/targets/vyos_config/tests/redirection/cli/shortname.yaml +++ b/tests/integration/targets/vyos_config/tests/redirection/cli/shortname.yaml @@ -57,8 +57,8 @@ - name: Remove interface description and delete temp user vyos.vyos.config: &cleanup lines: - - "delete interfaces ethernet eth0 description TEST-INTF" - - "delete system login user test_user" + - delete interfaces ethernet eth0 description TEST-INTF + - delete system login user test_user - name: Use src with module alias register: result @@ -71,7 +71,7 @@ - '"set interfaces ethernet eth0 description TEST-INTF" in result.commands' - '"set system login user test_user" in result.commands' -- name: "Restore hostname to {{ inventory_hostname }} and delete temp user" +- name: Restore hostname to {{ inventory_hostname }} and delete temp user vyos.vyos.config: *cleanup - name: use module alias to take configuration backup diff --git a/tests/integration/targets/vyos_facts/tests/cli/basic_facts.yaml b/tests/integration/targets/vyos_facts/tests/cli/basic_facts.yaml index f6e8208..232132e 100644 --- a/tests/integration/targets/vyos_facts/tests/cli/basic_facts.yaml +++ b/tests/integration/targets/vyos_facts/tests/cli/basic_facts.yaml @@ -51,8 +51,13 @@ assert: that: - result.changed == false - - "{{ result['ansible_facts']['available_network_resources'] | symmetric_difference(result['ansible_facts']['ansible_net_gather_network_resources']) |length\ - \ == 0 }}" + - "{{ + result['ansible_facts']['available_network_resources'] + | symmetric_difference( + result['ansible_facts']['ansible_net_gather_network_resources'] + ) + | length == 0 + }}" - name: test getting default facts register: result diff --git a/tests/integration/targets/vyos_firewall_global/tests/cli/_populate.yaml b/tests/integration/targets/vyos_firewall_global/tests/cli/_populate.yaml index d79f477..865bf2f 100644 --- a/tests/integration/targets/vyos_firewall_global/tests/cli/_populate.yaml +++ b/tests/integration/targets/vyos_firewall_global/tests/cli/_populate.yaml @@ -3,19 +3,45 @@ - name: Setup vars: - lines: - "set firewall all-ping 'enable'\nset firewall broadcast-ping 'enable'\n\ - set firewall config-trap 'enable'\nset firewall group address-group MGMT-HOSTS\ - \ address '192.0.1.1'\nset firewall group address-group MGMT-HOSTS address\ - \ '192.0.1.3'\nset firewall group address-group MGMT-HOSTS address '192.0.1.5'\n\ - set firewall group address-group MGMT-HOSTS description 'This group has the\ - \ Management hosts address list'\nset firewall group network-group MGMT description\ - \ 'This group has the Management network addresses'\nset firewall group network-group\ - \ MGMT network '192.0.1.0/24'\nset firewall ip-src-route 'enable'\nset firewall\ - \ log-martians 'enable'\nset firewall receive-redirects 'disable'\nset firewall\ - \ send-redirects 'enable'\nset firewall source-validation 'strict'\nset firewall\ - \ state-policy established action 'accept'\nset firewall state-policy established\ - \ log 'enable'\nset firewall state-policy invalid action 'reject'\nset firewall\ - \ syn-cookies 'enable'\nset firewall twa-hazards-protection 'enable'\n" + lines: >- + set firewall all-ping 'enable' + + set firewall broadcast-ping 'enable' + + set firewall config-trap 'enable' + + set firewall group address-group MGMT-HOSTS address '192.0.1.1' + + set firewall group address-group MGMT-HOSTS address '192.0.1.3' + + set firewall group address-group MGMT-HOSTS address '192.0.1.5' + + set firewall group address-group MGMT-HOSTS description 'This group has + the Management hosts address list' + + set firewall group network-group MGMT description 'This group has the + Management network addresses' + + set firewall group network-group MGMT network '192.0.1.0/24' + + set firewall ip-src-route 'enable' + + set firewall log-martians 'enable' + + set firewall receive-redirects 'disable' + + set firewall send-redirects 'enable' + + set firewall source-validation 'strict' + + set firewall state-policy established action 'accept' + + set firewall state-policy established log 'enable' + + set firewall state-policy invalid action 'reject' + + set firewall syn-cookies 'enable' + + set firewall twa-hazards-protection 'enable' ansible.netcommon.cli_config: config: "{{ lines }}" diff --git a/tests/integration/targets/vyos_firewall_global/tests/cli/deleted.yaml b/tests/integration/targets/vyos_firewall_global/tests/cli/deleted.yaml index df9be56..19fc83d 100644 --- a/tests/integration/targets/vyos_firewall_global/tests/cli/deleted.yaml +++ b/tests/integration/targets/vyos_firewall_global/tests/cli/deleted.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_firewall_global deleted integration tests ansible_connection={{ - ansible_connection }} + msg: START vyos_firewall_global deleted integration tests ansible_connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -21,8 +19,7 @@ - name: Assert that the correct set of commands were generated assert: that: - - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length\ - \ == 0 }}" + - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that the after dicts were correctly generated assert: diff --git a/tests/integration/targets/vyos_firewall_global/tests/cli/empty_config.yaml b/tests/integration/targets/vyos_firewall_global/tests/cli/empty_config.yaml index 643a99e..5b66f8c 100644 --- a/tests/integration/targets/vyos_firewall_global/tests/cli/empty_config.yaml +++ b/tests/integration/targets/vyos_firewall_global/tests/cli/empty_config.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_firewall_global empty_config integration tests on connection={{ - ansible_connection }} + msg: START vyos_firewall_global empty_config integration tests on connection={{ ansible_connection }} - name: Merged with empty config should give appropriate error message register: result @@ -35,8 +33,7 @@ - assert: that: - - result.msg == 'value of running_config parameter must not be empty for state - parsed' + - result.msg == 'value of running_config parameter must not be empty for state parsed' - name: Rendered with empty config should give appropriate error message register: result diff --git a/tests/integration/targets/vyos_firewall_global/tests/cli/gathered.yaml b/tests/integration/targets/vyos_firewall_global/tests/cli/gathered.yaml index e2b60fc..6a7e134 100644 --- a/tests/integration/targets/vyos_firewall_global/tests/cli/gathered.yaml +++ b/tests/integration/targets/vyos_firewall_global/tests/cli/gathered.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_firewall_global gathered integration tests on connection={{ - ansible_connection }} + msg: START vyos_firewall_global gathered integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml diff --git a/tests/integration/targets/vyos_firewall_global/tests/cli/merged.yaml b/tests/integration/targets/vyos_firewall_global/tests/cli/merged.yaml index 67a16ce..4fb2a2d 100644 --- a/tests/integration/targets/vyos_firewall_global/tests/cli/merged.yaml +++ b/tests/integration/targets/vyos_firewall_global/tests/cli/merged.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_firewall_global merged integration tests on connection={{ ansible_connection - }} + msg: START vyos_firewall_global merged integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -56,17 +54,14 @@ - name: Assert that correct set of commands were generated assert: that: - - "{{ merged['commands'] | symmetric_difference(result['commands']) |length\ - \ == 0 }}" + - "{{ merged['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that after dicts was correctly generated assert: that: - "{{ merged['after'] == result['after'] }}" - - name: - Merge the provided configuration with the existing running configuration - (IDEMPOTENT) + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_firewall_global: *id001 diff --git a/tests/integration/targets/vyos_firewall_global/tests/cli/parsed.yaml b/tests/integration/targets/vyos_firewall_global/tests/cli/parsed.yaml index 54885ce..59851c3 100644 --- a/tests/integration/targets/vyos_firewall_global/tests/cli/parsed.yaml +++ b/tests/integration/targets/vyos_firewall_global/tests/cli/parsed.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_firewall_global parsed integration tests on connection={{ ansible_connection - }} + msg: START vyos_firewall_global parsed integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -23,9 +21,7 @@ - name: Assert that correct parsing done assert: - that: - "{{ ansible_facts['network_resources']['firewall_global'] == result['parsed']\ - \ }}" + that: "{{ ansible_facts['network_resources']['firewall_global'] == result['parsed'] }}" - name: Gather the existing running configuration (IDEMPOTENT) register: result diff --git a/tests/integration/targets/vyos_firewall_global/tests/cli/rendered.yaml b/tests/integration/targets/vyos_firewall_global/tests/cli/rendered.yaml index 951abe1..34796b8 100644 --- a/tests/integration/targets/vyos_firewall_global/tests/cli/rendered.yaml +++ b/tests/integration/targets/vyos_firewall_global/tests/cli/rendered.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_firewall_global rendered integration tests on connection={{ - ansible_connection }} + msg: START vyos_firewall_global rendered integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -58,8 +57,7 @@ - name: Assert that correct set of commands were generated assert: that: - - "{{ rendered['commands'] | symmetric_difference(result['rendered'])\ - \ |length == 0 }}" + - "{{ rendered['commands'] | symmetric_difference(result['rendered']) |length == 0 }}" - name: Structure provided configuration into device specific commands (IDEMPOTENT) register: result diff --git a/tests/integration/targets/vyos_firewall_global/tests/cli/replaced.yaml b/tests/integration/targets/vyos_firewall_global/tests/cli/replaced.yaml index 6b0ee82..ec71139 100644 --- a/tests/integration/targets/vyos_firewall_global/tests/cli/replaced.yaml +++ b/tests/integration/targets/vyos_firewall_global/tests/cli/replaced.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_firewall_global replaced integration tests on connection={{ - ansible_connection }} + msg: START vyos_firewall_global replaced integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -58,8 +57,7 @@ - name: Assert that correct set of commands were generated assert: that: - - "{{ replaced['commands'] | symmetric_difference(result['commands'])\ - \ |length == 0 }}" + - "{{ replaced['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that before dicts are correctly generated assert: @@ -71,9 +69,7 @@ that: - "{{ replaced['after'] == result['after'] }}" - - name: - Replace device configurations of listed firewall with provided configurarions - (IDEMPOTENT) + - name: Replace device configurations of listed firewall with provided configurarions (IDEMPOTENT) register: result vyos.vyos.vyos_firewall_global: *id001 diff --git a/tests/integration/targets/vyos_firewall_global/tests/cli/rtt.yaml b/tests/integration/targets/vyos_firewall_global/tests/cli/rtt.yaml index ff24402..f48e432 100644 --- a/tests/integration/targets/vyos_firewall_global/tests/cli/rtt.yaml +++ b/tests/integration/targets/vyos_firewall_global/tests/cli/rtt.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_firewall_global round trip integration tests on connection={{ - ansible_connection }} + msg: START vyos_firewall_global round trip integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_firewall_global/tests/redirection/cli/shortname.yaml b/tests/integration/targets/vyos_firewall_global/tests/redirection/cli/shortname.yaml index 4e134d9..721a138 100644 --- a/tests/integration/targets/vyos_firewall_global/tests/redirection/cli/shortname.yaml +++ b/tests/integration/targets/vyos_firewall_global/tests/redirection/cli/shortname.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START shortname integration tests on connection={{ ansible_connection - }} + msg: START shortname integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -55,17 +54,14 @@ - name: Assert that correct set of commands were generated assert: that: - - "{{ merged['commands'] | symmetric_difference(result['commands']) |length\ - \ == 0 }}" + - "{{ merged['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that after dicts was correctly generated assert: that: - "{{ merged['after'] == result['after'] }}" - - name: - Merge the provided configuration with the existing running configuration - (IDEMPOTENT) + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) register: result vyos.vyos.firewall_global: *id001 diff --git a/tests/integration/targets/vyos_firewall_global/vars/main.yaml b/tests/integration/targets/vyos_firewall_global/vars/main.yaml index 9ec7a6e..b996a94 100644 --- a/tests/integration/targets/vyos_firewall_global/vars/main.yaml +++ b/tests/integration/targets/vyos_firewall_global/vars/main.yaml @@ -5,12 +5,10 @@ merged: - set firewall group address-group MGMT-HOSTS address 192.0.1.1 - set firewall group address-group MGMT-HOSTS address 192.0.1.3 - set firewall group address-group MGMT-HOSTS address 192.0.1.5 - - set firewall group address-group MGMT-HOSTS description 'This group has the - Management hosts address list' + - set firewall group address-group MGMT-HOSTS description 'This group has the Management hosts address list' - set firewall group address-group MGMT-HOSTS - set firewall group network-group MGMT network 192.0.1.0/24 - - set firewall group network-group MGMT description 'This group has the Management - network addresses' + - set firewall group network-group MGMT description 'This group has the Management network addresses' - set firewall group network-group MGMT - set firewall ip-src-route 'enable' - set firewall receive-redirects 'disable' @@ -103,13 +101,11 @@ replaced: - set firewall group address-group SALES-HOSTS address 192.0.2.1 - set firewall group address-group SALES-HOSTS address 192.0.2.2 - set firewall group address-group SALES-HOSTS address 192.0.2.3 - - set firewall group address-group SALES-HOSTS description 'Sales office hosts - address list' + - set firewall group address-group SALES-HOSTS description 'Sales office hosts address list' - set firewall group address-group SALES-HOSTS - set firewall group address-group ENG-HOSTS address 192.0.3.1 - set firewall group address-group ENG-HOSTS address 192.0.3.2 - - set firewall group address-group ENG-HOSTS description 'Sales office hosts address - list' + - set firewall group address-group ENG-HOSTS description 'Sales office hosts address list' - set firewall group address-group ENG-HOSTS after: config_trap: true @@ -158,17 +154,14 @@ rendered: - set firewall group address-group SALES-HOSTS address 192.0.2.1 - set firewall group address-group SALES-HOSTS address 192.0.2.2 - set firewall group address-group SALES-HOSTS address 192.0.2.3 - - set firewall group address-group SALES-HOSTS description 'Sales office hosts - address list' + - set firewall group address-group SALES-HOSTS description 'Sales office hosts address list' - set firewall group address-group SALES-HOSTS - set firewall group address-group ENG-HOSTS address 192.0.3.1 - set firewall group address-group ENG-HOSTS address 192.0.3.2 - - set firewall group address-group ENG-HOSTS description 'Sales office hosts address - list' + - set firewall group address-group ENG-HOSTS description 'Sales office hosts address list' - set firewall group address-group ENG-HOSTS - set firewall group network-group MGMT network 192.0.1.0/24 - - set firewall group network-group MGMT description 'This group has the Management - network addresses' + - set firewall group network-group MGMT description 'This group has the Management network addresses' - set firewall group network-group MGMT - set firewall ip-src-route 'enable' - set firewall receive-redirects 'disable' diff --git a/tests/integration/targets/vyos_firewall_interfaces/tests/cli/_populate.yaml b/tests/integration/targets/vyos_firewall_interfaces/tests/cli/_populate.yaml index 3dee476..c5e2f4f 100644 --- a/tests/integration/targets/vyos_firewall_interfaces/tests/cli/_populate.yaml +++ b/tests/integration/targets/vyos_firewall_interfaces/tests/cli/_populate.yaml @@ -3,13 +3,14 @@ - name: Setup vars: - lines: - "set interfaces ethernet eth1 firewall in name 'INBOUND' \nset interfaces\ - \ ethernet eth1 firewall out name 'OUTBOUND' \nset interfaces ethernet eth1\ - \ firewall local name 'LOCAL' \nset interfaces ethernet eth1 firewall local\ - \ ipv6-name 'V6-LOCAL'\nset interfaces ethernet eth2 firewall in name 'INBOUND'\n\ - set interfaces ethernet eth2 firewall out name 'OUTBOUND'\nset interfaces\ - \ ethernet eth2 firewall local name 'LOCAL' \nset interfaces ethernet eth2\ - \ firewall local ipv6-name 'V6-LOCAL'\n" + lines: |- + set interfaces ethernet eth1 firewall in name 'INBOUND' + set interfaces ethernet eth1 firewall out name 'OUTBOUND' + set interfaces ethernet eth1 firewall local name 'LOCAL' + set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL' + set interfaces ethernet eth2 firewall in name 'INBOUND' + set interfaces ethernet eth2 firewall out name 'OUTBOUND' + set interfaces ethernet eth2 firewall local name 'LOCAL' + set interfaces ethernet eth2 firewall local ipv6-name 'V6-LOCAL' ansible.netcommon.cli_config: config: "{{ lines }}" diff --git a/tests/integration/targets/vyos_firewall_interfaces/tests/cli/_populate_rule_sets.yaml b/tests/integration/targets/vyos_firewall_interfaces/tests/cli/_populate_rule_sets.yaml index d2fd3ee..b1e9425 100644 --- a/tests/integration/targets/vyos_firewall_interfaces/tests/cli/_populate_rule_sets.yaml +++ b/tests/integration/targets/vyos_firewall_interfaces/tests/cli/_populate_rule_sets.yaml @@ -1,8 +1,6 @@ --- - name: Setup vars: - lines: - "set firewall name 'INBOUND'\nset firewall name 'OUTBOUND'\nset firewall\ - \ name 'LOCAL'\nset firewall ipv6-name 'V6-LOCAL'\n" + lines: "set firewall name 'INBOUND'\nset firewall name 'OUTBOUND'\nset firewall name 'LOCAL'\nset firewall ipv6-name 'V6-LOCAL'\n" ansible.netcommon.cli_config: config: "{{ lines }}" diff --git a/tests/integration/targets/vyos_firewall_interfaces/tests/cli/_remove_config.yaml b/tests/integration/targets/vyos_firewall_interfaces/tests/cli/_remove_config.yaml index c95fc00..6074960 100644 --- a/tests/integration/targets/vyos_firewall_interfaces/tests/cli/_remove_config.yaml +++ b/tests/integration/targets/vyos_firewall_interfaces/tests/cli/_remove_config.yaml @@ -1,8 +1,6 @@ --- - name: Remove Config vars: - lines: - "delete interfaces ethernet eth1 firewall\ndelete interfaces ethernet\ - \ eth2 firewall\n" + lines: "delete interfaces ethernet eth1 firewall\ndelete interfaces ethernet eth2 firewall\n" ansible.netcommon.cli_config: config: "{{ lines }}" diff --git a/tests/integration/targets/vyos_firewall_interfaces/tests/cli/_remove_firewall_config.yaml b/tests/integration/targets/vyos_firewall_interfaces/tests/cli/_remove_firewall_config.yaml index da1b02c..f77e6b7 100644 --- a/tests/integration/targets/vyos_firewall_interfaces/tests/cli/_remove_firewall_config.yaml +++ b/tests/integration/targets/vyos_firewall_interfaces/tests/cli/_remove_firewall_config.yaml @@ -1,7 +1,6 @@ --- - name: Remove Config vars: - lines: "delete firewall name INBOUND\ndelete firewall name OUTBOUND\ndelete\ - \ firewall name LOCAL\ndelete firewall ipv6-name V6-LOCAL\n" + lines: "delete firewall name INBOUND\ndelete firewall name OUTBOUND\ndelete firewall name LOCAL\ndelete firewall ipv6-name V6-LOCAL\n" ansible.netcommon.cli_config: config: "{{ lines }}" diff --git a/tests/integration/targets/vyos_firewall_interfaces/tests/cli/deleted.yaml b/tests/integration/targets/vyos_firewall_interfaces/tests/cli/deleted.yaml index eb9bded..2b94c08 100644 --- a/tests/integration/targets/vyos_firewall_interfaces/tests/cli/deleted.yaml +++ b/tests/integration/targets/vyos_firewall_interfaces/tests/cli/deleted.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_firewall_interfaces deleted integration tests ansible_connection={{ - ansible_connection }} + msg: START vyos_firewall_interfaces deleted integration tests ansible_connection={{ ansible_connection }} - include_tasks: _populate_rule_sets.yaml @@ -26,14 +24,12 @@ - name: Assert that the correct set of commands were generated assert: that: - - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length\ - \ == 0 }}" + - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that the after dicts were correctly generated assert: that: - - "{{ deleted['after'] | symmetric_difference(result['after']) |length\ - \ == 0 }}" + - "{{ deleted['after'] | symmetric_difference(result['after']) |length == 0 }}" - name: Delete attributes of given interfaces (IDEMPOTENT) register: result @@ -48,8 +44,7 @@ - name: Assert that the before dicts were correctly generated assert: that: - - "{{ deleted['after'] | symmetric_difference(result['before']) |length\ - \ == 0 }}" + - "{{ deleted['after'] | symmetric_difference(result['before']) |length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_firewall_interfaces/tests/cli/deleted_afi.yaml b/tests/integration/targets/vyos_firewall_interfaces/tests/cli/deleted_afi.yaml index 8a31b2a..065fcf2 100644 --- a/tests/integration/targets/vyos_firewall_interfaces/tests/cli/deleted_afi.yaml +++ b/tests/integration/targets/vyos_firewall_interfaces/tests/cli/deleted_afi.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_firewall_interfaces deleted integration tests ansible_connection={{ - ansible_connection }} + msg: START vyos_firewall_interfaces deleted integration tests ansible_connection={{ ansible_connection }} - include_tasks: _populate_rule_sets.yaml @@ -34,14 +32,12 @@ - name: Assert that the correct set of commands were generated assert: that: - - "{{ deleted_afi['commands'] | symmetric_difference(result['commands'])\ - \ |length == 0 }}" + - "{{ deleted_afi['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that the after dicts were correctly generated assert: that: - - "{{ deleted_afi['after'] | symmetric_difference(result['after']) |length\ - \ == 0 }}" + - "{{ deleted_afi['after'] | symmetric_difference(result['after']) |length == 0 }}" - name: Delete attributes of given interfaces (IDEMPOTENT) register: result @@ -56,8 +52,7 @@ - name: Assert that the before dicts were correctly generated assert: that: - - "{{ deleted_afi['after'] | symmetric_difference(result['before']) |length\ - \ == 0 }}" + - "{{ deleted_afi['after'] | symmetric_difference(result['before']) |length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_firewall_interfaces/tests/cli/deleted_all.yaml b/tests/integration/targets/vyos_firewall_interfaces/tests/cli/deleted_all.yaml index a3515b0..f6cdae4 100644 --- a/tests/integration/targets/vyos_firewall_interfaces/tests/cli/deleted_all.yaml +++ b/tests/integration/targets/vyos_firewall_interfaces/tests/cli/deleted_all.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_firewall_interfaces deleted integration tests ansible_connection={{ - ansible_connection }} + msg: START vyos_firewall_interfaces deleted integration tests ansible_connection={{ ansible_connection }} - include_tasks: _populate_rule_sets.yaml @@ -23,14 +21,12 @@ - name: Assert that the correct set of commands were generated assert: that: - - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length\ - \ == 0 }}" + - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that the after dicts were correctly generated assert: that: - - "{{ deleted['after'] | symmetric_difference(result['after']) |length\ - \ == 0 }}" + - "{{ deleted['after'] | symmetric_difference(result['after']) |length == 0 }}" - name: Delete attributes of given interfaces (IDEMPOTENT) register: result @@ -45,8 +41,7 @@ - name: Assert that the before dicts were correctly generated assert: that: - - "{{ deleted['after'] | symmetric_difference(result['before']) |length\ - \ == 0 }}" + - "{{ deleted['after'] | symmetric_difference(result['before']) |length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_firewall_interfaces/tests/cli/deleted_single.yaml b/tests/integration/targets/vyos_firewall_interfaces/tests/cli/deleted_single.yaml index d62e27f..6aa5032 100644 --- a/tests/integration/targets/vyos_firewall_interfaces/tests/cli/deleted_single.yaml +++ b/tests/integration/targets/vyos_firewall_interfaces/tests/cli/deleted_single.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_firewall_interfaces deleted integration tests ansible_connection={{ - ansible_connection }} + msg: START vyos_firewall_interfaces deleted integration tests ansible_connection={{ ansible_connection }} - include_tasks: _populate_rule_sets.yaml @@ -29,14 +27,12 @@ - name: Assert that the correct set of commands were generated assert: that: - - "{{ deleted_single['commands'] | symmetric_difference(result['commands'])\ - \ |length == 0 }}" + - "{{ deleted_single['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that the after dicts were correctly generated assert: that: - - "{{ deleted_single['after'] | symmetric_difference(result['after'])\ - \ |length == 0 }}" + - "{{ deleted_single['after'] | symmetric_difference(result['after']) |length == 0 }}" - name: Delete attributes of given interfaces (IDEMPOTENT) register: result @@ -51,8 +47,7 @@ - name: Assert that the before dicts were correctly generated assert: that: - - "{{ deleted_single['after'] | symmetric_difference(result['before'])\ - \ |length == 0 }}" + - "{{ deleted_single['after'] | symmetric_difference(result['before']) |length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_firewall_interfaces/tests/cli/empty_config.yaml b/tests/integration/targets/vyos_firewall_interfaces/tests/cli/empty_config.yaml index 1b9eb34..0799a67 100644 --- a/tests/integration/targets/vyos_firewall_interfaces/tests/cli/empty_config.yaml +++ b/tests/integration/targets/vyos_firewall_interfaces/tests/cli/empty_config.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_firewall_interfaces empty_config integration tests on connection={{ - ansible_connection }} + msg: START vyos_firewall_interfaces empty_config integration tests on connection={{ ansible_connection }} - name: Merged with empty config should give appropriate error message register: result @@ -46,8 +44,7 @@ - assert: that: - - result.msg == 'value of running_config parameter must not be empty for state - parsed' + - result.msg == 'value of running_config parameter must not be empty for state parsed' - name: Rendered with empty config should give appropriate error message register: result diff --git a/tests/integration/targets/vyos_firewall_interfaces/tests/cli/gathered.yaml b/tests/integration/targets/vyos_firewall_interfaces/tests/cli/gathered.yaml index 2593a67..145ad73 100644 --- a/tests/integration/targets/vyos_firewall_interfaces/tests/cli/gathered.yaml +++ b/tests/integration/targets/vyos_firewall_interfaces/tests/cli/gathered.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_firewall_interfaces gathered integration tests on connection={{ - ansible_connection }} + msg: START vyos_firewall_interfaces gathered integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -22,8 +20,7 @@ - name: Assert that gathered dicts was correctly generated assert: that: - - "{{ populate | symmetric_difference(result['gathered']) |length == 0\ - \ }}" + - "{{ populate | symmetric_difference(result['gathered']) |length == 0 }}" - name: Gather the existing running configuration (IDEMPOTENT) register: result diff --git a/tests/integration/targets/vyos_firewall_interfaces/tests/cli/merged.yaml b/tests/integration/targets/vyos_firewall_interfaces/tests/cli/merged.yaml index 10c8f01..145fcef 100644 --- a/tests/integration/targets/vyos_firewall_interfaces/tests/cli/merged.yaml +++ b/tests/integration/targets/vyos_firewall_interfaces/tests/cli/merged.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_firewall_interfaces merged integration tests on connection={{ - ansible_connection }} + msg: START vyos_firewall_interfaces merged integration tests on connection={{ ansible_connection }} - include_tasks: _populate_rule_sets.yaml @@ -52,25 +50,19 @@ - name: Assert that before dicts were correctly generated assert: - that: - "{{ merged['before'] | symmetric_difference(result['before']) |length\ - \ == 0 }}" + that: "{{ merged['before'] | symmetric_difference(result['before']) |length == 0 }}" - name: Assert that correct set of commands were generated assert: that: - - "{{ merged['commands'] | symmetric_difference(result['commands']) |length\ - \ == 0 }}" + - "{{ merged['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that after dicts was correctly generated assert: that: - - "{{ merged['after'] | symmetric_difference(result['after']) |length\ - \ == 0 }}" + - "{{ merged['after'] | symmetric_difference(result['after']) |length == 0 }}" - - name: - Merge the provided configuration with the existing running configuration - (IDEMPOTENT) + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_firewall_interfaces: *id001 @@ -82,8 +74,7 @@ - name: Assert that before dicts were correctly generated assert: that: - - "{{ merged['after'] | symmetric_difference(result['before']) |length\ - \ == 0 }}" + - "{{ merged['after'] | symmetric_difference(result['before']) |length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_firewall_interfaces/tests/cli/merged_edit.yaml b/tests/integration/targets/vyos_firewall_interfaces/tests/cli/merged_edit.yaml index 1a53cab..fbbb81a 100644 --- a/tests/integration/targets/vyos_firewall_interfaces/tests/cli/merged_edit.yaml +++ b/tests/integration/targets/vyos_firewall_interfaces/tests/cli/merged_edit.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_firewall_interfaces merged integration tests on connection={{ - ansible_connection }} + msg: START vyos_firewall_interfaces merged integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -30,25 +28,19 @@ - name: Assert that before dicts were correctly generated assert: - that: - "{{ populate | symmetric_difference(result['before']) |length == 0\ - \ }}" + that: "{{ populate | symmetric_difference(result['before']) |length == 0 }}" - name: Assert that correct set of commands were generated assert: that: - - "{{ merged_edit['commands'] | symmetric_difference(result['commands'])\ - \ |length == 0 }}" + - "{{ merged_edit['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that after dicts was correctly generated assert: that: - - "{{ merged_edit['after'] | symmetric_difference(result['after']) |length\ - \ == 0 }}" + - "{{ merged_edit['after'] | symmetric_difference(result['after']) |length == 0 }}" - - name: - Merge the provided configuration with the existing running configuration - (IDEMPOTENT) + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_firewall_interfaces: *id001 @@ -60,8 +52,7 @@ - name: Assert that before dicts were correctly generated assert: that: - - "{{ merged_edit['after'] | symmetric_difference(result['before']) |length\ - \ == 0 }}" + - "{{ merged_edit['after'] | symmetric_difference(result['before']) |length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_firewall_interfaces/tests/cli/overridden.yaml b/tests/integration/targets/vyos_firewall_interfaces/tests/cli/overridden.yaml index 5776718..82508ba 100644 --- a/tests/integration/targets/vyos_firewall_interfaces/tests/cli/overridden.yaml +++ b/tests/integration/targets/vyos_firewall_interfaces/tests/cli/overridden.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_firewall_interfaces overridden integration tests on connection={{ - ansible_connection }} + msg: START vyos_firewall_interfaces overridden integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -33,14 +31,12 @@ - name: Assert that correct commands were generated assert: that: - - "{{ overridden['commands'] | symmetric_difference(result['commands'])\ - \ |length == 0 }}" + - "{{ overridden['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that after dicts were correctly generated assert: that: - - "{{ overridden['after'] | symmetric_difference(result['after']) |length\ - \ == 0 }}" + - "{{ overridden['after'] | symmetric_difference(result['after']) |length == 0 }}" - name: Overrides all device configuration with provided configurations (IDEMPOTENT) register: result @@ -54,8 +50,7 @@ - name: Assert that before dicts were correctly generated assert: that: - - "{{ overridden['after'] | symmetric_difference(result['before']) |length\ - \ == 0 }}" + - "{{ overridden['after'] | symmetric_difference(result['before']) |length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_firewall_interfaces/tests/cli/parsed.yaml b/tests/integration/targets/vyos_firewall_interfaces/tests/cli/parsed.yaml index 105c647..339e64e 100644 --- a/tests/integration/targets/vyos_firewall_interfaces/tests/cli/parsed.yaml +++ b/tests/integration/targets/vyos_firewall_interfaces/tests/cli/parsed.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_firewall_interfaces parsed integration tests on connection={{ - ansible_connection }} + msg: START vyos_firewall_interfaces parsed integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -29,9 +27,7 @@ - name: Assert that correct parsing done assert: - that: - "{{ ansible_facts['network_resources']['firewall_interfaces'] | symmetric_difference(result['parsed'])\ - \ |length == 0 }}" + that: "{{ ansible_facts['network_resources']['firewall_interfaces'] | symmetric_difference(result['parsed']) |length == 0 }}" - name: Gather the existing running configuration (IDEMPOTENT) register: result diff --git a/tests/integration/targets/vyos_firewall_interfaces/tests/cli/rendered.yaml b/tests/integration/targets/vyos_firewall_interfaces/tests/cli/rendered.yaml index 3283ec6..3b815eb 100644 --- a/tests/integration/targets/vyos_firewall_interfaces/tests/cli/rendered.yaml +++ b/tests/integration/targets/vyos_firewall_interfaces/tests/cli/rendered.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_firewall_interfaces rendered integration tests on connection={{ - ansible_connection }} + msg: START vyos_firewall_interfaces rendered integration tests on connection={{ ansible_connection }} - block: - name: Structure provided configuration into device specific commands @@ -49,8 +47,7 @@ - name: Assert that correct set of commands were generated assert: that: - - "{{ rendered['commands'] | symmetric_difference(result['rendered'])\ - \ |length == 0 }}" + - "{{ rendered['commands'] | symmetric_difference(result['rendered']) |length == 0 }}" - name: Structure provided configuration into device specific commands (IDEMPOTENT) register: result diff --git a/tests/integration/targets/vyos_firewall_interfaces/tests/cli/replaced.yaml b/tests/integration/targets/vyos_firewall_interfaces/tests/cli/replaced.yaml index d82a0f6..bca14cf 100644 --- a/tests/integration/targets/vyos_firewall_interfaces/tests/cli/replaced.yaml +++ b/tests/integration/targets/vyos_firewall_interfaces/tests/cli/replaced.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_firewall_interfaces replaced integration tests on connection={{ - ansible_connection }} + msg: START vyos_firewall_interfaces replaced integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -13,8 +11,7 @@ - include_tasks: _populate.yaml - block: - - name: Replace device configurations of listed firewall rules with provided - configurations + - name: Replace device configurations of listed firewall rules with provided configurations register: result vyos.vyos.vyos_firewall_interfaces: &id001 config: @@ -41,8 +38,7 @@ - name: Assert that correct set of commands were generated assert: that: - - "{{ replaced['commands'] | symmetric_difference(result['commands'])\ - \ |length == 0 }}" + - "{{ replaced['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that before dicts are correctly generated assert: @@ -52,11 +48,9 @@ - name: Assert that after dict is correctly generated assert: that: - - "{{ replaced['after'] | symmetric_difference(result['after']) |length\ - \ == 0 }}" + - "{{ replaced['after'] | symmetric_difference(result['after']) |length == 0 }}" - - name: Replace device configurations of listed firewall rules with provided - configurarions (IDEMPOTENT) + - name: Replace device configurations of listed firewall rules with provided configurarions (IDEMPOTENT) register: result vyos.vyos.vyos_firewall_interfaces: *id001 @@ -68,8 +62,7 @@ - name: Assert that before dict is correctly generated assert: that: - - "{{ replaced['after'] | symmetric_difference(result['before']) |length\ - \ == 0 }}" + - "{{ replaced['after'] | symmetric_difference(result['before']) |length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_firewall_interfaces/tests/cli/rtt.yaml b/tests/integration/targets/vyos_firewall_interfaces/tests/cli/rtt.yaml index ff3abb1..d64a987 100644 --- a/tests/integration/targets/vyos_firewall_interfaces/tests/cli/rtt.yaml +++ b/tests/integration/targets/vyos_firewall_interfaces/tests/cli/rtt.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_firewall_interfaces round trip integration tests on connection={{ - ansible_connection }} + msg: START vyos_firewall_interfaces round trip integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -66,9 +64,7 @@ - name: Assert that changes were applied assert: - that: - "{{ round_trip['after'] | symmetric_difference(result['after']) |length\ - \ == 0 }}" + that: "{{ round_trip['after'] | symmetric_difference(result['after']) |length == 0 }}" - name: Revert back to base config using facts round trip register: revert @@ -78,9 +74,7 @@ - name: Assert that config was reverted assert: - that: - "{{ base_config['after'] | symmetric_difference(revert['after']) |length\ - \ == 0 }}" + that: "{{ base_config['after'] | symmetric_difference(revert['after']) |length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_firewall_rules/tests/cli/_populate.yaml b/tests/integration/targets/vyos_firewall_rules/tests/cli/_populate.yaml index 12adf4f..31e0d13 100644 --- a/tests/integration/targets/vyos_firewall_rules/tests/cli/_populate.yaml +++ b/tests/integration/targets/vyos_firewall_rules/tests/cli/_populate.yaml @@ -1,28 +1,31 @@ --- - name: Setup vars: - lines: - "set firewall group address-group 'inbound'\nset firewall ipv6-name UPLINK\ - \ default-action 'accept'\nset firewall ipv6-name UPLINK description 'This\ - \ is ipv6 specific rule-set'\nset firewall ipv6-name UPLINK rule 1 action\ - \ 'accept'\nset firewall ipv6-name UPLINK rule 1 description 'Fwipv6-Rule\ - \ 1 is configured by Ansible'\nset firewall ipv6-name UPLINK rule 1 ipsec\ - \ 'match-ipsec'\nset firewall ipv6-name UPLINK rule 2 action 'accept'\nset\ - \ firewall ipv6-name UPLINK rule 2 description 'Fwipv6-Rule 2 is configured\ - \ by Ansible'\nset firewall ipv6-name UPLINK rule 2 ipsec 'match-ipsec'\n\ - set firewall name INBOUND default-action 'accept'\nset firewall name INBOUND\ - \ description 'IPv4 INBOUND rule set'\nset firewall name INBOUND rule 101\ - \ action 'accept'\nset firewall name INBOUND rule 101 description 'Rule 101\ - \ is configured by Ansible'\nset firewall name INBOUND rule 101 ipsec 'match-ipsec'\n\ - set firewall name INBOUND rule 102 action 'reject'\nset firewall name INBOUND\ - \ rule 102 description 'Rule 102 is configured by Ansible'\nset firewall name\ - \ INBOUND rule 102 ipsec 'match-ipsec'\nset firewall name INBOUND rule 103\ - \ action 'accept'\nset firewall name INBOUND rule 103 description 'Rule 103\ - \ is configured by Ansible'\nset firewall name INBOUND rule 103 destination\ - \ group address-group 'inbound'\nset firewall name INBOUND rule 103 source\ - \ address '192.0.2.0'\nset firewall name INBOUND rule 103 state established\ - \ 'enable'\nset firewall name INBOUND rule 103 state invalid 'disable'\nset\ - \ firewall name INBOUND rule 103 state new 'disable'\nset firewall name INBOUND\ - \ rule 103 state related 'enable'\n" + lines: |- + set firewall group address-group 'inbound' + set firewall ipv6-name UPLINK default-action 'accept' + set firewall ipv6-name UPLINK description 'This is ipv6 specific rule-set' + set firewall ipv6-name UPLINK rule 1 action 'accept' + set firewall ipv6-name UPLINK rule 1 description 'Fwipv6-Rule 1 is configured by Ansible' + set firewall ipv6-name UPLINK rule 1 ipsec 'match-ipsec' + set firewall ipv6-name UPLINK rule 2 action 'accept' + set firewall ipv6-name UPLINK rule 2 description 'Fwipv6-Rule 2 is configured by Ansible' + set firewall ipv6-name UPLINK rule 2 ipsec 'match-ipsec' + set firewall name INBOUND default-action 'accept' + set firewall name INBOUND description 'IPv4 INBOUND rule set' + set firewall name INBOUND rule 101 action 'accept' + set firewall name INBOUND rule 101 description 'Rule 101 is configured by Ansible' + set firewall name INBOUND rule 101 ipsec 'match-ipsec' + set firewall name INBOUND rule 102 action 'reject' + set firewall name INBOUND rule 102 description 'Rule 102 is configured by Ansible' + set firewall name INBOUND rule 102 ipsec 'match-ipsec' + set firewall name INBOUND rule 103 action 'accept' + set firewall name INBOUND rule 103 description 'Rule 103 is configured by Ansible' + set firewall name INBOUND rule 103 destination group address-group 'inbound' + set firewall name INBOUND rule 103 source address '192.0.2.0' + set firewall name INBOUND rule 103 state established 'enable' + set firewall name INBOUND rule 103 state invalid 'disable' + set firewall name INBOUND rule 103 state new 'disable' + set firewall name INBOUND rule 103 state related 'enable' ansible.netcommon.cli_config: config: "{{ lines }}" diff --git a/tests/integration/targets/vyos_firewall_rules/tests/cli/deleted.yaml b/tests/integration/targets/vyos_firewall_rules/tests/cli/deleted.yaml index 6a830f9..97b3ae8 100644 --- a/tests/integration/targets/vyos_firewall_rules/tests/cli/deleted.yaml +++ b/tests/integration/targets/vyos_firewall_rules/tests/cli/deleted.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - Start vyos_firewall_rules deleted integration tests ansible_connection={{ - ansible_connection }} + msg: Start vyos_firewall_rules deleted integration tests ansible_connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -27,14 +25,12 @@ - name: Assert that the correct set of commands were generated assert: that: - - "{{ deleted_rs['commands'] | symmetric_difference(result['commands'])\ - \ |length == 0 }}" + - "{{ deleted_rs['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that the after dicts were correctly generated assert: that: - - "{{ deleted_rs['after'] | symmetric_difference(result['after']) |length\ - \ == 0 }}" + - "{{ deleted_rs['after'] | symmetric_difference(result['after']) |length == 0 }}" - name: Delete attributes of given interfaces (IDEMPOTENT) register: result @@ -49,7 +45,6 @@ - name: Assert that the before dicts were correctly generated assert: that: - - "{{ deleted_rs['after'] | symmetric_difference(result['before']) |length\ - \ == 0 }}" + - "{{ deleted_rs['after'] | symmetric_difference(result['before']) |length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_firewall_rules/tests/cli/deleted_afi.yaml b/tests/integration/targets/vyos_firewall_rules/tests/cli/deleted_afi.yaml index e104171..c7a2278 100644 --- a/tests/integration/targets/vyos_firewall_rules/tests/cli/deleted_afi.yaml +++ b/tests/integration/targets/vyos_firewall_rules/tests/cli/deleted_afi.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - Start vyos_firewall_rules deleted integration tests ansible_connection={{ - ansible_connection }} + msg: Start vyos_firewall_rules deleted integration tests ansible_connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -24,14 +22,12 @@ - name: Assert that the correct set of commands were generated assert: that: - - "{{ deleted_afi_all['commands'] | symmetric_difference(result['commands'])\ - \ |length == 0 }}" + - "{{ deleted_afi_all['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that the after dicts were correctly generated assert: that: - - "{{ deleted_afi_all['after'] | symmetric_difference(result['after'])\ - \ |length == 0 }}" + - "{{ deleted_afi_all['after'] | symmetric_difference(result['after']) |length == 0 }}" - name: Delete attributes of given interfaces (IDEMPOTENT) register: result @@ -46,7 +42,6 @@ - name: Assert that the before dicts were correctly generated assert: that: - - "{{ deleted_afi_all['after'] | symmetric_difference(result['before'])\ - \ |length == 0 }}" + - "{{ deleted_afi_all['after'] | symmetric_difference(result['before']) |length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_firewall_rules/tests/cli/deleted_all.yaml b/tests/integration/targets/vyos_firewall_rules/tests/cli/deleted_all.yaml index 9df5127..c55a4c5 100644 --- a/tests/integration/targets/vyos_firewall_rules/tests/cli/deleted_all.yaml +++ b/tests/integration/targets/vyos_firewall_rules/tests/cli/deleted_all.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - Start vyos_firewall_rules deleted integration tests ansible_connection={{ - ansible_connection }} + msg: Start vyos_firewall_rules deleted integration tests ansible_connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -21,14 +19,12 @@ - name: Assert that the correct set of commands were generated assert: that: - - "{{ deleted_afi_all['commands'] | symmetric_difference(result['commands'])\ - \ |length == 0 }}" + - "{{ deleted_afi_all['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that the after dicts were correctly generated assert: that: - - "{{ deleted_afi_all['after'] | symmetric_difference(result['after'])\ - \ |length == 0 }}" + - "{{ deleted_afi_all['after'] | symmetric_difference(result['after']) |length == 0 }}" - name: Delete attributes of given interfaces (IDEMPOTENT) register: result @@ -43,7 +39,6 @@ - name: Assert that the before dicts were correctly generated assert: that: - - "{{ deleted_afi_all['after'] | symmetric_difference(result['before'])\ - \ |length == 0 }}" + - "{{ deleted_afi_all['after'] | symmetric_difference(result['before']) |length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_firewall_rules/tests/cli/empty_config.yaml b/tests/integration/targets/vyos_firewall_rules/tests/cli/empty_config.yaml index ba71e71..064296a 100644 --- a/tests/integration/targets/vyos_firewall_rules/tests/cli/empty_config.yaml +++ b/tests/integration/targets/vyos_firewall_rules/tests/cli/empty_config.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_firewall_rules empty_config integration tests on connection={{ - ansible_connection }} + msg: START vyos_firewall_rules empty_config integration tests on connection={{ ansible_connection }} - name: Merged with empty config should give appropriate error message register: result @@ -46,8 +44,7 @@ - assert: that: - - result.msg == 'value of running_config parameter must not be empty for state - parsed' + - result.msg == 'value of running_config parameter must not be empty for state parsed' - name: Rendered with empty config should give appropriate error message register: result diff --git a/tests/integration/targets/vyos_firewall_rules/tests/cli/gathered.yaml b/tests/integration/targets/vyos_firewall_rules/tests/cli/gathered.yaml index b824198..29096eb 100644 --- a/tests/integration/targets/vyos_firewall_rules/tests/cli/gathered.yaml +++ b/tests/integration/targets/vyos_firewall_rules/tests/cli/gathered.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_firewall_rules gathered integration tests on connection={{ ansible_connection - }} + msg: START vyos_firewall_rules gathered integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -18,8 +16,7 @@ - name: Assert that gathered dicts was correctly generated assert: that: - - "{{ populate | symmetric_difference(result['gathered']) |length == 0\ - \ }}" + - "{{ populate | symmetric_difference(result['gathered']) |length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_firewall_rules/tests/cli/merged.yaml b/tests/integration/targets/vyos_firewall_rules/tests/cli/merged.yaml index 48fdff7..674b437 100644 --- a/tests/integration/targets/vyos_firewall_rules/tests/cli/merged.yaml +++ b/tests/integration/targets/vyos_firewall_rules/tests/cli/merged.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_firewall_rules merged integration tests on connection={{ ansible_connection - }} + msg: START vyos_firewall_rules merged integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -67,31 +65,24 @@ - name: Assert that before dicts were correctly generated assert: - that: - "{{ merged['before'] | symmetric_difference(result['before']) |length\ - \ == 0 }}" + that: "{{ merged['before'] | symmetric_difference(result['before']) |length == 0 }}" - name: Assert that correct set of commands were generated assert: that: - - "{{ merged['commands'] | symmetric_difference(result['commands']) |length\ - \ == 0 }}" + - "{{ merged['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that fact was correctly generated assert: that: - - "{{ merged['after'] | symmetric_difference(ansible_facts['network_resources']['firewall_rules']) |length\ - \ == 0 }}" + - "{{ merged['after'] | symmetric_difference(ansible_facts['network_resources']['firewall_rules']) |length == 0 }}" - name: Assert that after dicts was correctly generated assert: that: - - "{{ merged['after'] | symmetric_difference(result['after']) |length\ - \ == 0 }}" + - "{{ merged['after'] | symmetric_difference(result['after']) |length == 0 }}" - - name: - Merge the provided configuration with the existing running configuration - (IDEMPOTENT) + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_firewall_rules: *id001 @@ -103,7 +94,6 @@ - name: Assert that before dicts were correctly generated assert: that: - - "{{ merged['after'] | symmetric_difference(result['before']) |length\ - \ == 0 }}" + - "{{ merged['after'] | symmetric_difference(result['before']) |length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_firewall_rules/tests/cli/overridden.yaml b/tests/integration/targets/vyos_firewall_rules/tests/cli/overridden.yaml index aac79e5..6e1b3a3 100644 --- a/tests/integration/targets/vyos_firewall_rules/tests/cli/overridden.yaml +++ b/tests/integration/targets/vyos_firewall_rules/tests/cli/overridden.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_firewall_rules overridden integration tests on connection={{ - ansible_connection }} + msg: START vyos_firewall_rules overridden integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -37,14 +36,12 @@ - name: Assert that correct commands were generated assert: that: - - "{{ overridden['commands'] | symmetric_difference(result['commands'])\ - \ |length == 0 }}" + - "{{ overridden['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that after dicts were correctly generated assert: that: - - "{{ overridden['after'] | symmetric_difference(result['after']) |length\ - \ == 0 }}" + - "{{ overridden['after'] | symmetric_difference(result['after']) |length == 0 }}" - name: Overrides all device configuration with provided configurations (IDEMPOTENT) register: result @@ -58,7 +55,6 @@ - name: Assert that before dicts were correctly generated assert: that: - - "{{ overridden['after'] | symmetric_difference(result['before']) |length\ - \ == 0 }}" + - "{{ overridden['after'] | symmetric_difference(result['before']) |length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_firewall_rules/tests/cli/parsed.yaml b/tests/integration/targets/vyos_firewall_rules/tests/cli/parsed.yaml index 3e4c972..e6eae78 100644 --- a/tests/integration/targets/vyos_firewall_rules/tests/cli/parsed.yaml +++ b/tests/integration/targets/vyos_firewall_rules/tests/cli/parsed.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_firewall_rules parsed integration tests on connection={{ ansible_connection - }} + msg: START vyos_firewall_rules parsed integration tests on connection={{ ansible_connection }} - name: Parse externally provided Firewall rules config to agnostic model register: result @@ -13,5 +11,4 @@ - name: Assert that config was correctly parsed assert: that: - - "{{ parsed['after'] | symmetric_difference(result['parsed']) |length ==\ - \ 0 }}" + - "{{ parsed['after'] | symmetric_difference(result['parsed']) |length == 0 }}" diff --git a/tests/integration/targets/vyos_firewall_rules/tests/cli/rendered.yaml b/tests/integration/targets/vyos_firewall_rules/tests/cli/rendered.yaml index d376744..36feb69 100644 --- a/tests/integration/targets/vyos_firewall_rules/tests/cli/rendered.yaml +++ b/tests/integration/targets/vyos_firewall_rules/tests/cli/rendered.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_firewall_rules rendered integration tests on connection={{ ansible_connection - }} + msg: START vyos_firewall_rules rendered integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -51,8 +49,7 @@ - name: Assert that correct set of commands were generated assert: that: - - "{{ rendered['commands'] | symmetric_difference(result['rendered'])\ - \ |length == 0 }}" + - "{{ rendered['commands'] | symmetric_difference(result['rendered']) |length == 0 }}" - debug: msg: END vyos_firewall_rules rendered integration tests on connection={{ ansible_connection }} diff --git a/tests/integration/targets/vyos_firewall_rules/tests/cli/replaced.yaml b/tests/integration/targets/vyos_firewall_rules/tests/cli/replaced.yaml index 850aa60..5959c22 100644 --- a/tests/integration/targets/vyos_firewall_rules/tests/cli/replaced.yaml +++ b/tests/integration/targets/vyos_firewall_rules/tests/cli/replaced.yaml @@ -1,16 +1,13 @@ --- - debug: - msg: - START vyos_firewall_rules replaced integration tests on connection={{ ansible_connection - }} + msg: START vyos_firewall_rules replaced integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml - include_tasks: _populate.yaml - block: - - name: Replace device configurations of listed firewall rules with provided - configurations + - name: Replace device configurations of listed firewall rules with provided configurations register: result vyos.vyos.vyos_firewall_rules: &id001 config: @@ -40,8 +37,7 @@ - name: Assert that correct set of commands were generated assert: that: - - "{{ replaced['commands'] | symmetric_difference(result['commands'])\ - \ |length == 0 }}" + - "{{ replaced['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that before dicts are correctly generated assert: @@ -51,11 +47,9 @@ - name: Assert that after dict is correctly generated assert: that: - - "{{ replaced['after'] | symmetric_difference(result['after']) |length\ - \ == 0 }}" + - "{{ replaced['after'] | symmetric_difference(result['after']) |length == 0 }}" - - name: Replace device configurations of listed firewall rules with provided - configurarions (IDEMPOTENT) + - name: Replace device configurations of listed firewall rules with provided configurarions (IDEMPOTENT) register: result vyos.vyos.vyos_firewall_rules: *id001 @@ -67,7 +61,6 @@ - name: Assert that before dict is correctly generated assert: that: - - "{{ replaced['after'] | symmetric_difference(result['before']) |length\ - \ == 0 }}" + - "{{ replaced['after'] | symmetric_difference(result['before']) |length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_firewall_rules/tests/cli/rtt.yaml b/tests/integration/targets/vyos_firewall_rules/tests/cli/rtt.yaml index f3f4252..dcf5b28 100644 --- a/tests/integration/targets/vyos_firewall_rules/tests/cli/rtt.yaml +++ b/tests/integration/targets/vyos_firewall_rules/tests/cli/rtt.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_firewall_rules round trip integration tests on connection={{ - ansible_connection }} + msg: START vyos_firewall_rules round trip integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -74,9 +73,7 @@ - name: Assert that changes were applied assert: - that: - "{{ round_trip['after'] | symmetric_difference(result['after']) |length\ - \ == 0 }}" + that: "{{ round_trip['after'] | symmetric_difference(result['after']) |length == 0 }}" - name: Revert back to base config using facts round trip register: revert @@ -86,8 +83,6 @@ - name: Assert that config was reverted assert: - that: - "{{ base_config['after'] | symmetric_difference(revert['after']) |length\ - \ == 0 }}" + that: "{{ base_config['after'] | symmetric_difference(revert['after']) |length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_firewall_rules/vars/main.yaml b/tests/integration/targets/vyos_firewall_rules/vars/main.yaml index 3bd1512..e2b3e10 100644 --- a/tests/integration/targets/vyos_firewall_rules/vars/main.yaml +++ b/tests/integration/targets/vyos_firewall_rules/vars/main.yaml @@ -6,13 +6,11 @@ merged: - set firewall ipv6-name UPLINK description 'This is ipv6 specific rule-set' - set firewall ipv6-name UPLINK rule 1 action 'accept' - set firewall ipv6-name UPLINK rule 1 - - set firewall ipv6-name UPLINK rule 1 description 'Fwipv6-Rule 1 is configured - by Ansible' + - set firewall ipv6-name UPLINK rule 1 description 'Fwipv6-Rule 1 is configured by Ansible' - set firewall ipv6-name UPLINK rule 1 ipsec 'match-ipsec' - set firewall ipv6-name UPLINK rule 2 action 'accept' - set firewall ipv6-name UPLINK rule 2 - - set firewall ipv6-name UPLINK rule 2 description 'Fwipv6-Rule 2 is configured - by Ansible' + - set firewall ipv6-name UPLINK rule 2 description 'Fwipv6-Rule 2 is configured by Ansible' - set firewall ipv6-name UPLINK rule 2 ipsec 'match-ipsec' - set firewall name INBOUND default-action 'accept' - set firewall name INBOUND description 'IPv4 INBOUND rule set' diff --git a/tests/integration/targets/vyos_hostname/tests/cli/deleted.yaml b/tests/integration/targets/vyos_hostname/tests/cli/deleted.yaml index 2c052f4..cefaccf 100644 --- a/tests/integration/targets/vyos_hostname/tests/cli/deleted.yaml +++ b/tests/integration/targets/vyos_hostname/tests/cli/deleted.yaml @@ -24,9 +24,7 @@ that: - result.after == {} - - name: - Delete the existing configuration with the provided running configuration - (IDEMPOTENT) + - name: Delete the existing configuration with the provided running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_hostname: *id001 diff --git a/tests/integration/targets/vyos_hostname/tests/cli/empty_config.yaml b/tests/integration/targets/vyos_hostname/tests/cli/empty_config.yaml index 8efead2..e829ac9 100644 --- a/tests/integration/targets/vyos_hostname/tests/cli/empty_config.yaml +++ b/tests/integration/targets/vyos_hostname/tests/cli/empty_config.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_hostname empty_config integration tests on connection={{ - ansible_connection }} + msg: START vyos_hostname empty_config integration tests on connection={{ ansible_connection }} - name: Merged with empty config should give appropriate error message register: result @@ -45,8 +44,7 @@ - assert: that: - - result.msg == 'value of running_config parameter must not be empty for state - parsed' + - result.msg == 'value of running_config parameter must not be empty for state parsed' - name: Rendered with empty config should give appropriate error message register: result diff --git a/tests/integration/targets/vyos_hostname/tests/cli/gathered.yaml b/tests/integration/targets/vyos_hostname/tests/cli/gathered.yaml index f3eacad..2d31670 100644 --- a/tests/integration/targets/vyos_hostname/tests/cli/gathered.yaml +++ b/tests/integration/targets/vyos_hostname/tests/cli/gathered.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_hostname gathered integration tests on connection={{ - ansible_connection }} + msg: START vyos_hostname gathered integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_hostname/tests/cli/merged.yaml b/tests/integration/targets/vyos_hostname/tests/cli/merged.yaml index 14ed1df..c1e4f25 100644 --- a/tests/integration/targets/vyos_hostname/tests/cli/merged.yaml +++ b/tests/integration/targets/vyos_hostname/tests/cli/merged.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_hostname merged integration tests on connection={{ - ansible_connection }} + msg: START vyos_hostname merged integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -10,7 +9,7 @@ register: result vyos.vyos.vyos_hostname: &id001 config: - hostname: "vyosTest" + hostname: vyosTest state: merged - vyos.vyos.vyos_facts: @@ -29,9 +28,7 @@ that: - result.before == {} - - name: - Merge the provided configuration with the existing running configuration - (IDEMPOTENT) + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_hostname: *id001 diff --git a/tests/integration/targets/vyos_hostname/tests/cli/overridden.yaml b/tests/integration/targets/vyos_hostname/tests/cli/overridden.yaml index a50ef64..15065b4 100644 --- a/tests/integration/targets/vyos_hostname/tests/cli/overridden.yaml +++ b/tests/integration/targets/vyos_hostname/tests/cli/overridden.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_hostname overridden integration tests on connection={{ - ansible_connection }} + msg: START vyos_hostname overridden integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -12,7 +11,7 @@ register: result vyos.vyos.vyos_hostname: &id001 config: - hostname: "vyosTest" + hostname: vyosTest state: overridden - vyos.vyos.vyos_facts: @@ -26,9 +25,7 @@ - result.after == ansible_facts['network_resources']['hostname'] - result.after == merged.after - - name: - override the provided configuration with the existing running configuration - (IDEMPOTENT) + - name: override the provided configuration with the existing running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_hostname: *id001 diff --git a/tests/integration/targets/vyos_hostname/tests/cli/parsed.yaml b/tests/integration/targets/vyos_hostname/tests/cli/parsed.yaml index b1aa806..377f121 100644 --- a/tests/integration/targets/vyos_hostname/tests/cli/parsed.yaml +++ b/tests/integration/targets/vyos_hostname/tests/cli/parsed.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_hostname parsed integration tests on connection={{ ansible_connection - }} + msg: START vyos_hostname parsed integration tests on connection={{ ansible_connection }} - name: Provide the running configuration for parsing (config to be parsed) register: result diff --git a/tests/integration/targets/vyos_hostname/tests/cli/rendered.yaml b/tests/integration/targets/vyos_hostname/tests/cli/rendered.yaml index 25c81b2..bfad4a8 100644 --- a/tests/integration/targets/vyos_hostname/tests/cli/rendered.yaml +++ b/tests/integration/targets/vyos_hostname/tests/cli/rendered.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_hostname rendered integration tests on connection={{ - ansible_connection }} + msg: START vyos_hostname rendered integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -10,7 +9,7 @@ register: result vyos.vyos.vyos_hostname: config: - hostname: "vyosTest" + hostname: vyosTest state: rendered - assert: diff --git a/tests/integration/targets/vyos_hostname/tests/cli/replaced.yaml b/tests/integration/targets/vyos_hostname/tests/cli/replaced.yaml index 7d9b522..18b5ee5 100644 --- a/tests/integration/targets/vyos_hostname/tests/cli/replaced.yaml +++ b/tests/integration/targets/vyos_hostname/tests/cli/replaced.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_hostname replaced integration tests on connection={{ - ansible_connection }} + msg: START vyos_hostname replaced integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -12,7 +11,7 @@ register: result vyos.vyos.vyos_hostname: &id001 config: - hostname: "vyosTest" + hostname: vyosTest state: replaced - vyos.vyos.vyos_facts: @@ -26,9 +25,7 @@ - result.after == ansible_facts['network_resources']['hostname'] - result.after == merged.after - - name: - Replace the provided configuration with the existing running configuration - (IDEMPOTENT) + - name: Replace the provided configuration with the existing running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_hostname: *id001 diff --git a/tests/integration/targets/vyos_hostname/vars/main.yaml b/tests/integration/targets/vyos_hostname/vars/main.yaml index ca02d03..2ea481d 100644 --- a/tests/integration/targets/vyos_hostname/vars/main.yaml +++ b/tests/integration/targets/vyos_hostname/vars/main.yaml @@ -4,7 +4,7 @@ merged: commands: - set system host-name vyosTest after: - hostname: "vyosTest" + hostname: vyosTest deleted: commands: diff --git a/tests/integration/targets/vyos_interfaces/tests/cli/_populate.yaml b/tests/integration/targets/vyos_interfaces/tests/cli/_populate.yaml index ee0b775..cb4e86c 100644 --- a/tests/integration/targets/vyos_interfaces/tests/cli/_populate.yaml +++ b/tests/integration/targets/vyos_interfaces/tests/cli/_populate.yaml @@ -3,12 +3,13 @@ - name: Setup vars: - lines: - "set interfaces ethernet \"{{ intf }}\" description 'Configured by Ansible'\n\ - set interfaces ethernet \"{{ intf }}\" speed 'auto'\nset interfaces ethernet\ - \ \"{{ intf }}\" duplex 'auto'\nset interfaces ethernet \"{{ intf }}\" mtu\ - \ '1500'\nset interfaces ethernet \"{{ intf }}\" vif 200\nset interfaces ethernet\ - \ \"{{ intf }}\" vif 200 description 'VIF - 200'\n" + lines: |- + set interfaces ethernet "{{ intf }}" description 'Configured by Ansible' + set interfaces ethernet "{{ intf }}" speed 'auto' + set interfaces ethernet "{{ intf }}" duplex 'auto' + set interfaces ethernet "{{ intf }}" mtu '1500' + set interfaces ethernet "{{ intf }}" vif 200 + set interfaces ethernet "{{ intf }}" vif 200 description 'VIF - 200' loop: - eth1 - eth2 diff --git a/tests/integration/targets/vyos_interfaces/tests/cli/_remove_config.yaml b/tests/integration/targets/vyos_interfaces/tests/cli/_remove_config.yaml index 6353d1c..ed2b424 100644 --- a/tests/integration/targets/vyos_interfaces/tests/cli/_remove_config.yaml +++ b/tests/integration/targets/vyos_interfaces/tests/cli/_remove_config.yaml @@ -1,12 +1,13 @@ --- - name: Remove Config vars: - lines: - "delete interfaces ethernet \"{{ intf }}\" description\ndelete interfaces\ - \ ethernet \"{{ intf }}\" speed\ndelete interfaces ethernet \"{{ intf }}\"\ - \ duplex\ndelete interfaces ethernet \"{{ intf }}\" mtu\ndelete interfaces\ - \ ethernet \"{{ intf }}\" disable\ndelete interfaces ethernet \"{{ intf }}\"\ - \ vif\n" + lines: |- + delete interfaces ethernet "{{ intf }}" description + delete interfaces ethernet "{{ intf }}" speed + delete interfaces ethernet "{{ intf }}" duplex + delete interfaces ethernet "{{ intf }}" mtu + delete interfaces ethernet "{{ intf }}" disable + delete interfaces ethernet "{{ intf }}" vif loop: - eth1 - eth2 diff --git a/tests/integration/targets/vyos_interfaces/tests/cli/deleted.yaml b/tests/integration/targets/vyos_interfaces/tests/cli/deleted.yaml index 2c12ff2..620bf53 100644 --- a/tests/integration/targets/vyos_interfaces/tests/cli/deleted.yaml +++ b/tests/integration/targets/vyos_interfaces/tests/cli/deleted.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - Start vyos_interfaces deleted integration tests ansible_connection={{ ansible_connection - }} + msg: Start vyos_interfaces deleted integration tests ansible_connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -24,14 +22,12 @@ - name: Assert that the correct set of commands were generated assert: that: - - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length\ - \ == 0 }}" + - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that the after dicts were correctly generated assert: that: - - "{{ deleted['after'] | symmetric_difference(result['after']) |length\ - \ == 0 }}" + - "{{ deleted['after'] | symmetric_difference(result['after']) |length == 0 }}" - name: Delete attributes of given interfaces (IDEMPOTENT) register: result @@ -45,7 +41,6 @@ - name: Assert that the before dicts were correctly generated assert: that: - - "{{ deleted['after'] | symmetric_difference(result['before']) |length\ - \ == 0 }}" + - "{{ deleted['after'] | symmetric_difference(result['before']) |length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_interfaces/tests/cli/empty_config.yaml b/tests/integration/targets/vyos_interfaces/tests/cli/empty_config.yaml index 652f158..f8133d6 100644 --- a/tests/integration/targets/vyos_interfaces/tests/cli/empty_config.yaml +++ b/tests/integration/targets/vyos_interfaces/tests/cli/empty_config.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_interfaces empty_config integration tests on connection={{ - ansible_connection }} + msg: START vyos_interfaces empty_config integration tests on connection={{ ansible_connection }} - name: Merged with empty config should give appropriate error message register: result @@ -45,8 +44,7 @@ - assert: that: - - result.msg == 'value of running_config parameter must not be empty for state - parsed' + - result.msg == 'value of running_config parameter must not be empty for state parsed' - name: Rendered with empty config should give appropriate error message register: result diff --git a/tests/integration/targets/vyos_interfaces/tests/cli/gathered.yaml b/tests/integration/targets/vyos_interfaces/tests/cli/gathered.yaml index f8057c8..88e5376 100644 --- a/tests/integration/targets/vyos_interfaces/tests/cli/gathered.yaml +++ b/tests/integration/targets/vyos_interfaces/tests/cli/gathered.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_interfaces gathered integration tests on connection={{ ansible_connection - }} + msg: START vyos_interfaces gathered integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -16,8 +14,7 @@ - name: Assert that gathered dicts was correctly generated assert: that: - - "{{ populate | symmetric_difference(result['gathered']) |length == 0\ - \ }}" + - "{{ populate | symmetric_difference(result['gathered']) |length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_interfaces/tests/cli/merged.yaml b/tests/integration/targets/vyos_interfaces/tests/cli/merged.yaml index 39f4938..194d9bc 100644 --- a/tests/integration/targets/vyos_interfaces/tests/cli/merged.yaml +++ b/tests/integration/targets/vyos_interfaces/tests/cli/merged.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_interfaces merged integration tests on connection={{ ansible_connection - }} + msg: START vyos_interfaces merged integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -32,25 +30,19 @@ - name: Assert that before dicts were correctly generated assert: - that: - "{{ merged['before'] | symmetric_difference(result['before']) |length\ - \ == 0 }}" + that: "{{ merged['before'] | symmetric_difference(result['before']) |length == 0 }}" - name: Assert that correct set of commands were generated assert: that: - - "{{ merged['commands'] | symmetric_difference(result['commands']) |length\ - \ == 0 }}" + - "{{ merged['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that after dicts was correctly generated assert: that: - - "{{ merged['after'] | symmetric_difference(result['after']) |length\ - \ == 0 }}" + - "{{ merged['after'] | symmetric_difference(result['after']) |length == 0 }}" - - name: - Merge the provided configuration with the existing running configuration - (IDEMPOTENT) + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_interfaces: *id001 @@ -62,7 +54,6 @@ - name: Assert that before dicts were correctly generated assert: that: - - "{{ merged['after'] | symmetric_difference(result['before']) |length\ - \ == 0 }}" + - "{{ merged['after'] | symmetric_difference(result['before']) |length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_interfaces/tests/cli/overridden.yaml b/tests/integration/targets/vyos_interfaces/tests/cli/overridden.yaml index 66588cd..f8915d3 100644 --- a/tests/integration/targets/vyos_interfaces/tests/cli/overridden.yaml +++ b/tests/integration/targets/vyos_interfaces/tests/cli/overridden.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_interfaces overridden integration tests on connection={{ ansible_connection - }} + msg: START vyos_interfaces overridden integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -28,14 +26,12 @@ - name: Assert that correct commands were generated assert: that: - - "{{ overridden['commands'] | symmetric_difference(result['commands'])\ - \ |length == 0 }}" + - "{{ overridden['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that after dicts were correctly generated assert: that: - - "{{ overridden['after'] | symmetric_difference(result['after']) |length\ - \ == 0 }}" + - "{{ overridden['after'] | symmetric_difference(result['after']) |length == 0 }}" - name: Overrides all device configuration with provided configurations (IDEMPOTENT) register: result @@ -49,7 +45,6 @@ - name: Assert that before dicts were correctly generated assert: that: - - "{{ overridden['after'] | symmetric_difference(result['before']) |length\ - \ == 0 }}" + - "{{ overridden['after'] | symmetric_difference(result['before']) |length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_interfaces/tests/cli/parsed.yaml b/tests/integration/targets/vyos_interfaces/tests/cli/parsed.yaml index a22fb60..0ebfd32 100644 --- a/tests/integration/targets/vyos_interfaces/tests/cli/parsed.yaml +++ b/tests/integration/targets/vyos_interfaces/tests/cli/parsed.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_interfaces parsed integration tests on connection={{ ansible_connection - }} + msg: START vyos_interfaces parsed integration tests on connection={{ ansible_connection }} - name: Parse externally provided interfaces config to agnostic model register: result @@ -13,5 +11,4 @@ - name: Assert that config was correctly parsed assert: that: - - "{{ parsed['after'] | symmetric_difference(result['parsed']) |length ==\ - \ 0 }}" + - "{{ parsed['after'] | symmetric_difference(result['parsed']) |length == 0 }}" diff --git a/tests/integration/targets/vyos_interfaces/tests/cli/rendered.yaml b/tests/integration/targets/vyos_interfaces/tests/cli/rendered.yaml index 41d10d0..cd8cdf6 100644 --- a/tests/integration/targets/vyos_interfaces/tests/cli/rendered.yaml +++ b/tests/integration/targets/vyos_interfaces/tests/cli/rendered.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_interfaces rendered integration tests on connection={{ ansible_connection - }} + msg: START vyos_interfaces rendered integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -38,7 +36,6 @@ - name: Assert that correct set of commands were generated assert: that: - - "{{ rendered['commands'] | symmetric_difference(result['rendered'])\ - \ |length == 0 }}" + - "{{ rendered['commands'] | symmetric_difference(result['rendered']) |length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_interfaces/tests/cli/replaced.yaml b/tests/integration/targets/vyos_interfaces/tests/cli/replaced.yaml index a22a4c7..f6cfda4 100644 --- a/tests/integration/targets/vyos_interfaces/tests/cli/replaced.yaml +++ b/tests/integration/targets/vyos_interfaces/tests/cli/replaced.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_interfaces replaced integration tests on connection={{ ansible_connection - }} + msg: START vyos_interfaces replaced integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -25,8 +23,7 @@ - name: Assert that correct set of commands were generated assert: that: - - "{{ replaced['commands'] | symmetric_difference(result['commands'])\ - \ |length == 0 }}" + - "{{ replaced['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that before dicts are correctly generated assert: @@ -36,12 +33,9 @@ - name: Assert that after dict is correctly generated assert: that: - - "{{ replaced['after'] | symmetric_difference(result['after']) |length\ - \ == 0 }}" + - "{{ replaced['after'] | symmetric_difference(result['after']) |length == 0 }}" - - name: - Replace device configurations of listed interfaces with provided configurarions - (IDEMPOTENT) + - name: Replace device configurations of listed interfaces with provided configurarions (IDEMPOTENT) register: result vyos.vyos.vyos_interfaces: *id001 @@ -53,7 +47,6 @@ - name: Assert that before dict is correctly generated assert: that: - - "{{ replaced['after'] | symmetric_difference(result['before']) |length\ - \ == 0 }}" + - "{{ replaced['after'] | symmetric_difference(result['before']) |length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_interfaces/tests/cli/rtt.yaml b/tests/integration/targets/vyos_interfaces/tests/cli/rtt.yaml index 5aefbb4..5073a34 100644 --- a/tests/integration/targets/vyos_interfaces/tests/cli/rtt.yaml +++ b/tests/integration/targets/vyos_interfaces/tests/cli/rtt.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_interfaces round trip integration tests on connection={{ ansible_connection - }} + msg: START vyos_interfaces round trip integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -64,9 +62,7 @@ - name: Assert that changes were applied assert: - that: - "{{ round_trip['after'] | symmetric_difference(result['after']) |length\ - \ == 0 }}" + that: "{{ round_trip['after'] | symmetric_difference(result['after']) |length == 0 }}" - name: Revert back to base config using facts round trip register: revert @@ -76,8 +72,6 @@ - name: Assert that config was reverted assert: - that: - "{{ base_config['after'] | symmetric_difference(revert['after']) |length\ - \ == 0 }}" + that: "{{ base_config['after'] | symmetric_difference(revert['after']) |length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_interfaces/tests/redirection/cli/shortname.yaml b/tests/integration/targets/vyos_interfaces/tests/redirection/cli/shortname.yaml index 810601a..fcab967 100644 --- a/tests/integration/targets/vyos_interfaces/tests/redirection/cli/shortname.yaml +++ b/tests/integration/targets/vyos_interfaces/tests/redirection/cli/shortname.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START shortname integration tests on connection={{ ansible_connection - }} + msg: START shortname integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -31,25 +30,19 @@ - name: Assert that before dicts were correctly generated assert: - that: - "{{ merged['before'] | symmetric_difference(result['before']) |length\ - \ == 0 }}" + that: "{{ merged['before'] | symmetric_difference(result['before']) |length == 0 }}" - name: Assert that correct set of commands were generated assert: that: - - "{{ merged['commands'] | symmetric_difference(result['commands']) |length\ - \ == 0 }}" + - "{{ merged['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that after dicts was correctly generated assert: that: - - "{{ merged['after'] | symmetric_difference(result['after']) |length\ - \ == 0 }}" + - "{{ merged['after'] | symmetric_difference(result['after']) |length == 0 }}" - - name: - Merge the provided configuration with the existing running configuration - (IDEMPOTENT) + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) register: result vyos.vyos.interfaces: *id001 @@ -61,7 +54,6 @@ - name: Assert that before dicts were correctly generated assert: that: - - "{{ merged['after'] | symmetric_difference(result['before']) |length\ - \ == 0 }}" + - "{{ merged['after'] | symmetric_difference(result['before']) |length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_interfaces/vars/main.yaml b/tests/integration/targets/vyos_interfaces/vars/main.yaml index 83d0e59..7bf9b25 100644 --- a/tests/integration/targets/vyos_interfaces/vars/main.yaml +++ b/tests/integration/targets/vyos_interfaces/vars/main.yaml @@ -10,16 +10,14 @@ merged: - name: eth2 enabled: true commands: - - set interfaces ethernet eth1 description 'Configured by Ansible - Interface - 1' + - set interfaces ethernet eth1 description 'Configured by Ansible - Interface 1' - set interfaces ethernet eth1 mtu '1500' - set interfaces ethernet eth1 duplex 'auto' - set interfaces ethernet eth1 speed 'auto' - set interfaces ethernet eth1 vif 100 description 'Eth1 - VIF 100' - set interfaces ethernet eth1 vif 100 mtu '400' - set interfaces ethernet eth1 vif 101 description 'Eth1 - VIF 101' - - set interfaces ethernet eth2 description 'Configured by Ansible - Interface - 2 (ADMIN DOWN)' + - set interfaces ethernet eth2 description 'Configured by Ansible - Interface 2 (ADMIN DOWN)' - set interfaces ethernet eth2 mtu '600' - set interfaces ethernet eth2 disable after: diff --git a/tests/integration/targets/vyos_l3_interfaces/tests/cli/_populate.yaml b/tests/integration/targets/vyos_l3_interfaces/tests/cli/_populate.yaml index 2a766d5..6f6c506 100644 --- a/tests/integration/targets/vyos_l3_interfaces/tests/cli/_populate.yaml +++ b/tests/integration/targets/vyos_l3_interfaces/tests/cli/_populate.yaml @@ -3,10 +3,11 @@ - name: Setup vars: - lines: - "set interfaces ethernet eth1 address '192.0.2.14/24'\nset interfaces\ - \ ethernet eth2 address '192.0.2.10/24'\nset interfaces ethernet eth2 address\ - \ '192.0.2.11/24'\nset interfaces ethernet eth2 address '2001:db8::10/32'\n\ - set interfaces ethernet eth2 address '2001:db8::12/32'\n" + lines: |- + set interfaces ethernet eth1 address '192.0.2.14/24' + set interfaces ethernet eth2 address '192.0.2.10/24' + set interfaces ethernet eth2 address '192.0.2.11/24' + set interfaces ethernet eth2 address '2001:db8::10/32' + set interfaces ethernet eth2 address '2001:db8::12/32' ansible.netcommon.cli_config: config: "{{ lines }}" diff --git a/tests/integration/targets/vyos_l3_interfaces/tests/cli/_remove_config.yaml b/tests/integration/targets/vyos_l3_interfaces/tests/cli/_remove_config.yaml index c5acac9..aa5a628 100644 --- a/tests/integration/targets/vyos_l3_interfaces/tests/cli/_remove_config.yaml +++ b/tests/integration/targets/vyos_l3_interfaces/tests/cli/_remove_config.yaml @@ -1,9 +1,7 @@ --- - name: Remove Config vars: - lines: - "delete interfaces ethernet \"{{ intf }}\" address\ndelete interfaces\ - \ ethernet \"{{ intf }}\" vif\n" + lines: "delete interfaces ethernet \"{{ intf }}\" address\ndelete interfaces ethernet \"{{ intf }}\" vif\n" loop: - eth1 - eth2 diff --git a/tests/integration/targets/vyos_l3_interfaces/tests/cli/deleted.yaml b/tests/integration/targets/vyos_l3_interfaces/tests/cli/deleted.yaml index 9242fb5..df21b43 100644 --- a/tests/integration/targets/vyos_l3_interfaces/tests/cli/deleted.yaml +++ b/tests/integration/targets/vyos_l3_interfaces/tests/cli/deleted.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_interfaces deleted integration tests ansible_connection={{ ansible_connection - }} + msg: START vyos_interfaces deleted integration tests ansible_connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -24,14 +22,12 @@ - name: Assert that the correct set of commands were generated assert: that: - - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length\ - \ == 0 }}" + - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that the after dicts were correctly generated assert: that: - - "{{ deleted['after'] | symmetric_difference(result['after']) |length\ - \ == 0 }}" + - "{{ deleted['after'] | symmetric_difference(result['after']) |length == 0 }}" - name: Delete attributes of given interfaces (IDEMPOTENT) register: result @@ -45,7 +41,6 @@ - name: Assert that the before dicts were correctly generated assert: that: - - "{{ deleted['after'] | symmetric_difference(result['before']) |length\ - \ == 0 }}" + - "{{ deleted['after'] | symmetric_difference(result['before']) |length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_l3_interfaces/tests/cli/empty_config.yaml b/tests/integration/targets/vyos_l3_interfaces/tests/cli/empty_config.yaml index 15393fb..94b6c13 100644 --- a/tests/integration/targets/vyos_l3_interfaces/tests/cli/empty_config.yaml +++ b/tests/integration/targets/vyos_l3_interfaces/tests/cli/empty_config.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_l3_interfaces empty_config integration tests on connection={{ - ansible_connection }} + msg: START vyos_l3_interfaces empty_config integration tests on connection={{ ansible_connection }} - name: Merged with empty config should give appropriate error message register: result @@ -46,8 +44,7 @@ - assert: that: - - result.msg == 'value of running_config parameter must not be empty for state - parsed' + - result.msg == 'value of running_config parameter must not be empty for state parsed' - name: Rendered with empty config should give appropriate error message register: result diff --git a/tests/integration/targets/vyos_l3_interfaces/tests/cli/gathered.yaml b/tests/integration/targets/vyos_l3_interfaces/tests/cli/gathered.yaml index f18f7d3..41a53d8 100644 --- a/tests/integration/targets/vyos_l3_interfaces/tests/cli/gathered.yaml +++ b/tests/integration/targets/vyos_l3_interfaces/tests/cli/gathered.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_l3_interfaces gathered integration tests on connection={{ ansible_connection - }} + msg: START vyos_l3_interfaces gathered integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -16,8 +14,7 @@ - name: Assert that gathered dicts was correctly generated assert: that: - - "{{ populate | symmetric_difference(result['gathered']) |length == 0\ - \ }}" + - "{{ populate | symmetric_difference(result['gathered']) |length == 0 }}" - name: Gather the existing running configuration (IDEMPOTENT) register: result diff --git a/tests/integration/targets/vyos_l3_interfaces/tests/cli/merged.yaml b/tests/integration/targets/vyos_l3_interfaces/tests/cli/merged.yaml index d1f7bf0..4ec4d0f 100644 --- a/tests/integration/targets/vyos_l3_interfaces/tests/cli/merged.yaml +++ b/tests/integration/targets/vyos_l3_interfaces/tests/cli/merged.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_l3_interfaces merged integration tests on connection={{ ansible_connection - }} + msg: START vyos_l3_interfaces merged integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -30,25 +28,19 @@ - name: Assert that before dicts were correctly generated assert: - that: - "{{ merged['before'] | symmetric_difference(result['before']) |length\ - \ == 0 }}" + that: "{{ merged['before'] | symmetric_difference(result['before']) |length == 0 }}" - name: Assert that correct set of commands were generated assert: that: - - "{{ merged['commands'] | symmetric_difference(result['commands']) |length\ - \ == 0 }}" + - "{{ merged['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that after dicts was correctly generated assert: that: - - "{{ merged['after'] | symmetric_difference(result['after']) |length\ - \ == 0 }}" + - "{{ merged['after'] | symmetric_difference(result['after']) |length == 0 }}" - - name: - Merge the provided configuration with the existing running configuration - (IDEMPOTENT) + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_l3_interfaces: *id001 @@ -60,7 +52,6 @@ - name: Assert that before dicts were correctly generated assert: that: - - "{{ merged['after'] | symmetric_difference(result['before']) |length\ - \ == 0 }}" + - "{{ merged['after'] | symmetric_difference(result['before']) |length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_l3_interfaces/tests/cli/overridden.yaml b/tests/integration/targets/vyos_l3_interfaces/tests/cli/overridden.yaml index c12e2ae..8334a61 100644 --- a/tests/integration/targets/vyos_l3_interfaces/tests/cli/overridden.yaml +++ b/tests/integration/targets/vyos_l3_interfaces/tests/cli/overridden.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_l3_interfaces merged integration tests on connection={{ ansible_connection - }} + msg: START vyos_l3_interfaces merged integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -28,14 +26,12 @@ - name: Assert that correct commands were generated assert: that: - - "{{ overridden['commands'] | symmetric_difference(result['commands'])\ - \ |length == 0 }}" + - "{{ overridden['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that after dicts were correctly generated assert: that: - - "{{ overridden['after'] | symmetric_difference(result['after']) |length\ - \ == 0 }}" + - "{{ overridden['after'] | symmetric_difference(result['after']) |length == 0 }}" - name: Overrides all device configuration with provided configurations (IDEMPOTENT) register: result @@ -49,7 +45,6 @@ - name: Assert that before dicts were correctly generated assert: that: - - "{{ overridden['after'] | symmetric_difference(result['before']) |length\ - \ == 0 }}" + - "{{ overridden['after'] | symmetric_difference(result['before']) |length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_l3_interfaces/tests/cli/parsed.yaml b/tests/integration/targets/vyos_l3_interfaces/tests/cli/parsed.yaml index 6640271..969359f 100644 --- a/tests/integration/targets/vyos_l3_interfaces/tests/cli/parsed.yaml +++ b/tests/integration/targets/vyos_l3_interfaces/tests/cli/parsed.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_l3_nterfaces parsed integration tests on connection={{ ansible_connection - }} + msg: START vyos_l3_nterfaces parsed integration tests on connection={{ ansible_connection }} - name: Parse externally provided interfaces config to agnostic model register: result @@ -13,5 +11,4 @@ - name: Assert that config was correctly parsed assert: that: - - "{{ parsed['after'] | symmetric_difference(result['parsed']) |length ==\ - \ 0 }}" + - "{{ parsed['after'] | symmetric_difference(result['parsed']) |length == 0 }}" diff --git a/tests/integration/targets/vyos_l3_interfaces/tests/cli/rendered.yaml b/tests/integration/targets/vyos_l3_interfaces/tests/cli/rendered.yaml index 2a606c3..199879f 100644 --- a/tests/integration/targets/vyos_l3_interfaces/tests/cli/rendered.yaml +++ b/tests/integration/targets/vyos_l3_interfaces/tests/cli/rendered.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_l3_interfaces rendered integration tests on connection={{ ansible_connection - }} + msg: START vyos_l3_interfaces rendered integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -26,8 +24,7 @@ - name: Assert that correct set of commands were generated assert: that: - - "{{ rendered['commands'] | symmetric_difference(result['rendered'])\ - \ |length == 0 }}" + - "{{ rendered['commands'] | symmetric_difference(result['rendered']) |length == 0 }}" - name: Structure provided configuration into device specific commands (IDEMPOTENT) register: result diff --git a/tests/integration/targets/vyos_l3_interfaces/tests/cli/replaced.yaml b/tests/integration/targets/vyos_l3_interfaces/tests/cli/replaced.yaml index 26fe4f8..502175f 100644 --- a/tests/integration/targets/vyos_l3_interfaces/tests/cli/replaced.yaml +++ b/tests/integration/targets/vyos_l3_interfaces/tests/cli/replaced.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_l3_interfaces replaced integration tests on connection={{ ansible_connection - }} + msg: START vyos_l3_interfaces replaced integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -23,8 +21,7 @@ - name: Assert that correct set of commands were generated assert: that: - - "{{ replaced['commands'] | symmetric_difference(result['commands'])\ - \ |length == 0 }}" + - "{{ replaced['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that before dicts are correctly generated assert: @@ -34,12 +31,9 @@ - name: Assert that after dict is correctly generated assert: that: - - "{{ replaced['after'] | symmetric_difference(result['after']) |length\ - \ == 0 }}" + - "{{ replaced['after'] | symmetric_difference(result['after']) |length == 0 }}" - - name: - Replace device configurations of listed interfaces with provided configurarions - (IDEMPOTENT) + - name: Replace device configurations of listed interfaces with provided configurarions (IDEMPOTENT) register: result vyos.vyos.vyos_l3_interfaces: *id001 @@ -51,7 +45,6 @@ - name: Assert that before dict is correctly generated assert: that: - - "{{ replaced['after'] | symmetric_difference(result['before']) |length\ - \ == 0 }}" + - "{{ replaced['after'] | symmetric_difference(result['before']) |length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_l3_interfaces/tests/redirection/cli/shortname.yaml b/tests/integration/targets/vyos_l3_interfaces/tests/redirection/cli/shortname.yaml index 963ab55..6debbee 100644 --- a/tests/integration/targets/vyos_l3_interfaces/tests/redirection/cli/shortname.yaml +++ b/tests/integration/targets/vyos_l3_interfaces/tests/redirection/cli/shortname.yaml @@ -24,8 +24,7 @@ - name: Assert that correct set of commands were generated assert: that: - - "{{ rendered['commands'] | symmetric_difference(result['rendered'])\ - \ |length == 0 }}" + - "{{ rendered['commands'] | symmetric_difference(result['rendered']) |length == 0 }}" - name: Structure provided configuration into device specific commands (IDEMPOTENT) register: result diff --git a/tests/integration/targets/vyos_lag_interfaces/tests/cli/_populate.yaml b/tests/integration/targets/vyos_lag_interfaces/tests/cli/_populate.yaml index d519d28..be0d635 100644 --- a/tests/integration/targets/vyos_lag_interfaces/tests/cli/_populate.yaml +++ b/tests/integration/targets/vyos_lag_interfaces/tests/cli/_populate.yaml @@ -3,12 +3,16 @@ - name: Setup vars: - lines: - "set interfaces bonding bond0\nset interfaces bonding bond0 hash-policy\ - \ 'layer2'\nset interfaces bonding bond0 mode 'active-backup'\nset interfaces\ - \ ethernet eth1 bond-group bond0\nset interfaces bonding bond1\nset interfaces\ - \ bonding bond0 primary 'eth1'\nset interfaces bonding bond1 hash-policy 'layer2+3'\n\ - set interfaces bonding bond1 mode 'active-backup'\nset interfaces ethernet\ - \ eth2 bond-group bond1\nset interfaces bonding bond1 primary 'eth2'\n" + lines: |- + set interfaces bonding bond0 + set interfaces bonding bond0 hash-policy 'layer2' + set interfaces bonding bond0 mode 'active-backup' + set interfaces ethernet eth1 bond-group bond0 + set interfaces bonding bond1 + set interfaces bonding bond0 primary 'eth1' + set interfaces bonding bond1 hash-policy 'layer2+3' + set interfaces bonding bond1 mode 'active-backup' + set interfaces ethernet eth2 bond-group bond1 + set interfaces bonding bond1 primary 'eth2' ansible.netcommon.cli_config: config: "{{ lines }}" diff --git a/tests/integration/targets/vyos_lag_interfaces/tests/cli/_remove_bond.yaml b/tests/integration/targets/vyos_lag_interfaces/tests/cli/_remove_bond.yaml index 017c56a..e22a6ca 100644 --- a/tests/integration/targets/vyos_lag_interfaces/tests/cli/_remove_bond.yaml +++ b/tests/integration/targets/vyos_lag_interfaces/tests/cli/_remove_bond.yaml @@ -1,17 +1,21 @@ ---- - name: Remove Config vars: - lines: - "delete interfaces bonding bond0 hash-policy\ndelete interfaces ethernet\ - \ eth1 bond-group bond0\ndelete interfaces bonding bond0 mode\ndelete interfaces\ - \ bonding bond0 primary\ndelete interfaces bonding bond1 hash-policy\ndelete\ - \ interfaces ethernet eth2 bond-group bond1\ndelete interfaces bonding bond1\ - \ mode\ndelete interfaces bonding bond1 primary\n" + lines: |- + delete interfaces bonding bond0 hash-policy + delete interfaces ethernet eth1 bond-group bond0 + delete interfaces bonding bond0 mode + delete interfaces bonding bond0 primary + delete interfaces bonding bond1 hash-policy + delete interfaces ethernet eth2 bond-group bond1 + delete interfaces bonding bond1 mode + delete interfaces bonding bond1 primary ansible.netcommon.cli_config: config: "{{ lines }}" - name: Remove Bond vars: - lines: "delete interfaces bonding bond0\ndelete interfaces bonding bond1\n" + lines: | + delete interfaces bonding bond0 + delete interfaces bonding bond1 ansible.netcommon.cli_config: config: "{{ lines }}" diff --git a/tests/integration/targets/vyos_lag_interfaces/tests/cli/deleted.yaml b/tests/integration/targets/vyos_lag_interfaces/tests/cli/deleted.yaml index ae15884..e30be07 100644 --- a/tests/integration/targets/vyos_lag_interfaces/tests/cli/deleted.yaml +++ b/tests/integration/targets/vyos_lag_interfaces/tests/cli/deleted.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_lag_interfaces deleted integration tests ansible_connection={{ - ansible_connection }} + msg: START vyos_lag_interfaces deleted integration tests ansible_connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -24,14 +22,12 @@ - name: Assert that the correct set of commands were generated assert: that: - - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length\ - \ == 0 }}" + - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that the after dicts were correctly generated assert: that: - - "{{ deleted['after'] | symmetric_difference(result['after']) |length\ - \ == 0 }}" + - "{{ deleted['after'] | symmetric_difference(result['after']) |length == 0 }}" - name: Delete attributes of given interfaces (IDEMPOTENT) register: result @@ -45,7 +41,6 @@ - name: Assert that the before dicts were correctly generated assert: that: - - "{{ deleted['after'] | symmetric_difference(result['before']) |length\ - \ == 0 }}" + - "{{ deleted['after'] | symmetric_difference(result['before']) |length == 0 }}" always: - include_tasks: _remove_bond.yaml diff --git a/tests/integration/targets/vyos_lag_interfaces/tests/cli/empty_config.yaml b/tests/integration/targets/vyos_lag_interfaces/tests/cli/empty_config.yaml index 22ac8a8..efe8936 100644 --- a/tests/integration/targets/vyos_lag_interfaces/tests/cli/empty_config.yaml +++ b/tests/integration/targets/vyos_lag_interfaces/tests/cli/empty_config.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_lag_interfaces empty_config integration tests on connection={{ - ansible_connection }} + msg: START vyos_lag_interfaces empty_config integration tests on connection={{ ansible_connection }} - name: Merged with empty config should give appropriate error message register: result @@ -46,8 +44,7 @@ - assert: that: - - result.msg == 'value of running_config parameter must not be empty for state - parsed' + - result.msg == 'value of running_config parameter must not be empty for state parsed' - name: Rendered with empty config should give appropriate error message register: result diff --git a/tests/integration/targets/vyos_lag_interfaces/tests/cli/gathered.yaml b/tests/integration/targets/vyos_lag_interfaces/tests/cli/gathered.yaml index caa8f30..f6c281f 100644 --- a/tests/integration/targets/vyos_lag_interfaces/tests/cli/gathered.yaml +++ b/tests/integration/targets/vyos_lag_interfaces/tests/cli/gathered.yaml @@ -1,23 +1,20 @@ --- - debug: - msg: - START vyos_lag_interfaces gathered integration tests on connection={{ ansible_connection - }} + msg: START vyos_lag_interfaces gathered integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml - block: - name: Gather the provided configuration with the existing running configuration register: result - vyos.vyos.vyos_lag_interfaces: &id001 + vyos.vyos.vyos_lag_interfaces: config: state: gathered - name: Assert that gathered dicts was correctly generated assert: that: - - "{{ populate | symmetric_difference(result['gathered']) |length == 0\ - \ }}" + - "{{ populate | symmetric_difference(result['gathered']) |length == 0 }}" always: - include_tasks: _remove_bond.yaml diff --git a/tests/integration/targets/vyos_lag_interfaces/tests/cli/merged.yaml b/tests/integration/targets/vyos_lag_interfaces/tests/cli/merged.yaml index 8e6c764..64ac9a4 100644 --- a/tests/integration/targets/vyos_lag_interfaces/tests/cli/merged.yaml +++ b/tests/integration/targets/vyos_lag_interfaces/tests/cli/merged.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_lag_interfaces merged integration tests on connection={{ ansible_connection - }} + msg: START vyos_lag_interfaces merged integration tests on connection={{ ansible_connection }} - include_tasks: _add_bond.yaml @@ -28,25 +26,19 @@ - name: Assert that before dicts were correctly generated assert: - that: - "{{ merged['before'] | symmetric_difference(result['before']) |length\ - \ == 0 }}" + that: "{{ merged['before'] | symmetric_difference(result['before']) |length == 0 }}" - name: Assert that correct set of commands were generated assert: that: - - "{{ merged['commands'] | symmetric_difference(result['commands']) |length\ - \ == 0 }}" + - "{{ merged['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that after dicts was correctly generated assert: that: - - "{{ merged['after'] | symmetric_difference(result['after']) |length\ - \ == 0 }}" + - "{{ merged['after'] | symmetric_difference(result['after']) |length == 0 }}" - - name: - Merge the provided configuration with the existing running configuration - (IDEMPOTENT) + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_lag_interfaces: *id001 @@ -58,7 +50,6 @@ - name: Assert that before dicts were correctly generated assert: that: - - "{{ merged['after'] | symmetric_difference(result['before']) |length\ - \ == 0 }}" + - "{{ merged['after'] | symmetric_difference(result['before']) |length == 0 }}" always: - include_tasks: _remove_bond.yaml diff --git a/tests/integration/targets/vyos_lag_interfaces/tests/cli/overridden.yaml b/tests/integration/targets/vyos_lag_interfaces/tests/cli/overridden.yaml index 93aa7d9..482d54d 100644 --- a/tests/integration/targets/vyos_lag_interfaces/tests/cli/overridden.yaml +++ b/tests/integration/targets/vyos_lag_interfaces/tests/cli/overridden.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_lag_interfaces overridden integration tests on connection={{ - ansible_connection }} + msg: START vyos_lag_interfaces overridden integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -26,14 +25,12 @@ - name: Assert that correct commands were generated assert: that: - - "{{ overridden['commands'] | symmetric_difference(result['commands'])\ - \ |length == 0 }}" + - "{{ overridden['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that after dicts were correctly generated assert: that: - - "{{ overridden['after'] | symmetric_difference(result['after']) |length\ - \ == 0 }}" + - "{{ overridden['after'] | symmetric_difference(result['after']) |length == 0 }}" - name: Overrides all device configuration with provided configurations (IDEMPOTENT) register: result @@ -47,7 +44,6 @@ - name: Assert that before dicts were correctly generated assert: that: - - "{{ overridden['after'] | symmetric_difference(result['before']) |length\ - \ == 0 }}" + - "{{ overridden['after'] | symmetric_difference(result['before']) |length == 0 }}" always: - include_tasks: _remove_bond.yaml diff --git a/tests/integration/targets/vyos_lag_interfaces/tests/cli/parsed.yaml b/tests/integration/targets/vyos_lag_interfaces/tests/cli/parsed.yaml index 412dcaf..81a7b46 100644 --- a/tests/integration/targets/vyos_lag_interfaces/tests/cli/parsed.yaml +++ b/tests/integration/targets/vyos_lag_interfaces/tests/cli/parsed.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_lag_interfaces parsed integration tests on connection={{ ansible_connection - }} + msg: START vyos_lag_interfaces parsed integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -23,9 +21,7 @@ - name: Assert that correct parsing done assert: - that: - "{{ ansible_facts['network_resources']['lag_interfaces'] | symmetric_difference(result['parsed'])\ - \ |length == 0 }}" + that: "{{ ansible_facts['network_resources']['lag_interfaces'] | symmetric_difference(result['parsed']) |length == 0 }}" always: - include_tasks: _remove_bond.yaml diff --git a/tests/integration/targets/vyos_lag_interfaces/tests/cli/rendered.yaml b/tests/integration/targets/vyos_lag_interfaces/tests/cli/rendered.yaml index ad05199..7d86a3a 100644 --- a/tests/integration/targets/vyos_lag_interfaces/tests/cli/rendered.yaml +++ b/tests/integration/targets/vyos_lag_interfaces/tests/cli/rendered.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_lag_interfaces rendered integration tests on connection={{ ansible_connection - }} + msg: START vyos_lag_interfaces rendered integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -28,8 +26,7 @@ - name: Assert that correct set of commands were generated assert: that: - - "{{ rendered['commands'] | symmetric_difference(result['rendered'])\ - \ |length == 0 }}" + - "{{ rendered['commands'] | symmetric_difference(result['rendered']) |length == 0 }}" always: - include_tasks: _remove_bond.yaml diff --git a/tests/integration/targets/vyos_lag_interfaces/tests/cli/replaced.yaml b/tests/integration/targets/vyos_lag_interfaces/tests/cli/replaced.yaml index 2e6de6c..66e55df 100644 --- a/tests/integration/targets/vyos_lag_interfaces/tests/cli/replaced.yaml +++ b/tests/integration/targets/vyos_lag_interfaces/tests/cli/replaced.yaml @@ -1,14 +1,11 @@ --- - debug: - msg: - START vyos_lag_interfaces replaced integration tests on connection={{ ansible_connection - }} + msg: START vyos_lag_interfaces replaced integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml - block: - - name: Replace device configurations of listed LAG interfaces with provided - configurations + - name: Replace device configurations of listed LAG interfaces with provided configurations register: result vyos.vyos.vyos_lag_interfaces: &id001 config: @@ -22,8 +19,7 @@ - name: Assert that correct set of commands were generated assert: that: - - "{{ replaced['commands'] | symmetric_difference(result['commands'])\ - \ |length == 0 }}" + - "{{ replaced['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that before dicts are correctly generated assert: @@ -33,11 +29,9 @@ - name: Assert that after dict is correctly generated assert: that: - - "{{ replaced['after'] | symmetric_difference(result['after']) |length\ - \ == 0 }}" + - "{{ replaced['after'] | symmetric_difference(result['after']) |length == 0 }}" - - name: Replace device configurations of listed LAG interfaces with provided - configurarions (IDEMPOTENT) + - name: Replace device configurations of listed LAG interfaces with provided configurarions (IDEMPOTENT) register: result vyos.vyos.vyos_lag_interfaces: *id001 @@ -49,7 +43,6 @@ - name: Assert that before dict is correctly generated assert: that: - - "{{ replaced['after'] | symmetric_difference(result['before']) |length\ - \ == 0 }}" + - "{{ replaced['after'] | symmetric_difference(result['before']) |length == 0 }}" always: - include_tasks: _remove_bond.yaml diff --git a/tests/integration/targets/vyos_lag_interfaces/tests/cli/rtt.yaml b/tests/integration/targets/vyos_lag_interfaces/tests/cli/rtt.yaml index 0e7c178..5e9dc75 100644 --- a/tests/integration/targets/vyos_lag_interfaces/tests/cli/rtt.yaml +++ b/tests/integration/targets/vyos_lag_interfaces/tests/cli/rtt.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_lag_interfaces round trip integration tests on connection={{ - ansible_connection }} + msg: START vyos_lag_interfaces round trip integration tests on connection={{ ansible_connection }} - include_tasks: _remove_bond.yaml @@ -51,9 +50,7 @@ - name: Assert that changes were applied assert: - that: - "{{ round_trip['after'] | symmetric_difference(result['after']) |length\ - \ == 0 }}" + that: "{{ round_trip['after'] | symmetric_difference(result['after']) |length == 0 }}" - name: Revert back to base config using facts round trip register: revert @@ -63,8 +60,6 @@ - name: Assert that config was reverted assert: - that: - "{{ base_config['after'] | symmetric_difference(revert['after']) |length\ - \ == 0 }}" + that: "{{ base_config['after'] | symmetric_difference(revert['after']) |length == 0 }}" always: - include_tasks: _remove_bond.yaml diff --git a/tests/integration/targets/vyos_lag_interfaces/tests/redirection/cli/shortname.yaml b/tests/integration/targets/vyos_lag_interfaces/tests/redirection/cli/shortname.yaml index 876563c..40c5fe2 100644 --- a/tests/integration/targets/vyos_lag_interfaces/tests/redirection/cli/shortname.yaml +++ b/tests/integration/targets/vyos_lag_interfaces/tests/redirection/cli/shortname.yaml @@ -26,25 +26,19 @@ - name: Assert that before dicts were correctly generated assert: - that: - "{{ merged['before'] | symmetric_difference(result['before']) |length\ - \ == 0 }}" + that: "{{ merged['before'] | symmetric_difference(result['before']) |length == 0 }}" - name: Assert that correct set of commands were generated assert: that: - - "{{ merged['commands'] | symmetric_difference(result['commands']) |length\ - \ == 0 }}" + - "{{ merged['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that after dicts was correctly generated assert: that: - - "{{ merged['after'] | symmetric_difference(result['after']) |length\ - \ == 0 }}" + - "{{ merged['after'] | symmetric_difference(result['after']) |length == 0 }}" - - name: - Merge the provided configuration with the existing running configuration - (IDEMPOTENT) + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) register: result vyos.vyos.lag_interfaces: *id001 @@ -56,7 +50,6 @@ - name: Assert that before dicts were correctly generated assert: that: - - "{{ merged['after'] | symmetric_difference(result['before']) |length\ - \ == 0 }}" + - "{{ merged['after'] | symmetric_difference(result['before']) |length == 0 }}" always: - include_tasks: _remove_bond.yaml diff --git a/tests/integration/targets/vyos_lldp_global/tests/cli/_populate.yaml b/tests/integration/targets/vyos_lldp_global/tests/cli/_populate.yaml index eb0f21e..2547872 100644 --- a/tests/integration/targets/vyos_lldp_global/tests/cli/_populate.yaml +++ b/tests/integration/targets/vyos_lldp_global/tests/cli/_populate.yaml @@ -3,8 +3,6 @@ - name: Setup vars: - lines: - "set service lldp\nset service lldp legacy-protocols 'cdp'\nset service\ - \ lldp management-address '192.0.2.17'\n" + lines: "set service lldp\nset service lldp legacy-protocols 'cdp'\nset service lldp management-address '192.0.2.17'\n" ansible.netcommon.cli_config: config: "{{ lines }}" diff --git a/tests/integration/targets/vyos_lldp_global/tests/cli/_remove_config.yaml b/tests/integration/targets/vyos_lldp_global/tests/cli/_remove_config.yaml index 7e5b37c..406bc79 100644 --- a/tests/integration/targets/vyos_lldp_global/tests/cli/_remove_config.yaml +++ b/tests/integration/targets/vyos_lldp_global/tests/cli/_remove_config.yaml @@ -1,8 +1,6 @@ --- - name: Remove Config vars: - lines: - "delete service lldp legacy-protocols\ndelete service lldp management-address\n\ - delete service lldp\n" + lines: "delete service lldp legacy-protocols\ndelete service lldp management-address\ndelete service lldp\n" ansible.netcommon.cli_config: config: "{{ lines }}" diff --git a/tests/integration/targets/vyos_lldp_global/tests/cli/deleted.yaml b/tests/integration/targets/vyos_lldp_global/tests/cli/deleted.yaml index 0d36e5f..9cf87b8 100644 --- a/tests/integration/targets/vyos_lldp_global/tests/cli/deleted.yaml +++ b/tests/integration/targets/vyos_lldp_global/tests/cli/deleted.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_lldp_global deleted integration tests ansible_connection={{ - ansible_connection }} + msg: START vyos_lldp_global deleted integration tests ansible_connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -20,8 +19,7 @@ - name: Assert that the correct set of commands were generated assert: that: - - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length\ - \ == 0 }}" + - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that the after dicts were correctly generated assert: diff --git a/tests/integration/targets/vyos_lldp_global/tests/cli/empty_config.yaml b/tests/integration/targets/vyos_lldp_global/tests/cli/empty_config.yaml index 0333fa4..c3811f6 100644 --- a/tests/integration/targets/vyos_lldp_global/tests/cli/empty_config.yaml +++ b/tests/integration/targets/vyos_lldp_global/tests/cli/empty_config.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_lldp_global empty_config integration tests on connection={{ - ansible_connection }} + msg: START vyos_lldp_global empty_config integration tests on connection={{ ansible_connection }} - name: Merged with empty config should give appropriate error message register: result @@ -34,8 +33,7 @@ - assert: that: - - result.msg == 'value of running_config parameter must not be empty for state - parsed' + - result.msg == 'value of running_config parameter must not be empty for state parsed' - name: Rendered with empty config should give appropriate error message register: result diff --git a/tests/integration/targets/vyos_lldp_global/tests/cli/gathered.yaml b/tests/integration/targets/vyos_lldp_global/tests/cli/gathered.yaml index 46e5b36..9c24e58 100644 --- a/tests/integration/targets/vyos_lldp_global/tests/cli/gathered.yaml +++ b/tests/integration/targets/vyos_lldp_global/tests/cli/gathered.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_lldp_global gathered integration tests on connection={{ - ansible_connection }} + msg: START vyos_lldp_global gathered integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml diff --git a/tests/integration/targets/vyos_lldp_global/tests/cli/merged.yaml b/tests/integration/targets/vyos_lldp_global/tests/cli/merged.yaml index 85a35f6..a2e8e6b 100644 --- a/tests/integration/targets/vyos_lldp_global/tests/cli/merged.yaml +++ b/tests/integration/targets/vyos_lldp_global/tests/cli/merged.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_lldp_global merged integration tests on connection={{ ansible_connection - }} + msg: START vyos_lldp_global merged integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -24,17 +22,14 @@ - name: Assert that correct set of commands were generated assert: that: - - "{{ merged['commands'] | symmetric_difference(result['commands']) |length\ - \ == 0 }}" + - "{{ merged['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that after dicts was correctly generated assert: that: - "{{ merged['after'] == result['after'] }}" - - name: - Merge the provided configuration with the existing running configuration - (IDEMPOTENT) + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_lldp_global: *id001 diff --git a/tests/integration/targets/vyos_lldp_global/tests/cli/parsed.yaml b/tests/integration/targets/vyos_lldp_global/tests/cli/parsed.yaml index 1047f30..f8fe762 100644 --- a/tests/integration/targets/vyos_lldp_global/tests/cli/parsed.yaml +++ b/tests/integration/targets/vyos_lldp_global/tests/cli/parsed.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_lldp_global parsed integration tests on connection={{ ansible_connection - }} + msg: START vyos_lldp_global parsed integration tests on connection={{ ansible_connection }} - name: Parse externally provided LLDP global config to agnostic model register: result diff --git a/tests/integration/targets/vyos_lldp_global/tests/cli/rendered.yaml b/tests/integration/targets/vyos_lldp_global/tests/cli/rendered.yaml index 59ff032..b293214 100644 --- a/tests/integration/targets/vyos_lldp_global/tests/cli/rendered.yaml +++ b/tests/integration/targets/vyos_lldp_global/tests/cli/rendered.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_lldp_global rendered integration tests on connection={{ - ansible_connection }} + msg: START vyos_lldp_global rendered integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -19,8 +18,7 @@ - name: Assert that correct set of commands were generated assert: that: - - "{{ rendered['commands'] | symmetric_difference(result['rendered'])\ - \ |length == 0 }}" + - "{{ rendered['commands'] | symmetric_difference(result['rendered']) |length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_lldp_global/tests/cli/replaced.yaml b/tests/integration/targets/vyos_lldp_global/tests/cli/replaced.yaml index 55874b7..c74aa46 100644 --- a/tests/integration/targets/vyos_lldp_global/tests/cli/replaced.yaml +++ b/tests/integration/targets/vyos_lldp_global/tests/cli/replaced.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_lldp_global replaced integration tests on connection={{ ansible_connection - }} + msg: START vyos_lldp_global replaced integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -21,8 +19,7 @@ - name: Assert that correct set of commands were generated assert: that: - - "{{ replaced['commands'] | symmetric_difference(result['commands'])\ - \ |length == 0 }}" + - "{{ replaced['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that before dicts are correctly generated assert: @@ -34,9 +31,7 @@ that: - "{{ replaced['after'] == result['after'] }}" - - name: - Replace device configurations of LLDP service with provided configurarions - (IDEMPOTENT) + - name: Replace device configurations of LLDP service with provided configurarions (IDEMPOTENT) register: result vyos.vyos.vyos_lldp_global: *id001 diff --git a/tests/integration/targets/vyos_lldp_global/tests/cli/rtt.yaml b/tests/integration/targets/vyos_lldp_global/tests/cli/rtt.yaml index b0bd603..10fe454 100644 --- a/tests/integration/targets/vyos_lldp_global/tests/cli/rtt.yaml +++ b/tests/integration/targets/vyos_lldp_global/tests/cli/rtt.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_lldp_global round trip integration tests on connection={{ ansible_connection - }} + msg: START vyos_lldp_global round trip integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/_populate.yaml b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/_populate.yaml index 2c6782b..5ed9e98 100644 --- a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/_populate.yaml +++ b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/_populate.yaml @@ -3,13 +3,14 @@ - name: Setup vars: - lines: - "set service lldp interface eth1\nset service lldp interface eth1 location\ - \ civic-based country-code US\nset service lldp interface eth1 location civic-based\ - \ ca-type 0 ca-value ENGLISH\nset service lldp interface eth2\nset service\ - \ lldp interface eth2 location coordinate-based latitude 33.524449N\nset service\ - \ lldp interface eth2 location coordinate-based altitude 2200\nset service\ - \ lldp interface eth2 location coordinate-based datum WGS84\nset service lldp\ - \ interface eth2 location coordinate-based longitude 222.267255W\n" + lines: >- + "set service lldp interface eth1\nset service lldp interface eth1 location + civic-based country-code US\nset service lldp interface eth1 location + civic-based ca-type 0 ca-value ENGLISH\nset service lldp interface + eth2\nset service lldp interface eth2 location coordinate-based latitude + 33.524449N\nset service lldp interface eth2 location coordinate-based + altitude 2200\nset service lldp interface eth2 location coordinate-based + datum WGS84\nset service lldp interface eth2 location coordinate-based + longitude 222.267255W\n" ansible.netcommon.cli_config: config: "{{ lines }}" diff --git a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/_populate_intf.yaml b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/_populate_intf.yaml index 208f21e..c1e3a8c 100644 --- a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/_populate_intf.yaml +++ b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/_populate_intf.yaml @@ -1,9 +1,10 @@ --- - name: Setup vars: - lines: - "set service lldp interface eth2\nset service lldp interface eth2 location\ - \ civic-based country-code US\nset service lldp interface eth2 location civic-based\ - \ ca-type 0 ca-value ENGLISH\nset service lldp interface eth2 disable\n" + lines: >- + "set service lldp interface eth2 + \nset service lldp interface eth2 location civic-based country-code US + \nset service lldp interface eth2 location civic-based ca-type 0 ca-value ENGLISH + \nset service lldp interface eth2 disable" ansible.netcommon.cli_config: config: "{{ lines }}" diff --git a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/deleted.yaml b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/deleted.yaml index 776fa22..c522704 100644 --- a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/deleted.yaml +++ b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/deleted.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_lldp_interfaces deleted integration tests ansible_connection={{ - ansible_connection }} + msg: START vyos_lldp_interfaces deleted integration tests ansible_connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -24,14 +22,12 @@ - name: Assert that the correct set of commands were generated assert: that: - - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length\ - \ == 0 }}" + - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that the after dicts were correctly generated assert: that: - - "{{ deleted['after'] | symmetric_difference(result['after']) |length\ - \ == 0 }}" + - "{{ deleted['after'] | symmetric_difference(result['after']) |length == 0 }}" - name: Delete attributes of given interfaces (IDEMPOTENT) register: result @@ -46,7 +42,6 @@ - name: Assert that the before dicts were correctly generated assert: that: - - "{{ deleted['after'] | symmetric_difference(result['before']) |length\ - \ == 0 }}" + - "{{ deleted['after'] | symmetric_difference(result['before']) |length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/empty_config.yaml b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/empty_config.yaml index 6c097e3..209f828 100644 --- a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/empty_config.yaml +++ b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/empty_config.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_lldp_interfaces empty_config integration tests on connection={{ - ansible_connection }} + msg: START vyos_lldp_interfaces empty_config integration tests on connection={{ ansible_connection }} - name: Merged with empty config should give appropriate error message register: result @@ -46,8 +44,7 @@ - assert: that: - - result.msg == 'value of running_config parameter must not be empty for state - parsed' + - result.msg == 'value of running_config parameter must not be empty for state parsed' - name: Rendered with empty config should give appropriate error message register: result diff --git a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/gathered.yaml b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/gathered.yaml index 216f2d1..7b8e778 100644 --- a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/gathered.yaml +++ b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/gathered.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_lldp_interfaces gathered integration tests on connection={{ ansible_connection - }} + msg: START vyos_lldp_interfaces gathered integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -16,7 +14,6 @@ - name: Assert that gathered dicts was correctly generated assert: that: - - "{{ populate | symmetric_difference(result['gathered']) |length == 0\ - \ }}" + - "{{ populate | symmetric_difference(result['gathered']) |length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/merged.yaml b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/merged.yaml index 30c46ec..ecf7597 100644 --- a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/merged.yaml +++ b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/merged.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_lldp_interfaces merged integration tests on connection={{ ansible_connection - }} + msg: START vyos_lldp_interfaces merged integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -30,25 +28,19 @@ - name: Assert that before dicts were correctly generated assert: - that: - "{{ merged['before'] | symmetric_difference(result['before']) |length\ - \ == 0 }}" + that: "{{ merged['before'] | symmetric_difference(result['before']) |length == 0 }}" - name: Assert that correct set of commands were generated assert: that: - - "{{ merged['commands'] | symmetric_difference(result['commands']) |length\ - \ == 0 }}" + - "{{ merged['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that after dicts was correctly generated assert: that: - - "{{ merged['after'] | symmetric_difference(result['after']) |length\ - \ == 0 }}" + - "{{ merged['after'] | symmetric_difference(result['after']) |length == 0 }}" - - name: - Merge the provided configuration with the existing running configuration - (IDEMPOTENT) + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_lldp_interfaces: *id001 @@ -60,7 +52,6 @@ - name: Assert that before dicts were correctly generated assert: that: - - "{{ merged['after'] | symmetric_difference(result['before']) |length\ - \ == 0 }}" + - "{{ merged['after'] | symmetric_difference(result['before']) |length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/overridden.yaml b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/overridden.yaml index e077e01..7050481 100644 --- a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/overridden.yaml +++ b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/overridden.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_lldp_interfaces overridden integration tests on connection={{ - ansible_connection }} + msg: START vyos_lldp_interfaces overridden integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -21,20 +19,17 @@ - name: Assert that before dicts were correctly generated assert: that: - - "{{ populate_intf | symmetric_difference(result['before']) |length ==\ - \ 0 }}" + - "{{ populate_intf | symmetric_difference(result['before']) |length == 0 }}" - name: Assert that correct commands were generated assert: that: - - "{{ overridden['commands'] | symmetric_difference(result['commands'])\ - \ |length == 0 }}" + - "{{ overridden['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that after dicts were correctly generated assert: that: - - "{{ overridden['after'] | symmetric_difference(result['after']) |length\ - \ == 0 }}" + - "{{ overridden['after'] | symmetric_difference(result['after']) |length == 0 }}" - name: Overrides all device configuration with provided configurations (IDEMPOTENT) register: result @@ -48,7 +43,6 @@ - name: Assert that before dicts were correctly generated assert: that: - - "{{ overridden['after'] | symmetric_difference(result['before']) |length\ - \ == 0 }}" + - "{{ overridden['after'] | symmetric_difference(result['before']) |length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/parsed.yaml b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/parsed.yaml index a32e9d5..c312934 100644 --- a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/parsed.yaml +++ b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/parsed.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_lldp_nterfaces parsed integration tests on connection={{ ansible_connection - }} + msg: START vyos_lldp_nterfaces parsed integration tests on connection={{ ansible_connection }} - name: Parse externally provided interfaces config to agnostic model register: result @@ -13,5 +11,4 @@ - name: Assert that config was correctly parsed assert: that: - - "{{ parsed['after'] | symmetric_difference(result['parsed']) |length ==\ - \ 0 }}" + - "{{ parsed['after'] | symmetric_difference(result['parsed']) |length == 0 }}" diff --git a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/rendered.yaml b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/rendered.yaml index 87bed90..3eb2538 100644 --- a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/rendered.yaml +++ b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/rendered.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_lldp_interfaces rendered integration tests on connection={{ ansible_connection - }} + msg: START vyos_lldp_interfaces rendered integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -30,7 +28,6 @@ - name: Assert that correct set of commands were generated assert: that: - - "{{ rendered['commands'] | symmetric_difference(result['rendered'])\ - \ |length == 0 }}" + - "{{ rendered['commands'] | symmetric_difference(result['rendered']) |length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/replaced.yaml b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/replaced.yaml index 46c91cf..e914c99 100644 --- a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/replaced.yaml +++ b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/replaced.yaml @@ -1,14 +1,11 @@ --- - debug: - msg: START vyos_lldp_interfaces replaced integration tests on connection={{ - ansible_connection }} + msg: START vyos_lldp_interfaces replaced integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml - block: - - name: - Replace device configurations of listed LLDP interfaces with provided - configurations + - name: Replace device configurations of listed LLDP interfaces with provided configurations register: result vyos.vyos.vyos_lldp_interfaces: &id001 config: @@ -34,8 +31,7 @@ - name: Assert that correct set of commands were generated assert: that: - - "{{ replaced['commands'] | symmetric_difference(result['commands'])\ - \ |length == 0 }}" + - "{{ replaced['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that before dicts are correctly generated assert: @@ -45,12 +41,9 @@ - name: Assert that after dict is correctly generated assert: that: - - "{{ replaced['after'] | symmetric_difference(result['after']) |length\ - \ == 0 }}" + - "{{ replaced['after'] | symmetric_difference(result['after']) |length == 0 }}" - - name: - Replace device configurations of listed LLDP interfaces with provided - configurarions (IDEMPOTENT) + - name: Replace device configurations of listed LLDP interfaces with provided configurarions (IDEMPOTENT) register: result vyos.vyos.vyos_lldp_interfaces: *id001 @@ -62,7 +55,6 @@ - name: Assert that before dict is correctly generated assert: that: - - "{{ replaced['after'] | symmetric_difference(result['before']) |length\ - \ == 0 }}" + - "{{ replaced['after'] | symmetric_difference(result['before']) |length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/rtt.yaml b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/rtt.yaml index e23253b..6cf5d69 100644 --- a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/rtt.yaml +++ b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/rtt.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_lldp_interfaces round trip integration tests on connection={{ - ansible_connection }} + msg: START vyos_lldp_interfaces round trip integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -42,9 +40,7 @@ - name: Assert that changes were applied assert: - that: - "{{ round_trip['after'] | symmetric_difference(result['after']) |length\ - \ == 0 }}" + that: "{{ round_trip['after'] | symmetric_difference(result['after']) |length == 0 }}" - name: Revert back to base config using facts round trip register: revert @@ -54,8 +50,6 @@ - name: Assert that config was reverted assert: - that: - "{{ base_config['after'] | symmetric_difference(revert['after']) |length\ - \ == 0 }}" + that: "{{ base_config['after'] | symmetric_difference(revert['after']) |length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_lldp_interfaces/tests/redirection/cli/shortname.yaml b/tests/integration/targets/vyos_lldp_interfaces/tests/redirection/cli/shortname.yaml index 0b06a74..c21192a 100644 --- a/tests/integration/targets/vyos_lldp_interfaces/tests/redirection/cli/shortname.yaml +++ b/tests/integration/targets/vyos_lldp_interfaces/tests/redirection/cli/shortname.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START shortaname integration tests on connection={{ - ansible_connection }} + msg: START shortaname integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -20,20 +19,17 @@ - name: Assert that before dicts were correctly generated assert: that: - - "{{ populate_intf | symmetric_difference(result['before']) |length ==\ - \ 0 }}" + - "{{ populate_intf | symmetric_difference(result['before']) |length == 0 }}" - name: Assert that correct commands were generated assert: that: - - "{{ overridden['commands'] | symmetric_difference(result['commands'])\ - \ |length == 0 }}" + - "{{ overridden['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that after dicts were correctly generated assert: that: - - "{{ overridden['after'] | symmetric_difference(result['after']) |length\ - \ == 0 }}" + - "{{ overridden['after'] | symmetric_difference(result['after']) |length == 0 }}" - name: Overrides all device configuration with provided configurations (IDEMPOTENT) register: result @@ -47,7 +43,6 @@ - name: Assert that before dicts were correctly generated assert: that: - - "{{ overridden['after'] | symmetric_difference(result['before']) |length\ - \ == 0 }}" + - "{{ overridden['after'] | symmetric_difference(result['before']) |length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_logging_global/tests/cli/deleted.yaml b/tests/integration/targets/vyos_logging_global/tests/cli/deleted.yaml index cd89ac5..d6bb462 100644 --- a/tests/integration/targets/vyos_logging_global/tests/cli/deleted.yaml +++ b/tests/integration/targets/vyos_logging_global/tests/cli/deleted.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START Deleted integration state for vyos_logging ansible_connection={{ - ansible_connection }} + msg: START Deleted integration state for vyos_logging ansible_connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -14,8 +13,7 @@ - name: TEST - [deleted] Assert that correct set of commands were generated assert: that: - - "{{ deleted['commands'] | symmetric_difference(result['commands']) |\ - \ length == 0 }}" + - "{{ deleted['commands'] | symmetric_difference(result['commands']) | length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_logging_global/tests/cli/empty_config.yaml b/tests/integration/targets/vyos_logging_global/tests/cli/empty_config.yaml index 2764ed6..60d283f 100644 --- a/tests/integration/targets/vyos_logging_global/tests/cli/empty_config.yaml +++ b/tests/integration/targets/vyos_logging_global/tests/cli/empty_config.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_logging_global empty_config integration tests on connection={{ - ansible_connection }} + msg: START vyos_logging_global empty_config integration tests on connection={{ ansible_connection }} - name: Merged with empty config should give appropriate error message register: result @@ -46,8 +44,7 @@ - assert: that: - - result.msg == 'value of running_config parameter must not be empty for state - parsed' + - result.msg == 'value of running_config parameter must not be empty for state parsed' - name: Rendered with empty config should give appropriate error message register: result diff --git a/tests/integration/targets/vyos_logging_global/tests/cli/gathered.yaml b/tests/integration/targets/vyos_logging_global/tests/cli/gathered.yaml index a4b26d4..68084cd 100644 --- a/tests/integration/targets/vyos_logging_global/tests/cli/gathered.yaml +++ b/tests/integration/targets/vyos_logging_global/tests/cli/gathered.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_logging_global gathered integration tests on connection={{ - ansible_connection }} + msg: START vyos_logging_global gathered integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml diff --git a/tests/integration/targets/vyos_logging_global/tests/cli/merged.yaml b/tests/integration/targets/vyos_logging_global/tests/cli/merged.yaml index 8d2283c..b4d3856 100644 --- a/tests/integration/targets/vyos_logging_global/tests/cli/merged.yaml +++ b/tests/integration/targets/vyos_logging_global/tests/cli/merged.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_logging_global merged integration tests on connection={{ ansible_connection - }} + msg: START vyos_logging_global merged integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -44,12 +42,9 @@ - name: Assert that correct set of commands were generated assert: that: - - "{{ merged['commands'] | symmetric_difference(result['commands']) |length\ - \ == 0 }}" + - "{{ merged['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - - name: - Merge the provided configuration with the existing running configuration - (IDEMPOTENT) + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_logging_global: *id001 diff --git a/tests/integration/targets/vyos_logging_global/tests/cli/overridden.yaml b/tests/integration/targets/vyos_logging_global/tests/cli/overridden.yaml index c532b5a..eacdca2 100644 --- a/tests/integration/targets/vyos_logging_global/tests/cli/overridden.yaml +++ b/tests/integration/targets/vyos_logging_global/tests/cli/overridden.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_logging_global overridden integration tests on connection={{ - ansible_connection }} + msg: START vyos_logging_global overridden integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -26,8 +25,7 @@ - name: Assert that correct commands were generated assert: that: - - "{{ overridden['commands'] | symmetric_difference(result['commands'])\ - \ |length == 0 }}" + - "{{ overridden['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Overrides all device configuration with provided configurations (IDEMPOTENT) register: result diff --git a/tests/integration/targets/vyos_logging_global/tests/cli/rendered.yaml b/tests/integration/targets/vyos_logging_global/tests/cli/rendered.yaml index 7858b9f..3746dd7 100644 --- a/tests/integration/targets/vyos_logging_global/tests/cli/rendered.yaml +++ b/tests/integration/targets/vyos_logging_global/tests/cli/rendered.yaml @@ -1,15 +1,13 @@ --- - debug: - msg: - START vyos_logging_global rendered integration tests on connection={{ ansible_connection - }} + msg: START vyos_logging_global rendered integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml - block: - name: Structure provided configuration into device specific commands register: result - vyos.vyos.vyos_logging_global: &id001 + vyos.vyos.vyos_logging_global: config: console: facilities: @@ -40,8 +38,7 @@ - name: Assert that correct set of commands were generated assert: that: - - "{{ rendered['commands'] | symmetric_difference(result['rendered'])\ - \ |length == 0 }}" + - "{{ rendered['commands'] | symmetric_difference(result['rendered']) |length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_logging_global/vars/main.yaml b/tests/integration/targets/vyos_logging_global/vars/main.yaml index ae8b853..8d22af0 100644 --- a/tests/integration/targets/vyos_logging_global/vars/main.yaml +++ b/tests/integration/targets/vyos_logging_global/vars/main.yaml @@ -77,7 +77,6 @@ deleted: commands: - delete system syslog after: {} - parsed: after: console: diff --git a/tests/integration/targets/vyos_ntp_global/tests/cli/deleted.yaml b/tests/integration/targets/vyos_ntp_global/tests/cli/deleted.yaml index 81f406c..de5cbae 100644 --- a/tests/integration/targets/vyos_ntp_global/tests/cli/deleted.yaml +++ b/tests/integration/targets/vyos_ntp_global/tests/cli/deleted.yaml @@ -24,9 +24,7 @@ that: - result.after == populate.config - - name: - Delete the existing configuration with the provided running configuration - (IDEMPOTENT) + - name: Delete the existing configuration with the provided running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_ntp_global: *id001 diff --git a/tests/integration/targets/vyos_ntp_global/tests/cli/empty_config.yaml b/tests/integration/targets/vyos_ntp_global/tests/cli/empty_config.yaml index ec29f16..40c2554 100644 --- a/tests/integration/targets/vyos_ntp_global/tests/cli/empty_config.yaml +++ b/tests/integration/targets/vyos_ntp_global/tests/cli/empty_config.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_ntp_global empty_config integration tests on connection={{ - ansible_connection }} + msg: START vyos_ntp_global empty_config integration tests on connection={{ ansible_connection }} - name: Merged with empty config should give appropriate error message register: result @@ -45,8 +44,7 @@ - assert: that: - - result.msg == 'value of running_config parameter must not be empty for state - parsed' + - result.msg == 'value of running_config parameter must not be empty for state parsed' - name: Rendered with empty config should give appropriate error message register: result diff --git a/tests/integration/targets/vyos_ntp_global/tests/cli/gathered.yaml b/tests/integration/targets/vyos_ntp_global/tests/cli/gathered.yaml index 3c9032b..4b72fe4 100644 --- a/tests/integration/targets/vyos_ntp_global/tests/cli/gathered.yaml +++ b/tests/integration/targets/vyos_ntp_global/tests/cli/gathered.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_ntp_global gathered integration tests on connection={{ - ansible_connection }} + msg: START vyos_ntp_global gathered integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_ntp_global/tests/cli/merged.yaml b/tests/integration/targets/vyos_ntp_global/tests/cli/merged.yaml index ad36012..4d2994d 100644 --- a/tests/integration/targets/vyos_ntp_global/tests/cli/merged.yaml +++ b/tests/integration/targets/vyos_ntp_global/tests/cli/merged.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_ntp_global merged integration tests on connection={{ - ansible_connection }} + msg: START vyos_ntp_global merged integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -42,9 +41,7 @@ that: - result.before == populate.config - - name: - Merge the provided configuration with the existing running configuration - (IDEMPOTENT) + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_ntp_global: *id001 diff --git a/tests/integration/targets/vyos_ntp_global/tests/cli/overridden.yaml b/tests/integration/targets/vyos_ntp_global/tests/cli/overridden.yaml index 43def13..1b8d415 100644 --- a/tests/integration/targets/vyos_ntp_global/tests/cli/overridden.yaml +++ b/tests/integration/targets/vyos_ntp_global/tests/cli/overridden.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_ntp_global overridden integration tests on connection={{ - ansible_connection }} + msg: START vyos_ntp_global overridden integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -37,9 +36,7 @@ - result.after == ansible_facts['network_resources']['ntp_global'] - result.after == overridden.after - - name: - Override the existing configuration with the provided running configuration - (IDEMPOTENT) + - name: Override the existing configuration with the provided running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_ntp_global: *id001 diff --git a/tests/integration/targets/vyos_ntp_global/tests/cli/parsed.yaml b/tests/integration/targets/vyos_ntp_global/tests/cli/parsed.yaml index 09524b0..daf20f9 100644 --- a/tests/integration/targets/vyos_ntp_global/tests/cli/parsed.yaml +++ b/tests/integration/targets/vyos_ntp_global/tests/cli/parsed.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_ntp_global parsed integration tests on connection={{ ansible_connection - }} + msg: START vyos_ntp_global parsed integration tests on connection={{ ansible_connection }} - name: Provide the running configuration for parsing (config to be parsed) register: result diff --git a/tests/integration/targets/vyos_ntp_global/tests/cli/rendered.yaml b/tests/integration/targets/vyos_ntp_global/tests/cli/rendered.yaml index 8705509..29ed3ad 100644 --- a/tests/integration/targets/vyos_ntp_global/tests/cli/rendered.yaml +++ b/tests/integration/targets/vyos_ntp_global/tests/cli/rendered.yaml @@ -1,14 +1,13 @@ --- - debug: - msg: START vyos_ntp_global rendered integration tests on connection={{ - ansible_connection }} + msg: START vyos_ntp_global rendered integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml - block: - name: Structure provided configuration into device specific commands register: result - vyos.vyos.vyos_ntp_global: &id001 + vyos.vyos.vyos_ntp_global: config: servers: - server: server5 diff --git a/tests/integration/targets/vyos_ntp_global/tests/cli/replaced.yaml b/tests/integration/targets/vyos_ntp_global/tests/cli/replaced.yaml index 8d1241b..3942a34 100644 --- a/tests/integration/targets/vyos_ntp_global/tests/cli/replaced.yaml +++ b/tests/integration/targets/vyos_ntp_global/tests/cli/replaced.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_ntp_global replaced integration tests on connection={{ - ansible_connection }} + msg: START vyos_ntp_global replaced integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -27,9 +26,7 @@ - result.after == ansible_facts['network_resources']['ntp_global'] - result.after == replaced.after - - name: - Replace the provided configuration with the existing running configuration - (IDEMPOTENT) + - name: Replace the provided configuration with the existing running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_ntp_global: *id001 diff --git a/tests/integration/targets/vyos_ntp_global/tests/cli/rtt.yaml b/tests/integration/targets/vyos_ntp_global/tests/cli/rtt.yaml index 86f75f4..6137c21 100644 --- a/tests/integration/targets/vyos_ntp_global/tests/cli/rtt.yaml +++ b/tests/integration/targets/vyos_ntp_global/tests/cli/rtt.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_ntp_global rtt integration tests on connection={{ - ansible_connection }} + msg: START vyos_ntp_global rtt integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/deleted.yaml b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/deleted.yaml index 679a39b..59fe52a 100644 --- a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/deleted.yaml +++ b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/deleted.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_ospf_interfaces deleted integration tests on connection={{ - ansible_connection }} + msg: START vyos_ospf_interfaces deleted integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -10,7 +9,7 @@ register: result vyos.vyos.vyos_ospf_interfaces: &id001 config: - - name: "bond2" + - name: bond2 state: deleted - vyos.vyos.vyos_facts: @@ -23,9 +22,7 @@ - result.commands|symmetric_difference(deleted.commands) == [] - result.after|symmetric_difference(ansible_facts['network_resources']['ospf_interfaces']) == [] - - name: - Delete the existing configuration with the provided running configuration - (IDEMPOTENT) + - name: Delete the existing configuration with the provided running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_ospf_interfaces: *id001 diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/empty_config.yaml b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/empty_config.yaml index f99b8fe..27273b4 100644 --- a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/empty_config.yaml +++ b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/empty_config.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_ospf_interfaces empty_config integration tests on connection={{ - ansible_connection }} + msg: START vyos_ospf_interfaces empty_config integration tests on connection={{ ansible_connection }} - name: Merged with empty config should give appropriate error message register: result @@ -46,8 +44,7 @@ - assert: that: - - result.msg == 'value of running_config parameter must not be empty for state - parsed' + - result.msg == 'value of running_config parameter must not be empty for state parsed' - name: Rendered with empty config should give appropriate error message register: result diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/gathered.yaml b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/gathered.yaml index 84c22cb..69c5d10 100644 --- a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/gathered.yaml +++ b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/gathered.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_ospf_interfaces gathered integration tests on connection={{ - ansible_connection }} + msg: START vyos_ospf_interfaces gathered integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/merged.yaml b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/merged.yaml index 1dcbac6..7b091dd 100644 --- a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/merged.yaml +++ b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/merged.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_ospf_interfaces merged integration tests on connection={{ - ansible_connection }} + msg: START vyos_ospf_interfaces merged integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -10,19 +9,19 @@ register: result vyos.vyos.vyos_ospf_interfaces: &id001 config: - - name: "eth0" + - name: eth0 address_family: - - afi: "ipv4" + - afi: ipv4 cost: 50 priority: 26 - - afi: "ipv6" + - afi: ipv6 mtu_ignore: true instance: 33 - - name: "bond2" + - name: bond2 address_family: - - afi: "ipv4" + - afi: ipv4 transmit_delay: 45 - - afi: "ipv6" + - afi: ipv6 passive: true state: merged @@ -36,9 +35,7 @@ - result.commands|symmetric_difference(merged.commands) == [] - result.after|symmetric_difference(ansible_facts['network_resources']['ospf_interfaces']) == [] - - name: - Merge the provided configuration with the existing running configuration - (IDEMPOTENT) + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_ospf_interfaces: *id001 diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/overridden.yaml b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/overridden.yaml index 2652c40..7e72806 100644 --- a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/overridden.yaml +++ b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/overridden.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_ospf_interfaces overridden integration tests on connection={{ - ansible_connection }} + msg: START vyos_ospf_interfaces overridden integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -11,13 +9,13 @@ register: result vyos.vyos.vyos_ospf_interfaces: &id001 config: - - name: "eth0" + - name: eth0 address_family: - - afi: "ipv4" + - afi: ipv4 transmit_delay: 50 priority: 26 - network: "point-to-point" - - afi: "ipv6" + network: point-to-point + - afi: ipv6 dead_interval: 39 state: overridden @@ -31,9 +29,7 @@ - result.commands|symmetric_difference(overridden.commands) == [] - result.after|symmetric_difference(ansible_facts['network_resources']['ospf_interfaces']) == [] - - name: - Override the existing configuration with the provided running configuration - (IDEMPOTENT) + - name: Override the existing configuration with the provided running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_ospf_interfaces: *id001 diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/parsed.yaml b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/parsed.yaml index c260ec4..0d13f76 100644 --- a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/parsed.yaml +++ b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/parsed.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_ospfv3_interfaces parsed integration tests on connection={{ ansible_connection - }} + msg: START vyos_ospfv3_interfaces parsed integration tests on connection={{ ansible_connection }} - name: Provide the running configuration for parsing (config to be parsed) register: result diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/rendered.yaml b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/rendered.yaml index 2c27672..4cb5f4f 100644 --- a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/rendered.yaml +++ b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/rendered.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_ospf_interfaces rendered integration tests on connection={{ - ansible_connection }} + msg: START vyos_ospf_interfaces rendered integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -10,19 +9,19 @@ register: result vyos.vyos.vyos_ospf_interfaces: config: - - name: "eth0" + - name: eth0 address_family: - - afi: "ipv4" + - afi: ipv4 cost: 50 priority: 26 - - afi: "ipv6" + - afi: ipv6 mtu_ignore: true instance: 33 - - name: "bond2" + - name: bond2 address_family: - - afi: "ipv4" + - afi: ipv4 transmit_delay: 45 - - afi: "ipv6" + - afi: ipv6 passive: true state: rendered diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/replaced.yaml b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/replaced.yaml index 9efcdea..2bb8a02 100644 --- a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/replaced.yaml +++ b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/replaced.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_ospf_interfaces replaced integration tests on connection={{ - ansible_connection }} + msg: START vyos_ospf_interfaces replaced integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -10,24 +9,24 @@ register: result vyos.vyos.vyos_ospf_interfaces: &id001 config: - - name: "eth0" + - name: eth0 address_family: - - afi: "ipv4" + - afi: ipv4 transmit_delay: 50 priority: 26 - network: "point-to-point" - - afi: "ipv6" + network: point-to-point + - afi: ipv6 dead_interval: 39 - - name: "bond2" + - name: bond2 address_family: - - afi: "ipv4" + - afi: ipv4 transmit_delay: 45 bandwidth: 70 authentication: md5_key: key_id: 10 key: "1111111111232345" - - afi: "ipv6" + - afi: ipv6 passive: true state: replaced @@ -41,9 +40,7 @@ - result.commands|symmetric_difference(replaced.commands) == [] - result.after|symmetric_difference(ansible_facts['network_resources']['ospf_interfaces']) == [] - - name: - Replace the existing configuration with the provided running configuration - (IDEMPOTENT) + - name: Replace the existing configuration with the provided running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_ospf_interfaces: *id001 diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/rtt.yaml b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/rtt.yaml index 5f6374d..42da6ac 100644 --- a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/rtt.yaml +++ b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/rtt.yaml @@ -1,28 +1,27 @@ --- - debug: - msg: START vyos_ospf_interfaces rtt integration tests on connection={{ - ansible_connection }} + msg: START vyos_ospf_interfaces rtt integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml - block: - name: Merge the provided configuration with the existing running configuration register: baseconfig - vyos.vyos.vyos_ospf_interfaces: &id001 + vyos.vyos.vyos_ospf_interfaces: config: - - name: "eth0" + - name: eth0 address_family: - - afi: "ipv4" + - afi: ipv4 cost: 50 priority: 26 - - afi: "ipv6" + - afi: ipv6 mtu_ignore: true instance: 33 - - name: "bond2" + - name: bond2 address_family: - - afi: "ipv4" + - afi: ipv4 transmit_delay: 45 - - afi: "ipv6" + - afi: ipv6 passive: true state: merged @@ -40,13 +39,13 @@ register: result vyos.vyos.vyos_ospf_interfaces: config: - - name: "eth0" + - name: eth0 address_family: - - afi: "ipv4" + - afi: ipv4 transmit_delay: 50 priority: 26 - network: "point-to-point" - - afi: "ipv6" + network: point-to-point + - afi: ipv6 dead_interval: 39 - name: Revert back to base config using facts round trip diff --git a/tests/integration/targets/vyos_ospf_interfaces/vars/main.yaml b/tests/integration/targets/vyos_ospf_interfaces/vars/main.yaml index f585cbc..5c618ee 100644 --- a/tests/integration/targets/vyos_ospf_interfaces/vars/main.yaml +++ b/tests/integration/targets/vyos_ospf_interfaces/vars/main.yaml @@ -9,19 +9,19 @@ merged: - set interfaces bonding bond2 ipv6 ospfv3 passive after: - address_family: - - afi: "ipv4" + - afi: ipv4 transmit_delay: 45 - - afi: "ipv6" + - afi: ipv6 passive: true - name: "bond2" + name: bond2 - address_family: - - afi: "ipv4" + - afi: ipv4 cost: 50 priority: 26 - - afi: "ipv6" + - afi: ipv6 instance: "33" mtu_ignore: true - name: "eth0" + name: eth0 replaced: commands: @@ -36,24 +36,24 @@ replaced: after: - address_family: - - afi: "ipv4" + - afi: ipv4 authentication: md5_key: key: "1111111111232345" key_id: 10 bandwidth: 70 transmit_delay: 45 - - afi: "ipv6" + - afi: ipv6 passive: true - name: "bond2" + name: bond2 - address_family: - - afi: "ipv4" - network: "point-to-point" + - afi: ipv4 + network: point-to-point priority: 26 transmit_delay: 50 - - afi: "ipv6" + - afi: ipv6 dead_interval: 39 - name: "eth0" + name: eth0 overridden: commands: @@ -68,13 +68,13 @@ overridden: after: - address_family: - - afi: "ipv4" - network: "point-to-point" + - afi: ipv4 + network: point-to-point priority: 26 transmit_delay: 50 - - afi: "ipv6" + - afi: ipv6 dead_interval: 39 - name: "eth0" + name: eth0 deleted: commands: @@ -82,13 +82,13 @@ deleted: - delete interfaces bonding bond2 ipv6 ospfv3 after: - address_family: - - afi: "ipv4" + - afi: ipv4 cost: 50 priority: 26 - - afi: "ipv6" + - afi: ipv6 instance: "33" mtu_ignore: true - name: "eth0" + name: eth0 rendered: commands: diff --git a/tests/integration/targets/vyos_ospfv2/tests/cli/_populate.yaml b/tests/integration/targets/vyos_ospfv2/tests/cli/_populate.yaml index f17c5cb..872d330 100644 --- a/tests/integration/targets/vyos_ospfv2/tests/cli/_populate.yaml +++ b/tests/integration/targets/vyos_ospfv2/tests/cli/_populate.yaml @@ -3,35 +3,35 @@ - name: Setup vars: - lines: "set protocols ospf mpls-te 'enable' \n - set protocols ospf mpls-te router-address '192.0.11.11' \n - set protocols ospf redistribute bgp metric-type '2' \n - set protocols ospf redistribute bgp metric '10'\n - set protocols ospf default-information originate metric-type '2' \n - set protocols ospf default-information originate 'always' \n - set protocols ospf default-information originate metric '10' \n - set protocols ospf default-information originate route-map 'ingress' \n - set protocols ospf auto-cost reference-bandwidth '2' \n - set protocols ospf parameters router-id '192.0.1.1' \n - set protocols ospf parameters 'opaque-lsa' \n - set protocols ospf parameters abr-type 'cisco' \n - set protocols ospf parameters 'rfc1583-compatibility' \n - set protocols ospf passive-interface 'eth1' \n - set protocols ospf passive-interface 'eth2' \n - set protocols ospf max-metric router-lsa on-shutdown '10' \n - set protocols ospf max-metric router-lsa 'administrative' \n - set protocols ospf max-metric router-lsa on-startup '10' \n - set protocols ospf log-adjacency-changes 'detail' \n - set protocols ospf neighbor 192.0.11.12 priority '2' \n - set protocols ospf neighbor 192.0.11.12 poll-interval '10' \n - set protocols ospf area 2 authentication 'plaintext-password' \n - set protocols ospf area 2 shortcut 'enable' \n - set protocols ospf area 2 area-type 'normal' \n - set protocols ospf area 3 area-type 'nssa' \n - set protocols ospf area 4 range 192.0.3.0/24 cost '10' \n - set protocols ospf area 4 range 192.0.4.0/24 cost '12' \n - set protocols ospf area 4 area-type stub default-cost '20' \n - set protocols ospf area 4 network '192.0.2.0/24'" - + lines: >- + "set protocols ospf mpls-te 'enable' + \n set protocols ospf mpls-te router-address '192.0.11.11' + \n set protocols ospf redistribute bgp metric-type '2' + \n set protocols ospf redistribute bgp metric '10' + \n set protocols ospf default-information originate metric-type '2' + \n set protocols ospf default-information originate 'always' + \n set protocols ospf default-information originate metric '10' + \n set protocols ospf default-information originate route-map 'ingress' + \n set protocols ospf auto-cost reference-bandwidth '2' + \n set protocols ospf parameters router-id '192.0.1.1' + \n set protocols ospf parameters 'opaque-lsa' + \n set protocols ospf parameters abr-type 'cisco' + \n set protocols ospf parameters 'rfc1583-compatibility' + \n set protocols ospf passive-interface 'eth1' + \n set protocols ospf passive-interface 'eth2' + \n set protocols ospf max-metric router-lsa on-shutdown '10' + \n set protocols ospf max-metric router-lsa 'administrative' + \n set protocols ospf max-metric router-lsa on-startup '10' + \n set protocols ospf log-adjacency-changes 'detail' + \n set protocols ospf neighbor 192.0.11.12 priority '2' + \n set protocols ospf neighbor 192.0.11.12 poll-interval '10' + \n set protocols ospf area 2 authentication 'plaintext-password' + \n set protocols ospf area 2 shortcut 'enable' + \n set protocols ospf area 2 area-type 'normal' + \n set protocols ospf area 3 area-type 'nssa' + \n set protocols ospf area 4 range 192.0.3.0/24 cost '10' + \n set protocols ospf area 4 range 192.0.4.0/24 cost '12' + \n set protocols ospf area 4 area-type stub default-cost '20' + \n set protocols ospf area 4 network '192.0.2.0/24'" ansible.netcommon.cli_config: config: "{{ lines }}" diff --git a/tests/integration/targets/vyos_ospfv2/tests/cli/deleted.yaml b/tests/integration/targets/vyos_ospfv2/tests/cli/deleted.yaml index 553bb9f..6a24aae 100644 --- a/tests/integration/targets/vyos_ospfv2/tests/cli/deleted.yaml +++ b/tests/integration/targets/vyos_ospfv2/tests/cli/deleted.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_ospfv2 deleted integration tests ansible_connection={{ - ansible_connection }} + msg: START vyos_ospfv2 deleted integration tests ansible_connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -20,8 +19,7 @@ - name: Assert that the correct set of commands were generated assert: that: - - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length\ - \ == 0 }}" + - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that the after dicts were correctly generated assert: diff --git a/tests/integration/targets/vyos_ospfv2/tests/cli/empty_config.yaml b/tests/integration/targets/vyos_ospfv2/tests/cli/empty_config.yaml index 4566bf4..5c5d42c 100644 --- a/tests/integration/targets/vyos_ospfv2/tests/cli/empty_config.yaml +++ b/tests/integration/targets/vyos_ospfv2/tests/cli/empty_config.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_ospfv2 empty_config integration tests on connection={{ - ansible_connection }} + msg: START vyos_ospfv2 empty_config integration tests on connection={{ ansible_connection }} - name: Merged with empty config should give appropriate error message register: result @@ -34,8 +33,7 @@ - assert: that: - - result.msg == 'value of running_config parameter must not be empty for state - parsed' + - result.msg == 'value of running_config parameter must not be empty for state parsed' - name: Rendered with empty config should give appropriate error message register: result diff --git a/tests/integration/targets/vyos_ospfv2/tests/cli/gathered.yaml b/tests/integration/targets/vyos_ospfv2/tests/cli/gathered.yaml index a8e3149..239d2e0 100644 --- a/tests/integration/targets/vyos_ospfv2/tests/cli/gathered.yaml +++ b/tests/integration/targets/vyos_ospfv2/tests/cli/gathered.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_ospfv2 gathered integration tests on connection={{ - ansible_connection }} + msg: START vyos_ospfv2 gathered integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml diff --git a/tests/integration/targets/vyos_ospfv2/tests/cli/merged.yaml b/tests/integration/targets/vyos_ospfv2/tests/cli/merged.yaml index 8aced96..67f688d 100644 --- a/tests/integration/targets/vyos_ospfv2/tests/cli/merged.yaml +++ b/tests/integration/targets/vyos_ospfv2/tests/cli/merged.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_ospfv2 merged integration tests on connection={{ ansible_connection - }} + msg: START vyos_ospfv2 merged integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -11,7 +9,7 @@ register: result vyos.vyos.vyos_ospfv2: &id001 config: - log_adjacency_changes: "detail" + log_adjacency_changes: detail max_metric: router_lsa: administrative: true @@ -22,34 +20,34 @@ always: true metric: 10 metric_type: 2 - route_map: "ingress" + route_map: ingress mpls_te: enabled: true - router_address: "192.0.11.11" + router_address: 192.0.11.11 auto_cost: reference_bandwidth: 2 neighbor: - - neighbor_id: "192.0.11.12" + - neighbor_id: 192.0.11.12 poll_interval: 10 priority: 2 redistribute: - - route_type: "bgp" + - route_type: bgp metric: 10 metric_type: 2 passive_interface: - - "eth1" - - "eth2" + - eth1 + - eth2 parameters: - router_id: "192.0.1.1" + router_id: 192.0.1.1 opaque_lsa: true rfc1583_compatibility: true - abr_type: "cisco" + abr_type: cisco areas: - area_id: "2" area_type: normal: true - authentication: "plaintext-password" - shortcut: "enable" + authentication: plaintext-password + shortcut: enable - area_id: "3" area_type: nssa: @@ -59,11 +57,11 @@ stub: default_cost: 20 network: - - address: "192.0.2.0/24" + - address: 192.0.2.0/24 range: - - address: "192.0.3.0/24" + - address: 192.0.3.0/24 cost: 10 - - address: "192.0.4.0/24" + - address: 192.0.4.0/24 cost: 12 state: merged @@ -74,17 +72,14 @@ - name: Assert that correct set of commands were generated assert: that: - - "{{ merged['commands'] | symmetric_difference(result['commands']) |length\ - \ == 0 }}" + - "{{ merged['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that after dicts was correctly generated assert: that: - "{{ merged['after'] == result['after'] }}" - - name: - Merge the provided configuration with the existing running configuration - (IDEMPOTENT) + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_ospfv2: *id001 diff --git a/tests/integration/targets/vyos_ospfv2/tests/cli/merged_update.yaml b/tests/integration/targets/vyos_ospfv2/tests/cli/merged_update.yaml index bc82146..60243c3 100644 --- a/tests/integration/targets/vyos_ospfv2/tests/cli/merged_update.yaml +++ b/tests/integration/targets/vyos_ospfv2/tests/cli/merged_update.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_ospfv2 merged integration tests on connection={{ ansible_connection - }} + msg: START vyos_ospfv2 merged integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -11,14 +9,14 @@ register: result vyos.vyos.vyos_ospfv2: &id001 config: - log_adjacency_changes: "detail" + log_adjacency_changes: detail max_metric: router_lsa: administrative: true on_shutdown: 10 on_startup: 10 passive_interface: - - "eth1" + - eth1 areas: - area_id: "3" area_type: @@ -29,9 +27,9 @@ stub: set: false network: - - address: "192.0.2.0/24" - - address: "192.0.22.0/24" - - address: "192.0.32.0/24" + - address: 192.0.2.0/24 + - address: 192.0.22.0/24 + - address: 192.0.32.0/24 state: merged - name: Assert that before dicts were correctly generated @@ -41,17 +39,14 @@ - name: Assert that correct set of commands were generated assert: that: - - "{{ merged_update['commands'] | symmetric_difference(result['commands']) |length\ - \ == 0 }}" + - "{{ merged_update['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that after dicts was correctly generated assert: that: - "{{ merged_update['after'] == result['after'] }}" - - name: - Merge the provided configuration with the existing running configuration - (IDEMPOTENT) + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_ospfv2: *id001 diff --git a/tests/integration/targets/vyos_ospfv2/tests/cli/parsed.yaml b/tests/integration/targets/vyos_ospfv2/tests/cli/parsed.yaml index ac5c203..ad5b005 100644 --- a/tests/integration/targets/vyos_ospfv2/tests/cli/parsed.yaml +++ b/tests/integration/targets/vyos_ospfv2/tests/cli/parsed.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_ospfv2 parsed integration tests on connection={{ ansible_connection - }} + msg: START vyos_ospfv2 parsed integration tests on connection={{ ansible_connection }} - name: Parse externally provided ospfv2 config to agnostic model register: result diff --git a/tests/integration/targets/vyos_ospfv2/tests/cli/rendered.yaml b/tests/integration/targets/vyos_ospfv2/tests/cli/rendered.yaml index e11aa6a..2372300 100644 --- a/tests/integration/targets/vyos_ospfv2/tests/cli/rendered.yaml +++ b/tests/integration/targets/vyos_ospfv2/tests/cli/rendered.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_ospfv2 rendered integration tests on connection={{ - ansible_connection }} + msg: START vyos_ospfv2 rendered integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -10,7 +9,7 @@ register: result vyos.vyos.vyos_ospfv2: config: - log_adjacency_changes: "detail" + log_adjacency_changes: detail max_metric: router_lsa: administrative: true @@ -21,34 +20,34 @@ always: true metric: 10 metric_type: 2 - route_map: "ingress" + route_map: ingress mpls_te: enabled: true - router_address: "192.0.11.11" + router_address: 192.0.11.11 auto_cost: reference_bandwidth: 2 neighbor: - - neighbor_id: "192.0.11.12" + - neighbor_id: 192.0.11.12 poll_interval: 10 priority: 2 redistribute: - - route_type: "bgp" + - route_type: bgp metric: 10 metric_type: 2 passive_interface: - - "eth1" - - "eth2" + - eth1 + - eth2 parameters: - router_id: "192.0.1.1" + router_id: 192.0.1.1 opaque_lsa: true rfc1583_compatibility: true - abr_type: "cisco" + abr_type: cisco areas: - area_id: "2" area_type: normal: true - authentication: "plaintext-password" - shortcut: "enable" + authentication: plaintext-password + shortcut: enable - area_id: "3" area_type: nssa: @@ -58,18 +57,17 @@ stub: default_cost: 20 network: - - address: "192.0.2.0/24" + - address: 192.0.2.0/24 range: - - address: "192.0.3.0/24" + - address: 192.0.3.0/24 cost: 10 - - address: "192.0.4.0/24" + - address: 192.0.4.0/24 cost: 12 state: rendered - name: Assert that correct set of commands were generated assert: that: - - "{{ rendered['commands'] | symmetric_difference(result['rendered'])\ - \ |length == 0 }}" + - "{{ rendered['commands'] | symmetric_difference(result['rendered']) |length == 0 }}" - debug: msg: END vyos_ospfv2 rendered integration tests on connection={{ ansible_connection }} diff --git a/tests/integration/targets/vyos_ospfv2/tests/cli/replaced.yaml b/tests/integration/targets/vyos_ospfv2/tests/cli/replaced.yaml index b348484..93d7efe 100644 --- a/tests/integration/targets/vyos_ospfv2/tests/cli/replaced.yaml +++ b/tests/integration/targets/vyos_ospfv2/tests/cli/replaced.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_ospfv2 replaced integration tests on connection={{ - ansible_connection }} + msg: START vyos_ospfv2 replaced integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -10,7 +9,7 @@ register: result vyos.vyos.vyos_ospfv2: &id001 config: - log_adjacency_changes: "detail" + log_adjacency_changes: detail max_metric: router_lsa: administrative: true @@ -21,52 +20,51 @@ always: true metric: 10 metric_type: 2 - route_map: "ingress" + route_map: ingress mpls_te: enabled: true - router_address: "192.0.22.22" + router_address: 192.0.22.22 auto_cost: reference_bandwidth: 2 neighbor: - - neighbor_id: "192.0.11.12" + - neighbor_id: 192.0.11.12 poll_interval: 10 priority: 2 redistribute: - - route_type: "bgp" + - route_type: bgp metric: 10 metric_type: 2 passive_interface: - - "eth1" + - eth1 parameters: - router_id: "192.0.1.1" + router_id: 192.0.1.1 opaque_lsa: true rfc1583_compatibility: true - abr_type: "cisco" + abr_type: cisco areas: - area_id: "2" area_type: normal: true - authentication: "plaintext-password" - shortcut: "enable" + authentication: plaintext-password + shortcut: enable - area_id: "4" area_type: stub: default_cost: 20 network: - - address: "192.0.2.0/24" - - address: "192.0.12.0/24" - - address: "192.0.22.0/24" - - address: "192.0.32.0/24" + - address: 192.0.2.0/24 + - address: 192.0.12.0/24 + - address: 192.0.22.0/24 + - address: 192.0.32.0/24 range: - - address: "1.1.2.0/24" + - address: 1.1.2.0/24 cost: 10 state: replaced - name: Assert that correct set of commands were generated assert: that: - - "{{ replaced['commands'] | symmetric_difference(result['commands'])\ - \ |length == 0 }}" + - "{{ replaced['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that before dicts are correctly generated assert: @@ -78,9 +76,7 @@ that: - "{{ replaced['after'] == result['after'] }}" - - name: - Replace device configurations of listed ospfv2 routes with provided configurarions - (IDEMPOTENT) + - name: Replace device configurations of listed ospfv2 routes with provided configurarions (IDEMPOTENT) register: result vyos.vyos.vyos_ospfv2: *id001 diff --git a/tests/integration/targets/vyos_ospfv2/tests/cli/rtt.yaml b/tests/integration/targets/vyos_ospfv2/tests/cli/rtt.yaml index 9407ffa..60f96f5 100644 --- a/tests/integration/targets/vyos_ospfv2/tests/cli/rtt.yaml +++ b/tests/integration/targets/vyos_ospfv2/tests/cli/rtt.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_ospfv2 round trip integration tests on connection={{ - ansible_connection }} + msg: START vyos_ospfv2 round trip integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -10,7 +9,7 @@ register: base_config vyos.vyos.vyos_ospfv2: config: - log_adjacency_changes: "detail" + log_adjacency_changes: detail max_metric: router_lsa: administrative: true @@ -21,34 +20,34 @@ always: true metric: 10 metric_type: 2 - route_map: "ingress" + route_map: ingress mpls_te: enabled: true - router_address: "192.0.11.11" + router_address: 192.0.11.11 auto_cost: reference_bandwidth: 2 neighbor: - - neighbor_id: "192.0.11.12" + - neighbor_id: 192.0.11.12 poll_interval: 10 priority: 2 redistribute: - - route_type: "bgp" + - route_type: bgp metric: 10 metric_type: 2 passive_interface: - - "eth1" - - "eth2" + - eth1 + - eth2 parameters: - router_id: "192.0.1.1" + router_id: 192.0.1.1 opaque_lsa: true rfc1583_compatibility: true - abr_type: "cisco" + abr_type: cisco areas: - area_id: "2" area_type: normal: true - authentication: "plaintext-password" - shortcut: "enable" + authentication: plaintext-password + shortcut: enable - area_id: "3" area_type: nssa: @@ -58,11 +57,11 @@ stub: default_cost: 20 network: - - address: "192.0.2.0/24" + - address: 192.0.2.0/24 range: - - address: "192.0.3.0/24" + - address: 192.0.3.0/24 cost: 10 - - address: "192.0.4.0/24" + - address: 192.0.4.0/24 cost: 12 state: merged @@ -81,20 +80,20 @@ - area_id: "2" area_type: normal: true - authentication: "plaintext-password" - shortcut: "enable" + authentication: plaintext-password + shortcut: enable - area_id: "4" area_type: stub: default_cost: 20 set: true network: - - address: "192.0.12.0/24" - - address: "192.0.2.0/24" - - address: "192.0.22.0/24" - - address: "192.0.32.0/24" + - address: 192.0.12.0/24 + - address: 192.0.2.0/24 + - address: 192.0.22.0/24 + - address: 192.0.32.0/24 range: - - address: "1.1.2.0/24" + - address: 1.1.2.0/24 cost: 10 auto_cost: reference_bandwidth: 2 @@ -103,8 +102,8 @@ always: true metric: 10 metric_type: 2 - route_map: "ingress" - log_adjacency_changes: "detail" + route_map: ingress + log_adjacency_changes: detail max_metric: router_lsa: administrative: true @@ -112,22 +111,22 @@ on_startup: 10 mpls_te: enabled: true - router_address: "192.0.22.22" + router_address: 192.0.22.22 neighbor: - - neighbor_id: "192.0.11.12" + - neighbor_id: 192.0.11.12 poll_interval: 10 priority: 2 parameters: - abr_type: "cisco" + abr_type: cisco opaque_lsa: true rfc1583_compatibility: true - router_id: "192.0.1.1" + router_id: 192.0.1.1 passive_interface: - - "eth1" + - eth1 redistribute: - metric: 10 metric_type: 2 - route_type: "bgp" + route_type: bgp state: replaced - name: Assert that changes were applied diff --git a/tests/integration/targets/vyos_ospfv2/tests/redirection/cli/shortname.yaml b/tests/integration/targets/vyos_ospfv2/tests/redirection/cli/shortname.yaml index 15295d1..89f734e 100644 --- a/tests/integration/targets/vyos_ospfv2/tests/redirection/cli/shortname.yaml +++ b/tests/integration/targets/vyos_ospfv2/tests/redirection/cli/shortname.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START shortname integration tests on connection={{ ansible_connection - }} + msg: START shortname integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -10,7 +9,7 @@ register: result vyos.vyos.ospfv2: &id001 config: - log_adjacency_changes: "detail" + log_adjacency_changes: detail max_metric: router_lsa: administrative: true @@ -21,34 +20,34 @@ always: true metric: 10 metric_type: 2 - route_map: "ingress" + route_map: ingress mpls_te: enabled: true - router_address: "192.0.11.11" + router_address: 192.0.11.11 auto_cost: reference_bandwidth: 2 neighbor: - - neighbor_id: "192.0.11.12" + - neighbor_id: 192.0.11.12 poll_interval: 10 priority: 2 redistribute: - - route_type: "bgp" + - route_type: bgp metric: 10 metric_type: 2 passive_interface: - - "eth1" - - "eth2" + - eth1 + - eth2 parameters: - router_id: "192.0.1.1" + router_id: 192.0.1.1 opaque_lsa: true rfc1583_compatibility: true - abr_type: "cisco" + abr_type: cisco areas: - area_id: "2" area_type: normal: true - authentication: "plaintext-password" - shortcut: "enable" + authentication: plaintext-password + shortcut: enable - area_id: "3" area_type: nssa: @@ -58,11 +57,11 @@ stub: default_cost: 20 network: - - address: "192.0.2.0/24" + - address: 192.0.2.0/24 range: - - address: "192.0.3.0/24" + - address: 192.0.3.0/24 cost: 10 - - address: "192.0.4.0/24" + - address: 192.0.4.0/24 cost: 12 state: merged @@ -73,17 +72,14 @@ - name: Assert that correct set of commands were generated assert: that: - - "{{ merged['commands'] | symmetric_difference(result['commands']) |length\ - \ == 0 }}" + - "{{ merged['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that after dicts was correctly generated assert: that: - "{{ merged['after'] == result['after'] }}" - - name: - Merge the provided configuration with the existing running configuration - (IDEMPOTENT) + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) register: result vyos.vyos.ospfv2: *id001 diff --git a/tests/integration/targets/vyos_ospfv2/vars/main.yaml b/tests/integration/targets/vyos_ospfv2/vars/main.yaml index da81c19..70d25fc 100644 --- a/tests/integration/targets/vyos_ospfv2/vars/main.yaml +++ b/tests/integration/targets/vyos_ospfv2/vars/main.yaml @@ -43,8 +43,8 @@ merged: - area_id: "2" area_type: normal: true - authentication: "plaintext-password" - shortcut: "enable" + authentication: plaintext-password + shortcut: enable - area_id: "3" area_type: nssa: @@ -55,11 +55,11 @@ merged: default_cost: 20 set: true network: - - address: "192.0.2.0/24" + - address: 192.0.2.0/24 range: - - address: "192.0.3.0/24" + - address: 192.0.3.0/24 cost: 10 - - address: "192.0.4.0/24" + - address: 192.0.4.0/24 cost: 12 auto_cost: reference_bandwidth: 2 @@ -68,8 +68,8 @@ merged: always: true metric: 10 metric_type: 2 - route_map: "ingress" - log_adjacency_changes: "detail" + route_map: ingress + log_adjacency_changes: detail max_metric: router_lsa: administrative: true @@ -77,31 +77,31 @@ merged: on_startup: 10 mpls_te: enabled: true - router_address: "192.0.11.11" + router_address: 192.0.11.11 neighbor: - - neighbor_id: "192.0.11.12" + - neighbor_id: 192.0.11.12 poll_interval: 10 priority: 2 parameters: - abr_type: "cisco" + abr_type: cisco opaque_lsa: true rfc1583_compatibility: true - router_id: "192.0.1.1" + router_id: 192.0.1.1 passive_interface: - - "eth1" - - "eth2" + - eth1 + - eth2 redistribute: - metric: 10 metric_type: 2 - route_type: "bgp" + route_type: bgp merged_update: before: areas: - area_id: "2" area_type: normal: true - authentication: "plaintext-password" - shortcut: "enable" + authentication: plaintext-password + shortcut: enable - area_id: "3" area_type: nssa: @@ -112,11 +112,11 @@ merged_update: default_cost: 20 set: true network: - - address: "192.0.2.0/24" + - address: 192.0.2.0/24 range: - - address: "192.0.3.0/24" + - address: 192.0.3.0/24 cost: 10 - - address: "192.0.4.0/24" + - address: 192.0.4.0/24 cost: 12 auto_cost: reference_bandwidth: 2 @@ -125,8 +125,8 @@ merged_update: always: true metric: 10 metric_type: 2 - route_map: "ingress" - log_adjacency_changes: "detail" + route_map: ingress + log_adjacency_changes: detail max_metric: router_lsa: administrative: true @@ -134,43 +134,43 @@ merged_update: on_startup: 10 mpls_te: enabled: true - router_address: "192.0.11.11" + router_address: 192.0.11.11 neighbor: - - neighbor_id: "192.0.11.12" + - neighbor_id: 192.0.11.12 poll_interval: 10 priority: 2 parameters: - abr_type: "cisco" + abr_type: cisco opaque_lsa: true rfc1583_compatibility: true - router_id: "192.0.1.1" + router_id: 192.0.1.1 passive_interface: - - "eth1" - - "eth2" + - eth1 + - eth2 redistribute: - metric: 10 metric_type: 2 - route_type: "bgp" + route_type: bgp after: areas: - area_id: "2" area_type: normal: true - authentication: "plaintext-password" - shortcut: "enable" + authentication: plaintext-password + shortcut: enable - area_id: "3" area_type: nssa: set: true - area_id: "4" network: - - address: "192.0.2.0/24" - - address: "192.0.22.0/24" - - address: "192.0.32.0/24" + - address: 192.0.2.0/24 + - address: 192.0.22.0/24 + - address: 192.0.32.0/24 range: - - address: "192.0.3.0/24" + - address: 192.0.3.0/24 cost: 10 - - address: "192.0.4.0/24" + - address: 192.0.4.0/24 cost: 12 auto_cost: reference_bandwidth: 2 @@ -179,8 +179,8 @@ merged_update: always: true metric: 10 metric_type: 2 - route_map: "ingress" - log_adjacency_changes: "detail" + route_map: ingress + log_adjacency_changes: detail max_metric: router_lsa: administrative: true @@ -188,23 +188,23 @@ merged_update: on_startup: 10 mpls_te: enabled: true - router_address: "192.0.11.11" + router_address: 192.0.11.11 neighbor: - - neighbor_id: "192.0.11.12" + - neighbor_id: 192.0.11.12 poll_interval: 10 priority: 2 parameters: - abr_type: "cisco" + abr_type: cisco opaque_lsa: true rfc1583_compatibility: true - router_id: "192.0.1.1" + router_id: 192.0.1.1 passive_interface: - - "eth1" - - "eth2" + - eth1 + - eth2 redistribute: - metric: 10 metric_type: 2 - route_type: "bgp" + route_type: bgp commands: - delete protocols ospf area 4 area-type stub - set protocols ospf area 4 network 192.0.22.0/24 @@ -214,8 +214,8 @@ populate: - area_id: "2" area_type: normal: true - authentication: "plaintext-password" - shortcut: "enable" + authentication: plaintext-password + shortcut: enable - area_id: "3" area_type: nssa: @@ -226,11 +226,11 @@ populate: default_cost: 20 set: true network: - - address: "192.0.2.0/24" + - address: 192.0.2.0/24 range: - - address: "192.0.3.0/24" + - address: 192.0.3.0/24 cost: 10 - - address: "192.0.4.0/24" + - address: 192.0.4.0/24 cost: 12 auto_cost: reference_bandwidth: 2 @@ -239,8 +239,8 @@ populate: always: true metric: 10 metric_type: 2 - route_map: "ingress" - log_adjacency_changes: "detail" + route_map: ingress + log_adjacency_changes: detail max_metric: router_lsa: administrative: true @@ -248,23 +248,23 @@ populate: on_startup: 10 mpls_te: enabled: true - router_address: "192.0.11.11" + router_address: 192.0.11.11 neighbor: - - neighbor_id: "192.0.11.12" + - neighbor_id: 192.0.11.12 poll_interval: 10 priority: 2 parameters: - abr_type: "cisco" + abr_type: cisco opaque_lsa: true rfc1583_compatibility: true - router_id: "192.0.1.1" + router_id: 192.0.1.1 passive_interface: - - "eth1" - - "eth2" + - eth1 + - eth2 redistribute: - metric: 10 metric_type: 2 - route_type: "bgp" + route_type: bgp replaced: commands: - delete protocols ospf passive-interface eth2 @@ -284,20 +284,20 @@ replaced: - area_id: "2" area_type: normal: true - authentication: "plaintext-password" - shortcut: "enable" + authentication: plaintext-password + shortcut: enable - area_id: "4" area_type: stub: default_cost: 20 set: true network: - - address: "192.0.12.0/24" - - address: "192.0.2.0/24" - - address: "192.0.22.0/24" - - address: "192.0.32.0/24" + - address: 192.0.12.0/24 + - address: 192.0.2.0/24 + - address: 192.0.22.0/24 + - address: 192.0.32.0/24 range: - - address: "1.1.2.0/24" + - address: 1.1.2.0/24 cost: 10 auto_cost: reference_bandwidth: 2 @@ -306,8 +306,8 @@ replaced: always: true metric: 10 metric_type: 2 - route_map: "ingress" - log_adjacency_changes: "detail" + route_map: ingress + log_adjacency_changes: detail max_metric: router_lsa: administrative: true @@ -315,22 +315,22 @@ replaced: on_startup: 10 mpls_te: enabled: true - router_address: "192.0.22.22" + router_address: 192.0.22.22 neighbor: - - neighbor_id: "192.0.11.12" + - neighbor_id: 192.0.11.12 poll_interval: 10 priority: 2 parameters: - abr_type: "cisco" + abr_type: cisco opaque_lsa: true rfc1583_compatibility: true - router_id: "192.0.1.1" + router_id: 192.0.1.1 passive_interface: - - "eth1" + - eth1 redistribute: - metric: 10 metric_type: 2 - route_type: "bgp" + route_type: bgp rendered: commands: - set protocols ospf mpls-te enable @@ -375,8 +375,8 @@ parsed: - area_id: "2" area_type: normal: true - authentication: "plaintext-password" - shortcut: "enable" + authentication: plaintext-password + shortcut: enable - area_id: "3" area_type: nssa: @@ -387,11 +387,11 @@ parsed: default_cost: 20 set: true network: - - address: "192.0.2.0/24" + - address: 192.0.2.0/24 range: - - address: "192.0.3.0/24" + - address: 192.0.3.0/24 cost: 10 - - address: "192.0.4.0/24" + - address: 192.0.4.0/24 cost: 12 auto_cost: reference_bandwidth: 2 @@ -400,8 +400,8 @@ parsed: always: true metric: 10 metric_type: 2 - route_map: "ingress" - log_adjacency_changes: "detail" + route_map: ingress + log_adjacency_changes: detail max_metric: router_lsa: administrative: true @@ -409,26 +409,26 @@ parsed: on_startup: 10 mpls_te: enabled: true - router_address: "192.0.11.11" + router_address: 192.0.11.11 neighbor: - - neighbor_id: "192.0.11.12" + - neighbor_id: 192.0.11.12 poll_interval: 10 priority: 2 parameters: - abr_type: "cisco" + abr_type: cisco opaque_lsa: true rfc1583_compatibility: true - router_id: "192.0.1.1" + router_id: 192.0.1.1 passive_interface: - - "eth1" - - "eth2" + - eth1 + - eth2 redistribute: - metric: 10 metric_type: 2 - route_type: "bgp" + route_type: bgp deleted: commands: - - "delete protocols ospf" + - delete protocols ospf after: {} round_trip: after: @@ -436,20 +436,20 @@ round_trip: - area_id: "2" area_type: normal: true - authentication: "plaintext-password" - shortcut: "enable" + authentication: plaintext-password + shortcut: enable - area_id: "4" area_type: stub: default_cost: 20 set: true network: - - address: "192.0.12.0/24" - - address: "192.0.2.0/24" - - address: "192.0.22.0/24" - - address: "192.0.32.0/24" + - address: 192.0.12.0/24 + - address: 192.0.2.0/24 + - address: 192.0.22.0/24 + - address: 192.0.32.0/24 range: - - address: "1.1.2.0/24" + - address: 1.1.2.0/24 cost: 10 auto_cost: reference_bandwidth: 2 @@ -458,8 +458,8 @@ round_trip: always: true metric: 10 metric_type: 2 - route_map: "ingress" - log_adjacency_changes: "detail" + route_map: ingress + log_adjacency_changes: detail max_metric: router_lsa: administrative: true @@ -467,19 +467,19 @@ round_trip: on_startup: 10 mpls_te: enabled: true - router_address: "192.0.22.22" + router_address: 192.0.22.22 neighbor: - - neighbor_id: "192.0.11.12" + - neighbor_id: 192.0.11.12 poll_interval: 10 priority: 2 parameters: - abr_type: "cisco" + abr_type: cisco opaque_lsa: true rfc1583_compatibility: true - router_id: "192.0.1.1" + router_id: 192.0.1.1 passive_interface: - - "eth1" + - eth1 redistribute: - metric: 10 metric_type: 2 - route_type: "bgp" + route_type: bgp diff --git a/tests/integration/targets/vyos_ospfv3/tests/cli/_populate.yaml b/tests/integration/targets/vyos_ospfv3/tests/cli/_populate.yaml index 164fcc0..c484a7f 100644 --- a/tests/integration/targets/vyos_ospfv3/tests/cli/_populate.yaml +++ b/tests/integration/targets/vyos_ospfv3/tests/cli/_populate.yaml @@ -3,13 +3,14 @@ - name: Setup vars: - lines: "set protocols ospfv3 area 2 export-list 'export1' \n - set protocols ospfv3 area 2 import-list 'import1' \n - set protocols ospfv3 area 2 range '2001:db10::/32' \n - set protocols ospfv3 area 2 range '2001:db20::/32' \n - set protocols ospfv3 area 2 range '2001:db30::/32' \n - set protocols ospfv3 area 3 range '2001:db40::/32' \n - set protocols ospfv3 parameters router-id '192.0.2.10' \n - set protocols ospfv3 redistribute 'bgp'" + lines: >- + "set protocols ospfv3 area 2 export-list 'export1' + \n set protocols ospfv3 area 2 import-list 'import1' + \n set protocols ospfv3 area 2 range '2001:db10::/32' + \n set protocols ospfv3 area 2 range '2001:db20::/32' + \n set protocols ospfv3 area 2 range '2001:db30::/32' + \n set protocols ospfv3 area 3 range '2001:db40::/32' + \n set protocols ospfv3 parameters router-id '192.0.2.10' + \n set protocols ospfv3 redistribute 'bgp'" ansible.netcommon.cli_config: config: "{{ lines }}" diff --git a/tests/integration/targets/vyos_ospfv3/tests/cli/deleted.yaml b/tests/integration/targets/vyos_ospfv3/tests/cli/deleted.yaml index 2e55472..3f8ad58 100644 --- a/tests/integration/targets/vyos_ospfv3/tests/cli/deleted.yaml +++ b/tests/integration/targets/vyos_ospfv3/tests/cli/deleted.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_ospfv3 deleted integration tests ansible_connection={{ - ansible_connection }} + msg: START vyos_ospfv3 deleted integration tests ansible_connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -20,8 +19,7 @@ - name: Assert that the correct set of commands were generated assert: that: - - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length\ - \ == 0 }}" + - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that the after dicts were correctly generated assert: diff --git a/tests/integration/targets/vyos_ospfv3/tests/cli/empty_config.yaml b/tests/integration/targets/vyos_ospfv3/tests/cli/empty_config.yaml index fec61ab..4097f79 100644 --- a/tests/integration/targets/vyos_ospfv3/tests/cli/empty_config.yaml +++ b/tests/integration/targets/vyos_ospfv3/tests/cli/empty_config.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_ospfv3 empty_config integration tests on connection={{ - ansible_connection }} + msg: START vyos_ospfv3 empty_config integration tests on connection={{ ansible_connection }} - name: Merged with empty config should give appropriate error message register: result @@ -34,8 +33,7 @@ - assert: that: - - result.msg == 'value of running_config parameter must not be empty for state - parsed' + - result.msg == 'value of running_config parameter must not be empty for state parsed' - name: Rendered with empty config should give appropriate error message register: result diff --git a/tests/integration/targets/vyos_ospfv3/tests/cli/gathered.yaml b/tests/integration/targets/vyos_ospfv3/tests/cli/gathered.yaml index 3654bbe..ed70f9c 100644 --- a/tests/integration/targets/vyos_ospfv3/tests/cli/gathered.yaml +++ b/tests/integration/targets/vyos_ospfv3/tests/cli/gathered.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_ospfv3 gathered integration tests on connection={{ - ansible_connection }} + msg: START vyos_ospfv3 gathered integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml diff --git a/tests/integration/targets/vyos_ospfv3/tests/cli/merged.yaml b/tests/integration/targets/vyos_ospfv3/tests/cli/merged.yaml index 7bbc3c6..28d596f 100644 --- a/tests/integration/targets/vyos_ospfv3/tests/cli/merged.yaml +++ b/tests/integration/targets/vyos_ospfv3/tests/cli/merged.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_ospfv3 merged integration tests on connection={{ ansible_connection - }} + msg: START vyos_ospfv3 merged integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -13,19 +11,19 @@ config: areas: - area_id: "2" - export_list: "export1" - import_list: "import1" + export_list: export1 + import_list: import1 range: - - address: "2001:db10::/32" - - address: "2001:db20::/32" - - address: "2001:db30::/32" + - address: 2001:db10::/32 + - address: 2001:db20::/32 + - address: 2001:db30::/32 - area_id: "3" range: - - address: "2001:db40::/32" + - address: 2001:db40::/32 parameters: - router_id: "192.0.2.10" + router_id: 192.0.2.10 redistribute: - - route_type: "bgp" + - route_type: bgp state: merged - name: Assert that before dicts were correctly generated @@ -35,17 +33,14 @@ - name: Assert that correct set of commands were generated assert: that: - - "{{ merged['commands'] | symmetric_difference(result['commands']) |length\ - \ == 0 }}" + - "{{ merged['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that after dicts was correctly generated assert: that: - "{{ merged['after'] == result['after'] }}" - - name: - Merge the provided configuration with the existing running configuration - (IDEMPOTENT) + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_ospfv3: *id001 diff --git a/tests/integration/targets/vyos_ospfv3/tests/cli/merged_update.yaml b/tests/integration/targets/vyos_ospfv3/tests/cli/merged_update.yaml index 02657c8..c2d9ee0 100644 --- a/tests/integration/targets/vyos_ospfv3/tests/cli/merged_update.yaml +++ b/tests/integration/targets/vyos_ospfv3/tests/cli/merged_update.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_ospfv3 merged integration tests on connection={{ ansible_connection - }} + msg: START vyos_ospfv3 merged integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -14,15 +12,15 @@ areas: - area_id: "2" range: - - address: "2001:db10::/32" + - address: 2001:db10::/32 - area_id: "3" range: - - address: "2001:db40::/32" - - address: "2001:db70::/32" + - address: 2001:db40::/32 + - address: 2001:db70::/32 parameters: - router_id: "192.0.2.10" + router_id: 192.0.2.10 redistribute: - - route_type: "bgp" + - route_type: bgp state: merged - name: Assert that before dicts were correctly generated @@ -32,17 +30,14 @@ - name: Assert that correct set of commands were generated assert: that: - - "{{ merged_update['commands'] | symmetric_difference(result['commands']) |length\ - \ == 0 }}" + - "{{ merged_update['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that after dicts was correctly generated assert: that: - "{{ merged_update['after'] == result['after'] }}" - - name: - Merge the provided configuration with the existing running configuration - (IDEMPOTENT) + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_ospfv3: *id001 diff --git a/tests/integration/targets/vyos_ospfv3/tests/cli/parsed.yaml b/tests/integration/targets/vyos_ospfv3/tests/cli/parsed.yaml index 1bec41a..5981efb 100644 --- a/tests/integration/targets/vyos_ospfv3/tests/cli/parsed.yaml +++ b/tests/integration/targets/vyos_ospfv3/tests/cli/parsed.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_ospfv3 parsed integration tests on connection={{ ansible_connection - }} + msg: START vyos_ospfv3 parsed integration tests on connection={{ ansible_connection }} - name: Parse externally provided ospfv3 config to agnostic model register: result diff --git a/tests/integration/targets/vyos_ospfv3/tests/cli/rendered.yaml b/tests/integration/targets/vyos_ospfv3/tests/cli/rendered.yaml index b921bda..243f8ed 100644 --- a/tests/integration/targets/vyos_ospfv3/tests/cli/rendered.yaml +++ b/tests/integration/targets/vyos_ospfv3/tests/cli/rendered.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_ospfv3 rendered integration tests on connection={{ - ansible_connection }} + msg: START vyos_ospfv3 rendered integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -11,27 +10,26 @@ vyos.vyos.vyos_ospfv3: config: redistribute: - - route_type: "bgp" + - route_type: bgp parameters: - router_id: "192.0.2.10" + router_id: 192.0.2.10 areas: - area_id: "2" - export_list: "export1" - import_list: "import1" + export_list: export1 + import_list: import1 range: - - address: "2001:db10::/32" - - address: "2001:db20::/32" - - address: "2001:db30::/32" + - address: 2001:db10::/32 + - address: 2001:db20::/32 + - address: 2001:db30::/32 - area_id: "3" range: - - address: "2001:db40::/32" + - address: 2001:db40::/32 state: rendered - name: Assert that correct set of commands were generated assert: that: - - "{{ rendered['commands'] | symmetric_difference(result['rendered'])\ - \ |length == 0 }}" + - "{{ rendered['commands'] | symmetric_difference(result['rendered']) |length == 0 }}" - debug: msg: END vyos_ospfv3 rendered integration tests on connection={{ ansible_connection }} diff --git a/tests/integration/targets/vyos_ospfv3/tests/cli/replaced.yaml b/tests/integration/targets/vyos_ospfv3/tests/cli/replaced.yaml index e5905f5..3643826 100644 --- a/tests/integration/targets/vyos_ospfv3/tests/cli/replaced.yaml +++ b/tests/integration/targets/vyos_ospfv3/tests/cli/replaced.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_ospfv3 replaced integration tests on connection={{ - ansible_connection }} + msg: START vyos_ospfv3 replaced integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -11,28 +10,27 @@ vyos.vyos.vyos_ospfv3: &id001 config: redistribute: - - route_type: "bgp" + - route_type: bgp parameters: - router_id: "192.0.2.10" + router_id: 192.0.2.10 areas: - area_id: "2" - export_list: "export1" - import_list: "import1" + export_list: export1 + import_list: import1 range: - - address: "2001:db10::/32" - - address: "2001:db30::/32" - - address: "2001:db50::/32" + - address: 2001:db10::/32 + - address: 2001:db30::/32 + - address: 2001:db50::/32 - area_id: "4" range: - - address: "2001:db60::/32" + - address: 2001:db60::/32 state: replaced - name: Assert that correct set of commands were generated assert: that: - - "{{ replaced['commands'] | symmetric_difference(result['commands'])\ - \ |length == 0 }}" + - "{{ replaced['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that before dicts are correctly generated assert: @@ -44,9 +42,7 @@ that: - "{{ replaced['after'] == result['after'] }}" - - name: - Replace device configurations of listed ospfv3 routes with provided configurarions - (IDEMPOTENT) + - name: Replace device configurations of listed ospfv3 routes with provided configurarions (IDEMPOTENT) register: result vyos.vyos.vyos_ospfv3: *id001 diff --git a/tests/integration/targets/vyos_ospfv3/tests/cli/rtt.yaml b/tests/integration/targets/vyos_ospfv3/tests/cli/rtt.yaml index 2142aad..793f890 100644 --- a/tests/integration/targets/vyos_ospfv3/tests/cli/rtt.yaml +++ b/tests/integration/targets/vyos_ospfv3/tests/cli/rtt.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_ospfv3 round trip integration tests on connection={{ - ansible_connection }} + msg: START vyos_ospfv3 round trip integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -12,19 +11,19 @@ config: areas: - area_id: "2" - export_list: "export1" - import_list: "import1" + export_list: export1 + import_list: import1 range: - - address: "2001:db10::/32" - - address: "2001:db20::/32" - - address: "2001:db30::/32" + - address: 2001:db10::/32 + - address: 2001:db20::/32 + - address: 2001:db30::/32 - area_id: "3" range: - - address: "2001:db40::/32" + - address: 2001:db40::/32 parameters: - router_id: "192.0.2.10" + router_id: 192.0.2.10 redistribute: - - route_type: "bgp" + - route_type: bgp state: merged - name: Gather ospfv3 facts @@ -39,21 +38,21 @@ vyos.vyos.vyos_ospfv3: config: redistribute: - - route_type: "bgp" + - route_type: bgp parameters: - router_id: "192.0.2.10" + router_id: 192.0.2.10 areas: - area_id: "2" - export_list: "export1" - import_list: "import1" + export_list: export1 + import_list: import1 range: - - address: "2001:db10::/32" - - address: "2001:db30::/32" - - address: "2001:db50::/32" + - address: 2001:db10::/32 + - address: 2001:db30::/32 + - address: 2001:db50::/32 - area_id: "4" range: - - address: "2001:db60::/32" + - address: 2001:db60::/32 state: replaced - name: Assert that changes were applied diff --git a/tests/integration/targets/vyos_ospfv3/tests/redirection/cli/shortname.yaml b/tests/integration/targets/vyos_ospfv3/tests/redirection/cli/shortname.yaml index 65935e6..51239b1 100644 --- a/tests/integration/targets/vyos_ospfv3/tests/redirection/cli/shortname.yaml +++ b/tests/integration/targets/vyos_ospfv3/tests/redirection/cli/shortname.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START shortname integration tests on connection={{ ansible_connection - }} + msg: START shortname integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -12,19 +11,19 @@ config: areas: - area_id: "2" - export_list: "export1" - import_list: "import1" + export_list: export1 + import_list: import1 range: - - address: "2001:db10::/32" - - address: "2001:db20::/32" - - address: "2001:db30::/32" + - address: 2001:db10::/32 + - address: 2001:db20::/32 + - address: 2001:db30::/32 - area_id: "3" range: - - address: "2001:db40::/32" + - address: 2001:db40::/32 parameters: - router_id: "192.0.2.10" + router_id: 192.0.2.10 redistribute: - - route_type: "bgp" + - route_type: bgp state: merged - name: Assert that before dicts were correctly generated @@ -34,17 +33,14 @@ - name: Assert that correct set of commands were generated assert: that: - - "{{ merged['commands'] | symmetric_difference(result['commands']) |length\ - \ == 0 }}" + - "{{ merged['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that after dicts was correctly generated assert: that: - "{{ merged['after'] == result['after'] }}" - - name: - Merge the provided configuration with the existing running configuration - (IDEMPOTENT) + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) register: result vyos.vyos.ospfv3: *id001 diff --git a/tests/integration/targets/vyos_ospfv3/vars/main.yaml b/tests/integration/targets/vyos_ospfv3/vars/main.yaml index 3793760..21fce2d 100644 --- a/tests/integration/targets/vyos_ospfv3/vars/main.yaml +++ b/tests/integration/targets/vyos_ospfv3/vars/main.yaml @@ -15,19 +15,19 @@ merged: after: areas: - area_id: "2" - export_list: "export1" - import_list: "import1" + export_list: export1 + import_list: import1 range: - - address: "2001:db10::/32" - - address: "2001:db20::/32" - - address: "2001:db30::/32" + - address: 2001:db10::/32 + - address: 2001:db20::/32 + - address: 2001:db30::/32 - area_id: "3" range: - - address: "2001:db40::/32" + - address: 2001:db40::/32 parameters: - router_id: "192.0.2.10" + router_id: 192.0.2.10 redistribute: - - route_type: "bgp" + - route_type: bgp merged_update: commands: @@ -35,37 +35,37 @@ merged_update: after: areas: - area_id: "2" - export_list: "export1" - import_list: "import1" + export_list: export1 + import_list: import1 range: - - address: "2001:db10::/32" - - address: "2001:db20::/32" - - address: "2001:db30::/32" + - address: 2001:db10::/32 + - address: 2001:db20::/32 + - address: 2001:db30::/32 - area_id: "3" range: - - address: "2001:db40::/32" - - address: "2001:db70::/32" + - address: 2001:db40::/32 + - address: 2001:db70::/32 parameters: - router_id: "192.0.2.10" + router_id: 192.0.2.10 redistribute: - - route_type: "bgp" + - route_type: bgp populate: areas: - area_id: "2" - export_list: "export1" - import_list: "import1" + export_list: export1 + import_list: import1 range: - - address: "2001:db10::/32" - - address: "2001:db20::/32" - - address: "2001:db30::/32" + - address: 2001:db10::/32 + - address: 2001:db20::/32 + - address: 2001:db30::/32 - area_id: "3" range: - - address: "2001:db40::/32" + - address: 2001:db40::/32 parameters: - router_id: "192.0.2.10" + router_id: 192.0.2.10 redistribute: - - route_type: "bgp" + - route_type: bgp replaced: commands: - delete protocols ospfv3 area 2 range 2001:db20::/32 @@ -76,19 +76,19 @@ replaced: after: areas: - area_id: "2" - export_list: "export1" - import_list: "import1" + export_list: export1 + import_list: import1 range: - - address: "2001:db10::/32" - - address: "2001:db30::/32" - - address: "2001:db50::/32" + - address: 2001:db10::/32 + - address: 2001:db30::/32 + - address: 2001:db50::/32 - area_id: "4" range: - - address: "2001:db60::/32" + - address: 2001:db60::/32 parameters: - router_id: "192.0.2.10" + router_id: 192.0.2.10 redistribute: - - route_type: "bgp" + - route_type: bgp rendered: commands: - set protocols ospfv3 redistribute bgp @@ -105,37 +105,37 @@ parsed: after: areas: - area_id: "2" - export_list: "export1" - import_list: "import1" + export_list: export1 + import_list: import1 range: - - address: "2001:db10::/32" - - address: "2001:db20::/32" - - address: "2001:db30::/32" + - address: 2001:db10::/32 + - address: 2001:db20::/32 + - address: 2001:db30::/32 - area_id: "3" range: - - address: "2001:db40::/32" + - address: 2001:db40::/32 parameters: - router_id: "192.0.2.10" + router_id: 192.0.2.10 redistribute: - - route_type: "bgp" + - route_type: bgp deleted: commands: - - "delete protocols ospfv3" + - delete protocols ospfv3 after: {} round_trip: after: areas: - area_id: "2" - export_list: "export1" - import_list: "import1" + export_list: export1 + import_list: import1 range: - - address: "2001:db10::/32" - - address: "2001:db30::/32" - - address: "2001:db50::/32" + - address: 2001:db10::/32 + - address: 2001:db30::/32 + - address: 2001:db50::/32 - area_id: "4" range: - - address: "2001:db60::/32" + - address: 2001:db60::/32 parameters: - router_id: "192.0.2.10" + router_id: 192.0.2.10 redistribute: - - route_type: "bgp" + - route_type: bgp diff --git a/tests/integration/targets/vyos_prefix_lists/tests/cli/_populate_config.yaml b/tests/integration/targets/vyos_prefix_lists/tests/cli/_populate_config.yaml index 9be477d..6135462 100644 --- a/tests/integration/targets/vyos_prefix_lists/tests/cli/_populate_config.yaml +++ b/tests/integration/targets/vyos_prefix_lists/tests/cli/_populate_config.yaml @@ -2,21 +2,21 @@ - name: Populate config vyos.vyos.vyos_config: lines: - - "set policy prefix-list AnsibleIPv4PrefixList description 'PL configured by ansible'" - - "set policy prefix-list AnsibleIPv4PrefixList rule 2 action 'permit'" - - "set policy prefix-list AnsibleIPv4PrefixList rule 2 description 'Rule 2 given by ansible'" - - "set policy prefix-list AnsibleIPv4PrefixList rule 2 le '32'" - - "set policy prefix-list AnsibleIPv4PrefixList rule 2 prefix '92.168.10.0/26'" - - "set policy prefix-list AnsibleIPv4PrefixList rule 3 action 'deny'" - - "set policy prefix-list AnsibleIPv4PrefixList rule 3 description 'Rule 3'" - - "set policy prefix-list AnsibleIPv4PrefixList rule 3 ge '26'" - - "set policy prefix-list AnsibleIPv4PrefixList rule 3 prefix '72.168.2.0/24'" - - "set policy prefix-list6 AllowIPv6Prefix description 'Configured by ansible for allowing IPv6 networks'" - - "set policy prefix-list6 AllowIPv6Prefix rule 5 action 'permit'" - - "set policy prefix-list6 AllowIPv6Prefix rule 5 description 'Permit rule'" - - "set policy prefix-list6 AllowIPv6Prefix rule 5 le '37'" - - "set policy prefix-list6 AllowIPv6Prefix rule 5 prefix '2001:db8:8000::/35'" - - "set policy prefix-list6 DenyIPv6Prefix description 'Configured by ansible for disallowing IPv6 networks'" - - "set policy prefix-list6 DenyIPv6Prefix rule 8 action 'deny'" - - "set policy prefix-list6 DenyIPv6Prefix rule 8 le '37'" - - "set policy prefix-list6 DenyIPv6Prefix rule 8 prefix '2001:db8:2000::/35'" + - set policy prefix-list AnsibleIPv4PrefixList description 'PL configured by ansible' + - set policy prefix-list AnsibleIPv4PrefixList rule 2 action 'permit' + - set policy prefix-list AnsibleIPv4PrefixList rule 2 description 'Rule 2 given by ansible' + - set policy prefix-list AnsibleIPv4PrefixList rule 2 le '32' + - set policy prefix-list AnsibleIPv4PrefixList rule 2 prefix '92.168.10.0/26' + - set policy prefix-list AnsibleIPv4PrefixList rule 3 action 'deny' + - set policy prefix-list AnsibleIPv4PrefixList rule 3 description 'Rule 3' + - set policy prefix-list AnsibleIPv4PrefixList rule 3 ge '26' + - set policy prefix-list AnsibleIPv4PrefixList rule 3 prefix '72.168.2.0/24' + - set policy prefix-list6 AllowIPv6Prefix description 'Configured by ansible for allowing IPv6 networks' + - set policy prefix-list6 AllowIPv6Prefix rule 5 action 'permit' + - set policy prefix-list6 AllowIPv6Prefix rule 5 description 'Permit rule' + - set policy prefix-list6 AllowIPv6Prefix rule 5 le '37' + - set policy prefix-list6 AllowIPv6Prefix rule 5 prefix '2001:db8:8000::/35' + - set policy prefix-list6 DenyIPv6Prefix description 'Configured by ansible for disallowing IPv6 networks' + - set policy prefix-list6 DenyIPv6Prefix rule 8 action 'deny' + - set policy prefix-list6 DenyIPv6Prefix rule 8 le '37' + - set policy prefix-list6 DenyIPv6Prefix rule 8 prefix '2001:db8:2000::/35' diff --git a/tests/integration/targets/vyos_prefix_lists/tests/cli/deleted.yaml b/tests/integration/targets/vyos_prefix_lists/tests/cli/deleted.yaml index efcb14c..b0c0ac9 100644 --- a/tests/integration/targets/vyos_prefix_lists/tests/cli/deleted.yaml +++ b/tests/integration/targets/vyos_prefix_lists/tests/cli/deleted.yaml @@ -11,7 +11,7 @@ - name: Delete all prefix-lists ignore_errors: true register: result - vyos.vyos.vyos_prefix_lists: &id006 + vyos.vyos.vyos_prefix_lists: &id001 config: state: deleted @@ -24,8 +24,7 @@ - name: Assert that correct set of commands were generated assert: that: - - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length\ - \ == 0 }}" + - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that after dict is correctly generated assert: @@ -34,7 +33,7 @@ - name: Delete all prefix-lists (IDEMPOTENT) register: result - vyos.vyos.vyos_prefix_lists: *id006 + vyos.vyos.vyos_prefix_lists: *id001 - name: Assert that task was idempotent assert: @@ -51,7 +50,7 @@ register: result vyos.vyos.vyos_prefix_lists: config: - - afi: "ipv6" + - afi: ipv6 state: deleted - name: Assert that before dicts are correctly generated @@ -83,12 +82,12 @@ register: result vyos.vyos.vyos_prefix_lists: config: - - afi: "ipv4" + - afi: ipv4 prefix_lists: - - name: "AnsibleIPv4PrefixList" - - afi: "ipv6" + - name: AnsibleIPv4PrefixList + - afi: ipv6 prefix_lists: - - name: "DenyIPv6Prefix" + - name: DenyIPv6Prefix state: deleted - name: Assert that before dicts are correctly generated diff --git a/tests/integration/targets/vyos_prefix_lists/tests/cli/merged.yaml b/tests/integration/targets/vyos_prefix_lists/tests/cli/merged.yaml index ef94743..1240db5 100644 --- a/tests/integration/targets/vyos_prefix_lists/tests/cli/merged.yaml +++ b/tests/integration/targets/vyos_prefix_lists/tests/cli/merged.yaml @@ -9,40 +9,40 @@ register: result vyos.vyos.vyos_prefix_lists: &id001 config: - - afi: "ipv4" + - afi: ipv4 prefix_lists: - - name: "AnsibleIPv4PrefixList" - description: "PL configured by ansible" + - name: AnsibleIPv4PrefixList + description: PL configured by ansible entries: - sequence: 2 - description: "Rule 2 given by ansible" - action: "permit" - prefix: "92.168.10.0/26" + description: Rule 2 given by ansible + action: permit + prefix: 92.168.10.0/26 le: 32 - sequence: 3 - description: "Rule 3" - action: "deny" - prefix: "72.168.2.0/24" + description: Rule 3 + action: deny + prefix: 72.168.2.0/24 ge: 26 - - afi: "ipv6" + - afi: ipv6 prefix_lists: - - name: "AllowIPv6Prefix" - description: "Configured by ansible for allowing IPv6 networks" + - name: AllowIPv6Prefix + description: Configured by ansible for allowing IPv6 networks entries: - sequence: 5 - description: "Permit rule" - action: "permit" - prefix: "2001:db8:8000::/35" + description: Permit rule + action: permit + prefix: 2001:db8:8000::/35 le: 37 - name: DenyIPv6Prefix - description: "Configured by ansible for disallowing IPv6 networks" + description: Configured by ansible for disallowing IPv6 networks entries: - sequence: 8 action: deny - prefix: "2001:db8:2000::/35" + prefix: 2001:db8:2000::/35 le: 37 state: merged @@ -53,8 +53,7 @@ - name: Assert that correct set of commands were generated assert: that: - - "{{ merged['commands'] | symmetric_difference(result['commands']) |length\ - \ == 0 }}" + - "{{ merged['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that after dicts were correctly generated assert: diff --git a/tests/integration/targets/vyos_prefix_lists/tests/cli/overridden.yaml b/tests/integration/targets/vyos_prefix_lists/tests/cli/overridden.yaml index 7bcd26b..7c00001 100644 --- a/tests/integration/targets/vyos_prefix_lists/tests/cli/overridden.yaml +++ b/tests/integration/targets/vyos_prefix_lists/tests/cli/overridden.yaml @@ -9,24 +9,24 @@ - block: - name: Override all prefix-lists configuration with provided configuration register: result - vyos.vyos.vyos_prefix_lists: &id003 + vyos.vyos.vyos_prefix_lists: &id001 config: - - afi: "ipv4" + - afi: ipv4 prefix_lists: - - name: "AnsibleIPv4PrefixList" + - name: AnsibleIPv4PrefixList description: Rule 3 overridden by ansible entries: - sequence: 2 - action: "deny" + action: deny ge: 26 - prefix: "82.168.2.0/24" + prefix: 82.168.2.0/24 - - name: "OverriddenPrefixList" + - name: OverriddenPrefixList description: Configuration overridden by ansible entries: - sequence: 10 action: permit - prefix: "203.0.113.96/27" + prefix: 203.0.113.96/27 le: 32 state: overridden @@ -40,8 +40,7 @@ - name: Assert that correct set of commands were generated assert: that: - - "{{ overridden['commands'] | symmetric_difference(result['commands']) |length\ - \ == 0 }}" + - "{{ overridden['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that after dicts were correctly generated assert: @@ -50,7 +49,7 @@ - name: Override all prefix-lists configuration with provided configuration (IDEMPOTENT) register: result - vyos.vyos.vyos_prefix_lists: *id003 + vyos.vyos.vyos_prefix_lists: *id001 - name: Assert that task was idempotent assert: diff --git a/tests/integration/targets/vyos_prefix_lists/tests/cli/rendered.yaml b/tests/integration/targets/vyos_prefix_lists/tests/cli/rendered.yaml index 12a0deb..284abce 100644 --- a/tests/integration/targets/vyos_prefix_lists/tests/cli/rendered.yaml +++ b/tests/integration/targets/vyos_prefix_lists/tests/cli/rendered.yaml @@ -6,46 +6,45 @@ register: result vyos.vyos.vyos_prefix_lists: config: - - afi: "ipv4" + - afi: ipv4 prefix_lists: - - name: "AnsibleIPv4PrefixList" - description: "PL configured by ansible" + - name: AnsibleIPv4PrefixList + description: PL configured by ansible entries: - sequence: 2 - description: "Rule 2 given by ansible" - action: "permit" - prefix: "92.168.10.0/26" + description: Rule 2 given by ansible + action: permit + prefix: 92.168.10.0/26 le: 32 - sequence: 3 - description: "Rule 3" - action: "deny" - prefix: "72.168.2.0/24" + description: Rule 3 + action: deny + prefix: 72.168.2.0/24 ge: 26 - - afi: "ipv6" + - afi: ipv6 prefix_lists: - - name: "AllowIPv6Prefix" - description: "Configured by ansible for allowing IPv6 networks" + - name: AllowIPv6Prefix + description: Configured by ansible for allowing IPv6 networks entries: - sequence: 5 - description: "Permit rule" - action: "permit" - prefix: "2001:db8:8000::/35" + description: Permit rule + action: permit + prefix: 2001:db8:8000::/35 le: 37 - name: DenyIPv6Prefix - description: "Configured by ansible for disallowing IPv6 networks" + description: Configured by ansible for disallowing IPv6 networks entries: - sequence: 8 action: deny - prefix: "2001:db8:2000::/35" + prefix: 2001:db8:2000::/35 le: 37 state: rendered - name: Assert that correct set of commands were rendered assert: that: - - "{{ merged['commands'] | symmetric_difference(result['rendered']) |length\ - \ == 0 }}" + - "{{ merged['commands'] | symmetric_difference(result['rendered']) |length == 0 }}" - result.changed == False diff --git a/tests/integration/targets/vyos_prefix_lists/tests/cli/replaced.yaml b/tests/integration/targets/vyos_prefix_lists/tests/cli/replaced.yaml index fc9f5da..9145eb7 100644 --- a/tests/integration/targets/vyos_prefix_lists/tests/cli/replaced.yaml +++ b/tests/integration/targets/vyos_prefix_lists/tests/cli/replaced.yaml @@ -9,17 +9,17 @@ - block: - name: Replace prefix-lists configurations of listed prefix-lists with provided configurations register: result - vyos.vyos.vyos_prefix_lists: &id002 + vyos.vyos.vyos_prefix_lists: &id001 config: - - afi: "ipv4" + - afi: ipv4 prefix_lists: - - name: "AnsibleIPv4PrefixList" - description: "Configuration replaced by ansible" + - name: AnsibleIPv4PrefixList + description: Configuration replaced by ansible entries: - sequence: 3 - description: "Rule 3 replaced by ansible" - action: "permit" - prefix: "82.168.2.0/24" + description: Rule 3 replaced by ansible + action: permit + prefix: 82.168.2.0/24 ge: 26 state: replaced @@ -33,8 +33,7 @@ - name: Assert that correct set of commands were generated assert: that: - - "{{ replaced['commands'] | symmetric_difference(result['commands']) |length\ - \ == 0 }}" + - "{{ replaced['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that after dicts were correctly generated assert: @@ -45,7 +44,7 @@ - name: Replace prefix-lists configurations of listed prefix-lists with provided configurations (IDEMPOTENT) register: result - vyos.vyos.vyos_prefix_lists: *id002 + vyos.vyos.vyos_prefix_lists: *id001 - name: Assert that task was idempotent assert: diff --git a/tests/integration/targets/vyos_prefix_lists/tests/cli/rtt.yaml b/tests/integration/targets/vyos_prefix_lists/tests/cli/rtt.yaml index 2be2515..df7eb25 100644 --- a/tests/integration/targets/vyos_prefix_lists/tests/cli/rtt.yaml +++ b/tests/integration/targets/vyos_prefix_lists/tests/cli/rtt.yaml @@ -9,40 +9,40 @@ register: base_config vyos.vyos.vyos_prefix_lists: config: - - afi: "ipv4" + - afi: ipv4 prefix_lists: - - name: "AnsibleIPv4PrefixList" - description: "PL configured by ansible" + - name: AnsibleIPv4PrefixList + description: PL configured by ansible entries: - sequence: 2 - description: "Rule 2 given by ansible" - action: "permit" - prefix: "92.168.10.0/26" + description: Rule 2 given by ansible + action: permit + prefix: 92.168.10.0/26 le: 32 - sequence: 3 - description: "Rule 3" - action: "deny" - prefix: "72.168.2.0/24" + description: Rule 3 + action: deny + prefix: 72.168.2.0/24 ge: 26 - - afi: "ipv6" + - afi: ipv6 prefix_lists: - - name: "AllowIPv6Prefix" - description: "Configured by ansible for allowing IPv6 networks" + - name: AllowIPv6Prefix + description: Configured by ansible for allowing IPv6 networks entries: - sequence: 5 - description: "Permit rule" - action: "permit" - prefix: "2001:db8:8000::/35" + description: Permit rule + action: permit + prefix: 2001:db8:8000::/35 le: 37 - name: DenyIPv6Prefix - description: "Configured by ansible for disallowing IPv6 networks" + description: Configured by ansible for disallowing IPv6 networks entries: - sequence: 8 action: deny - prefix: "2001:db8:2000::/35" + prefix: 2001:db8:2000::/35 le: 37 state: merged @@ -57,15 +57,15 @@ register: result vyos.vyos.vyos_prefix_lists: config: - - afi: "ipv4" + - afi: ipv4 prefix_lists: - - name: "AnsibleIPv4PrefixList" - description: "Configuration replaced by ansible" + - name: AnsibleIPv4PrefixList + description: Configuration replaced by ansible entries: - sequence: 3 - description: "Rule 3 replaced by ansible" - action: "permit" - prefix: "82.168.2.0/24" + description: Rule 3 replaced by ansible + action: permit + prefix: 82.168.2.0/24 ge: 26 state: replaced diff --git a/tests/integration/targets/vyos_prefix_lists/vars/main.yaml b/tests/integration/targets/vyos_prefix_lists/vars/main.yaml index 3a30342..7127749 100644 --- a/tests/integration/targets/vyos_prefix_lists/vars/main.yaml +++ b/tests/integration/targets/vyos_prefix_lists/vars/main.yaml @@ -1,7 +1,6 @@ --- merged: before: [] - commands: - set policy prefix-list6 AllowIPv6Prefix - set policy prefix-list6 AllowIPv6Prefix description 'Configured by ansible for allowing IPv6 networks' @@ -106,15 +105,13 @@ overridden: - delete policy prefix-list6 DenyIPv6Prefix - set policy prefix-list AnsibleIPv4PrefixList description 'Rule 3 overridden by ansible' - set policy prefix-list AnsibleIPv4PrefixList rule 2 action 'deny' - - delete policy prefix-list AnsibleIPv4PrefixList rule 2 description 'Rule 2 given - by ansible' + - delete policy prefix-list AnsibleIPv4PrefixList rule 2 description 'Rule 2 given by ansible' - set policy prefix-list AnsibleIPv4PrefixList rule 2 ge '26' - delete policy prefix-list AnsibleIPv4PrefixList rule 2 le '32' - set policy prefix-list AnsibleIPv4PrefixList rule 2 prefix '82.168.2.0/24' - delete policy prefix-list AnsibleIPv4PrefixList rule 3 - set policy prefix-list OverriddenPrefixList - - set policy prefix-list OverriddenPrefixList description 'Configuration overridden - by ansible' + - set policy prefix-list OverriddenPrefixList description 'Configuration overridden by ansible' - set policy prefix-list OverriddenPrefixList rule 10 - set policy prefix-list OverriddenPrefixList rule 10 action 'permit' - set policy prefix-list OverriddenPrefixList rule 10 le '32' diff --git a/tests/integration/targets/vyos_route_maps/tests/cli/deleted.yaml b/tests/integration/targets/vyos_route_maps/tests/cli/deleted.yaml index 84b6446..09a81cc 100644 --- a/tests/integration/targets/vyos_route_maps/tests/cli/deleted.yaml +++ b/tests/integration/targets/vyos_route_maps/tests/cli/deleted.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_route_maps deleted integration tests on connection={{ - ansible_connection }} + msg: START vyos_route_maps deleted integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -21,12 +20,9 @@ - name: Assert that the after dicts were correctly generated assert: that: - - "{{ deleted['after'] | symmetric_difference(result['after']) |length\ - \ == 0 }}" + - "{{ deleted['after'] | symmetric_difference(result['after']) |length == 0 }}" - - name: - Delete the existing configuration with the provided running configuration - (IDEMPOTENT) + - name: Delete the existing configuration with the provided running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_route_maps: *id001 diff --git a/tests/integration/targets/vyos_route_maps/tests/cli/empty_config.yaml b/tests/integration/targets/vyos_route_maps/tests/cli/empty_config.yaml index 6d992b8..13b45ac 100644 --- a/tests/integration/targets/vyos_route_maps/tests/cli/empty_config.yaml +++ b/tests/integration/targets/vyos_route_maps/tests/cli/empty_config.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_route_maps empty_config integration tests on connection={{ - ansible_connection }} + msg: START vyos_route_maps empty_config integration tests on connection={{ ansible_connection }} - name: Merged with empty config should give appropriate error message register: result @@ -45,8 +44,7 @@ - assert: that: - - result.msg == 'value of running_config parameter must not be empty for state - parsed' + - result.msg == 'value of running_config parameter must not be empty for state parsed' - name: Rendered with empty config should give appropriate error message register: result diff --git a/tests/integration/targets/vyos_route_maps/tests/cli/gathered.yaml b/tests/integration/targets/vyos_route_maps/tests/cli/gathered.yaml index 358f5b1..b2a0fa5 100644 --- a/tests/integration/targets/vyos_route_maps/tests/cli/gathered.yaml +++ b/tests/integration/targets/vyos_route_maps/tests/cli/gathered.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_route_maps gathered integration tests on connection={{ - ansible_connection }} + msg: START vyos_route_maps gathered integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml diff --git a/tests/integration/targets/vyos_route_maps/tests/cli/merged.yaml b/tests/integration/targets/vyos_route_maps/tests/cli/merged.yaml index d679800..21205c4 100644 --- a/tests/integration/targets/vyos_route_maps/tests/cli/merged.yaml +++ b/tests/integration/targets/vyos_route_maps/tests/cli/merged.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_route_maps merged integration tests on connection={{ - ansible_connection }} + msg: START vyos_route_maps merged integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -13,7 +12,7 @@ - route_map: test1 entries: - sequence: 1 - description: "test" + description: test action: permit continue_sequence: 2 - route_map: test3 @@ -26,7 +25,7 @@ set: local_preference: 4 metric: 5 - metric_type: "type-1" + metric_type: type-1 origin: egp originator_id: 192.0.2.34 tag: 5 @@ -46,12 +45,9 @@ - name: Assert that before dicts were correctly generated assert: that: - - "{{ merged['before'] | symmetric_difference(result['before']) |length\ - \ == 0 }}" + - "{{ merged['before'] | symmetric_difference(result['before']) |length == 0 }}" - - name: - Merge the provided configuration with the existing running configuration - (IDEMPOTENT) + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_route_maps: *id001 diff --git a/tests/integration/targets/vyos_route_maps/tests/cli/overridden.yaml b/tests/integration/targets/vyos_route_maps/tests/cli/overridden.yaml index d33a7c4..1d57173 100644 --- a/tests/integration/targets/vyos_route_maps/tests/cli/overridden.yaml +++ b/tests/integration/targets/vyos_route_maps/tests/cli/overridden.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_route_maps overridden integration tests on connection={{ - ansible_connection }} + msg: START vyos_route_maps overridden integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -20,7 +19,7 @@ set: local_preference: 6 metric: 4 - metric_type: "type-1" + metric_type: type-1 origin: egp originator_id: 192.0.2.34 tag: 4 @@ -37,9 +36,7 @@ - result.commands|symmetric_difference(overridden.commands) == [] - result.after|symmetric_difference(ansible_facts['network_resources']['route_maps']) == [] - - name: - Override the existing configuration with the provided running configuration - (IDEMPOTENT) + - name: Override the existing configuration with the provided running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_route_maps: *id001 diff --git a/tests/integration/targets/vyos_route_maps/tests/cli/parsed.yaml b/tests/integration/targets/vyos_route_maps/tests/cli/parsed.yaml index f098347..c41b513 100644 --- a/tests/integration/targets/vyos_route_maps/tests/cli/parsed.yaml +++ b/tests/integration/targets/vyos_route_maps/tests/cli/parsed.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_route_maps parsed integration tests on connection={{ ansible_connection - }} + msg: START vyos_route_maps parsed integration tests on connection={{ ansible_connection }} - name: Provide the running configuration for parsing (config to be parsed) register: result diff --git a/tests/integration/targets/vyos_route_maps/tests/cli/rendered.yaml b/tests/integration/targets/vyos_route_maps/tests/cli/rendered.yaml index f9e599f..00a0199 100644 --- a/tests/integration/targets/vyos_route_maps/tests/cli/rendered.yaml +++ b/tests/integration/targets/vyos_route_maps/tests/cli/rendered.yaml @@ -1,19 +1,18 @@ --- - debug: - msg: START vyos_route_maps rendered integration tests on connection={{ - ansible_connection }} + msg: START vyos_route_maps rendered integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml - block: - name: Structure provided configuration into device specific commands register: result - vyos.vyos.vyos_route_maps: &id001 + vyos.vyos.vyos_route_maps: config: - route_map: test1 entries: - sequence: 1 - description: "test" + description: test action: permit continue_sequence: 2 - route_map: test3 @@ -26,7 +25,7 @@ set: local_preference: 4 metric: 5 - metric_type: "type-1" + metric_type: type-1 origin: egp originator_id: 192.0.2.34 tag: 5 diff --git a/tests/integration/targets/vyos_route_maps/tests/cli/replaced.yaml b/tests/integration/targets/vyos_route_maps/tests/cli/replaced.yaml index 57a91fd..d7d05ec 100644 --- a/tests/integration/targets/vyos_route_maps/tests/cli/replaced.yaml +++ b/tests/integration/targets/vyos_route_maps/tests/cli/replaced.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_route_maps replaced integration tests on connection={{ - ansible_connection }} + msg: START vyos_route_maps replaced integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -20,7 +19,7 @@ set: local_preference: 6 metric: 4 - metric_type: "type-1" + metric_type: type-1 origin: egp originator_id: 192.0.2.34 tag: 4 @@ -37,9 +36,7 @@ - result.commands|symmetric_difference(replaced.commands) == [] - result.after|symmetric_difference(ansible_facts['network_resources']['route_maps']) == [] - - name: - Replace the provided configuration with the existing running configuration - (IDEMPOTENT) + - name: Replace the provided configuration with the existing running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_route_maps: *id001 diff --git a/tests/integration/targets/vyos_route_maps/tests/cli/rtt.yaml b/tests/integration/targets/vyos_route_maps/tests/cli/rtt.yaml index 6b1616b..af16ddb 100644 --- a/tests/integration/targets/vyos_route_maps/tests/cli/rtt.yaml +++ b/tests/integration/targets/vyos_route_maps/tests/cli/rtt.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_route_maps merged integration tests on connection={{ - ansible_connection }} + msg: START vyos_route_maps merged integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -13,7 +12,7 @@ - route_map: test1 entries: - sequence: 1 - description: "test" + description: test action: permit continue_sequence: 2 - route_map: test3 @@ -26,7 +25,7 @@ set: local_preference: 4 metric: 5 - metric_type: "type-1" + metric_type: type-1 origin: egp originator_id: 192.0.2.34 tag: 5 @@ -57,7 +56,7 @@ set: local_preference: 6 metric: 4 - metric_type: "type-1" + metric_type: type-1 origin: egp originator_id: 192.0.2.34 tag: 4 diff --git a/tests/integration/targets/vyos_route_maps/vars/main.yaml b/tests/integration/targets/vyos_route_maps/vars/main.yaml index 47658f4..838cc5e 100644 --- a/tests/integration/targets/vyos_route_maps/vars/main.yaml +++ b/tests/integration/targets/vyos_route_maps/vars/main.yaml @@ -17,26 +17,26 @@ merged: - set policy route-map test3 rule 1 match peer 192.0.2.32 after: - - route_map: "test3" + - route_map: test3 entries: - sequence: 1 - action: "permit" + action: permit match: metric: 1 - peer: "192.0.2.32" + peer: 192.0.2.32 set: local_preference: "4" metric: "5" - metric_type: "type-1" + metric_type: type-1 origin: egp - originator_id: "192.0.2.34" + originator_id: 192.0.2.34 tag: "5" weight: "4" - - route_map: "test1" + - route_map: test1 entries: - sequence: 1 - description: "test" - action: "permit" + description: test + action: permit continue_sequence: 2 replaced: @@ -53,7 +53,7 @@ replaced: - route_map: test2 entries: - sequence: 1 - description: "test" + description: test action: permit - sequence: 1 action: permit @@ -69,7 +69,7 @@ replaced: set: local_preference: 6 metric: 4 - metric_type: "type-1" + metric_type: type-1 origin: egp originator_id: 192.0.2.34 tag: 4 @@ -97,7 +97,7 @@ overridden: set: local_preference: 6 metric: 4 - metric_type: "type-1" + metric_type: type-1 origin: egp originator_id: 192.0.2.34 tag: 4 diff --git a/tests/integration/targets/vyos_snmp_server/tests/cli/deleted.yaml b/tests/integration/targets/vyos_snmp_server/tests/cli/deleted.yaml index 8cd2c8a..e6ac9b9 100644 --- a/tests/integration/targets/vyos_snmp_server/tests/cli/deleted.yaml +++ b/tests/integration/targets/vyos_snmp_server/tests/cli/deleted.yaml @@ -24,9 +24,7 @@ that: - result.after == {} - - name: - Delete the existing configuration with the provided running configuration - (IDEMPOTENT) + - name: Delete the existing configuration with the provided running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_snmp_server: *id001 diff --git a/tests/integration/targets/vyos_snmp_server/tests/cli/empty_config.yaml b/tests/integration/targets/vyos_snmp_server/tests/cli/empty_config.yaml index 558b53f..e213efd 100644 --- a/tests/integration/targets/vyos_snmp_server/tests/cli/empty_config.yaml +++ b/tests/integration/targets/vyos_snmp_server/tests/cli/empty_config.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_snmp_server empty_config integration tests on connection={{ - ansible_connection }} + msg: START vyos_snmp_server empty_config integration tests on connection={{ ansible_connection }} - name: Merged with empty config should give appropriate error message register: result @@ -45,8 +44,7 @@ - assert: that: - - result.msg == 'value of running_config parameter must not be empty for state - parsed' + - result.msg == 'value of running_config parameter must not be empty for state parsed' - name: Rendered with empty config should give appropriate error message register: result diff --git a/tests/integration/targets/vyos_snmp_server/tests/cli/gathered.yaml b/tests/integration/targets/vyos_snmp_server/tests/cli/gathered.yaml index 7cdf3c4..60bddee 100644 --- a/tests/integration/targets/vyos_snmp_server/tests/cli/gathered.yaml +++ b/tests/integration/targets/vyos_snmp_server/tests/cli/gathered.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_snmp_server gathered integration tests on connection={{ - ansible_connection }} + msg: START vyos_snmp_server gathered integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_snmp_server/tests/cli/merged.yaml b/tests/integration/targets/vyos_snmp_server/tests/cli/merged.yaml index 06627b0..7f8139d 100644 --- a/tests/integration/targets/vyos_snmp_server/tests/cli/merged.yaml +++ b/tests/integration/targets/vyos_snmp_server/tests/cli/merged.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_snmp_server merged integration tests on connection={{ - ansible_connection }} + msg: START vyos_snmp_server merged integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -11,24 +10,24 @@ vyos.vyos.vyos_snmp_server: &id001 config: communities: - - name: "switches" - authorization_type: "rw" - - name: "bridges" - clients: ["1.1.1.1", "12.1.1.10"] - contact: "admin2@ex.com" + - name: switches + authorization_type: rw + - name: bridges + clients: [1.1.1.1, 12.1.1.10] + contact: admin2@ex.com listen_addresses: - - address: "20.1.1.1" - - address: "100.1.2.1" + - address: 20.1.1.1 + - address: 100.1.2.1 port: 33 snmp_v3: users: - user: adminuser authentication: - plaintext_key: "abc1234567" - type: "sha" + plaintext_key: abc1234567 + type: sha privacy: - plaintext_key: "abc1234567" - type: "aes" + plaintext_key: abc1234567 + type: aes state: merged - vyos.vyos.vyos_facts: @@ -47,9 +46,7 @@ that: - result.before == {} - - name: - Merge the provided configuration with the existing running configuration - (IDEMPOTENT) + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_snmp_server: *id001 diff --git a/tests/integration/targets/vyos_snmp_server/tests/cli/overridden.yaml b/tests/integration/targets/vyos_snmp_server/tests/cli/overridden.yaml index b1d6565..2dc6eda 100644 --- a/tests/integration/targets/vyos_snmp_server/tests/cli/overridden.yaml +++ b/tests/integration/targets/vyos_snmp_server/tests/cli/overridden.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_snmp_server overridden integration tests on connection={{ - ansible_connection }} + msg: START vyos_snmp_server overridden integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -13,31 +12,31 @@ vyos.vyos.vyos_snmp_server: &id001 config: communities: - - name: "bridges" - networks: ["1.1.1.0/24", "12.1.1.0/24"] - location: "RDU" + - name: bridges + networks: [1.1.1.0/24, 12.1.1.0/24] + location: RDU listen_addresses: - - address: "100.1.2.1" + - address: 100.1.2.1 port: 33 snmp_v3: users: - user: adminuser engine_id: "33" authentication: - plaintext_key: "abc1234567" - type: "sha" + plaintext_key: abc1234567 + type: sha privacy: - plaintext_key: "abc1234567" - type: "aes" + plaintext_key: abc1234567 + type: aes - user: guestuser2 authentication: - plaintext_key: "opq1234567" - type: "sha" + plaintext_key: opq1234567 + type: sha privacy: - plaintext_key: "opq1234567" - type: "aes" + plaintext_key: opq1234567 + type: aes views: - - view: "default" + - view: default oid: 1 state: overridden @@ -50,9 +49,7 @@ - result.after == ansible_facts['network_resources']['snmp_server'] - result.commands|length == 13 - - name: - Override the existing configuration with the provided running configuration - (IDEMPOTENT) + - name: Override the existing configuration with the provided running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_snmp_server: *id001 diff --git a/tests/integration/targets/vyos_snmp_server/tests/cli/parsed.yaml b/tests/integration/targets/vyos_snmp_server/tests/cli/parsed.yaml index 4ecc1ac..bd1b1c3 100644 --- a/tests/integration/targets/vyos_snmp_server/tests/cli/parsed.yaml +++ b/tests/integration/targets/vyos_snmp_server/tests/cli/parsed.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_snmp_server parsed integration tests on connection={{ ansible_connection - }} + msg: START vyos_snmp_server parsed integration tests on connection={{ ansible_connection }} - name: Provide the running configuration for parsing (config to be parsed) register: result diff --git a/tests/integration/targets/vyos_snmp_server/tests/cli/rendered.yaml b/tests/integration/targets/vyos_snmp_server/tests/cli/rendered.yaml index e238827..f3d9254 100644 --- a/tests/integration/targets/vyos_snmp_server/tests/cli/rendered.yaml +++ b/tests/integration/targets/vyos_snmp_server/tests/cli/rendered.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_snmp_server rendered integration tests on connection={{ - ansible_connection }} + msg: START vyos_snmp_server rendered integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -11,24 +10,24 @@ vyos.vyos.vyos_snmp_server: config: communities: - - name: "switches" - authorization_type: "rw" - - name: "bridges" - clients: ["1.1.1.1", "12.1.1.10"] - contact: "admin2@ex.com" + - name: switches + authorization_type: rw + - name: bridges + clients: [1.1.1.1, 12.1.1.10] + contact: admin2@ex.com listen_addresses: - - address: "20.1.1.1" - - address: "100.1.2.1" + - address: 20.1.1.1 + - address: 100.1.2.1 port: 33 snmp_v3: users: - user: adminuser authentication: - plaintext_key: "abc1234567" - type: "sha" + plaintext_key: abc1234567 + type: sha privacy: - plaintext_key: "abc1234567" - type: "aes" + plaintext_key: abc1234567 + type: aes state: rendered - assert: diff --git a/tests/integration/targets/vyos_snmp_server/tests/cli/replaced.yaml b/tests/integration/targets/vyos_snmp_server/tests/cli/replaced.yaml index 2bfcaf6..3b75992 100644 --- a/tests/integration/targets/vyos_snmp_server/tests/cli/replaced.yaml +++ b/tests/integration/targets/vyos_snmp_server/tests/cli/replaced.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_snmp_server replaced integration tests on connection={{ - ansible_connection }} + msg: START vyos_snmp_server replaced integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -13,31 +12,31 @@ vyos.vyos.vyos_snmp_server: &id001 config: communities: - - name: "bridges" - networks: ["1.1.1.0/24", "12.1.1.0/24"] - location: "RDU" + - name: bridges + networks: [1.1.1.0/24, 12.1.1.0/24] + location: RDU listen_addresses: - - address: "100.1.2.1" + - address: 100.1.2.1 port: 33 snmp_v3: users: - user: adminuser engine_id: "33" authentication: - plaintext_key: "abc1234567" - type: "sha" + plaintext_key: abc1234567 + type: sha privacy: - plaintext_key: "abc1234567" - type: "aes" + plaintext_key: abc1234567 + type: aes - user: guestuser2 authentication: - plaintext_key: "opq1234567" - type: "sha" + plaintext_key: opq1234567 + type: sha privacy: - plaintext_key: "opq1234567" - type: "aes" + plaintext_key: opq1234567 + type: aes views: - - view: "default" + - view: default oid: 1 state: replaced @@ -50,9 +49,7 @@ - result.after == ansible_facts['network_resources']['snmp_server'] - result.commands|length == 13 - - name: - Replace the existing configuration with the provided running configuration - (IDEMPOTENT) + - name: Replace the existing configuration with the provided running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_snmp_server: *id001 diff --git a/tests/integration/targets/vyos_snmp_server/vars/main.yaml b/tests/integration/targets/vyos_snmp_server/vars/main.yaml index 060421b..3034390 100644 --- a/tests/integration/targets/vyos_snmp_server/vars/main.yaml +++ b/tests/integration/targets/vyos_snmp_server/vars/main.yaml @@ -17,23 +17,23 @@ merged: - clients: - 1.1.1.1 - 12.1.1.10 - name: "bridges" - - authorization_type: "rw" - name: "switches" - contact: "admin2@ex.com" + name: bridges + - authorization_type: rw + name: switches + contact: admin2@ex.com listen_addresses: - - address: "100.1.2.1" + - address: 100.1.2.1 port: 33 - - address: "20.1.1.1" + - address: 20.1.1.1 snmp_v3: users: - authentication: - plaintext_key: "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER" - type: "sha" + plaintext_key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER + type: sha privacy: - plaintext_key: "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER" - type: "aes" - user: "adminuser" + plaintext_key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER + type: aes + user: adminuser overridden: commands: @@ -53,74 +53,73 @@ overridden: after: communities: - - name: "bridges" + - name: bridges networks: - - "1.1.1.0/24" - - "12.1.1.0/24" - - name: "switches" + - 1.1.1.0/24 + - 12.1.1.0/24 + - name: switches listen_addresses: - - address: "100.1.2.1" + - address: 100.1.2.1 port: 33 - location: "RDU, NC" + location: RDU, NC snmp_v3: users: - authentication: - plaintext_key: "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER" - type: "sha" + plaintext_key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER + type: sha privacy: - plaintext_key: "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER" - type: "aes" - user: "adminuser" + plaintext_key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER + type: aes + user: adminuser - authentication: - plaintext_key: "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER" - type: "sha" + plaintext_key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER + type: sha privacy: - plaintext_key: "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER" - type: "aes" - user: "guestuser2" + plaintext_key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER + type: aes + user: guestuser2 views: - oid: 1 - view: "default" + view: default deleted: commands: - delete service snmp after: {} - parsed: after: communities: - - authorization_type: "ro" + - authorization_type: ro clients: - 203.0.113.10 - 203.0.113.20 - name: "routers" + name: routers networks: - 192.0.2.0/24 - 2001::/64 - contact: "admin@example.com" + contact: admin@example.com listen_addresses: - - address: "172.16.254.36" + - address: 172.16.254.36 port: 161 - - address: "2001::1" - location: "UK, London" + - address: 2001::1 + location: UK, London snmp_v3: engine_id: "000000000000000000000002" groups: - - group: "default" - mode: "ro" - view: "default" + - group: default + mode: ro + view: default users: - authentication: - plaintext_key: "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER" - type: "sha" - group: "default" + plaintext_key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER + type: sha + group: default privacy: - plaintext_key: "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER" - type: "aes" - user: "vyos" + plaintext_key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER + type: aes + user: vyos views: - oid: "1" - view: "default" + view: default trap_target: - address: "203.0.113.10" + address: 203.0.113.10 diff --git a/tests/integration/targets/vyos_static_routes/tests/cli/_populate.yaml b/tests/integration/targets/vyos_static_routes/tests/cli/_populate.yaml index 12e4392..fdd6b1a 100644 --- a/tests/integration/targets/vyos_static_routes/tests/cli/_populate.yaml +++ b/tests/integration/targets/vyos_static_routes/tests/cli/_populate.yaml @@ -3,12 +3,14 @@ - name: Setup vars: - lines: "set protocols static route 192.0.2.32/28 next-hop '192.0.2.10'\nset\ - \ protocols static route 192.0.2.32/28 next-hop '192.0.2.9'\nset protocols\ - \ static route 192.0.2.32/28 blackhole\nset protocols static route 192.0.2.32/28\n\ - set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::1'\n\ - set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::2'\n\ - set protocols static route6 2001:db8:1000::/36 blackhole distance '2'\nset\ - \ protocols static route6 2001:db8:1000::/36\n" + lines: >- + "set protocols static route 192.0.2.32/28 next-hop '192.0.2.10'\n + set protocols static route 192.0.2.32/28 next-hop '192.0.2.9'\n + set protocols static route 192.0.2.32/28 blackhole\n + set protocols static route 192.0.2.32/28\n + set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::1'\n + set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::2'\n + set protocols static route6 2001:db8:1000::/36 blackhole distance '2'\n + set protocols static route6 2001:db8:1000::/36" ansible.netcommon.cli_config: config: "{{ lines }}" diff --git a/tests/integration/targets/vyos_static_routes/tests/cli/deleted_afi.yaml b/tests/integration/targets/vyos_static_routes/tests/cli/deleted_afi.yaml index 491f9c3..bcfa049 100644 --- a/tests/integration/targets/vyos_static_routes/tests/cli/deleted_afi.yaml +++ b/tests/integration/targets/vyos_static_routes/tests/cli/deleted_afi.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - Start vyos_static_routes deleted integration tests ansible_connection={{ - ansible_connection }} + msg: Start vyos_static_routes deleted integration tests ansible_connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -25,14 +23,12 @@ - name: Assert that the correct set of commands were generated assert: that: - - "{{ deleted_afi_all['commands'] | symmetric_difference(result['commands'])\ - \ |length == 0 }}" + - "{{ deleted_afi_all['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that the after dicts were correctly generated assert: that: - - "{{ deleted_afi_all['after'] | symmetric_difference(result['after'])\ - \ |length == 0 }}" + - "{{ deleted_afi_all['after'] | symmetric_difference(result['after']) |length == 0 }}" - name: Delete attributes of given interfaces (IDEMPOTENT) register: result @@ -47,7 +43,6 @@ - name: Assert that the before dicts were correctly generated assert: that: - - "{{ deleted_afi_all['after'] | symmetric_difference(result['before'])\ - \ |length == 0 }}" + - "{{ deleted_afi_all['after'] | symmetric_difference(result['before']) |length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_static_routes/tests/cli/deleted_all.yaml b/tests/integration/targets/vyos_static_routes/tests/cli/deleted_all.yaml index bddb528..ebc9192 100644 --- a/tests/integration/targets/vyos_static_routes/tests/cli/deleted_all.yaml +++ b/tests/integration/targets/vyos_static_routes/tests/cli/deleted_all.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - Start vyos_static_routes deleted integration tests ansible_connection={{ - ansible_connection }} + msg: Start vyos_static_routes deleted integration tests ansible_connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -21,14 +19,12 @@ - name: Assert that the correct set of commands were generated assert: that: - - "{{ deleted_afi_all['commands'] | symmetric_difference(result['commands'])\ - \ |length == 0 }}" + - "{{ deleted_afi_all['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that the after dicts were correctly generated assert: that: - - "{{ deleted_afi_all['after'] | symmetric_difference(result['after'])\ - \ |length == 0 }}" + - "{{ deleted_afi_all['after'] | symmetric_difference(result['after']) |length == 0 }}" - name: Delete attributes of given interfaces (IDEMPOTENT) register: result @@ -43,7 +39,6 @@ - name: Assert that the before dicts were correctly generated assert: that: - - "{{ deleted_afi_all['after'] | symmetric_difference(result['before'])\ - \ |length == 0 }}" + - "{{ deleted_afi_all['after'] | symmetric_difference(result['before']) |length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_static_routes/tests/cli/empty_config.yaml b/tests/integration/targets/vyos_static_routes/tests/cli/empty_config.yaml index 6fded87..31ca9e6 100644 --- a/tests/integration/targets/vyos_static_routes/tests/cli/empty_config.yaml +++ b/tests/integration/targets/vyos_static_routes/tests/cli/empty_config.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_static_routes empty_config integration tests on connection={{ - ansible_connection }} + msg: START vyos_static_routes empty_config integration tests on connection={{ ansible_connection }} - name: Merged with empty config should give appropriate error message register: result @@ -46,8 +44,7 @@ - assert: that: - - result.msg == 'value of running_config parameter must not be empty for state - parsed' + - result.msg == 'value of running_config parameter must not be empty for state parsed' - name: Rendered with empty config should give appropriate error message register: result diff --git a/tests/integration/targets/vyos_static_routes/tests/cli/gathered.yaml b/tests/integration/targets/vyos_static_routes/tests/cli/gathered.yaml index 6b34912..0af88be 100644 --- a/tests/integration/targets/vyos_static_routes/tests/cli/gathered.yaml +++ b/tests/integration/targets/vyos_static_routes/tests/cli/gathered.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_static_routes gathered integration tests on connection={{ ansible_connection - }} + msg: START vyos_static_routes gathered integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -16,8 +14,7 @@ - name: Assert that gathered dicts was correctly generated assert: that: - - "{{ populate | symmetric_difference(result['gathered']) |length == 0\ - \ }}" + - "{{ populate | symmetric_difference(result['gathered']) |length == 0 }}" - name: Gather the existing running configuration (IDEMPOTENT) register: result diff --git a/tests/integration/targets/vyos_static_routes/tests/cli/merged.yaml b/tests/integration/targets/vyos_static_routes/tests/cli/merged.yaml index 19e71fa..273f460 100644 --- a/tests/integration/targets/vyos_static_routes/tests/cli/merged.yaml +++ b/tests/integration/targets/vyos_static_routes/tests/cli/merged.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_static_routes merged integration tests on connection={{ ansible_connection - }} + msg: START vyos_static_routes merged integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -36,25 +34,19 @@ - name: Assert that before dicts were correctly generated assert: - that: - "{{ merged['before'] | symmetric_difference(result['before']) |length\ - \ == 0 }}" + that: "{{ merged['before'] | symmetric_difference(result['before']) |length == 0 }}" - name: Assert that correct set of commands were generated assert: that: - - "{{ merged['commands'] | symmetric_difference(result['commands']) |length\ - \ == 0 }}" + - "{{ merged['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that after dicts was correctly generated assert: that: - - "{{ merged['after'] | symmetric_difference(result['after']) |length\ - \ == 0 }}" + - "{{ merged['after'] | symmetric_difference(result['after']) |length == 0 }}" - - name: - Merge the provided configuration with the existing running configuration - (IDEMPOTENT) + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_static_routes: *id001 @@ -66,7 +58,6 @@ - name: Assert that before dicts were correctly generated assert: that: - - "{{ merged['after'] | symmetric_difference(result['before']) |length\ - \ == 0 }}" + - "{{ merged['after'] | symmetric_difference(result['before']) |length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_static_routes/tests/cli/overridden.yaml b/tests/integration/targets/vyos_static_routes/tests/cli/overridden.yaml index 9281306..da5aff4 100644 --- a/tests/integration/targets/vyos_static_routes/tests/cli/overridden.yaml +++ b/tests/integration/targets/vyos_static_routes/tests/cli/overridden.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_static_routes overridden integration tests on connection={{ - ansible_connection }} + msg: START vyos_static_routes overridden integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -26,14 +25,12 @@ - name: Assert that correct commands were generated assert: that: - - "{{ overridden['commands'] | symmetric_difference(result['commands'])\ - \ |length == 0 }}" + - "{{ overridden['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that after dicts were correctly generated assert: that: - - "{{ overridden['after'] | symmetric_difference(result['after']) |length\ - \ == 0 }}" + - "{{ overridden['after'] | symmetric_difference(result['after']) |length == 0 }}" - name: Overrides all device configuration with provided configurations (IDEMPOTENT) register: result @@ -47,7 +44,6 @@ - name: Assert that before dicts were correctly generated assert: that: - - "{{ overridden['after'] | symmetric_difference(result['before']) |length\ - \ == 0 }}" + - "{{ overridden['after'] | symmetric_difference(result['before']) |length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_static_routes/tests/cli/parsed.yaml b/tests/integration/targets/vyos_static_routes/tests/cli/parsed.yaml index 5776f7f..9881bd0 100644 --- a/tests/integration/targets/vyos_static_routes/tests/cli/parsed.yaml +++ b/tests/integration/targets/vyos_static_routes/tests/cli/parsed.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_static_routes parsed integration tests on connection={{ ansible_connection - }} + msg: START vyos_static_routes parsed integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -23,9 +21,7 @@ - name: Assert that correct parsing done assert: - that: - "{{ ansible_facts['network_resources']['static_routes'] | symmetric_difference(result['parsed'])\ - \ |length == 0 }}" + that: "{{ ansible_facts['network_resources']['static_routes'] | symmetric_difference(result['parsed']) |length == 0 }}" - name: Gather the existing running configuration (IDEMPOTENT) register: result diff --git a/tests/integration/targets/vyos_static_routes/tests/cli/rendered.yaml b/tests/integration/targets/vyos_static_routes/tests/cli/rendered.yaml index 4362d1f..761cff7 100644 --- a/tests/integration/targets/vyos_static_routes/tests/cli/rendered.yaml +++ b/tests/integration/targets/vyos_static_routes/tests/cli/rendered.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START vyos_static_routes rendered integration tests on connection={{ ansible_connection - }} + msg: START vyos_static_routes rendered integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml @@ -37,8 +35,7 @@ - name: Assert that correct set of commands were generated assert: that: - - "{{ rendered['commands'] | symmetric_difference(result['rendered'])\ - \ |length == 0 }}" + - "{{ rendered['commands'] | symmetric_difference(result['rendered']) |length == 0 }}" - name: Structure provided configuration into device specific commands (IDEMPOTENT) register: result diff --git a/tests/integration/targets/vyos_static_routes/tests/cli/replaced.yaml b/tests/integration/targets/vyos_static_routes/tests/cli/replaced.yaml index 28f80fb..26150e5 100644 --- a/tests/integration/targets/vyos_static_routes/tests/cli/replaced.yaml +++ b/tests/integration/targets/vyos_static_routes/tests/cli/replaced.yaml @@ -1,14 +1,11 @@ --- - debug: - msg: - START vyos_static_routes replaced integration tests on connection={{ ansible_connection - }} + msg: START vyos_static_routes replaced integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml - block: - - name: Replace device configurations of listed static routes with provided - configurations + - name: Replace device configurations of listed static routes with provided configurations register: result vyos.vyos.vyos_static_routes: &id001 config: @@ -29,8 +26,7 @@ - name: Assert that correct set of commands were generated assert: that: - - "{{ replaced['commands'] | symmetric_difference(result['commands'])\ - \ |length == 0 }}" + - "{{ replaced['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that before dicts are correctly generated assert: @@ -40,11 +36,9 @@ - name: Assert that after dict is correctly generated assert: that: - - "{{ replaced['after'] | symmetric_difference(result['after']) |length\ - \ == 0 }}" + - "{{ replaced['after'] | symmetric_difference(result['after']) |length == 0 }}" - - name: Replace device configurations of listed static routes with provided - configurarions (IDEMPOTENT) + - name: Replace device configurations of listed static routes with provided configurarions (IDEMPOTENT) register: result vyos.vyos.vyos_static_routes: *id001 @@ -56,7 +50,6 @@ - name: Assert that before dict is correctly generated assert: that: - - "{{ replaced['after'] | symmetric_difference(result['before']) |length\ - \ == 0 }}" + - "{{ replaced['after'] | symmetric_difference(result['before']) |length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_static_routes/tests/cli/rtt.yaml b/tests/integration/targets/vyos_static_routes/tests/cli/rtt.yaml index 64e8044..2f8d475 100644 --- a/tests/integration/targets/vyos_static_routes/tests/cli/rtt.yaml +++ b/tests/integration/targets/vyos_static_routes/tests/cli/rtt.yaml @@ -1,7 +1,6 @@ --- - debug: - msg: START vyos_static_routes round trip integration tests on connection={{ - ansible_connection }} + msg: START vyos_static_routes round trip integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -60,9 +59,7 @@ - name: Assert that changes were applied assert: - that: - "{{ round_trip['after'] | symmetric_difference(result['after']) |length\ - \ == 0 }}" + that: "{{ round_trip['after'] | symmetric_difference(result['after']) |length == 0 }}" - name: Revert back to base config using facts round trip register: revert @@ -72,8 +69,6 @@ - name: Assert that config was reverted assert: - that: - "{{ base_config['after'] | symmetric_difference(revert['after']) |length\ - \ == 0 }}" + that: "{{ base_config['after'] | symmetric_difference(revert['after']) |length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_static_routes/tests/redirection/cli/shortname.yaml b/tests/integration/targets/vyos_static_routes/tests/redirection/cli/shortname.yaml index 364866e..9bf6cbb 100644 --- a/tests/integration/targets/vyos_static_routes/tests/redirection/cli/shortname.yaml +++ b/tests/integration/targets/vyos_static_routes/tests/redirection/cli/shortname.yaml @@ -1,8 +1,6 @@ --- - debug: - msg: - START shortname merged integration tests on connection={{ ansible_connection - }} + msg: START shortname merged integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml @@ -36,25 +34,19 @@ - name: Assert that before dicts were correctly generated assert: - that: - "{{ merged['before'] | symmetric_difference(result['before']) |length\ - \ == 0 }}" + that: "{{ merged['before'] | symmetric_difference(result['before']) |length == 0 }}" - name: Assert that correct set of commands were generated assert: that: - - "{{ merged['commands'] | symmetric_difference(result['commands']) |length\ - \ == 0 }}" + - "{{ merged['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that after dicts was correctly generated assert: that: - - "{{ merged['after'] | symmetric_difference(result['after']) |length\ - \ == 0 }}" + - "{{ merged['after'] | symmetric_difference(result['after']) |length == 0 }}" - - name: - Merge the provided configuration with the existing running configuration - (IDEMPOTENT) + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) register: result vyos.vyos.static_routes: *id001 @@ -66,7 +58,6 @@ - name: Assert that before dicts were correctly generated assert: that: - - "{{ merged['after'] | symmetric_difference(result['before']) |length\ - \ == 0 }}" + - "{{ merged['after'] | symmetric_difference(result['before']) |length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_user/tests/cli/auth.yaml b/tests/integration/targets/vyos_user/tests/cli/auth.yaml index 87eaba6..a3178bf 100644 --- a/tests/integration/targets/vyos_user/tests/cli/auth.yaml +++ b/tests/integration/targets/vyos_user/tests/cli/auth.yaml @@ -9,18 +9,18 @@ - name: test login via ssh with new user expect: - command: - ssh auth_user@{{ ansible_ssh_host }} -p {{ ansible_port | default(22) - }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no '/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper + command: >- + ssh auth_user@{{ ansible_ssh_host }} -p {{ ansible_port | default(22) }} \ + -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no '/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper show version' responses: (?i)password: pass123 - name: test login via ssh with invalid password (should fail) expect: - command: - ssh auth_user@{{ ansible_ssh_host }} -p {{ ansible_port | default(22) - }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no '/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper + command: >- + ssh auth_user@{{ ansible_ssh_host }} -p {{ ansible_port | default(22) }} \ + -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no '/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper show version' responses: (?i)password: badpass diff --git a/tests/integration/targets/vyos_user/tests/cli/basic.yaml b/tests/integration/targets/vyos_user/tests/cli/basic.yaml index edd3b5c..096edc0 100644 --- a/tests/integration/targets/vyos_user/tests/cli/basic.yaml +++ b/tests/integration/targets/vyos_user/tests/cli/basic.yaml @@ -34,8 +34,7 @@ - assert: that: - result.changed == true - - result.commands == ["set system login user ansibletest2 level operator", - "set system login user ansibletest3 level operator"] + - result.commands == ["set system login user ansibletest2 level operator", "set system login user ansibletest3 level operator"] - name: Add user again (Idempotent) register: result @@ -79,5 +78,4 @@ - assert: that: - result.changed == true - - result.commands == ["delete system login user ansibletest1", "delete system - login user ansibletest2", "delete system login user ansibletest3"] + - result.commands == ["delete system login user ansibletest1", "delete system login user ansibletest2", "delete system login user ansibletest3"] diff --git a/tests/unit/mock/loader.py b/tests/unit/mock/loader.py index 2828f38..67b84c6 100644 --- a/tests/unit/mock/loader.py +++ b/tests/unit/mock/loader.py @@ -18,6 +18,7 @@ # Make coding more python3-ish from __future__ import absolute_import, division, print_function + __metaclass__ = type import os diff --git a/tests/unit/mock/path.py b/tests/unit/mock/path.py index 3962f24..1f1b7f0 100644 --- a/tests/unit/mock/path.py +++ b/tests/unit/mock/path.py @@ -1,8 +1,10 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type from ansible.utils.path import unfrackpath from ansible_collections.vyos.vyos.tests.unit.compat.mock import MagicMock + mock_unfrackpath_noop = MagicMock(spec_set=unfrackpath, side_effect=lambda x, *args, **kwargs: x) diff --git a/tests/unit/mock/procenv.py b/tests/unit/mock/procenv.py index 06987e3..d7f3dc9 100644 --- a/tests/unit/mock/procenv.py +++ b/tests/unit/mock/procenv.py @@ -19,10 +19,12 @@ # Make coding more python3-ish from __future__ import absolute_import, division, print_function + __metaclass__ = type import json import sys + from contextlib import contextmanager from io import BytesIO, StringIO diff --git a/tests/unit/mock/vault_helper.py b/tests/unit/mock/vault_helper.py index 4c6c890..6006ba9 100644 --- a/tests/unit/mock/vault_helper.py +++ b/tests/unit/mock/vault_helper.py @@ -14,6 +14,7 @@ # Make coding more python3-ish from __future__ import absolute_import, division, print_function + __metaclass__ = type from ansible.module_utils._text import to_bytes diff --git a/tests/unit/mock/yaml_helper.py b/tests/unit/mock/yaml_helper.py index 540055d..2e85759 100644 --- a/tests/unit/mock/yaml_helper.py +++ b/tests/unit/mock/yaml_helper.py @@ -1,9 +1,11 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type import io import yaml + from ansible.module_utils.six import PY3 from ansible.parsing.yaml.dumper import AnsibleDumper from ansible.parsing.yaml.loader import AnsibleLoader @@ -115,10 +117,14 @@ class YamlTestUtils(object): yaml_string_obj_from_string = yaml.dump(obj_from_string, Dumper=AnsibleDumper) else: yaml_string_obj_from_stream = yaml.dump( - obj_from_stream, Dumper=AnsibleDumper, encoding=None + obj_from_stream, + Dumper=AnsibleDumper, + encoding=None, ) yaml_string_obj_from_string = yaml.dump( - obj_from_string, Dumper=AnsibleDumper, encoding=None + obj_from_string, + Dumper=AnsibleDumper, + encoding=None, ) assert yaml_string == yaml_string_obj_from_stream diff --git a/tests/unit/modules/conftest.py b/tests/unit/modules/conftest.py index 013d198..41465c3 100644 --- a/tests/unit/modules/conftest.py +++ b/tests/unit/modules/conftest.py @@ -2,11 +2,13 @@ # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function + __metaclass__ = type import json import pytest + from ansible.module_utils._text import to_bytes from ansible.module_utils.common._collections_compat import MutableMapping from ansible.module_utils.six import string_types diff --git a/tests/unit/modules/network/vyos/test_vyos_banner.py b/tests/unit/modules/network/vyos/test_vyos_banner.py index f054ee0..d418a27 100644 --- a/tests/unit/modules/network/vyos/test_vyos_banner.py +++ b/tests/unit/modules/network/vyos/test_vyos_banner.py @@ -16,6 +16,7 @@ # Make coding more python3-ish from __future__ import absolute_import, division, print_function + __metaclass__ = type from unittest.mock import patch @@ -33,12 +34,12 @@ class TestVyosBannerModule(TestVyosModule): super(TestVyosBannerModule, self).setUp() self.mock_get_config = patch( - "ansible_collections.vyos.vyos.plugins.modules.vyos_banner.get_config" + "ansible_collections.vyos.vyos.plugins.modules.vyos_banner.get_config", ) self.get_config = self.mock_get_config.start() self.mock_load_config = patch( - "ansible_collections.vyos.vyos.plugins.modules.vyos_banner.load_config" + "ansible_collections.vyos.vyos.plugins.modules.vyos_banner.load_config", ) self.load_config = self.mock_load_config.start() diff --git a/tests/unit/modules/network/vyos/test_vyos_bgp_address_family.py b/tests/unit/modules/network/vyos/test_vyos_bgp_address_family.py index 9ef28aa..87b3ad9 100644 --- a/tests/unit/modules/network/vyos/test_vyos_bgp_address_family.py +++ b/tests/unit/modules/network/vyos/test_vyos_bgp_address_family.py @@ -18,6 +18,7 @@ # Make coding more python3-ish from __future__ import absolute_import, division, print_function + __metaclass__ = type from unittest.mock import patch @@ -34,13 +35,13 @@ class TestVyosBgpafModule(TestVyosModule): def setUp(self): super(TestVyosBgpafModule, self).setUp() self.mock_get_resource_connection_config = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module_base.get_resource_connection" + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module_base.get_resource_connection", ) self.get_resource_connection_config = self.mock_get_resource_connection_config.start() self.mock_execute_show_command = patch( "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts." - + "bgp_address_family.bgp_address_family.Bgp_address_familyFacts.get_device_data" + + "bgp_address_family.bgp_address_family.Bgp_address_familyFacts.get_device_data", ) self.execute_show_command = self.mock_execute_show_command.start() @@ -95,12 +96,12 @@ class TestVyosBgpafModule(TestVyosModule): dict( afi="ipv6", attribute_unchanged=dict(next_hop=True), - ) + ), ], ), ], - ) - ) + ), + ), ) self.execute_module(changed=False, commands=[]) @@ -142,12 +143,12 @@ class TestVyosBgpafModule(TestVyosModule): dict(action="export", path_list="list01"), ], capability=dict(orf="send"), - ) + ), ], ), ], - ) - ) + ), + ), ) commands = [ "set protocols bgp 65536 address-family ipv4-unicast aggregate-address 192.0.2.0/24 as-setipv4-unicast aggregate-address 192.0.2.0/24 summary-only", @@ -196,12 +197,12 @@ class TestVyosBgpafModule(TestVyosModule): dict( afi="ipv6", attribute_unchanged=dict(next_hop=True), - ) + ), ], ), ], ), - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -257,12 +258,12 @@ class TestVyosBgpafModule(TestVyosModule): dict(action="export", path_list="list01"), ], capability=dict(orf="send"), - ) + ), ], ), ], ), - ) + ), ) commands = [ "delete protocols bgp 65536 neighbor 203.0.113.5 address-family ipv6-unicast attribute-unchanged", @@ -316,12 +317,12 @@ class TestVyosBgpafModule(TestVyosModule): dict( afi="ipv6", attribute_unchanged=dict(next_hop=True), - ) + ), ], ), ], ), - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -360,7 +361,7 @@ class TestVyosBgpafModule(TestVyosModule): ), ], ), - ) + ), ) commands = [ "delete protocols bgp 65536 neighbor 203.0.113.5 address-family", @@ -400,7 +401,7 @@ class TestVyosBgpafModule(TestVyosModule): ), ], ), - ) + ), ) commands = [ "delete protocols bgp 65536 address-family ipv4-unicast", @@ -445,7 +446,7 @@ class TestVyosBgpafModule(TestVyosModule): ), ], ), - ) + ), ) result = self.execute_module(failed=True) self.assertIn("Only one bgp instance is allowed per device", result["msg"]) @@ -487,12 +488,12 @@ class TestVyosBgpafModule(TestVyosModule): dict( afi="ipv6", attribute_unchanged=dict(next_hop=True), - ) + ), ], ), ], ), - ) + ), ) rendered_cmds = [ @@ -554,7 +555,7 @@ class TestVyosBgpafModule(TestVyosModule): { "afi": "ipv6", "attribute_unchanged": {"next_hop": True}, - } + }, ], }, ], @@ -593,7 +594,7 @@ class TestVyosBgpafModule(TestVyosModule): { "afi": "ipv6", "attribute_unchanged": {"next_hop": True}, - } + }, ], }, ], diff --git a/tests/unit/modules/network/vyos/test_vyos_bgp_global.py b/tests/unit/modules/network/vyos/test_vyos_bgp_global.py index 830fd38..99d17ce 100644 --- a/tests/unit/modules/network/vyos/test_vyos_bgp_global.py +++ b/tests/unit/modules/network/vyos/test_vyos_bgp_global.py @@ -18,6 +18,7 @@ # Make coding more python3-ish from __future__ import absolute_import, division, print_function + __metaclass__ = type from unittest.mock import patch @@ -35,22 +36,22 @@ class TestVyosBgpglobalModule(TestVyosModule): super(TestVyosBgpglobalModule, self).setUp() self.mock_get_resource_connection_config = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module_base.get_resource_connection" + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module_base.get_resource_connection", ) self.get_resource_connection_config = self.mock_get_resource_connection_config.start() self.mock_execute_show_command_config = patch( - "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.config.bgp_global.bgp_global.Bgp_global._get_config" + "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.config.bgp_global.bgp_global.Bgp_global._get_config", ) self.execute_show_command_config = self.mock_execute_show_command_config.start() self.mock_get_resource_connection_facts = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection" + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection", ) self.get_resource_connection_facts = self.mock_get_resource_connection_facts.start() self.mock_execute_show_command = patch( - "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.bgp_global.bgp_global.Bgp_globalFacts.get_device_data" + "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.bgp_global.bgp_global.Bgp_globalFacts.get_device_data", ) self.execute_show_command = self.mock_execute_show_command.start() @@ -117,7 +118,7 @@ class TestVyosBgpglobalModule(TestVyosModule): ], ), state="merged", - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -141,7 +142,7 @@ class TestVyosBgpglobalModule(TestVyosModule): dict(action="export", acl=31), dict(action="import", acl=9), ], - ) + ), ], bgp_params=dict( confederation=[dict(peers=20), dict(identifier=66)], @@ -149,7 +150,7 @@ class TestVyosBgpglobalModule(TestVyosModule): ), ), state="merged", - ) + ), ) commands = [ "set protocols bgp 65536 neighbor 2001:db8::2 distribute-list export 31", @@ -205,7 +206,7 @@ class TestVyosBgpglobalModule(TestVyosModule): ], ), state="replaced", - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -242,7 +243,7 @@ class TestVyosBgpglobalModule(TestVyosModule): ), ), state="replaced", - ) + ), ) commands = [ "delete protocols bgp 65536 parameters default", @@ -308,7 +309,7 @@ class TestVyosBgpglobalModule(TestVyosModule): ), ), state="replaced", - ) + ), ) result = self.execute_module(failed=True) self.assertIn("Only one bgp instance is allowed per device", result["msg"]) @@ -345,7 +346,7 @@ class TestVyosBgpglobalModule(TestVyosModule): ), ), state="replaced", - ) + ), ) result = self.execute_module(failed=True, filename="vyos_bgp_global_af_config.cfg") self.assertIn( @@ -397,7 +398,7 @@ class TestVyosBgpglobalModule(TestVyosModule): ], ), state="rendered", - ) + ), ) rendered_cmds = [ "set protocols bgp 65536 neighbor 10.0.0.4 disable-connected-check", diff --git a/tests/unit/modules/network/vyos/test_vyos_command.py b/tests/unit/modules/network/vyos/test_vyos_command.py index 40db158..2c7cd32 100644 --- a/tests/unit/modules/network/vyos/test_vyos_command.py +++ b/tests/unit/modules/network/vyos/test_vyos_command.py @@ -18,6 +18,7 @@ # Make coding more python3-ish from __future__ import absolute_import, division, print_function + __metaclass__ = type from unittest.mock import patch @@ -34,7 +35,7 @@ class TestVyosCommandModule(TestVyosModule): def setUp(self): super(TestVyosCommandModule, self).setUp() self.mock_run_commands = patch( - "ansible_collections.vyos.vyos.plugins.modules.vyos_command.run_commands" + "ansible_collections.vyos.vyos.plugins.modules.vyos_command.run_commands", ) self.run_commands = self.mock_run_commands.start() diff --git a/tests/unit/modules/network/vyos/test_vyos_config.py b/tests/unit/modules/network/vyos/test_vyos_config.py index 743acab..4f1cac6 100644 --- a/tests/unit/modules/network/vyos/test_vyos_config.py +++ b/tests/unit/modules/network/vyos/test_vyos_config.py @@ -19,6 +19,7 @@ # Make coding more python3-ish from __future__ import absolute_import, division, print_function + __metaclass__ = type from unittest.mock import MagicMock, patch @@ -37,22 +38,22 @@ class TestVyosConfigModule(TestVyosModule): super(TestVyosConfigModule, self).setUp() self.mock_get_config = patch( - "ansible_collections.vyos.vyos.plugins.modules.vyos_config.get_config" + "ansible_collections.vyos.vyos.plugins.modules.vyos_config.get_config", ) self.get_config = self.mock_get_config.start() self.mock_load_config = patch( - "ansible_collections.vyos.vyos.plugins.modules.vyos_config.load_config" + "ansible_collections.vyos.vyos.plugins.modules.vyos_config.load_config", ) self.load_config = self.mock_load_config.start() self.mock_run_commands = patch( - "ansible_collections.vyos.vyos.plugins.modules.vyos_config.run_commands" + "ansible_collections.vyos.vyos.plugins.modules.vyos_config.run_commands", ) self.run_commands = self.mock_run_commands.start() self.mock_get_connection = patch( - "ansible_collections.vyos.vyos.plugins.modules.vyos_config.get_connection" + "ansible_collections.vyos.vyos.plugins.modules.vyos_config.get_connection", ) self.get_connection = self.mock_get_connection.start() @@ -91,7 +92,7 @@ class TestVyosConfigModule(TestVyosModule): "delete interfaces ethernet eth0 address", ] self.conn.get_diff = MagicMock( - return_value=self.cliconf_obj.get_diff(candidate, self.running_config) + return_value=self.cliconf_obj.get_diff(candidate, self.running_config), ) self.execute_module(changed=True, commands=commands) @@ -116,7 +117,7 @@ class TestVyosConfigModule(TestVyosModule): set_module_args(dict(lines=commands)) candidate = "\n".join(commands) self.conn.get_diff = MagicMock( - return_value=self.cliconf_obj.get_diff(candidate, self.running_config) + return_value=self.cliconf_obj.get_diff(candidate, self.running_config), ) self.execute_module(changed=True, commands=commands) @@ -136,6 +137,6 @@ class TestVyosConfigModule(TestVyosModule): set_module_args(dict(lines=lines, match="none")) candidate = "\n".join(lines) self.conn.get_diff = MagicMock( - return_value=self.cliconf_obj.get_diff(candidate, None, diff_match="none") + return_value=self.cliconf_obj.get_diff(candidate, None, diff_match="none"), ) self.execute_module(changed=True, commands=lines, sort=False) diff --git a/tests/unit/modules/network/vyos/test_vyos_facts.py b/tests/unit/modules/network/vyos/test_vyos_facts.py index 691d7cf..dd3a796 100644 --- a/tests/unit/modules/network/vyos/test_vyos_facts.py +++ b/tests/unit/modules/network/vyos/test_vyos_facts.py @@ -17,8 +17,10 @@ # Make coding more python3-ish from __future__ import absolute_import, division, print_function + __metaclass__ = type import json + from unittest.mock import patch from ansible_collections.vyos.vyos.plugins.modules import vyos_facts @@ -33,17 +35,17 @@ class TestVyosFactsModule(TestVyosModule): def setUp(self): super(TestVyosFactsModule, self).setUp() self.mock_run_commands = patch( - "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.legacy.base.run_commands" + "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.legacy.base.run_commands", ) self.run_commands = self.mock_run_commands.start() self.mock_get_resource_connection = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection" + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection", ) self.get_resource_connection = self.mock_get_resource_connection.start() self.mock_get_capabilities = patch( - "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.legacy.base.get_capabilities" + "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.legacy.base.get_capabilities", ) self.get_capabilities = self.mock_get_capabilities.start() self.get_capabilities.return_value = { diff --git a/tests/unit/modules/network/vyos/test_vyos_firewall_global.py b/tests/unit/modules/network/vyos/test_vyos_firewall_global.py index 71b3a18..25c5632 100644 --- a/tests/unit/modules/network/vyos/test_vyos_firewall_global.py +++ b/tests/unit/modules/network/vyos/test_vyos_firewall_global.py @@ -18,6 +18,7 @@ # Make coding more python3-ish from __future__ import absolute_import, division, print_function + __metaclass__ = type from unittest.mock import patch @@ -34,27 +35,27 @@ class TestVyosFirewallRulesModule(TestVyosModule): def setUp(self): super(TestVyosFirewallRulesModule, self).setUp() self.mock_get_config = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config" + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config", ) self.get_config = self.mock_get_config.start() self.mock_load_config = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config" + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config", ) self.load_config = self.mock_load_config.start() self.mock_get_resource_connection_config = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection" + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection", ) self.get_resource_connection_config = self.mock_get_resource_connection_config.start() self.mock_get_resource_connection_facts = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection" + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection", ) self.get_resource_connection_facts = self.mock_get_resource_connection_facts.start() self.mock_execute_show_command = patch( - "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.firewall_global.firewall_global.Firewall_globalFacts.get_device_data" + "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.firewall_global.firewall_global.Firewall_globalFacts.get_device_data", ) self.execute_show_command = self.mock_execute_show_command.start() @@ -96,7 +97,7 @@ class TestVyosFirewallRulesModule(TestVyosModule): afi="ipv4", ip_src_route=True, icmp_redirects=dict(send=True, receive=False), - ) + ), ], group=dict( address_group=[ @@ -141,12 +142,12 @@ class TestVyosFirewallRulesModule(TestVyosModule): name="TELNET", description="This group has the telnet ports", members=[dict(port="23")], - ) + ), ], ), ), state="merged", - ) + ), ) commands = [ "set firewall group address-group MGMT-HOSTS address 192.0.1.1", @@ -228,12 +229,12 @@ class TestVyosFirewallRulesModule(TestVyosModule): name="SSH", description="This group has the ssh ports", members=[dict(port="22")], - ) + ), ], - ) + ), ), state="merged", - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -282,12 +283,12 @@ class TestVyosFirewallRulesModule(TestVyosModule): name="SSH", description="This group has the ssh ports", members=[dict(port="2222")], - ) + ), ], - ) + ), ), state="replaced", - ) + ), ) commands = [ "delete firewall group address-group RND-HOSTS address 192.0.2.3", @@ -346,12 +347,12 @@ class TestVyosFirewallRulesModule(TestVyosModule): name="SSH", description="This group has the ssh ports", members=[dict(port="22")], - ) + ), ], - ) + ), ), state="replaced", - ) + ), ) self.execute_module(changed=False, commands=[]) diff --git a/tests/unit/modules/network/vyos/test_vyos_firewall_interfaces.py b/tests/unit/modules/network/vyos/test_vyos_firewall_interfaces.py index 10d93ca..3034d58 100644 --- a/tests/unit/modules/network/vyos/test_vyos_firewall_interfaces.py +++ b/tests/unit/modules/network/vyos/test_vyos_firewall_interfaces.py @@ -18,6 +18,7 @@ # Make coding more python3-ish from __future__ import absolute_import, division, print_function + __metaclass__ = type from unittest.mock import patch @@ -34,28 +35,28 @@ class TestVyosFirewallInterfacesModule(TestVyosModule): def setUp(self): super(TestVyosFirewallInterfacesModule, self).setUp() self.mock_get_config = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config" + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config", ) self.get_config = self.mock_get_config.start() self.mock_load_config = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config" + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config", ) self.load_config = self.mock_load_config.start() self.mock_get_resource_connection_config = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection" + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection", ) self.get_resource_connection_config = self.mock_get_resource_connection_config.start() self.mock_get_resource_connection_facts = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection" + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection", ) self.get_resource_connection_facts = self.mock_get_resource_connection_facts.start() self.mock_execute_show_command = patch( "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos." - "facts.firewall_interfaces.firewall_interfaces.Firewall_interfacesFacts.get_device_data" + "facts.firewall_interfaces.firewall_interfaces.Firewall_interfacesFacts.get_device_data", ) self.execute_show_command = self.mock_execute_show_command.start() @@ -113,7 +114,7 @@ class TestVyosFirewallInterfacesModule(TestVyosModule): ), ], state="merged", - ) + ), ) commands = [ "set interfaces ethernet eth1 firewall in name 'INBOUND'", @@ -167,7 +168,7 @@ class TestVyosFirewallInterfacesModule(TestVyosModule): ), ], state="merged", - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -178,10 +179,10 @@ class TestVyosFirewallInterfacesModule(TestVyosModule): dict( name="eth0", access_rules=[dict(afi="ipv4"), dict(afi="ipv6")], - ) + ), ], state="deleted", - ) + ), ) commands = [ "delete interfaces ethernet eth0 firewall in name", @@ -259,7 +260,7 @@ class TestVyosFirewallInterfacesModule(TestVyosModule): ), ], state="replaced", - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -308,7 +309,7 @@ class TestVyosFirewallInterfacesModule(TestVyosModule): ), ], state="replaced", - ) + ), ) commands = [ "delete interfaces ethernet eth0 firewall out name", @@ -330,12 +331,12 @@ class TestVyosFirewallInterfacesModule(TestVyosModule): dict( afi="ipv4", rules=[dict(name="INBOUND", direction="in")], - ) + ), ], - ) + ), ], state="overridden", - ) + ), ) commands = [ "delete interfaces ethernet eth0 firewall", @@ -384,6 +385,6 @@ class TestVyosFirewallInterfacesModule(TestVyosModule): ), ], state="overridden", - ) + ), ) self.execute_module(changed=False, commands=[]) diff --git a/tests/unit/modules/network/vyos/test_vyos_firewall_rules.py b/tests/unit/modules/network/vyos/test_vyos_firewall_rules.py index 18da678..b43b11c 100644 --- a/tests/unit/modules/network/vyos/test_vyos_firewall_rules.py +++ b/tests/unit/modules/network/vyos/test_vyos_firewall_rules.py @@ -18,6 +18,7 @@ # Make coding more python3-ish from __future__ import absolute_import, division, print_function + __metaclass__ = type from unittest.mock import patch @@ -34,35 +35,35 @@ class TestVyosFirewallRulesModule(TestVyosModule): def setUp(self): super(TestVyosFirewallRulesModule, self).setUp() self.mock_get_config = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config" + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config", ) self.get_config = self.mock_get_config.start() self.mock_load_config = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config" + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config", ) self.load_config = self.mock_load_config.start() self.mock_get_resource_connection_config = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection" + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection", ) self.get_resource_connection_config = self.mock_get_resource_connection_config.start() self.mock_get_resource_connection_facts = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection" + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection", ) self.get_resource_connection_facts = self.mock_get_resource_connection_facts.start() self.mock_execute_show_command = patch( - "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.static_routes.static_routes.Static_routesFacts.get_device_data" + "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.static_routes.static_routes.Static_routesFacts.get_device_data", ) self.mock_execute_show_command = patch( - "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.firewall_rules.firewall_rules.Firewall_rulesFacts.get_device_data" + "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.firewall_rules.firewall_rules.Firewall_rulesFacts.get_device_data", ) self.execute_show_command = self.mock_execute_show_command.start() self.mock_get_os_version = patch( - "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.config.firewall_rules.firewall_rules.Firewall_rules._get_os_version" + "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.config.firewall_rules.firewall_rules.Firewall_rules._get_os_version", ) self.get_os_version = self.mock_get_os_version.start() self.get_os_version.return_value = "Vyos 1.2" @@ -126,7 +127,7 @@ class TestVyosFirewallRulesModule(TestVyosModule): ), ], state="merged", - ) + ), ) commands = [ "set firewall ipv6-name V6-INBOUND default-action 'reject'", @@ -186,7 +187,7 @@ class TestVyosFirewallRulesModule(TestVyosModule): ), ], state="merged", - ) + ), ) commands = [ "set firewall ipv6-name V6-INBOUND default-action 'reject'", @@ -224,14 +225,14 @@ class TestVyosFirewallRulesModule(TestVyosModule): protocol="icmp", fragment="match-frag", disable=True, - ) + ), ], ), ], - ) + ), ], state="merged", - ) + ), ) commands = [ "set firewall name INBOUND default-action 'accept'", @@ -278,14 +279,14 @@ class TestVyosFirewallRulesModule(TestVyosModule): invalid=True, new=True, ), - ) + ), ], ), ], - ) + ), ], state="merged", - ) + ), ) commands = [ "set firewall name INBOUND rule 101 protocol 'tcp'", @@ -323,23 +324,23 @@ class TestVyosFirewallRulesModule(TestVyosModule): address_group="OUT-ADDR-GROUP", network_group="OUT-NET-GROUP", port_group="OUT-PORT-GROUP", - ) + ), ), source=dict( group=dict( address_group="IN-ADDR-GROUP", network_group="IN-NET-GROUP", port_group="IN-PORT-GROUP", - ) + ), ), - ) + ), ], ), ], - ) + ), ], state="merged", - ) + ), ) commands = [ "set firewall name INBOUND rule 101 source group address-group IN-ADDR-GROUP", @@ -374,14 +375,14 @@ class TestVyosFirewallRulesModule(TestVyosModule): utc=True, ), tcp=dict(flags="ALL"), - ) + ), ], ), ], - ) + ), ], state="merged", - ) + ), ) commands = [ "set firewall name INBOUND rule 101", @@ -417,14 +418,14 @@ class TestVyosFirewallRulesModule(TestVyosModule): protocol="icmp", disabled=True, icmp=dict(type_name="echo-request"), - ) + ), ], ), ], - ) + ), ], state="merged", - ) + ), ) commands = [ "set firewall ipv6-name INBOUND default-action 'accept'", @@ -470,14 +471,14 @@ class TestVyosFirewallRulesModule(TestVyosModule): invalid=True, new=True, ), - ) + ), ], ), ], - ) + ), ], state="merged", - ) + ), ) commands = [ "set firewall ipv6-name INBOUND rule 101 protocol 'tcp'", @@ -515,23 +516,23 @@ class TestVyosFirewallRulesModule(TestVyosModule): address_group="OUT-ADDR-GROUP", network_group="OUT-NET-GROUP", port_group="OUT-PORT-GROUP", - ) + ), ), source=dict( group=dict( address_group="IN-ADDR-GROUP", network_group="IN-NET-GROUP", port_group="IN-PORT-GROUP", - ) + ), ), - ) + ), ], ), ], - ) + ), ], state="merged", - ) + ), ) commands = [ "set firewall ipv6-name INBOUND rule 101 source group address-group IN-ADDR-GROUP", @@ -566,14 +567,14 @@ class TestVyosFirewallRulesModule(TestVyosModule): utc=True, ), tcp=dict(flags="ALL"), - ) + ), ], ), ], - ) + ), ], state="merged", - ) + ), ) commands = [ "set firewall ipv6-name INBOUND rule 101", @@ -602,14 +603,14 @@ class TestVyosFirewallRulesModule(TestVyosModule): number="101", protocol="icmp", icmp=dict(type_name="port-unreachable"), - ) + ), ], ), ], - ) + ), ], state="merged", - ) + ), ) commands = [ "set firewall ipv6-name INBOUND rule 101 icmpv6 type port-unreachable", @@ -632,14 +633,14 @@ class TestVyosFirewallRulesModule(TestVyosModule): number="101", protocol="icmp", icmp=dict(type=1, code=1), - ) + ), ], ), ], - ) + ), ], state="merged", - ) + ), ) commands = [ "set firewall name INBOUND rule 101 icmp type 1", @@ -663,14 +664,14 @@ class TestVyosFirewallRulesModule(TestVyosModule): number="101", protocol="icmp", icmp=dict(type_name="echo-request"), - ) + ), ], ), ], - ) + ), ], state="merged", - ) + ), ) commands = [ "set firewall name INBOUND rule 101 icmp type-name echo-request", @@ -684,7 +685,7 @@ class TestVyosFirewallRulesModule(TestVyosModule): dict( config=[dict(afi="ipv4", rule_sets=[dict(name="V4-INGRESS")])], state="deleted", - ) + ), ) commands = ["delete firewall name V4-INGRESS"] self.execute_module(changed=True, commands=commands) @@ -697,7 +698,7 @@ class TestVyosFirewallRulesModule(TestVyosModule): dict(afi="ipv6", rule_sets=[dict(name="V6-INGRESS")]), ], state="deleted", - ) + ), ) commands = [ "delete firewall name V4-INGRESS", @@ -718,7 +719,7 @@ class TestVyosFirewallRulesModule(TestVyosModule): dict(afi="ipv6", rule_sets=[dict(name="V6-ING")]), ], state="deleted", - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -771,14 +772,14 @@ class TestVyosFirewallRulesModule(TestVyosModule): dict( icmp=dict(type_name="echo-request"), number=20, - ) + ), ], ), ], ), ], state="replaced", - ) + ), ) commands = [ "delete firewall name V4-INGRESS rule 101 disable", @@ -836,14 +837,14 @@ class TestVyosFirewallRulesModule(TestVyosModule): dict( icmp=dict(type_name="echo-request"), number=20, - ) + ), ], ), ], ), ], state="replaced", - ) + ), ) commands = [ "delete firewall name V4-INGRESS enable-default-log", @@ -871,7 +872,7 @@ class TestVyosFirewallRulesModule(TestVyosModule): protocol="icmp", fragment="match-frag", disabled=True, - ) + ), ], ), dict( @@ -894,14 +895,14 @@ class TestVyosFirewallRulesModule(TestVyosModule): dict( icmp=dict(type_name="echo-request"), number=20, - ) + ), ], ), ], ), ], state="replaced", - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -933,7 +934,7 @@ class TestVyosFirewallRulesModule(TestVyosModule): ), ], state="replaced", - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -958,7 +959,7 @@ class TestVyosFirewallRulesModule(TestVyosModule): protocol="icmp", fragment="match-frag", disabled=True, - ) + ), ], ), dict( @@ -981,14 +982,14 @@ class TestVyosFirewallRulesModule(TestVyosModule): dict( icmp=dict(type_name="echo-request"), number=20, - ) + ), ], ), ], ), ], state="merged", - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -1019,7 +1020,7 @@ class TestVyosFirewallRulesModule(TestVyosModule): address_group="IN-ADDR-GROUP", network_group="IN-NET-GROUP", port_group="IN-PORT-GROUP", - ) + ), ), ), dict( @@ -1050,7 +1051,7 @@ class TestVyosFirewallRulesModule(TestVyosModule): ), ], state="overridden", - ) + ), ) commands = [ "delete firewall ipv6-name V6-INGRESS", @@ -1103,7 +1104,7 @@ class TestVyosFirewallRulesModule(TestVyosModule): protocol="icmp", fragment="match-frag", disabled=True, - ) + ), ], ), dict( @@ -1126,14 +1127,14 @@ class TestVyosFirewallRulesModule(TestVyosModule): dict( icmp=dict(type_name="echo-request"), number=20, - ) + ), ], ), ], ), ], state="overridden", - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -1159,14 +1160,14 @@ class TestVyosFirewallRulesModule(TestVyosModule): protocol="icmp", disabled=True, icmp=dict(type_name="echo-request"), - ) + ), ], ), ], - ) + ), ], state="merged", - ) + ), ) commands = [ "set firewall ipv6-name INBOUND default-action 'accept'", diff --git a/tests/unit/modules/network/vyos/test_vyos_hostname.py b/tests/unit/modules/network/vyos/test_vyos_hostname.py index c7edc26..a056f6b 100644 --- a/tests/unit/modules/network/vyos/test_vyos_hostname.py +++ b/tests/unit/modules/network/vyos/test_vyos_hostname.py @@ -18,6 +18,7 @@ # Make coding more python3-ish from __future__ import absolute_import, division, print_function + __metaclass__ = type from unittest.mock import patch @@ -35,17 +36,17 @@ class TestVyosHostnameModule(TestVyosModule): super(TestVyosHostnameModule, self).setUp() self.mock_get_resource_connection_config = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module_base.get_resource_connection" + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module_base.get_resource_connection", ) self.get_resource_connection_config = self.mock_get_resource_connection_config.start() self.mock_get_resource_connection_facts = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection" + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection", ) self.get_resource_connection_facts = self.mock_get_resource_connection_facts.start() self.mock_execute_show_command = patch( - "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.hostname.hostname.HostnameFacts.get_config" + "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.hostname.hostname.HostnameFacts.get_config", ) self.execute_show_command = self.mock_execute_show_command.start() diff --git a/tests/unit/modules/network/vyos/test_vyos_interfaces.py b/tests/unit/modules/network/vyos/test_vyos_interfaces.py index 06bbefa..affb4f8 100644 --- a/tests/unit/modules/network/vyos/test_vyos_interfaces.py +++ b/tests/unit/modules/network/vyos/test_vyos_interfaces.py @@ -18,6 +18,7 @@ # Make coding more python3-ish from __future__ import absolute_import, division, print_function + __metaclass__ = type from unittest.mock import patch @@ -34,28 +35,28 @@ class TestVyosFirewallInterfacesModule(TestVyosModule): def setUp(self): super(TestVyosFirewallInterfacesModule, self).setUp() self.mock_get_config = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config" + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config", ) self.get_config = self.mock_get_config.start() self.mock_load_config = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config" + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config", ) self.load_config = self.mock_load_config.start() self.mock_get_resource_connection_config = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection" + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection", ) self.get_resource_connection_config = self.mock_get_resource_connection_config.start() self.mock_get_resource_connection_facts = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection" + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection", ) self.get_resource_connection_facts = self.mock_get_resource_connection_facts.start() self.mock_execute_show_command = patch( "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos." - "facts.interfaces.interfaces.InterfacesFacts.get_device_data" + "facts.interfaces.interfaces.InterfacesFacts.get_device_data", ) self.execute_show_command = self.mock_execute_show_command.start() @@ -82,7 +83,7 @@ class TestVyosFirewallInterfacesModule(TestVyosModule): dict(name="wg01", description="wg - 1", enabled=True), ], state="merged", - ) + ), ) commands = [ @@ -103,7 +104,7 @@ class TestVyosFirewallInterfacesModule(TestVyosModule): ), ], state="merged", - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -122,7 +123,7 @@ class TestVyosFirewallInterfacesModule(TestVyosModule): dict(name="eth1", description="Configured by Ansible"), ], state="merged", - ) + ), ) commands = [ @@ -147,7 +148,7 @@ class TestVyosFirewallInterfacesModule(TestVyosModule): dict(name="eth1", description="Configured by Ansible"), ], state="replaced", - ) + ), ) commands = [ @@ -172,7 +173,7 @@ class TestVyosFirewallInterfacesModule(TestVyosModule): dict(name="eth1", description="Configured by Ansible"), ], state="overridden", - ) + ), ) commands = [ diff --git a/tests/unit/modules/network/vyos/test_vyos_logging_global.py b/tests/unit/modules/network/vyos/test_vyos_logging_global.py index 209844e..872769e 100644 --- a/tests/unit/modules/network/vyos/test_vyos_logging_global.py +++ b/tests/unit/modules/network/vyos/test_vyos_logging_global.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type from textwrap import dedent @@ -23,17 +24,17 @@ class TestVyosLoggingGlobalModule(TestVyosModule): super(TestVyosLoggingGlobalModule, self).setUp() self.mock_get_resource_connection_config = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module_base.get_resource_connection" + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module_base.get_resource_connection", ) self.get_resource_connection_config = self.mock_get_resource_connection_config.start() self.mock_get_resource_connection_facts = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection" + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection", ) self.get_resource_connection_facts = self.mock_get_resource_connection_facts.start() self.mock_execute_show_command = patch( - "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.logging_global.logging_global.Logging_globalFacts.get_logging_data" + "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.logging_global.logging_global.Logging_globalFacts.get_logging_data", ) self.execute_show_command = self.mock_execute_show_command.start() @@ -68,7 +69,7 @@ class TestVyosLoggingGlobalModule(TestVyosModule): set system syslog user paul facility local7 level 'err' set system syslog user vyos facility local6 level 'alert' set system syslog user vyos facility local7 level 'debug' - """ + """, ) playbook = dict( config=dict( @@ -77,7 +78,7 @@ class TestVyosLoggingGlobalModule(TestVyosModule): dict(facility="all"), dict(facility="local7", severity="err"), dict(facility="news", severity="debug"), - ] + ], ), files=[ dict(path="xyz"), @@ -127,7 +128,7 @@ class TestVyosLoggingGlobalModule(TestVyosModule): dict(facility="local7", severity="debug"), ], ), - ) + ), ) compare_cmds = [] playbook["state"] = "merged" @@ -140,7 +141,7 @@ class TestVyosLoggingGlobalModule(TestVyosModule): def test_vyos_logging_global_merged(self): self.execute_show_command.return_value = dedent( """\ - """ + """, ) playbook = dict( config=dict( @@ -149,7 +150,7 @@ class TestVyosLoggingGlobalModule(TestVyosModule): dict(facility="all"), dict(facility="local7", severity="err"), dict(facility="news", severity="debug"), - ] + ], ), files=[ dict(path="xyz"), @@ -199,7 +200,7 @@ class TestVyosLoggingGlobalModule(TestVyosModule): dict(facility="local7", severity="debug"), ], ), - ) + ), ) compare_cmds = [ "set system syslog user paul facility local7 level err", @@ -254,7 +255,7 @@ class TestVyosLoggingGlobalModule(TestVyosModule): set system syslog user paul facility local7 level 'err' set system syslog user vyos facility local6 level 'alert' set system syslog user vyos facility local7 level 'debug' - """ + """, ) playbook = dict(config=dict()) compare_cmds = ["delete system syslog"] @@ -291,7 +292,7 @@ class TestVyosLoggingGlobalModule(TestVyosModule): set system syslog user paul facility local7 level 'err' set system syslog user vyos facility local6 level 'alert' set system syslog user vyos facility local7 level 'debug' - """ + """, ) playbook = dict( config=dict( @@ -304,9 +305,9 @@ class TestVyosLoggingGlobalModule(TestVyosModule): dict(facility="local6", severity="err"), dict(facility="local7", severity="emerg"), ], - ) + ), ], - ) + ), ) compare_cmds = [ "delete system syslog console facility all", @@ -344,7 +345,7 @@ class TestVyosLoggingGlobalModule(TestVyosModule): self.execute_show_command.return_value = dedent( """\ set system syslog console facility local6 - """ + """, ) playbook = dict(config=dict(console=dict(facilities=[dict(facility="local6")]))) compare_cmds = [] @@ -359,7 +360,7 @@ class TestVyosLoggingGlobalModule(TestVyosModule): """\ set system syslog console set system syslog global - """ + """, ) playbook = dict( config=dict( @@ -372,9 +373,9 @@ class TestVyosLoggingGlobalModule(TestVyosModule): dict(facility="local6", severity="err"), dict(facility="local7", severity="emerg"), ], - ) + ), ], - ) + ), ) compare_cmds = [ "set system syslog console facility local7 level emerg", @@ -397,13 +398,13 @@ class TestVyosLoggingGlobalModule(TestVyosModule): dict( hostname="10.0.2.16", facilities=[dict(facility="local6")], - ) + ), ], users=[ dict(username="vyos"), dict(username="paul", facilities=[dict(facility="local7")]), ], - ) + ), ) compare_cmds = [ "set system syslog console facility all", @@ -424,10 +425,10 @@ class TestVyosLoggingGlobalModule(TestVyosModule): """\ set system syslog console facility all set system syslog file xyz - """ + """, ), state="parsed", - ) + ), ) parsed = dict( console=dict(facilities=[dict(facility="all")]), @@ -441,7 +442,7 @@ class TestVyosLoggingGlobalModule(TestVyosModule): self.execute_show_command.return_value = dedent( """\ set system syslog console facility all - """ + """, ) set_module_args(dict(state="gathered")) gathered = dict(console=dict(facilities=[dict(facility="all")])) diff --git a/tests/unit/modules/network/vyos/test_vyos_ntp_global.py b/tests/unit/modules/network/vyos/test_vyos_ntp_global.py index 37c851d..6609c2f 100644 --- a/tests/unit/modules/network/vyos/test_vyos_ntp_global.py +++ b/tests/unit/modules/network/vyos/test_vyos_ntp_global.py @@ -18,6 +18,7 @@ # Make coding more python3-ish from __future__ import absolute_import, division, print_function + __metaclass__ = type from unittest.mock import patch @@ -35,17 +36,17 @@ class TestVyosNTPModule(TestVyosModule): super(TestVyosNTPModule, self).setUp() self.mock_get_resource_connection_config = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module_base.get_resource_connection" + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module_base.get_resource_connection", ) self.get_resource_connection_config = self.mock_get_resource_connection_config.start() self.mock_get_resource_connection_facts = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection" + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection", ) self.get_resource_connection_facts = self.mock_get_resource_connection_facts.start() self.mock_execute_show_command = patch( - "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.ntp_global.ntp_global.Ntp_globalFacts.get_config" + "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.ntp_global.ntp_global.Ntp_globalFacts.get_config", ) self.execute_show_command = self.mock_execute_show_command.start() @@ -81,7 +82,7 @@ class TestVyosNTPModule(TestVyosModule): ], ), state="merged", - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -105,7 +106,7 @@ class TestVyosNTPModule(TestVyosModule): ], ), state="merged", - ) + ), ) commands = [ @@ -146,7 +147,7 @@ class TestVyosNTPModule(TestVyosModule): ], ), state="replaced", - ) + ), ) commands = [ "delete system ntp allow-clients address 10.1.1.0/24", @@ -183,7 +184,7 @@ class TestVyosNTPModule(TestVyosModule): ], ), state="replaced", - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -202,7 +203,7 @@ class TestVyosNTPModule(TestVyosModule): ], ), state="overridden", - ) + ), ) commands = [ "delete system ntp allow-clients address 10.1.1.0/24", @@ -234,7 +235,7 @@ class TestVyosNTPModule(TestVyosModule): ], ), state="overridden", - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -253,7 +254,7 @@ class TestVyosNTPModule(TestVyosModule): ], ), state="rendered", - ) + ), ) rendered_commands = [ "set system ntp allow-clients address 10.7.7.0/24", @@ -334,7 +335,7 @@ class TestVyosNTPModule(TestVyosModule): ], ), state="deleted", - ) + ), ) commands = [ "delete system ntp allow-clients", diff --git a/tests/unit/modules/network/vyos/test_vyos_ospf_interfaces.py b/tests/unit/modules/network/vyos/test_vyos_ospf_interfaces.py index 248b98e..1d12a3c 100644 --- a/tests/unit/modules/network/vyos/test_vyos_ospf_interfaces.py +++ b/tests/unit/modules/network/vyos/test_vyos_ospf_interfaces.py @@ -18,6 +18,7 @@ # Make coding more python3-ish from __future__ import absolute_import, division, print_function + __metaclass__ = type from unittest.mock import patch @@ -34,12 +35,12 @@ class TestVyosOspfInterfacesModule(TestVyosModule): def setUp(self): super(TestVyosOspfInterfacesModule, self).setUp() self.mock_get_resource_connection_config = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module_base.get_resource_connection" + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module_base.get_resource_connection", ) self.get_resource_connection_config = self.mock_get_resource_connection_config.start() self.mock_execute_show_command = patch( - "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.ospf_interfaces.ospf_interfaces.Ospf_interfacesFacts.get_device_data" + "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.ospf_interfaces.ospf_interfaces.Ospf_interfacesFacts.get_device_data", ) self.execute_show_command = self.mock_execute_show_command.start() @@ -91,7 +92,7 @@ class TestVyosOspfInterfacesModule(TestVyosModule): ), ], state="merged", - ) + ), ) commands = [ "set interfaces bonding bond2 ip ospf transmit-delay 9", @@ -124,7 +125,7 @@ class TestVyosOspfInterfacesModule(TestVyosModule): ], ), ], - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -149,7 +150,7 @@ class TestVyosOspfInterfacesModule(TestVyosModule): ], ), ], - ) + ), ) commands = [ "set interfaces ethernet eth0 ipv6 ospfv3 cost 500", @@ -185,7 +186,7 @@ class TestVyosOspfInterfacesModule(TestVyosModule): ), ], state="replaced", - ) + ), ) commands = [ "set interfaces bonding bond2 ip ospf transmit-delay 9", @@ -220,7 +221,7 @@ class TestVyosOspfInterfacesModule(TestVyosModule): ), ], state="replaced", - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -251,7 +252,7 @@ class TestVyosOspfInterfacesModule(TestVyosModule): ), ], state="overridden", - ) + ), ) commands = [ "set interfaces bonding bond2 ip ospf transmit-delay 9", @@ -288,7 +289,7 @@ class TestVyosOspfInterfacesModule(TestVyosModule): ), ], state="overridden", - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -301,7 +302,7 @@ class TestVyosOspfInterfacesModule(TestVyosModule): ), ], state="deleted", - ) + ), ) commands = ["delete interfaces ethernet eth0 ipv6 ospfv3"] self.execute_module(changed=True, commands=commands) @@ -315,7 +316,7 @@ class TestVyosOspfInterfacesModule(TestVyosModule): ), ], state="deleted", - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -347,7 +348,7 @@ class TestVyosOspfInterfacesModule(TestVyosModule): ), ], state="rendered", - ) + ), ) commands = [ "set interfaces ethernet eth0 ip ospf cost 100", @@ -389,7 +390,7 @@ class TestVyosOspfInterfacesModule(TestVyosModule): "md5_key": { "key": "1111111111232345", "key_id": 10, - } + }, }, "bandwidth": 70, "transmit_delay": 45, diff --git a/tests/unit/modules/network/vyos/test_vyos_ospfv2.py b/tests/unit/modules/network/vyos/test_vyos_ospfv2.py index d2ddb40..ec4018e 100644 --- a/tests/unit/modules/network/vyos/test_vyos_ospfv2.py +++ b/tests/unit/modules/network/vyos/test_vyos_ospfv2.py @@ -18,6 +18,7 @@ # Make coding more python3-ish from __future__ import absolute_import, division, print_function + __metaclass__ = type from unittest.mock import patch @@ -34,27 +35,27 @@ class TestVyosOspfv2Module(TestVyosModule): def setUp(self): super(TestVyosOspfv2Module, self).setUp() self.mock_get_config = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config" + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config", ) self.get_config = self.mock_get_config.start() self.mock_load_config = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config" + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config", ) self.load_config = self.mock_load_config.start() self.mock_get_resource_connection_config = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection" + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection", ) self.get_resource_connection_config = self.mock_get_resource_connection_config.start() self.mock_get_resource_connection_facts = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection" + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection", ) self.get_resource_connection_facts = self.mock_get_resource_connection_facts.start() self.mock_execute_show_command = patch( - "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.ospfv2.ospfv2.Ospfv2Facts.get_device_data" + "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.ospfv2.ospfv2.Ospfv2Facts.get_device_data", ) self.execute_show_command = self.mock_execute_show_command.start() @@ -103,7 +104,7 @@ class TestVyosOspfv2Module(TestVyosModule): ], ), state="merged", - ) + ), ) commands = [ "set protocols ospf mpls-te enable", @@ -147,7 +148,7 @@ class TestVyosOspfv2Module(TestVyosModule): ], ), state="merged", - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -177,7 +178,7 @@ class TestVyosOspfv2Module(TestVyosModule): ], ), state="merged", - ) + ), ) commands = [ "delete protocols ospf area 14 area-type stub", @@ -212,7 +213,7 @@ class TestVyosOspfv2Module(TestVyosModule): ], ), state="replaced", - ) + ), ) commands = [ "set protocols ospf mpls-te enable", @@ -255,7 +256,7 @@ class TestVyosOspfv2Module(TestVyosModule): ], ), state="replaced", - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -346,7 +347,7 @@ set protocols ospf redistribute bgp metric-type '2'""" "metric": 10, "metric_type": 2, "route_map": "ingress", - } + }, }, "log_adjacency_changes": "detail", "max_metric": { @@ -354,7 +355,7 @@ set protocols ospf redistribute bgp metric-type '2'""" "administrative": True, "on_shutdown": 10, "on_startup": 10, - } + }, }, "mpls_te": {"enabled": True, "router_address": "192.0.11.11"}, "neighbor": [ @@ -362,7 +363,7 @@ set protocols ospf redistribute bgp metric-type '2'""" "neighbor_id": "192.0.11.12", "poll_interval": 10, "priority": 2, - } + }, ], "parameters": { "abr_type": "cisco", @@ -401,7 +402,7 @@ set protocols ospf redistribute bgp metric-type '2'""" ], ), state="rendered", - ) + ), ) commands = [ "set protocols ospf mpls-te enable", diff --git a/tests/unit/modules/network/vyos/test_vyos_ospfv3.py b/tests/unit/modules/network/vyos/test_vyos_ospfv3.py index 0002451..1cf0260 100644 --- a/tests/unit/modules/network/vyos/test_vyos_ospfv3.py +++ b/tests/unit/modules/network/vyos/test_vyos_ospfv3.py @@ -18,6 +18,7 @@ # Make coding more python3-ish from __future__ import absolute_import, division, print_function + __metaclass__ = type from unittest.mock import patch @@ -34,27 +35,27 @@ class TestVyosOspfv3Module(TestVyosModule): def setUp(self): super(TestVyosOspfv3Module, self).setUp() self.mock_get_config = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config" + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config", ) self.get_config = self.mock_get_config.start() self.mock_load_config = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config" + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config", ) self.load_config = self.mock_load_config.start() self.mock_get_resource_connection_config = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection" + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection", ) self.get_resource_connection_config = self.mock_get_resource_connection_config.start() self.mock_get_resource_connection_facts = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection" + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection", ) self.get_resource_connection_facts = self.mock_get_resource_connection_facts.start() self.mock_execute_show_command = patch( - "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.ospfv3.ospfv3.Ospfv3Facts.get_device_data" + "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.ospfv3.ospfv3.Ospfv3Facts.get_device_data", ) self.execute_show_command = self.mock_execute_show_command.start() @@ -101,7 +102,7 @@ class TestVyosOspfv3Module(TestVyosModule): ], ), state="merged", - ) + ), ) commands = [ "set protocols ospfv3 redistribute bgp", @@ -139,7 +140,7 @@ class TestVyosOspfv3Module(TestVyosModule): ], ), state="merged", - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -170,7 +171,7 @@ class TestVyosOspfv3Module(TestVyosModule): ], ), state="merged", - ) + ), ) commands = [ "set protocols ospfv3 redistribute bgp", @@ -203,7 +204,7 @@ class TestVyosOspfv3Module(TestVyosModule): ], ), state="replaced", - ) + ), ) commands = [ "set protocols ospfv3 redistribute bgp", @@ -238,7 +239,7 @@ class TestVyosOspfv3Module(TestVyosModule): ], ), state="replaced", - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -321,7 +322,7 @@ set protocols ospfv3 redistribute 'bgp'""" ], ), state="rendered", - ) + ), ) commands = [ "set protocols ospfv3 redistribute bgp", diff --git a/tests/unit/modules/network/vyos/test_vyos_ping.py b/tests/unit/modules/network/vyos/test_vyos_ping.py index 25bb6cf..2821696 100644 --- a/tests/unit/modules/network/vyos/test_vyos_ping.py +++ b/tests/unit/modules/network/vyos/test_vyos_ping.py @@ -18,6 +18,7 @@ # Make coding more python3-ish from __future__ import absolute_import, division, print_function + __metaclass__ = type from unittest.mock import patch @@ -34,7 +35,7 @@ class TestVyosPingModule(TestVyosModule): def setUp(self): super(TestVyosPingModule, self).setUp() self.mock_run_commands = patch( - "ansible_collections.vyos.vyos.plugins.modules.vyos_ping.run_commands" + "ansible_collections.vyos.vyos.plugins.modules.vyos_ping.run_commands", ) self.run_commands = self.mock_run_commands.start() diff --git a/tests/unit/modules/network/vyos/test_vyos_prefix_lists.py b/tests/unit/modules/network/vyos/test_vyos_prefix_lists.py index 5c488ec..3da58f7 100644 --- a/tests/unit/modules/network/vyos/test_vyos_prefix_lists.py +++ b/tests/unit/modules/network/vyos/test_vyos_prefix_lists.py @@ -18,6 +18,7 @@ # Make coding more python3-ish from __future__ import absolute_import, division, print_function + __metaclass__ = type from textwrap import dedent @@ -47,12 +48,12 @@ class TestVyosPrefixListsModule(TestVyosModule): super(TestVyosPrefixListsModule, self).setUp() self.mock_get_resource_connection = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module_base.get_resource_connection" + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module_base.get_resource_connection", ) self.get_resource_connection = self.mock_get_resource_connection.start() self.mock_get_config = patch( - "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.prefix_lists.prefix_lists.Prefix_listsFacts.get_config" + "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.prefix_lists.prefix_lists.Prefix_listsFacts.get_config", ) self.get_config = self.mock_get_config.start() @@ -65,7 +66,7 @@ class TestVyosPrefixListsModule(TestVyosModule): def test_vyos_prefix_lists_linear_merged(self): self.get_config.return_value = dedent( """\ - """ + """, ) set_module_args( dict( @@ -151,7 +152,7 @@ class TestVyosPrefixListsModule(TestVyosModule): ), ], state="merged", - ) + ), ) commands = [ "set policy prefix-list plist1", @@ -236,7 +237,7 @@ class TestVyosPrefixListsModule(TestVyosModule): set policy prefix-list6 plist4 rule 50 set policy prefix-list6 plist4 rule 50 action 'deny' set policy prefix-list6 plist4 rule 50 prefix '2001:db8:4000::/36' - """ + """, ) set_module_args( dict( @@ -322,7 +323,7 @@ class TestVyosPrefixListsModule(TestVyosModule): ), ], state="merged", - ) + ), ) result = self.execute_module(changed=False) self.assertEqual(result["commands"], []) @@ -368,7 +369,7 @@ class TestVyosPrefixListsModule(TestVyosModule): set policy prefix-list6 plist4 rule 50 set policy prefix-list6 plist4 rule 50 action 'deny' set policy prefix-list6 plist4 rule 50 prefix '2001:db8:4000::/36' - """ + """, ) set_module_args( dict( @@ -392,12 +393,12 @@ class TestVyosPrefixListsModule(TestVyosModule): prefix="72.168.2.0/24", ), ], - ) + ), ], - ) + ), ], state="replaced", - ) + ), ) commands = [ "delete policy prefix-list plist1 rule 10 description 'Test rule 10'", @@ -447,7 +448,7 @@ class TestVyosPrefixListsModule(TestVyosModule): set policy prefix-list6 plist4 rule 50 set policy prefix-list6 plist4 rule 50 action 'deny' set policy prefix-list6 plist4 rule 50 prefix '2001:db8:4000::/36' - """ + """, ) set_module_args( dict( @@ -462,14 +463,14 @@ class TestVyosPrefixListsModule(TestVyosModule): sequence=10, action="permit", prefix="82.168.10.0/26", - ) + ), ], - ) + ), ], - ) + ), ], state="replaced", - ) + ), ) commands = [ "delete policy prefix-list plist1 description 'Test plist1'", @@ -521,7 +522,7 @@ class TestVyosPrefixListsModule(TestVyosModule): set policy prefix-list6 plist4 rule 50 set policy prefix-list6 plist4 rule 50 action 'deny' set policy prefix-list6 plist4 rule 50 prefix '2001:db8:4000::/36' - """ + """, ) set_module_args( dict( @@ -536,14 +537,14 @@ class TestVyosPrefixListsModule(TestVyosModule): sequence=10, action="deny", prefix="102.168.10.0/26", - ) + ), ], - ) + ), ], - ) + ), ], state="overridden", - ) + ), ) commands = [ "delete policy prefix-list plist1 description 'Test plist1'", @@ -599,7 +600,7 @@ class TestVyosPrefixListsModule(TestVyosModule): set policy prefix-list6 plist4 rule 50 set policy prefix-list6 plist4 rule 50 action 'deny' set policy prefix-list6 plist4 rule 50 prefix '2001:db8:4000::/36' - """ + """, ) set_module_args( dict( @@ -614,14 +615,14 @@ class TestVyosPrefixListsModule(TestVyosModule): sequence=50, action="permit", prefix="102.168.10.0/26", - ) + ), ], - ) + ), ], - ) + ), ], state="overridden", - ) + ), ) commands = [ "set policy prefix-list plist5", @@ -677,7 +678,7 @@ class TestVyosPrefixListsModule(TestVyosModule): set policy prefix-list6 plist4 rule 50 set policy prefix-list6 plist4 rule 50 action 'deny' set policy prefix-list6 plist4 rule 50 prefix '2001:db8:4000::/36' - """ + """, ) set_module_args(dict(state="deleted")) commands = [ @@ -730,7 +731,7 @@ class TestVyosPrefixListsModule(TestVyosModule): set policy prefix-list6 plist4 rule 50 set policy prefix-list6 plist4 rule 50 action 'deny' set policy prefix-list6 plist4 rule 50 prefix '2001:db8:4000::/36' - """ + """, ) set_module_args(dict(config=[dict(afi="ipv4")], state="deleted")) commands = [ @@ -781,13 +782,13 @@ class TestVyosPrefixListsModule(TestVyosModule): set policy prefix-list6 plist4 rule 50 set policy prefix-list6 plist4 rule 50 action 'deny' set policy prefix-list6 plist4 rule 50 prefix '2001:db8:4000::/36' - """ + """, ) set_module_args( dict( config=[dict(afi="ipv6", prefix_lists=[dict(name="plist3")])], state="deleted", - ) + ), ) commands = ["delete policy prefix-list6 plist3"] result = self.execute_module(changed=True) @@ -834,7 +835,7 @@ class TestVyosPrefixListsModule(TestVyosModule): set policy prefix-list6 plist4 rule 50 set policy prefix-list6 plist4 rule 50 action 'deny' set policy prefix-list6 plist4 rule 50 prefix '2001:db8:4000::/36' - """ + """, ) set_module_args( dict( @@ -843,7 +844,7 @@ class TestVyosPrefixListsModule(TestVyosModule): dict(afi="ipv6", prefix_lists=[dict(name="plist3")]), ], state="deleted", - ) + ), ) commands = [ "delete policy prefix-list plist2", @@ -893,7 +894,7 @@ class TestVyosPrefixListsModule(TestVyosModule): set policy prefix-list6 plist4 rule 50 set policy prefix-list6 plist4 rule 50 action 'deny' set policy prefix-list6 plist4 rule 50 prefix '2001:db8:4000::/36' - """ + """, ) set_module_args(dict(running_config=cfg, state="parsed")) parsed = [ @@ -1066,7 +1067,7 @@ class TestVyosPrefixListsModule(TestVyosModule): ), ], state="rendered", - ) + ), ) rendered = [ "set policy prefix-list plist1", @@ -1151,7 +1152,7 @@ class TestVyosPrefixListsModule(TestVyosModule): set policy prefix-list6 plist4 rule 50 set policy prefix-list6 plist4 rule 50 action 'deny' set policy prefix-list6 plist4 rule 50 prefix '2001:db8:4000::/36' - """ + """, ) set_module_args(dict(state="gathered")) gathered = [ diff --git a/tests/unit/modules/network/vyos/test_vyos_route_maps.py b/tests/unit/modules/network/vyos/test_vyos_route_maps.py index adac6c3..ce13dcf 100644 --- a/tests/unit/modules/network/vyos/test_vyos_route_maps.py +++ b/tests/unit/modules/network/vyos/test_vyos_route_maps.py @@ -18,6 +18,7 @@ # Make coding more python3-ish from __future__ import absolute_import, division, print_function + __metaclass__ = type from unittest.mock import patch @@ -35,17 +36,17 @@ class TestVyosRouteMapsModule(TestVyosModule): super(TestVyosRouteMapsModule, self).setUp() self.mock_get_resource_connection_config = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module_base.get_resource_connection" + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module_base.get_resource_connection", ) self.get_resource_connection_config = self.mock_get_resource_connection_config.start() self.mock_get_resource_connection_facts = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection" + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection", ) self.get_resource_connection_facts = self.mock_get_resource_connection_facts.start() self.mock_execute_show_command = patch( - "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.route_maps.route_maps.Route_mapsFacts.get_config" + "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.route_maps.route_maps.Route_mapsFacts.get_config", ) self.execute_show_command = self.mock_execute_show_command.start() @@ -100,12 +101,12 @@ class TestVyosRouteMapsModule(TestVyosModule): tag=5, weight=4, ), - ) + ), ], - ) + ), ], state="merged", - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -144,12 +145,12 @@ class TestVyosRouteMapsModule(TestVyosModule): tag=4, weight=4, ), - ) + ), ], - ) + ), ], state="merged", - ) + ), ) commands = [ "set policy route-map test2 rule 1 action permit", @@ -209,12 +210,12 @@ class TestVyosRouteMapsModule(TestVyosModule): tag=4, weight=4, ), - ) + ), ], ), ], state="replaced", - ) + ), ) commands = [ "delete policy route-map test3 rule 1 match interface eth2", @@ -261,12 +262,12 @@ class TestVyosRouteMapsModule(TestVyosModule): tag=5, weight=4, ), - ) + ), ], ), ], state="replaced", - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -299,12 +300,12 @@ class TestVyosRouteMapsModule(TestVyosModule): tag=4, weight=4, ), - ) + ), ], - ) + ), ], state="overridden", - ) + ), ) commands = [ "delete policy route-map test3", @@ -361,12 +362,12 @@ class TestVyosRouteMapsModule(TestVyosModule): tag=5, weight=4, ), - ) + ), ], ), ], state="overridden", - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -404,7 +405,7 @@ class TestVyosRouteMapsModule(TestVyosModule): tag=5, weight=4, ), - ) + ), ], ), dict( @@ -425,7 +426,7 @@ class TestVyosRouteMapsModule(TestVyosModule): ), ], state="rendered", - ) + ), ) rendered_cmds = [ "set policy route-map test3 rule 1 action permit", @@ -504,7 +505,7 @@ class TestVyosRouteMapsModule(TestVyosModule): "tag": "5", "weight": "4", }, - } + }, ], "route_map": "test3", }, @@ -544,7 +545,7 @@ class TestVyosRouteMapsModule(TestVyosModule): "tag": "5", "weight": "4", }, - } + }, ], "route_map": "test3", }, @@ -572,12 +573,12 @@ class TestVyosRouteMapsModule(TestVyosModule): tag=5, weight=4, ), - ) + ), ], ), ], state="deleted", - ) + ), ) commands = ["delete policy route-map test3"] self.execute_module(changed=True, commands=commands) diff --git a/tests/unit/modules/network/vyos/test_vyos_snmp_server.py b/tests/unit/modules/network/vyos/test_vyos_snmp_server.py index b6d61b1..4314465 100644 --- a/tests/unit/modules/network/vyos/test_vyos_snmp_server.py +++ b/tests/unit/modules/network/vyos/test_vyos_snmp_server.py @@ -18,6 +18,7 @@ # Make coding more python3-ish from __future__ import absolute_import, division, print_function + __metaclass__ = type from unittest.mock import patch @@ -35,17 +36,17 @@ class TestVyosSnmpServerModule(TestVyosModule): super(TestVyosSnmpServerModule, self).setUp() self.mock_get_resource_connection_config = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module_base.get_resource_connection" + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module_base.get_resource_connection", ) self.get_resource_connection_config = self.mock_get_resource_connection_config.start() self.mock_get_resource_connection_facts = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection" + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection", ) self.get_resource_connection_facts = self.mock_get_resource_connection_facts.start() self.mock_execute_show_command = patch( - "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.snmp_server.snmp_server.Snmp_serverFacts.get_config" + "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.snmp_server.snmp_server.Snmp_serverFacts.get_config", ) self.execute_show_command = self.mock_execute_show_command.start() @@ -74,7 +75,7 @@ class TestVyosSnmpServerModule(TestVyosModule): dict( name="bridges", networks=["12.1.1.0/24", "1.1.1.0/24"], - ) + ), ], listen_addresses=[ dict(address="100.1.2.1", port=33), @@ -92,11 +93,11 @@ class TestVyosSnmpServerModule(TestVyosModule): authentication=dict(type="sha", plaintext_key="opq1234567"), privacy=dict(type="aes", plaintext_key="opq1234567"), ), - ] + ], ), ), state="merged", - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -108,7 +109,7 @@ class TestVyosSnmpServerModule(TestVyosModule): dict( name="bridges", networks=["12.1.1.0/24", "1.1.1.0/24"], - ) + ), ], listen_addresses=[ dict(address="100.1.2.1", port=33), @@ -126,11 +127,11 @@ class TestVyosSnmpServerModule(TestVyosModule): authentication=dict(type="sha", plaintext_key="opq1234567"), privacy=dict(type="aes", plaintext_key="opq1234567"), ), - ] + ], ), ), state="replaced", - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -142,7 +143,7 @@ class TestVyosSnmpServerModule(TestVyosModule): dict( name="bridges", networks=["12.1.1.0/24", "1.1.1.0/24"], - ) + ), ], listen_addresses=[ dict(address="100.1.2.1", port=33), @@ -160,11 +161,11 @@ class TestVyosSnmpServerModule(TestVyosModule): authentication=dict(type="sha", plaintext_key="opq1234567"), privacy=dict(type="aes", plaintext_key="opq1234567"), ), - ] + ], ), ), state="overridden", - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -193,7 +194,7 @@ class TestVyosSnmpServerModule(TestVyosModule): mode="rw", seclevel="priv", view="view1", - ) + ), ], trap_targets=[ dict( @@ -205,7 +206,7 @@ class TestVyosSnmpServerModule(TestVyosModule): ), ), state="merged", - ) + ), ) commands = [ "set service snmp community routers client 1.1.1.0/24", @@ -249,7 +250,7 @@ class TestVyosSnmpServerModule(TestVyosModule): mode="rw", seclevel="priv", view="view1", - ) + ), ], trap_targets=[ dict( @@ -261,7 +262,7 @@ class TestVyosSnmpServerModule(TestVyosModule): ), ), state="replaced", - ) + ), ) commands = [ "set service snmp community routers client 1.1.1.0/24", @@ -318,7 +319,7 @@ class TestVyosSnmpServerModule(TestVyosModule): mode="rw", seclevel="priv", view="view1", - ) + ), ], trap_targets=[ dict( @@ -330,7 +331,7 @@ class TestVyosSnmpServerModule(TestVyosModule): ), ), state="overridden", - ) + ), ) commands = [ "set service snmp community routers client 1.1.1.0/24", @@ -366,7 +367,7 @@ class TestVyosSnmpServerModule(TestVyosModule): set_module_args( dict( state="deleted", - ) + ), ) commands = ["delete service snmp"] self.execute_module(changed=True, commands=commands) @@ -396,7 +397,7 @@ class TestVyosSnmpServerModule(TestVyosModule): mode="rw", seclevel="priv", view="view1", - ) + ), ], trap_targets=[ dict( @@ -408,7 +409,7 @@ class TestVyosSnmpServerModule(TestVyosModule): ), ), state="rendered", - ) + ), ) commands = [ "set service snmp community routers client 1.1.1.0/24", @@ -471,7 +472,7 @@ class TestVyosSnmpServerModule(TestVyosModule): "mode": "rw", "seclevel": "priv", "view": "view1", - } + }, ], }, "trap_source": "1.1.1.1", @@ -512,7 +513,7 @@ class TestVyosSnmpServerModule(TestVyosModule): }, "user": "guest_user", }, - ] + ], }, } self.assertEqual(gathered_list, result["gathered"]) diff --git a/tests/unit/modules/network/vyos/test_vyos_static_routes.py b/tests/unit/modules/network/vyos/test_vyos_static_routes.py index 96137bd..b38d979 100644 --- a/tests/unit/modules/network/vyos/test_vyos_static_routes.py +++ b/tests/unit/modules/network/vyos/test_vyos_static_routes.py @@ -18,6 +18,7 @@ # Make coding more python3-ish from __future__ import absolute_import, division, print_function + __metaclass__ = type from unittest.mock import patch @@ -34,27 +35,27 @@ class TestVyosStaticRoutesModule(TestVyosModule): def setUp(self): super(TestVyosStaticRoutesModule, self).setUp() self.mock_get_config = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config" + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config", ) self.get_config = self.mock_get_config.start() self.mock_load_config = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config" + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config", ) self.load_config = self.mock_load_config.start() self.mock_get_resource_connection_config = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection" + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection", ) self.get_resource_connection_config = self.mock_get_resource_connection_config.start() self.mock_get_resource_connection_facts = patch( - "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection" + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection", ) self.get_resource_connection_facts = self.mock_get_resource_connection_facts.start() self.mock_execute_show_command = patch( - "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.static_routes.static_routes.Static_routesFacts.get_device_data" + "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.static_routes.static_routes.Static_routesFacts.get_device_data", ) self.execute_show_command = self.mock_execute_show_command.start() @@ -93,14 +94,14 @@ class TestVyosStaticRoutesModule(TestVyosModule): interface="eth0", ), ], - ) + ), ], - ) - ] - ) + ), + ], + ), ], state="merged", - ) + ), ) commands = [ "set protocols static route 192.0.2.48/28", @@ -126,14 +127,14 @@ class TestVyosStaticRoutesModule(TestVyosModule): dict(forward_router_address="192.0.2.9"), dict(forward_router_address="192.0.2.10"), ], - ) + ), ], - ) - ] - ) + ), + ], + ), ], state="merged", - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -158,14 +159,14 @@ class TestVyosStaticRoutesModule(TestVyosModule): admin_distance=10, ), ], - ) + ), ], - ) - ] - ) + ), + ], + ), ], state="replaced", - ) + ), ) commands = [ "set protocols static route 192.0.2.48/28", @@ -191,14 +192,14 @@ class TestVyosStaticRoutesModule(TestVyosModule): dict(forward_router_address="192.0.2.9"), dict(forward_router_address="192.0.2.10"), ], - ) + ), ], - ) - ] - ) + ), + ], + ), ], state="replaced", - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -218,14 +219,14 @@ class TestVyosStaticRoutesModule(TestVyosModule): dict(forward_router_address="192.0.2.9"), dict(forward_router_address="192.0.2.10"), ], - ) + ), ], - ) - ] - ) + ), + ], + ), ], state="overridden", - ) + ), ) commands = [ "delete protocols static route 192.0.2.32/28", @@ -250,14 +251,14 @@ class TestVyosStaticRoutesModule(TestVyosModule): dict(forward_router_address="192.0.2.9"), dict(forward_router_address="192.0.2.10"), ], - ) + ), ], - ) - ] - ) + ), + ], + ), ], state="overridden", - ) + ), ) self.execute_module(changed=False, commands=[]) @@ -266,7 +267,7 @@ class TestVyosStaticRoutesModule(TestVyosModule): dict( config=[dict(address_families=[dict(afi="ipv4")])], state="deleted", - ) + ), ) commands = ["delete protocols static route"] self.execute_module(changed=True, commands=commands) diff --git a/tests/unit/modules/network/vyos/test_vyos_system.py b/tests/unit/modules/network/vyos/test_vyos_system.py index 252172d..cf405ca 100644 --- a/tests/unit/modules/network/vyos/test_vyos_system.py +++ b/tests/unit/modules/network/vyos/test_vyos_system.py @@ -18,6 +18,7 @@ # Make coding more python3-ish from __future__ import absolute_import, division, print_function + __metaclass__ = type from unittest.mock import patch @@ -35,12 +36,12 @@ class TestVyosSystemModule(TestVyosModule): super(TestVyosSystemModule, self).setUp() self.mock_get_config = patch( - "ansible_collections.vyos.vyos.plugins.modules.vyos_system.get_config" + "ansible_collections.vyos.vyos.plugins.modules.vyos_system.get_config", ) self.get_config = self.mock_get_config.start() self.mock_load_config = patch( - "ansible_collections.vyos.vyos.plugins.modules.vyos_system.load_config" + "ansible_collections.vyos.vyos.plugins.modules.vyos_system.load_config", ) self.load_config = self.mock_load_config.start() @@ -97,7 +98,7 @@ class TestVyosSystemModule(TestVyosModule): host_name="router", domain_name="example.com", name_server=["8.8.8.8", "8.8.4.4"], - ) + ), ) result = self.execute_module() self.assertEqual([], result["commands"]) diff --git a/tests/unit/modules/network/vyos/test_vyos_user.py b/tests/unit/modules/network/vyos/test_vyos_user.py index 2387296..7029720 100644 --- a/tests/unit/modules/network/vyos/test_vyos_user.py +++ b/tests/unit/modules/network/vyos/test_vyos_user.py @@ -18,6 +18,7 @@ # Make coding more python3-ish from __future__ import absolute_import, division, print_function + __metaclass__ = type from unittest.mock import patch @@ -35,12 +36,12 @@ class TestVyosUserModule(TestVyosModule): super(TestVyosUserModule, self).setUp() self.mock_get_config = patch( - "ansible_collections.vyos.vyos.plugins.modules.vyos_user.get_config" + "ansible_collections.vyos.vyos.plugins.modules.vyos_user.get_config", ) self.get_config = self.mock_get_config.start() self.mock_load_config = patch( - "ansible_collections.vyos.vyos.plugins.modules.vyos_user.load_config" + "ansible_collections.vyos.vyos.plugins.modules.vyos_user.load_config", ) self.load_config = self.mock_load_config.start() @@ -87,7 +88,7 @@ class TestVyosUserModule(TestVyosModule): [ "delete system login user ansible", "delete system login user admin", - ] + ], ), ) @@ -97,7 +98,7 @@ class TestVyosUserModule(TestVyosModule): name="test", configured_password="test", update_password="on_create", - ) + ), ) result = self.execute_module(changed=True) self.assertEqual( @@ -111,7 +112,7 @@ class TestVyosUserModule(TestVyosModule): name="ansible", configured_password="test", update_password="on_create", - ) + ), ) self.execute_module() @@ -121,7 +122,7 @@ class TestVyosUserModule(TestVyosModule): name="ansible", configured_password="test", update_password="always", - ) + ), ) result = self.execute_module(changed=True) self.assertEqual( diff --git a/tests/unit/modules/network/vyos/vyos_module.py b/tests/unit/modules/network/vyos/vyos_module.py index b1bdc2e..60d94b5 100644 --- a/tests/unit/modules/network/vyos/vyos_module.py +++ b/tests/unit/modules/network/vyos/vyos_module.py @@ -18,6 +18,7 @@ # Make coding more python3-ish from __future__ import absolute_import, division, print_function + __metaclass__ = type import json @@ -29,6 +30,7 @@ from ansible_collections.vyos.vyos.tests.unit.modules.utils import ( ModuleTestCase, ) + fixture_path = os.path.join(os.path.dirname(__file__), "fixtures") fixture_data = {} diff --git a/tests/unit/modules/utils.py b/tests/unit/modules/utils.py index a7dd0b3..6489f13 100644 --- a/tests/unit/modules/utils.py +++ b/tests/unit/modules/utils.py @@ -1,8 +1,10 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type import json import unittest + from unittest.mock import patch from ansible.module_utils import basic @@ -41,7 +43,9 @@ def fail_json(*args, **kwargs): class ModuleTestCase(unittest.TestCase): def setUp(self): self.mock_module = patch.multiple( - basic.AnsibleModule, exit_json=exit_json, fail_json=fail_json + basic.AnsibleModule, + exit_json=exit_json, + fail_json=fail_json, ) self.mock_module.start() self.mock_sleep = patch("time.sleep") |