diff --git a/.ansible-lint b/.ansible-lint new file mode 100644 index 000000000..7324ff454 --- /dev/null +++ b/.ansible-lint @@ -0,0 +1,6 @@ +--- + +profile: production +skip_list: + # ansible-lint does not like the `import-3.11` ignore in tests/sanity/ignore-*.txt + - sanity diff --git a/.flake8 b/.flake8 new file mode 100644 index 000000000..9a7fc1251 --- /dev/null +++ b/.flake8 @@ -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/tests/unit/compat/__init__.py b/.github/CODEOWNERS similarity index 100% rename from tests/unit/compat/__init__.py rename to .github/CODEOWNERS diff --git a/.github/workflows/ack.yml b/.github/workflows/check_label.yml similarity index 60% rename from .github/workflows/ack.yml rename to .github/workflows/check_label.yml index fda595dc5..b120bfa32 100644 --- a/.github/workflows/ack.yml +++ b/.github/workflows/check_label.yml @@ -1,15 +1,11 @@ --- -# See https://github.com/ansible-community/devtools/blob/main/.github/workflows/ack.yml -name: ack - +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: - ack: - uses: ansible/devtools/.github/workflows/ack.yml@main + 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 b425edcc2..3e0f17919 100644 --- a/.github/workflows/codecoverage.yml +++ b/.github/workflows/codecoverage.yml @@ -1,8 +1,9 @@ --- -name: Code Coverage +name: "Code coverage" on: # yamllint disable-line rule:truthy push: + branches: [main] pull_request: branches: [ main ] diff --git a/.github/workflows/draft_release.yml b/.github/workflows/draft_release.yml new file mode 100644 index 000000000..88b45f2b0 --- /dev/null +++ b/.github/workflows/draft_release.yml @@ -0,0 +1,18 @@ +--- +name: "Draft release" +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true +on: # yamllint disable-line rule:truthy + workflow_dispatch: +env: + NAMESPACE: ${{ github.repository_owner }} + COLLECTION_NAME: iosxr + ANSIBLE_COLLECTIONS_PATHS: ./ +jobs: + update_release_draft: + uses: ansible/ansible-content-actions/.github/workflows/draft_release.yaml@main + with: + repo: ${{ github.event.pull_request.head.repo.full_name }} + secrets: + BOT_PAT: ${{ secrets.BOT_PAT }} diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml deleted file mode 100644 index 06d11b8a0..000000000 --- a/.github/workflows/push.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -# push workflow is shared and expected to perform actions after a merge happens -# on a maintenance branch (default or release). For example updating the -# draft release-notes. -# based on great work from -# https://github.com/T-Systems-MMS/ansible-collection-icinga-director -name: push - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -on: # yamllint disable-line rule:truthy - workflow_dispatch: - -env: - NAMESPACE: cisco - COLLECTION_NAME: iosxr - ANSIBLE_COLLECTIONS_PATHS: ./ - -jobs: - update_release_draft: - uses: ansible/devtools/.github/workflows/push_network.yml@main - with: - repo: ansible-collections/cisco.iosxr - secrets: - BOT_PAT: ${{ secrets.BOT_PAT }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index eb04259d1..6dbb1aa39 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,12 +1,12 @@ --- -name: release +name: "Release collection" on: # yamllint disable-line rule:truthy release: types: [published] jobs: release: - uses: ansible/devtools/.github/workflows/release_collection.yml@main + uses: ansible/ansible-content-actions/.github/workflows/release.yaml@main with: environment: release secrets: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1a1278d2e..64409a9a4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,5 +1,5 @@ --- -name: Test collection +name: "CI" concurrency: group: ${{ github.head_ref || github.run_id }} @@ -13,15 +13,17 @@ on: # yamllint disable-line rule:truthy - 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: @@ -29,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 + - ansible-lint - unit-source 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.ansible-lint.result }}', '${{ needs.unit-source.result }}' - ]) == {'success'}" + ])" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8fdbd4b3a..90167726d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,6 @@ repos: - repo: https://github.com/ansible-network/collection_prep rev: 1.1.1 hooks: - # - id: autoversion # removed as being handled by GHA push and release drafter - id: update-docs - repo: https://github.com/pre-commit/pre-commit-hooks @@ -23,7 +22,7 @@ repos: - id: add-trailing-comma - repo: https://github.com/pre-commit/mirrors-prettier - rev: "v3.0.3" + 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" @@ -34,13 +33,18 @@ repos: - prettier-plugin-toml - repo: https://github.com/PyCQA/isort - rev: 5.12.0 + rev: 5.13.2 hooks: - id: isort name: Sort import statements using isort args: ["--filter-files"] - repo: https://github.com/psf/black - rev: 23.9.1 + rev: 23.12.1 hooks: - id: black + + - repo: https://github.com/pycqa/flake8 + rev: 7.0.0 + hooks: + - id: flake8 diff --git a/.zuul.yaml b/.zuul.yaml deleted file mode 100644 index a892ec722..000000000 --- a/.zuul.yaml +++ /dev/null @@ -1,8 +0,0 @@ ---- -- project: - check: - jobs: - - ansible-tox-linters - gate: - jobs: - - ansible-tox-linters diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 896bf0a68..70c2fc3b4 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,6 +5,61 @@ Cisco Iosxr Collection Release Notes .. contents:: Topics +v8.0.0 +====== + +Major Changes +------------- + +- This release removes previously deprecated module and attributes from this collection. Please refer to the **Removed Features** section for details. + +Removed Features (previously deprecated) +---------------------------------------- + +- Remove deprecated iosxr_logging module which is replaced with iosxr_logging_global resource module. + +v7.2.0 +====== + +Minor Changes +------------- + +- Add missing options in afi and safi in address-family of bgp_templates RM. + +Bugfixes +-------- + +- Fix 'afi' value in bgp_templates RM to valid values. + +v7.1.0 +====== + +Minor Changes +------------- + +- iosxr_facts - Add cdp neighbors in ansible_net_neighbors dictionary (https://github.com/ansible-collections/cisco.iosxr/pull/457). + +v7.0.0 +====== + +Release Summary +--------------- + +Starting from this release, the minimum `ansible-core` version this collection requires is `2.14.0`. The last known version compatible with ansible-core<2.14 is `v6.1.1`. + +Major Changes +------------- + +- Bumping `requires_ansible` to `>=2.14.0`, since previous ansible-core versions are EoL now. + +v6.1.1 +====== + +Bugfixes +-------- + +- Fix issue in gathered state of interfaces and l3_interfaces RMs(https://github.com/ansible-collections/cisco.iosxr/issues/452, https://github.com/ansible-collections/cisco.iosxr/issues/451) + v6.1.0 ====== diff --git a/README.md b/README.md index 0d66637b7..d3e158bba 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,16 @@ # Cisco IOSXR Collection [![CI](https://zuul-ci.org/gated.svg)](https://dashboard.zuul.ansible.com/t/ansible/project/github.com/ansible-collections/cisco.iosxr) [![Codecov](https://codecov.io/gh/ansible-collections/cisco.iosxr/branch/main/graph/badge.svg)](https://codecov.io/gh/ansible-collections/cisco.iosxr) +[![CI](https://github.com/ansible-collections/cisco.iosxr/actions/workflows/tests.yml/badge.svg?branch=main&event=schedule)](https://github.com/ansible-collections/cisco.iosxr/actions/workflows/tests.yml) + The Ansible Cisco IOSXR collection includes a variety of Ansible content to help automate the management of Cisco IOSXR network appliances. -This collection has been tested against Cisco IOSXR version 7.0.2. +This collection has been tested against Cisco IOS-XR version 7.0.2 ## Ansible version compatibility -This collection has been tested against following Ansible versions: **>=2.9.10**. +This collection has been tested against following Ansible versions: **>=2.14.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`). @@ -18,7 +20,8 @@ PEP440 is the schema used to describe the versions of Ansible. ### Supported connections -The Cisco IOSXR collection supports ``network_cli`` and ``netconf`` connections. + +The Cisco IOS-XR collection supports ``network_cli`` and ``netconf`` connections. A detailed platform guide can be found [here](https://github.com/ansible-collections/cisco.iosxr/blob/main/platform_guide.rst). ## Included content @@ -54,7 +57,6 @@ Name | Description [cisco.iosxr.iosxr_lag_interfaces](https://github.com/ansible-collections/cisco.iosxr/blob/main/docs/cisco.iosxr.iosxr_lag_interfaces_module.rst)|Resource module to configure LAG interfaces. [cisco.iosxr.iosxr_lldp_global](https://github.com/ansible-collections/cisco.iosxr/blob/main/docs/cisco.iosxr.iosxr_lldp_global_module.rst)|Resource module to configure LLDP. [cisco.iosxr.iosxr_lldp_interfaces](https://github.com/ansible-collections/cisco.iosxr/blob/main/docs/cisco.iosxr.iosxr_lldp_interfaces_module.rst)|Resource module to configure LLDP interfaces. -[cisco.iosxr.iosxr_logging](https://github.com/ansible-collections/cisco.iosxr/blob/main/docs/cisco.iosxr.iosxr_logging_module.rst)|(deprecated, removed after 2023-08-01) Configuration management of system logging services on network devices [cisco.iosxr.iosxr_logging_global](https://github.com/ansible-collections/cisco.iosxr/blob/main/docs/cisco.iosxr.iosxr_logging_global_module.rst)|Resource module to configure logging. [cisco.iosxr.iosxr_netconf](https://github.com/ansible-collections/cisco.iosxr/blob/main/docs/cisco.iosxr.iosxr_netconf_module.rst)|Configures NetConf sub-system service on Cisco IOS-XR devices [cisco.iosxr.iosxr_ntp_global](https://github.com/ansible-collections/cisco.iosxr/blob/main/docs/cisco.iosxr.iosxr_ntp_global_module.rst)|Resource module to configure NTP. @@ -74,7 +76,7 @@ Click the ``Content`` button to see the list of content included in this collect ## Installing this collection -You can install the Cisco IOSXR collection with the Ansible Galaxy CLI: +You can install the Cisco IOS-XR collection with the Ansible Galaxy CLI: ansible-galaxy collection install cisco.iosxr diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index 6409b2d8e..2b66f7eca 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -52,11 +52,6 @@ releases: - description: LLDP interfaces resource module name: iosxr_lldp_interfaces namespace: "" - - description: - Configuration management of system logging services on network - devices - name: iosxr_logging - namespace: "" - description: Configures NetConf sub-system service on Cisco IOS-XR devices name: iosxr_netconf namespace: "" @@ -677,3 +672,58 @@ releases: - fix_iosxr_config.yaml - prefix_list_doc.yaml release_date: "2023-10-30" + 6.1.1: + changes: + bugfixes: + - Fix issue in gathered state of interfaces and l3_interfaces RMs(https://github.com/ansible-collections/cisco.iosxr/issues/452, + https://github.com/ansible-collections/cisco.iosxr/issues/451) + fragments: + - bugfix_interfaces.yaml + - fix_acl_interfaces.yaml + - fix_python_version.yaml + - revert_pylibssh_depn.yaml + release_date: "2023-11-27" + 7.0.0: + changes: + major_changes: + - Bumping `requires_ansible` to `>=2.14.0`, since previous ansible-core versions + are EoL now. + release_summary: + Starting from this release, the minimum `ansible-core` version + this collection requires is `2.14.0`. The last known version compatible with + ansible-core<2.14 is `v6.1.1`. + fragments: + - trivial_lint.yaml + - update_ansible_version.yaml + release_date: "2023-11-30" + 7.1.0: + changes: + minor_changes: + - iosxr_facts - Add cdp neighbors in ansible_net_neighbors dictionary (https://github.com/ansible-collections/cisco.iosxr/pull/457). + fragments: + - fix_add_cdp_neighbors.yaml + - fix_iosxr_config.yaml + release_date: "2024-01-08" + 7.2.0: + changes: + bugfixes: + - Fix 'afi' value in bgp_templates RM to valid values. + minor_changes: + - Add missing options in afi and safi in address-family of bgp_templates RM. + fragments: + - bugfix_bgp_templates.yaml + - fix_bgp_template.yaml + - fix_nightly.yaml + release_date: "2024-03-01" + 8.0.0: + changes: + major_changes: + - This release removes previously deprecated module and attributes from this + collection. Please refer to the **Removed Features** section for details. + removed_features: + - Remove deprecated iosxr_logging module which is replaced with iosxr_logging_global + resource module. + fragments: + - remove_deprecated.yaml + - trivial_tests_updates.yaml + release_date: "2024-03-27" diff --git a/changelogs/fragments/add_2.18.yaml b/changelogs/fragments/add_2.18.yaml new file mode 100644 index 000000000..0aaf1f750 --- /dev/null +++ b/changelogs/fragments/add_2.18.yaml @@ -0,0 +1,3 @@ +--- +trivial: + - Add ignore-2.18.txt. diff --git a/changelogs/fragments/fix_python_version.yaml b/changelogs/fragments/fix_python_version.yaml deleted file mode 100644 index 69a25f71d..000000000 --- a/changelogs/fragments/fix_python_version.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - Fix python requirement for tests. diff --git a/changelogs/fragments/remove_tests.yaml b/changelogs/fragments/remove_tests.yaml new file mode 100644 index 000000000..6e0e85990 --- /dev/null +++ b/changelogs/fragments/remove_tests.yaml @@ -0,0 +1,3 @@ +--- +trivial: + - Remove tests related to iosxr_logging deprecated module. diff --git a/docs/cisco.iosxr.iosxr_acl_interfaces_module.rst b/docs/cisco.iosxr.iosxr_acl_interfaces_module.rst index c61999008..34b2b30f0 100644 --- a/docs/cisco.iosxr.iosxr_acl_interfaces_module.rst +++ b/docs/cisco.iosxr.iosxr_acl_interfaces_module.rst @@ -240,27 +240,26 @@ Examples - name: Merge the provided configuration with the existing running configuration cisco.iosxr.iosxr_acl_interfaces: config: - - name: GigabitEthernet0/0/0/0 - access_groups: - - afi: ipv4 - acls: - - name: acl_1 - direction: in - - name: acl_2 - direction: out - - afi: ipv6 - acls: - - name: acl6_1 - direction: in - - name: acl6_2 - direction: out - - - name: GigabitEthernet0/0/0/1 - access_groups: - - afi: ipv4 - acls: - - name: acl_1 - direction: out + - name: GigabitEthernet0/0/0/0 + access_groups: + - afi: ipv4 + acls: + - name: acl_1 + direction: in + - name: acl_2 + direction: out + - afi: ipv6 + acls: + - name: acl6_1 + direction: in + - name: acl6_2 + direction: out + - name: GigabitEthernet0/0/0/1 + access_groups: + - afi: ipv4 + acls: + - name: acl_1 + direction: out state: merged # After state: @@ -309,14 +308,14 @@ Examples - name: Update acl_interfaces configuration using merged cisco.iosxr.iosxr_acl_interfaces: config: - - name: GigabitEthernet0/0/0/1 - access_groups: - - afi: ipv4 - acls: - - name: acl_2 - direction: out - - name: acl_1 - direction: in + - name: GigabitEthernet0/0/0/1 + access_groups: + - afi: ipv4 + acls: + - name: acl_2 + direction: out + - name: acl_1 + direction: in state: merged # After state: @@ -363,15 +362,17 @@ Examples # ipv4 access-group acl_1 egress # ! - - name: Replace device configurations of listed interface with provided configurations + - name: >- + Replace device configurations of listed interface with provided + configurations cisco.iosxr.iosxr_acl_interfaces: config: - - name: GigabitEthernet0/0/0/0 - access_groups: - - afi: ipv6 - acls: - - name: acl6_3 - direction: in + - name: GigabitEthernet0/0/0/0 + access_groups: + - afi: ipv6 + acls: + - name: acl6_3 + direction: in state: replaced # After state: @@ -418,16 +419,16 @@ Examples - name: Overridde all interface ACL configuration with provided configuration cisco.iosxr.iosxr_acl_interfaces: config: - - name: GigabitEthernet0/0/0/1 - access_groups: - - afi: ipv4 - acls: - - name: acl_2 - direction: in - - afi: ipv6 - acls: - - name: acl6_3 - direction: out + - name: GigabitEthernet0/0/0/1 + access_groups: + - afi: ipv4 + acls: + - name: acl_2 + direction: in + - afi: ipv6 + acls: + - name: acl6_3 + direction: out state: overridden # After state: @@ -474,7 +475,7 @@ Examples - name: Delete all ACL attributes of GigabitEthernet0/0/0/1 cisco.iosxr.iosxr_acl_interfaces: config: - - name: GigabitEthernet0/0/0/1 + - name: GigabitEthernet0/0/0/1 state: deleted # After state: @@ -674,14 +675,14 @@ Examples - name: Render platform specific commands from task input using rendered state cisco.iosxr.iosxr_acl_interfaces: config: - - name: GigabitEthernet0/0/0/0 - access_groups: - - afi: ipv4 - acls: - - name: acl_1 - direction: in - - name: acl_2 - direction: out + - name: GigabitEthernet0/0/0/0 + access_groups: + - afi: ipv4 + acls: + - name: acl_1 + direction: in + - name: acl_2 + direction: out state: rendered # Task Output (redacted) diff --git a/docs/cisco.iosxr.iosxr_acls_module.rst b/docs/cisco.iosxr.iosxr_acls_module.rst index e5ddf3321..32cf48121 100644 --- a/docs/cisco.iosxr.iosxr_acls_module.rst +++ b/docs/cisco.iosxr.iosxr_acls_module.rst @@ -4034,85 +4034,80 @@ Examples - name: Merge the provided configuration with the existing running configuration cisco.iosxr.iosxr_acls: config: - - afi: ipv6 - acls: - - name: acl6_1 - aces: - - sequence: 10 - grant: deny - protocol: tcp - source: - prefix: 2001:db8:1234::/48 - port_protocol: - range: - start: ftp - end: telnet - destination: - any: true - protocol_options: - tcp: - syn: true - ttl: - range: - start: 180 - end: 250 - routing: true - authen: true - log: true - - - sequence: 20 - grant: permit - protocol: icmpv6 - source: - any: true - destination: - any: true - protocol_options: - icmpv6: - router_advertisement: true - precedence: network - destopts: true - - - afi: ipv4 - acls: - - name: acl_1 - aces: - - sequence: 16 - remark: TEST_ACL_1_REMARK - - - sequence: 21 - grant: permit - protocol: tcp - source: - host: 192.0.2.10 - port_protocol: - range: - start: pop3 - end: 121 - destination: - address: 198.51.100.0 - wildcard_bits: 0.0.0.15 - protocol_options: - tcp: - rst: true - - - sequence: 23 - grant: deny - protocol: icmp - source: - any: true - destination: - prefix: 198.51.100.0/28 - protocol_options: - icmp: - reassembly_timeout: true - dscp: - lt: af12 - - - name: acl_2 - aces: - - sequence: 10 - remark: TEST_ACL_2_REMARK + - afi: ipv6 + acls: + - name: acl6_1 + aces: + - sequence: 10 + grant: deny + protocol: tcp + source: + prefix: '2001:db8:1234::/48' + port_protocol: + range: + start: ftp + end: telnet + destination: + any: true + protocol_options: + tcp: + syn: true + ttl: + range: + start: 180 + end: 250 + routing: true + authen: true + log: true + - sequence: 20 + grant: permit + protocol: icmpv6 + source: + any: true + destination: + any: true + protocol_options: + icmpv6: + router_advertisement: true + precedence: network + destopts: true + - afi: ipv4 + acls: + - name: acl_1 + aces: + - sequence: 16 + remark: TEST_ACL_1_REMARK + - sequence: 21 + grant: permit + protocol: tcp + source: + host: 192.0.2.10 + port_protocol: + range: + start: pop3 + end: 121 + destination: + address: 198.51.100.0 + wildcard_bits: 0.0.0.15 + protocol_options: + tcp: + rst: true + - sequence: 23 + grant: deny + protocol: icmp + source: + any: true + destination: + prefix: 198.51.100.0/28 + protocol_options: + icmp: + reassembly_timeout: true + dscp: + lt: af12 + - name: acl_2 + aces: + - sequence: 10 + remark: TEST_ACL_2_REMARK state: merged # Task Output @@ -4279,7 +4274,6 @@ Examples protocol_options: tcp: syn: true - - sequence: 23 protocol_options: icmp: @@ -4516,7 +4510,6 @@ Examples any: true ttl: eq: 100 - - sequence: 12 grant: deny source: @@ -4765,7 +4758,6 @@ Examples destination: any: true protocol: tcp - - name: acl_2 aces: - sequence: 20 @@ -5435,27 +5427,26 @@ Examples - name: Render platform specific commands (without connecting to the device) cisco.iosxr.iosxr_acls: config: - - afi: ipv4 - acls: - - name: acl_2 - aces: - - sequence: 11 - grant: permit - protocol: igmp - source: - host: 198.51.100.130 - destination: - any: true - ttl: - eq: 100 - - - sequence: 12 - grant: deny - source: - any: true - destination: - any: true - protocol: icmp + - afi: ipv4 + acls: + - name: acl_2 + aces: + - sequence: 11 + grant: permit + protocol: igmp + source: + host: 198.51.100.130 + destination: + any: true + ttl: + eq: 100 + - sequence: 12 + grant: deny + source: + any: true + destination: + any: true + protocol: icmp state: rendered # Task Output (redacted) diff --git a/docs/cisco.iosxr.iosxr_banner_module.rst b/docs/cisco.iosxr.iosxr_banner_module.rst index 747571a97..46d105682 100644 --- a/docs/cisco.iosxr.iosxr_banner_module.rst +++ b/docs/cisco.iosxr.iosxr_banner_module.rst @@ -128,7 +128,7 @@ Examples - name: Configure banner from file cisco.iosxr.iosxr_banner: banner: motd - text: "{{ lookup('file', './config_partial/raw_banner.cfg') }}" + text: '{{ lookup(''file'', ''./config_partial/raw_banner.cfg'') }}' state: present diff --git a/docs/cisco.iosxr.iosxr_bgp_address_family_module.rst b/docs/cisco.iosxr.iosxr_bgp_address_family_module.rst index 8ad152d3b..5a3ae6c65 100644 --- a/docs/cisco.iosxr.iosxr_bgp_address_family_module.rst +++ b/docs/cisco.iosxr.iosxr_bgp_address_family_module.rst @@ -2663,17 +2663,17 @@ Examples cisco.iosxr.iosxr_bgp_address_family: state: merged config: - as_number: "65536" + as_number: '65536' address_family: - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast vrf: vrf1 dynamic_med: 9 redistribute: - protocol: connected metric: 10 - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast dynamic_med: 10 redistribute: - protocol: application @@ -2768,10 +2768,10 @@ Examples cisco.iosxr.iosxr_bgp_address_family: state: replaced config: - as_number: "65536" + as_number: '65536' address_family: - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast vrf: vrf1 dynamic_med: 10 # Task output @@ -2845,10 +2845,10 @@ Examples cisco.iosxr.iosxr_bgp_address_family: state: overridden config: - as_number: "65536" + as_number: '65536' address_family: - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast vrf: vrf1 dynamic_med: 10 @@ -2939,17 +2939,17 @@ Examples cisco.iosxr.iosxr_bgp_address_family: state: rendered config: - as_number: "65536" + as_number: '65536' address_family: - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast vrf: vrf1 dynamic_med: 9 redistribute: - protocol: connected metric: 10 - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast dynamic_med: 10 redistribute: - protocol: application @@ -2979,21 +2979,21 @@ Examples # # Using gathered # ------------- - - name: Merge the provided configuration with the existing running configuration + - name: Gather existing running configuration cisco.iosxr.iosxr_bgp_address_family: state: gathered config: - as_number: "65536" + as_number: '65536' address_family: - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast vrf: vrf1 dynamic_med: 9 redistribute: - protocol: connected metric: 10 - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast dynamic_med: 10 redistribute: - protocol: application @@ -3031,8 +3031,8 @@ Examples # # Using parsed # - #parsed.cfg - #------------ + # parsed.cfg + # ------------ # router bgp 65536 # bgp router-id 192.0.1.1 # address-family ipv4 unicast diff --git a/docs/cisco.iosxr.iosxr_bgp_global_module.rst b/docs/cisco.iosxr.iosxr_bgp_global_module.rst index 1d2297c60..382bd6659 100644 --- a/docs/cisco.iosxr.iosxr_bgp_global_module.rst +++ b/docs/cisco.iosxr.iosxr_bgp_global_module.rst @@ -8997,45 +8997,44 @@ Examples # # Before state # ------------ - # RP/0/0/CPU0:10#show running-config router bgp # Thu Feb 4 09:38:36.245 UTC # % No such configuration item(s) # RP/0/0/CPU0:10# - - name: Merge the following BGP global configuration - cisco.iosxr.iosxr_bgp_global: - config: - as_number: 65536 - default_metric: 5 - socket: - receive_buffer_size: 514 - send_buffer_size: 4098 - bgp: - confederation: - identifier: 4 - bestpath: - med: - confed: True - cluster_id: 5 - router_id: 192.0.2.10 - neighbors: - - neighbor: 192.0.2.13 - remote_as: 65538 - bfd: - fast_detect: - strict_mode: True - multiplier: 6 - minimum_interval: 20 - vrfs: - - vrf: vrf1 - default_metric: 5 + - name: Merge the following BGP global configuration + cisco.iosxr.iosxr_bgp_global: + config: + as_number: 65536 + default_metric: 5 + socket: + receive_buffer_size: 514 + send_buffer_size: 4098 + bgp: + confederation: + identifier: 4 + bestpath: + med: + confed: true + cluster_id: 5 + router_id: 192.0.2.10 + neighbors: + - neighbor: 192.0.2.13 + remote_as: 65538 + bfd: + fast_detect: + strict_mode: true + multiplier: 6 + minimum_interval: 20 + vrfs: + - vrf: vrf1 + default_metric: 5 + # # Task Output: - # ------------ + # --------------- # # before: {} - # commands: # - router bgp 65536 # - bgp cluster-id 5 @@ -9129,37 +9128,38 @@ Examples # ! # ! - - name: Replace the following configuration - cisco.iosxr.iosxr_bgp_global: - state: replaced - config: - as_number: 65536 - default_metric: 4 - socket: - receive_buffer_size: 514 - send_buffer_size: 4098 - bgp: - confederation: - identifier: 4 - bestpath: - med: - confed: True - cluster_id: 5 - router_id: 192.0.2.10 - neighbors: - - neighbor: 192.0.2.14 - remote_as: 65538 - bfd: - fast_detect: - strict_mode: True - multiplier: 6 - minimum_interval: 20 - vrfs: - - vrf: vrf1 - default_metric: 5 + - name: Replace the following configuration + cisco.iosxr.iosxr_bgp_global: + state: replaced + config: + as_number: 65536 + default_metric: 4 + socket: + receive_buffer_size: 514 + send_buffer_size: 4098 + bgp: + confederation: + identifier: 4 + bestpath: + med: + confed: true + cluster_id: 5 + router_id: 192.0.2.10 + neighbors: + - neighbor: 192.0.2.14 + remote_as: 65538 + bfd: + fast_detect: + strict_mode: true + multiplier: 6 + minimum_interval: 20 + vrfs: + - vrf: vrf1 + default_metric: 5 + # # Task Output: - # ------------ + # ------------- # # before: # as_number: '65536' @@ -9273,37 +9273,37 @@ Examples # ! # ! - - name: Override running config with provided configuration - cisco.iosxr.iosxr_bgp_global: - state: overridden - config: - as_number: 65536 - default_metric: 4 - socket: - receive_buffer_size: 514 - send_buffer_size: 4098 - bgp: - confederation: - identifier: 4 - bestpath: - med: - confed: True - cluster_id: 5 - router_id: 192.0.2.10 - neighbors: - - neighbor: 192.0.2.14 - remote_as: 65538 - bfd: - fast_detect: - strict_mode: True - multiplier: 6 - minimum_interval: 20 - vrfs: - - vrf: vrf1 - default_metric: 5 + - name: Override running config with provided configuration + cisco.iosxr.iosxr_bgp_global: + state: overridden + config: + as_number: 65536 + default_metric: 4 + socket: + receive_buffer_size: 514 + send_buffer_size: 4098 + bgp: + confederation: + identifier: 4 + bestpath: + med: + confed: true + cluster_id: 5 + router_id: 192.0.2.10 + neighbors: + - neighbor: 192.0.2.14 + remote_as: 65538 + bfd: + fast_detect: + strict_mode: true + multiplier: 6 + minimum_interval: 20 + vrfs: + - vrf: vrf1 + default_metric: 5 # # Task Output: - # ------------ + # ------------- # # before: # as_number: '65536' @@ -9418,14 +9418,15 @@ Examples # ! # - - name: Delete BGP configurations handled by this module - cisco.iosxr.iosxr_bgp_global: - config: - as_number: 65536 - state: deleted + - name: Delete BGP configurations handled by this module + cisco.iosxr.iosxr_bgp_global: + config: + as_number: 65536 + state: deleted + # # Task Output: - # ------------ + # ------------- # # before: # as_number: '65536' @@ -9504,13 +9505,13 @@ Examples # ! # - - name: Purge all BGP configurations from the device - cisco.iosxr.iosxr_bgp_global: - state: purged + - name: Purge all BGP configurations from the device + cisco.iosxr.iosxr_bgp_global: + state: purged # # Task Output: - # ------------ + # ------------- # # before: # as_number: '65536' @@ -9550,49 +9551,54 @@ Examples # Thu Feb 4 09:38:36.245 UTC # % No such configuration item(s) # RP/0/0/CPU0:10# + # - # Using replaced # - - name: Render platform specific configuration lines (without connecting to the device) - cisco.iosxr.iosxr_bgp_global: - state: rendered - config: - as_number: 1 - default_metric: 4 - vrfs: - - vrf: vrf3 - bfd: - minimum_interval: 20 - multiplier: 10 - bgp: - fast_external_fallover: - disable: True - router_id: 1.2.3.4 - auto_policy_soft_reset: - disable: True - timers: - keepalive_time: 20 - holdtime: 30 - - vrf: vrf2 - bgp: - enforce_first_as: - disable: True - default_metric: 4 - neighbors: - - neighbor: 1.1.1.3 - remote_as: 2 - graceful_maintenance: - set: True - activate: - inheritance_disable: True - local_preference: - value: 1 - as_prepends: - value: 2 + # Using Rendered + # ----------------- + # + - name: >- + Render platform specific configuration lines (without connecting to the + device) + cisco.iosxr.iosxr_bgp_global: + state: rendered + config: + as_number: 1 + default_metric: 4 + vrfs: + - vrf: vrf3 + bfd: + minimum_interval: 20 + multiplier: 10 + bgp: + fast_external_fallover: + disable: true + router_id: 1.2.3.4 + auto_policy_soft_reset: + disable: true + timers: + keepalive_time: 20 + holdtime: 30 + - vrf: vrf2 + bgp: + enforce_first_as: + disable: true + default_metric: 4 + neighbors: + - neighbor: 1.1.1.3 + remote_as: 2 + graceful_maintenance: + set: true + activate: + inheritance_disable: true + local_preference: + value: 1 + as_prepends: + value: 2 - # Task Output: - # ------------ # + # Task output + # ----------------------- # rendered: # - router bgp 1 # - default-metric 4 @@ -9638,14 +9644,13 @@ Examples # ! # - - name: Parse externally provided BGP config - cisco.iosxr.iosxr_bgp_global: - running_config: "{{ lookup('file', 'parsed.cfg') }}" - state: parsed + - name: Parse externally provided BGP config + cisco.iosxr.iosxr_bgp_global: + running_config: "{{ lookup('file', 'parsed.cfg') }}" + state: parsed - # Task Output: - # ------------ - # + # Task output + # ----------------------- # parsed: # as_number: '65536' # bgp: @@ -9699,9 +9704,9 @@ Examples # ! # ! - - name: Gather bgp global facts - cisco.iosxr.iosxr_bgp_global: - state: gathered + - name: Gather bgp global facts + cisco.iosxr.iosxr_bgp_global: + state: gathered # Task Output: # ------------ diff --git a/docs/cisco.iosxr.iosxr_bgp_neighbor_address_family_module.rst b/docs/cisco.iosxr.iosxr_bgp_neighbor_address_family_module.rst index 74e3b014b..271fa5ffb 100644 --- a/docs/cisco.iosxr.iosxr_bgp_neighbor_address_family_module.rst +++ b/docs/cisco.iosxr.iosxr_bgp_neighbor_address_family_module.rst @@ -3583,16 +3583,16 @@ Examples neighbors: - neighbor_address: 192.0.2.2 address_family: - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast multipath: true default_originate: set: true weight: 5 - neighbor_address: 192.0.2.3 address_family: - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast multipath: true default_originate: set: true @@ -3602,8 +3602,8 @@ Examples neighbors: - neighbor_address: 192.0.2.4 address_family: - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast multipath: true default_originate: set: true @@ -3612,8 +3612,8 @@ Examples neighbors: - neighbor_address: 192.0.2.5 address_family: - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast multipath: true default_originate: set: true @@ -3765,7 +3765,7 @@ Examples # capability orf prefix both # default-originate - - name: Delete the provided configuration + - name: Delete the provided configuration cisco.iosxr.iosxr_bgp_neighbor_address_family: state: deleted config: @@ -3773,8 +3773,8 @@ Examples neighbors: - neighbor_address: 192.0.2.2 address_family: - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast multipath: true default_originate: set: true @@ -3868,8 +3868,8 @@ Examples neighbors: - neighbor_address: 192.0.2.2 address_family: - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast default_originate: set: true weight: 4 @@ -3996,7 +3996,7 @@ Examples # capability orf prefix both # default-originate - - name: override the provided configuration + - name: override the provided configuration cisco.iosxr.iosxr_bgp_neighbor_address_family: state: overridden config: @@ -4004,8 +4004,8 @@ Examples neighbors: - neighbor_address: 192.0.2.2 address_family: - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast multipath: true default_originate: set: true @@ -4077,7 +4077,9 @@ Examples # neighbor 192.0.2.5 # remote-as 65540 - - name: Render platform specific configuration lines with state rendered (without connecting to the device) + - name: >- + Render platform specific configuration lines with state rendered (without + connecting to the device) cisco.iosxr.iosxr_bgp_neighbor_address_family: state: rendered config: @@ -4085,16 +4087,16 @@ Examples neighbors: - neighbor_address: 192.0.2.2 address_family: - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast multipath: true default_originate: set: true weight: 5 - neighbor_address: 192.0.2.3 address_family: - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast multipath: true default_originate: set: true @@ -4104,8 +4106,8 @@ Examples neighbors: - neighbor_address: 192.0.2.4 address_family: - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast multipath: true default_originate: set: true @@ -4114,8 +4116,8 @@ Examples neighbors: - neighbor_address: 192.0.2.5 address_family: - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast multipath: true default_originate: set: true @@ -4149,8 +4151,8 @@ Examples # # Using parsed # - #parsed.cfg - #------------ + # parsed.cfg + # ------------ # router bgp 65536 # bgp router-id 192.0.1.1 # address-family ipv4 unicast @@ -4232,8 +4234,8 @@ Examples # capability_orf_prefix: both # # - #Using Gathered - #----------------- + # Using Gathered + # ----------------- # Before state state: # ------------- # RP/0/0/CPU0:iosxr-02#show running-config router bgp @@ -4275,8 +4277,8 @@ Examples # - name: Gathered the provided configuration with the existing running configuration cisco.iosxr.iosxr_bgp_neighbor_address_family: - config: - state: gathered + config: + state: gathered # Task output diff --git a/docs/cisco.iosxr.iosxr_bgp_templates_module.rst b/docs/cisco.iosxr.iosxr_bgp_templates_module.rst index 3dbc6cae0..72440deaa 100644 --- a/docs/cisco.iosxr.iosxr_bgp_templates_module.rst +++ b/docs/cisco.iosxr.iosxr_bgp_templates_module.rst @@ -225,6 +225,10 @@ Parameters @@ -1419,6 +1423,10 @@ Parameters
  • unicast
  • labeled-unicast
  • sr-policy
  • +
  • link-state
  • +
  • evpn
  • +
  • mspw
  • +
  • vpls-vpws
  • @@ -4628,52 +4636,52 @@ Examples - name: Merge the provided configuration with the existing running configuration cisco.iosxr.iosxr_bgp_templates: config: - as_number: 65536 - neighbor: - - address_family: - - advertise: - local_labeled_route: - set: true - afi: ipv4 - safi: unicast - advertisement_interval: 10 - bfd: - fast_detect: - strict_mode: true - internal_vpn_client: true - name: neighbor-group1 - precedence: critical - - cluster_id: "1" - description: neighbor-group2 - dmz_link_bandwidth: - set: true - ebgp_multihop: - value: 255 - egress_engineering: - set: true - graceful_maintenance: - as_prepends: - value: 0 - set: true - ignore_connected_check: - set: true - internal_vpn_client: true - local: - address: - inheritance_disable: true - local_as: - value: 6 - name: neighbor-group2 - precedence: flash - receive_buffer_size: 512 - send_buffer_size: 4096 - session_open_mode: both - tcp: - mss: - inheritance_disable: true - ttl_security: - set: true - update_source: Loopback919 + as_number: 65536 + neighbor: + - address_family: + - advertise: + local_labeled_route: + set: true + afi: ipv4 + safi: unicast + advertisement_interval: 10 + bfd: + fast_detect: + strict_mode: true + internal_vpn_client: true + name: neighbor-group1 + precedence: critical + - cluster_id: '1' + description: neighbor-group2 + dmz_link_bandwidth: + set: true + ebgp_multihop: + value: 255 + egress_engineering: + set: true + graceful_maintenance: + as_prepends: + value: 0 + set: true + ignore_connected_check: + set: true + internal_vpn_client: true + local: + address: + inheritance_disable: true + local_as: + value: 6 + name: neighbor-group2 + precedence: flash + receive_buffer_size: 512 + send_buffer_size: 4096 + session_open_mode: both + tcp: + mss: + inheritance_disable: true + ttl_security: + set: true + update_source: Loopback919 state: merged # Task Output @@ -4833,29 +4841,29 @@ Examples - name: Replaced given bgp_templates configuration cisco.iosxr.iosxr_bgp_templates: - config: - as_number: 65536 - neighbor: - - address_family: - - advertise: - local_labeled_route: - set: true - afi: ipv4 - safi: unicast - advertisement_interval: 12 - name: neighbor-group1 - precedence: flash - - cluster_id: "2" - description: replace neighbor-group2 - ebgp_multihop: - value: 254 - graceful_maintenance: - as_prepends: - value: 2 - set: true - update_source: Loopback917 - name: neighbor-group2 - state: replaced + config: + as_number: 65536 + neighbor: + - address_family: + - advertise: + local_labeled_route: + set: true + afi: ipv4 + safi: unicast + advertisement_interval: 12 + name: neighbor-group1 + precedence: flash + - cluster_id: '2' + description: replace neighbor-group2 + ebgp_multihop: + value: 254 + graceful_maintenance: + as_prepends: + value: 2 + set: true + update_source: Loopback917 + name: neighbor-group2 + state: replaced # Task Output # ----------- @@ -5004,8 +5012,8 @@ Examples - name: Delete given bgp_nbr_address_family configuration cisco.iosxr.iosxr_bgp_templates: &deleted - config: - state: deleted + config: + state: deleted # Task Output # ----------- @@ -5045,8 +5053,6 @@ Examples # # RP/0/RP0/CPU0:10# - - # Using gathered # Before state: # ------------- @@ -5087,8 +5093,8 @@ Examples - name: Gather given bgp_templates configuration cisco.iosxr.iosxr_bgp_templates: &id001 - config: - state: gathered + config: + state: gathered # Task output # ----------- @@ -5179,25 +5185,24 @@ Examples # internal-vpn-client # ! # ! - - name: override given bgp_templates configuration cisco.iosxr.iosxr_bgp_templates: - config: - as_number: 65536 - neighbor: - - address_family: - - advertise: - local_labeled_route: - disable: true - afi: ipv4 - safi: unicast - advertisement_interval: 12 - bfd: - fast_detect: - strict_mode: true - name: neighbor-group1 - precedence: flash - state: overridden + config: + as_number: 65536 + neighbor: + - address_family: + - advertise: + local_labeled_route: + disable: true + afi: ipv4 + safi: unicast + advertisement_interval: 12 + bfd: + fast_detect: + strict_mode: true + name: neighbor-group1 + precedence: flash + state: overridden # Task Output # ----------- @@ -5276,7 +5281,9 @@ Examples # Using rendered - - name: Render platform specific configuration lines with state rendered (without connecting to the device) + - name: >- + Render platform specific configuration lines with state rendered (without + connecting to the device) cisco.iosxr.iosxr_bgp_templates: config: as_number: 65536 @@ -5294,7 +5301,7 @@ Examples internal_vpn_client: true name: neighbor-group1 precedence: critical - - cluster_id: "1" + - cluster_id: '1' description: neighbor-group2 dmz_link_bandwidth: set: true diff --git a/docs/cisco.iosxr.iosxr_command_module.rst b/docs/cisco.iosxr.iosxr_command_module.rst index 7d77a4e76..fa3db325e 100644 --- a/docs/cisco.iosxr.iosxr_command_module.rst +++ b/docs/cisco.iosxr.iosxr_command_module.rst @@ -153,32 +153,32 @@ Examples - name: run multiple commands on remote nodes cisco.iosxr.iosxr_command: commands: - - show version - - show interfaces - - {command: example command that prompts, prompt: expected prompt, answer: yes} + - show version + - show interfaces + - {command: example command that prompts, prompt: expected prompt, answer: true} - name: run multiple commands and evaluate the output cisco.iosxr.iosxr_command: commands: - - show version - - show interfaces + - show version + - show interfaces wait_for: - - result[0] contains IOS-XR - - result[1] contains Loopback0 + - result[0] contains IOS-XR + - result[1] contains Loopback0 - - name: multiple prompt, multiple answer (mandatory check for all prompts) + - name: 'multiple prompt, multiple answer (mandatory check for all prompts)' cisco.iosxr.iosxr_command: commands: - - command: key config-key password-encryption - prompt: - - "Enter old key :" - - "Enter new key :" - - "Enter confirm key :" - answer: - - "test1234" - - "test12345" - - "test12345" - check_all: true + - command: key config-key password-encryption + prompt: + - 'Enter old key :' + - 'Enter new key :' + - 'Enter confirm key :' + answer: + - test1234 + - test12345 + - test12345 + check_all: true diff --git a/docs/cisco.iosxr.iosxr_config_module.rst b/docs/cisco.iosxr.iosxr_config_module.rst index a358ac0ec..28c4c4b37 100644 --- a/docs/cisco.iosxr.iosxr_config_module.rst +++ b/docs/cisco.iosxr.iosxr_config_module.rst @@ -375,28 +375,26 @@ Examples - name: configure interface settings cisco.iosxr.iosxr_config: lines: - - description test interface - - ip address 172.31.1.1 255.255.255.0 + - description test interface + - ip address 172.31.1.1 255.255.255.0 parents: interface GigabitEthernet0/0/0/0 - name: load a config from disk and replace the current config cisco.iosxr.iosxr_config: src: config.cfg replace: config - backup: yes + backup: 'yes' - - name: for idempotency, use full-form commands + - name: 'for idempotency, use full-form commands' cisco.iosxr.iosxr_config: lines: - # - shut - - shutdown - # parents: int g0/0/0/1 + - shutdown parents: interface GigabitEthernet0/0/0/1 - name: configurable backup path cisco.iosxr.iosxr_config: src: config.cfg - backup: yes + backup: true backup_options: filename: backup.cfg dir_path: /home/user diff --git a/docs/cisco.iosxr.iosxr_facts_module.rst b/docs/cisco.iosxr.iosxr_facts_module.rst index 3525556d3..827a769bf 100644 --- a/docs/cisco.iosxr.iosxr_facts_module.rst +++ b/docs/cisco.iosxr.iosxr_facts_module.rst @@ -112,25 +112,25 @@ Examples # Collect only the config and default facts - cisco.iosxr.iosxr_facts: gather_subset: - - config + - config # Do not collect hardware facts - cisco.iosxr.iosxr_facts: gather_subset: - - '!hardware' + - '!hardware' # Collect only the lacp facts - cisco.iosxr.iosxr_facts: gather_subset: - - '!all' - - '!min' + - '!all' + - '!min' gather_network_resources: - - lacp + - lacp # Do not collect lacp_interfaces facts - cisco.iosxr.iosxr_facts: gather_network_resources: - - '!lacp_interfaces' + - '!lacp_interfaces' # Collect lacp and minimal default facts - cisco.iosxr.iosxr_facts: @@ -140,11 +140,11 @@ Examples # Collect only the interfaces facts - cisco.iosxr.iosxr_facts: gather_subset: - - '!all' - - '!min' + - '!all' + - '!min' gather_network_resources: - - interfaces - - l2_interfaces + - interfaces + - l2_interfaces @@ -381,7 +381,7 @@ Common return values are documented `here when interfaces is configured -
    The list of LLDP neighbors from the remote device
    +
    The list of LLDP and CDP neighbors from the remote device. If both, CDP and LLDP neighbor data is present on one port, CDP is preferred.

    diff --git a/docs/cisco.iosxr.iosxr_hostname_module.rst b/docs/cisco.iosxr.iosxr_hostname_module.rst index cd3855dc8..de7e0ed3a 100644 --- a/docs/cisco.iosxr.iosxr_hostname_module.rst +++ b/docs/cisco.iosxr.iosxr_hostname_module.rst @@ -133,9 +133,9 @@ Examples # Before state: # ------------- - #RP/0/RP0/CPU0:ios#show running-config hostname - #Thu Jan 20 19:48:56.011 UTC - #hostname ios + # RP/0/RP0/CPU0:ios#show running-config hostname + # Thu Jan 20 19:48:56.011 UTC + # hostname ios # Merged play: # ------------ @@ -156,7 +156,7 @@ Examples # ------------ # RP/0/0/CPU0:Router1#show running-config hostname - #Thu Jan 20 19:48:56.011 UTC + # Thu Jan 20 19:48:56.011 UTC # hostname Router1 @@ -165,7 +165,7 @@ Examples # ------------- # RP/0/0/CPU0:Router1#show running-config hostname - #Thu Jan 20 19:48:56.011 UTC + # Thu Jan 20 19:48:56.011 UTC # hostname Router1 # Deleted play: @@ -184,9 +184,9 @@ Examples # After state: # ------------ - #RP/0/RP0/CPU0:ios#show running-config hostname - #Thu Jan 20 19:55:12.971 UTC - #hostname ios + # RP/0/RP0/CPU0:ios#show running-config hostname + # Thu Jan 20 19:55:12.971 UTC + # hostname ios # Using state: overridden # Before state: @@ -213,17 +213,17 @@ Examples # After state: # ------------ - #RP/0/RP0/CPU0:RouterTest#show running-config hostname - #Thu Jan 20 19:48:56.011 UTC - #hostname RouterTest + # RP/0/RP0/CPU0:RouterTest#show running-config hostname + # Thu Jan 20 19:48:56.011 UTC + # hostname RouterTest # Using state: replaced # Before state: # ------------- - #RP/0/RP0/CPU0:RouterTest#show running-config hostname - #Thu Jan 20 19:48:56.011 UTC - #hostname RouterTest + # RP/0/RP0/CPU0:RouterTest#show running-config hostname + # Thu Jan 20 19:48:56.011 UTC + # hostname RouterTest # Replaced play: # -------------- @@ -247,9 +247,9 @@ Examples # Before state: # ------------- - #RP/0/RP0/CPU0:RouterTest#show running-config hostname - #Thu Jan 20 19:48:56.011 UTC - #hostname RouterTest + # RP/0/RP0/CPU0:RouterTest#show running-config hostname + # Thu Jan 20 19:48:56.011 UTC + # hostname RouterTest # Gathered play: # -------------- diff --git a/docs/cisco.iosxr.iosxr_interfaces_module.rst b/docs/cisco.iosxr.iosxr_interfaces_module.rst index 850fb77b3..cf82bc6e8 100644 --- a/docs/cisco.iosxr.iosxr_interfaces_module.rst +++ b/docs/cisco.iosxr.iosxr_interfaces_module.rst @@ -233,13 +233,13 @@ Examples - name: Configure Ethernet interfaces cisco.iosxr.iosxr_interfaces: config: - - name: GigabitEthernet0/0/0/2 - description: Configured by Ansible - enabled: true - - name: GigabitEthernet0/0/0/3 - description: Configured by Ansible Network - enabled: false - duplex: full + - name: GigabitEthernet0/0/0/2 + description: Configured by Ansible + enabled: true + - name: GigabitEthernet0/0/0/3 + description: Configured by Ansible Network + enabled: false + duplex: full state: merged # Task Output @@ -316,14 +316,14 @@ Examples - name: Replace their existing configuration per interface cisco.iosxr.iosxr_interfaces: config: - - name: GigabitEthernet0/0/0/2 - description: Configured by Ansible - enabled: true - mtu: 2000 - - name: GigabitEthernet0/0/0/3 - description: Configured by Ansible Network - enabled: false - duplex: auto + - name: GigabitEthernet0/0/0/2 + description: Configured by Ansible + enabled: true + mtu: 2000 + - name: GigabitEthernet0/0/0/3 + description: Configured by Ansible Network + enabled: false + duplex: auto state: replaced # Task Output @@ -407,14 +407,14 @@ Examples - name: Override interfaces configuration cisco.iosxr.iosxr_interfaces: config: - - name: GigabitEthernet0/0/0/2 - description: Configured by Ansible - enabled: true - duplex: auto - - name: GigabitEthernet0/0/0/3 - description: Configured by Ansible Network - enabled: false - speed: 1000 + - name: GigabitEthernet0/0/0/2 + description: Configured by Ansible + enabled: true + duplex: auto + - name: GigabitEthernet0/0/0/3 + description: Configured by Ansible Network + enabled: false + speed: 1000 state: overridden # Task Output @@ -494,8 +494,8 @@ Examples - name: Delete interfaces arguments cisco.iosxr.iosxr_interfaces: config: - - name: GigabitEthernet0/0/0/2 - - name: GigabitEthernet0/0/0/3 + - name: GigabitEthernet0/0/0/2 + - name: GigabitEthernet0/0/0/3 state: deleted # Task Output @@ -604,17 +604,17 @@ Examples - name: Render platform specific commands from task input using rendered state cisco.iosxr.iosxr_interfaces: config: - - name: GigabitEthernet0/0/0/0 - description: Configured and Merged by Ansible-Network - mtu: 110 - enabled: true - duplex: half - - name: GigabitEthernet0/0/0/1 - description: Configured and Merged by Ansible-Network - mtu: 2800 - enabled: false - speed: 100 - duplex: full + - name: GigabitEthernet0/0/0/0 + description: Configured and Merged by Ansible-Network + mtu: 110 + enabled: true + duplex: half + - name: GigabitEthernet0/0/0/1 + description: Configured and Merged by Ansible-Network + mtu: 2800 + enabled: false + speed: 100 + duplex: full state: rendered # Task Output diff --git a/docs/cisco.iosxr.iosxr_l2_interfaces_module.rst b/docs/cisco.iosxr.iosxr_l2_interfaces_module.rst index bfefedfea..bf19ac2f0 100644 --- a/docs/cisco.iosxr.iosxr_l2_interfaces_module.rst +++ b/docs/cisco.iosxr.iosxr_l2_interfaces_module.rst @@ -415,20 +415,21 @@ Examples - name: Merge provided configuration with device configuration cisco.iosxr.iosxr_l2_interfaces: config: - - name: GigabitEthernet0/0/0/3 - native_vlan: 20 - - name: GigabitEthernet0/0/0/4 - native_vlan: 40 - l2transport: true - l2protocol: - - stp: tunnel - - name: GigabitEthernet0/0/0/3.900 - l2transport: true - q_vlan: - - 20 - - 40 + - name: GigabitEthernet0/0/0/3 + native_vlan: 20 + - name: GigabitEthernet0/0/0/4 + native_vlan: 40 + l2transport: true + l2protocol: + - stp: tunnel + - name: GigabitEthernet0/0/0/3.900 + l2transport: true + q_vlan: + - 20 + - 40 state: merged + # After state: # ------------ # @@ -477,20 +478,23 @@ Examples # dot1q vlan 20 40 # ! - - name: Replaces device configuration of listed interfaces with provided configuration + - name: >- + Replaces device configuration of listed interfaces with provided + configuration cisco.iosxr.iosxr_l2_interfaces: config: - - name: GigabitEthernet0/0/0/4 - native_vlan: 40 - l2transport: true - l2protocol: - - stp: forward - - name: GigabitEthernet0/0/0/3.900 - q_vlan: - - 20 - - any + - name: GigabitEthernet0/0/0/4 + native_vlan: 40 + l2transport: true + l2protocol: + - stp: forward + - name: GigabitEthernet0/0/0/3.900 + q_vlan: + - 20 + - any state: replaced + # After state: # ------------- # @@ -542,17 +546,18 @@ Examples - name: Override device configuration of all interfaces with provided configuration cisco.iosxr.iosxr_l2_interfaces: config: - - name: GigabitEthernet0/0/0/4 - native_vlan: 40 - l2transport: true - l2protocol: - - stp: forward - - name: GigabitEthernet0/0/0/3.900 - q_vlan: - - 20 - - any + - name: GigabitEthernet0/0/0/4 + native_vlan: 40 + l2transport: true + l2protocol: + - stp: forward + - name: GigabitEthernet0/0/0/3.900 + q_vlan: + - 20 + - any state: overridden + # After state: # ------------- # @@ -601,7 +606,7 @@ Examples - name: "Delete L2 attributes of given interfaces (Note: This won't delete the interface itself)" cisco.iosxr.iosxr_l2_interfaces: config: - - name: GigabitEthernet0/0/0/4 + - name: GigabitEthernet0/0/0/4 state: deleted # After state: @@ -743,25 +748,21 @@ Examples - name: Render platform specific commands from task input using rendered state cisco.iosxr.iosxr_l2_interfaces: config: - - - name: GigabitEthernet0/0/0/1 - native_vlan: 10 - l2transport: true - l2protocol: - - - pvst: tunnel - - - cdp: forward - propagate: true - - - name: GigabitEthernet0/0/0/3.900 - q_vlan: - - 20 - - 40 - - - name: GigabitEthernet0/0/0/4 - native_vlan: 40 + - name: GigabitEthernet0/0/0/1 + native_vlan: 10 + l2transport: true + l2protocol: + - pvst: tunnel + - cdp: forward + propagate: true + - name: GigabitEthernet0/0/0/3.900 + q_vlan: + - 20 + - 40 + - name: GigabitEthernet0/0/0/4 + native_vlan: 40 state: rendered + # Task Output (redacted) # ----------------------- # "rendered": [ diff --git a/docs/cisco.iosxr.iosxr_l3_interfaces_module.rst b/docs/cisco.iosxr.iosxr_l3_interfaces_module.rst index 531553106..b57c413a1 100644 --- a/docs/cisco.iosxr.iosxr_l3_interfaces_module.rst +++ b/docs/cisco.iosxr.iosxr_l3_interfaces_module.rst @@ -239,13 +239,13 @@ Examples - name: Merge provided configuration with device configuration cisco.iosxr.iosxr_l3_interfaces: config: - - name: GigabitEthernet0/0/0/2 - ipv4: - - address: 192.168.0.1/24 - - name: GigabitEthernet0/0/0/3 - ipv4: - - address: 192.168.2.1/24 - secondary: true + - name: GigabitEthernet0/0/0/2 + ipv4: + - address: 192.168.0.1/24 + - name: GigabitEthernet0/0/0/3 + ipv4: + - address: 192.168.2.1/24 + secondary: true state: merged # Task Output @@ -313,13 +313,14 @@ Examples - name: Override device configuration of all interfaces with provided configuration cisco.iosxr.iosxr_l3_interfaces: config: - - name: GigabitEthernet0/0/0/3 - ipv4: - - address: 192.168.0.2/24 - - address: 192.168.2.1/24 - secondary: true + - name: GigabitEthernet0/0/0/3 + ipv4: + - address: 192.168.0.2/24 + - address: 192.168.2.1/24 + secondary: true state: overridden + # Task Output # ----------- # @@ -387,17 +388,20 @@ Examples # ipv4 address 192.168.2.1 255.255.255.0 secondary # ! - - name: Replaces device configuration of listed interfaces with provided configuration + - name: >- + Replaces device configuration of listed interfaces with provided + configuration cisco.iosxr.iosxr_l3_interfaces: config: - - name: GigabitEthernet0/0/0/3 - ipv6: - - address: fd5d:12c9:2201:1::1/64 - - name: GigabitEthernet0/0/0/2 - ipv4: - - address: 192.168.0.2/24 + - name: GigabitEthernet0/0/0/3 + ipv6: + - address: 'fd5d:12c9:2201:1::1/64' + - name: GigabitEthernet0/0/0/2 + ipv4: + - address: 192.168.0.2/24 state: replaced + # Task Output # ----------- # @@ -464,14 +468,15 @@ Examples # ipv6 address fd5d:12c9:2201:1::1/64 # ! - - name: "Delete attributes for interfaces (This won't delete the interface itself)" + - name: Delete attributes for interfaces (This won't delete the interface itself) cisco.iosxr.iosxr_l3_interfaces: config: - - name: GigabitEthernet0/0/0/3 - - name: GigabitEthernet0/0/0/4 - - name: GigabitEthernet0/0/0/3.700 + - name: GigabitEthernet0/0/0/3 + - name: GigabitEthernet0/0/0/4 + - name: GigabitEthernet0/0/0/3.700 state: deleted + # Task Output # ----------- # @@ -543,7 +548,7 @@ Examples # interface preconfigure GigabitEthernet0/0/0/4 # ipv6 address fd5d:12c9:2201:1::1/64 # shutdown - #! + # ! - name: "Delete L3 config of all interfaces (This won't delete the interface itself)" cisco.iosxr.iosxr_l3_interfaces: @@ -681,18 +686,19 @@ Examples - name: Render platform specific commands from task input using rendered state cisco.iosxr.iosxr_l3_interfaces: config: - - name: GigabitEthernet0/0/0/0 - ipv4: - - address: 198.51.100.1/24 - - name: GigabitEthernet0/0/0/1 - ipv6: - - address: 2001:db8:0:3::/64 - ipv4: - - address: 192.0.2.1/24 - - address: 192.0.2.2/24 - secondary: true + - name: GigabitEthernet0/0/0/0 + ipv4: + - address: 198.51.100.1/24 + - name: GigabitEthernet0/0/0/1 + ipv6: + - address: '2001:db8:0:3::/64' + ipv4: + - address: 192.0.2.1/24 + - address: 192.0.2.2/24 + secondary: true state: rendered + # Task Output # ----------- # diff --git a/docs/cisco.iosxr.iosxr_lacp_interfaces_module.rst b/docs/cisco.iosxr.iosxr_lacp_interfaces_module.rst index 1defd59d6..ca81c7281 100644 --- a/docs/cisco.iosxr.iosxr_lacp_interfaces_module.rst +++ b/docs/cisco.iosxr.iosxr_lacp_interfaces_module.rst @@ -297,19 +297,18 @@ Examples - name: Merge provided configuration with device configuration cisco.iosxr.iosxr_lacp_interfaces: config: - - name: Bundle-Ether10 - churn_logging: actor - collector_max_delay: 100 - switchover_suppress_flaps: 500 - - - name: Bundle-Ether11 - system: - mac: 00c2.4c00.bd15 - - - name: GigabitEthernet0/0/0/1 - period: 200 + - name: Bundle-Ether10 + churn_logging: actor + collector_max_delay: 100 + switchover_suppress_flaps: 500 + - name: Bundle-Ether11 + system: + mac: 00c2.4c00.bd15 + - name: GigabitEthernet0/0/0/1 + period: 200 state: merged + # # # ----------- @@ -397,13 +396,13 @@ Examples - name: Replace LACP configuration of listed interfaces with provided configuration cisco.iosxr.iosxr_lacp_interfaces: config: - - name: Bundle-Ether10 - churn_logging: partner - - - name: GigabitEthernet0/0/0/2 - period: 300 + - name: Bundle-Ether10 + churn_logging: partner + - name: GigabitEthernet0/0/0/2 + period: 300 state: replaced + # # # ----------- @@ -493,15 +492,15 @@ Examples - name: Override all interface LACP configuration with provided configuration cisco.iosxr.iosxr_lacp_interfaces: config: - - name: Bundle-Ether12 - churn_logging: both - collector_max_delay: 100 - switchover_suppress_flaps: 500 - - - name: GigabitEthernet0/0/0/1 - period: 300 + - name: Bundle-Ether12 + churn_logging: both + collector_max_delay: 100 + switchover_suppress_flaps: 500 + - name: GigabitEthernet0/0/0/1 + period: 300 state: overridden + # # # ----------- @@ -586,16 +585,18 @@ Examples # ! # - - name: Deleted LACP configurations of provided interfaces (Note - This won't delete + - name: >- + Deleted LACP configurations of provided interfaces (Note - This won't delete the interface itself) cisco.iosxr.iosxr_lacp_interfaces: config: - - name: Bundle-Ether10 - - name: Bundle-Ether11 - - name: GigabitEthernet0/0/0/1 - - name: GigabitEthernet0/0/0/2 + - name: Bundle-Ether10 + - name: Bundle-Ether11 + - name: GigabitEthernet0/0/0/1 + - name: GigabitEthernet0/0/0/2 state: deleted + # # # ----------- @@ -691,19 +692,18 @@ Examples - name: Render platform specific commands from task input using rendered state cisco.iosxr.iosxr_lacp_interfaces: config: - - name: Bundle-Ether10 - churn_logging: actor - collector_max_delay: 100 - switchover_suppress_flaps: 500 - - - name: Bundle-Ether11 - system: - mac: 00c2.4c00.bd15 - - - name: GigabitEthernet0/0/0/1 - period: 200 + - name: Bundle-Ether10 + churn_logging: actor + collector_max_delay: 100 + switchover_suppress_flaps: 500 + - name: Bundle-Ether11 + system: + mac: 00c2.4c00.bd15 + - name: GigabitEthernet0/0/0/1 + period: 200 state: rendered + # ------------- # Output # ------------- diff --git a/docs/cisco.iosxr.iosxr_lag_interfaces_module.rst b/docs/cisco.iosxr.iosxr_lag_interfaces_module.rst index 8d4cda1a3..8950db1b9 100644 --- a/docs/cisco.iosxr.iosxr_lag_interfaces_module.rst +++ b/docs/cisco.iosxr.iosxr_lag_interfaces_module.rst @@ -319,26 +319,26 @@ Examples - name: Merge provided configuration with device configuration cisco.iosxr.iosxr_lag_interfaces: config: - - name: Bundle-Ether10 - members: - - member: GigabitEthernet0/0/0/1 - mode: inherit - - member: GigabitEthernet0/0/0/3 - mode: inherit - mode: active - links: - max_active: 5 - min_active: 2 - load_balancing_hash: src-ip - - - name: Bundle-Ether12 - members: - - member: GigabitEthernet0/0/0/2 - mode: passive - - member: GigabitEthernet0/0/0/4 - mode: passive - load_balancing_hash: dst-ip + - name: Bundle-Ether10 + members: + - member: GigabitEthernet0/0/0/1 + mode: inherit + - member: GigabitEthernet0/0/0/3 + mode: inherit + mode: active + links: + max_active: 5 + min_active: 2 + load_balancing_hash: src-ip + - name: Bundle-Ether12 + members: + - member: GigabitEthernet0/0/0/2 + mode: passive + - member: GigabitEthernet0/0/0/4 + mode: passive + load_balancing_hash: dst-ip state: merged + # # # ----------- @@ -429,15 +429,14 @@ Examples - name: Replace device configuration of listed Bundles with provided configurations cisco.iosxr.iosxr_lag_interfaces: config: - - name: Bundle-Ether12 - members: - - name: GigabitEthernet0/0/0/2 - mode: passive - - - name: Bundle-Ether11 - members: - - name: GigabitEthernet0/0/0/4 - load_balancing_hash: src-ip + - name: Bundle-Ether12 + members: + - name: GigabitEthernet0/0/0/2 + mode: passive + - name: Bundle-Ether11 + members: + - name: GigabitEthernet0/0/0/4 + load_balancing_hash: src-ip state: replaced # # @@ -538,15 +537,16 @@ Examples - name: Overrides all device configuration with provided configuration cisco.iosxr.iosxr_lag_interfaces: config: - - name: Bundle-Ether10 - members: - - member: GigabitEthernet0/0/0/1 - mode: inherit - - member: GigabitEthernet0/0/0/2 - mode: inherit - mode: active - load_balancing_hash: dst-ip + - name: Bundle-Ether10 + members: + - member: GigabitEthernet0/0/0/1 + mode: inherit + - member: GigabitEthernet0/0/0/2 + mode: inherit + mode: active + load_balancing_hash: dst-ip state: overridden + # # # ------------ @@ -636,15 +636,17 @@ Examples # # - - name: Delete attributes of given bundles and removes member interfaces from them + - name: >- + Delete attributes of given bundles and removes member interfaces from them (Note - This won't delete the bundles themselves) cisco.iosxr.iosxr_lag_interfaces: config: - - name: Bundle-Ether10 - - name: Bundle-Ether11 - - name: Bundle-Ether12 + - name: Bundle-Ether10 + - name: Bundle-Ether11 + - name: Bundle-Ether12 state: deleted + # # # ------------ @@ -898,25 +900,24 @@ Examples - name: Render platform specific commands from task input using rendered state cisco.iosxr.iosxr_lag_interfaces: config: - - name: Bundle-Ether10 - members: - - member: GigabitEthernet0/0/0/1 - mode: inherit - - member: GigabitEthernet0/0/0/3 - mode: inherit - mode: active - links: - max_active: 5 - min_active: 2 - load_balancing_hash: src-ip - - - name: Bundle-Ether12 - members: - - member: GigabitEthernet0/0/0/2 - mode: passive - - member: GigabitEthernet0/0/0/4 - mode: passive - load_balancing_hash: dst-ip + - name: Bundle-Ether10 + members: + - member: GigabitEthernet0/0/0/1 + mode: inherit + - member: GigabitEthernet0/0/0/3 + mode: inherit + mode: active + links: + max_active: 5 + min_active: 2 + load_balancing_hash: src-ip + - name: Bundle-Ether12 + members: + - member: GigabitEthernet0/0/0/2 + mode: passive + - member: GigabitEthernet0/0/0/4 + mode: passive + load_balancing_hash: dst-ip state: rendered # Output: @@ -949,7 +950,6 @@ Examples # - " bundle id 12 mode passive" # ] # - # diff --git a/docs/cisco.iosxr.iosxr_lldp_interfaces_module.rst b/docs/cisco.iosxr.iosxr_lldp_interfaces_module.rst index 3fb795717..70892cf6e 100644 --- a/docs/cisco.iosxr.iosxr_lldp_interfaces_module.rst +++ b/docs/cisco.iosxr.iosxr_lldp_interfaces_module.rst @@ -225,17 +225,17 @@ Examples - name: Merge provided configuration with running configuration cisco.iosxr.iosxr_lldp_interfaces: config: - - name: GigabitEthernet0/0/0/1 - destination: - mac_address: ieee-nearest-non-tmpr-bridge - transmit: false - - - name: GigabitEthernet0/0/0/2 - destination: - mac_address: ieee-nearest-bridge - receive: false + - name: GigabitEthernet0/0/0/1 + destination: + mac_address: ieee-nearest-non-tmpr-bridge + transmit: false + - name: GigabitEthernet0/0/0/2 + destination: + mac_address: ieee-nearest-bridge + receive: false state: merged + # # # ------------------------ @@ -347,15 +347,17 @@ Examples # # - - name: Replace existing LLDP configurations of specified interfaces with provided + - name: >- + Replace existing LLDP configurations of specified interfaces with provided configuration cisco.iosxr.iosxr_lldp_interfaces: config: - - name: GigabitEthernet0/0/0/1 - destination: - mac_address: ieee-nearest-non-tmpr-bridge + - name: GigabitEthernet0/0/0/1 + destination: + mac_address: ieee-nearest-non-tmpr-bridge state: replaced + # # # ------------------------ @@ -471,13 +473,16 @@ Examples # # - - name: Override the LLDP configurations of all the interfaces with provided configurations + - name: >- + Override the LLDP configurations of all the interfaces with provided + configurations cisco.iosxr.iosxr_lldp_interfaces: config: - - name: GigabitEthernet0/0/0/1 - transmit: false + - name: GigabitEthernet0/0/0/1 + transmit: false state: overridden + # # # ------------------------ @@ -743,17 +748,15 @@ Examples - name: Render platform specific commands from task input using rendered state cisco.iosxr.iosxr_lldp_interfaces: config: - - name: GigabitEthernet0/0/0/1 - destination: - mac_address: ieee-nearest-non-tmpr-bridge - transmit: false - - - name: GigabitEthernet0/0/0/2 - destination: - mac_address: ieee-nearest-bridge - receive: false + - name: GigabitEthernet0/0/0/1 + destination: + mac_address: ieee-nearest-non-tmpr-bridge + transmit: false + - name: GigabitEthernet0/0/0/2 + destination: + mac_address: ieee-nearest-bridge + receive: false state: rendered - # ------------------------ # Module Execution Result # ------------------------ diff --git a/docs/cisco.iosxr.iosxr_logging_global_module.rst b/docs/cisco.iosxr.iosxr_logging_global_module.rst index 872434004..c0dd4be33 100644 --- a/docs/cisco.iosxr.iosxr_logging_global_module.rst +++ b/docs/cisco.iosxr.iosxr_logging_global_module.rst @@ -1764,56 +1764,56 @@ Examples .. code-block:: yaml # Using merged - #----------------- + # ----------------- # Before state - #RP/0/0/CPU0:10#show running-config logging - #Thu Feb 4 09:38:36.245 UTC - #% No such configuration item(s) - #RP/0/0/CPU0:10# + # RP/0/0/CPU0:10#show running-config logging + # Thu Feb 4 09:38:36.245 UTC + # % No such configuration item(s) + # RP/0/0/CPU0:10# # # - name: Merge the provided configuration with the existing running configuration cisco.iosxr.iosxr_logging_global: - config: - buffered: - size: 2097152 - severity: warnings - correlator: - buffer_size: 1024 - events: - display_location: True - files: - - maxfilesize: '1024' - name: test - path: test - severity: info - hostnameprefix: test - hosts: - - host: 1.1.1.1 - port: default - severity: critical - vrf: default - ipv4: - dscp: af11 - localfilesize: 1024 - monitor: - severity: errors - source_interfaces: - - interface: GigabitEthernet0/0/0/0 - vrf: test - tls_servers: - - name: test - tls_hostname: test2 - trustpoint: test2 - vrf: test - trap: - severity: informational - state: merged + config: + buffered: + size: 2097152 + severity: warnings + correlator: + buffer_size: 1024 + events: + display_location: true + files: + - maxfilesize: '1024' + name: test + path: test + severity: info + hostnameprefix: test + hosts: + - host: 1.1.1.1 + port: default + severity: critical + vrf: default + ipv4: + dscp: af11 + localfilesize: 1024 + monitor: + severity: errors + source_interfaces: + - interface: GigabitEthernet0/0/0/0 + vrf: test + tls_servers: + - name: test + tls_hostname: test2 + trustpoint: test2 + vrf: test + trap: + severity: informational + state: merged # # # After state: - #------------------------------------------- - #RP/0/0/CPU0:10#show running-config logging + # ------------------------------------------- + # RP/0/0/CPU0:10#show running-config logging # Tue Jul 20 18:09:18.491 UTC # logging tls-server test # vrf test @@ -1832,8 +1832,8 @@ Examples # logging localfilesize 1024 # logging source-interface GigabitEthernet0/0/0/0 vrf test # logging hostnameprefix test - #------------------------------------------------ - #Module execution + # ------------------------------------------------ + # Module execution # # "after": { # "buffered": { @@ -1982,8 +1982,8 @@ Examples # Using replaced: # ----------------------------------------------------------- # - #Before state - #RP/0/0/CPU0:10#show running-config logging + # Before state + # RP/0/0/CPU0:10#show running-config logging # Tue Jul 20 18:09:18.491 UTC # logging tls-server test # vrf test @@ -2002,42 +2002,42 @@ Examples # logging localfilesize 1024 # logging source-interface GigabitEthernet0/0/0/0 vrf test # logging hostnameprefix test - #----------------------------------------------------------- + # ----------------------------------------------------------- # - name: Replace BGP configuration with provided configuration cisco.iosxr.iosxr_logging_global: - state: replaced - config: - buffered: - severity: errors - correlator: - buffer_size: 1024 - files: - - maxfilesize: '1024' - name: test - path: test1 - severity: info - hostnameprefix: test1 - hosts: - - host: 1.1.1.3 - port: default - severity: critical - vrf: default - ipv6: - dscp: af11 - localfilesize: 1024 - monitor: - severity: errors - tls_servers: - - name: test - tls_hostname: test2 - trustpoint: test - vrf: test - trap: - severity: critical + state: replaced + config: + buffered: + severity: errors + correlator: + buffer_size: 1024 + files: + - maxfilesize: '1024' + name: test + path: test1 + severity: info + hostnameprefix: test1 + hosts: + - host: 1.1.1.3 + port: default + severity: critical + vrf: default + ipv6: + dscp: af11 + localfilesize: 1024 + monitor: + severity: errors + tls_servers: + - name: test + tls_hostname: test2 + trustpoint: test + vrf: test + trap: + severity: critical # # After state: - #RP/0/0/CPU0:10#show running-config logging + # RP/0/0/CPU0:10#show running-config logging # Tue Jul 20 18:31:51.709 UTC # logging tls-server test # vrf test @@ -2053,7 +2053,7 @@ Examples # logging correlator buffer-size 1024 # logging localfilesize 1024 # logging hostnameprefix test1 - #----------------------------------------------------------------- + # ----------------------------------------------------------------- # # Module Execution: # "after": { @@ -2173,7 +2173,7 @@ Examples # Using deleted: # ----------------------------------------------------------- # Before state: - #RP/0/0/CPU0:10#show running-config logging + # RP/0/0/CPU0:10#show running-config logging # Tue Jul 20 18:09:18.491 UTC # logging tls-server test # vrf test @@ -2193,15 +2193,15 @@ Examples # logging source-interface GigabitEthernet0/0/0/0 vrf test # logging hostnameprefix test # - #----------------------------------------------------------- + # ----------------------------------------------------------- - name: Delete given logging_global configuration cisco.iosxr.iosxr_logging_global: - state: deleted + state: deleted # # After state: - #RP/0/0/CPU0:10#show running-config + # RP/0/0/CPU0:10#show running-config # - #------------------------------------------------------------- + # ------------------------------------------------------------- # Module Execution: # # "after": {}, @@ -2287,7 +2287,7 @@ Examples # using gathered: # ------------------------------------------------------------ # Before state: - #RP/0/0/CPU0:10#show running-config logging + # RP/0/0/CPU0:10#show running-config logging # Tue Jul 20 18:09:18.491 UTC # logging tls-server test # vrf test @@ -2310,9 +2310,9 @@ Examples # - name: Gather iosxr_logging_global facts using gathered state cisco.iosxr.iosxr_logging_global: - state: gathered + state: gathered # - #------------------------------------------------------------- + # ------------------------------------------------------------- # Module Execution: # # "changed": false, @@ -2379,7 +2379,7 @@ Examples # # # Using parsed: - #--------------------------------------------------------------- + # --------------------------------------------------------------- # # parsed.cfg # @@ -2404,9 +2404,9 @@ Examples # - name: Parse externally provided Logging global config to agnostic model cisco.iosxr.iosxr_logging_global: - running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}" - state: parsed - #---------------------------------------------------------------- + running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}" + state: parsed + # ---------------------------------------------------------------- # Module execution: # "changed": false, # "parsed": { @@ -2466,44 +2466,46 @@ Examples # # Using rendered: # ---------------------------------------------------------------------------- - - name: Render platform specific configuration lines with state rendered (without connecting to the device) + - name: >- + Render platform specific configuration lines with state rendered (without + connecting to the device) cisco.iosxr.iosxr_logging_global: - state: rendered - config: - buffered: - size: 2097152 - severity: warnings - correlator: - buffer_size: 1024 - events: - display_location: True - files: - - maxfilesize: '1024' - name: test - path: test - severity: info - hostnameprefix: test - hosts: - - host: 1.1.1.1 - port: default - severity: critical - vrf: default - ipv4: - dscp: af11 - localfilesize: 1024 - monitor: - severity: errors - source_interfaces: - - interface: GigabitEthernet0/0/0/0 - vrf: test - tls_servers: - - name: test - tls_hostname: test2 - trustpoint: test2 - vrf: test - trap: - severity: informational - #---------------------------------------------------------------- + state: rendered + config: + buffered: + size: 2097152 + severity: warnings + correlator: + buffer_size: 1024 + events: + display_location: true + files: + - maxfilesize: '1024' + name: test + path: test + severity: info + hostnameprefix: test + hosts: + - host: 1.1.1.1 + port: default + severity: critical + vrf: default + ipv4: + dscp: af11 + localfilesize: 1024 + monitor: + severity: errors + source_interfaces: + - interface: GigabitEthernet0/0/0/0 + vrf: test + tls_servers: + - name: test + tls_hostname: test2 + trustpoint: test2 + vrf: test + trap: + severity: informational + # ---------------------------------------------------------------- # Module Execution: # "rendered": [ # "logging buffered errors", @@ -2526,7 +2528,7 @@ Examples # Using overridden: # --------------------------------------------------------------------------------- # Before state: - #RP/0/0/CPU0:10#show running-config logging + # RP/0/0/CPU0:10#show running-config logging # Tue Jul 20 18:09:18.491 UTC # logging tls-server test # vrf test @@ -2546,42 +2548,42 @@ Examples # logging source-interface GigabitEthernet0/0/0/0 vrf test # logging hostnameprefix test # - #----------------------------------------------------------- + # ----------------------------------------------------------- # - name: Overridde logging global configuration with provided configuration cisco.iosxr.iosxr_logging_global: - state: overridden - config: - buffered: - severity: errors - correlator: - buffer_size: 1024 - files: - - maxfilesize: '1024' - name: test - path: test1 - severity: info - hostnameprefix: test1 - hosts: - - host: 1.1.1.3 - port: default - severity: critical - vrf: default - ipv6: - dscp: af11 - localfilesize: 1024 - monitor: - severity: errors - tls_servers: - - name: test - tls_hostname: test2 - trustpoint: test - vrf: test - trap: - severity: critical + state: overridden + config: + buffered: + severity: errors + correlator: + buffer_size: 1024 + files: + - maxfilesize: '1024' + name: test + path: test1 + severity: info + hostnameprefix: test1 + hosts: + - host: 1.1.1.3 + port: default + severity: critical + vrf: default + ipv6: + dscp: af11 + localfilesize: 1024 + monitor: + severity: errors + tls_servers: + - name: test + tls_hostname: test2 + trustpoint: test + vrf: test + trap: + severity: critical # # After state: - #RP/0/0/CPU0:10#show running-config logging + # RP/0/0/CPU0:10#show running-config logging # Tue Jul 20 18:31:51.709 UTC # logging tls-server test # vrf test @@ -2597,7 +2599,7 @@ Examples # logging correlator buffer-size 1024 # logging localfilesize 1024 # logging hostnameprefix test1 - #----------------------------------------------------------------- + # ----------------------------------------------------------------- # # Module Execution: # "after": { diff --git a/docs/cisco.iosxr.iosxr_logging_module.rst b/docs/cisco.iosxr.iosxr_logging_module.rst deleted file mode 100644 index 58e73d977..000000000 --- a/docs/cisco.iosxr.iosxr_logging_module.rst +++ /dev/null @@ -1,538 +0,0 @@ -.. _cisco.iosxr.iosxr_logging_module: - - -************************* -cisco.iosxr.iosxr_logging -************************* - -**(deprecated, removed after 2023-08-01) Configuration management of system logging services on network devices** - - -Version added: 1.0.0 - -.. contents:: - :local: - :depth: 1 - -DEPRECATED ----------- -:Removed in collection release after 2023-08-01 -:Why: Updated module released with more functionality. -:Alternative: iosxr_logging_global - - - -Synopsis --------- -- This module provides declarative management configuration of system logging (syslog) on Cisco IOS XR devices. - - - -Requirements ------------- -The below requirements are needed on the host that executes this module. - -- ncclient >= 0.5.3 when using netconf -- lxml >= 4.1.1 when using netconf - - -Parameters ----------- - -.. raw:: html - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ParameterChoices/DefaultsComments
    -
    - aggregate - -
    - list - / elements=dictionary -
    -
    - -
    List of syslog logging configuration definitions.
    -
    -
    - dest - -
    - string -
    -
    -
      Choices: -
    • host
    • -
    • console
    • -
    • monitor
    • -
    • buffered
    • -
    • file
    • -
    -
    -
    Destination for system logging (syslog) messages.
    -
    -
    - facility - -
    - string -
    -
    - -
    To configure the type of syslog facility in which system logging (syslog) messages are sent to syslog servers Optional config for dest = host
    -
    -
    - hostnameprefix - -
    - string -
    -
    - -
    To append a hostname prefix to system logging (syslog) messages logged to syslog servers. Optional config for dest = host
    -
    -
    - level - -
    - string -
    -
    -
      Choices: -
    • emergencies
    • -
    • alerts
    • -
    • critical
    • -
    • errors
    • -
    • warning
    • -
    • notifications
    • -
    • informational
    • -
    • debugging
    • -
    -
    -
    Specifies the severity level for the logging.
    -

    aliases: severity
    -
    -
    - name - -
    - string -
    -
    - -
    When dest = file name indicates file-name
    -
    When dest = host name indicates the host-name or ip-address of syslog server.
    -
    -
    - path - -
    - string -
    -
    - -
    Set file path.
    -
    -
    - size - -
    - integer -
    -
    - -
    Size of buffer when dest = buffered. The acceptable value is in the range 307200 to 125000000 bytes. Default 307200
    -
    Size of file when dest = file. The acceptable value is in the range 1 to 2097152KB. Default 2 GB
    -
    -
    - state - -
    - string -
    -
    -
      Choices: -
    • present
    • -
    • absent
    • -
    -
    -
    Existential state of the logging configuration on the node.
    -
    -
    - vrf - -
    - string -
    -
    - -
    vrf name when syslog server is configured, dest = host
    -
    -
    - dest - -
    - string -
    -
    -
      Choices: -
    • host
    • -
    • console
    • -
    • monitor
    • -
    • buffered
    • -
    • file
    • -
    -
    -
    Destination for system logging (syslog) messages.
    -
    -
    - facility - -
    - string -
    -
    - Default:
    "local7"
    -
    -
    To configure the type of syslog facility in which system logging (syslog) messages are sent to syslog servers Optional config for dest = host
    -
    -
    - hostnameprefix - -
    - string -
    -
    - -
    To append a hostname prefix to system logging (syslog) messages logged to syslog servers. Optional config for dest = host
    -
    -
    - level - -
    - string -
    -
    -
      Choices: -
    • emergencies
    • -
    • alerts
    • -
    • critical
    • -
    • errors
    • -
    • warning
    • -
    • notifications
    • -
    • informational
    • -
    • debugging ←
    • -
    -
    -
    Specifies the severity level for the logging.
    -

    aliases: severity
    -
    -
    - name - -
    - string -
    -
    - -
    When dest = file name indicates file-name
    -
    When dest = host name indicates the host-name or ip-address of syslog server.
    -
    -
    - path - -
    - string -
    -
    - -
    Set file path.
    -
    -
    - size - -
    - integer -
    -
    - -
    Size of buffer when dest = buffered. The acceptable value is in the range 307200 to 125000000 bytes. Default 307200
    -
    Size of file when dest = file. The acceptable value is in the range 1 to 2097152KB. Default 2 GB
    -
    -
    - state - -
    - string -
    -
    -
      Choices: -
    • present ←
    • -
    • absent
    • -
    -
    -
    Existential state of the logging configuration on the node.
    -
    -
    - vrf - -
    - string -
    -
    - Default:
    "default"
    -
    -
    vrf name when syslog server is configured, dest = host
    -
    -
    - - -Notes ------ - -.. note:: - - This module works with connection ``network_cli`` and ``netconf``. See `the IOS-XR Platform Options <../network/user_guide/platform_iosxr.html>`_. - - For more information on using Ansible to manage network devices see the :ref:`Ansible Network Guide ` - - For more information on using Ansible to manage Cisco devices see the `Cisco integration page `_. - - - -Examples --------- - -.. code-block:: yaml - - - name: configure logging for syslog server host - cisco.iosxr.iosxr_logging: - dest: host - name: 10.10.10.1 - level: critical - state: present - - - name: add hostnameprefix configuration - cisco.iosxr.iosxr_logging: - hostnameprefix: host1 - state: absent - - - name: add facility configuration - cisco.iosxr.iosxr_logging: - facility: local1 - state: present - - - name: configure console logging level - cisco.iosxr.iosxr_logging: - dest: console - level: debugging - state: present - - - name: configure monitor logging level - cisco.iosxr.iosxr_logging: - dest: monitor - level: errors - state: present - - - name: configure syslog to a file - cisco.iosxr.iosxr_logging: - dest: file - name: file_name - size: 2048 - level: errors - state: present - - - name: configure buffered logging with size - cisco.iosxr.iosxr_logging: - dest: buffered - size: 5100000 - - - name: Configure logging using aggregate - cisco.iosxr.iosxr_logging: - aggregate: - - {dest: console, level: warning} - - {dest: buffered, size: 4800000} - - {dest: file, name: file3, size: 2048} - - {dest: host, name: host3, level: critical} - - - name: Delete logging using aggregate - cisco.iosxr.iosxr_logging: - aggregate: - - {dest: console, level: warning} - - {dest: buffered, size: 4800000} - - {dest: file, name: file3, size: 2048} - - {dest: host, name: host3, level: critical} - state: absent - - - -Return Values -------------- -Common return values are documented `here `_, the following are the fields unique to this module: - -.. raw:: html - - - - - - - - - - - - - - - - - -
    KeyReturnedDescription
    -
    - commands - -
    - list -
    -
    always (empty list when no commands to send) -
    The list of configuration mode commands to send to the device
    -
    -
    Sample:
    -
    ['logging 10.10.10.1 vrf default severity debugging', 'logging facility local7', 'logging hostnameprefix host1', 'logging console critical', 'logging buffered 2097153', 'logging buffered warnings', 'logging monitor errors', 'logging file log_file maxfilesize 1024 severity info']
    -
    -
    - xml - -
    - list -
    -
    always (empty list when no xml rpc to send) -
    NetConf rpc xml sent to device with transport netconf
    -
    -
    Sample:
    -
    ['<config xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0"> <syslog xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-infra-syslog-cfg"> <files> <file xc:operation="delete"> <file-name>file1</file-name> <file-log-attributes> <max-file-size>2097152</max-file-size> <severity>2</severity> </file-log-attributes> </file> </files> </syslog> </config>']
    -
    -

    - - -Status ------- - - -- This module will be removed in a release after 2023-08-01. *[deprecated]* -- For more information see `DEPRECATED`_. - - -Authors -~~~~~~~ - -- Trishna Guha (@trishnaguha) -- Kedar Kekan (@kedarX) diff --git a/docs/cisco.iosxr.iosxr_ntp_global_module.rst b/docs/cisco.iosxr.iosxr_ntp_global_module.rst index 7f2fd2969..01800361d 100644 --- a/docs/cisco.iosxr.iosxr_ntp_global_module.rst +++ b/docs/cisco.iosxr.iosxr_ntp_global_module.rst @@ -1647,51 +1647,51 @@ Examples # ------------ - name: Merge the provided configuration with the existing running configuration cisco.iosxr.iosxr_ntp_global: - config: - access_group: - ipv4: - peer: PeerAcl1 - query_only: QueryOnlyAcl1 - serve: ServeAcl1 - serve_only: ServeOnlyAcl1 - vrfs: - - ipv4: - peer: PeerAcl3 - serve: ServeAcl2 - name: siteA - authenticate: true - broadcastdelay: 1 - drift: - aging_time: 0 - file: apphost - interfaces: - - name: GigabitEthernet0/0/0/0 - multicast_client: 224.0.0.8 - multicast_destination: 224.0.0.8 - broadcast_client: true - ipv4: - dscp: af11 - ipv6: - precedence: routine - log_internal_sync: true - master: 1 - max_associations: 10 - passive: true - peers: - - iburst: true - peer: 192.0.2.1 - vrf: siteC - servers: - - burst: true - server: 192.0.2.2 - vrf: siteD - source: GigabitEthernet0/0/0/0 - source_vrfs: - - name: GigabitEthernet0/0/0/0 - vrf: siteE - trusted_keys: - - key_id: 1 - update_calendar: true + config: + access_group: + ipv4: + peer: PeerAcl1 + query_only: QueryOnlyAcl1 + serve: ServeAcl1 + serve_only: ServeOnlyAcl1 + vrfs: + - ipv4: + peer: PeerAcl3 + serve: ServeAcl2 + name: siteA + authenticate: true + broadcastdelay: 1 + drift: + aging_time: 0 + file: apphost + interfaces: + - name: GigabitEthernet0/0/0/0 + multicast_client: 224.0.0.8 + multicast_destination: 224.0.0.8 + broadcast_client: true + ipv4: + dscp: af11 + ipv6: + precedence: routine + log_internal_sync: true + master: 1 + max_associations: 10 + passive: true + peers: + - iburst: true + peer: 192.0.2.1 + vrf: siteC + servers: + - burst: true + server: 192.0.2.2 + vrf: siteD + source: GigabitEthernet0/0/0/0 + source_vrfs: + - name: GigabitEthernet0/0/0/0 + vrf: siteE + trusted_keys: + - key_id: 1 + update_calendar: true # Commands Fired: # ------------ # "commands": [ @@ -1859,52 +1859,52 @@ Examples # ---------------- - name: Override BGP configuration with provided configuration cisco.iosxr.iosxr_ntp_global: - state: overridden - config: - access_group: - ipv4: - peer: PeerAcl1 - query_only: QueryOnlyAcl1 - serve: ServeAcl4 - serve_only: ServeOnlyAcl1 - vrfs: - - ipv4: - peer: PeerAcl3 - serve: ServeAcl2 - name: siteA - authenticate: true - broadcastdelay: 1 - drift: - aging_time: 0 - file: apphost - interfaces: - - name: GigabitEthernet0/0/0/1 - multicast_client: 224.0.0.8 - multicast_destination: 224.0.0.8 - broadcast_client: true - ipv4: - dscp: af12 - ipv6: - precedence: routine - log_internal_sync: true - master: 1 - max_associations: 10 - passive: true - peers: - - iburst: true - peer: 192.0.2.3 - vrf: siteC - servers: - - burst: true - server: 192.0.2.2 - vrf: siteD - source: GigabitEthernet0/0/0/1 - source_vrfs: - - name: GigabitEthernet0/0/0/0 - vrf: siteE - trusted_keys: - - key_id: 1 - update_calendar: true + state: overridden + config: + access_group: + ipv4: + peer: PeerAcl1 + query_only: QueryOnlyAcl1 + serve: ServeAcl4 + serve_only: ServeOnlyAcl1 + vrfs: + - ipv4: + peer: PeerAcl3 + serve: ServeAcl2 + name: siteA + authenticate: true + broadcastdelay: 1 + drift: + aging_time: 0 + file: apphost + interfaces: + - name: GigabitEthernet0/0/0/1 + multicast_client: 224.0.0.8 + multicast_destination: 224.0.0.8 + broadcast_client: true + ipv4: + dscp: af12 + ipv6: + precedence: routine + log_internal_sync: true + master: 1 + max_associations: 10 + passive: true + peers: + - iburst: true + peer: 192.0.2.3 + vrf: siteC + servers: + - burst: true + server: 192.0.2.2 + vrf: siteD + source: GigabitEthernet0/0/0/1 + source_vrfs: + - name: GigabitEthernet0/0/0/0 + vrf: siteE + trusted_keys: + - key_id: 1 + update_calendar: true # Commands Fired: # --------------- # "commands": [ @@ -1990,52 +1990,52 @@ Examples # ---------------- - name: Replaced BGP configuration with provided configuration cisco.iosxr.iosxr_ntp_global: - state: replaced - config: - access_group: - ipv4: - peer: PeerAcl1 - query_only: QueryOnlyAcl1 - serve: ServeAcl4 - serve_only: ServeOnlyAcl1 - vrfs: - - ipv4: - peer: PeerAcl3 - serve: ServeAcl2 - name: siteA - authenticate: true - broadcastdelay: 1 - drift: - aging_time: 0 - file: apphost - interfaces: - - name: GigabitEthernet0/0/0/1 - multicast_client: 224.0.0.8 - multicast_destination: 224.0.0.8 - broadcast_client: true - ipv4: - dscp: af12 - ipv6: - precedence: routine - log_internal_sync: true - master: 1 - max_associations: 10 - passive: true - peers: - - iburst: true - peer: 192.0.2.3 - vrf: siteC - servers: - - burst: true - server: 192.0.2.2 - vrf: siteD - source: GigabitEthernet0/0/0/1 - source_vrfs: - - name: GigabitEthernet0/0/0/0 - vrf: siteE - trusted_keys: - - key_id: 1 - update_calendar: true + state: replaced + config: + access_group: + ipv4: + peer: PeerAcl1 + query_only: QueryOnlyAcl1 + serve: ServeAcl4 + serve_only: ServeOnlyAcl1 + vrfs: + - ipv4: + peer: PeerAcl3 + serve: ServeAcl2 + name: siteA + authenticate: true + broadcastdelay: 1 + drift: + aging_time: 0 + file: apphost + interfaces: + - name: GigabitEthernet0/0/0/1 + multicast_client: 224.0.0.8 + multicast_destination: 224.0.0.8 + broadcast_client: true + ipv4: + dscp: af12 + ipv6: + precedence: routine + log_internal_sync: true + master: 1 + max_associations: 10 + passive: true + peers: + - iburst: true + peer: 192.0.2.3 + vrf: siteC + servers: + - burst: true + server: 192.0.2.2 + vrf: siteD + source: GigabitEthernet0/0/0/1 + source_vrfs: + - name: GigabitEthernet0/0/0/0 + vrf: siteE + trusted_keys: + - key_id: 1 + update_calendar: true # Commands Fired: # --------------- # "commands": [ @@ -2196,7 +2196,9 @@ Examples # Using state: rendered # Rendered play: # -------------- - - name: Render platform specific configuration lines with state rendered (without connecting to the device) + - name: >- + Render platform specific configuration lines with state rendered (without + connecting to the device) cisco.iosxr.iosxr_ntp_global: state: rendered config: diff --git a/docs/cisco.iosxr.iosxr_ospf_interfaces_module.rst b/docs/cisco.iosxr.iosxr_ospf_interfaces_module.rst index 90bfd176d..a98178d93 100644 --- a/docs/cisco.iosxr.iosxr_ospf_interfaces_module.rst +++ b/docs/cisco.iosxr.iosxr_ospf_interfaces_module.rst @@ -2394,7 +2394,7 @@ Examples address_family: - afi: ipv4 processes: - - process_id: "LAB3" + - process_id: LAB3 area: area_id: 0.0.0.3 cost: 20 @@ -2403,7 +2403,7 @@ Examples keychain: cisco - afi: ipv6 processes: - - process_id: "LAB3" + - process_id: LAB3 area: area_id: 0.0.0.2 cost: 30 @@ -2495,7 +2495,7 @@ Examples address_family: - afi: ipv4 processes: - - process_id: "LAB3" + - process_id: LAB3 area: area_id: 0.0.0.3 cost: 30 @@ -2504,7 +2504,7 @@ Examples keychain: ciscoiosxr - afi: ipv6 processes: - - process_id: "LAB3" + - process_id: LAB3 area: area_id: 0.0.0.2 cost: 30 @@ -2590,7 +2590,7 @@ Examples address_family: - afi: ipv4 processes: - - process_id: "LAB1" + - process_id: LAB1 area: area_id: 0.0.0.3 cost: 10 @@ -2848,18 +2848,18 @@ Examples address_family: - afi: ipv4 processes: - - process_id: "LAB3" - area: - area_id: 0.0.0.3 + - process_id: LAB3 + area: + area_id: 0.0.0.3 cost: 20 authentication: message_digest: keychain: cisco - afi: ipv6 processes: - - process_id: "LAB3" - area: - area_id: 0.0.0.2 + - process_id: LAB3 + area: + area_id: 0.0.0.2 cost: 30 state: rendered diff --git a/docs/cisco.iosxr.iosxr_ospfv2_module.rst b/docs/cisco.iosxr.iosxr_ospfv2_module.rst index e42308d58..fe61bd4f6 100644 --- a/docs/cisco.iosxr.iosxr_ospfv2_module.rst +++ b/docs/cisco.iosxr.iosxr_ospfv2_module.rst @@ -5583,48 +5583,47 @@ Examples cisco.iosxr.iosxr_ospfv2: config: processes: - - process_id: '27' - areas: - - area_id: '10' - hello_interval: 2 + - process_id: '27' + areas: + - area_id: '10' + hello_interval: 2 + authentication: + keychain: ansi11393 + - process_id: '26' + adjacency_stagger: + max_adjacency: 20 + min_adjacency: 10 + - process_id: '10' authentication: - keychain: ansi11393 - - process_id: '26' - adjacency_stagger: - max_adjacency: 20 - min_adjacency: 10 - - process_id: '10' - authentication: - keychain: ansible_test1102 - areas: - - area_id: '11' - default_cost: 5 - cost: 11 - - area_id: 22 - default_cost: 6 - - process_id: '30' - areas: - - area_id: 11 - default_cost: 5 - - area_id: 22 - default_cost: 6 - - cost: 2 - default_metric: 10 - transmit_delay: 2 - hello_interval: 1 - dead_interval: 2 - retransmit_interval: 2 - weight: 2 - packet_size: 577 - priority: 1 - router_id: 2.2.2.2 - demand_circuit: enable - passive: disable - summary_in: enable - flood_reduction: disable - mtu_ignore: enable - external_out: disable + keychain: ansible_test1102 + areas: + - area_id: '11' + default_cost: 5 + cost: 11 + - area_id: 22 + default_cost: 6 + - process_id: '30' + areas: + - area_id: 11 + default_cost: 5 + - area_id: 22 + default_cost: 6 + cost: 2 + default_metric: 10 + transmit_delay: 2 + hello_interval: 1 + dead_interval: 2 + retransmit_interval: 2 + weight: 2 + packet_size: 577 + priority: 1 + router_id: 2.2.2.2 + demand_circuit: enable + passive: disable + summary_in: enable + flood_reduction: disable + mtu_ignore: enable + external_out: disable state: merged # Task Output: @@ -5810,19 +5809,19 @@ Examples cisco.iosxr.iosxr_ospfv2: config: processes: - - process_id: 27 - areas: - - area_id: 10 - hello_interval: 2 - - area_id: 20 - cost: 2 - default_cost: 2 - authentication: - keychain: ansi11393 - - process_id: 26 - adjacency_stagger: - min_adjacency: 10 - max_adjacency: 20 + - process_id: 27 + areas: + - area_id: 10 + hello_interval: 2 + - area_id: 20 + cost: 2 + default_cost: 2 + authentication: + keychain: ansi11393 + - process_id: 26 + adjacency_stagger: + min_adjacency: 10 + max_adjacency: 20 state: replaced # Task Output: @@ -6038,23 +6037,24 @@ Examples cisco.iosxr.iosxr_ospfv2: config: processes: - - process_id: 27 - areas: - - area_id: 10 - hello_interval: 2 - authentication: - keychain: ansi11393 - - area_id: 20 - cost: 2 - default_cost: 2 - authentication: - keychain: ansi11393 - - process_id: 26 - adjacency_stagger: - min_adjacency: 10 - max_adjacency: 20 + - process_id: 27 + areas: + - area_id: 10 + hello_interval: 2 + authentication: + keychain: ansi11393 + - area_id: 20 + cost: 2 + default_cost: 2 + authentication: + keychain: ansi11393 + - process_id: 26 + adjacency_stagger: + min_adjacency: 10 + max_adjacency: 20 state: overridden + # # Task Output: # ------------ @@ -6248,12 +6248,13 @@ Examples cisco.iosxr.iosxr_ospfv2: config: processes: - - process_id: '10' - - process_id: '26' - - process_id: '27' - - process_id: '30' + - process_id: '10' + - process_id: '26' + - process_id: '27' + - process_id: '30' state: deleted + # # Task Output: # ------------ @@ -6485,50 +6486,50 @@ Examples cisco.iosxr.iosxr_ospfv2: config: processes: - - process_id: 27 - areas: - - area_id: 10 - hello_interval: 2 + - process_id: 27 + areas: + - area_id: 10 + hello_interval: 2 + authentication: + keychain: ansi11393 + - process_id: 26 + adjacency_stagger: + min_adjacency: 10 + max_adjacency: 20 + - process_id: 10 authentication: - keychain: ansi11393 - - process_id: 26 - adjacency_stagger: - min_adjacency: 10 - max_adjacency: 20 - - process_id: 10 - authentication: - keychain: ansible_test1102 - areas: - - area_id: 11 - default_cost: 5 - cost: 11 - - area_id: 22 - default_cost: 6 - - process_id: 30 - areas: - - area_id: 11 - default_cost: 5 - - area_id: 22 - default_cost: 6 - - cost: 2 - default_metric: 10 - transmit_delay: 2 - hello_interval: 1 - dead_interval: 2 - retransmit_interval: 2 - weight: 2 - packet_size: 577 - priority: 1 - router_id: 2.2.2.2 - demand_circuit: enable - passive: disable - summary_in: enable - flood_reduction: disable - mtu_ignore: enable - external_out: disable + keychain: ansible_test1102 + areas: + - area_id: 11 + default_cost: 5 + cost: 11 + - area_id: 22 + default_cost: 6 + - process_id: 30 + areas: + - area_id: 11 + default_cost: 5 + - area_id: 22 + default_cost: 6 + cost: 2 + default_metric: 10 + transmit_delay: 2 + hello_interval: 1 + dead_interval: 2 + retransmit_interval: 2 + weight: 2 + packet_size: 577 + priority: 1 + router_id: 2.2.2.2 + demand_circuit: enable + passive: disable + summary_in: enable + flood_reduction: disable + mtu_ignore: enable + external_out: disable state: rendered + # # Task Output: # ------------ diff --git a/docs/cisco.iosxr.iosxr_ospfv3_module.rst b/docs/cisco.iosxr.iosxr_ospfv3_module.rst index 168cd62f2..494562fc5 100644 --- a/docs/cisco.iosxr.iosxr_ospfv3_module.rst +++ b/docs/cisco.iosxr.iosxr_ospfv3_module.rst @@ -9241,7 +9241,7 @@ Examples retransmit_interval: 2 packet_size: 577 priority: 1 - router_id: '2.2.2.2' + router_id: 2.2.2.2 demand_circuit: true mtu_ignore: true state: merged @@ -9787,12 +9787,13 @@ Examples cisco.iosxr.iosxr_ospfv3: config: processes: - - process_id: '10' - - process_id: '26' - - process_id: '27' - - process_id: '30' + - process_id: '10' + - process_id: '26' + - process_id: '27' + - process_id: '30' state: deleted + # # Task Output: # ------------ diff --git a/docs/cisco.iosxr.iosxr_prefix_lists_module.rst b/docs/cisco.iosxr.iosxr_prefix_lists_module.rst index 6e9bc7367..348b07d0c 100644 --- a/docs/cisco.iosxr.iosxr_prefix_lists_module.rst +++ b/docs/cisco.iosxr.iosxr_prefix_lists_module.rst @@ -322,50 +322,50 @@ Examples # Before state - #RP/0/0/CPU0:10#show running-config - #Thu Feb 4 09:38:36.245 UTC - #% No such configuration item(s) - #RP/0/0/CPU0:10# + # RP/0/0/CPU0:10#show running-config + # Thu Feb 4 09:38:36.245 UTC + # % No such configuration item(s) + # RP/0/0/CPU0:10# # - name: Merge the provided configuration with the existing running configuration cisco.iosxr.iosxr_prefix_lists: - state: merged - config: - - afi: ipv6 - prefix_lists: - - name: pl_1 - entries: - - prefix: 2001:db8:1234::/48 - action: deny - sequence: 1 - - name: pl_2 - entries: - - sequence: 2 - action: remark - description: TEST_PL_2_REMARK - - afi: ipv4 - prefix_lists: - - name: pl1 - entries: - - sequence: 3 - action: remark - description: TEST_PL1_2_REMARK - - sequence: 4 - action: permit - prefix: 10.0.0.0/24 - - name: pl2 - entries: - - sequence: 5 - action: remark - description: TEST_PL2_REMARK - - name: pl3 - entries: - - sequence: 6 - action: permit - prefix: 35.0.0.0/8 - eq: 0 + state: merged + config: + - afi: ipv6 + prefix_lists: + - name: pl_1 + entries: + - prefix: '2001:db8:1234::/48' + action: deny + sequence: 1 + - name: pl_2 + entries: + - sequence: 2 + action: remark + description: TEST_PL_2_REMARK + - afi: ipv4 + prefix_lists: + - name: pl1 + entries: + - sequence: 3 + action: remark + description: TEST_PL1_2_REMARK + - sequence: 4 + action: permit + prefix: 10.0.0.0/24 + - name: pl2 + entries: + - sequence: 5 + action: remark + description: TEST_PL2_REMARK + - name: pl3 + entries: + - sequence: 6 + action: permit + prefix: 35.0.0.0/8 + eq: 0 # Task Output # ------------- @@ -415,12 +415,12 @@ Examples # After state: # ------------ - #RP/0/0/CPU0:10#show running-config + # RP/0/0/CPU0:10#show running-config # ipv6 prefix-list pl_1 # 1 deny 2001:db8:1234::/48 # ! # ipv6 prefix-list pl_2 - # 2 remark TEST_PL_2_REMARK + # 2 remark TEST_PL_2_REMAR # ! # ipv4 prefix-list pl1 # 3 remark TEST_PL1_2_REMARK @@ -439,7 +439,7 @@ Examples # Before state: # ------------- - #RP/0/0/CPU0:10#show running-config + # RP/0/0/CPU0:10#show running-config # # ipv6 prefix-list pl_1 # 1 deny 2001:db8:1234::/48 @@ -457,29 +457,31 @@ Examples # - - name: Replace device configurations of listed prefix lists with provided configurations + - name: >- + Replace device configurations of listed prefix lists with provided + configurations register: result - cisco.iosxr.iosxr_prefix_lists: &id001 + cisco.iosxr.iosxr_prefix_lists: config: - - afi: ipv4 - prefix_lists: - - name: pl1 - entries: - - sequence: 3 - action: permit - prefix: 10.0.0.0/24 - - afi: ipv6 - prefix_lists: - - name: pl_1 - entries: - - prefix: 2001:db8:1234::/48 - action: permit - sequence: 1 - - name: pl_2 - entries: - - sequence: 2 - action: remark - description: TEST_PL1_2 + - afi: ipv4 + prefix_lists: + - name: pl1 + entries: + - sequence: 3 + action: permit + prefix: 10.0.0.0/24 + - afi: ipv6 + prefix_lists: + - name: pl_1 + entries: + - prefix: '2001:db8:1234::/48' + action: permit + sequence: 1 + - name: pl_2 + entries: + - sequence: 2 + action: remark + description: TEST_PL1_2 state: replaced @@ -546,7 +548,7 @@ Examples # After state: - #RP/0/0/CPU0:10#show running-config + # RP/0/0/CPU0:10#show running-config # # ipv6 prefix-list pl_1 # 1 deny 2001:db8:1234::/48 @@ -644,7 +646,7 @@ Examples # After state: # ------------ - #RP/0/0/CPU0:10#show running-config + # RP/0/0/CPU0:10#show running-config # ipv6 prefix-list pl_1 # 1 deny 2001:db8:1234::/48 # ! @@ -665,7 +667,7 @@ Examples - name: Gather ACL interfaces facts using gathered state cisco.iosxr.iosxr_prefix_lists: - state: gathered + state: gathered # gathered: # - afi: ipv6 @@ -707,7 +709,7 @@ Examples # parsed.cfg - #------------------------------ + # ------------------------------ # ipv6 prefix-list pl_1 # 1 deny 2001:db8:1234::/48 # ! @@ -722,11 +724,10 @@ Examples # 5 remark TEST_PL2_REMARK - - name: Parse externally provided Prefix_lists config to agnostic model cisco.iosxr.iosxr_prefix_lists: - running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}" - state: parsed + running_config: '{{ lookup(''file'', ''./fixtures/parsed.cfg'') }}' + state: parsed # Task Output @@ -771,40 +772,39 @@ Examples - name: Render platform specific commands from task input using rendered state register: result cisco.iosxr.iosxr_prefix_lists: - config: - - afi: ipv6 - prefix_lists: - - name: pl_1 - entries: - - prefix: 2001:db8:1234::/48 - action: deny - sequence: 1 - - name: pl_2 - entries: - - sequence: 2 - action: remark - description: TEST_PL_2_REMARK - - afi: ipv4 - prefix_lists: - - name: pl1 - entries: - - sequence: 3 - action: remark - description: TEST_PL1_2_REMARK - - sequence: 4 - action: permit - prefix: 10.0.0.0/24 - - name: pl2 - entries: - - sequence: 5 - action: remark - description: TEST_PL2_REMARK - - sequence: 6 - action: permit - prefix: 35.0.0.0/8 - eq: 0 - - state: rendered + config: + - afi: ipv6 + prefix_lists: + - name: pl_1 + entries: + - prefix: '2001:db8:1234::/48' + action: deny + sequence: 1 + - name: pl_2 + entries: + - sequence: 2 + action: remark + description: TEST_PL_2_REMARK + - afi: ipv4 + prefix_lists: + - name: pl1 + entries: + - sequence: 3 + action: remark + description: TEST_PL1_2_REMARK + - sequence: 4 + action: permit + prefix: 10.0.0.0/24 + - name: pl2 + entries: + - sequence: 5 + action: remark + description: TEST_PL2_REMARK + - sequence: 6 + action: permit + prefix: 35.0.0.0/8 + eq: 0 + state: rendered # Task Output @@ -818,14 +818,12 @@ Examples # "ipv4 prefix-list pl2 6 permit 35.0.0.0/8 eq 0" # ] - - # Using overridden: # Before state: # ------------- - #RP/0/0/CPU0:10#show running-config + # RP/0/0/CPU0:10#show running-config # # ipv6 prefix-list pl_1 # 1 deny 2001:db8:1234::/48 @@ -842,22 +840,22 @@ Examples # - name: Overridde all Prefix_lists configuration with provided configuration cisco.iosxr.iosxr_prefix_lists: - config: - - afi: ipv4 - prefix_lists: - - name: pl3 - entries: - - sequence: 3 - action: remark - description: TEST_PL1_3_REMARK - - sequence: 4 - action: permit - prefix: 10.0.0.0/24 - - sequence: 6 - action: permit - prefix: 35.0.0.0/8 - eq: 0 - state: overridden + config: + - afi: ipv4 + prefix_lists: + - name: pl3 + entries: + - sequence: 3 + action: remark + description: TEST_PL1_3_REMARK + - sequence: 4 + action: permit + prefix: 10.0.0.0/24 + - sequence: 6 + action: permit + prefix: 35.0.0.0/8 + eq: 0 + state: overridden # Task Output @@ -916,14 +914,14 @@ Examples # After state: - #RP/0/0/CPU0:10#show running-config + # RP/0/0/CPU0:10#show running-config # - #ipv4 prefix-list pl3 + # ipv4 prefix-list pl3 # 3 remark TEST_PL1_3_REMARK # 4 permit 10.0.0.0/24 # 6 permit 35.0.0.0/8 eq 0 # ! - #! + # ! diff --git a/docs/cisco.iosxr.iosxr_snmp_server_module.rst b/docs/cisco.iosxr.iosxr_snmp_server_module.rst index b89aea405..eab8fe518 100644 --- a/docs/cisco.iosxr.iosxr_snmp_server_module.rst +++ b/docs/cisco.iosxr.iosxr_snmp_server_module.rst @@ -5417,101 +5417,102 @@ Examples # --------------------- EMPTY ----------------- # Merged play: # ------------ + - name: Merge the provided configuration with the existing running configuration cisco.iosxr.iosxr_snmp_server: - config: - vrfs: - - hosts: - - community: test1 - host: 1.1.1.1 - traps: true - vrf: vrf1 - users: - - Ipv4_acl: test1 - Ipv6_acl: test2 - group: test2 - user: u1 - version: v1 - timeouts: - duplicate: 0 - inQdrop: 0 - trap: - throttle_time: 12 - targets: - - host: 1.1.1.2 - name: test + config: + vrfs: + - hosts: + - community: test1 + host: 1.1.1.1 + traps: true + vrf: vrf1 + users: + - Ipv4_acl: test1 + Ipv6_acl: test2 + group: test2 + user: u1 + version: v1 + timeouts: + duplicate: 0 + inQdrop: 0 + trap: + throttle_time: 12 + targets: + - host: 1.1.1.2 + name: test + ifmib: + internal_cache_max_duration: 4 + inform: + retries: 7 + chassis_id: test2 + packetsize: 490 + queue_length: 2 + throttle_time: 60 + trap_source: GigabitEthernet0/0/0/2 + trap_timeout: 3 + context: + - c1 + - c2 + contact: t1 + correlator: + buffer_size: 1024 + communities: + - name: test2 + ro: true + sdrowner: true + acl_v4: test + acl_v6: test1 + community_maps: + - name: cm1 + context: c1 + target_list: t1 + security_name: s1 + drop: + report_IPv4: test1 + unknown_user: true + ipv6: + precedence: routine + ipv4: + dscp: af11 + location: test1 + logging_threshold_oid_processing: 1 + logging_threshold_pdu_processing: 1 + mib_bulkstat_max_procmem_size: 101 + mroutemib_send_all_vrf: true + overload_control: + overload_drop_time: 4 + overload_throttle_rate: 6 + notification_log_mib: + GlobalSize: 5 + size: 5 + traps: + hsrp: true + ipsla: true + ipsec: + start: true + stop: true + bridgemib: true + bulkstat_collection: true + cisco_entity_ext: true + config: true + copy_complete: true + addrpool: + high: true + low: true + bfd: true + bgp: + cbgp2: true + l2tun: + sessions: true + tunnel_down: true + tunnel_up: true + l2vpn: + all: true + vc_down: true + vc_up: true + msdp_peer_state_change: true - ifmib: - internal_cache_max_duration: 4 - inform: - retries: 7 - chassis_id: test2 - packetsize: 490 - queue_length: 2 - throttle_time: 60 - trap_source: GigabitEthernet0/0/0/2 - trap_timeout: 3 - context: - - c1 - - c2 - contact: t1 - correlator: - buffer_size: 1024 - communities: - - name: test2 - ro: true - sdrowner: true - acl_v4: test - acl_v6: test1 - community_maps: - - name: cm1 - context: c1 - target_list: t1 - security_name: s1 - drop: - report_IPv4: test1 - unknown_user: true - ipv6: - precedence: routine - ipv4: - dscp: af11 - location: test1 - logging_threshold_oid_processing: 1 - logging_threshold_pdu_processing: 1 - mib_bulkstat_max_procmem_size: 101 - mroutemib_send_all_vrf: true - overload_control: - overload_drop_time: 4 - overload_throttle_rate: 6 - notification_log_mib: - GlobalSize: 5 - size: 5 - traps: - hsrp: true - ipsla: true - ipsec: - start: true - stop: true - bridgemib: true - bulkstat_collection: true - cisco_entity_ext: true - config: true - copy_complete: true - addrpool: - high: true - low: true - bfd: true - bgp: - cbgp2: true - l2tun: - sessions: true - tunnel_down: true - tunnel_up: true - l2vpn: - all: true - vc_down: true - vc_up: true - msdp_peer_state_change: true # # Commands Fired: # ------------ @@ -5822,78 +5823,78 @@ Examples # ---------------- - name: Override Snmp-server configuration with provided configuration cisco.iosxr.iosxr_snmp_server: - config: - timeouts: - duplicate: 0 - inQdrop: 0 - trap: - throttle_time: 13 - targets: - - host: 1.1.1.2 - name: test + config: + timeouts: + duplicate: 0 + inQdrop: 0 + trap: + throttle_time: 13 + targets: + - host: 1.1.1.2 + name: test + ifmib: + internal_cache_max_duration: 5 + inform: + retries: 7 + chassis_id: test + packetsize: 491 + queue_length: 2 + throttle_time: 60 + trap_source: GigabitEthernet0/0/0/2 + trap_timeout: 3 + context: + - c1 + - c2 + contact: t1 + correlator: + buffer_size: 1025 + communities: + - name: test1 + ro: true + sdrowner: true + acl_v4: test + acl_v6: test1 + community_maps: + - name: cm2 + context: c1 + target_list: t1 + security_name: s1 + drop: + report_IPv4: test2 + unknown_user: true + ipv6: + precedence: routine + ipv4: + dscp: af11 + location: test1 + logging_threshold_oid_processing: 2 + logging_threshold_pdu_processing: 2 + mib_bulkstat_max_procmem_size: 101 + mroutemib_send_all_vrf: true + overload_control: + overload_drop_time: 4 + overload_throttle_rate: 6 + notification_log_mib: + GlobalSize: 5 + size: 5 + traps: + hsrp: true + ipsla: true + ipsec: + start: true + stop: true + bridgemib: true + bulkstat_collection: true + cisco_entity_ext: true + config: true + copy_complete: true + l2vpn: + all: true + vc_down: true + vc_up: true + msdp_peer_state_change: true + state: overridden - ifmib: - internal_cache_max_duration: 5 - inform: - retries: 7 - chassis_id: test - packetsize: 491 - queue_length: 2 - throttle_time: 60 - trap_source: GigabitEthernet0/0/0/2 - trap_timeout: 3 - context: - - c1 - - c2 - contact: t1 - correlator: - buffer_size: 1025 - communities: - - name: test1 - ro: true - sdrowner: true - acl_v4: test - acl_v6: test1 - community_maps: - - name: cm2 - context: c1 - target_list: t1 - security_name: s1 - drop: - report_IPv4: test2 - unknown_user: true - ipv6: - precedence: routine - ipv4: - dscp: af11 - location: test1 - logging_threshold_oid_processing: 2 - logging_threshold_pdu_processing: 2 - mib_bulkstat_max_procmem_size: 101 - mroutemib_send_all_vrf: true - overload_control: - overload_drop_time: 4 - overload_throttle_rate: 6 - notification_log_mib: - GlobalSize: 5 - size: 5 - traps: - hsrp: true - ipsla: true - ipsec: - start: true - stop: true - bridgemib: true - bulkstat_collection: true - cisco_entity_ext: true - config: true - copy_complete: true - l2vpn: - all: true - vc_down: true - vc_up: true - msdp_peer_state_change: true - state: overridden # Commands Fired: # --------------- # "commands": [ @@ -6033,78 +6034,78 @@ Examples # ---------------- - name: Replace Snmp-server configuration with provided configuration cisco.iosxr.iosxr_snmp_server: - state: replaced - config: - timeouts: - duplicate: 0 - inQdrop: 0 - trap: - throttle_time: 13 - targets: - - host: 1.1.1.2 - name: test + state: replaced + config: + timeouts: + duplicate: 0 + inQdrop: 0 + trap: + throttle_time: 13 + targets: + - host: 1.1.1.2 + name: test + ifmib: + internal_cache_max_duration: 5 + inform: + retries: 7 + chassis_id: test + packetsize: 491 + queue_length: 2 + throttle_time: 60 + trap_source: GigabitEthernet0/0/0/2 + trap_timeout: 3 + context: + - c1 + - c2 + contact: t1 + correlator: + buffer_size: 1025 + communities: + - name: test1 + ro: true + sdrowner: true + acl_v4: test + acl_v6: test1 + community_maps: + - name: cm2 + context: c1 + target_list: t1 + security_name: s1 + drop: + report_IPv4: test2 + unknown_user: true + ipv6: + precedence: routine + ipv4: + dscp: af11 + location: test1 + logging_threshold_oid_processing: 2 + logging_threshold_pdu_processing: 2 + mib_bulkstat_max_procmem_size: 101 + mroutemib_send_all_vrf: true + overload_control: + overload_drop_time: 4 + overload_throttle_rate: 6 + notification_log_mib: + GlobalSize: 5 + size: 5 + traps: + hsrp: true + ipsla: true + ipsec: + start: true + stop: true + bridgemib: true + bulkstat_collection: true + cisco_entity_ext: true + config: true + copy_complete: true + l2vpn: + all: true + vc_down: true + vc_up: true + msdp_peer_state_change: true - ifmib: - internal_cache_max_duration: 5 - inform: - retries: 7 - chassis_id: test - packetsize: 491 - queue_length: 2 - throttle_time: 60 - trap_source: GigabitEthernet0/0/0/2 - trap_timeout: 3 - context: - - c1 - - c2 - contact: t1 - correlator: - buffer_size: 1025 - communities: - - name: test1 - ro: true - sdrowner: true - acl_v4: test - acl_v6: test1 - community_maps: - - name: cm2 - context: c1 - target_list: t1 - security_name: s1 - drop: - report_IPv4: test2 - unknown_user: true - ipv6: - precedence: routine - ipv4: - dscp: af11 - location: test1 - logging_threshold_oid_processing: 2 - logging_threshold_pdu_processing: 2 - mib_bulkstat_max_procmem_size: 101 - mroutemib_send_all_vrf: true - overload_control: - overload_drop_time: 4 - overload_throttle_rate: 6 - notification_log_mib: - GlobalSize: 5 - size: 5 - traps: - hsrp: true - ipsla: true - ipsec: - start: true - stop: true - bridgemib: true - bulkstat_collection: true - cisco_entity_ext: true - config: true - copy_complete: true - l2vpn: - all: true - vc_down: true - vc_up: true - msdp_peer_state_change: true # # Commands Fired: # --------------- @@ -6397,7 +6398,9 @@ Examples # Using state: rendered # Rendered play: # -------------- - - name: Render platform specific configuration lines with state rendered (without connecting to the device) + - name: >- + Render platform specific configuration lines with state rendered (without + connecting to the device) cisco.iosxr.iosxr_snmp_server: state: rendered config: @@ -6421,7 +6424,6 @@ Examples targets: - host: 1.1.1.2 name: test - ifmib: internal_cache_max_duration: 4 inform: @@ -6494,6 +6496,7 @@ Examples vc_up: true msdp_peer_state_change: true register: result + # Module Execution Result: # ------------------------ # "rendered": [ diff --git a/docs/cisco.iosxr.iosxr_static_routes_module.rst b/docs/cisco.iosxr.iosxr_static_routes_module.rst index 7174bdbc7..5005ef6b2 100644 --- a/docs/cisco.iosxr.iosxr_static_routes_module.rst +++ b/docs/cisco.iosxr.iosxr_static_routes_module.rst @@ -445,57 +445,52 @@ Examples - name: Merge the provided configuration with the existing running configuration cisco.iosxr.iosxr_static_routes: config: - - address_families: - - afi: ipv4 - safi: unicast - routes: - - dest: 192.0.2.16/28 - next_hops: - - forward_router_address: 192.0.2.10 - interface: FastEthernet0/0/0/1 - description: LAB - metric: 120 - tag: 10 - - - interface: FastEthernet0/0/0/5 - track: ip_sla_1 - - - dest: 192.0.2.32/28 - next_hops: - - forward_router_address: 192.0.2.11 - admin_distance: 100 - - - afi: ipv6 - safi: unicast - routes: - - dest: 2001:db8:1000::/36 - next_hops: - - interface: FastEthernet0/0/0/7 - description: DC - - - interface: FastEthernet0/0/0/8 - forward_router_address: 2001:db8:2000:2::1 - - - vrf: DEV_SITE - address_families: - - afi: ipv4 - safi: unicast - routes: - - dest: 192.0.2.48/28 - next_hops: - - forward_router_address: 192.0.2.12 - description: DEV - dest_vrf: test_1 - - - dest: 192.0.2.80/28 - next_hops: - - interface: FastEthernet0/0/0/2 - forward_router_address: 192.0.2.14 - dest_vrf: test_1 - track: ip_sla_2 - vrflabel: 124 + - address_families: + - afi: ipv4 + safi: unicast + routes: + - dest: 192.0.2.16/28 + next_hops: + - forward_router_address: 192.0.2.10 + interface: FastEthernet0/0/0/1 + description: LAB + metric: 120 + tag: 10 + - interface: FastEthernet0/0/0/5 + track: ip_sla_1 + - dest: 192.0.2.32/28 + next_hops: + - forward_router_address: 192.0.2.11 + admin_distance: 100 + - afi: ipv6 + safi: unicast + routes: + - dest: '2001:db8:1000::/36' + next_hops: + - interface: FastEthernet0/0/0/7 + description: DC + - interface: FastEthernet0/0/0/8 + forward_router_address: '2001:db8:2000:2::1' + - vrf: DEV_SITE + address_families: + - afi: ipv4 + safi: unicast + routes: + - dest: 192.0.2.48/28 + next_hops: + - forward_router_address: 192.0.2.12 + description: DEV + dest_vrf: test_1 + - dest: 192.0.2.80/28 + next_hops: + - interface: FastEthernet0/0/0/2 + forward_router_address: 192.0.2.14 + dest_vrf: test_1 + track: ip_sla_2 + vrflabel: 124 state: merged + # Task Output # ----------- # before: [] @@ -608,23 +603,22 @@ Examples - name: Update existing static routes configuration using merged cisco.iosxr.iosxr_static_routes: config: - - vrf: DEV_SITE - address_families: - - afi: ipv4 - safi: unicast - routes: - - dest: 192.0.2.48/28 - next_hops: - - forward_router_address: 192.0.2.12 - vrflabel: 2301 - dest_vrf: test_1 - - - dest: 192.0.2.80/28 - next_hops: - - interface: FastEthernet0/0/0/2 - forward_router_address: 192.0.2.14 - dest_vrf: test_1 - description: rt_test_1 + - vrf: DEV_SITE + address_families: + - afi: ipv4 + safi: unicast + routes: + - dest: 192.0.2.48/28 + next_hops: + - forward_router_address: 192.0.2.12 + vrflabel: 2301 + dest_vrf: test_1 + - dest: 192.0.2.80/28 + next_hops: + - interface: FastEthernet0/0/0/2 + forward_router_address: 192.0.2.14 + dest_vrf: test_1 + description: rt_test_1 state: merged # Task Output @@ -777,17 +771,17 @@ Examples - name: Replace device configurations of static routes with provided configurations cisco.iosxr.iosxr_static_routes: config: - - vrf: DEV_SITE - address_families: - - afi: ipv4 - safi: unicast - routes: - - dest: 192.0.2.48/28 - next_hops: - - forward_router_address: 192.0.2.15 - interface: FastEthernet0/0/0/3 - description: DEV_NEW - dest_vrf: dev_test_2 + - vrf: DEV_SITE + address_families: + - afi: ipv4 + safi: unicast + routes: + - dest: 192.0.2.48/28 + next_hops: + - forward_router_address: 192.0.2.15 + interface: FastEthernet0/0/0/3 + description: DEV_NEW + dest_vrf: dev_test_2 state: replaced # Task Output @@ -843,7 +837,7 @@ Examples # vrflabel: 124 # safi: unicast # vrf: DEV_SITE - #commands: + # commands: # - router static # - vrf DEV_SITE # - address-family ipv4 unicast @@ -946,25 +940,25 @@ Examples - name: Overridde all static routes configuration with provided configuration cisco.iosxr.iosxr_static_routes: config: - - vrf: DEV_NEW - address_families: - - afi: ipv4 - safi: unicast - routes: - - dest: 192.0.2.48/28 - next_hops: - - forward_router_address: 192.0.2.15 - interface: FastEthernet0/0/0/3 - description: DEV1 - - afi: ipv6 - safi: unicast - routes: - - dest: 2001:db8:3000::/36 - next_hops: - - interface: FastEthernet0/0/0/4 - forward_router_address: 2001:db8:2000:2::2 - description: PROD1 - track: ip_sla_1 + - vrf: DEV_NEW + address_families: + - afi: ipv4 + safi: unicast + routes: + - dest: 192.0.2.48/28 + next_hops: + - forward_router_address: 192.0.2.15 + interface: FastEthernet0/0/0/3 + description: DEV1 + - afi: ipv6 + safi: unicast + routes: + - dest: '2001:db8:3000::/36' + next_hops: + - interface: FastEthernet0/0/0/4 + forward_router_address: '2001:db8:2000:2::2' + description: PROD1 + track: ip_sla_1 state: overridden # Task Output @@ -1091,10 +1085,10 @@ Examples - name: Delete all destination network entries under a single AFI cisco.iosxr.iosxr_static_routes: config: - - vrf: DEV_SITE - address_families: - - afi: ipv4 - safi: unicast + - vrf: DEV_SITE + address_families: + - afi: ipv4 + safi: unicast state: deleted # Task output @@ -1410,26 +1404,25 @@ Examples # Using rendered - name: Render platform specific commands (without connecting to the device) - cisco.iosxr.iosxr_static_routes: + cisco.iosxr.iosxr_static_routes: null config: - - vrf: DEV_SITE - address_families: - - afi: ipv4 - safi: unicast - routes: - - dest: 192.0.2.48/28 - next_hops: - - forward_router_address: 192.0.2.12 - description: DEV - dest_vrf: test_1 - - - dest: 192.0.2.80/28 - next_hops: - - interface: FastEthernet0/0/0/2 - forward_router_address: 192.0.2.14 - dest_vrf: test_1 - track: ip_sla_2 - vrflabel: 124 + - vrf: DEV_SITE + address_families: + - afi: ipv4 + safi: unicast + routes: + - dest: 192.0.2.48/28 + next_hops: + - forward_router_address: 192.0.2.12 + description: DEV + dest_vrf: test_1 + - dest: 192.0.2.80/28 + next_hops: + - interface: FastEthernet0/0/0/2 + forward_router_address: 192.0.2.14 + dest_vrf: test_1 + track: ip_sla_2 + vrflabel: 124 # Task Output (redacted) # ----------------------- diff --git a/docs/cisco.iosxr.iosxr_system_module.rst b/docs/cisco.iosxr.iosxr_system_module.rst index efc494ed1..f59eea224 100644 --- a/docs/cisco.iosxr.iosxr_system_module.rst +++ b/docs/cisco.iosxr.iosxr_system_module.rst @@ -196,17 +196,17 @@ Examples hostname: iosxr01 domain_name: test.example.com domain_search: - - ansible.com - - redhat.com - - cisco.com + - ansible.com + - redhat.com + - cisco.com - name: remove configuration cisco.iosxr.iosxr_system: hostname: iosxr01 domain_name: test.example.com domain_search: - - ansible.com - - redhat.com - - cisco.com + - ansible.com + - redhat.com + - cisco.com state: absent - name: configure hostname and domain-name with vrf cisco.iosxr.iosxr_system: @@ -214,9 +214,9 @@ Examples vrf: nondefault domain_name: test.example.com domain_search: - - ansible.com - - redhat.com - - cisco.com + - ansible.com + - redhat.com + - cisco.com - name: configure DNS lookup sources cisco.iosxr.iosxr_system: lookup_source: MgmtEth0/0/CPU0/0 @@ -224,8 +224,8 @@ Examples - name: configure name servers cisco.iosxr.iosxr_system: name_servers: - - 8.8.8.8 - - 8.8.4.4 + - 8.8.8.8 + - 8.8.4.4 diff --git a/docs/cisco.iosxr.iosxr_user_module.rst b/docs/cisco.iosxr.iosxr_user_module.rst index 808742af5..b56d09516 100644 --- a/docs/cisco.iosxr.iosxr_user_module.rst +++ b/docs/cisco.iosxr.iosxr_user_module.rst @@ -424,18 +424,18 @@ Examples - name: set multiple users to group sys-admin cisco.iosxr.iosxr_user: aggregate: - - name: netop - - name: netend + - name: netop + - name: netend group: sysadmin state: present - name: set multiple users to multiple groups cisco.iosxr.iosxr_user: aggregate: - - name: netop - - name: netend + - name: netop + - name: netend groups: - - sysadmin - - root-system + - sysadmin + - root-system state: present - name: Change Password for User netop cisco.iosxr.iosxr_user: diff --git a/galaxy.yml b/galaxy.yml index b51e17d7f..acaab18e6 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -2,7 +2,7 @@ authors: - Ansible Network Community (ansible-network) dependencies: - "ansible.netcommon": ">=2.5.1" + "ansible.netcommon": ">=6.0.0" license_file: LICENSE name: iosxr namespace: cisco @@ -13,4 +13,4 @@ issues: https://github.com/ansible-collections/cisco.iosxr/issues tags: [cisco, iosxr, networking, netconf] # NOTE(pabelanger): We create an empty version key to keep ansible-galaxy # happy. We dynamically inject version info based on git information. -version: "6.1.0" +version: "8.0.0" diff --git a/meta/runtime.yml b/meta/runtime.yml index d2e135969..5bf8ab65f 100644 --- a/meta/runtime.yml +++ b/meta/runtime.yml @@ -1,5 +1,5 @@ --- -requires_ansible: ">=2.9.10" +requires_ansible: ">=2.14.0" plugin_routing: modules: acl_interfaces: @@ -30,15 +30,6 @@ plugin_routing: redirect: cisco.iosxr.iosxr_lldp_global lldp_interfaces: redirect: cisco.iosxr.iosxr_lldp_interfaces - logging: - redirect: cisco.iosxr.iosxr_logging - deprecation: - removal_date: "2023-08-01" - warning_text: See the plugin documentation for more details - iosxr_logging: - deprecation: - removal_date: "2023-08-01" - warning_text: See the plugin documentation for more details logging_global: redirect: cisco.iosxr.iosxr_logging_global netconf: diff --git a/platform_guide.rst b/platform_guide.rst new file mode 100644 index 000000000..f1e8996ca --- /dev/null +++ b/platform_guide.rst @@ -0,0 +1,142 @@ +.. _iosxr_platform_options: + +*************************************** +IOS-XR Platform Options +*************************************** + +The `Cisco IOS-XR collection `_ supports multiple connections. This page offers details on how each connection works in Ansible and how to use it. + +.. contents:: + :local: + +Connections available +================================================================================ + +.. table:: + :class: documentation-table + + ==================== ========================================== ============================================================================================================ + .. CLI NETCONF + only for modules ``iosxr_banner``, ``iosxr_interface``, ``iosxr_logging``, ``iosxr_system``, ``iosxr_user`` + ==================== ========================================== ============================================================================================================ + Protocol SSH XML over SSH + + Credentials uses SSH keys / SSH-agent if present uses SSH keys / SSH-agent if present + accepts ``-u myuser -k`` if using password accepts ``-u myuser -k`` if using password + + Indirect Access by a bastion (jump host) by a bastion (jump host) + + Connection Settings ``ansible_connection:`` ``ansible_connection:`` + ``ansible.netcommon.network_cli`` ``ansible.netcommon.netconf`` + + Enable Mode not supported not supported + (Privilege Escalation) + + Returned Data Format Refer to individual module documentation Refer to individual module documentation + ==================== ========================================== ============================================================================================================ + + +The ``ansible_connection: local`` has been deprecated. Please use ``ansible_connection: ansible.netcommon.network_cli`` or ``ansible_connection: ansible.netcommon.netconf`` instead. + +Using CLI in Ansible +==================== + +Example CLI inventory ``[iosxr:vars]`` +---------------------------------------- + +.. code-block:: yaml + + [iosxr:vars] + ansible_connection=ansible.netcommon.network_cli + ansible_network_os=cisco.iosxr.iosxr + ansible_user=myuser + ansible_password=!vault... + ansible_ssh_common_args='-o ProxyCommand="ssh -W %h:%p -q bastion01"' + +- If you are using SSH keys (including an ssh-agent) you can remove the ``ansible_password`` configuration. +- If you are accessing your host directly (not through a bastion/jump host) you can remove the ``ansible_ssh_common_args`` configuration. +- If you are accessing your host through a bastion/jump host, you cannot include your SSH password in the ``ProxyCommand`` directive. To prevent secrets from leaking out (for example in ``ps`` output), SSH does not support providing passwords through environment variables. + +Example CLI task +---------------- + +.. code-block:: yaml + + - name: Retrieve IOS-XR version + cisco.iosxr.iosxr_command: + commands: show version + when: ansible_network_os == 'cisco.iosxr.iosxr' + +Using NETCONF in Ansible +========================== + +Enabling NETCONF +--------------- + +Before you can use NETCONF to connect to a switch, you must: + + - install the ``ncclient`` python package on your control node(s) with ``pip install ncclient`` + - enable NETCONF on the Cisco IOS-XR device(s) + +To enable NETCONF on a new switch with Ansible, use the ``cisco.iosxr.iosxr_netconf`` module through the CLI connection. Set up your platform-level variables just like in the CLI example above, then run a playbook task like this: + +.. code-block:: yaml + + - name: Enable NETCONF + connection: ansible.netcommon.network_cli + cisco.iosxr.iosxr_netconf: + when: ansible_network_os == 'cisco.iosxr.iosxr' + +Once NETCONF is enabled, change your variables to use the NETCONF connection. + +Example NETCONF inventory ``[iosxr:vars]`` +------------------------------------------ + +.. code-block:: yaml + + [iosxr:vars] + ansible_connection=ansible.netcommon.netconf + ansible_network_os=cisco.iosxr.iosxr + ansible_user=myuser + ansible_password=!vault | + ansible_ssh_common_args='-o ProxyCommand="ssh -W %h:%p -q bastion01"' + + +Example NETCONF task +----------------------- + +.. code-block:: yaml + + - name: Configure hostname and domain-name + cisco.iosxr.iosxr_system: + hostname: iosxr01 + domain_name: test.example.com + domain_search: + - ansible.com + - redhat.com + - cisco.com + + +Warning +-------- +Never store passwords in plain text. We recommend using SSH keys to authenticate SSH connections. Ansible supports ssh-agent to manage your SSH keys. If you must use passwords to authenticate SSH connections, we recommend encrypting them with Ansible Vault. + +Cisco IOS-XR platform support matrix +=================================== + +The following platforms and software versions have been certified by Cisco to work with this version of Ansible. + +.. table:: Platform / Software Minimum Requirements + :align: center + + =================== ====================== + Supported Platforms Minimum IOS-XR Version + =================== ====================== + Cisco IOS-XR 7.0.2 and later + =================== ====================== + + +Notes +----- + +`Setting Timeout Option `_ diff --git a/plugins/module_utils/network/iosxr/argspec/bgp_templates/bgp_templates.py b/plugins/module_utils/network/iosxr/argspec/bgp_templates/bgp_templates.py index 793f26282..51a70c5fd 100644 --- a/plugins/module_utils/network/iosxr/argspec/bgp_templates/bgp_templates.py +++ b/plugins/module_utils/network/iosxr/argspec/bgp_templates/bgp_templates.py @@ -48,7 +48,14 @@ class Bgp_templatesArgs(object): # pylint: disable=R0903 "options": { "afi": { "type": "str", - "choices": ["ipv4", "ipv6"], + "choices": [ + "ipv4", + "ipv6", + "vpnv4", + "vpnv6", + "link-state", + "l2vpn", + ], }, "safi": { "type": "str", @@ -62,6 +69,10 @@ class Bgp_templatesArgs(object): # pylint: disable=R0903 "unicast", "labeled-unicast", "sr-policy", + "link-state", + "evpn", + "mspw", + "vpls-vpws", ], }, "signalling": { diff --git a/plugins/module_utils/network/iosxr/facts/interfaces/interfaces.py b/plugins/module_utils/network/iosxr/facts/interfaces/interfaces.py index becdae1e7..5efcd6084 100644 --- a/plugins/module_utils/network/iosxr/facts/interfaces/interfaces.py +++ b/plugins/module_utils/network/iosxr/facts/interfaces/interfaces.py @@ -112,4 +112,4 @@ def render_config(self, spec, conf): enabled = utils.parse_conf_cmd_arg(conf, "shutdown", False) config["enabled"] = enabled if enabled is not None else True - return utils.remove_empties(config) + return utils.remove_empties(config) diff --git a/plugins/module_utils/network/iosxr/facts/l2_interfaces/l2_interfaces.py b/plugins/module_utils/network/iosxr/facts/l2_interfaces/l2_interfaces.py index 19150c1f0..f562e20f8 100644 --- a/plugins/module_utils/network/iosxr/facts/l2_interfaces/l2_interfaces.py +++ b/plugins/module_utils/network/iosxr/facts/l2_interfaces/l2_interfaces.py @@ -155,4 +155,4 @@ def render_config(self, spec, conf): if cpsv: config["l2protocol"].append({"cpsv": cpsv}) - return utils.remove_empties(config) + return utils.remove_empties(config) diff --git a/plugins/module_utils/network/iosxr/facts/l3_interfaces/l3_interfaces.py b/plugins/module_utils/network/iosxr/facts/l3_interfaces/l3_interfaces.py index 4d0158e25..b4dba858e 100644 --- a/plugins/module_utils/network/iosxr/facts/l3_interfaces/l3_interfaces.py +++ b/plugins/module_utils/network/iosxr/facts/l3_interfaces/l3_interfaces.py @@ -94,43 +94,43 @@ def render_config(self, spec, conf): """ config = deepcopy(spec) match = re.search(r"^(\S+)", conf) - - intf = match.group(1) - if match.group(1).lower() == "preconfigure": - match = re.search(r"^(\S+) (.*)", conf) - if match: - intf = match.group(2) - - if get_interface_type(intf) == "unknown": - return {} - - # populate the facts from the configuration - config["name"] = intf - - # Get the configured IPV4 details - ipv4 = [] - ipv4_all = re.findall(r"ipv4 address (\S+.*)", conf) - for each in ipv4_all: - each_ipv4 = dict() - if "secondary" in each: - each_ipv4["address"] = self.format_ipv4(each.split(" secondary")[0]) - each_ipv4["secondary"] = True - elif "secondary" not in each and "dhcp" not in each: - each_ipv4["address"] = self.format_ipv4(each) - elif "dhcp" in each: - each_ipv4["address"] = "dhcp" - ipv4.append(each_ipv4) - config["ipv4"] = ipv4 - - # Get the configured IPV6 details - ipv6 = [] - ipv6_all = re.findall(r"ipv6 address (\S+)", conf) - for each in ipv6_all: - each_ipv6 = dict() - each_ipv6["address"] = each - ipv6.append(each_ipv6) - config["ipv6"] = ipv6 - return utils.remove_empties(config) + if match: + intf = match.group(1) + if match.group(1).lower() == "preconfigure": + match = re.search(r"^(\S+) (.*)", conf) + if match: + intf = match.group(2) + + if get_interface_type(intf) == "unknown": + return {} + + # populate the facts from the configuration + config["name"] = intf + + # Get the configured IPV4 details + ipv4 = [] + ipv4_all = re.findall(r"ipv4 address (\S+.*)", conf) + for each in ipv4_all: + each_ipv4 = dict() + if "secondary" in each: + each_ipv4["address"] = self.format_ipv4(each.split(" secondary")[0]) + each_ipv4["secondary"] = True + elif "secondary" not in each and "dhcp" not in each: + each_ipv4["address"] = self.format_ipv4(each) + elif "dhcp" in each: + each_ipv4["address"] = "dhcp" + ipv4.append(each_ipv4) + config["ipv4"] = ipv4 + + # Get the configured IPV6 details + ipv6 = [] + ipv6_all = re.findall(r"ipv6 address (\S+)", conf) + for each in ipv6_all: + each_ipv6 = dict() + each_ipv6["address"] = each + ipv6.append(each_ipv6) + config["ipv6"] = ipv6 + return utils.remove_empties(config) def format_ipv4(self, address): if address.split(" ")[1]: diff --git a/plugins/module_utils/network/iosxr/facts/legacy/base.py b/plugins/module_utils/network/iosxr/facts/legacy/base.py index cc657f42a..2baf42c9f 100644 --- a/plugins/module_utils/network/iosxr/facts/legacy/base.py +++ b/plugins/module_utils/network/iosxr/facts/legacy/base.py @@ -123,6 +123,8 @@ class Interfaces(FactsBase): "show ipv6 interface", "show lldp", "show lldp neighbors detail", + "show cdp", + "show cdp neighbors detail", ] def populate(self): @@ -142,6 +144,10 @@ def populate(self): neighbors = self.responses[3] self.facts["neighbors"] = self.parse_neighbors(neighbors) + if "CDP is not enabled" not in self.responses[4]: + neighbors = self.responses[5] + self.facts["neighbors"] = self.parse_cdp_neighbors(neighbors) + def populate_interfaces(self, interfaces): facts = dict() for key, value in iteritems(interfaces): @@ -200,6 +206,25 @@ def parse_neighbors(self, neighbors): facts[intf].append(fact) return facts + def parse_cdp_neighbors(self, neighbors): + facts = dict() + for entry in neighbors.split("-------------------------"): + if entry == "": + continue + intf_port = self.parse_cdp_intf_port(entry) + if intf_port is None: + return facts + intf, port = intf_port + if intf not in facts: + facts[intf] = list() + fact = dict() + fact["host"] = self.parse_cdp_host(entry) + fact["platform"] = self.parse_cdp_platform(entry) + fact["port"] = port + fact["ip"] = self.parse_cdp_ip(entry) + facts[intf].append(fact) + return facts + def parse_interfaces(self, data): parsed = dict() key = "" @@ -281,3 +306,23 @@ def parse_lldp_port(self, data): match = re.search(r"Port id: (.+)$", data, re.M) if match: return match.group(1) + + def parse_cdp_intf_port(self, data): + match = re.search(r"^Interface: (.+), Port ID \(outgoing port\): (.+)$", data, re.M) + if match: + return match.group(1), match.group(2) + + def parse_cdp_host(self, data): + match = re.search(r"^Device ID: (.+)$", data, re.M) + if match: + return match.group(1) + + def parse_cdp_platform(self, data): + match = re.search(r"^Platform: (.+),", data, re.M) + if match: + return match.group(1) + + def parse_cdp_ip(self, data): + match = re.search(r"^ IP address: (.+)$", data, re.M) + if match: + return match.group(1) diff --git a/plugins/modules/iosxr_acl_interfaces.py b/plugins/modules/iosxr_acl_interfaces.py index 7dc8df807..80dcc44f4 100644 --- a/plugins/modules/iosxr_acl_interfaces.py +++ b/plugins/modules/iosxr_acl_interfaces.py @@ -130,27 +130,26 @@ - name: Merge the provided configuration with the existing running configuration cisco.iosxr.iosxr_acl_interfaces: config: - - name: GigabitEthernet0/0/0/0 - access_groups: - - afi: ipv4 - acls: - - name: acl_1 - direction: in - - name: acl_2 - direction: out - - afi: ipv6 - acls: - - name: acl6_1 - direction: in - - name: acl6_2 - direction: out - - - name: GigabitEthernet0/0/0/1 - access_groups: - - afi: ipv4 - acls: - - name: acl_1 - direction: out + - name: GigabitEthernet0/0/0/0 + access_groups: + - afi: ipv4 + acls: + - name: acl_1 + direction: in + - name: acl_2 + direction: out + - afi: ipv6 + acls: + - name: acl6_1 + direction: in + - name: acl6_2 + direction: out + - name: GigabitEthernet0/0/0/1 + access_groups: + - afi: ipv4 + acls: + - name: acl_1 + direction: out state: merged # After state: @@ -199,14 +198,14 @@ - name: Update acl_interfaces configuration using merged cisco.iosxr.iosxr_acl_interfaces: config: - - name: GigabitEthernet0/0/0/1 - access_groups: - - afi: ipv4 - acls: - - name: acl_2 - direction: out - - name: acl_1 - direction: in + - name: GigabitEthernet0/0/0/1 + access_groups: + - afi: ipv4 + acls: + - name: acl_2 + direction: out + - name: acl_1 + direction: in state: merged # After state: @@ -253,15 +252,17 @@ # ipv4 access-group acl_1 egress # ! -- name: Replace device configurations of listed interface with provided configurations +- name: >- + Replace device configurations of listed interface with provided + configurations cisco.iosxr.iosxr_acl_interfaces: config: - - name: GigabitEthernet0/0/0/0 - access_groups: - - afi: ipv6 - acls: - - name: acl6_3 - direction: in + - name: GigabitEthernet0/0/0/0 + access_groups: + - afi: ipv6 + acls: + - name: acl6_3 + direction: in state: replaced # After state: @@ -308,16 +309,16 @@ - name: Overridde all interface ACL configuration with provided configuration cisco.iosxr.iosxr_acl_interfaces: config: - - name: GigabitEthernet0/0/0/1 - access_groups: - - afi: ipv4 - acls: - - name: acl_2 - direction: in - - afi: ipv6 - acls: - - name: acl6_3 - direction: out + - name: GigabitEthernet0/0/0/1 + access_groups: + - afi: ipv4 + acls: + - name: acl_2 + direction: in + - afi: ipv6 + acls: + - name: acl6_3 + direction: out state: overridden # After state: @@ -364,7 +365,7 @@ - name: Delete all ACL attributes of GigabitEthernet0/0/0/1 cisco.iosxr.iosxr_acl_interfaces: config: - - name: GigabitEthernet0/0/0/1 + - name: GigabitEthernet0/0/0/1 state: deleted # After state: @@ -564,14 +565,14 @@ - name: Render platform specific commands from task input using rendered state cisco.iosxr.iosxr_acl_interfaces: config: - - name: GigabitEthernet0/0/0/0 - access_groups: - - afi: ipv4 - acls: - - name: acl_1 - direction: in - - name: acl_2 - direction: out + - name: GigabitEthernet0/0/0/0 + access_groups: + - afi: ipv4 + acls: + - name: acl_1 + direction: in + - name: acl_2 + direction: out state: rendered # Task Output (redacted) diff --git a/plugins/modules/iosxr_acls.py b/plugins/modules/iosxr_acls.py index 813eb12ab..620838353 100644 --- a/plugins/modules/iosxr_acls.py +++ b/plugins/modules/iosxr_acls.py @@ -709,85 +709,80 @@ - name: Merge the provided configuration with the existing running configuration cisco.iosxr.iosxr_acls: config: - - afi: ipv6 - acls: - - name: acl6_1 - aces: - - sequence: 10 - grant: deny - protocol: tcp - source: - prefix: 2001:db8:1234::/48 - port_protocol: - range: - start: ftp - end: telnet - destination: - any: true - protocol_options: - tcp: - syn: true - ttl: - range: - start: 180 - end: 250 - routing: true - authen: true - log: true - - - sequence: 20 - grant: permit - protocol: icmpv6 - source: - any: true - destination: - any: true - protocol_options: - icmpv6: - router_advertisement: true - precedence: network - destopts: true - - - afi: ipv4 - acls: - - name: acl_1 - aces: - - sequence: 16 - remark: TEST_ACL_1_REMARK - - - sequence: 21 - grant: permit - protocol: tcp - source: - host: 192.0.2.10 - port_protocol: - range: - start: pop3 - end: 121 - destination: - address: 198.51.100.0 - wildcard_bits: 0.0.0.15 - protocol_options: - tcp: - rst: true - - - sequence: 23 - grant: deny - protocol: icmp - source: - any: true - destination: - prefix: 198.51.100.0/28 - protocol_options: - icmp: - reassembly_timeout: true - dscp: - lt: af12 - - - name: acl_2 - aces: - - sequence: 10 - remark: TEST_ACL_2_REMARK + - afi: ipv6 + acls: + - name: acl6_1 + aces: + - sequence: 10 + grant: deny + protocol: tcp + source: + prefix: '2001:db8:1234::/48' + port_protocol: + range: + start: ftp + end: telnet + destination: + any: true + protocol_options: + tcp: + syn: true + ttl: + range: + start: 180 + end: 250 + routing: true + authen: true + log: true + - sequence: 20 + grant: permit + protocol: icmpv6 + source: + any: true + destination: + any: true + protocol_options: + icmpv6: + router_advertisement: true + precedence: network + destopts: true + - afi: ipv4 + acls: + - name: acl_1 + aces: + - sequence: 16 + remark: TEST_ACL_1_REMARK + - sequence: 21 + grant: permit + protocol: tcp + source: + host: 192.0.2.10 + port_protocol: + range: + start: pop3 + end: 121 + destination: + address: 198.51.100.0 + wildcard_bits: 0.0.0.15 + protocol_options: + tcp: + rst: true + - sequence: 23 + grant: deny + protocol: icmp + source: + any: true + destination: + prefix: 198.51.100.0/28 + protocol_options: + icmp: + reassembly_timeout: true + dscp: + lt: af12 + - name: acl_2 + aces: + - sequence: 10 + remark: TEST_ACL_2_REMARK state: merged # Task Output @@ -954,7 +949,6 @@ protocol_options: tcp: syn: true - - sequence: 23 protocol_options: icmp: @@ -1191,7 +1185,6 @@ any: true ttl: eq: 100 - - sequence: 12 grant: deny source: @@ -1440,7 +1433,6 @@ destination: any: true protocol: tcp - - name: acl_2 aces: - sequence: 20 @@ -2110,27 +2102,26 @@ - name: Render platform specific commands (without connecting to the device) cisco.iosxr.iosxr_acls: config: - - afi: ipv4 - acls: - - name: acl_2 - aces: - - sequence: 11 - grant: permit - protocol: igmp - source: - host: 198.51.100.130 - destination: - any: true - ttl: - eq: 100 - - - sequence: 12 - grant: deny - source: - any: true - destination: - any: true - protocol: icmp + - afi: ipv4 + acls: + - name: acl_2 + aces: + - sequence: 11 + grant: permit + protocol: igmp + source: + host: 198.51.100.130 + destination: + any: true + ttl: + eq: 100 + - sequence: 12 + grant: deny + source: + any: true + destination: + any: true + protocol: icmp state: rendered # Task Output (redacted) diff --git a/plugins/modules/iosxr_banner.py b/plugins/modules/iosxr_banner.py index 2d80022b9..909d79511 100644 --- a/plugins/modules/iosxr_banner.py +++ b/plugins/modules/iosxr_banner.py @@ -70,7 +70,7 @@ - name: Configure banner from file cisco.iosxr.iosxr_banner: banner: motd - text: "{{ lookup('file', './config_partial/raw_banner.cfg') }}" + text: '{{ lookup(''file'', ''./config_partial/raw_banner.cfg'') }}' state: present """ diff --git a/plugins/modules/iosxr_bgp_address_family.py b/plugins/modules/iosxr_bgp_address_family.py index 3010a2f7f..b0cf5a8c7 100644 --- a/plugins/modules/iosxr_bgp_address_family.py +++ b/plugins/modules/iosxr_bgp_address_family.py @@ -492,17 +492,17 @@ cisco.iosxr.iosxr_bgp_address_family: state: merged config: - as_number: "65536" + as_number: '65536' address_family: - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast vrf: vrf1 dynamic_med: 9 redistribute: - protocol: connected metric: 10 - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast dynamic_med: 10 redistribute: - protocol: application @@ -597,10 +597,10 @@ cisco.iosxr.iosxr_bgp_address_family: state: replaced config: - as_number: "65536" + as_number: '65536' address_family: - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast vrf: vrf1 dynamic_med: 10 # Task output @@ -674,10 +674,10 @@ cisco.iosxr.iosxr_bgp_address_family: state: overridden config: - as_number: "65536" + as_number: '65536' address_family: - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast vrf: vrf1 dynamic_med: 10 @@ -768,17 +768,17 @@ cisco.iosxr.iosxr_bgp_address_family: state: rendered config: - as_number: "65536" + as_number: '65536' address_family: - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast vrf: vrf1 dynamic_med: 9 redistribute: - protocol: connected metric: 10 - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast dynamic_med: 10 redistribute: - protocol: application @@ -808,21 +808,21 @@ # # Using gathered # ------------- -- name: Merge the provided configuration with the existing running configuration +- name: Gather existing running configuration cisco.iosxr.iosxr_bgp_address_family: state: gathered config: - as_number: "65536" + as_number: '65536' address_family: - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast vrf: vrf1 dynamic_med: 9 redistribute: - protocol: connected metric: 10 - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast dynamic_med: 10 redistribute: - protocol: application @@ -860,8 +860,8 @@ # # Using parsed # -#parsed.cfg -#------------ +# parsed.cfg +# ------------ # router bgp 65536 # bgp router-id 192.0.1.1 # address-family ipv4 unicast diff --git a/plugins/modules/iosxr_bgp_global.py b/plugins/modules/iosxr_bgp_global.py index d7f344409..fe444a9ea 100644 --- a/plugins/modules/iosxr_bgp_global.py +++ b/plugins/modules/iosxr_bgp_global.py @@ -939,45 +939,44 @@ # # Before state # ------------ - # RP/0/0/CPU0:10#show running-config router bgp # Thu Feb 4 09:38:36.245 UTC # % No such configuration item(s) # RP/0/0/CPU0:10# - - name: Merge the following BGP global configuration - cisco.iosxr.iosxr_bgp_global: - config: - as_number: 65536 - default_metric: 5 - socket: - receive_buffer_size: 514 - send_buffer_size: 4098 - bgp: - confederation: - identifier: 4 - bestpath: - med: - confed: True - cluster_id: 5 - router_id: 192.0.2.10 - neighbors: - - neighbor: 192.0.2.13 - remote_as: 65538 - bfd: - fast_detect: - strict_mode: True - multiplier: 6 - minimum_interval: 20 - vrfs: - - vrf: vrf1 - default_metric: 5 +- name: Merge the following BGP global configuration + cisco.iosxr.iosxr_bgp_global: + config: + as_number: 65536 + default_metric: 5 + socket: + receive_buffer_size: 514 + send_buffer_size: 4098 + bgp: + confederation: + identifier: 4 + bestpath: + med: + confed: true + cluster_id: 5 + router_id: 192.0.2.10 + neighbors: + - neighbor: 192.0.2.13 + remote_as: 65538 + bfd: + fast_detect: + strict_mode: true + multiplier: 6 + minimum_interval: 20 + vrfs: + - vrf: vrf1 + default_metric: 5 +# # Task Output: -# ------------ +# --------------- # # before: {} - # commands: # - router bgp 65536 # - bgp cluster-id 5 @@ -1071,37 +1070,38 @@ # ! # ! - - name: Replace the following configuration - cisco.iosxr.iosxr_bgp_global: - state: replaced - config: - as_number: 65536 - default_metric: 4 - socket: - receive_buffer_size: 514 - send_buffer_size: 4098 - bgp: - confederation: - identifier: 4 - bestpath: - med: - confed: True - cluster_id: 5 - router_id: 192.0.2.10 - neighbors: - - neighbor: 192.0.2.14 - remote_as: 65538 - bfd: - fast_detect: - strict_mode: True - multiplier: 6 - minimum_interval: 20 - vrfs: - - vrf: vrf1 - default_metric: 5 +- name: Replace the following configuration + cisco.iosxr.iosxr_bgp_global: + state: replaced + config: + as_number: 65536 + default_metric: 4 + socket: + receive_buffer_size: 514 + send_buffer_size: 4098 + bgp: + confederation: + identifier: 4 + bestpath: + med: + confed: true + cluster_id: 5 + router_id: 192.0.2.10 + neighbors: + - neighbor: 192.0.2.14 + remote_as: 65538 + bfd: + fast_detect: + strict_mode: true + multiplier: 6 + minimum_interval: 20 + vrfs: + - vrf: vrf1 + default_metric: 5 +# # Task Output: -# ------------ +# ------------- # # before: # as_number: '65536' @@ -1215,37 +1215,37 @@ # ! # ! - - name: Override running config with provided configuration - cisco.iosxr.iosxr_bgp_global: - state: overridden - config: - as_number: 65536 - default_metric: 4 - socket: - receive_buffer_size: 514 - send_buffer_size: 4098 - bgp: - confederation: - identifier: 4 - bestpath: - med: - confed: True - cluster_id: 5 - router_id: 192.0.2.10 - neighbors: - - neighbor: 192.0.2.14 - remote_as: 65538 - bfd: - fast_detect: - strict_mode: True - multiplier: 6 - minimum_interval: 20 - vrfs: - - vrf: vrf1 - default_metric: 5 +- name: Override running config with provided configuration + cisco.iosxr.iosxr_bgp_global: + state: overridden + config: + as_number: 65536 + default_metric: 4 + socket: + receive_buffer_size: 514 + send_buffer_size: 4098 + bgp: + confederation: + identifier: 4 + bestpath: + med: + confed: true + cluster_id: 5 + router_id: 192.0.2.10 + neighbors: + - neighbor: 192.0.2.14 + remote_as: 65538 + bfd: + fast_detect: + strict_mode: true + multiplier: 6 + minimum_interval: 20 + vrfs: + - vrf: vrf1 + default_metric: 5 # # Task Output: -# ------------ +# ------------- # # before: # as_number: '65536' @@ -1360,14 +1360,15 @@ # ! # - - name: Delete BGP configurations handled by this module - cisco.iosxr.iosxr_bgp_global: - config: - as_number: 65536 - state: deleted +- name: Delete BGP configurations handled by this module + cisco.iosxr.iosxr_bgp_global: + config: + as_number: 65536 + state: deleted +# # Task Output: -# ------------ +# ------------- # # before: # as_number: '65536' @@ -1446,13 +1447,13 @@ # ! # - - name: Purge all BGP configurations from the device - cisco.iosxr.iosxr_bgp_global: - state: purged +- name: Purge all BGP configurations from the device + cisco.iosxr.iosxr_bgp_global: + state: purged # # Task Output: -# ------------ +# ------------- # # before: # as_number: '65536' @@ -1492,49 +1493,54 @@ # Thu Feb 4 09:38:36.245 UTC # % No such configuration item(s) # RP/0/0/CPU0:10# +# -# Using replaced # - - name: Render platform specific configuration lines (without connecting to the device) - cisco.iosxr.iosxr_bgp_global: - state: rendered - config: - as_number: 1 - default_metric: 4 - vrfs: - - vrf: vrf3 - bfd: - minimum_interval: 20 - multiplier: 10 - bgp: - fast_external_fallover: - disable: True - router_id: 1.2.3.4 - auto_policy_soft_reset: - disable: True - timers: - keepalive_time: 20 - holdtime: 30 - - vrf: vrf2 - bgp: - enforce_first_as: - disable: True - default_metric: 4 - neighbors: - - neighbor: 1.1.1.3 - remote_as: 2 - graceful_maintenance: - set: True - activate: - inheritance_disable: True - local_preference: - value: 1 - as_prepends: - value: 2 +# Using Rendered +# ----------------- +# +- name: >- + Render platform specific configuration lines (without connecting to the + device) + cisco.iosxr.iosxr_bgp_global: + state: rendered + config: + as_number: 1 + default_metric: 4 + vrfs: + - vrf: vrf3 + bfd: + minimum_interval: 20 + multiplier: 10 + bgp: + fast_external_fallover: + disable: true + router_id: 1.2.3.4 + auto_policy_soft_reset: + disable: true + timers: + keepalive_time: 20 + holdtime: 30 + - vrf: vrf2 + bgp: + enforce_first_as: + disable: true + default_metric: 4 + neighbors: + - neighbor: 1.1.1.3 + remote_as: 2 + graceful_maintenance: + set: true + activate: + inheritance_disable: true + local_preference: + value: 1 + as_prepends: + value: 2 -# Task Output: -# ------------ # +# Task output +# ----------------------- # rendered: # - router bgp 1 # - default-metric 4 @@ -1580,14 +1586,13 @@ # ! # - - name: Parse externally provided BGP config - cisco.iosxr.iosxr_bgp_global: - running_config: "{{ lookup('file', 'parsed.cfg') }}" - state: parsed +- name: Parse externally provided BGP config + cisco.iosxr.iosxr_bgp_global: + running_config: "{{ lookup('file', 'parsed.cfg') }}" + state: parsed -# Task Output: -# ------------ -# +# Task output +# ----------------------- # parsed: # as_number: '65536' # bgp: @@ -1641,9 +1646,9 @@ # ! # ! - - name: Gather bgp global facts - cisco.iosxr.iosxr_bgp_global: - state: gathered +- name: Gather bgp global facts + cisco.iosxr.iosxr_bgp_global: + state: gathered # Task Output: # ------------ @@ -1673,7 +1678,6 @@ # vrfs: # - default_metric: 5 # vrf: vrf1 - """ RETURN = """ before: diff --git a/plugins/modules/iosxr_bgp_neighbor_address_family.py b/plugins/modules/iosxr_bgp_neighbor_address_family.py index 85903d307..4657d771a 100644 --- a/plugins/modules/iosxr_bgp_neighbor_address_family.py +++ b/plugins/modules/iosxr_bgp_neighbor_address_family.py @@ -418,16 +418,16 @@ neighbors: - neighbor_address: 192.0.2.2 address_family: - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast multipath: true default_originate: set: true weight: 5 - neighbor_address: 192.0.2.3 address_family: - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast multipath: true default_originate: set: true @@ -437,8 +437,8 @@ neighbors: - neighbor_address: 192.0.2.4 address_family: - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast multipath: true default_originate: set: true @@ -447,8 +447,8 @@ neighbors: - neighbor_address: 192.0.2.5 address_family: - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast multipath: true default_originate: set: true @@ -600,7 +600,7 @@ # capability orf prefix both # default-originate -- name: Delete the provided configuration +- name: Delete the provided configuration cisco.iosxr.iosxr_bgp_neighbor_address_family: state: deleted config: @@ -608,8 +608,8 @@ neighbors: - neighbor_address: 192.0.2.2 address_family: - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast multipath: true default_originate: set: true @@ -703,8 +703,8 @@ neighbors: - neighbor_address: 192.0.2.2 address_family: - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast default_originate: set: true weight: 4 @@ -831,7 +831,7 @@ # capability orf prefix both # default-originate -- name: override the provided configuration +- name: override the provided configuration cisco.iosxr.iosxr_bgp_neighbor_address_family: state: overridden config: @@ -839,8 +839,8 @@ neighbors: - neighbor_address: 192.0.2.2 address_family: - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast multipath: true default_originate: set: true @@ -912,7 +912,9 @@ # neighbor 192.0.2.5 # remote-as 65540 -- name: Render platform specific configuration lines with state rendered (without connecting to the device) +- name: >- + Render platform specific configuration lines with state rendered (without + connecting to the device) cisco.iosxr.iosxr_bgp_neighbor_address_family: state: rendered config: @@ -920,16 +922,16 @@ neighbors: - neighbor_address: 192.0.2.2 address_family: - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast multipath: true default_originate: set: true weight: 5 - neighbor_address: 192.0.2.3 address_family: - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast multipath: true default_originate: set: true @@ -939,8 +941,8 @@ neighbors: - neighbor_address: 192.0.2.4 address_family: - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast multipath: true default_originate: set: true @@ -949,8 +951,8 @@ neighbors: - neighbor_address: 192.0.2.5 address_family: - - afi: "ipv4" - safi: "unicast" + - afi: ipv4 + safi: unicast multipath: true default_originate: set: true @@ -984,8 +986,8 @@ # # Using parsed # -#parsed.cfg -#------------ +# parsed.cfg +# ------------ # router bgp 65536 # bgp router-id 192.0.1.1 # address-family ipv4 unicast @@ -1067,8 +1069,8 @@ # capability_orf_prefix: both # # -#Using Gathered -#----------------- +# Using Gathered +# ----------------- # Before state state: # ------------- # RP/0/0/CPU0:iosxr-02#show running-config router bgp @@ -1110,8 +1112,8 @@ # - name: Gathered the provided configuration with the existing running configuration cisco.iosxr.iosxr_bgp_neighbor_address_family: - config: - state: gathered + config: + state: gathered # Task output @@ -1157,7 +1159,6 @@ # set: true # capability_orf_prefix: both # - """ from ansible.module_utils.basic import AnsibleModule diff --git a/plugins/modules/iosxr_bgp_templates.py b/plugins/modules/iosxr_bgp_templates.py index 6800ed60a..b57ac4f9f 100644 --- a/plugins/modules/iosxr_bgp_templates.py +++ b/plugins/modules/iosxr_bgp_templates.py @@ -46,11 +46,12 @@ afi: description: address family. type: str - choices: [ 'ipv4', 'ipv6' ] + choices: [ 'ipv4', 'ipv6', 'vpnv4', 'vpnv6', 'link-state', 'l2vpn'] safi: description: Address Family modifier type: str - choices: [ 'flowspec', 'mdt', 'multicast', 'mvpn', 'rt-filter', 'tunnel', 'unicast', 'labeled-unicast' , 'sr-policy'] + choices: [ 'flowspec', 'mdt', 'multicast', 'mvpn', 'rt-filter', 'tunnel', + 'unicast', 'labeled-unicast' , 'sr-policy', 'link-state', 'evpn', 'mspw', 'vpls-vpws'] signalling: type: dict description: Signalling protocols to disable, BGP or LDP @@ -798,52 +799,52 @@ - name: Merge the provided configuration with the existing running configuration cisco.iosxr.iosxr_bgp_templates: config: - as_number: 65536 - neighbor: - - address_family: - - advertise: - local_labeled_route: - set: true - afi: ipv4 - safi: unicast - advertisement_interval: 10 - bfd: - fast_detect: - strict_mode: true - internal_vpn_client: true - name: neighbor-group1 - precedence: critical - - cluster_id: "1" - description: neighbor-group2 - dmz_link_bandwidth: - set: true - ebgp_multihop: - value: 255 - egress_engineering: - set: true - graceful_maintenance: - as_prepends: - value: 0 - set: true - ignore_connected_check: - set: true - internal_vpn_client: true - local: - address: - inheritance_disable: true - local_as: - value: 6 - name: neighbor-group2 - precedence: flash - receive_buffer_size: 512 - send_buffer_size: 4096 - session_open_mode: both - tcp: - mss: - inheritance_disable: true - ttl_security: - set: true - update_source: Loopback919 + as_number: 65536 + neighbor: + - address_family: + - advertise: + local_labeled_route: + set: true + afi: ipv4 + safi: unicast + advertisement_interval: 10 + bfd: + fast_detect: + strict_mode: true + internal_vpn_client: true + name: neighbor-group1 + precedence: critical + - cluster_id: '1' + description: neighbor-group2 + dmz_link_bandwidth: + set: true + ebgp_multihop: + value: 255 + egress_engineering: + set: true + graceful_maintenance: + as_prepends: + value: 0 + set: true + ignore_connected_check: + set: true + internal_vpn_client: true + local: + address: + inheritance_disable: true + local_as: + value: 6 + name: neighbor-group2 + precedence: flash + receive_buffer_size: 512 + send_buffer_size: 4096 + session_open_mode: both + tcp: + mss: + inheritance_disable: true + ttl_security: + set: true + update_source: Loopback919 state: merged # Task Output @@ -1003,29 +1004,29 @@ - name: Replaced given bgp_templates configuration cisco.iosxr.iosxr_bgp_templates: - config: - as_number: 65536 - neighbor: - - address_family: - - advertise: - local_labeled_route: - set: true - afi: ipv4 - safi: unicast - advertisement_interval: 12 - name: neighbor-group1 - precedence: flash - - cluster_id: "2" - description: replace neighbor-group2 - ebgp_multihop: - value: 254 - graceful_maintenance: - as_prepends: - value: 2 - set: true - update_source: Loopback917 - name: neighbor-group2 - state: replaced + config: + as_number: 65536 + neighbor: + - address_family: + - advertise: + local_labeled_route: + set: true + afi: ipv4 + safi: unicast + advertisement_interval: 12 + name: neighbor-group1 + precedence: flash + - cluster_id: '2' + description: replace neighbor-group2 + ebgp_multihop: + value: 254 + graceful_maintenance: + as_prepends: + value: 2 + set: true + update_source: Loopback917 + name: neighbor-group2 + state: replaced # Task Output # ----------- @@ -1174,8 +1175,8 @@ - name: Delete given bgp_nbr_address_family configuration cisco.iosxr.iosxr_bgp_templates: &deleted - config: - state: deleted + config: + state: deleted # Task Output # ----------- @@ -1215,8 +1216,6 @@ # # RP/0/RP0/CPU0:10# - - # Using gathered # Before state: # ------------- @@ -1257,8 +1256,8 @@ - name: Gather given bgp_templates configuration cisco.iosxr.iosxr_bgp_templates: &id001 - config: - state: gathered + config: + state: gathered # Task output # ----------- @@ -1349,25 +1348,24 @@ # internal-vpn-client # ! # ! - - name: override given bgp_templates configuration cisco.iosxr.iosxr_bgp_templates: - config: - as_number: 65536 - neighbor: - - address_family: - - advertise: - local_labeled_route: - disable: true - afi: ipv4 - safi: unicast - advertisement_interval: 12 - bfd: - fast_detect: - strict_mode: true - name: neighbor-group1 - precedence: flash - state: overridden + config: + as_number: 65536 + neighbor: + - address_family: + - advertise: + local_labeled_route: + disable: true + afi: ipv4 + safi: unicast + advertisement_interval: 12 + bfd: + fast_detect: + strict_mode: true + name: neighbor-group1 + precedence: flash + state: overridden # Task Output # ----------- @@ -1446,7 +1444,9 @@ # Using rendered -- name: Render platform specific configuration lines with state rendered (without connecting to the device) +- name: >- + Render platform specific configuration lines with state rendered (without + connecting to the device) cisco.iosxr.iosxr_bgp_templates: config: as_number: 65536 @@ -1464,7 +1464,7 @@ internal_vpn_client: true name: neighbor-group1 precedence: critical - - cluster_id: "1" + - cluster_id: '1' description: neighbor-group2 dmz_link_bandwidth: set: true diff --git a/plugins/modules/iosxr_command.py b/plugins/modules/iosxr_command.py index d85f99d1f..f6ff502a4 100644 --- a/plugins/modules/iosxr_command.py +++ b/plugins/modules/iosxr_command.py @@ -88,32 +88,32 @@ - name: run multiple commands on remote nodes cisco.iosxr.iosxr_command: commands: - - show version - - show interfaces - - {command: example command that prompts, prompt: expected prompt, answer: yes} + - show version + - show interfaces + - {command: example command that prompts, prompt: expected prompt, answer: true} - name: run multiple commands and evaluate the output cisco.iosxr.iosxr_command: commands: - - show version - - show interfaces + - show version + - show interfaces wait_for: - - result[0] contains IOS-XR - - result[1] contains Loopback0 + - result[0] contains IOS-XR + - result[1] contains Loopback0 -- name: multiple prompt, multiple answer (mandatory check for all prompts) +- name: 'multiple prompt, multiple answer (mandatory check for all prompts)' cisco.iosxr.iosxr_command: commands: - - command: key config-key password-encryption - prompt: - - "Enter old key :" - - "Enter new key :" - - "Enter confirm key :" - answer: - - "test1234" - - "test12345" - - "test12345" - check_all: true + - command: key config-key password-encryption + prompt: + - 'Enter old key :' + - 'Enter new key :' + - 'Enter confirm key :' + answer: + - test1234 + - test12345 + - test12345 + check_all: true """ RETURN = """ diff --git a/plugins/modules/iosxr_config.py b/plugins/modules/iosxr_config.py index bef0477fd..7fc59fefa 100644 --- a/plugins/modules/iosxr_config.py +++ b/plugins/modules/iosxr_config.py @@ -195,28 +195,26 @@ - name: configure interface settings cisco.iosxr.iosxr_config: lines: - - description test interface - - ip address 172.31.1.1 255.255.255.0 + - description test interface + - ip address 172.31.1.1 255.255.255.0 parents: interface GigabitEthernet0/0/0/0 - name: load a config from disk and replace the current config cisco.iosxr.iosxr_config: src: config.cfg replace: config - backup: yes + backup: 'yes' -- name: for idempotency, use full-form commands +- name: 'for idempotency, use full-form commands' cisco.iosxr.iosxr_config: lines: - # - shut - - shutdown - # parents: int g0/0/0/1 + - shutdown parents: interface GigabitEthernet0/0/0/1 - name: configurable backup path cisco.iosxr.iosxr_config: src: config.cfg - backup: yes + backup: true backup_options: filename: backup.cfg dir_path: /home/user diff --git a/plugins/modules/iosxr_facts.py b/plugins/modules/iosxr_facts.py index c3e7df382..a85328ab2 100644 --- a/plugins/modules/iosxr_facts.py +++ b/plugins/modules/iosxr_facts.py @@ -67,25 +67,25 @@ # Collect only the config and default facts - cisco.iosxr.iosxr_facts: gather_subset: - - config + - config # Do not collect hardware facts - cisco.iosxr.iosxr_facts: gather_subset: - - '!hardware' + - '!hardware' # Collect only the lacp facts - cisco.iosxr.iosxr_facts: gather_subset: - - '!all' - - '!min' + - '!all' + - '!min' gather_network_resources: - - lacp + - lacp # Do not collect lacp_interfaces facts - cisco.iosxr.iosxr_facts: gather_network_resources: - - '!lacp_interfaces' + - '!lacp_interfaces' # Collect lacp and minimal default facts - cisco.iosxr.iosxr_facts: @@ -95,11 +95,11 @@ # Collect only the interfaces facts - cisco.iosxr.iosxr_facts: gather_subset: - - '!all' - - '!min' + - '!all' + - '!min' gather_network_resources: - - interfaces - - l2_interfaces + - interfaces + - l2_interfaces """ RETURN = """ @@ -172,7 +172,8 @@ returned: when interfaces is configured type: dict ansible_net_neighbors: - description: The list of LLDP neighbors from the remote device + description: The list of LLDP and CDP neighbors from the remote device. If both, + CDP and LLDP neighbor data is present on one port, CDP is preferred. returned: when interfaces is configured type: dict diff --git a/plugins/modules/iosxr_hostname.py b/plugins/modules/iosxr_hostname.py index a41aaf77d..7ea657a32 100644 --- a/plugins/modules/iosxr_hostname.py +++ b/plugins/modules/iosxr_hostname.py @@ -71,9 +71,9 @@ # Before state: # ------------- -#RP/0/RP0/CPU0:ios#show running-config hostname -#Thu Jan 20 19:48:56.011 UTC -#hostname ios +# RP/0/RP0/CPU0:ios#show running-config hostname +# Thu Jan 20 19:48:56.011 UTC +# hostname ios # Merged play: # ------------ @@ -94,7 +94,7 @@ # ------------ # RP/0/0/CPU0:Router1#show running-config hostname -#Thu Jan 20 19:48:56.011 UTC +# Thu Jan 20 19:48:56.011 UTC # hostname Router1 @@ -103,7 +103,7 @@ # ------------- # RP/0/0/CPU0:Router1#show running-config hostname -#Thu Jan 20 19:48:56.011 UTC +# Thu Jan 20 19:48:56.011 UTC # hostname Router1 # Deleted play: @@ -122,9 +122,9 @@ # After state: # ------------ -#RP/0/RP0/CPU0:ios#show running-config hostname -#Thu Jan 20 19:55:12.971 UTC -#hostname ios +# RP/0/RP0/CPU0:ios#show running-config hostname +# Thu Jan 20 19:55:12.971 UTC +# hostname ios # Using state: overridden # Before state: @@ -151,17 +151,17 @@ # After state: # ------------ -#RP/0/RP0/CPU0:RouterTest#show running-config hostname -#Thu Jan 20 19:48:56.011 UTC -#hostname RouterTest +# RP/0/RP0/CPU0:RouterTest#show running-config hostname +# Thu Jan 20 19:48:56.011 UTC +# hostname RouterTest # Using state: replaced # Before state: # ------------- -#RP/0/RP0/CPU0:RouterTest#show running-config hostname -#Thu Jan 20 19:48:56.011 UTC -#hostname RouterTest +# RP/0/RP0/CPU0:RouterTest#show running-config hostname +# Thu Jan 20 19:48:56.011 UTC +# hostname RouterTest # Replaced play: # -------------- @@ -185,9 +185,9 @@ # Before state: # ------------- -#RP/0/RP0/CPU0:RouterTest#show running-config hostname -#Thu Jan 20 19:48:56.011 UTC -#hostname RouterTest +# RP/0/RP0/CPU0:RouterTest#show running-config hostname +# Thu Jan 20 19:48:56.011 UTC +# hostname RouterTest # Gathered play: # -------------- diff --git a/plugins/modules/iosxr_interfaces.py b/plugins/modules/iosxr_interfaces.py index 4f4345d3c..bfa25edca 100644 --- a/plugins/modules/iosxr_interfaces.py +++ b/plugins/modules/iosxr_interfaces.py @@ -121,13 +121,13 @@ - name: Configure Ethernet interfaces cisco.iosxr.iosxr_interfaces: config: - - name: GigabitEthernet0/0/0/2 - description: Configured by Ansible - enabled: true - - name: GigabitEthernet0/0/0/3 - description: Configured by Ansible Network - enabled: false - duplex: full + - name: GigabitEthernet0/0/0/2 + description: Configured by Ansible + enabled: true + - name: GigabitEthernet0/0/0/3 + description: Configured by Ansible Network + enabled: false + duplex: full state: merged # Task Output @@ -204,14 +204,14 @@ - name: Replace their existing configuration per interface cisco.iosxr.iosxr_interfaces: config: - - name: GigabitEthernet0/0/0/2 - description: Configured by Ansible - enabled: true - mtu: 2000 - - name: GigabitEthernet0/0/0/3 - description: Configured by Ansible Network - enabled: false - duplex: auto + - name: GigabitEthernet0/0/0/2 + description: Configured by Ansible + enabled: true + mtu: 2000 + - name: GigabitEthernet0/0/0/3 + description: Configured by Ansible Network + enabled: false + duplex: auto state: replaced # Task Output @@ -295,14 +295,14 @@ - name: Override interfaces configuration cisco.iosxr.iosxr_interfaces: config: - - name: GigabitEthernet0/0/0/2 - description: Configured by Ansible - enabled: true - duplex: auto - - name: GigabitEthernet0/0/0/3 - description: Configured by Ansible Network - enabled: false - speed: 1000 + - name: GigabitEthernet0/0/0/2 + description: Configured by Ansible + enabled: true + duplex: auto + - name: GigabitEthernet0/0/0/3 + description: Configured by Ansible Network + enabled: false + speed: 1000 state: overridden # Task Output @@ -382,8 +382,8 @@ - name: Delete interfaces arguments cisco.iosxr.iosxr_interfaces: config: - - name: GigabitEthernet0/0/0/2 - - name: GigabitEthernet0/0/0/3 + - name: GigabitEthernet0/0/0/2 + - name: GigabitEthernet0/0/0/3 state: deleted # Task Output @@ -492,17 +492,17 @@ - name: Render platform specific commands from task input using rendered state cisco.iosxr.iosxr_interfaces: config: - - name: GigabitEthernet0/0/0/0 - description: Configured and Merged by Ansible-Network - mtu: 110 - enabled: true - duplex: half - - name: GigabitEthernet0/0/0/1 - description: Configured and Merged by Ansible-Network - mtu: 2800 - enabled: false - speed: 100 - duplex: full + - name: GigabitEthernet0/0/0/0 + description: Configured and Merged by Ansible-Network + mtu: 110 + enabled: true + duplex: half + - name: GigabitEthernet0/0/0/1 + description: Configured and Merged by Ansible-Network + mtu: 2800 + enabled: false + speed: 100 + duplex: full state: rendered # Task Output diff --git a/plugins/modules/iosxr_l2_interfaces.py b/plugins/modules/iosxr_l2_interfaces.py index d1f8bbea6..0614dbda4 100644 --- a/plugins/modules/iosxr_l2_interfaces.py +++ b/plugins/modules/iosxr_l2_interfaces.py @@ -183,20 +183,21 @@ - name: Merge provided configuration with device configuration cisco.iosxr.iosxr_l2_interfaces: config: - - name: GigabitEthernet0/0/0/3 - native_vlan: 20 - - name: GigabitEthernet0/0/0/4 - native_vlan: 40 - l2transport: true - l2protocol: - - stp: tunnel - - name: GigabitEthernet0/0/0/3.900 - l2transport: true - q_vlan: - - 20 - - 40 + - name: GigabitEthernet0/0/0/3 + native_vlan: 20 + - name: GigabitEthernet0/0/0/4 + native_vlan: 40 + l2transport: true + l2protocol: + - stp: tunnel + - name: GigabitEthernet0/0/0/3.900 + l2transport: true + q_vlan: + - 20 + - 40 state: merged + # After state: # ------------ # @@ -245,20 +246,23 @@ # dot1q vlan 20 40 # ! -- name: Replaces device configuration of listed interfaces with provided configuration +- name: >- + Replaces device configuration of listed interfaces with provided + configuration cisco.iosxr.iosxr_l2_interfaces: config: - - name: GigabitEthernet0/0/0/4 - native_vlan: 40 - l2transport: true - l2protocol: - - stp: forward - - name: GigabitEthernet0/0/0/3.900 - q_vlan: - - 20 - - any + - name: GigabitEthernet0/0/0/4 + native_vlan: 40 + l2transport: true + l2protocol: + - stp: forward + - name: GigabitEthernet0/0/0/3.900 + q_vlan: + - 20 + - any state: replaced + # After state: # ------------- # @@ -310,17 +314,18 @@ - name: Override device configuration of all interfaces with provided configuration cisco.iosxr.iosxr_l2_interfaces: config: - - name: GigabitEthernet0/0/0/4 - native_vlan: 40 - l2transport: true - l2protocol: - - stp: forward - - name: GigabitEthernet0/0/0/3.900 - q_vlan: - - 20 - - any + - name: GigabitEthernet0/0/0/4 + native_vlan: 40 + l2transport: true + l2protocol: + - stp: forward + - name: GigabitEthernet0/0/0/3.900 + q_vlan: + - 20 + - any state: overridden + # After state: # ------------- # @@ -369,7 +374,7 @@ - name: "Delete L2 attributes of given interfaces (Note: This won't delete the interface itself)" cisco.iosxr.iosxr_l2_interfaces: config: - - name: GigabitEthernet0/0/0/4 + - name: GigabitEthernet0/0/0/4 state: deleted # After state: @@ -511,25 +516,21 @@ - name: Render platform specific commands from task input using rendered state cisco.iosxr.iosxr_l2_interfaces: config: - - - name: GigabitEthernet0/0/0/1 - native_vlan: 10 - l2transport: true - l2protocol: - - - pvst: tunnel - - - cdp: forward - propagate: true - - - name: GigabitEthernet0/0/0/3.900 - q_vlan: - - 20 - - 40 - - - name: GigabitEthernet0/0/0/4 - native_vlan: 40 + - name: GigabitEthernet0/0/0/1 + native_vlan: 10 + l2transport: true + l2protocol: + - pvst: tunnel + - cdp: forward + propagate: true + - name: GigabitEthernet0/0/0/3.900 + q_vlan: + - 20 + - 40 + - name: GigabitEthernet0/0/0/4 + native_vlan: 40 state: rendered + # Task Output (redacted) # ----------------------- # "rendered": [ @@ -656,9 +657,6 @@ # shutdown # dot1q native vlan 40 # ! - - - """ RETURN = """ diff --git a/plugins/modules/iosxr_l3_interfaces.py b/plugins/modules/iosxr_l3_interfaces.py index c683e292c..babf38a90 100644 --- a/plugins/modules/iosxr_l3_interfaces.py +++ b/plugins/modules/iosxr_l3_interfaces.py @@ -128,13 +128,13 @@ - name: Merge provided configuration with device configuration cisco.iosxr.iosxr_l3_interfaces: config: - - name: GigabitEthernet0/0/0/2 - ipv4: - - address: 192.168.0.1/24 - - name: GigabitEthernet0/0/0/3 - ipv4: - - address: 192.168.2.1/24 - secondary: true + - name: GigabitEthernet0/0/0/2 + ipv4: + - address: 192.168.0.1/24 + - name: GigabitEthernet0/0/0/3 + ipv4: + - address: 192.168.2.1/24 + secondary: true state: merged # Task Output @@ -202,13 +202,14 @@ - name: Override device configuration of all interfaces with provided configuration cisco.iosxr.iosxr_l3_interfaces: config: - - name: GigabitEthernet0/0/0/3 - ipv4: - - address: 192.168.0.2/24 - - address: 192.168.2.1/24 - secondary: true + - name: GigabitEthernet0/0/0/3 + ipv4: + - address: 192.168.0.2/24 + - address: 192.168.2.1/24 + secondary: true state: overridden + # Task Output # ----------- # @@ -276,17 +277,20 @@ # ipv4 address 192.168.2.1 255.255.255.0 secondary # ! -- name: Replaces device configuration of listed interfaces with provided configuration +- name: >- + Replaces device configuration of listed interfaces with provided + configuration cisco.iosxr.iosxr_l3_interfaces: config: - - name: GigabitEthernet0/0/0/3 - ipv6: - - address: fd5d:12c9:2201:1::1/64 - - name: GigabitEthernet0/0/0/2 - ipv4: - - address: 192.168.0.2/24 + - name: GigabitEthernet0/0/0/3 + ipv6: + - address: 'fd5d:12c9:2201:1::1/64' + - name: GigabitEthernet0/0/0/2 + ipv4: + - address: 192.168.0.2/24 state: replaced + # Task Output # ----------- # @@ -353,14 +357,15 @@ # ipv6 address fd5d:12c9:2201:1::1/64 # ! -- name: "Delete attributes for interfaces (This won't delete the interface itself)" +- name: Delete attributes for interfaces (This won't delete the interface itself) cisco.iosxr.iosxr_l3_interfaces: config: - - name: GigabitEthernet0/0/0/3 - - name: GigabitEthernet0/0/0/4 - - name: GigabitEthernet0/0/0/3.700 + - name: GigabitEthernet0/0/0/3 + - name: GigabitEthernet0/0/0/4 + - name: GigabitEthernet0/0/0/3.700 state: deleted + # Task Output # ----------- # @@ -432,7 +437,7 @@ # interface preconfigure GigabitEthernet0/0/0/4 # ipv6 address fd5d:12c9:2201:1::1/64 # shutdown -#! +# ! - name: "Delete L3 config of all interfaces (This won't delete the interface itself)" cisco.iosxr.iosxr_l3_interfaces: @@ -570,18 +575,19 @@ - name: Render platform specific commands from task input using rendered state cisco.iosxr.iosxr_l3_interfaces: config: - - name: GigabitEthernet0/0/0/0 - ipv4: - - address: 198.51.100.1/24 - - name: GigabitEthernet0/0/0/1 - ipv6: - - address: 2001:db8:0:3::/64 - ipv4: - - address: 192.0.2.1/24 - - address: 192.0.2.2/24 - secondary: true + - name: GigabitEthernet0/0/0/0 + ipv4: + - address: 198.51.100.1/24 + - name: GigabitEthernet0/0/0/1 + ipv6: + - address: '2001:db8:0:3::/64' + ipv4: + - address: 192.0.2.1/24 + - address: 192.0.2.2/24 + secondary: true state: rendered + # Task Output # ----------- # diff --git a/plugins/modules/iosxr_lacp.py b/plugins/modules/iosxr_lacp.py index f963ff66c..f4fd19ae5 100644 --- a/plugins/modules/iosxr_lacp.py +++ b/plugins/modules/iosxr_lacp.py @@ -329,8 +329,6 @@ # RP/0/0/CPU0:an-iosxr-02#show running-config lacp # lacp system mac 00c1.4c00.bd15 # lacp system priority - - """ RETURN = """ before: diff --git a/plugins/modules/iosxr_lacp_interfaces.py b/plugins/modules/iosxr_lacp_interfaces.py index 1ebeaae8f..07a93d0e5 100644 --- a/plugins/modules/iosxr_lacp_interfaces.py +++ b/plugins/modules/iosxr_lacp_interfaces.py @@ -165,19 +165,18 @@ - name: Merge provided configuration with device configuration cisco.iosxr.iosxr_lacp_interfaces: config: - - name: Bundle-Ether10 - churn_logging: actor - collector_max_delay: 100 - switchover_suppress_flaps: 500 - - - name: Bundle-Ether11 - system: - mac: 00c2.4c00.bd15 - - - name: GigabitEthernet0/0/0/1 - period: 200 + - name: Bundle-Ether10 + churn_logging: actor + collector_max_delay: 100 + switchover_suppress_flaps: 500 + - name: Bundle-Ether11 + system: + mac: 00c2.4c00.bd15 + - name: GigabitEthernet0/0/0/1 + period: 200 state: merged + # # # ----------- @@ -265,13 +264,13 @@ - name: Replace LACP configuration of listed interfaces with provided configuration cisco.iosxr.iosxr_lacp_interfaces: config: - - name: Bundle-Ether10 - churn_logging: partner - - - name: GigabitEthernet0/0/0/2 - period: 300 + - name: Bundle-Ether10 + churn_logging: partner + - name: GigabitEthernet0/0/0/2 + period: 300 state: replaced + # # # ----------- @@ -361,15 +360,15 @@ - name: Override all interface LACP configuration with provided configuration cisco.iosxr.iosxr_lacp_interfaces: config: - - name: Bundle-Ether12 - churn_logging: both - collector_max_delay: 100 - switchover_suppress_flaps: 500 - - - name: GigabitEthernet0/0/0/1 - period: 300 + - name: Bundle-Ether12 + churn_logging: both + collector_max_delay: 100 + switchover_suppress_flaps: 500 + - name: GigabitEthernet0/0/0/1 + period: 300 state: overridden + # # # ----------- @@ -454,16 +453,18 @@ # ! # -- name: Deleted LACP configurations of provided interfaces (Note - This won't delete +- name: >- + Deleted LACP configurations of provided interfaces (Note - This won't delete the interface itself) cisco.iosxr.iosxr_lacp_interfaces: config: - - name: Bundle-Ether10 - - name: Bundle-Ether11 - - name: GigabitEthernet0/0/0/1 - - name: GigabitEthernet0/0/0/2 + - name: Bundle-Ether10 + - name: Bundle-Ether11 + - name: GigabitEthernet0/0/0/1 + - name: GigabitEthernet0/0/0/2 state: deleted + # # # ----------- @@ -559,19 +560,18 @@ - name: Render platform specific commands from task input using rendered state cisco.iosxr.iosxr_lacp_interfaces: config: - - name: Bundle-Ether10 - churn_logging: actor - collector_max_delay: 100 - switchover_suppress_flaps: 500 - - - name: Bundle-Ether11 - system: - mac: 00c2.4c00.bd15 - - - name: GigabitEthernet0/0/0/1 - period: 200 + - name: Bundle-Ether10 + churn_logging: actor + collector_max_delay: 100 + switchover_suppress_flaps: 500 + - name: Bundle-Ether11 + system: + mac: 00c2.4c00.bd15 + - name: GigabitEthernet0/0/0/1 + period: 200 state: rendered + # ------------- # Output # ------------- @@ -587,8 +587,6 @@ # - "interface GigabitEthernet0/0/0/1" # - " lacp period 200" # - - """ RETURN = """ before: diff --git a/plugins/modules/iosxr_lag_interfaces.py b/plugins/modules/iosxr_lag_interfaces.py index 6d1dacec1..4732dbfde 100644 --- a/plugins/modules/iosxr_lag_interfaces.py +++ b/plugins/modules/iosxr_lag_interfaces.py @@ -157,26 +157,26 @@ - name: Merge provided configuration with device configuration cisco.iosxr.iosxr_lag_interfaces: config: - - name: Bundle-Ether10 - members: - - member: GigabitEthernet0/0/0/1 - mode: inherit - - member: GigabitEthernet0/0/0/3 - mode: inherit - mode: active - links: - max_active: 5 - min_active: 2 - load_balancing_hash: src-ip - - - name: Bundle-Ether12 - members: - - member: GigabitEthernet0/0/0/2 - mode: passive - - member: GigabitEthernet0/0/0/4 - mode: passive - load_balancing_hash: dst-ip + - name: Bundle-Ether10 + members: + - member: GigabitEthernet0/0/0/1 + mode: inherit + - member: GigabitEthernet0/0/0/3 + mode: inherit + mode: active + links: + max_active: 5 + min_active: 2 + load_balancing_hash: src-ip + - name: Bundle-Ether12 + members: + - member: GigabitEthernet0/0/0/2 + mode: passive + - member: GigabitEthernet0/0/0/4 + mode: passive + load_balancing_hash: dst-ip state: merged + # # # ----------- @@ -267,15 +267,14 @@ - name: Replace device configuration of listed Bundles with provided configurations cisco.iosxr.iosxr_lag_interfaces: config: - - name: Bundle-Ether12 - members: - - name: GigabitEthernet0/0/0/2 - mode: passive - - - name: Bundle-Ether11 - members: - - name: GigabitEthernet0/0/0/4 - load_balancing_hash: src-ip + - name: Bundle-Ether12 + members: + - name: GigabitEthernet0/0/0/2 + mode: passive + - name: Bundle-Ether11 + members: + - name: GigabitEthernet0/0/0/4 + load_balancing_hash: src-ip state: replaced # # @@ -376,15 +375,16 @@ - name: Overrides all device configuration with provided configuration cisco.iosxr.iosxr_lag_interfaces: config: - - name: Bundle-Ether10 - members: - - member: GigabitEthernet0/0/0/1 - mode: inherit - - member: GigabitEthernet0/0/0/2 - mode: inherit - mode: active - load_balancing_hash: dst-ip + - name: Bundle-Ether10 + members: + - member: GigabitEthernet0/0/0/1 + mode: inherit + - member: GigabitEthernet0/0/0/2 + mode: inherit + mode: active + load_balancing_hash: dst-ip state: overridden + # # # ------------ @@ -474,15 +474,17 @@ # # -- name: Delete attributes of given bundles and removes member interfaces from them +- name: >- + Delete attributes of given bundles and removes member interfaces from them (Note - This won't delete the bundles themselves) cisco.iosxr.iosxr_lag_interfaces: config: - - name: Bundle-Ether10 - - name: Bundle-Ether11 - - name: Bundle-Ether12 + - name: Bundle-Ether10 + - name: Bundle-Ether11 + - name: Bundle-Ether12 state: deleted + # # # ------------ @@ -736,25 +738,24 @@ - name: Render platform specific commands from task input using rendered state cisco.iosxr.iosxr_lag_interfaces: config: - - name: Bundle-Ether10 - members: - - member: GigabitEthernet0/0/0/1 - mode: inherit - - member: GigabitEthernet0/0/0/3 - mode: inherit - mode: active - links: - max_active: 5 - min_active: 2 - load_balancing_hash: src-ip - - - name: Bundle-Ether12 - members: - - member: GigabitEthernet0/0/0/2 - mode: passive - - member: GigabitEthernet0/0/0/4 - mode: passive - load_balancing_hash: dst-ip + - name: Bundle-Ether10 + members: + - member: GigabitEthernet0/0/0/1 + mode: inherit + - member: GigabitEthernet0/0/0/3 + mode: inherit + mode: active + links: + max_active: 5 + min_active: 2 + load_balancing_hash: src-ip + - name: Bundle-Ether12 + members: + - member: GigabitEthernet0/0/0/2 + mode: passive + - member: GigabitEthernet0/0/0/4 + mode: passive + load_balancing_hash: dst-ip state: rendered # Output: @@ -787,9 +788,6 @@ # - " bundle id 12 mode passive" # ] # -# - - """ RETURN = """ before: diff --git a/plugins/modules/iosxr_lldp_global.py b/plugins/modules/iosxr_lldp_global.py index 662fb498e..c3eb21ddb 100644 --- a/plugins/modules/iosxr_lldp_global.py +++ b/plugins/modules/iosxr_lldp_global.py @@ -426,9 +426,6 @@ # "lldp tlv-select management-address disable", # "lldp timer 3000" # ] - - - """ RETURN = """ before: diff --git a/plugins/modules/iosxr_lldp_interfaces.py b/plugins/modules/iosxr_lldp_interfaces.py index f88d132e5..0322a0e1f 100644 --- a/plugins/modules/iosxr_lldp_interfaces.py +++ b/plugins/modules/iosxr_lldp_interfaces.py @@ -120,17 +120,17 @@ - name: Merge provided configuration with running configuration cisco.iosxr.iosxr_lldp_interfaces: config: - - name: GigabitEthernet0/0/0/1 - destination: - mac_address: ieee-nearest-non-tmpr-bridge - transmit: false - - - name: GigabitEthernet0/0/0/2 - destination: - mac_address: ieee-nearest-bridge - receive: false + - name: GigabitEthernet0/0/0/1 + destination: + mac_address: ieee-nearest-non-tmpr-bridge + transmit: false + - name: GigabitEthernet0/0/0/2 + destination: + mac_address: ieee-nearest-bridge + receive: false state: merged + # # # ------------------------ @@ -242,15 +242,17 @@ # # -- name: Replace existing LLDP configurations of specified interfaces with provided +- name: >- + Replace existing LLDP configurations of specified interfaces with provided configuration cisco.iosxr.iosxr_lldp_interfaces: config: - - name: GigabitEthernet0/0/0/1 - destination: - mac_address: ieee-nearest-non-tmpr-bridge + - name: GigabitEthernet0/0/0/1 + destination: + mac_address: ieee-nearest-non-tmpr-bridge state: replaced + # # # ------------------------ @@ -366,13 +368,16 @@ # # -- name: Override the LLDP configurations of all the interfaces with provided configurations +- name: >- + Override the LLDP configurations of all the interfaces with provided + configurations cisco.iosxr.iosxr_lldp_interfaces: config: - - name: GigabitEthernet0/0/0/1 - transmit: false + - name: GigabitEthernet0/0/0/1 + transmit: false state: overridden + # # # ------------------------ @@ -638,17 +643,15 @@ - name: Render platform specific commands from task input using rendered state cisco.iosxr.iosxr_lldp_interfaces: config: - - name: GigabitEthernet0/0/0/1 - destination: - mac_address: ieee-nearest-non-tmpr-bridge - transmit: false - - - name: GigabitEthernet0/0/0/2 - destination: - mac_address: ieee-nearest-bridge - receive: false + - name: GigabitEthernet0/0/0/1 + destination: + mac_address: ieee-nearest-non-tmpr-bridge + transmit: false + - name: GigabitEthernet0/0/0/2 + destination: + mac_address: ieee-nearest-bridge + receive: false state: rendered - # ------------------------ # Module Execution Result # ------------------------ @@ -661,7 +664,6 @@ # "lldp receive disable", # "lldp destination mac-address ieee-nearest-bridge" # ] - """ RETURN = """ before: diff --git a/plugins/modules/iosxr_logging.py b/plugins/modules/iosxr_logging.py deleted file mode 100644 index 9889f568f..000000000 --- a/plugins/modules/iosxr_logging.py +++ /dev/null @@ -1,1270 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -# (c) 2017, Ansible by Red Hat, inc -# 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 - - -DOCUMENTATION = """ -module: iosxr_logging -author: -- Trishna Guha (@trishnaguha) -- Kedar Kekan (@kedarX) -short_description: (deprecated, removed after 2023-08-01) Configuration management of system logging services on network - devices -description: -- This module provides declarative management configuration of system logging (syslog) - on Cisco IOS XR devices. -version_added: 1.0.0 -deprecated: - alternative: iosxr_logging_global - why: Updated module released with more functionality. - removed_at_date: '2023-08-01' -requirements: -- ncclient >= 0.5.3 when using netconf -- lxml >= 4.1.1 when using netconf -notes: -- This module works with connection C(network_cli) and C(netconf). See L(the IOS-XR - Platform Options,../network/user_guide/platform_iosxr.html). -options: - dest: - description: - - Destination for system logging (syslog) messages. - choices: - - host - - console - - monitor - - buffered - - file - type: str - name: - description: - - When C(dest) = I(file) name indicates file-name - - When C(dest) = I(host) name indicates the host-name or ip-address of syslog - server. - type: str - vrf: - description: - - vrf name when syslog server is configured, C(dest) = C(host) - type: str - default: default - size: - description: - - Size of buffer when C(dest) = C(buffered). The acceptable value is in the range - I(307200 to 125000000 bytes). Default 307200 - - Size of file when C(dest) = C(file). The acceptable value is in the range I(1 - to 2097152)KB. Default 2 GB - type: int - facility: - description: - - To configure the type of syslog facility in which system logging (syslog) messages - are sent to syslog servers Optional config for C(dest) = C(host) - default: local7 - type: str - hostnameprefix: - description: - - To append a hostname prefix to system logging (syslog) messages logged to syslog - servers. Optional config for C(dest) = C(host) - type: str - level: - description: - - Specifies the severity level for the logging. - type: str - default: debugging - aliases: - - severity - choices: ["emergencies", "alerts", "critical", "errors", "warning", "notifications", "informational", "debugging"] - path: - description: - Set file path. - type: str - aggregate: - description: List of syslog logging configuration definitions. - type: list - elements: dict - suboptions: - dest: - description: - - Destination for system logging (syslog) messages. - choices: - - host - - console - - monitor - - buffered - - file - type: str - name: - description: - - When C(dest) = I(file) name indicates file-name - - When C(dest) = I(host) name indicates the host-name or ip-address of syslog - server. - type: str - path: - description: - Set file path. - type: str - vrf: - description: - - vrf name when syslog server is configured, C(dest) = C(host) - type: str - size: - description: - - Size of buffer when C(dest) = C(buffered). The acceptable value is in the range - I(307200 to 125000000 bytes). Default 307200 - - Size of file when C(dest) = C(file). The acceptable value is in the range I(1 - to 2097152)KB. Default 2 GB - type: int - facility: - description: - - To configure the type of syslog facility in which system logging (syslog) messages - are sent to syslog servers Optional config for C(dest) = C(host) - type: str - hostnameprefix: - description: - - To append a hostname prefix to system logging (syslog) messages logged to syslog - servers. Optional config for C(dest) = C(host) - type: str - level: - description: - - Specifies the severity level for the logging. - type: str - aliases: - - severity - choices: ["emergencies", "alerts", "critical", "errors", "warning", "notifications", "informational", "debugging"] - state: - description: - - Existential state of the logging configuration on the node. - choices: - - present - - absent - type: str - state: - description: - - Existential state of the logging configuration on the node. - default: present - choices: - - present - - absent - type: str -extends_documentation_fragment: -- cisco.iosxr.iosxr -""" - -EXAMPLES = """ -- name: configure logging for syslog server host - cisco.iosxr.iosxr_logging: - dest: host - name: 10.10.10.1 - level: critical - state: present - -- name: add hostnameprefix configuration - cisco.iosxr.iosxr_logging: - hostnameprefix: host1 - state: absent - -- name: add facility configuration - cisco.iosxr.iosxr_logging: - facility: local1 - state: present - -- name: configure console logging level - cisco.iosxr.iosxr_logging: - dest: console - level: debugging - state: present - -- name: configure monitor logging level - cisco.iosxr.iosxr_logging: - dest: monitor - level: errors - state: present - -- name: configure syslog to a file - cisco.iosxr.iosxr_logging: - dest: file - name: file_name - size: 2048 - level: errors - state: present - -- name: configure buffered logging with size - cisco.iosxr.iosxr_logging: - dest: buffered - size: 5100000 - -- name: Configure logging using aggregate - cisco.iosxr.iosxr_logging: - aggregate: - - {dest: console, level: warning} - - {dest: buffered, size: 4800000} - - {dest: file, name: file3, size: 2048} - - {dest: host, name: host3, level: critical} - -- name: Delete logging using aggregate - cisco.iosxr.iosxr_logging: - aggregate: - - {dest: console, level: warning} - - {dest: buffered, size: 4800000} - - {dest: file, name: file3, size: 2048} - - {dest: host, name: host3, level: critical} - state: absent -""" - -RETURN = """ -commands: - description: The list of configuration mode commands to send to the device - returned: always (empty list when no commands to send) - type: list - sample: - - logging 10.10.10.1 vrf default severity debugging - - logging facility local7 - - logging hostnameprefix host1 - - logging console critical - - logging buffered 2097153 - - logging buffered warnings - - logging monitor errors - - logging file log_file maxfilesize 1024 severity info -xml: - description: NetConf rpc xml sent to device with transport C(netconf) - returned: always (empty list when no xml rpc to send) - type: list - sample: - - ' - - - - file1 - - 2097152 - 2 - - - - - ' -""" - -import collections -import re - -from copy import deepcopy - -from ansible.module_utils._text import to_text -from ansible.module_utils.basic import AnsibleModule -from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( - remove_default_spec, -) - -from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.iosxr import ( - build_xml, - etree_find, - etree_findall, - get_capabilities, - get_config, - get_os_version, - is_cliconf, - is_netconf, - load_config, -) -from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.utils.utils import Version - - -severity_level = { - "emergency": "0", - "alert": "1", - "critical": "2", - "error": "3", - "warning": "4", - "notice": "5", - "info": "6", - "debug": "7", - "disable": "15", -} - -severity_transpose = { - "emergencies": "emergency", - "alerts": "alert", - "critical": "critical", - "errors": "error", - "warning": "warning", - "notifications": "notice", - "informational": "info", - "debugging": "debug", -} - - -class ConfigBase(object): - def __init__(self, module): - self._flag = None - self._module = module - self._result = {"changed": False, "warnings": []} - self._want = list() - self._have = list() - - def validate_size(self, value, type=None): - if value: - if type == "buffer": - if value and not int(307200) <= value <= int(125000000): - self._module.fail_json( - msg="buffer size must be between 307200 and 125000000", - ) - elif type == "file": - if value and not int(1) <= value <= int(2097152): - self._module.fail_json( - msg="file size must be between 1 and 2097152", - ) - return value - - def map_params_to_obj(self, required_if=None): - aggregate = self._module.params.get("aggregate") - if aggregate: - for item in aggregate: - for key in item: - if item.get(key) is None: - item[key] = self._module.params[key] - - d = item.copy() - - if d["dest"] not in ("host", "file"): - d["name"] = None - - if d["dest"] == "buffered": - if d["size"] is not None: - d["size"] = str( - self.validate_size(d["size"], "buffer"), - ) - else: - d["size"] = str(307200) - elif d["dest"] == "file": - if d["size"] is not None: - d["size"] = str(self.validate_size(d["size"], "file")) - else: - d["size"] = str(2097152) - else: - d["size"] = None - - if self._flag == "NC": - d["level"] = severity_transpose[d["level"]] - - self._want.append(d) - - else: - params = self._module.params - if params["dest"] not in ("host", "file"): - params["name"] = None - - if params["dest"] == "buffered": - if params["size"] is not None: - params["size"] = str( - self.validate_size(params["size"], "buffer"), - ) - else: - params["size"] = str(307200) - elif params["dest"] == "file": - if params["size"] is not None: - params["size"] = str( - self.validate_size(params["size"], "file"), - ) - else: - params["size"] = str(2097152) - else: - params["size"] = None - - if self._flag == "NC": - params["level"] = severity_transpose[params["level"]] - - self._want.append( - { - "dest": params["dest"], - "name": params["name"], - "vrf": params["vrf"], - "size": params["size"], - "path": params["path"], - "facility": params["facility"], - "level": params["level"], - "hostnameprefix": params["hostnameprefix"], - "state": params["state"], - }, - ) - - -class CliConfiguration(ConfigBase): - def __init__(self, module): - super(CliConfiguration, self).__init__(module) - self._file_list = set() - self._host_list = set() - - def map_obj_to_commands(self, os_version): - commands = list() - for want_item in self._want: - dest = want_item["dest"] - name = want_item["name"] - size = want_item["size"] - path = want_item["path"] - facility = want_item["facility"] - level = want_item["level"] - vrf = want_item["vrf"] - hostnameprefix = want_item["hostnameprefix"] - state = want_item["state"] - del want_item["state"] - - have_size = None - have_console_level = None - have_monitor_level = None - have_prefix = None - have_facility = None - - for item in self._have: - if item["dest"] == "buffered": - have_size = item["size"] - if item["dest"] == "console": - have_console_level = item["level"] - if item["dest"] == "monitor": - have_monitor_level = item["level"] - if item["dest"] is None and item["hostnameprefix"] is not None: - have_prefix = item["hostnameprefix"] - if ( - item["dest"] is None - and item["hostnameprefix"] is None - and item["facility"] is not None - ): - have_facility = item["facility"] - - if state == "absent": - if dest == "host" and name in self._host_list: - commands.append("no logging {0} vrf {1}".format(name, vrf)) - elif dest == "file" and name in self._file_list: - commands.append("no logging file {0}".format(name)) - elif dest == "console" and have_console_level is not None: - commands.append("no logging {0}".format(dest)) - elif dest == "monitor" and have_monitor_level: - commands.append("no logging {0}".format(dest)) - elif dest == "buffered" and have_size: - commands.append("no logging {0}".format(dest)) - - if dest is None and hostnameprefix is not None and have_prefix == hostnameprefix: - commands.append( - "no logging hostnameprefix {0}".format(hostnameprefix), - ) - if dest is None and facility is not None and have_facility == facility: - commands.append("no logging facility {0}".format(facility)) - - if state == "present": - if dest == "host" and name not in self._host_list: - if level == "errors" or level == "informational": - level = severity_transpose[level] - commands.append( - "logging {0} vrf {1} severity {2}".format( - name, - vrf, - level, - ), - ) - elif dest == "file" and name not in self._file_list: - if level == "errors" or level == "informational": - level = severity_transpose[level] - if os_version and Version(os_version) > Version("7.0"): - commands.append( - "logging file {0} path {1} maxfilesize {2} severity {3}".format( - name, - path, - size, - level, - ), - ) - else: - commands.append( - "logging file {0} maxfilesize {1} severity {2}".format( - name, - size, - level, - ), - ) - elif dest == "buffered" and ( - have_size is None or (have_size is not None and size != have_size) - ): - commands.append("logging buffered {0}".format(size)) - elif dest == "console" and ( - have_console_level is None - or (have_console_level is not None and have_console_level != level) - ): - commands.append("logging console {0}".format(level)) - elif dest == "monitor" and ( - have_monitor_level is None - or (have_monitor_level is not None and have_monitor_level != level) - ): - commands.append("logging monitor {0}".format(level)) - - if ( - dest is None - and hostnameprefix is not None - and ( - have_prefix is None - or (have_prefix is not None and hostnameprefix != have_prefix) - ) - ): - commands.append( - "logging hostnameprefix {0}".format(hostnameprefix), - ) - if dest is None and hostnameprefix is None and facility != have_facility: - commands.append("logging facility {0}".format(facility)) - - self._result["commands"] = commands - if commands: - commit = not self._module.check_mode - diff = load_config(self._module, commands, commit=commit) - if diff: - self._result["diff"] = dict(prepared=diff) - self._result["changed"] = True - - def parse_facility(self, line): - match = re.search(r"logging facility (\S+)", line, re.M) - facility = None - if match: - facility = match.group(1) - - return facility - - def parse_size(self, line, dest): - size = None - - if dest == "buffered": - match = re.search(r"logging buffered (\S+)", line, re.M) - if match: - try: - int_size = int(match.group(1)) - except ValueError: - int_size = None - - if int_size is not None: - if isinstance(int_size, int): - size = str(match.group(1)) - if dest == "file": - match = re.search( - r"logging file (\S+) (path\s\S+\s)?maxfilesize (\S+)", - line, - re.M, - ) - if match: - try: - if "path" in line: - int_size = int(match.group(2)) - else: - int_size = int(match.group(1)) - except ValueError: - int_size = None - - if int_size is not None: - if isinstance(int_size, int): - size = str(int_size) - - return size - - def parse_path(self, line, dest): - path = None - - if dest == "file": - match = re.search(r"logging file (\S+) (path\s\S+\s)", line, re.M) - if match: - try: - path = to_text( - match.group(2), - errors="surrogate_or_strict", - ) - except ValueError: - path = None - - return path - - def parse_hostnameprefix(self, line): - prefix = None - match = re.search(r"logging hostnameprefix (\S+)", line, re.M) - if match: - prefix = match.group(1) - return prefix - - def parse_name(self, line, dest): - name = None - if dest == "file": - match = re.search(r"logging file (\S+)", line, re.M) - if match: - name = match.group(1) - elif dest == "host": - match = re.search(r"logging (\S+)", line, re.M) - if match: - name = match.group(1) - - return name - - def parse_level(self, line, dest): - level_group = ( - "emergencies", - "alerts", - "critical", - "errors", - "warning", - "notifications", - "informational", - "debugging", - ) - - level = None - match = re.search(r"logging {0} (\S+)".format(dest), line, re.M) - if match: - if match.group(1) in level_group: - level = match.group(1) - - return level - - def parse_dest(self, line, group): - dest_group = ("console", "monitor", "buffered", "file") - dest = None - if group in dest_group: - dest = group - elif "vrf" in line: - dest = "host" - - return dest - - def parse_vrf(self, line, dest): - vrf = None - if dest == "host": - match = re.search(r"logging (\S+) vrf (\S+)", line, re.M) - if match: - vrf = match.group(2) - return vrf - - def map_config_to_obj(self): - data = get_config(self._module, config_filter="logging") - lines = data.split("\n") - - for line in lines: - match = re.search(r"logging (\S+)", line, re.M) - if match: - dest = self.parse_dest(line, match.group(1)) - name = self.parse_name(line, dest) - if dest == "host" and name is not None: - self._host_list.add(name) - if dest == "file" and name is not None: - self._file_list.add(name) - - self._have.append( - { - "dest": dest, - "name": name, - "size": self.parse_size(line, dest), - "path": self.parse_path(line, dest), - "facility": self.parse_facility(line), - "level": self.parse_level(line, dest), - "vrf": self.parse_vrf(line, dest), - "hostnameprefix": self.parse_hostnameprefix(line), - }, - ) - - def run(self, os_version): - self.map_params_to_obj() - self.map_config_to_obj() - self.map_obj_to_commands(os_version) - - return self._result - - -class NCConfiguration(ConfigBase): - def __init__(self, module): - super(NCConfiguration, self).__init__(module) - self._flag = "NC" - self._log_file_meta = collections.OrderedDict() - self._log_host_meta = collections.OrderedDict() - self._log_console_meta = collections.OrderedDict() - self._log_monitor_meta = collections.OrderedDict() - self._log_buffered_meta = collections.OrderedDict() - self._log_facility_meta = collections.OrderedDict() - self._log_prefix_meta = collections.OrderedDict() - - def map_obj_to_xml_rpc(self, os_version): - file_attribute_path = "file-log-attributes" - if os_version and Version(os_version) > Version("7.0.0"): - file_attribute_path = "file-specification" - self._log_file_meta.update( - [ - ( - "files", - { - "xpath": "syslog/files", - "tag": True, - "operation": "edit", - }, - ), - ( - "file", - { - "xpath": "syslog/files/file", - "tag": True, - "operation": "edit", - "attrib": "operation", - }, - ), - ( - "a:name", - { - "xpath": "syslog/files/file/file-name", - "operation": "edit", - }, - ), - ( - "file-attrib", - { - "xpath": "syslog/files/file/" + file_attribute_path, - "tag": True, - "operation": "edit", - }, - ), - ( - "a:size", - { - "xpath": "syslog/files/file/" + file_attribute_path + "/max-file-size", - "operation": "edit", - }, - ), - ( - "a:level", - { - "xpath": "syslog/files/file/" + file_attribute_path + "/severity", - "operation": "edit", - }, - ), - ( - "a:path", - { - "xpath": "syslog/files/file/" + file_attribute_path + "/path", - "operation": "edit", - }, - ), - ], - ) - else: - self._log_file_meta.update( - [ - ( - "files", - { - "xpath": "syslog/files", - "tag": True, - "operation": "edit", - }, - ), - ( - "file", - { - "xpath": "syslog/files/file", - "tag": True, - "operation": "edit", - "attrib": "operation", - }, - ), - ( - "a:name", - { - "xpath": "syslog/files/file/file-name", - "operation": "edit", - }, - ), - ( - "file-attrib", - { - "xpath": "syslog/files/file/" + file_attribute_path, - "tag": True, - "operation": "edit", - }, - ), - ( - "a:size", - { - "xpath": "syslog/files/file/" + file_attribute_path + "/max-file-size", - "operation": "edit", - }, - ), - ( - "a:level", - { - "xpath": "syslog/files/file/" + file_attribute_path + "/severity", - "operation": "edit", - }, - ), - ], - ) - self._log_host_meta.update( - [ - ( - "host-server", - { - "xpath": "syslog/host-server", - "tag": True, - "operation": "edit", - }, - ), - ( - "vrfs", - { - "xpath": "syslog/host-server/vrfs", - "tag": True, - "operation": "edit", - }, - ), - ( - "vrf", - { - "xpath": "syslog/host-server/vrfs/vrf", - "tag": True, - "operation": "edit", - }, - ), - ( - "a:vrf", - { - "xpath": "syslog/host-server/vrfs/vrf/vrf-name", - "operation": "edit", - }, - ), - ( - "ipv4s", - { - "xpath": "syslog/host-server/vrfs/vrf/ipv4s", - "tag": True, - "operation": "edit", - }, - ), - ( - "ipv4", - { - "xpath": "syslog/host-server/vrfs/vrf/ipv4s/ipv4", - "tag": True, - "operation": "edit", - "attrib": "operation", - }, - ), - ( - "a:name", - { - "xpath": "syslog/host-server/vrfs/vrf/ipv4s/ipv4/address", - "operation": "edit", - }, - ), - ( - "ipv4-sev", - { - "xpath": "syslog/host-server/vrfs/vrf/ipv4s/ipv4/ipv4-severity-port", - "tag": True, - "operation": "edit", - }, - ), - ( - "a:level", - { - "xpath": "syslog/host-server/vrfs/vrf/ipv4s/ipv4/ipv4-severity-port/severity", - "operation": "edit", - }, - ), - ], - ) - self._log_console_meta.update( - [ - ( - "a:enable-console", - { - "xpath": "syslog/enable-console-logging", - "operation": "edit", - "attrib": "operation", - }, - ), - ( - "console", - { - "xpath": "syslog/console-logging", - "tag": True, - "operation": "edit", - "attrib": "operation", - }, - ), - ( - "a:console-level", - { - "xpath": "syslog/console-logging/logging-level", - "operation": "edit", - }, - ), - ], - ) - self._log_monitor_meta.update( - [ - ( - "monitor", - { - "xpath": "syslog/monitor-logging", - "tag": True, - "operation": "edit", - "attrib": "operation", - }, - ), - ( - "a:monitor-level", - { - "xpath": "syslog/monitor-logging/logging-level", - "operation": "edit", - }, - ), - ], - ) - self._log_buffered_meta.update( - [ - ( - "buffered", - { - "xpath": "syslog/buffered-logging", - "tag": True, - "operation": "edit", - "attrib": "operation", - }, - ), - ( - "a:size", - { - "xpath": "syslog/buffered-logging/buffer-size", - "operation": "edit", - }, - ), - ( - "a:level", - { - "xpath": "syslog/buffered-logging/logging-level", - "operation": "edit", - }, - ), - ], - ) - self._log_facility_meta.update( - [ - ( - "facility", - { - "xpath": "syslog/logging-facilities", - "tag": True, - "operation": "edit", - "attrib": "operation", - }, - ), - ( - "a:facility", - { - "xpath": "syslog/logging-facilities/facility-level", - "operation": "edit", - }, - ), - ], - ) - self._log_prefix_meta.update( - [ - ( - "a:hostnameprefix", - { - "xpath": "syslog/host-name-prefix", - "operation": "edit", - "attrib": "operation", - }, - ), - ], - ) - - state = self._module.params["state"] - - _get_filter = build_xml("syslog", opcode="filter") - running = get_config( - self._module, - source="running", - config_filter=_get_filter, - ) - - file_ele = etree_findall(running, "file") - file_list = list() - if len(file_ele): - for file in file_ele: - file_name = etree_find(file, "file-name") - file_list.append( - file_name.text if file_name is not None else None, - ) - vrf_ele = etree_findall(running, "vrf") - host_list = list() - for vrf in vrf_ele: - host_ele = etree_findall(vrf, "ipv4") - for host in host_ele: - host_name = etree_find(host, "address") - host_list.append( - host_name.text if host_name is not None else None, - ) - - console_ele = etree_find(running, "console-logging") - console_level = ( - etree_find(console_ele, "logging-level") if console_ele is not None else None - ) - have_console = console_level.text if console_level is not None else None - - monitor_ele = etree_find(running, "monitor-logging") - monitor_level = ( - etree_find(monitor_ele, "logging-level") if monitor_ele is not None else None - ) - have_monitor = monitor_level.text if monitor_level is not None else None - - buffered_ele = etree_find(running, "buffered-logging") - buffered_size = ( - etree_find(buffered_ele, "buffer-size") if buffered_ele is not None else None - ) - have_buffered = buffered_size.text if buffered_size is not None else None - - facility_ele = etree_find(running, "logging-facilities") - facility_level = ( - etree_find(facility_ele, "facility-level") if facility_ele is not None else None - ) - have_facility = facility_level.text if facility_level is not None else None - - prefix_ele = etree_find(running, "host-name-prefix") - have_prefix = prefix_ele.text if prefix_ele is not None else None - - file_params = list() - host_params = list() - console_params = dict() - monitor_params = dict() - buffered_params = dict() - facility_params = dict() - prefix_params = dict() - - opcode = None - if state == "absent": - opcode = "delete" - for item in self._want: - if item["dest"] == "file" and item["name"] in file_list: - item["level"] = severity_level[item["level"]] - file_params.append(item) - elif item["dest"] == "host" and item["name"] in host_list: - item["level"] = severity_level[item["level"]] - host_params.append(item) - elif item["dest"] == "console" and have_console: - console_params.update({"console-level": item["level"]}) - elif item["dest"] == "monitor" and have_monitor: - monitor_params.update({"monitor-level": item["level"]}) - elif item["dest"] == "buffered" and have_buffered: - buffered_params["size"] = str(item["size"]) if item["size"] else None - buffered_params["level"] = item["level"] if item["level"] else None - elif ( - item["dest"] is None - and item["hostnameprefix"] is None - and item["facility"] is not None - and have_facility - ): - facility_params.update({"facility": item["facility"]}) - elif item["dest"] is None and item["hostnameprefix"] is not None and have_prefix: - prefix_params.update( - {"hostnameprefix": item["hostnameprefix"]}, - ) - elif state == "present": - opcode = "merge" - for item in self._want: - if item["dest"] == "file": - item["level"] = severity_level[item["level"]] - file_params.append(item) - elif item["dest"] == "host": - item["level"] = severity_level[item["level"]] - host_params.append(item) - elif item["dest"] == "console": - console_params.update({"console-level": item["level"]}) - elif item["dest"] == "monitor": - monitor_params.update({"monitor-level": item["level"]}) - elif item["dest"] == "buffered": - buffered_params["size"] = str(item["size"]) if item["size"] else None - buffered_params["level"] = item["level"] if item["level"] else None - elif ( - item["dest"] is None - and item["hostnameprefix"] is None - and item["facility"] is not None - ): - facility_params.update({"facility": item["facility"]}) - elif item["dest"] is None and item["hostnameprefix"] is not None: - prefix_params.update( - {"hostnameprefix": item["hostnameprefix"]}, - ) - - self._result["xml"] = [] - _edit_filter_list = list() - if opcode: - if len(file_params): - _edit_filter_list.append( - build_xml( - "syslog", - xmap=self._log_file_meta, - params=file_params, - opcode=opcode, - ), - ) - if len(host_params): - _edit_filter_list.append( - build_xml( - "syslog", - xmap=self._log_host_meta, - params=host_params, - opcode=opcode, - ), - ) - if len(console_params): - _edit_filter_list.append( - build_xml( - "syslog", - xmap=self._log_console_meta, - params=console_params, - opcode=opcode, - ), - ) - if len(monitor_params): - _edit_filter_list.append( - build_xml( - "syslog", - xmap=self._log_monitor_meta, - params=monitor_params, - opcode=opcode, - ), - ) - if len(buffered_params): - _edit_filter_list.append( - build_xml( - "syslog", - xmap=self._log_buffered_meta, - params=buffered_params, - opcode=opcode, - ), - ) - if len(facility_params): - _edit_filter_list.append( - build_xml( - "syslog", - xmap=self._log_facility_meta, - params=facility_params, - opcode=opcode, - ), - ) - if len(prefix_params): - _edit_filter_list.append( - build_xml( - "syslog", - xmap=self._log_prefix_meta, - params=prefix_params, - opcode=opcode, - ), - ) - - diff = None - if len(_edit_filter_list): - commit = not self._module.check_mode - diff = load_config( - self._module, - _edit_filter_list, - commit=commit, - running=running, - nc_get_filter=_get_filter, - ) - if diff: - if self._module._diff: - self._result["diff"] = dict(prepared=diff) - - self._result["xml"] = _edit_filter_list - self._result["changed"] = True - - def run(self, os_version): - self.map_params_to_obj() - self.map_obj_to_xml_rpc(os_version) - - return self._result - - -def main(): - """main entry point for module execution""" - element_spec = dict( - dest=dict( - type="str", - choices=["host", "console", "monitor", "buffered", "file"], - ), - name=dict(type="str"), - size=dict(type="int"), - path=dict(type="str"), - vrf=dict(type="str", default="default"), - facility=dict(type="str", default="local7"), - hostnameprefix=dict(type="str"), - level=dict( - type="str", - default="debugging", - aliases=["severity"], - choices=[ - "emergencies", - "alerts", - "critical", - "errors", - "warning", - "notifications", - "informational", - "debugging", - ], - ), - state=dict(default="present", choices=["present", "absent"]), - ) - - aggregate_spec = deepcopy(element_spec) - - # remove default in aggregate spec, to handle common arguments - remove_default_spec(aggregate_spec) - - mutually_exclusive = [("dest", "facility", "hostnameprefix")] - - required_if = [ - ("dest", "host", ["name"]), - ("dest", "file", ["name"]), - ("dest", "buffered", ["size"]), - ("dest", "console", ["level"]), - ("dest", "monitor", ["level"]), - ] - - argument_spec = dict( - aggregate=dict( - type="list", - elements="dict", - options=aggregate_spec, - mutually_exclusive=mutually_exclusive, - required_if=required_if, - ), - ) - - argument_spec.update(element_spec) - - module = AnsibleModule( - argument_spec=argument_spec, - mutually_exclusive=mutually_exclusive, - required_if=required_if, - supports_check_mode=True, - ) - config_object = None - if is_cliconf(module): - config_object = CliConfiguration(module) - os_version = get_os_version(module) - elif is_netconf(module): - config_object = NCConfiguration(module) - os_version = get_capabilities(module).get("device_info").get("network_os_version") - - if config_object: - result = config_object.run(os_version) - module.exit_json(**result) - - -if __name__ == "__main__": - main() diff --git a/plugins/modules/iosxr_logging_global.py b/plugins/modules/iosxr_logging_global.py index 4d25dcaab..55dd23f6b 100644 --- a/plugins/modules/iosxr_logging_global.py +++ b/plugins/modules/iosxr_logging_global.py @@ -364,56 +364,56 @@ """ EXAMPLES = """ # Using merged -#----------------- +# ----------------- # Before state -#RP/0/0/CPU0:10#show running-config logging -#Thu Feb 4 09:38:36.245 UTC -#% No such configuration item(s) -#RP/0/0/CPU0:10# +# RP/0/0/CPU0:10#show running-config logging +# Thu Feb 4 09:38:36.245 UTC +# % No such configuration item(s) +# RP/0/0/CPU0:10# # # - name: Merge the provided configuration with the existing running configuration cisco.iosxr.iosxr_logging_global: - config: - buffered: - size: 2097152 - severity: warnings - correlator: - buffer_size: 1024 - events: - display_location: True - files: - - maxfilesize: '1024' - name: test - path: test - severity: info - hostnameprefix: test - hosts: - - host: 1.1.1.1 - port: default - severity: critical - vrf: default - ipv4: - dscp: af11 - localfilesize: 1024 - monitor: - severity: errors - source_interfaces: - - interface: GigabitEthernet0/0/0/0 - vrf: test - tls_servers: - - name: test - tls_hostname: test2 - trustpoint: test2 - vrf: test - trap: - severity: informational - state: merged + config: + buffered: + size: 2097152 + severity: warnings + correlator: + buffer_size: 1024 + events: + display_location: true + files: + - maxfilesize: '1024' + name: test + path: test + severity: info + hostnameprefix: test + hosts: + - host: 1.1.1.1 + port: default + severity: critical + vrf: default + ipv4: + dscp: af11 + localfilesize: 1024 + monitor: + severity: errors + source_interfaces: + - interface: GigabitEthernet0/0/0/0 + vrf: test + tls_servers: + - name: test + tls_hostname: test2 + trustpoint: test2 + vrf: test + trap: + severity: informational + state: merged # # # After state: -#------------------------------------------- -#RP/0/0/CPU0:10#show running-config logging +# ------------------------------------------- +# RP/0/0/CPU0:10#show running-config logging # Tue Jul 20 18:09:18.491 UTC # logging tls-server test # vrf test @@ -432,8 +432,8 @@ # logging localfilesize 1024 # logging source-interface GigabitEthernet0/0/0/0 vrf test # logging hostnameprefix test -#------------------------------------------------ -#Module execution +# ------------------------------------------------ +# Module execution # # "after": { # "buffered": { @@ -582,8 +582,8 @@ # Using replaced: # ----------------------------------------------------------- # -#Before state -#RP/0/0/CPU0:10#show running-config logging +# Before state +# RP/0/0/CPU0:10#show running-config logging # Tue Jul 20 18:09:18.491 UTC # logging tls-server test # vrf test @@ -602,42 +602,42 @@ # logging localfilesize 1024 # logging source-interface GigabitEthernet0/0/0/0 vrf test # logging hostnameprefix test -#----------------------------------------------------------- +# ----------------------------------------------------------- # - name: Replace BGP configuration with provided configuration cisco.iosxr.iosxr_logging_global: - state: replaced - config: - buffered: - severity: errors - correlator: - buffer_size: 1024 - files: - - maxfilesize: '1024' - name: test - path: test1 - severity: info - hostnameprefix: test1 - hosts: - - host: 1.1.1.3 - port: default - severity: critical - vrf: default - ipv6: - dscp: af11 - localfilesize: 1024 - monitor: - severity: errors - tls_servers: - - name: test - tls_hostname: test2 - trustpoint: test - vrf: test - trap: - severity: critical + state: replaced + config: + buffered: + severity: errors + correlator: + buffer_size: 1024 + files: + - maxfilesize: '1024' + name: test + path: test1 + severity: info + hostnameprefix: test1 + hosts: + - host: 1.1.1.3 + port: default + severity: critical + vrf: default + ipv6: + dscp: af11 + localfilesize: 1024 + monitor: + severity: errors + tls_servers: + - name: test + tls_hostname: test2 + trustpoint: test + vrf: test + trap: + severity: critical # # After state: -#RP/0/0/CPU0:10#show running-config logging +# RP/0/0/CPU0:10#show running-config logging # Tue Jul 20 18:31:51.709 UTC # logging tls-server test # vrf test @@ -653,7 +653,7 @@ # logging correlator buffer-size 1024 # logging localfilesize 1024 # logging hostnameprefix test1 -#----------------------------------------------------------------- +# ----------------------------------------------------------------- # # Module Execution: # "after": { @@ -773,7 +773,7 @@ # Using deleted: # ----------------------------------------------------------- # Before state: -#RP/0/0/CPU0:10#show running-config logging +# RP/0/0/CPU0:10#show running-config logging # Tue Jul 20 18:09:18.491 UTC # logging tls-server test # vrf test @@ -793,15 +793,15 @@ # logging source-interface GigabitEthernet0/0/0/0 vrf test # logging hostnameprefix test # -#----------------------------------------------------------- +# ----------------------------------------------------------- - name: Delete given logging_global configuration cisco.iosxr.iosxr_logging_global: - state: deleted + state: deleted # # After state: -#RP/0/0/CPU0:10#show running-config +# RP/0/0/CPU0:10#show running-config # -#------------------------------------------------------------- +# ------------------------------------------------------------- # Module Execution: # # "after": {}, @@ -887,7 +887,7 @@ # using gathered: # ------------------------------------------------------------ # Before state: -#RP/0/0/CPU0:10#show running-config logging +# RP/0/0/CPU0:10#show running-config logging # Tue Jul 20 18:09:18.491 UTC # logging tls-server test # vrf test @@ -910,9 +910,9 @@ # - name: Gather iosxr_logging_global facts using gathered state cisco.iosxr.iosxr_logging_global: - state: gathered + state: gathered # -#------------------------------------------------------------- +# ------------------------------------------------------------- # Module Execution: # # "changed": false, @@ -979,7 +979,7 @@ # # # Using parsed: -#--------------------------------------------------------------- +# --------------------------------------------------------------- # # parsed.cfg # @@ -1004,9 +1004,9 @@ # - name: Parse externally provided Logging global config to agnostic model cisco.iosxr.iosxr_logging_global: - running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}" - state: parsed -#---------------------------------------------------------------- + running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}" + state: parsed +# ---------------------------------------------------------------- # Module execution: # "changed": false, # "parsed": { @@ -1066,44 +1066,46 @@ # # Using rendered: # ---------------------------------------------------------------------------- -- name: Render platform specific configuration lines with state rendered (without connecting to the device) +- name: >- + Render platform specific configuration lines with state rendered (without + connecting to the device) cisco.iosxr.iosxr_logging_global: - state: rendered - config: - buffered: - size: 2097152 - severity: warnings - correlator: - buffer_size: 1024 - events: - display_location: True - files: - - maxfilesize: '1024' - name: test - path: test - severity: info - hostnameprefix: test - hosts: - - host: 1.1.1.1 - port: default - severity: critical - vrf: default - ipv4: - dscp: af11 - localfilesize: 1024 - monitor: - severity: errors - source_interfaces: - - interface: GigabitEthernet0/0/0/0 - vrf: test - tls_servers: - - name: test - tls_hostname: test2 - trustpoint: test2 - vrf: test - trap: - severity: informational -#---------------------------------------------------------------- + state: rendered + config: + buffered: + size: 2097152 + severity: warnings + correlator: + buffer_size: 1024 + events: + display_location: true + files: + - maxfilesize: '1024' + name: test + path: test + severity: info + hostnameprefix: test + hosts: + - host: 1.1.1.1 + port: default + severity: critical + vrf: default + ipv4: + dscp: af11 + localfilesize: 1024 + monitor: + severity: errors + source_interfaces: + - interface: GigabitEthernet0/0/0/0 + vrf: test + tls_servers: + - name: test + tls_hostname: test2 + trustpoint: test2 + vrf: test + trap: + severity: informational +# ---------------------------------------------------------------- # Module Execution: # "rendered": [ # "logging buffered errors", @@ -1126,7 +1128,7 @@ # Using overridden: # --------------------------------------------------------------------------------- # Before state: -#RP/0/0/CPU0:10#show running-config logging +# RP/0/0/CPU0:10#show running-config logging # Tue Jul 20 18:09:18.491 UTC # logging tls-server test # vrf test @@ -1146,42 +1148,42 @@ # logging source-interface GigabitEthernet0/0/0/0 vrf test # logging hostnameprefix test # -#----------------------------------------------------------- +# ----------------------------------------------------------- # - name: Overridde logging global configuration with provided configuration cisco.iosxr.iosxr_logging_global: - state: overridden - config: - buffered: - severity: errors - correlator: - buffer_size: 1024 - files: - - maxfilesize: '1024' - name: test - path: test1 - severity: info - hostnameprefix: test1 - hosts: - - host: 1.1.1.3 - port: default - severity: critical - vrf: default - ipv6: - dscp: af11 - localfilesize: 1024 - monitor: - severity: errors - tls_servers: - - name: test - tls_hostname: test2 - trustpoint: test - vrf: test - trap: - severity: critical + state: overridden + config: + buffered: + severity: errors + correlator: + buffer_size: 1024 + files: + - maxfilesize: '1024' + name: test + path: test1 + severity: info + hostnameprefix: test1 + hosts: + - host: 1.1.1.3 + port: default + severity: critical + vrf: default + ipv6: + dscp: af11 + localfilesize: 1024 + monitor: + severity: errors + tls_servers: + - name: test + tls_hostname: test2 + trustpoint: test + vrf: test + trap: + severity: critical # # After state: -#RP/0/0/CPU0:10#show running-config logging +# RP/0/0/CPU0:10#show running-config logging # Tue Jul 20 18:31:51.709 UTC # logging tls-server test # vrf test @@ -1197,7 +1199,7 @@ # logging correlator buffer-size 1024 # logging localfilesize 1024 # logging hostnameprefix test1 -#----------------------------------------------------------------- +# ----------------------------------------------------------------- # # Module Execution: # "after": { diff --git a/plugins/modules/iosxr_ntp_global.py b/plugins/modules/iosxr_ntp_global.py index 94ca24f4c..bdcf2e523 100644 --- a/plugins/modules/iosxr_ntp_global.py +++ b/plugins/modules/iosxr_ntp_global.py @@ -273,51 +273,51 @@ # ------------ - name: Merge the provided configuration with the existing running configuration cisco.iosxr.iosxr_ntp_global: - config: - access_group: - ipv4: - peer: PeerAcl1 - query_only: QueryOnlyAcl1 - serve: ServeAcl1 - serve_only: ServeOnlyAcl1 - vrfs: - - ipv4: - peer: PeerAcl3 - serve: ServeAcl2 - name: siteA - authenticate: true - broadcastdelay: 1 - drift: - aging_time: 0 - file: apphost - interfaces: - - name: GigabitEthernet0/0/0/0 - multicast_client: 224.0.0.8 - multicast_destination: 224.0.0.8 - broadcast_client: true - ipv4: - dscp: af11 - ipv6: - precedence: routine - log_internal_sync: true - master: 1 - max_associations: 10 - passive: true - peers: - - iburst: true - peer: 192.0.2.1 - vrf: siteC - servers: - - burst: true - server: 192.0.2.2 - vrf: siteD - source: GigabitEthernet0/0/0/0 - source_vrfs: - - name: GigabitEthernet0/0/0/0 - vrf: siteE - trusted_keys: - - key_id: 1 - update_calendar: true + config: + access_group: + ipv4: + peer: PeerAcl1 + query_only: QueryOnlyAcl1 + serve: ServeAcl1 + serve_only: ServeOnlyAcl1 + vrfs: + - ipv4: + peer: PeerAcl3 + serve: ServeAcl2 + name: siteA + authenticate: true + broadcastdelay: 1 + drift: + aging_time: 0 + file: apphost + interfaces: + - name: GigabitEthernet0/0/0/0 + multicast_client: 224.0.0.8 + multicast_destination: 224.0.0.8 + broadcast_client: true + ipv4: + dscp: af11 + ipv6: + precedence: routine + log_internal_sync: true + master: 1 + max_associations: 10 + passive: true + peers: + - iburst: true + peer: 192.0.2.1 + vrf: siteC + servers: + - burst: true + server: 192.0.2.2 + vrf: siteD + source: GigabitEthernet0/0/0/0 + source_vrfs: + - name: GigabitEthernet0/0/0/0 + vrf: siteE + trusted_keys: + - key_id: 1 + update_calendar: true # Commands Fired: # ------------ # "commands": [ @@ -485,52 +485,52 @@ # ---------------- - name: Override BGP configuration with provided configuration cisco.iosxr.iosxr_ntp_global: - state: overridden - config: - access_group: - ipv4: - peer: PeerAcl1 - query_only: QueryOnlyAcl1 - serve: ServeAcl4 - serve_only: ServeOnlyAcl1 - vrfs: - - ipv4: - peer: PeerAcl3 - serve: ServeAcl2 - name: siteA - authenticate: true - broadcastdelay: 1 - drift: - aging_time: 0 - file: apphost - interfaces: - - name: GigabitEthernet0/0/0/1 - multicast_client: 224.0.0.8 - multicast_destination: 224.0.0.8 - broadcast_client: true - ipv4: - dscp: af12 - ipv6: - precedence: routine - log_internal_sync: true - master: 1 - max_associations: 10 - passive: true - peers: - - iburst: true - peer: 192.0.2.3 - vrf: siteC - servers: - - burst: true - server: 192.0.2.2 - vrf: siteD - source: GigabitEthernet0/0/0/1 - source_vrfs: - - name: GigabitEthernet0/0/0/0 - vrf: siteE - trusted_keys: - - key_id: 1 - update_calendar: true + state: overridden + config: + access_group: + ipv4: + peer: PeerAcl1 + query_only: QueryOnlyAcl1 + serve: ServeAcl4 + serve_only: ServeOnlyAcl1 + vrfs: + - ipv4: + peer: PeerAcl3 + serve: ServeAcl2 + name: siteA + authenticate: true + broadcastdelay: 1 + drift: + aging_time: 0 + file: apphost + interfaces: + - name: GigabitEthernet0/0/0/1 + multicast_client: 224.0.0.8 + multicast_destination: 224.0.0.8 + broadcast_client: true + ipv4: + dscp: af12 + ipv6: + precedence: routine + log_internal_sync: true + master: 1 + max_associations: 10 + passive: true + peers: + - iburst: true + peer: 192.0.2.3 + vrf: siteC + servers: + - burst: true + server: 192.0.2.2 + vrf: siteD + source: GigabitEthernet0/0/0/1 + source_vrfs: + - name: GigabitEthernet0/0/0/0 + vrf: siteE + trusted_keys: + - key_id: 1 + update_calendar: true # Commands Fired: # --------------- # "commands": [ @@ -616,52 +616,52 @@ # ---------------- - name: Replaced BGP configuration with provided configuration cisco.iosxr.iosxr_ntp_global: - state: replaced - config: - access_group: - ipv4: - peer: PeerAcl1 - query_only: QueryOnlyAcl1 - serve: ServeAcl4 - serve_only: ServeOnlyAcl1 - vrfs: - - ipv4: - peer: PeerAcl3 - serve: ServeAcl2 - name: siteA - authenticate: true - broadcastdelay: 1 - drift: - aging_time: 0 - file: apphost - interfaces: - - name: GigabitEthernet0/0/0/1 - multicast_client: 224.0.0.8 - multicast_destination: 224.0.0.8 - broadcast_client: true - ipv4: - dscp: af12 - ipv6: - precedence: routine - log_internal_sync: true - master: 1 - max_associations: 10 - passive: true - peers: - - iburst: true - peer: 192.0.2.3 - vrf: siteC - servers: - - burst: true - server: 192.0.2.2 - vrf: siteD - source: GigabitEthernet0/0/0/1 - source_vrfs: - - name: GigabitEthernet0/0/0/0 - vrf: siteE - trusted_keys: - - key_id: 1 - update_calendar: true + state: replaced + config: + access_group: + ipv4: + peer: PeerAcl1 + query_only: QueryOnlyAcl1 + serve: ServeAcl4 + serve_only: ServeOnlyAcl1 + vrfs: + - ipv4: + peer: PeerAcl3 + serve: ServeAcl2 + name: siteA + authenticate: true + broadcastdelay: 1 + drift: + aging_time: 0 + file: apphost + interfaces: + - name: GigabitEthernet0/0/0/1 + multicast_client: 224.0.0.8 + multicast_destination: 224.0.0.8 + broadcast_client: true + ipv4: + dscp: af12 + ipv6: + precedence: routine + log_internal_sync: true + master: 1 + max_associations: 10 + passive: true + peers: + - iburst: true + peer: 192.0.2.3 + vrf: siteC + servers: + - burst: true + server: 192.0.2.2 + vrf: siteD + source: GigabitEthernet0/0/0/1 + source_vrfs: + - name: GigabitEthernet0/0/0/0 + vrf: siteE + trusted_keys: + - key_id: 1 + update_calendar: true # Commands Fired: # --------------- # "commands": [ @@ -822,7 +822,9 @@ # Using state: rendered # Rendered play: # -------------- -- name: Render platform specific configuration lines with state rendered (without connecting to the device) +- name: >- + Render platform specific configuration lines with state rendered (without + connecting to the device) cisco.iosxr.iosxr_ntp_global: state: rendered config: diff --git a/plugins/modules/iosxr_ospf_interfaces.py b/plugins/modules/iosxr_ospf_interfaces.py index 6045e28d8..5ee6930f2 100644 --- a/plugins/modules/iosxr_ospf_interfaces.py +++ b/plugins/modules/iosxr_ospf_interfaces.py @@ -492,7 +492,7 @@ address_family: - afi: ipv4 processes: - - process_id: "LAB3" + - process_id: LAB3 area: area_id: 0.0.0.3 cost: 20 @@ -501,7 +501,7 @@ keychain: cisco - afi: ipv6 processes: - - process_id: "LAB3" + - process_id: LAB3 area: area_id: 0.0.0.2 cost: 30 @@ -593,7 +593,7 @@ address_family: - afi: ipv4 processes: - - process_id: "LAB3" + - process_id: LAB3 area: area_id: 0.0.0.3 cost: 30 @@ -602,7 +602,7 @@ keychain: ciscoiosxr - afi: ipv6 processes: - - process_id: "LAB3" + - process_id: LAB3 area: area_id: 0.0.0.2 cost: 30 @@ -688,7 +688,7 @@ address_family: - afi: ipv4 processes: - - process_id: "LAB1" + - process_id: LAB1 area: area_id: 0.0.0.3 cost: 10 @@ -946,18 +946,18 @@ address_family: - afi: ipv4 processes: - - process_id: "LAB3" - area: - area_id: 0.0.0.3 + - process_id: LAB3 + area: + area_id: 0.0.0.3 cost: 20 authentication: message_digest: keychain: cisco - afi: ipv6 processes: - - process_id: "LAB3" - area: - area_id: 0.0.0.2 + - process_id: LAB3 + area: + area_id: 0.0.0.2 cost: 30 state: rendered diff --git a/plugins/modules/iosxr_ospfv2.py b/plugins/modules/iosxr_ospfv2.py index 5aabe2091..f86a75a62 100644 --- a/plugins/modules/iosxr_ospfv2.py +++ b/plugins/modules/iosxr_ospfv2.py @@ -1077,48 +1077,47 @@ cisco.iosxr.iosxr_ospfv2: config: processes: - - process_id: '27' - areas: - - area_id: '10' - hello_interval: 2 + - process_id: '27' + areas: + - area_id: '10' + hello_interval: 2 + authentication: + keychain: ansi11393 + - process_id: '26' + adjacency_stagger: + max_adjacency: 20 + min_adjacency: 10 + - process_id: '10' authentication: - keychain: ansi11393 - - process_id: '26' - adjacency_stagger: - max_adjacency: 20 - min_adjacency: 10 - - process_id: '10' - authentication: - keychain: ansible_test1102 - areas: - - area_id: '11' - default_cost: 5 - cost: 11 - - area_id: 22 - default_cost: 6 - - process_id: '30' - areas: - - area_id: 11 - default_cost: 5 - - area_id: 22 - default_cost: 6 - - cost: 2 - default_metric: 10 - transmit_delay: 2 - hello_interval: 1 - dead_interval: 2 - retransmit_interval: 2 - weight: 2 - packet_size: 577 - priority: 1 - router_id: 2.2.2.2 - demand_circuit: enable - passive: disable - summary_in: enable - flood_reduction: disable - mtu_ignore: enable - external_out: disable + keychain: ansible_test1102 + areas: + - area_id: '11' + default_cost: 5 + cost: 11 + - area_id: 22 + default_cost: 6 + - process_id: '30' + areas: + - area_id: 11 + default_cost: 5 + - area_id: 22 + default_cost: 6 + cost: 2 + default_metric: 10 + transmit_delay: 2 + hello_interval: 1 + dead_interval: 2 + retransmit_interval: 2 + weight: 2 + packet_size: 577 + priority: 1 + router_id: 2.2.2.2 + demand_circuit: enable + passive: disable + summary_in: enable + flood_reduction: disable + mtu_ignore: enable + external_out: disable state: merged # Task Output: @@ -1304,19 +1303,19 @@ cisco.iosxr.iosxr_ospfv2: config: processes: - - process_id: 27 - areas: - - area_id: 10 - hello_interval: 2 - - area_id: 20 - cost: 2 - default_cost: 2 - authentication: - keychain: ansi11393 - - process_id: 26 - adjacency_stagger: - min_adjacency: 10 - max_adjacency: 20 + - process_id: 27 + areas: + - area_id: 10 + hello_interval: 2 + - area_id: 20 + cost: 2 + default_cost: 2 + authentication: + keychain: ansi11393 + - process_id: 26 + adjacency_stagger: + min_adjacency: 10 + max_adjacency: 20 state: replaced # Task Output: @@ -1532,23 +1531,24 @@ cisco.iosxr.iosxr_ospfv2: config: processes: - - process_id: 27 - areas: - - area_id: 10 - hello_interval: 2 - authentication: - keychain: ansi11393 - - area_id: 20 - cost: 2 - default_cost: 2 - authentication: - keychain: ansi11393 - - process_id: 26 - adjacency_stagger: - min_adjacency: 10 - max_adjacency: 20 + - process_id: 27 + areas: + - area_id: 10 + hello_interval: 2 + authentication: + keychain: ansi11393 + - area_id: 20 + cost: 2 + default_cost: 2 + authentication: + keychain: ansi11393 + - process_id: 26 + adjacency_stagger: + min_adjacency: 10 + max_adjacency: 20 state: overridden + # # Task Output: # ------------ @@ -1742,12 +1742,13 @@ cisco.iosxr.iosxr_ospfv2: config: processes: - - process_id: '10' - - process_id: '26' - - process_id: '27' - - process_id: '30' + - process_id: '10' + - process_id: '26' + - process_id: '27' + - process_id: '30' state: deleted + # # Task Output: # ------------ @@ -1979,50 +1980,50 @@ cisco.iosxr.iosxr_ospfv2: config: processes: - - process_id: 27 - areas: - - area_id: 10 - hello_interval: 2 + - process_id: 27 + areas: + - area_id: 10 + hello_interval: 2 + authentication: + keychain: ansi11393 + - process_id: 26 + adjacency_stagger: + min_adjacency: 10 + max_adjacency: 20 + - process_id: 10 authentication: - keychain: ansi11393 - - process_id: 26 - adjacency_stagger: - min_adjacency: 10 - max_adjacency: 20 - - process_id: 10 - authentication: - keychain: ansible_test1102 - areas: - - area_id: 11 - default_cost: 5 - cost: 11 - - area_id: 22 - default_cost: 6 - - process_id: 30 - areas: - - area_id: 11 - default_cost: 5 - - area_id: 22 - default_cost: 6 - - cost: 2 - default_metric: 10 - transmit_delay: 2 - hello_interval: 1 - dead_interval: 2 - retransmit_interval: 2 - weight: 2 - packet_size: 577 - priority: 1 - router_id: 2.2.2.2 - demand_circuit: enable - passive: disable - summary_in: enable - flood_reduction: disable - mtu_ignore: enable - external_out: disable + keychain: ansible_test1102 + areas: + - area_id: 11 + default_cost: 5 + cost: 11 + - area_id: 22 + default_cost: 6 + - process_id: 30 + areas: + - area_id: 11 + default_cost: 5 + - area_id: 22 + default_cost: 6 + cost: 2 + default_metric: 10 + transmit_delay: 2 + hello_interval: 1 + dead_interval: 2 + retransmit_interval: 2 + weight: 2 + packet_size: 577 + priority: 1 + router_id: 2.2.2.2 + demand_circuit: enable + passive: disable + summary_in: enable + flood_reduction: disable + mtu_ignore: enable + external_out: disable state: rendered + # # Task Output: # ------------ diff --git a/plugins/modules/iosxr_ospfv3.py b/plugins/modules/iosxr_ospfv3.py index 183e2b47b..b86e4ff1b 100644 --- a/plugins/modules/iosxr_ospfv3.py +++ b/plugins/modules/iosxr_ospfv3.py @@ -1653,7 +1653,7 @@ retransmit_interval: 2 packet_size: 577 priority: 1 - router_id: '2.2.2.2' + router_id: 2.2.2.2 demand_circuit: true mtu_ignore: true state: merged @@ -2199,12 +2199,13 @@ cisco.iosxr.iosxr_ospfv3: config: processes: - - process_id: '10' - - process_id: '26' - - process_id: '27' - - process_id: '30' + - process_id: '10' + - process_id: '26' + - process_id: '27' + - process_id: '30' state: deleted + # # Task Output: # ------------ diff --git a/plugins/modules/iosxr_prefix_lists.py b/plugins/modules/iosxr_prefix_lists.py index dc2f01843..c47998020 100644 --- a/plugins/modules/iosxr_prefix_lists.py +++ b/plugins/modules/iosxr_prefix_lists.py @@ -104,50 +104,50 @@ # Before state -#RP/0/0/CPU0:10#show running-config -#Thu Feb 4 09:38:36.245 UTC -#% No such configuration item(s) -#RP/0/0/CPU0:10# +# RP/0/0/CPU0:10#show running-config +# Thu Feb 4 09:38:36.245 UTC +# % No such configuration item(s) +# RP/0/0/CPU0:10# # - name: Merge the provided configuration with the existing running configuration cisco.iosxr.iosxr_prefix_lists: - state: merged - config: - - afi: ipv6 - prefix_lists: - - name: pl_1 - entries: - - prefix: 2001:db8:1234::/48 - action: deny - sequence: 1 - - name: pl_2 - entries: - - sequence: 2 - action: remark - description: TEST_PL_2_REMARK - - afi: ipv4 - prefix_lists: - - name: pl1 - entries: - - sequence: 3 - action: remark - description: TEST_PL1_2_REMARK - - sequence: 4 - action: permit - prefix: 10.0.0.0/24 - - name: pl2 - entries: - - sequence: 5 - action: remark - description: TEST_PL2_REMARK - - name: pl3 - entries: - - sequence: 6 - action: permit - prefix: 35.0.0.0/8 - eq: 0 + state: merged + config: + - afi: ipv6 + prefix_lists: + - name: pl_1 + entries: + - prefix: '2001:db8:1234::/48' + action: deny + sequence: 1 + - name: pl_2 + entries: + - sequence: 2 + action: remark + description: TEST_PL_2_REMARK + - afi: ipv4 + prefix_lists: + - name: pl1 + entries: + - sequence: 3 + action: remark + description: TEST_PL1_2_REMARK + - sequence: 4 + action: permit + prefix: 10.0.0.0/24 + - name: pl2 + entries: + - sequence: 5 + action: remark + description: TEST_PL2_REMARK + - name: pl3 + entries: + - sequence: 6 + action: permit + prefix: 35.0.0.0/8 + eq: 0 # Task Output # ------------- @@ -197,12 +197,12 @@ # After state: # ------------ -#RP/0/0/CPU0:10#show running-config +# RP/0/0/CPU0:10#show running-config # ipv6 prefix-list pl_1 # 1 deny 2001:db8:1234::/48 # ! # ipv6 prefix-list pl_2 -# 2 remark TEST_PL_2_REMARK +# 2 remark TEST_PL_2_REMAR # ! # ipv4 prefix-list pl1 # 3 remark TEST_PL1_2_REMARK @@ -221,7 +221,7 @@ # Before state: # ------------- -#RP/0/0/CPU0:10#show running-config +# RP/0/0/CPU0:10#show running-config # # ipv6 prefix-list pl_1 # 1 deny 2001:db8:1234::/48 @@ -239,29 +239,31 @@ # -- name: Replace device configurations of listed prefix lists with provided configurations +- name: >- + Replace device configurations of listed prefix lists with provided + configurations register: result - cisco.iosxr.iosxr_prefix_lists: &id001 + cisco.iosxr.iosxr_prefix_lists: config: - - afi: ipv4 - prefix_lists: - - name: pl1 - entries: - - sequence: 3 - action: permit - prefix: 10.0.0.0/24 - - afi: ipv6 - prefix_lists: - - name: pl_1 - entries: - - prefix: 2001:db8:1234::/48 - action: permit - sequence: 1 - - name: pl_2 - entries: - - sequence: 2 - action: remark - description: TEST_PL1_2 + - afi: ipv4 + prefix_lists: + - name: pl1 + entries: + - sequence: 3 + action: permit + prefix: 10.0.0.0/24 + - afi: ipv6 + prefix_lists: + - name: pl_1 + entries: + - prefix: '2001:db8:1234::/48' + action: permit + sequence: 1 + - name: pl_2 + entries: + - sequence: 2 + action: remark + description: TEST_PL1_2 state: replaced @@ -328,7 +330,7 @@ # After state: -#RP/0/0/CPU0:10#show running-config +# RP/0/0/CPU0:10#show running-config # # ipv6 prefix-list pl_1 # 1 deny 2001:db8:1234::/48 @@ -426,7 +428,7 @@ # After state: # ------------ -#RP/0/0/CPU0:10#show running-config +# RP/0/0/CPU0:10#show running-config # ipv6 prefix-list pl_1 # 1 deny 2001:db8:1234::/48 # ! @@ -447,7 +449,7 @@ - name: Gather ACL interfaces facts using gathered state cisco.iosxr.iosxr_prefix_lists: - state: gathered + state: gathered # gathered: # - afi: ipv6 @@ -489,7 +491,7 @@ # parsed.cfg -#------------------------------ +# ------------------------------ # ipv6 prefix-list pl_1 # 1 deny 2001:db8:1234::/48 # ! @@ -504,11 +506,10 @@ # 5 remark TEST_PL2_REMARK - - name: Parse externally provided Prefix_lists config to agnostic model cisco.iosxr.iosxr_prefix_lists: - running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}" - state: parsed + running_config: '{{ lookup(''file'', ''./fixtures/parsed.cfg'') }}' + state: parsed # Task Output @@ -553,40 +554,39 @@ - name: Render platform specific commands from task input using rendered state register: result cisco.iosxr.iosxr_prefix_lists: - config: - - afi: ipv6 - prefix_lists: - - name: pl_1 - entries: - - prefix: 2001:db8:1234::/48 - action: deny - sequence: 1 - - name: pl_2 - entries: - - sequence: 2 - action: remark - description: TEST_PL_2_REMARK - - afi: ipv4 - prefix_lists: - - name: pl1 - entries: - - sequence: 3 - action: remark - description: TEST_PL1_2_REMARK - - sequence: 4 - action: permit - prefix: 10.0.0.0/24 - - name: pl2 - entries: - - sequence: 5 - action: remark - description: TEST_PL2_REMARK - - sequence: 6 - action: permit - prefix: 35.0.0.0/8 - eq: 0 - - state: rendered + config: + - afi: ipv6 + prefix_lists: + - name: pl_1 + entries: + - prefix: '2001:db8:1234::/48' + action: deny + sequence: 1 + - name: pl_2 + entries: + - sequence: 2 + action: remark + description: TEST_PL_2_REMARK + - afi: ipv4 + prefix_lists: + - name: pl1 + entries: + - sequence: 3 + action: remark + description: TEST_PL1_2_REMARK + - sequence: 4 + action: permit + prefix: 10.0.0.0/24 + - name: pl2 + entries: + - sequence: 5 + action: remark + description: TEST_PL2_REMARK + - sequence: 6 + action: permit + prefix: 35.0.0.0/8 + eq: 0 + state: rendered # Task Output @@ -600,14 +600,12 @@ # "ipv4 prefix-list pl2 6 permit 35.0.0.0/8 eq 0" # ] - - # Using overridden: # Before state: # ------------- -#RP/0/0/CPU0:10#show running-config +# RP/0/0/CPU0:10#show running-config # # ipv6 prefix-list pl_1 # 1 deny 2001:db8:1234::/48 @@ -624,22 +622,22 @@ # - name: Overridde all Prefix_lists configuration with provided configuration cisco.iosxr.iosxr_prefix_lists: - config: - - afi: ipv4 - prefix_lists: - - name: pl3 - entries: - - sequence: 3 - action: remark - description: TEST_PL1_3_REMARK - - sequence: 4 - action: permit - prefix: 10.0.0.0/24 - - sequence: 6 - action: permit - prefix: 35.0.0.0/8 - eq: 0 - state: overridden + config: + - afi: ipv4 + prefix_lists: + - name: pl3 + entries: + - sequence: 3 + action: remark + description: TEST_PL1_3_REMARK + - sequence: 4 + action: permit + prefix: 10.0.0.0/24 + - sequence: 6 + action: permit + prefix: 35.0.0.0/8 + eq: 0 + state: overridden # Task Output @@ -698,14 +696,14 @@ # After state: -#RP/0/0/CPU0:10#show running-config +# RP/0/0/CPU0:10#show running-config # -#ipv4 prefix-list pl3 +# ipv4 prefix-list pl3 # 3 remark TEST_PL1_3_REMARK # 4 permit 10.0.0.0/24 # 6 permit 35.0.0.0/8 eq 0 # ! -#! +# ! """ RETURN = """ diff --git a/plugins/modules/iosxr_snmp_server.py b/plugins/modules/iosxr_snmp_server.py index 43d7016d0..9bc685756 100644 --- a/plugins/modules/iosxr_snmp_server.py +++ b/plugins/modules/iosxr_snmp_server.py @@ -910,101 +910,102 @@ # --------------------- EMPTY ----------------- # Merged play: # ------------ + - name: Merge the provided configuration with the existing running configuration cisco.iosxr.iosxr_snmp_server: - config: - vrfs: - - hosts: - - community: test1 - host: 1.1.1.1 - traps: true - vrf: vrf1 - users: - - Ipv4_acl: test1 - Ipv6_acl: test2 - group: test2 - user: u1 - version: v1 - timeouts: - duplicate: 0 - inQdrop: 0 - trap: - throttle_time: 12 - targets: - - host: 1.1.1.2 - name: test + config: + vrfs: + - hosts: + - community: test1 + host: 1.1.1.1 + traps: true + vrf: vrf1 + users: + - Ipv4_acl: test1 + Ipv6_acl: test2 + group: test2 + user: u1 + version: v1 + timeouts: + duplicate: 0 + inQdrop: 0 + trap: + throttle_time: 12 + targets: + - host: 1.1.1.2 + name: test + ifmib: + internal_cache_max_duration: 4 + inform: + retries: 7 + chassis_id: test2 + packetsize: 490 + queue_length: 2 + throttle_time: 60 + trap_source: GigabitEthernet0/0/0/2 + trap_timeout: 3 + context: + - c1 + - c2 + contact: t1 + correlator: + buffer_size: 1024 + communities: + - name: test2 + ro: true + sdrowner: true + acl_v4: test + acl_v6: test1 + community_maps: + - name: cm1 + context: c1 + target_list: t1 + security_name: s1 + drop: + report_IPv4: test1 + unknown_user: true + ipv6: + precedence: routine + ipv4: + dscp: af11 + location: test1 + logging_threshold_oid_processing: 1 + logging_threshold_pdu_processing: 1 + mib_bulkstat_max_procmem_size: 101 + mroutemib_send_all_vrf: true + overload_control: + overload_drop_time: 4 + overload_throttle_rate: 6 + notification_log_mib: + GlobalSize: 5 + size: 5 + traps: + hsrp: true + ipsla: true + ipsec: + start: true + stop: true + bridgemib: true + bulkstat_collection: true + cisco_entity_ext: true + config: true + copy_complete: true + addrpool: + high: true + low: true + bfd: true + bgp: + cbgp2: true + l2tun: + sessions: true + tunnel_down: true + tunnel_up: true + l2vpn: + all: true + vc_down: true + vc_up: true + msdp_peer_state_change: true - ifmib: - internal_cache_max_duration: 4 - inform: - retries: 7 - chassis_id: test2 - packetsize: 490 - queue_length: 2 - throttle_time: 60 - trap_source: GigabitEthernet0/0/0/2 - trap_timeout: 3 - context: - - c1 - - c2 - contact: t1 - correlator: - buffer_size: 1024 - communities: - - name: test2 - ro: true - sdrowner: true - acl_v4: test - acl_v6: test1 - community_maps: - - name: cm1 - context: c1 - target_list: t1 - security_name: s1 - drop: - report_IPv4: test1 - unknown_user: true - ipv6: - precedence: routine - ipv4: - dscp: af11 - location: test1 - logging_threshold_oid_processing: 1 - logging_threshold_pdu_processing: 1 - mib_bulkstat_max_procmem_size: 101 - mroutemib_send_all_vrf: true - overload_control: - overload_drop_time: 4 - overload_throttle_rate: 6 - notification_log_mib: - GlobalSize: 5 - size: 5 - traps: - hsrp: true - ipsla: true - ipsec: - start: true - stop: true - bridgemib: true - bulkstat_collection: true - cisco_entity_ext: true - config: true - copy_complete: true - addrpool: - high: true - low: true - bfd: true - bgp: - cbgp2: true - l2tun: - sessions: true - tunnel_down: true - tunnel_up: true - l2vpn: - all: true - vc_down: true - vc_up: true - msdp_peer_state_change: true # # Commands Fired: # ------------ @@ -1315,78 +1316,78 @@ # ---------------- - name: Override Snmp-server configuration with provided configuration cisco.iosxr.iosxr_snmp_server: - config: - timeouts: - duplicate: 0 - inQdrop: 0 - trap: - throttle_time: 13 - targets: - - host: 1.1.1.2 - name: test + config: + timeouts: + duplicate: 0 + inQdrop: 0 + trap: + throttle_time: 13 + targets: + - host: 1.1.1.2 + name: test + ifmib: + internal_cache_max_duration: 5 + inform: + retries: 7 + chassis_id: test + packetsize: 491 + queue_length: 2 + throttle_time: 60 + trap_source: GigabitEthernet0/0/0/2 + trap_timeout: 3 + context: + - c1 + - c2 + contact: t1 + correlator: + buffer_size: 1025 + communities: + - name: test1 + ro: true + sdrowner: true + acl_v4: test + acl_v6: test1 + community_maps: + - name: cm2 + context: c1 + target_list: t1 + security_name: s1 + drop: + report_IPv4: test2 + unknown_user: true + ipv6: + precedence: routine + ipv4: + dscp: af11 + location: test1 + logging_threshold_oid_processing: 2 + logging_threshold_pdu_processing: 2 + mib_bulkstat_max_procmem_size: 101 + mroutemib_send_all_vrf: true + overload_control: + overload_drop_time: 4 + overload_throttle_rate: 6 + notification_log_mib: + GlobalSize: 5 + size: 5 + traps: + hsrp: true + ipsla: true + ipsec: + start: true + stop: true + bridgemib: true + bulkstat_collection: true + cisco_entity_ext: true + config: true + copy_complete: true + l2vpn: + all: true + vc_down: true + vc_up: true + msdp_peer_state_change: true + state: overridden - ifmib: - internal_cache_max_duration: 5 - inform: - retries: 7 - chassis_id: test - packetsize: 491 - queue_length: 2 - throttle_time: 60 - trap_source: GigabitEthernet0/0/0/2 - trap_timeout: 3 - context: - - c1 - - c2 - contact: t1 - correlator: - buffer_size: 1025 - communities: - - name: test1 - ro: true - sdrowner: true - acl_v4: test - acl_v6: test1 - community_maps: - - name: cm2 - context: c1 - target_list: t1 - security_name: s1 - drop: - report_IPv4: test2 - unknown_user: true - ipv6: - precedence: routine - ipv4: - dscp: af11 - location: test1 - logging_threshold_oid_processing: 2 - logging_threshold_pdu_processing: 2 - mib_bulkstat_max_procmem_size: 101 - mroutemib_send_all_vrf: true - overload_control: - overload_drop_time: 4 - overload_throttle_rate: 6 - notification_log_mib: - GlobalSize: 5 - size: 5 - traps: - hsrp: true - ipsla: true - ipsec: - start: true - stop: true - bridgemib: true - bulkstat_collection: true - cisco_entity_ext: true - config: true - copy_complete: true - l2vpn: - all: true - vc_down: true - vc_up: true - msdp_peer_state_change: true - state: overridden # Commands Fired: # --------------- # "commands": [ @@ -1526,78 +1527,78 @@ # ---------------- - name: Replace Snmp-server configuration with provided configuration cisco.iosxr.iosxr_snmp_server: - state: replaced - config: - timeouts: - duplicate: 0 - inQdrop: 0 - trap: - throttle_time: 13 - targets: - - host: 1.1.1.2 - name: test + state: replaced + config: + timeouts: + duplicate: 0 + inQdrop: 0 + trap: + throttle_time: 13 + targets: + - host: 1.1.1.2 + name: test + ifmib: + internal_cache_max_duration: 5 + inform: + retries: 7 + chassis_id: test + packetsize: 491 + queue_length: 2 + throttle_time: 60 + trap_source: GigabitEthernet0/0/0/2 + trap_timeout: 3 + context: + - c1 + - c2 + contact: t1 + correlator: + buffer_size: 1025 + communities: + - name: test1 + ro: true + sdrowner: true + acl_v4: test + acl_v6: test1 + community_maps: + - name: cm2 + context: c1 + target_list: t1 + security_name: s1 + drop: + report_IPv4: test2 + unknown_user: true + ipv6: + precedence: routine + ipv4: + dscp: af11 + location: test1 + logging_threshold_oid_processing: 2 + logging_threshold_pdu_processing: 2 + mib_bulkstat_max_procmem_size: 101 + mroutemib_send_all_vrf: true + overload_control: + overload_drop_time: 4 + overload_throttle_rate: 6 + notification_log_mib: + GlobalSize: 5 + size: 5 + traps: + hsrp: true + ipsla: true + ipsec: + start: true + stop: true + bridgemib: true + bulkstat_collection: true + cisco_entity_ext: true + config: true + copy_complete: true + l2vpn: + all: true + vc_down: true + vc_up: true + msdp_peer_state_change: true - ifmib: - internal_cache_max_duration: 5 - inform: - retries: 7 - chassis_id: test - packetsize: 491 - queue_length: 2 - throttle_time: 60 - trap_source: GigabitEthernet0/0/0/2 - trap_timeout: 3 - context: - - c1 - - c2 - contact: t1 - correlator: - buffer_size: 1025 - communities: - - name: test1 - ro: true - sdrowner: true - acl_v4: test - acl_v6: test1 - community_maps: - - name: cm2 - context: c1 - target_list: t1 - security_name: s1 - drop: - report_IPv4: test2 - unknown_user: true - ipv6: - precedence: routine - ipv4: - dscp: af11 - location: test1 - logging_threshold_oid_processing: 2 - logging_threshold_pdu_processing: 2 - mib_bulkstat_max_procmem_size: 101 - mroutemib_send_all_vrf: true - overload_control: - overload_drop_time: 4 - overload_throttle_rate: 6 - notification_log_mib: - GlobalSize: 5 - size: 5 - traps: - hsrp: true - ipsla: true - ipsec: - start: true - stop: true - bridgemib: true - bulkstat_collection: true - cisco_entity_ext: true - config: true - copy_complete: true - l2vpn: - all: true - vc_down: true - vc_up: true - msdp_peer_state_change: true # # Commands Fired: # --------------- @@ -1890,7 +1891,9 @@ # Using state: rendered # Rendered play: # -------------- -- name: Render platform specific configuration lines with state rendered (without connecting to the device) +- name: >- + Render platform specific configuration lines with state rendered (without + connecting to the device) cisco.iosxr.iosxr_snmp_server: state: rendered config: @@ -1914,7 +1917,6 @@ targets: - host: 1.1.1.2 name: test - ifmib: internal_cache_max_duration: 4 inform: @@ -1987,6 +1989,7 @@ vc_up: true msdp_peer_state_change: true register: result + # Module Execution Result: # ------------------------ # "rendered": [ diff --git a/plugins/modules/iosxr_static_routes.py b/plugins/modules/iosxr_static_routes.py index 7bc9cbd8c..3a9fa07b3 100644 --- a/plugins/modules/iosxr_static_routes.py +++ b/plugins/modules/iosxr_static_routes.py @@ -172,57 +172,52 @@ - name: Merge the provided configuration with the existing running configuration cisco.iosxr.iosxr_static_routes: config: - - address_families: - - afi: ipv4 - safi: unicast - routes: - - dest: 192.0.2.16/28 - next_hops: - - forward_router_address: 192.0.2.10 - interface: FastEthernet0/0/0/1 - description: LAB - metric: 120 - tag: 10 - - - interface: FastEthernet0/0/0/5 - track: ip_sla_1 - - - dest: 192.0.2.32/28 - next_hops: - - forward_router_address: 192.0.2.11 - admin_distance: 100 - - - afi: ipv6 - safi: unicast - routes: - - dest: 2001:db8:1000::/36 - next_hops: - - interface: FastEthernet0/0/0/7 - description: DC - - - interface: FastEthernet0/0/0/8 - forward_router_address: 2001:db8:2000:2::1 - - - vrf: DEV_SITE - address_families: - - afi: ipv4 - safi: unicast - routes: - - dest: 192.0.2.48/28 - next_hops: - - forward_router_address: 192.0.2.12 - description: DEV - dest_vrf: test_1 - - - dest: 192.0.2.80/28 - next_hops: - - interface: FastEthernet0/0/0/2 - forward_router_address: 192.0.2.14 - dest_vrf: test_1 - track: ip_sla_2 - vrflabel: 124 + - address_families: + - afi: ipv4 + safi: unicast + routes: + - dest: 192.0.2.16/28 + next_hops: + - forward_router_address: 192.0.2.10 + interface: FastEthernet0/0/0/1 + description: LAB + metric: 120 + tag: 10 + - interface: FastEthernet0/0/0/5 + track: ip_sla_1 + - dest: 192.0.2.32/28 + next_hops: + - forward_router_address: 192.0.2.11 + admin_distance: 100 + - afi: ipv6 + safi: unicast + routes: + - dest: '2001:db8:1000::/36' + next_hops: + - interface: FastEthernet0/0/0/7 + description: DC + - interface: FastEthernet0/0/0/8 + forward_router_address: '2001:db8:2000:2::1' + - vrf: DEV_SITE + address_families: + - afi: ipv4 + safi: unicast + routes: + - dest: 192.0.2.48/28 + next_hops: + - forward_router_address: 192.0.2.12 + description: DEV + dest_vrf: test_1 + - dest: 192.0.2.80/28 + next_hops: + - interface: FastEthernet0/0/0/2 + forward_router_address: 192.0.2.14 + dest_vrf: test_1 + track: ip_sla_2 + vrflabel: 124 state: merged + # Task Output # ----------- # before: [] @@ -335,23 +330,22 @@ - name: Update existing static routes configuration using merged cisco.iosxr.iosxr_static_routes: config: - - vrf: DEV_SITE - address_families: - - afi: ipv4 - safi: unicast - routes: - - dest: 192.0.2.48/28 - next_hops: - - forward_router_address: 192.0.2.12 - vrflabel: 2301 - dest_vrf: test_1 - - - dest: 192.0.2.80/28 - next_hops: - - interface: FastEthernet0/0/0/2 - forward_router_address: 192.0.2.14 - dest_vrf: test_1 - description: rt_test_1 + - vrf: DEV_SITE + address_families: + - afi: ipv4 + safi: unicast + routes: + - dest: 192.0.2.48/28 + next_hops: + - forward_router_address: 192.0.2.12 + vrflabel: 2301 + dest_vrf: test_1 + - dest: 192.0.2.80/28 + next_hops: + - interface: FastEthernet0/0/0/2 + forward_router_address: 192.0.2.14 + dest_vrf: test_1 + description: rt_test_1 state: merged # Task Output @@ -504,17 +498,17 @@ - name: Replace device configurations of static routes with provided configurations cisco.iosxr.iosxr_static_routes: config: - - vrf: DEV_SITE - address_families: - - afi: ipv4 - safi: unicast - routes: - - dest: 192.0.2.48/28 - next_hops: - - forward_router_address: 192.0.2.15 - interface: FastEthernet0/0/0/3 - description: DEV_NEW - dest_vrf: dev_test_2 + - vrf: DEV_SITE + address_families: + - afi: ipv4 + safi: unicast + routes: + - dest: 192.0.2.48/28 + next_hops: + - forward_router_address: 192.0.2.15 + interface: FastEthernet0/0/0/3 + description: DEV_NEW + dest_vrf: dev_test_2 state: replaced # Task Output @@ -570,7 +564,7 @@ # vrflabel: 124 # safi: unicast # vrf: DEV_SITE -#commands: +# commands: # - router static # - vrf DEV_SITE # - address-family ipv4 unicast @@ -673,25 +667,25 @@ - name: Overridde all static routes configuration with provided configuration cisco.iosxr.iosxr_static_routes: config: - - vrf: DEV_NEW - address_families: - - afi: ipv4 - safi: unicast - routes: - - dest: 192.0.2.48/28 - next_hops: - - forward_router_address: 192.0.2.15 - interface: FastEthernet0/0/0/3 - description: DEV1 - - afi: ipv6 - safi: unicast - routes: - - dest: 2001:db8:3000::/36 - next_hops: - - interface: FastEthernet0/0/0/4 - forward_router_address: 2001:db8:2000:2::2 - description: PROD1 - track: ip_sla_1 + - vrf: DEV_NEW + address_families: + - afi: ipv4 + safi: unicast + routes: + - dest: 192.0.2.48/28 + next_hops: + - forward_router_address: 192.0.2.15 + interface: FastEthernet0/0/0/3 + description: DEV1 + - afi: ipv6 + safi: unicast + routes: + - dest: '2001:db8:3000::/36' + next_hops: + - interface: FastEthernet0/0/0/4 + forward_router_address: '2001:db8:2000:2::2' + description: PROD1 + track: ip_sla_1 state: overridden # Task Output @@ -818,10 +812,10 @@ - name: Delete all destination network entries under a single AFI cisco.iosxr.iosxr_static_routes: config: - - vrf: DEV_SITE - address_families: - - afi: ipv4 - safi: unicast + - vrf: DEV_SITE + address_families: + - afi: ipv4 + safi: unicast state: deleted # Task output @@ -1137,26 +1131,25 @@ # Using rendered - name: Render platform specific commands (without connecting to the device) - cisco.iosxr.iosxr_static_routes: + cisco.iosxr.iosxr_static_routes: null config: - - vrf: DEV_SITE - address_families: - - afi: ipv4 - safi: unicast - routes: - - dest: 192.0.2.48/28 - next_hops: - - forward_router_address: 192.0.2.12 - description: DEV - dest_vrf: test_1 - - - dest: 192.0.2.80/28 - next_hops: - - interface: FastEthernet0/0/0/2 - forward_router_address: 192.0.2.14 - dest_vrf: test_1 - track: ip_sla_2 - vrflabel: 124 + - vrf: DEV_SITE + address_families: + - afi: ipv4 + safi: unicast + routes: + - dest: 192.0.2.48/28 + next_hops: + - forward_router_address: 192.0.2.12 + description: DEV + dest_vrf: test_1 + - dest: 192.0.2.80/28 + next_hops: + - interface: FastEthernet0/0/0/2 + forward_router_address: 192.0.2.14 + dest_vrf: test_1 + track: ip_sla_2 + vrflabel: 124 # Task Output (redacted) # ----------------------- diff --git a/plugins/modules/iosxr_system.py b/plugins/modules/iosxr_system.py index 0d0d60adb..d05608b6d 100644 --- a/plugins/modules/iosxr_system.py +++ b/plugins/modules/iosxr_system.py @@ -91,17 +91,17 @@ hostname: iosxr01 domain_name: test.example.com domain_search: - - ansible.com - - redhat.com - - cisco.com + - ansible.com + - redhat.com + - cisco.com - name: remove configuration cisco.iosxr.iosxr_system: hostname: iosxr01 domain_name: test.example.com domain_search: - - ansible.com - - redhat.com - - cisco.com + - ansible.com + - redhat.com + - cisco.com state: absent - name: configure hostname and domain-name with vrf cisco.iosxr.iosxr_system: @@ -109,9 +109,9 @@ vrf: nondefault domain_name: test.example.com domain_search: - - ansible.com - - redhat.com - - cisco.com + - ansible.com + - redhat.com + - cisco.com - name: configure DNS lookup sources cisco.iosxr.iosxr_system: lookup_source: MgmtEth0/0/CPU0/0 @@ -119,8 +119,8 @@ - name: configure name servers cisco.iosxr.iosxr_system: name_servers: - - 8.8.8.8 - - 8.8.4.4 + - 8.8.8.8 + - 8.8.4.4 """ RETURN = """ diff --git a/plugins/modules/iosxr_user.py b/plugins/modules/iosxr_user.py index ce4965a89..e89d6e9eb 100644 --- a/plugins/modules/iosxr_user.py +++ b/plugins/modules/iosxr_user.py @@ -224,18 +224,18 @@ - name: set multiple users to group sys-admin cisco.iosxr.iosxr_user: aggregate: - - name: netop - - name: netend + - name: netop + - name: netend group: sysadmin state: present - name: set multiple users to multiple groups cisco.iosxr.iosxr_user: aggregate: - - name: netop - - name: netend + - name: netop + - name: netend groups: - - sysadmin - - root-system + - sysadmin + - root-system state: present - name: Change Password for User netop cisco.iosxr.iosxr_user: diff --git a/requirements.txt b/requirements.txt index 83f814754..ece31d550 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,5 @@ ncclient paramiko -ipaddress -ansible-pylibssh grpcio protobuf +ansible-pylibssh diff --git a/test-requirements.txt b/test-requirements.txt index 2f1724f01..b8dae64f8 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,11 +1,12 @@ -black==22.3.0 ; python_version > '3.5' +black==23.3.0 flake8 mock pexpect -pytest-xdist yamllint coverage==4.5.4 google-api-python-client grpcio protobuf -git+https://github.com/ansible-community/pytest-ansible-units.git +pytest-ansible +pytest-xdist +pytest-cov diff --git a/tests/config.yml b/tests/config.yml index 41f529264..c26ea5966 100644 --- a/tests/config.yml +++ b/tests/config.yml @@ -1,3 +1,3 @@ --- modules: - python_requires: ">=3.6" + python_requires: ">=3.9" diff --git a/tests/integration/targets/iosxr_acl_interfaces/tests/cli/_remove_config.yaml b/tests/integration/targets/iosxr_acl_interfaces/tests/cli/_remove_config.yaml index 62eeb392e..6b08c8d17 100644 --- a/tests/integration/targets/iosxr_acl_interfaces/tests/cli/_remove_config.yaml +++ b/tests/integration/targets/iosxr_acl_interfaces/tests/cli/_remove_config.yaml @@ -18,6 +18,9 @@ - 0/0/0/1 - 0/0/0/2 - 0/0/0/4.1 + - 0/0/0/4 + - 0/0/0/8 + - 0/0/0/9 ignore_errors: true cisco.iosxr.iosxr_config: lines: diff --git a/tests/integration/targets/iosxr_config/tests/cli/backup.yaml b/tests/integration/targets/iosxr_config/tests/cli/backup.yaml index f33fedff6..26ecf9931 100644 --- a/tests/integration/targets/iosxr_config/tests/cli/backup.yaml +++ b/tests/integration/targets/iosxr_config/tests/cli/backup.yaml @@ -19,7 +19,7 @@ - ansible.builtin.assert: that: - result.changed == true - - result.updates is not defined + - result.updates is defined - name: Delete configurable backup file path ansible.builtin.file: diff --git a/tests/integration/targets/iosxr_config/tests/cli/comment-too-long.yaml b/tests/integration/targets/iosxr_config/tests/cli/comment-too-long.yaml index cbb59f6e8..b361b6c32 100644 --- a/tests/integration/targets/iosxr_config/tests/cli/comment-too-long.yaml +++ b/tests/integration/targets/iosxr_config/tests/cli/comment-too-long.yaml @@ -20,7 +20,6 @@ - ansible.builtin.assert: that: - result.changed == false - - result.updates is not defined - "'comment argument cannot be more than 60 characters' in result.msg" - ansible.builtin.debug: msg="END cli/comment-too-long.yaml on connection={{ ansible_connection }}" diff --git a/tests/integration/targets/iosxr_config/tests/cli/comment.yaml b/tests/integration/targets/iosxr_config/tests/cli/comment.yaml index dcbbe78a8..7b8ba6dec 100644 --- a/tests/integration/targets/iosxr_config/tests/cli/comment.yaml +++ b/tests/integration/targets/iosxr_config/tests/cli/comment.yaml @@ -20,7 +20,7 @@ - ansible.builtin.assert: that: - result.changed == true - - result.updates is not defined + - result.updates is defined - name: Check device with configuration register: result @@ -31,7 +31,6 @@ - ansible.builtin.assert: that: - result.changed == false - - result.updates is not defined - name: Assert accurately report configuration failure during pseudo-atomic operation register: result diff --git a/tests/integration/targets/iosxr_config/tests/cli/replace_block.yaml b/tests/integration/targets/iosxr_config/tests/cli/replace_block.yaml index b5dce6496..e3977bb74 100644 --- a/tests/integration/targets/iosxr_config/tests/cli/replace_block.yaml +++ b/tests/integration/targets/iosxr_config/tests/cli/replace_block.yaml @@ -31,3 +31,9 @@ that: - result2.changed == true - result1.commands == result2.commands + +- name: Cleanup + cisco.iosxr.iosxr_config: + commands: + - no interface GigabitEthernet 0/0/0/5 + ignore_errors: true diff --git a/tests/integration/targets/iosxr_config/tests/cli/src_basic.yaml b/tests/integration/targets/iosxr_config/tests/cli/src_basic.yaml index dd79ebe07..e4a7e9393 100644 --- a/tests/integration/targets/iosxr_config/tests/cli/src_basic.yaml +++ b/tests/integration/targets/iosxr_config/tests/cli/src_basic.yaml @@ -18,7 +18,7 @@ - ansible.builtin.assert: that: - result.changed == true - - result.updates is not defined + - result.updates is defined - name: Check device with configuration register: result @@ -28,6 +28,5 @@ - ansible.builtin.assert: that: - result.changed == false - - result.updates is not defined - ansible.builtin.debug: msg="END cli/src_basic.yaml on connection={{ ansible_connection }}" diff --git a/tests/integration/targets/iosxr_config/tests/cli/src_match_none.yaml b/tests/integration/targets/iosxr_config/tests/cli/src_match_none.yaml index 7794ab371..3e804679c 100644 --- a/tests/integration/targets/iosxr_config/tests/cli/src_match_none.yaml +++ b/tests/integration/targets/iosxr_config/tests/cli/src_match_none.yaml @@ -19,7 +19,7 @@ - ansible.builtin.assert: that: - result.changed == true - - result.updates is not defined + - result.updates is defined - name: Check device with configuration register: result @@ -29,6 +29,5 @@ - ansible.builtin.assert: that: - result.changed == false - - result.updates is not defined - ansible.builtin.debug: msg="END cli/src_match_none.yaml on connection={{ ansible_connection }}" diff --git a/tests/integration/targets/iosxr_logging/defaults/main.yaml b/tests/integration/targets/iosxr_logging/defaults/main.yaml deleted file mode 100644 index 9ef5ba516..000000000 --- a/tests/integration/targets/iosxr_logging/defaults/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -testcase: "*" -test_items: [] diff --git a/tests/integration/targets/iosxr_logging/meta/main.yaml b/tests/integration/targets/iosxr_logging/meta/main.yaml deleted file mode 100644 index be631e5d8..000000000 --- a/tests/integration/targets/iosxr_logging/meta/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -dependencies: - - prepare_iosxr_tests diff --git a/tests/integration/targets/iosxr_logging/tasks/cli.yaml b/tests/integration/targets/iosxr_logging/tasks/cli.yaml deleted file mode 100644 index 88e4708f8..000000000 --- a/tests/integration/targets/iosxr_logging/tasks/cli.yaml +++ /dev/null @@ -1,24 +0,0 @@ ---- -- name: Collect all CLI test cases - ansible.builtin.find: - paths: "{{ role_path }}/tests/cli" - patterns: "{{ testcase }}.yaml" - register: test_cases - delegate_to: localhost - -- name: Set test_items - ansible.builtin.set_fact: - test_items: "{{ test_cases.files | map(attribute='path') | list }}" - -- name: Run test case (connection=ansible.netcommon.network_cli) - ansible.builtin.include_tasks: "{{ test_case_to_run }}" - vars: - ansible_connection: ansible.netcommon.network_cli - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run - tags: - - network_cli - -- name: Reset connection - ansible.builtin.meta: reset_connection diff --git a/tests/integration/targets/iosxr_logging/tasks/main.yaml b/tests/integration/targets/iosxr_logging/tasks/main.yaml deleted file mode 100644 index 419a6cde6..000000000 --- a/tests/integration/targets/iosxr_logging/tasks/main.yaml +++ /dev/null @@ -1,6 +0,0 @@ ---- -- name: Include the CLI tasks - ansible.builtin.include_tasks: cli.yaml - -- name: Include the netconf tasks - ansible.builtin.include_tasks: netconf.yaml diff --git a/tests/integration/targets/iosxr_logging/tasks/netconf.yaml b/tests/integration/targets/iosxr_logging/tasks/netconf.yaml deleted file mode 100644 index 26f9ab49a..000000000 --- a/tests/integration/targets/iosxr_logging/tasks/netconf.yaml +++ /dev/null @@ -1,24 +0,0 @@ ---- -- name: Collect all CLI test cases - ansible.builtin.find: - paths: "{{ role_path }}/tests/netconf" - patterns: "{{ testcase }}.yaml" - register: test_cases - delegate_to: localhost - -- name: Set test_items - ansible.builtin.set_fact: - test_items: "{{ test_cases.files | map(attribute='path') | list }}" - -- name: Run test case (connection=ansible.netcommon.netconf) - ansible.builtin.include_tasks: "{{ test_case_to_run }}" - vars: - ansible_connection: ansible.netcommon.netconf - with_items: "{{ test_items }}" - loop_control: - loop_var: test_case_to_run - tags: - - netconf - -- name: Reset connection - ansible.builtin.meta: reset_connection diff --git a/tests/integration/targets/iosxr_logging/tests/cli/basic.yaml b/tests/integration/targets/iosxr_logging/tests/cli/basic.yaml deleted file mode 100644 index 02280f4a0..000000000 --- a/tests/integration/targets/iosxr_logging/tests/cli/basic.yaml +++ /dev/null @@ -1,140 +0,0 @@ ---- -- name: Remove host logging - cisco.iosxr.iosxr_logging: - dest: host - name: 172.16.0.1 - state: absent - -- name: Remove console logging - register: result - cisco.iosxr.iosxr_logging: - dest: console - state: absent - -- name: Remove buffered logging - register: result - cisco.iosxr.iosxr_logging: - dest: buffered - size: 2097155 - state: absent - -- name: Set up syslog host logging - register: result - cisco.iosxr.iosxr_logging: &id001 - dest: host - name: 172.16.0.1 - level: errors - state: present - -- ansible.builtin.assert: - that: - - result.changed == true - - '"logging 172.16.0.1 vrf default severity error" in result.commands' - -- name: Set up syslog host logging (idempotent) - register: result - cisco.iosxr.iosxr_logging: *id001 -- ansible.builtin.assert: &id003 - that: - - result.changed == false - -- name: Delete/disable syslog host logging - register: result - cisco.iosxr.iosxr_logging: &id002 - dest: host - name: 172.16.0.1 - state: absent - -- ansible.builtin.assert: - that: - - result.changed == true - - '"no logging 172.16.0.1 vrf default" in result.commands' - -- name: Delete/disable syslog host logging (idempotent) - register: result - cisco.iosxr.iosxr_logging: *id002 -- ansible.builtin.assert: *id003 -- name: Add console logging with level warning - register: result - cisco.iosxr.iosxr_logging: &id004 - dest: console - level: warning - state: present - -- ansible.builtin.assert: - that: - - result.changed == true - - '"logging console warning" in result.commands' - -- name: Console logging with level warning (idempotent) - register: result - cisco.iosxr.iosxr_logging: *id004 -- ansible.builtin.assert: *id003 -- name: Remove console logging with level warning - register: result - cisco.iosxr.iosxr_logging: - dest: console - level: warning - state: absent - -- ansible.builtin.assert: &id006 - that: - - result.changed == true - -- name: Configure buffered logging size - register: result - cisco.iosxr.iosxr_logging: &id005 - dest: buffered - size: 4800000 - state: present - -- ansible.builtin.assert: - that: - - result.changed == true - - '"logging buffered 4800000" in result.commands' - -- name: Configure buffered logging size (idempotence) - register: result - cisco.iosxr.iosxr_logging: *id005 -- ansible.builtin.assert: *id003 -- name: Remove buffered logging size - register: result - cisco.iosxr.iosxr_logging: - dest: buffered - size: 4800000 - state: absent - -- ansible.builtin.assert: *id006 -- name: Change logging parameters using aggregate - register: result - cisco.iosxr.iosxr_logging: - aggregate: - - dest: console - level: notifications - - - dest: buffered - size: 4700000 - state: present - -- ansible.builtin.assert: - that: - - result.changed == true - - '"logging buffered 4700000" in result.commands' - - '"logging console notifications" in result.commands' - -- name: Remove logging parameters using aggregate - register: result - cisco.iosxr.iosxr_logging: - aggregate: - - dest: console - level: notifications - - - dest: buffered - size: 4700000 - state: absent - -- ansible.builtin.assert: - that: - - result.changed == true - - '"no logging console" in result.commands' - - '"no logging buffered" in result.commands' diff --git a/tests/integration/targets/iosxr_logging/tests/netconf/basic.yaml b/tests/integration/targets/iosxr_logging/tests/netconf/basic.yaml deleted file mode 100644 index 2bd05e511..000000000 --- a/tests/integration/targets/iosxr_logging/tests/netconf/basic.yaml +++ /dev/null @@ -1,208 +0,0 @@ ---- -- name: Remove host logging - cisco.iosxr.iosxr_logging: - dest: host - name: 172.16.0.1 - state: absent - -- name: Remove console logging - register: result - cisco.iosxr.iosxr_logging: - dest: console - level: warning - state: absent - -- name: Remove buffered logging - register: result - cisco.iosxr.iosxr_logging: - dest: buffered - size: 2097155 - state: absent - -- name: Set up syslog host logging - register: result - cisco.iosxr.iosxr_logging: &id001 - dest: host - name: 172.16.0.1 - level: errors - state: present - -- ansible.builtin.assert: - that: - - result.changed == true - - '"172.16.0.1" in result.xml[0]' - -- name: Set up syslog host logging (idempotent) - register: result - cisco.iosxr.iosxr_logging: *id001 -- ansible.builtin.assert: &id003 - that: - - result.changed == false - -- name: Delete/disable syslog host logging - register: result - cisco.iosxr.iosxr_logging: &id002 - dest: host - name: 172.16.0.1 - state: absent - -- ansible.builtin.assert: - that: - - result.changed == true - - '"172.16.0.1" in result.xml[0]' - - '"delete" in result.xml[0]' - -- name: Delete/disable syslog host logging (idempotent) - register: result - cisco.iosxr.iosxr_logging: *id002 -- ansible.builtin.assert: *id003 -- name: Add console logging with level warning - register: result - cisco.iosxr.iosxr_logging: &id004 - dest: console - level: warning - state: present - -- ansible.builtin.assert: - that: - - result.changed == true - - '"console" in result.xml[0]' - - '"warning" in result.xml[0]' - -- name: Console logging with level warning (idempotent) - register: result - cisco.iosxr.iosxr_logging: *id004 -- ansible.builtin.assert: *id003 -- name: Remove console logging with level warning - register: result - cisco.iosxr.iosxr_logging: - dest: console - level: warning - state: absent - -- ansible.builtin.assert: &id006 - that: - - result.changed == true - -- name: Configure buffered logging size - register: result - cisco.iosxr.iosxr_logging: &id005 - dest: buffered - size: 4800000 - state: present - -- ansible.builtin.assert: - that: - - result.changed == true - - '"buffered" in result.xml[0]' - - '"4800000" in result.xml[0]' - -- name: Configure buffered logging size (idempotence) - register: result - cisco.iosxr.iosxr_logging: *id005 -- ansible.builtin.assert: *id003 -- name: Remove buffered logging size - register: result - cisco.iosxr.iosxr_logging: - dest: buffered - size: 4800000 - state: absent - -- ansible.builtin.assert: *id006 -- name: Change logging parameters using aggregate - register: result - cisco.iosxr.iosxr_logging: - aggregate: - - dest: console - level: notifications - - - dest: buffered - size: 4700000 - - - dest: monitor - level: alerts - - - dest: host - name: 10.10.10.1 - level: errors - - - dest: host - name: 10.10.10.2 - - - dest: file - name: file1 - size: 2048 - level: critical - path: /file1 - - - dest: file - name: file2 - size: 2048 - path: /file2 - - - facility: local3 - - - hostnameprefix: host3 - state: present - -- ansible.builtin.assert: - that: - - result.changed == true - - '"file1" in result.xml[0]' - - '"file2" in result.xml[0]' - - '"10.10.10.1" in result.xml[1]' - - '"10.10.10.2" in result.xml[1]' - - '"notice" in result.xml[2]' - - '"alert" in result.xml[3]' - - '"4700000" in result.xml[4]' - - '"debug" in result.xml[4]' - - '"local3" in result.xml[5]' - - '"host3" in result.xml[6]' - -- name: Remove logging parameters using aggregate - register: result - cisco.iosxr.iosxr_logging: - aggregate: - - dest: console - level: notifications - - - dest: buffered - size: 4700000 - - - dest: monitor - level: alerts - - - dest: host - name: 10.10.10.1 - level: errors - - - dest: host - name: 10.10.10.2 - - - dest: file - name: file1 - size: 2048 - level: critical - - - dest: file - name: file2 - size: 2048 - - - facility: local3 - - - hostnameprefix: host3 - state: absent - -- ansible.builtin.assert: - that: - - result.changed == true - - '"file1" in result.xml[0]' - - '"file2" in result.xml[0]' - - '"10.10.10.1" in result.xml[1]' - - '"10.10.10.2" in result.xml[1]' - - '"notice" in result.xml[2]' - - '"alert" in result.xml[3]' - - '"4700000" in result.xml[4]' - - '"debug" in result.xml[4]' - - '"local3" in result.xml[5]' - - '"host3" in result.xml[6]' diff --git a/tests/integration/targets/iosxr_smoke/tests/netconf/common_netconf.yaml b/tests/integration/targets/iosxr_smoke/tests/netconf/common_netconf.yaml index 2ab0957ae..5f08fd677 100644 --- a/tests/integration/targets/iosxr_smoke/tests/netconf/common_netconf.yaml +++ b/tests/integration/targets/iosxr_smoke/tests/netconf/common_netconf.yaml @@ -23,24 +23,4 @@ - "'this is my login banner' in result.xml" - "'that has a multiline' in result.xml" -# hit etree_findall() -- name: Remove host logging - cisco.iosxr.iosxr_logging: - dest: host - name: 172.16.0.1 - state: absent - -- name: Set up syslog host logging - cisco.iosxr.iosxr_logging: - dest: host - name: 172.16.0.1 - level: errors - state: present - register: result - -- ansible.builtin.assert: - that: - - "result.changed == true" - - '"172.16.0.1" in result.xml[0]' - - ansible.builtin.debug: msg="END iosxr netconf/common_netconf.yaml on connection={{ ansible_connection }}" diff --git a/tests/sanity/ignore-2.10.txt b/tests/sanity/ignore-2.10.txt deleted file mode 100644 index c2f1a6018..000000000 --- a/tests/sanity/ignore-2.10.txt +++ /dev/null @@ -1,28 +0,0 @@ -plugins/action/iosxr.py action-plugin-docs # base class for deprecated network platform modules using `connection: local -plugins/module_utils/network/iosxr/config/acl_interfaces/acl_interfaces.py compile-2.6!skip -plugins/module_utils/network/iosxr/config/ospf_interfaces/ospf_interfaces.py compile-2.6!skip -plugins/module_utils/network/iosxr/config/ospfv2/ospfv2.py compile-2.6!skip -plugins/module_utils/network/iosxr/config/ospfv3/ospfv3.py compile-2.6!skip -plugins/module_utils/network/iosxr/config/bgp_address_family/bgp_address_family.py compile-2.6!skip -plugins/module_utils/network/iosxr/config/bgp_global/bgp_global.py compile-2.6!skip -plugins/module_utils/network/iosxr/config/prefix_lists/prefix_lists.py compile-2.6!skip -plugins/module_utils/network/iosxr/config/bgp_neighbor_address_family/bgp_neighbor_address_family.py compile-2.6!skip -plugins/module_utils/network/iosxr/config/logging_global/logging_global.py compile-2.6!skip -plugins/module_utils/network/iosxr/config/acl_interfaces/acl_interfaces.py import-2.6!skip -plugins/module_utils/network/iosxr/config/ospf_interfaces/ospf_interfaces.py import-2.6!skip -plugins/module_utils/network/iosxr/config/ospfv2/ospfv2.py import-2.6!skip -plugins/module_utils/network/iosxr/config/ospfv3/ospfv3.py import-2.6!skip -plugins/module_utils/network/iosxr/config/bgp_address_family/bgp_address_family.py import-2.6!skip -plugins/module_utils/network/iosxr/config/bgp_neighbor_address_family/bgp_neighbor_address_family.py import-2.6!skip -plugins/module_utils/network/iosxr/config/bgp_global/bgp_global.py import-2.6!skip -plugins/module_utils/network/iosxr/config/prefix_lists/prefix_lists.py import-2.6!skip -plugins/module_utils/network/iosxr/config/logging_global/logging_global.py import-2.6!skip -plugins/modules/iosxr_acl_interfaces.py import-2.6!skip -plugins/modules/iosxr_ospf_interfaces.py import-2.6!skip -plugins/modules/iosxr_ospfv2.py import-2.6!skip -plugins/modules/iosxr_ospfv3.py import-2.6!skip -plugins/modules/iosxr_bgp_neighbor_address_family.py import-2.6!skip -plugins/modules/iosxr_bgp_address_family.py import-2.6!skip -plugins/modules/iosxr_bgp_global.py import-2.6!skip -plugins/modules/iosxr_prefix_lists.py import-2.6!skip -plugins/modules/iosxr_logging_global.py import-2.6!skip diff --git a/tests/sanity/ignore-2.11.txt b/tests/sanity/ignore-2.11.txt deleted file mode 100644 index b492817fc..000000000 --- a/tests/sanity/ignore-2.11.txt +++ /dev/null @@ -1,31 +0,0 @@ -plugins/action/iosxr.py action-plugin-docs # base class for deprecated network platform modules using `connection: local -plugins/module_utils/network/iosxr/config/acl_interfaces/acl_interfaces.py compile-2.6!skip -plugins/module_utils/network/iosxr/config/ospf_interfaces/ospf_interfaces.py compile-2.6!skip -plugins/module_utils/network/iosxr/config/ospfv2/ospfv2.py compile-2.6!skip -plugins/module_utils/network/iosxr/config/ospfv3/ospfv3.py compile-2.6!skip -plugins/module_utils/network/iosxr/config/bgp_address_family/bgp_address_family.py compile-2.6!skip -plugins/module_utils/network/iosxr/config/bgp_global/bgp_global.py compile-2.6!skip -plugins/module_utils/network/iosxr/config/prefix_lists/prefix_lists.py compile-2.6!skip -plugins/module_utils/network/iosxr/config/bgp_neighbor_address_family/bgp_neighbor_address_family.py compile-2.6!skip -plugins/module_utils/network/iosxr/config/logging_global/logging_global.py compile-2.6!skip -plugins/module_utils/network/iosxr/config/acl_interfaces/acl_interfaces.py import-2.6!skip -plugins/module_utils/network/iosxr/config/ospf_interfaces/ospf_interfaces.py import-2.6!skip -plugins/module_utils/network/iosxr/config/ospfv2/ospfv2.py import-2.6!skip -plugins/module_utils/network/iosxr/config/ospfv3/ospfv3.py import-2.6!skip -plugins/module_utils/network/iosxr/config/bgp_address_family/bgp_address_family.py import-2.6!skip -plugins/module_utils/network/iosxr/config/bgp_neighbor_address_family/bgp_neighbor_address_family.py import-2.6!skip -plugins/module_utils/network/iosxr/config/bgp_global/bgp_global.py import-2.6!skip -plugins/module_utils/network/iosxr/config/prefix_lists/prefix_lists.py import-2.6!skip -plugins/module_utils/network/iosxr/config/logging_global/logging_global.py import-2.6!skip -plugins/modules/iosxr_acl_interfaces.py import-2.6!skip -plugins/modules/iosxr_ospf_interfaces.py import-2.6!skip -plugins/modules/iosxr_ospfv2.py import-2.6!skip -plugins/modules/iosxr_ospfv3.py import-2.6!skip -plugins/modules/iosxr_bgp_neighbor_address_family.py import-2.6!skip -plugins/modules/iosxr_bgp_address_family.py import-2.6!skip -plugins/modules/iosxr_bgp_global.py import-2.6!skip -plugins/modules/iosxr_prefix_lists.py import-2.6!skip -plugins/modules/iosxr_logging_global.py import-2.6!skip -plugins/sub_plugins/grpc/pb/ems_grpc_pb2.py import-3.7!skip -plugins/sub_plugins/grpc/pb/ems_grpc_pb2.py import-3.8!skip -plugins/sub_plugins/grpc/pb/ems_grpc_pb2.py import-3.9!skip diff --git a/tests/sanity/ignore-2.12.txt b/tests/sanity/ignore-2.12.txt deleted file mode 100644 index 14952a817..000000000 --- a/tests/sanity/ignore-2.12.txt +++ /dev/null @@ -1,31 +0,0 @@ -plugins/action/iosxr.py action-plugin-docs # base class for deprecated network platform modules using `connection: local -plugins/module_utils/network/iosxr/config/acl_interfaces/acl_interfaces.py compile-2.6!skip -plugins/module_utils/network/iosxr/config/ospf_interfaces/ospf_interfaces.py compile-2.6!skip -plugins/module_utils/network/iosxr/config/ospfv2/ospfv2.py compile-2.6!skip -plugins/module_utils/network/iosxr/config/ospfv3/ospfv3.py compile-2.6!skip -plugins/module_utils/network/iosxr/config/bgp_address_family/bgp_address_family.py compile-2.6!skip -plugins/module_utils/network/iosxr/config/bgp_global/bgp_global.py compile-2.6!skip -plugins/module_utils/network/iosxr/config/prefix_lists/prefix_lists.py compile-2.6!skip -plugins/module_utils/network/iosxr/config/bgp_neighbor_address_family/bgp_neighbor_address_family.py compile-2.6!skip -plugins/module_utils/network/iosxr/config/logging_global/logging_global.py compile-2.6!skip -plugins/module_utils/network/iosxr/config/acl_interfaces/acl_interfaces.py import-2.6!skip -plugins/module_utils/network/iosxr/config/ospf_interfaces/ospf_interfaces.py import-2.6!skip -plugins/module_utils/network/iosxr/config/ospfv2/ospfv2.py import-2.6!skip -plugins/module_utils/network/iosxr/config/ospfv3/ospfv3.py import-2.6!skip -plugins/module_utils/network/iosxr/config/bgp_address_family/bgp_address_family.py import-2.6!skip -plugins/module_utils/network/iosxr/config/bgp_neighbor_address_family/bgp_neighbor_address_family.py import-2.6!skip -plugins/module_utils/network/iosxr/config/bgp_global/bgp_global.py import-2.6!skip -plugins/module_utils/network/iosxr/config/prefix_lists/prefix_lists.py import-2.6!skip -plugins/module_utils/network/iosxr/config/logging_global/logging_global.py import-2.6!skip -plugins/modules/iosxr_acl_interfaces.py import-2.6!skip -plugins/modules/iosxr_ospf_interfaces.py import-2.6!skip -plugins/modules/iosxr_ospfv2.py import-2.6!skip -plugins/modules/iosxr_ospfv3.py import-2.6!skip -plugins/modules/iosxr_bgp_neighbor_address_family.py import-2.6!skip -plugins/modules/iosxr_bgp_address_family.py import-2.6!skip -plugins/modules/iosxr_bgp_global.py import-2.6!skip -plugins/modules/iosxr_prefix_lists.py import-2.6!skip -plugins/modules/iosxr_logging_global.py import-2.6!skip -plugins/sub_plugins/grpc/pb/ems_grpc_pb2.py import-3.8!skip -plugins/sub_plugins/grpc/pb/ems_grpc_pb2.py import-3.9!skip -plugins/sub_plugins/grpc/pb/ems_grpc_pb2.py import-3.10!skip diff --git a/tests/sanity/ignore-2.13.txt b/tests/sanity/ignore-2.13.txt deleted file mode 100644 index 5d99b9b08..000000000 --- a/tests/sanity/ignore-2.13.txt +++ /dev/null @@ -1,4 +0,0 @@ -plugins/action/iosxr.py action-plugin-docs # base class for deprecated network platform modules using `connection: local -plugins/sub_plugins/grpc/pb/ems_grpc_pb2.py import-3.8!skip -plugins/sub_plugins/grpc/pb/ems_grpc_pb2.py import-3.9!skip -plugins/sub_plugins/grpc/pb/ems_grpc_pb2.py import-3.10!skip diff --git a/tests/sanity/ignore-2.14.txt b/tests/sanity/ignore-2.14.txt index 63b93ff5a..1e8023a57 100644 --- a/tests/sanity/ignore-2.14.txt +++ b/tests/sanity/ignore-2.14.txt @@ -1,4 +1,4 @@ -plugins/action/iosxr.py action-plugin-docs # base class for deprecated network platform modules using `connection: local +plugins/action/iosxr.py action-plugin-docs # base class for deprecated network platform modules using `connection: local` plugins/sub_plugins/grpc/pb/ems_grpc_pb2.py import-3.9!skip plugins/sub_plugins/grpc/pb/ems_grpc_pb2.py import-3.10!skip plugins/sub_plugins/grpc/pb/ems_grpc_pb2.py import-3.11!skip diff --git a/tests/sanity/ignore-2.15.txt b/tests/sanity/ignore-2.15.txt index 63b93ff5a..1e8023a57 100644 --- a/tests/sanity/ignore-2.15.txt +++ b/tests/sanity/ignore-2.15.txt @@ -1,4 +1,4 @@ -plugins/action/iosxr.py action-plugin-docs # base class for deprecated network platform modules using `connection: local +plugins/action/iosxr.py action-plugin-docs # base class for deprecated network platform modules using `connection: local` plugins/sub_plugins/grpc/pb/ems_grpc_pb2.py import-3.9!skip plugins/sub_plugins/grpc/pb/ems_grpc_pb2.py import-3.10!skip plugins/sub_plugins/grpc/pb/ems_grpc_pb2.py import-3.11!skip diff --git a/tests/sanity/ignore-2.16.txt b/tests/sanity/ignore-2.16.txt index 04e4d941a..6d49e3dcb 100644 --- a/tests/sanity/ignore-2.16.txt +++ b/tests/sanity/ignore-2.16.txt @@ -1,3 +1,4 @@ -plugins/action/iosxr.py action-plugin-docs # base class for deprecated network platform modules using `connection: local +plugins/action/iosxr.py action-plugin-docs # base class for deprecated network platform modules using `connection: local` plugins/sub_plugins/grpc/pb/ems_grpc_pb2.py import-3.10!skip plugins/sub_plugins/grpc/pb/ems_grpc_pb2.py import-3.11!skip +plugins/sub_plugins/grpc/pb/ems_grpc_pb2.py import-3.12!skip diff --git a/tests/sanity/ignore-2.17.txt b/tests/sanity/ignore-2.17.txt index 04e4d941a..6d49e3dcb 100644 --- a/tests/sanity/ignore-2.17.txt +++ b/tests/sanity/ignore-2.17.txt @@ -1,3 +1,4 @@ -plugins/action/iosxr.py action-plugin-docs # base class for deprecated network platform modules using `connection: local +plugins/action/iosxr.py action-plugin-docs # base class for deprecated network platform modules using `connection: local` plugins/sub_plugins/grpc/pb/ems_grpc_pb2.py import-3.10!skip plugins/sub_plugins/grpc/pb/ems_grpc_pb2.py import-3.11!skip +plugins/sub_plugins/grpc/pb/ems_grpc_pb2.py import-3.12!skip diff --git a/tests/sanity/ignore-2.18.txt b/tests/sanity/ignore-2.18.txt new file mode 100644 index 000000000..6d49e3dcb --- /dev/null +++ b/tests/sanity/ignore-2.18.txt @@ -0,0 +1,4 @@ +plugins/action/iosxr.py action-plugin-docs # base class for deprecated network platform modules using `connection: local` +plugins/sub_plugins/grpc/pb/ems_grpc_pb2.py import-3.10!skip +plugins/sub_plugins/grpc/pb/ems_grpc_pb2.py import-3.11!skip +plugins/sub_plugins/grpc/pb/ems_grpc_pb2.py import-3.12!skip diff --git a/tests/sanity/ignore-2.9.txt b/tests/sanity/ignore-2.9.txt deleted file mode 100644 index aab3e8dfc..000000000 --- a/tests/sanity/ignore-2.9.txt +++ /dev/null @@ -1,30 +0,0 @@ -plugins/action/iosxr.py action-plugin-docs # base class for deprecated network platform modules using `connection: local -plugins/modules/iosxr_logging.py validate-modules:deprecation-mismatch # 2.9 expects METADATA -plugins/modules/iosxr_logging.py validate-modules:invalid-documentation # removed_at_date not supported in `deprecated` dict -plugins/module_utils/network/iosxr/config/acl_interfaces/acl_interfaces.py compile-2.6!skip -plugins/module_utils/network/iosxr/config/ospf_interfaces/ospf_interfaces.py compile-2.6!skip -plugins/module_utils/network/iosxr/config/ospfv2/ospfv2.py compile-2.6!skip -plugins/module_utils/network/iosxr/config/ospfv3/ospfv3.py compile-2.6!skip -plugins/module_utils/network/iosxr/config/bgp_address_family/bgp_address_family.py compile-2.6!skip -plugins/module_utils/network/iosxr/config/bgp_neighbor_address_family/bgp_neighbor_address_family.py compile-2.6!skip -plugins/module_utils/network/iosxr/config/bgp_global/bgp_global.py compile-2.6!skip -plugins/module_utils/network/iosxr/config/prefix_lists/prefix_lists.py compile-2.6!skip -plugins/module_utils/network/iosxr/config/logging_global/logging_global.py compile-2.6!skip -plugins/module_utils/network/iosxr/config/acl_interfaces/acl_interfaces.py import-2.6!skip -plugins/module_utils/network/iosxr/config/ospf_interfaces/ospf_interfaces.py import-2.6!skip -plugins/module_utils/network/iosxr/config/ospfv2/ospfv2.py import-2.6!skip -plugins/module_utils/network/iosxr/config/ospfv3/ospfv3.py import-2.6!skip -plugins/module_utils/network/iosxr/config/bgp_address_family/bgp_address_family.py import-2.6!skip -plugins/module_utils/network/iosxr/config/bgp_neighbor_address_family/bgp_neighbor_address_family.py import-2.6!skip -plugins/module_utils/network/iosxr/config/bgp_global/bgp_global.py import-2.6!skip -plugins/module_utils/network/iosxr/config/prefix_lists/prefix_lists.py import-2.6!skip -plugins/module_utils/network/iosxr/config/logging_global/logging_global.py import-2.6!skip -plugins/modules/iosxr_acl_interfaces.py import-2.6!skip -plugins/modules/iosxr_ospf_interfaces.py import-2.6!skip -plugins/modules/iosxr_ospfv2.py import-2.6!skip -plugins/modules/iosxr_ospfv3.py import-2.6!skip -plugins/modules/iosxr_bgp_neighbor_address_family.py import-2.6!skip -plugins/modules/iosxr_bgp_address_family.py import-2.6!skip -plugins/modules/iosxr_bgp_global.py import-2.6!skip -plugins/modules/iosxr_prefix_lists.py import-2.6!skip -plugins/modules/iosxr_logging_global.py import-2.6!skip diff --git a/tests/unit/compat/mock.py b/tests/unit/compat/mock.py deleted file mode 100644 index e4ce72b34..000000000 --- a/tests/unit/compat/mock.py +++ /dev/null @@ -1,129 +0,0 @@ -# (c) 2014, Toshio Kuratomi -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see . - -# Make coding more python3-ish -from __future__ import absolute_import, division, print_function - - -__metaclass__ = type - -""" -Compat module for Python3.x's unittest.mock module -""" -import sys - -import _io - - -# Python 2.7 - -# Note: Could use the pypi mock library on python3.x as well as python2.x. It -# is the same as the python3 stdlib mock library - -try: - # Allow wildcard import because we really do want to import all of mock's - # symbols into this compat shim - # pylint: disable=wildcard-import,unused-wildcard-import - from unittest.mock import * -except ImportError: - # Python 2 - # pylint: disable=wildcard-import,unused-wildcard-import - try: - from mock import * - except ImportError: - print("You need the mock library installed on python2.x to run tests") - - -# Prior to 3.4.4, mock_open cannot handle binary read_data -if sys.version_info >= (3,) and sys.version_info < (3, 4, 4): - file_spec = None - - def _iterate_read_data(read_data): - # Helper for mock_open: - # Retrieve lines from read_data via a generator so that separate calls to - # readline, read, and readlines are properly interleaved - sep = b"\n" if isinstance(read_data, bytes) else "\n" - data_as_list = [l + sep for l in read_data.split(sep)] - - if data_as_list[-1] == sep: - # If the last line ended in a newline, the list comprehension will have an - # extra entry that's just a newline. Remove this. - data_as_list = data_as_list[:-1] - else: - # If there wasn't an extra newline by itself, then the file being - # emulated doesn't have a newline to end the last line remove the - # newline that our naive format() added - data_as_list[-1] = data_as_list[-1][:-1] - - for line in data_as_list: - yield line - - def mock_open(mock=None, read_data=""): - """ - A helper function to create a mock to replace the use of `open`. It works - for `open` called directly or used as a context manager. - - The `mock` argument is the mock object to configure. If `None` (the - default) then a `MagicMock` will be created for you, with the API limited - to methods or attributes available on standard file handles. - - `read_data` is a string for the `read` methoddline`, and `readlines` of the - file handle to return. This is an empty string by default. - """ - - def _readlines_side_effect(*args, **kwargs): - if handle.readlines.return_value is not None: - return handle.readlines.return_value - return list(_data) - - def _read_side_effect(*args, **kwargs): - if handle.read.return_value is not None: - return handle.read.return_value - return type(read_data)().join(_data) - - def _readline_side_effect(): - if handle.readline.return_value is not None: - while True: - yield handle.readline.return_value - for line in _data: - yield line - - global file_spec - if file_spec is None: - file_spec = list( - set(dir(_io.TextIOWrapper)).union(set(dir(_io.BytesIO))), - ) - - if mock is None: - mock = MagicMock(name="open", spec=open) - - handle = MagicMock(spec=file_spec) - handle.__enter__.return_value = handle - - _data = _iterate_read_data(read_data) - - handle.write.return_value = None - handle.read.return_value = None - handle.readline.return_value = None - handle.readlines.return_value = None - - handle.read.side_effect = _read_side_effect - handle.readline.side_effect = _readline_side_effect() - handle.readlines.side_effect = _readlines_side_effect - - mock.return_value = handle - return mock diff --git a/tests/unit/compat/unittest.py b/tests/unit/compat/unittest.py deleted file mode 100644 index df4266ec9..000000000 --- a/tests/unit/compat/unittest.py +++ /dev/null @@ -1,41 +0,0 @@ -# (c) 2014, Toshio Kuratomi -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see . - -# Make coding more python3-ish -from __future__ import absolute_import, division, print_function - - -__metaclass__ = type - -""" -Compat module for Python2.7's unittest module -""" - -import sys - - -# Allow wildcard import because we really do want to import all of -# unittests's symbols into this compat shim -# pylint: disable=wildcard-import,unused-wildcard-import -if sys.version_info < (2, 7): - try: - # Need unittest2 on python2.6 - from unittest2 import * - except ImportError: - print("You need unittest2 installed on python2.6.x to run tests") -else: - from unittest import * diff --git a/tests/unit/mock/path.py b/tests/unit/mock/path.py index 0c87896da..7d287a5fb 100644 --- a/tests/unit/mock/path.py +++ b/tests/unit/mock/path.py @@ -2,9 +2,9 @@ __metaclass__ = type -from ansible.utils.path import unfrackpath +from unittest.mock import MagicMock -from ansible_collections.cisco.iosxr.tests.unit.compat.mock import MagicMock +from ansible.utils.path import unfrackpath mock_unfrackpath_noop = MagicMock( diff --git a/tests/unit/modules/network/iosxr/fixtures/iosxr_interface_gathered.cfg b/tests/unit/modules/network/iosxr/fixtures/iosxr_interface_gathered.cfg new file mode 100644 index 000000000..f05a6eb71 --- /dev/null +++ b/tests/unit/modules/network/iosxr/fixtures/iosxr_interface_gathered.cfg @@ -0,0 +1,11 @@ + +interface GigabitEthernet0/0/0/5 + description RTI-DSKMPLS-LP201 #G0/0 + mtu 9216 + ipv4 address 10.255.2.9 255.255.255.252 +! +interface GigabitEthernet0/0/0/6 + description RTI-DSKMPLS-LP301 #G0/1 + mtu 9216 + ipv4 address 10.255.2.17 255.255.255.252 +! diff --git a/tests/unit/modules/network/iosxr/fixtures/show_cdp b/tests/unit/modules/network/iosxr/fixtures/show_cdp new file mode 100644 index 000000000..cd5d89cee --- /dev/null +++ b/tests/unit/modules/network/iosxr/fixtures/show_cdp @@ -0,0 +1,4 @@ +Global CDP information: + Sending CDP packets every 60 seconds + Sending a holdtime value of 30 seconds + Sending CDPv2 advertisements is not enabled diff --git a/tests/unit/modules/network/iosxr/fixtures/show_cdp_neighbors_detail b/tests/unit/modules/network/iosxr/fixtures/show_cdp_neighbors_detail new file mode 100644 index 000000000..f1ab85923 --- /dev/null +++ b/tests/unit/modules/network/iosxr/fixtures/show_cdp_neighbors_detail @@ -0,0 +1,16 @@ +------------------------- +Device ID: device2.cisco.com +Entry address(es): + IP address: 171.68.162.134 +Platform: cisco 4500, Capabilities: Router +Interface: Ethernet0/1, Port ID (outgoing port): Ethernet0 +Holdtime : 156 sec + +Version : +Cisco Internetwork Operating System Software +IOS (tm) 4500 Software (C4500-J-M), Version 11.1(10.4), MAINTENANCE INTERIM SOFTWARE +Copyright (c) 1986-1997 by Cisco Systems, Inc. +Compiled Mon 07-Apr-97 19:51 by dschwart + + +Total cdp entries displayed : 1 diff --git a/tests/unit/modules/network/iosxr/test_hostname.py b/tests/unit/modules/network/iosxr/test_hostname.py index 7c676530b..9eda36615 100644 --- a/tests/unit/modules/network/iosxr/test_hostname.py +++ b/tests/unit/modules/network/iosxr/test_hostname.py @@ -23,9 +23,9 @@ __metaclass__ = type from textwrap import dedent +from unittest.mock import patch from ansible_collections.cisco.iosxr.plugins.modules import iosxr_hostname -from ansible_collections.cisco.iosxr.tests.unit.compat.mock import patch from ansible_collections.cisco.iosxr.tests.unit.modules.utils import set_module_args from .iosxr_module import TestIosxrModule diff --git a/tests/unit/modules/network/iosxr/test_iosxr.py b/tests/unit/modules/network/iosxr/test_iosxr.py index af2fd3a5c..32eb85797 100644 --- a/tests/unit/modules/network/iosxr/test_iosxr.py +++ b/tests/unit/modules/network/iosxr/test_iosxr.py @@ -22,15 +22,15 @@ __metaclass__ = type from os import path +from unittest import TestCase from ansible.module_utils._text import to_bytes, to_text from mock import MagicMock from ansible_collections.cisco.iosxr.plugins.cliconf import iosxr -from ansible_collections.cisco.iosxr.tests.unit.compat import unittest -class TestPluginCLIConfIOSXR(unittest.TestCase): +class TestPluginCLIConfIOSXR(TestCase): """Test class for IOSXR CLI Conf Methods""" def setUp(self): diff --git a/tests/unit/modules/network/iosxr/test_iosxr_acl_interfaces.py b/tests/unit/modules/network/iosxr/test_iosxr_acl_interfaces.py index 8500c0733..0c29c6c13 100644 --- a/tests/unit/modules/network/iosxr/test_iosxr_acl_interfaces.py +++ b/tests/unit/modules/network/iosxr/test_iosxr_acl_interfaces.py @@ -22,8 +22,9 @@ __metaclass__ = type +from unittest.mock import patch + from ansible_collections.cisco.iosxr.plugins.modules import iosxr_acl_interfaces -from ansible_collections.cisco.iosxr.tests.unit.compat.mock import patch from ansible_collections.cisco.iosxr.tests.unit.modules.utils import set_module_args from .iosxr_module import TestIosxrModule, load_fixture diff --git a/tests/unit/modules/network/iosxr/test_iosxr_acls.py b/tests/unit/modules/network/iosxr/test_iosxr_acls.py index 181b239d8..d301bda7b 100644 --- a/tests/unit/modules/network/iosxr/test_iosxr_acls.py +++ b/tests/unit/modules/network/iosxr/test_iosxr_acls.py @@ -8,8 +8,9 @@ __metaclass__ = type +from unittest.mock import patch + from ansible_collections.cisco.iosxr.plugins.modules import iosxr_acls -from ansible_collections.cisco.iosxr.tests.unit.compat.mock import patch from ansible_collections.cisco.iosxr.tests.unit.modules.utils import set_module_args from .iosxr_module import TestIosxrModule, load_fixture diff --git a/tests/unit/modules/network/iosxr/test_iosxr_banner.py b/tests/unit/modules/network/iosxr/test_iosxr_banner.py index 5dcbada13..32085d51e 100644 --- a/tests/unit/modules/network/iosxr/test_iosxr_banner.py +++ b/tests/unit/modules/network/iosxr/test_iosxr_banner.py @@ -38,9 +38,9 @@ __metaclass__ = type +from unittest.mock import patch from ansible_collections.cisco.iosxr.plugins.modules import iosxr_banner -from ansible_collections.cisco.iosxr.tests.unit.compat.mock import patch from ansible_collections.cisco.iosxr.tests.unit.modules.utils import set_module_args from .iosxr_module import TestIosxrModule, load_fixture diff --git a/tests/unit/modules/network/iosxr/test_iosxr_bgp_address_family.py b/tests/unit/modules/network/iosxr/test_iosxr_bgp_address_family.py index 57770b59d..ce8d12c95 100644 --- a/tests/unit/modules/network/iosxr/test_iosxr_bgp_address_family.py +++ b/tests/unit/modules/network/iosxr/test_iosxr_bgp_address_family.py @@ -23,9 +23,9 @@ __metaclass__ = type from textwrap import dedent +from unittest.mock import patch from ansible_collections.cisco.iosxr.plugins.modules import iosxr_bgp_address_family -from ansible_collections.cisco.iosxr.tests.unit.compat.mock import patch from ansible_collections.cisco.iosxr.tests.unit.modules.utils import set_module_args from .iosxr_module import TestIosxrModule diff --git a/tests/unit/modules/network/iosxr/test_iosxr_bgp_global.py b/tests/unit/modules/network/iosxr/test_iosxr_bgp_global.py index 901b5b4d8..6527fb48d 100644 --- a/tests/unit/modules/network/iosxr/test_iosxr_bgp_global.py +++ b/tests/unit/modules/network/iosxr/test_iosxr_bgp_global.py @@ -23,9 +23,9 @@ __metaclass__ = type from textwrap import dedent +from unittest.mock import patch from ansible_collections.cisco.iosxr.plugins.modules import iosxr_bgp_global -from ansible_collections.cisco.iosxr.tests.unit.compat.mock import patch from ansible_collections.cisco.iosxr.tests.unit.modules.utils import set_module_args from .iosxr_module import TestIosxrModule diff --git a/tests/unit/modules/network/iosxr/test_iosxr_bgp_neighbor_address_family.py b/tests/unit/modules/network/iosxr/test_iosxr_bgp_neighbor_address_family.py index d6fd0610d..6714adee8 100644 --- a/tests/unit/modules/network/iosxr/test_iosxr_bgp_neighbor_address_family.py +++ b/tests/unit/modules/network/iosxr/test_iosxr_bgp_neighbor_address_family.py @@ -23,9 +23,9 @@ __metaclass__ = type from textwrap import dedent +from unittest.mock import patch from ansible_collections.cisco.iosxr.plugins.modules import iosxr_bgp_neighbor_address_family -from ansible_collections.cisco.iosxr.tests.unit.compat.mock import patch from ansible_collections.cisco.iosxr.tests.unit.modules.utils import set_module_args from .iosxr_module import TestIosxrModule diff --git a/tests/unit/modules/network/iosxr/test_iosxr_bgp_templates.py b/tests/unit/modules/network/iosxr/test_iosxr_bgp_templates.py index 4efc04503..58cec9977 100644 --- a/tests/unit/modules/network/iosxr/test_iosxr_bgp_templates.py +++ b/tests/unit/modules/network/iosxr/test_iosxr_bgp_templates.py @@ -23,9 +23,9 @@ __metaclass__ = type from textwrap import dedent +from unittest.mock import patch from ansible_collections.cisco.iosxr.plugins.modules import iosxr_bgp_templates -from ansible_collections.cisco.iosxr.tests.unit.compat.mock import patch from ansible_collections.cisco.iosxr.tests.unit.modules.utils import set_module_args from .iosxr_module import TestIosxrModule @@ -239,6 +239,22 @@ def test_iosxr_bgp_tmpl_merged(self): safi="unicast", advertise=dict(local_labeled_route=dict(set=True)), ), + dict( + afi="vpnv4", + safi="unicast", + ), + dict( + afi="vpnv6", + safi="unicast", + ), + dict( + afi="link-state", + safi="link-state", + ), + dict( + afi="l2vpn", + safi="evpn", + ), ], ), dict( @@ -324,6 +340,10 @@ def test_iosxr_bgp_tmpl_merged(self): "bfd fast-detect strict-mode", "internal-vpn-client", "precedence critical", + "address-family vpnv4 unicast", + "address-family vpnv6 unicast", + "address-family link-state link-state", + "address-family l2vpn evpn", "address-family ipv4 unicast", "advertise local-labeled-route", "neighbor-group test1", @@ -1128,6 +1148,14 @@ def test_iosxr_bgp_tmpl_gathered(self): precedence critical advertisement-interval 10 internal-vpn-client + address-family vpnv4 unicast + ! + address-family vpnv6 unicast + ! + address-family link-state link-state + ! + address-family l2vpn evpn + ! address-family ipv4 unicast advertise local-labeled-route ! @@ -1199,6 +1227,10 @@ def test_iosxr_bgp_tmpl_gathered(self): "advertisement_interval": 10, "internal_vpn_client": True, "address_family": [ + {"afi": "vpnv4", "safi": "unicast"}, + {"afi": "vpnv6", "safi": "unicast"}, + {"afi": "link-state", "safi": "link-state"}, + {"afi": "l2vpn", "safi": "evpn"}, { "afi": "ipv4", "safi": "unicast", diff --git a/tests/unit/modules/network/iosxr/test_iosxr_command.py b/tests/unit/modules/network/iosxr/test_iosxr_command.py index cd691d6c4..b3787e600 100644 --- a/tests/unit/modules/network/iosxr/test_iosxr_command.py +++ b/tests/unit/modules/network/iosxr/test_iosxr_command.py @@ -21,8 +21,9 @@ __metaclass__ = type +from unittest.mock import patch + from ansible_collections.cisco.iosxr.plugins.modules import iosxr_command -from ansible_collections.cisco.iosxr.tests.unit.compat.mock import patch from ansible_collections.cisco.iosxr.tests.unit.modules.utils import set_module_args from .iosxr_module import TestIosxrModule, load_fixture diff --git a/tests/unit/modules/network/iosxr/test_iosxr_config.py b/tests/unit/modules/network/iosxr/test_iosxr_config.py index 9ac6866af..dffd4b4c9 100644 --- a/tests/unit/modules/network/iosxr/test_iosxr_config.py +++ b/tests/unit/modules/network/iosxr/test_iosxr_config.py @@ -21,10 +21,10 @@ __metaclass__ = type +from unittest.mock import MagicMock, patch from ansible_collections.cisco.iosxr.plugins.cliconf.iosxr import Cliconf from ansible_collections.cisco.iosxr.plugins.modules import iosxr_config -from ansible_collections.cisco.iosxr.tests.unit.compat.mock import MagicMock, patch from ansible_collections.cisco.iosxr.tests.unit.modules.utils import set_module_args from .iosxr_module import TestIosxrModule, load_fixture diff --git a/tests/unit/modules/network/iosxr/test_iosxr_facts.py b/tests/unit/modules/network/iosxr/test_iosxr_facts.py index da7d597ae..6c0e02e0f 100644 --- a/tests/unit/modules/network/iosxr/test_iosxr_facts.py +++ b/tests/unit/modules/network/iosxr/test_iosxr_facts.py @@ -23,8 +23,9 @@ import json +from unittest.mock import patch + from ansible_collections.cisco.iosxr.plugins.modules import iosxr_facts -from ansible_collections.cisco.iosxr.tests.unit.compat.mock import patch from ansible_collections.cisco.iosxr.tests.unit.modules.utils import set_module_args from .iosxr_module import TestIosxrModule, load_fixture @@ -131,3 +132,19 @@ def test_iosxr_facts_cpu_utilization(self): ansible_facts["ansible_net_cpu_utilization"], cpu_utilization_data, ) + + def test_iosxr_facts_neighbors(self): + set_module_args(dict(gather_subset="interfaces")) + result = self.execute_module() + ansible_facts = result["ansible_facts"]["ansible_net_neighbors"] + expected_neighbors = { + "Ethernet0/1": [ + { + "host": "device2.cisco.com", + "platform": "cisco 4500", + "port": "Ethernet0", + "ip": "171.68.162.134", + }, + ], + } + self.assertCountEqual(ansible_facts.keys(), expected_neighbors.keys()) diff --git a/tests/unit/modules/network/iosxr/test_iosxr_interfaces.py b/tests/unit/modules/network/iosxr/test_iosxr_interfaces.py index 901ff40cd..15a8de4e5 100644 --- a/tests/unit/modules/network/iosxr/test_iosxr_interfaces.py +++ b/tests/unit/modules/network/iosxr/test_iosxr_interfaces.py @@ -22,8 +22,9 @@ __metaclass__ = type +from unittest.mock import patch + from ansible_collections.cisco.iosxr.plugins.modules import iosxr_interfaces -from ansible_collections.cisco.iosxr.tests.unit.compat.mock import patch from ansible_collections.cisco.iosxr.tests.unit.modules.utils import set_module_args from .iosxr_module import TestIosxrModule, load_fixture @@ -68,14 +69,14 @@ def tearDown(self): self.mock_load_config.stop() self.mock_execute_show_command.stop() - def _prepare(self): + def _prepare(self, interface_conf): def load_from_file(*args, **kwargs): - return load_fixture("iosxr_interface_config.cfg") + return load_fixture(interface_conf) self.execute_show_command.side_effect = load_from_file def test_iosxr_interfaces_merged_idempotent(self): - self._prepare() + self._prepare("iosxr_interface_config.cfg") set_module_args( dict( config=[ @@ -138,7 +139,7 @@ def test_iosxr_interfaces_merged(self): self.assertEqual(sorted(result["commands"]), sorted(commands)) def test_iosxr_interfaces_replaced(self): - self._prepare() + self._prepare("iosxr_interface_config.cfg") set_module_args( dict( config=[ @@ -168,7 +169,7 @@ def test_iosxr_interfaces_replaced(self): self.assertEqual(sorted(result["commands"]), sorted(commands)) def test_iosxr_interfaces_deleted(self): - self._prepare() + self._prepare("iosxr_interface_config.cfg") set_module_args(dict(state="deleted")) commands = [ @@ -268,7 +269,7 @@ def test_iosxr_interfaces_parsed(self): def test_iosxr_interfaces_overridden(self): self.maxDiff = None - self._prepare() + self._prepare("iosxr_interface_config.cfg") set_module_args( dict( config=[ @@ -298,3 +299,23 @@ def test_iosxr_interfaces_overridden(self): result = self.execute_module(changed=True) self.assertEqual(sorted(result["commands"]), sorted(commands)) + + def test_iosxr_interfaces_gathered(self): + self._prepare("iosxr_interface_gathered.cfg") + set_module_args(dict(state="gathered")) + result = self.execute_module(changed=False) + gathered = [ + { + "name": "GigabitEthernet0/0/0/5", + "description": "RTI-DSKMPLS-LP201 #G0/0", + "enabled": True, + "mtu": 9216, + }, + { + "name": "GigabitEthernet0/0/0/6", + "description": "RTI-DSKMPLS-LP301 #G0/1", + "enabled": True, + "mtu": 9216, + }, + ] + self.assertEqual(gathered, result["gathered"]) diff --git a/tests/unit/modules/network/iosxr/test_iosxr_l2_interfaces.py b/tests/unit/modules/network/iosxr/test_iosxr_l2_interfaces.py index f28561777..9bef80c39 100644 --- a/tests/unit/modules/network/iosxr/test_iosxr_l2_interfaces.py +++ b/tests/unit/modules/network/iosxr/test_iosxr_l2_interfaces.py @@ -22,8 +22,9 @@ __metaclass__ = type +from unittest.mock import patch + from ansible_collections.cisco.iosxr.plugins.modules import iosxr_l2_interfaces -from ansible_collections.cisco.iosxr.tests.unit.compat.mock import patch from ansible_collections.cisco.iosxr.tests.unit.modules.utils import set_module_args from .iosxr_module import TestIosxrModule, load_fixture diff --git a/tests/unit/modules/network/iosxr/test_iosxr_l3_interfaces.py b/tests/unit/modules/network/iosxr/test_iosxr_l3_interfaces.py index 1bbfa7578..14b5a1e51 100644 --- a/tests/unit/modules/network/iosxr/test_iosxr_l3_interfaces.py +++ b/tests/unit/modules/network/iosxr/test_iosxr_l3_interfaces.py @@ -22,8 +22,9 @@ __metaclass__ = type +from unittest.mock import patch + from ansible_collections.cisco.iosxr.plugins.modules import iosxr_l3_interfaces -from ansible_collections.cisco.iosxr.tests.unit.compat.mock import patch from ansible_collections.cisco.iosxr.tests.unit.modules.utils import set_module_args from .iosxr_module import TestIosxrModule, load_fixture @@ -67,14 +68,14 @@ def tearDown(self): self.mock_load_config.stop() self.mock_execute_show_command.stop() - def _prepare(self): + def _prepare(self, l3_interface_config): def load_from_file(*args, **kwargs): - return load_fixture("iosxr_l3_interface_config.cfg") + return load_fixture(l3_interface_config) self.execute_show_command.side_effect = load_from_file def test_iosxr_l3_interfaces_merged_idempotent(self): - self._prepare() + self._prepare("iosxr_l3_interface_config.cfg") set_module_args( dict( config=[ @@ -128,7 +129,7 @@ def test_iosxr_l3_interfaces_merged(self): self.assertEqual(sorted(result["commands"]), sorted(commands)) def test_iosxr_l3_interfaces_replaced(self): - self._prepare() + self._prepare("iosxr_l3_interface_config.cfg") set_module_args( dict( config=[ @@ -153,7 +154,7 @@ def test_iosxr_l3_interfaces_replaced(self): self.assertEqual(sorted(result["commands"]), sorted(commands)) def test_iosxr_l3_interfaces_deleted(self): - self._prepare() + self._prepare("iosxr_l3_interface_config.cfg") set_module_args(dict(state="deleted")) commands = [ @@ -228,7 +229,7 @@ def test_iosxr_l3_interfaces_parsed(self): def test_iosxr_l3_interfaces_overridden(self): self.maxDiff = None - self._prepare() + self._prepare("iosxr_l3_interface_config.cfg") set_module_args( dict( config=[ @@ -253,3 +254,13 @@ def test_iosxr_l3_interfaces_overridden(self): result = self.execute_module(changed=True) self.assertEqual(sorted(result["commands"]), sorted(commands)) + + def test_iosxr_3_interfaces_gathered(self): + self._prepare("iosxr_interface_gathered.cfg") + set_module_args(dict(state="gathered")) + result = self.execute_module(changed=False) + gathered = [ + {"name": "GigabitEthernet0/0/0/5", "ipv4": [{"address": "10.255.2.9/30"}]}, + {"name": "GigabitEthernet0/0/0/6", "ipv4": [{"address": "10.255.2.17/30"}]}, + ] + self.assertEqual(gathered, result["gathered"]) diff --git a/tests/unit/modules/network/iosxr/test_iosxr_lacp.py b/tests/unit/modules/network/iosxr/test_iosxr_lacp.py index 23c4b8cd9..09e7fa8ec 100644 --- a/tests/unit/modules/network/iosxr/test_iosxr_lacp.py +++ b/tests/unit/modules/network/iosxr/test_iosxr_lacp.py @@ -22,8 +22,9 @@ __metaclass__ = type +from unittest.mock import patch + from ansible_collections.cisco.iosxr.plugins.modules import iosxr_lacp -from ansible_collections.cisco.iosxr.tests.unit.compat.mock import patch from ansible_collections.cisco.iosxr.tests.unit.modules.utils import set_module_args from .iosxr_module import TestIosxrModule, load_fixture diff --git a/tests/unit/modules/network/iosxr/test_iosxr_lacp_interfaces.py b/tests/unit/modules/network/iosxr/test_iosxr_lacp_interfaces.py index 55358a061..d6bb57c40 100644 --- a/tests/unit/modules/network/iosxr/test_iosxr_lacp_interfaces.py +++ b/tests/unit/modules/network/iosxr/test_iosxr_lacp_interfaces.py @@ -22,8 +22,9 @@ __metaclass__ = type +from unittest.mock import patch + from ansible_collections.cisco.iosxr.plugins.modules import iosxr_lacp_interfaces -from ansible_collections.cisco.iosxr.tests.unit.compat.mock import patch from ansible_collections.cisco.iosxr.tests.unit.modules.utils import set_module_args from .iosxr_module import TestIosxrModule, load_fixture diff --git a/tests/unit/modules/network/iosxr/test_iosxr_lag_interfaces.py b/tests/unit/modules/network/iosxr/test_iosxr_lag_interfaces.py index b0d68fc62..032539115 100644 --- a/tests/unit/modules/network/iosxr/test_iosxr_lag_interfaces.py +++ b/tests/unit/modules/network/iosxr/test_iosxr_lag_interfaces.py @@ -22,8 +22,9 @@ __metaclass__ = type +from unittest.mock import patch + from ansible_collections.cisco.iosxr.plugins.modules import iosxr_lag_interfaces -from ansible_collections.cisco.iosxr.tests.unit.compat.mock import patch from ansible_collections.cisco.iosxr.tests.unit.modules.utils import set_module_args from .iosxr_module import TestIosxrModule, load_fixture diff --git a/tests/unit/modules/network/iosxr/test_iosxr_lldp_global.py b/tests/unit/modules/network/iosxr/test_iosxr_lldp_global.py index 4830058df..d2b74103b 100644 --- a/tests/unit/modules/network/iosxr/test_iosxr_lldp_global.py +++ b/tests/unit/modules/network/iosxr/test_iosxr_lldp_global.py @@ -22,8 +22,9 @@ __metaclass__ = type +from unittest.mock import patch + from ansible_collections.cisco.iosxr.plugins.modules import iosxr_lldp_global -from ansible_collections.cisco.iosxr.tests.unit.compat.mock import patch from ansible_collections.cisco.iosxr.tests.unit.modules.utils import set_module_args from .iosxr_module import TestIosxrModule, load_fixture diff --git a/tests/unit/modules/network/iosxr/test_iosxr_lldp_interfaces.py b/tests/unit/modules/network/iosxr/test_iosxr_lldp_interfaces.py index 78b6d79f0..889eb8e57 100644 --- a/tests/unit/modules/network/iosxr/test_iosxr_lldp_interfaces.py +++ b/tests/unit/modules/network/iosxr/test_iosxr_lldp_interfaces.py @@ -22,8 +22,9 @@ __metaclass__ = type +from unittest.mock import patch + from ansible_collections.cisco.iosxr.plugins.modules import iosxr_lldp_interfaces -from ansible_collections.cisco.iosxr.tests.unit.compat.mock import patch from ansible_collections.cisco.iosxr.tests.unit.modules.utils import set_module_args from .iosxr_module import TestIosxrModule, load_fixture diff --git a/tests/unit/modules/network/iosxr/test_iosxr_logging_global.py b/tests/unit/modules/network/iosxr/test_iosxr_logging_global.py index bffee2b17..205740f19 100644 --- a/tests/unit/modules/network/iosxr/test_iosxr_logging_global.py +++ b/tests/unit/modules/network/iosxr/test_iosxr_logging_global.py @@ -23,9 +23,9 @@ __metaclass__ = type from textwrap import dedent +from unittest.mock import patch from ansible_collections.cisco.iosxr.plugins.modules import iosxr_logging_global -from ansible_collections.cisco.iosxr.tests.unit.compat.mock import patch from ansible_collections.cisco.iosxr.tests.unit.modules.utils import set_module_args from .iosxr_module import TestIosxrModule diff --git a/tests/unit/modules/network/iosxr/test_iosxr_n540.py b/tests/unit/modules/network/iosxr/test_iosxr_n540.py index d2820cfa1..e7ec26877 100644 --- a/tests/unit/modules/network/iosxr/test_iosxr_n540.py +++ b/tests/unit/modules/network/iosxr/test_iosxr_n540.py @@ -22,15 +22,15 @@ __metaclass__ = type from os import path +from unittest import TestCase from ansible.module_utils._text import to_bytes, to_text from mock import MagicMock from ansible_collections.cisco.iosxr.plugins.cliconf import iosxr -from ansible_collections.cisco.iosxr.tests.unit.compat import unittest -class TestPluginCLIConfIOSXR(unittest.TestCase): +class TestPluginCLIConfIOSXR(TestCase): """Test class for IOSXR CLI Conf Methods""" def setUp(self): diff --git a/tests/unit/modules/network/iosxr/test_iosxr_netconf.py b/tests/unit/modules/network/iosxr/test_iosxr_netconf.py index 727752948..db1f03449 100644 --- a/tests/unit/modules/network/iosxr/test_iosxr_netconf.py +++ b/tests/unit/modules/network/iosxr/test_iosxr_netconf.py @@ -21,8 +21,9 @@ __metaclass__ = type +from unittest.mock import patch + from ansible_collections.cisco.iosxr.plugins.modules import iosxr_netconf -from ansible_collections.cisco.iosxr.tests.unit.compat.mock import patch from ansible_collections.cisco.iosxr.tests.unit.modules.utils import set_module_args from .iosxr_module import TestIosxrModule diff --git a/tests/unit/modules/network/iosxr/test_iosxr_ntp_global.py b/tests/unit/modules/network/iosxr/test_iosxr_ntp_global.py index 702e2a007..e9e0e66fd 100644 --- a/tests/unit/modules/network/iosxr/test_iosxr_ntp_global.py +++ b/tests/unit/modules/network/iosxr/test_iosxr_ntp_global.py @@ -23,9 +23,9 @@ __metaclass__ = type from textwrap import dedent +from unittest.mock import patch from ansible_collections.cisco.iosxr.plugins.modules import iosxr_ntp_global -from ansible_collections.cisco.iosxr.tests.unit.compat.mock import patch from ansible_collections.cisco.iosxr.tests.unit.modules.utils import set_module_args from .iosxr_module import TestIosxrModule diff --git a/tests/unit/modules/network/iosxr/test_iosxr_ospf_interfaces.py b/tests/unit/modules/network/iosxr/test_iosxr_ospf_interfaces.py index 5b967be00..f5030c703 100644 --- a/tests/unit/modules/network/iosxr/test_iosxr_ospf_interfaces.py +++ b/tests/unit/modules/network/iosxr/test_iosxr_ospf_interfaces.py @@ -8,8 +8,9 @@ __metaclass__ = type +from unittest.mock import patch + from ansible_collections.cisco.iosxr.plugins.modules import iosxr_ospf_interfaces -from ansible_collections.cisco.iosxr.tests.unit.compat.mock import patch from ansible_collections.cisco.iosxr.tests.unit.modules.utils import set_module_args from .iosxr_module import TestIosxrModule, load_fixture diff --git a/tests/unit/modules/network/iosxr/test_iosxr_ospfv2.py b/tests/unit/modules/network/iosxr/test_iosxr_ospfv2.py index b51727dbd..3d4e26298 100644 --- a/tests/unit/modules/network/iosxr/test_iosxr_ospfv2.py +++ b/tests/unit/modules/network/iosxr/test_iosxr_ospfv2.py @@ -8,8 +8,9 @@ __metaclass__ = type +from unittest.mock import patch + from ansible_collections.cisco.iosxr.plugins.modules import iosxr_ospfv2 -from ansible_collections.cisco.iosxr.tests.unit.compat.mock import patch from ansible_collections.cisco.iosxr.tests.unit.modules.utils import set_module_args from .iosxr_module import TestIosxrModule, load_fixture diff --git a/tests/unit/modules/network/iosxr/test_iosxr_ospfv3.py b/tests/unit/modules/network/iosxr/test_iosxr_ospfv3.py index 23c9d071b..447323e7f 100644 --- a/tests/unit/modules/network/iosxr/test_iosxr_ospfv3.py +++ b/tests/unit/modules/network/iosxr/test_iosxr_ospfv3.py @@ -8,8 +8,9 @@ __metaclass__ = type +from unittest.mock import patch + from ansible_collections.cisco.iosxr.plugins.modules import iosxr_ospfv3 -from ansible_collections.cisco.iosxr.tests.unit.compat.mock import patch from ansible_collections.cisco.iosxr.tests.unit.modules.utils import set_module_args from .iosxr_module import TestIosxrModule, load_fixture diff --git a/tests/unit/modules/network/iosxr/test_iosxr_ping.py b/tests/unit/modules/network/iosxr/test_iosxr_ping.py index d0ceda0fb..87ffc4f13 100644 --- a/tests/unit/modules/network/iosxr/test_iosxr_ping.py +++ b/tests/unit/modules/network/iosxr/test_iosxr_ping.py @@ -9,9 +9,9 @@ __metaclass__ = type from textwrap import dedent +from unittest.mock import patch from ansible_collections.cisco.iosxr.plugins.modules import iosxr_ping -from ansible_collections.cisco.iosxr.tests.unit.compat.mock import patch from ansible_collections.cisco.iosxr.tests.unit.modules.utils import set_module_args from .iosxr_module import TestIosxrModule @@ -135,7 +135,7 @@ def test_iosxr_ping_state_absent_pass(self): } self.assertEqual(result, mock_res) - def test_iosxr_ping_state_absent_pass(self): + def test_iosxr_ping_state_absent_pass_1(self): self.execute_show_command.return_value = dedent( """\ Type escape sequence to abort. diff --git a/tests/unit/modules/network/iosxr/test_iosxr_prefix_lists.py b/tests/unit/modules/network/iosxr/test_iosxr_prefix_lists.py index 6dca5d920..9c2f895ac 100644 --- a/tests/unit/modules/network/iosxr/test_iosxr_prefix_lists.py +++ b/tests/unit/modules/network/iosxr/test_iosxr_prefix_lists.py @@ -23,9 +23,9 @@ __metaclass__ = type from textwrap import dedent +from unittest.mock import patch from ansible_collections.cisco.iosxr.plugins.modules import iosxr_prefix_lists -from ansible_collections.cisco.iosxr.tests.unit.compat.mock import patch from ansible_collections.cisco.iosxr.tests.unit.modules.utils import set_module_args from .iosxr_module import TestIosxrModule diff --git a/tests/unit/modules/network/iosxr/test_iosxr_snmp_server.py b/tests/unit/modules/network/iosxr/test_iosxr_snmp_server.py index 148625190..eaad485d8 100644 --- a/tests/unit/modules/network/iosxr/test_iosxr_snmp_server.py +++ b/tests/unit/modules/network/iosxr/test_iosxr_snmp_server.py @@ -23,9 +23,9 @@ __metaclass__ = type from textwrap import dedent +from unittest.mock import patch from ansible_collections.cisco.iosxr.plugins.modules import iosxr_snmp_server -from ansible_collections.cisco.iosxr.tests.unit.compat.mock import patch from ansible_collections.cisco.iosxr.tests.unit.modules.utils import set_module_args from .iosxr_module import TestIosxrModule diff --git a/tests/unit/modules/network/iosxr/test_iosxr_static_routes.py b/tests/unit/modules/network/iosxr/test_iosxr_static_routes.py index a185b0c4f..4cce2eb6e 100644 --- a/tests/unit/modules/network/iosxr/test_iosxr_static_routes.py +++ b/tests/unit/modules/network/iosxr/test_iosxr_static_routes.py @@ -8,8 +8,9 @@ __metaclass__ = type +from unittest.mock import patch + from ansible_collections.cisco.iosxr.plugins.modules import iosxr_static_routes -from ansible_collections.cisco.iosxr.tests.unit.compat.mock import patch from ansible_collections.cisco.iosxr.tests.unit.modules.utils import set_module_args from .iosxr_module import TestIosxrModule, load_fixture diff --git a/tests/unit/modules/network/iosxr/test_iosxr_system.py b/tests/unit/modules/network/iosxr/test_iosxr_system.py index 253725979..973f07066 100644 --- a/tests/unit/modules/network/iosxr/test_iosxr_system.py +++ b/tests/unit/modules/network/iosxr/test_iosxr_system.py @@ -21,8 +21,9 @@ __metaclass__ = type +from unittest.mock import patch + from ansible_collections.cisco.iosxr.plugins.modules import iosxr_system -from ansible_collections.cisco.iosxr.tests.unit.compat.mock import patch from ansible_collections.cisco.iosxr.tests.unit.modules.utils import set_module_args from .iosxr_module import TestIosxrModule, load_fixture diff --git a/tests/unit/modules/network/iosxr/test_iosxr_user.py b/tests/unit/modules/network/iosxr/test_iosxr_user.py index 0d783d4cd..0ab53a529 100644 --- a/tests/unit/modules/network/iosxr/test_iosxr_user.py +++ b/tests/unit/modules/network/iosxr/test_iosxr_user.py @@ -21,8 +21,9 @@ __metaclass__ = type +from unittest.mock import patch + from ansible_collections.cisco.iosxr.plugins.modules import iosxr_user -from ansible_collections.cisco.iosxr.tests.unit.compat.mock import patch from ansible_collections.cisco.iosxr.tests.unit.modules.utils import set_module_args from .iosxr_module import TestIosxrModule, load_fixture diff --git a/tests/unit/modules/network/iosxr/test_iosxr_utils.py b/tests/unit/modules/network/iosxr/test_iosxr_utils.py index 7707adf41..c63e57030 100644 --- a/tests/unit/modules/network/iosxr/test_iosxr_utils.py +++ b/tests/unit/modules/network/iosxr/test_iosxr_utils.py @@ -7,11 +7,13 @@ __metaclass__ = type + +from unittest import TestCase + from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.utils.utils import Version -from ansible_collections.cisco.iosxr.tests.unit.compat import unittest -class TestIosxrUtils(unittest.TestCase): +class TestIosxrUtils(TestCase): def setUp(self): pass diff --git a/tests/unit/modules/utils.py b/tests/unit/modules/utils.py index d63a86922..87be9cf8e 100644 --- a/tests/unit/modules/utils.py +++ b/tests/unit/modules/utils.py @@ -4,12 +4,12 @@ __metaclass__ = type import json +from unittest import TestCase +from unittest.mock import patch + from ansible.module_utils import basic from ansible.module_utils._text import to_bytes -from ansible_collections.cisco.iosxr.tests.unit.compat import unittest -from ansible_collections.cisco.iosxr.tests.unit.compat.mock import patch - def set_module_args(args): if "_ansible_remote_tmp" not in args: @@ -40,7 +40,7 @@ def fail_json(*args, **kwargs): raise AnsibleFailJson(kwargs) -class ModuleTestCase(unittest.TestCase): +class ModuleTestCase(TestCase): def setUp(self): self.mock_module = patch.multiple( basic.AnsibleModule, diff --git a/tox-ansible.ini b/tox-ansible.ini new file mode 100644 index 000000000..b49a359f9 --- /dev/null +++ b/tox-ansible.ini @@ -0,0 +1,3 @@ +[ansible] + +skip = "" diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 6ada631cb..000000000 --- a/tox.ini +++ /dev/null @@ -1,31 +0,0 @@ -[tox] -minversion = 1.4.2 -envlist = linters -skipsdist = True - -[testenv] -deps = -r{toxinidir}/requirements.txt - -r{toxinidir}/test-requirements.txt - -[testenv:black] -install_command = pip install {opts} {packages} -commands = - black -v {toxinidir} - -[testenv:linters] -install_command = pip install {opts} {packages} -commands = - black -v --diff --check {toxinidir} - flake8 {posargs} - -[testenv:venv] -commands = {posargs} - -[flake8] -# E123, E125 skipped as they are invalid PEP-8. - -show-source = True -ignore = E123,E125,E203,E402,E501,E741,F401,F811,F841,W503 -max-line-length = 160 -builtins = _ -exclude = .git,.tox,tests/unit/compat/