diff --git a/.ansible-lint b/.ansible-lint new file mode 100644 index 000000000..8d9bb70b8 --- /dev/null +++ b/.ansible-lint @@ -0,0 +1,5 @@ +--- +profile: production + +exclude_paths: + - changelogs/changelog.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 93e8dc7d9..d589116e4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,7 +6,7 @@ repos: - id: update-docs - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.5.0 hooks: - id: check-merge-conflict - id: check-symlinks @@ -17,12 +17,12 @@ repos: - id: trailing-whitespace - repo: https://github.com/asottile/add-trailing-comma - rev: v3.0.1 + rev: v3.1.0 hooks: - id: add-trailing-comma - repo: https://github.com/pre-commit/mirrors-prettier - rev: "v3.0.2" + rev: "v3.0.3" hooks: - id: prettier entry: env CI=1 bash -c "prettier --list-different . || ec=$? && prettier --loglevel=error --write . && exit $ec" @@ -40,6 +40,6 @@ repos: args: ["--filter-files"] - repo: https://github.com/psf/black - rev: 23.7.0 + rev: 23.9.1 hooks: - id: black diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 29a132412..9362e34d6 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,6 +5,57 @@ Cisco Nxos Collection Release Notes .. contents:: Topics +v5.2.1 +====== + +Bugfixes +-------- + +- nxos_acls - fix parsing of ACE with named source/dest port range (https://github.com/ansible-collections/cisco.nxos/issues/763). +- vtp_version - allow VTP version 3 to be configured (https://github.com/ansible-collections/cisco.nxos/issues/704). + +Documentation Changes +--------------------- + +- nxos_acls - update examples and use YAML output in them for better readibility. + +v5.2.0 +====== + +Minor Changes +------------- + +- Added new module fc_interfaces +- bgp_global - support remote-as as a route-map (https://github.com/ansible-collections/cisco.nxos/issues/741). +- bgp_neighbor_address_family - support rewrite-rt-asn for ipv4 mvpn (https://github.com/ansible-collections/cisco.nxos/issues/741). +- bgp_templates - Add support for safi evpn (https://github.com/ansible-collections/cisco.nxos/issues/739). +- bgp_templates - Add support for send_community (https://github.com/ansible-collections/cisco.nxos/issues/740). +- route_maps - support extcommunity rt option (https://github.com/ansible-collections/cisco.nxos/issues/743). + +Bugfixes +-------- + +- acls - Fix parsing error when ACE has a source port range (https://github.com/ansible-collections/cisco.nxos/issues/713). +- interfaces - Re-apply existing non-default MTU when changing mode to L2 (https://github.com/ansible-collections/cisco.nxos/issues/730). +- lag_interfaces - Allow force option to be idempotent (https://github.com/ansible-collections/cisco.nxos/issues/742). +- snmp_server - fix host delete when authentication options are present (https://github.com/ansible-collections/cisco.nxos/issues/439). + +Documentation Changes +--------------------- + +- Update examples for bgp_address_family resource modules using yaml callback plugin. +- Update examples for bgp_global resource modules using yaml callback plugin. +- Update examples for bgp_neighbor_address_family resource modules using yaml callback plugin. +- Update examples for bgp_templates resource modules using yaml callback plugin. +- Update examples for ospf_interfaces resource modules using yaml callback plugin. +- Update examples for ospfv2 resource modules using yaml callback plugin. +- Update examples for ospfv3 resource modules using yaml callback plugin. + +New Modules +----------- + +- nxos_fc_interfaces - Fc Interfaces resource module + v5.1.0 ====== diff --git a/README.md b/README.md index c038ee93e..e8ad6e9d9 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,7 @@ Name | Description [cisco.nxos.nxos_evpn_global](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_evpn_global_module.rst)|Handles the EVPN control plane for VXLAN. [cisco.nxos.nxos_evpn_vni](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_evpn_vni_module.rst)|Manages Cisco EVPN VXLAN Network Identifier (VNI). [cisco.nxos.nxos_facts](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_facts_module.rst)|Gets facts about NX-OS switches +[cisco.nxos.nxos_fc_interfaces](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_fc_interfaces_module.rst)|Fc Interfaces resource module [cisco.nxos.nxos_feature](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_feature_module.rst)|Manage features in NX-OS switches. [cisco.nxos.nxos_file_copy](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_file_copy_module.rst)|Copy a file to a remote NXOS device. [cisco.nxos.nxos_gir](https://github.com/ansible-collections/cisco.nxos/blob/main/docs/cisco.nxos.nxos_gir_module.rst)|Trigger a graceful removal or insertion (GIR) of the switch. diff --git a/bindep.txt b/bindep.txt index ba9c980fb..70fd8dfa5 100644 --- a/bindep.txt +++ b/bindep.txt @@ -2,5 +2,3 @@ # see https://docs.openstack.org/infra/bindep/ for additional information. gcc-c++ [doc test platform:rpm] -python3-devel [test platform:rpm] -python3 [test platform:rpm] diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index 404de0b8e..91c728004 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -1,4 +1,5 @@ -ancestor: null +--- +ancestor: releases: 1.0.0: modules: @@ -8,14 +9,10 @@ releases: - description: Manages AAA server host-specific configuration. name: nxos_aaa_server_host namespace: "" - - description: - (deprecated, removed after 2022-06-01) Manages access list entries - for ACLs. + - description: (deprecated, removed after 2022-06-01) Manages access list entries for ACLs. name: nxos_acl namespace: "" - - description: - (deprecated, removed after 2022-06-01) Manages applying ACLs to - interfaces. + - description: (deprecated, removed after 2022-06-01) Manages applying ACLs to interfaces. name: nxos_acl_interface namespace: "" - description: ACL interfaces resource module @@ -93,9 +90,7 @@ releases: - description: Set boot options like boot, kickstart image and issu. name: nxos_install_os namespace: "" - - description: - (deprecated, removed after 2022-06-01) Manages physical attributes - of interfaces. + - description: (deprecated, removed after 2022-06-01) Manages physical attributes of interfaces. name: nxos_interface namespace: "" - description: Manages configuration of an OSPF interface instance. @@ -104,17 +99,13 @@ releases: - description: Interfaces resource module name: nxos_interfaces namespace: "" - - description: - (deprecated, removed after 2022-06-01) Manage Layer-2 interface - on Cisco NXOS devices. + - description: (deprecated, removed after 2022-06-01) Manage Layer-2 interface on Cisco NXOS devices. name: nxos_l2_interface namespace: "" - description: L2 interfaces resource module name: nxos_l2_interfaces namespace: "" - - description: - (deprecated, removed after 2022-06-01) Manage L3 interfaces on - Cisco NXOS network devices + - description: (deprecated, removed after 2022-06-01) Manage L3 interfaces on Cisco NXOS network devices name: nxos_l3_interface namespace: "" - description: L3 interfaces resource module @@ -129,14 +120,10 @@ releases: - description: LAG interfaces resource module name: nxos_lag_interfaces namespace: "" - - description: - (deprecated, removed after 2022-06-01) Manage link aggregation - groups on Cisco NXOS devices. + - description: (deprecated, removed after 2022-06-01) Manage link aggregation groups on Cisco NXOS devices. name: nxos_linkagg namespace: "" - - description: - (deprecated, removed after 2022-06-01) Manage LLDP configuration - on Cisco NXOS network devices. + - description: (deprecated, removed after 2022-06-01) Manage LLDP configuration on Cisco NXOS network devices. name: nxos_lldp namespace: "" - description: LLDP resource module @@ -160,9 +147,7 @@ releases: - description: Manage NXAPI configuration on an NXOS device. name: nxos_nxapi namespace: "" - - description: - (deprecated, removed after 2022-06-01) Manages configuration of - an ospf instance. + - description: (deprecated, removed after 2022-06-01) Manages configuration of an ospf instance. name: nxos_ospf namespace: "" - description: Manages a VRF for an OSPF router. @@ -240,9 +225,7 @@ releases: - description: Manage the collection of local users on Nexus devices name: nxos_user namespace: "" - - description: - (deprecated, removed after 2022-06-01) Manages VLAN resources and - attributes. + - description: (deprecated, removed after 2022-06-01) Manages VLAN resources and attributes. name: nxos_vlan namespace: "" - description: VLANs resource module @@ -291,23 +274,20 @@ releases: cliconf: - description: Use NX-OS cliconf to run commands on Cisco NX-OS platform name: nxos - namespace: null + namespace: httpapi: - description: Use NX-API to run commands on Cisco NX-OS platform name: nxos - namespace: null + namespace: release_date: "2020-06-23" 1.0.1: changes: bugfixes: - - Element type of `commands` key should be `raw` since it accepts both strings - and dicts (https://github.com/ansible-collections/cisco.nxos/pull/126). + - Element type of `commands` key should be `raw` since it accepts both strings and dicts (https://github.com/ansible-collections/cisco.nxos/pull/126). - Fix nxos_interfaces states replaced and overridden (https://github.com/ansible-collections/cisco.nxos/pull/102). - Fixed force option in lag_interfaces.py (https://github.com/ansible-collections/cisco.nxos/pull/111). - - Make `src`, `backup` and `backup_options` in nxos_config work when module - alias is used (https://github.com/ansible-collections/cisco.nxos/pull/121). - - Makes sure that docstring and argspec are in sync and removes sanity ignores - (https://github.com/ansible-collections/cisco.nxos/pull/112). + - Make `src`, `backup` and `backup_options` in nxos_config work when module alias is used (https://github.com/ansible-collections/cisco.nxos/pull/121). + - Makes sure that docstring and argspec are in sync and removes sanity ignores (https://github.com/ansible-collections/cisco.nxos/pull/112). - Update docs after sanity fixes to modules. - nxos_user - do not fail when a custom role is used (https://github.com/ansible-collections/cisco.nxos/pull/130) minor_changes: @@ -349,13 +329,11 @@ releases: - Preserve whitespaces in banner text (https://github.com/ansible-collections/cisco.nxos/pull/146). deprecated_features: - Deprecated `nxos_smu` in favour of `nxos_rpm` module. - - The `nxos_ospf_vrf` module is deprecated by `nxos_ospfv2` and `nxos_ospfv3` - Resource Modules. + - The `nxos_ospf_vrf` module is deprecated by `nxos_ospfv2` and `nxos_ospfv3` Resource Modules. minor_changes: - Add nxos_ospfv3 module. - - Allow other transfer protocols than scp to pull files from a NXOS device in - nxos_file_copy module. sftp, http, https, tftp and ftp can be choosen as a - transfer protocol, when the file_pull parameter is true.. + - Allow other transfer protocols than scp to pull files from a NXOS device in nxos_file_copy module. sftp, http, https, tftp and ftp can be choosen as a transfer + protocol, when the file_pull parameter is true.. fragments: - 161-transfer_protocol_file_copy.yaml - add_nxos_ospfv3.yaml @@ -378,8 +356,7 @@ releases: - Update regex to accept the platform "N77" as supporting fabricpath. - Vlan config diff was not removing default values deprecated_features: - - Deprecated `nxos_interface_ospf` in favor of `nxos_ospf_interfaces` Resource - Module. + - Deprecated `nxos_interface_ospf` in favor of `nxos_ospf_interfaces` Resource Module. minor_changes: - Add nxos_ospf_interfaces resource module. fragments: @@ -399,8 +376,7 @@ releases: - Add version key to galaxy.yaml to work around ansible-galaxy bug - Allow nxos_user to run with MDS (https://github.com/ansible-collections/cisco.nxos/issues/163). - Fix for nxos_lag_interfaces issue (https://github.com/ansible-collections/cisco.nxos/pull/194). - - Make sure that the OSPF modules work properly when process_id is a string - (https://github.com/ansible-collections/cisco.nxos/issues/198). + - Make sure that the OSPF modules work properly when process_id is a string (https://github.com/ansible-collections/cisco.nxos/issues/198). fragments: - fix_nxos_lag_interfaces_1.yaml - fix_ospf_process_id.yaml @@ -413,24 +389,18 @@ releases: - Add support for interfaces in mode 'fabricpath' to l2_interfaces (https://github.com/ansible-collections/cisco.nxos/issues/220). - Allow enabling `fabric forwarding` feature through nxos_feature (https://github.com/ansible-collections/cisco.nxos/issues/213). - Allow tag updates with state replaced (https://github.com/ansible-collections/cisco.nxos/issues/197). - - Fixes traceback while parsing power supply info in nxos_facts for newer NX-OS - releases (https://github.com/ansible-collections/cisco.nxos/issues/192). + - Fixes traceback while parsing power supply info in nxos_facts for newer NX-OS releases (https://github.com/ansible-collections/cisco.nxos/issues/192). - Handle domain-name properly with vrf contexts (https://github.com/ansible-collections/cisco.nxos/issues/234). - Parse interface contexts properly (https://github.com/ansible-collections/cisco.nxos/issues/195). - Properly handle partial matches in community string (https://github.com/ansible-collections/cisco.nxos/issues/203). - Update argspecs with default value for parameters. - - Update docs to clarify the idemptonecy releated caveat and add it in the output - warnings (https://github.com/ansible-collections/ansible.netcommon/pull/189) - - config replace is actually supported for devices other than N9K and hence - we should not fail, and instead let the device handle it (https://github.com/ansible-collections/cisco.nxos/issues/215). + - Update docs to clarify the idemptonecy releated caveat and add it in the output warnings (https://github.com/ansible-collections/ansible.netcommon/pull/189) + - config replace is actually supported for devices other than N9K and hence we should not fail, and instead let the device handle it (https://github.com/ansible-collections/cisco.nxos/issues/215). deprecated_features: - - Deprecated `nxos_bgp` and `nxos_bgp_neighbor` modules in favor of `nxos_bgp_global` - resource module. + - Deprecated `nxos_bgp` and `nxos_bgp_neighbor` modules in favor of `nxos_bgp_global` resource module. doc_changes: - - Fix error in ``host_reachability`` parameter's example where a default value - is used, which the ``host_reachability`` parameter does not support. Improve - descriptions of some parameters to be more explicit. Correct spelling and - grammar where errors were noticed. + - Fix error in ``host_reachability`` parameter's example where a default value is used, which the ``host_reachability`` parameter does not support. Improve + descriptions of some parameters to be more explicit. Correct spelling and grammar where errors were noticed. minor_changes: - Add `echo_request` option for ICMP. - Add nxos_bgp_global resource module. @@ -460,32 +430,24 @@ releases: 2.0.0: changes: bugfixes: - - Fail gracefully when BGP is already configured with a different ASN when states - merged or replaced is used. - - Fixes to nxos_logging, nxos_igmp_snooping, nxos_l3_interfaces, nxos_ospf_interfaces - and nxos_static_routes to conform with latest CLI behaviour. + - Fail gracefully when BGP is already configured with a different ASN when states merged or replaced is used. + - Fixes to nxos_logging, nxos_igmp_snooping, nxos_l3_interfaces, nxos_ospf_interfaces and nxos_static_routes to conform with latest CLI behaviour. - Properly configure neighbor timers and shutdown state (https://github.com/ansible-collections/cisco.nxos/issues/240). deprecated_features: - Deprecated nxos_bgp_af in favour of nxos_bgp_address_family resource module. - - Deprecated nxos_bgp_neighbor_af in favour of nxos_bgp_neighbor_address_family - resource module. + - Deprecated nxos_bgp_neighbor_af in favour of nxos_bgp_neighbor_address_family resource module. major_changes: - - "Please refer to - ansible.netcommon - `changelog `_ - for more details." - - Requires ansible.netcommon v2.0.0+ to support `ansible_network_single_user_mode` - and `ansible_network_import_modules`. + - Please refer to ansible.netcommon `changelog `_ + for more details. + - Requires ansible.netcommon v2.0.0+ to support `ansible_network_single_user_mode` and `ansible_network_import_modules`. minor_changes: - Add bfd option for neighbors (https://github.com/ansible-collections/cisco.nxos/issues/241). - - Add hello_interval_ms option in nxos_pim_interface module to support sub-second - intervals (https://github.com/ansible-collections/cisco.nxos/issues/226). + - Add hello_interval_ms option in nxos_pim_interface module to support sub-second intervals (https://github.com/ansible-collections/cisco.nxos/issues/226). - Add nxos_bgp_address_family Resource Module. - Add nxos_bgp_neighbor_address_family Resource Module. - Add support df_bit and size option for nxos_ping (https://github.com/ansible-collections/cisco.nxos/pull/237). - Adds support for `single_user_mode` command output caching. - - Move nxos_config idempotent warning message with the task response under `warnings` - key if `changed` is `True` + - Move nxos_config idempotent warning message with the task response under `warnings` key if `changed` is `True` fragments: - 237_nxos_ping_df_size.yaml - add_caching_support.yaml @@ -509,8 +471,7 @@ releases: 2.1.0: changes: bugfixes: - - Allow commands to be properly generated with Jinja2 2.10.3 (workaround for - https://github.com/pallets/jinja/issues/710). + - Allow commands to be properly generated with Jinja2 2.10.3 (workaround for https://github.com/pallets/jinja/issues/710). - Allow integer values to be set for dscp key (https://github.com/ansible-collections/cisco.nxos/issues/253). - Do not fail when parsing non rule entries in access-list config (https://github.com/ansible-collections/cisco.nxos/issues/262). minor_changes: @@ -529,8 +490,7 @@ releases: changes: bugfixes: - For versions >=2.1.0, this collection requires ansible.netcommon >=2.0.1. - - Re-releasing this collection with ansible.netcommon dependency requirements - updated. + - Re-releasing this collection with ansible.netcommon dependency requirements updated. fragments: - 275-add_ignore_txt.yml - update_requirement.yaml @@ -539,8 +499,7 @@ releases: changes: minor_changes: - Add nxos_route_maps resource module. - - Add support for ansible_network_resources key allows to fetch the available - resources for a platform (https://github.com/ansible-collections/cisco.nxos/issues/268). + - Add support for ansible_network_resources key allows to fetch the available resources for a platform (https://github.com/ansible-collections/cisco.nxos/issues/268). fragments: - 268_available_network_resources.yaml - add_nxos_route_maps.yaml @@ -553,13 +512,11 @@ releases: 2.3.0: changes: bugfixes: - - Fix how `send_community` attribute is handled in `nxos_bgp_neighbor_address_family` - (https://github.com/ansible-collections/cisco.nxos/issues/281). + - Fix how `send_community` attribute is handled in `nxos_bgp_neighbor_address_family` (https://github.com/ansible-collections/cisco.nxos/issues/281). - Make `passive_interface` work properly when set to False. minor_changes: - Add `default_passive_interface` option in `nxos_ospf_interfaces`. - - Add a netconf subplugin to make netconf_* modules work with older NX-OS versions - (https://github.com/ansible-collections/ansible.netcommon/issues/252). + - Add a netconf subplugin to make netconf_* modules work with older NX-OS versions (https://github.com/ansible-collections/ansible.netcommon/issues/252). fragments: - bgp_nbr_af.yaml - changelog.yaml @@ -571,11 +528,9 @@ releases: - pre_sort.yaml plugins: netconf: - - description: - Use nxos netconf plugin to run netconf commands on Cisco NX-OS - platform. + - description: Use nxos netconf plugin to run netconf commands on Cisco NX-OS platform. name: nxos - namespace: null + namespace: release_date: "2021-05-18" 2.4.0: changes: @@ -598,12 +553,10 @@ releases: changes: bugfixes: - Convert vlan lists to ranges in nxos_l2_interfaces (https://github.com/ansible-collections/cisco.nxos/issues/95). - - Do not expand direction 'both' into 'import' and 'export' for Nexus 9000 platforms - (https://github.com/ansible-collections/cisco.nxos/issues/303). + - Do not expand direction 'both' into 'import' and 'export' for Nexus 9000 platforms (https://github.com/ansible-collections/cisco.nxos/issues/303). - Prevent traceback when parsing unexpected line in nxos_static_routes. deprecated_features: - - The nxos_logging module has been deprecated in favor of the new nxos_logging_global - resource module and will be removed in a release after '2023-08-01'. + - The nxos_logging module has been deprecated in favor of the new nxos_logging_global resource module and will be removed in a release after '2023-08-01'. doc_changes: - Broken link in documentation fixed. minor_changes: @@ -626,8 +579,7 @@ releases: changes: bugfixes: - "`nxos_facts` - Fix gathering CDP neighbor facts from certain N7Ks (https://github.com/ansible-collections/cisco.nxos/issues/329)." - - "`nxos_zone_zoneset` - zone member addition with smart zoning in an already - existing zone should be a no-op (https://github.com/ansible-collections/cisco.nxos/issues/339)." + - "`nxos_zone_zoneset` - zone member addition with smart zoning in an already existing zone should be a no-op (https://github.com/ansible-collections/cisco.nxos/issues/339)." doc_changes: - Added notes in module docs to indicate supportability for Cisco MDS. fragments: @@ -643,8 +595,7 @@ releases: - "`nxos_acls` - Fix traceback with 'port_protocol' range (https://github.com/ansible-collections/cisco.nxos/issues/356)" - "`nxos_facts` - Fix KeyError while gathering CDP neighbor facts (https://github.com/ansible-collections/cisco.nxos/issues/354)." - "`nxos_ospf_interfaces` - Correctly sort interface names before rendering." - - "`nxos_vlans` - switching to `| json-pretty` instead of `| json` as a workaround - for the timeout issue with `libssh` (https://github.com/ansible/pylibssh/issues/208)" + - "`nxos_vlans` - switching to `| json-pretty` instead of `| json` as a workaround for the timeout issue with `libssh` (https://github.com/ansible/pylibssh/issues/208)" deprecated_features: - Deprecated `nxos_ntp`, `nxos_ntp_options`, `nxos_ntp_auth` modules. doc_changes: @@ -672,15 +623,14 @@ releases: minor_changes: - "`nxos_telemetry` - Add support for state gathered" fragments: - - 0-copy_ignore_txt.yml + - "0-copy_ignore_txt.yml" - nxos_telemetry.yaml - readme.yaml release_date: "2021-10-01" 2.7.1: changes: bugfixes: - - "`nxos_acls` - Updating an existing ACE can only be done with states replaced - or overridden. Using state merged will result in a failure." + - "`nxos_acls` - Updating an existing ACE can only be done with states replaced or overridden. Using state merged will result in a failure." - "`nxos_logging_global` - Fix vlan_mgr not being gathered in facts (https://github.com/ansible-collections/cisco.nxos/issues/380)." - "`nxos_vlans` - Fallback to json when json-pretty is not supported (https://github.com/ansible-collections/cisco.nxos/issues/377)." fragments: @@ -710,20 +660,17 @@ releases: 2.8.1: changes: bugfixes: - - nxos_acls - Fix incorrect parsing of remarks if it has 'ip/ipv6 access-list' - in it. + - nxos_acls - Fix incorrect parsing of remarks if it has 'ip/ipv6 access-list' in it. fragments: - nxos_acls.yaml release_date: "2021-12-10" 2.8.2: changes: bugfixes: - - "`nxos_ntp_global` - In some cases, there is an extra whitespace in the source-interface - line. This patch accounts for this behaviour in config (https://github.com/ansible-collections/cisco.nxos/issues/399)." + - "`nxos_ntp_global` - In some cases, there is an extra whitespace in the source-interface line. This patch accounts for this behaviour in config (https://github.com/ansible-collections/cisco.nxos/issues/399)." release_summary: - The v2.8.1 of the cisco.nxos collection is not available on - Ansible Automation Hub. Please download and use v2.8.2 which also contains - an additional bug fix. + The v2.8.1 of the cisco.nxos collection is not available on Ansible Automation Hub. Please download and use v2.8.2 which also contains an additional + bug fix. fragments: - ignore.yaml - nxos_ntp.yaml @@ -732,8 +679,7 @@ releases: 2.9.0: changes: bugfixes: - - "`nxos_bgp_address_family` - Add hmm as valid option for redistribute protocol - (https://github.com/ansible-collections/cisco.nxos/issues/385)." + - "`nxos_bgp_address_family` - Add hmm as valid option for redistribute protocol (https://github.com/ansible-collections/cisco.nxos/issues/385)." - "`nxos_snmp_server` - Fix rendering context command (https://github.com/ansible-collections/cisco.nxos/issues/406)." minor_changes: - Add nxos_hostname resource module. @@ -752,8 +698,7 @@ releases: bugfixes: - Fix action plugin redirection to make module defaults work properly. - Fix for nxos_vlans issue (https://github.com/ansible-collections/cisco.nxos/issues/425). - - "`nxos_ntp_global` - Aliased `vrf` to `use_vrf` wherever applicable to maintain - consistency with models for other platforms." + - "`nxos_ntp_global` - Aliased `vrf` to `use_vrf` wherever applicable to maintain consistency with models for other platforms." - nxos_snmp_server - Add alias for community (https://github.com/ansible-collections/cisco.nxos/issues/433) doc_changes: - Added notes in module docs to indicate supportability for Cisco MDS. @@ -770,22 +715,17 @@ releases: 3.0.0: changes: bugfixes: - - "`nxos_lag_interfaces` - Fix KeyError with state overridden when port-channel - has no members (https://github.com/ansible-collections/cisco.nxos/issues/452)." - - "`nxos_ntp_global` - correctly propagate CLI failure for non-existent auth - keys (https://github.com/ansible-collections/cisco.nxos/issues/467)." + - "`nxos_lag_interfaces` - Fix KeyError with state overridden when port-channel has no members (https://github.com/ansible-collections/cisco.nxos/issues/452)." + - "`nxos_ntp_global` - correctly propagate CLI failure for non-existent auth keys (https://github.com/ansible-collections/cisco.nxos/issues/467)." - "`nxos_snmp_server` - Properly handle corner cases for snmp-server user (https://github.com/ansible-collections/cisco.nxos/issues/454)." - - "`snmp_server` - Snmp contact/location and location were not gathered if containing - whitespaces." + - "`snmp_server` - Snmp contact/location and location were not gathered if containing whitespaces." major_changes: - The minimum required ansible.netcommon version has been bumped to v2.6.1. - Updated base plugin references to ansible.netcommon. - "`nxos_facts` - change default gather_subset to `min` from `!config` (https://github.com/ansible-collections/cisco.nxos/issues/418)." - - nxos_file_copy has been rewritten as a module. This change also removes the - dependency on pexpect for file_pull operation. Since this now uses AnsibleModule - class for argspec validation, the validation messages will be slighlty different. - Expect changes in the return payload in some cases. All functionality remains - unchanged. + - nxos_file_copy has been rewritten as a module. This change also removes the dependency on pexpect for file_pull operation. Since this now uses AnsibleModule + class for argspec validation, the validation messages will be slighlty different. Expect changes in the return payload in some cases. All functionality + remains unchanged. minor_changes: - "`nxos_snmp_server` - add support for BGP, OSPF and OSPFv3 traps." fragments: @@ -805,13 +745,11 @@ releases: changes: bugfixes: - "`nxos_file_copy` - Skip `vrf` when running against MDS switches (https://github.com/ansible-collections/cisco.nxos/issues/508)." - - "`nxos_interfaces` - Enable all virtual interfaces with `enabled` set to True - (https://github.com/ansible-collections/cisco.nxos/issues/335)." + - "`nxos_interfaces` - Enable all virtual interfaces with `enabled` set to True (https://github.com/ansible-collections/cisco.nxos/issues/335)." - "`nxos_ntp_global` - Ensure idempotence for aliased keys (https://github.com/ansible-collections/cisco.nxos/issues/484)." - "`nxos_snmp_server` - Fix typo for traps link cisco-xcvr-mon-status-chg." doc_changes: - - Updated documentation in nxos_snmp_server, nxos_ntp_global and nxos_logging_global - modules to reflect which options are unsupported on MDS switches. + - Updated documentation in nxos_snmp_server, nxos_ntp_global and nxos_logging_global modules to reflect which options are unsupported on MDS switches. minor_changes: - "`nxos_snmp_server` - Add support for localizedV2key (https://github.com/ansible-collections/cisco.nxos/issues/415)." - "`nxos_snmp_server` - Add support for sha-256 based based user authentication." @@ -852,8 +790,7 @@ releases: 3.1.1: changes: bugfixes: - - Fix issue with modules related to OSPF interfaces failing when the target - NXOS device has subinterfaces. + - Fix issue with modules related to OSPF interfaces failing when the target NXOS device has subinterfaces. fragments: - ospf_subinterface_failure.yaml - paramiko.yaml @@ -862,8 +799,7 @@ releases: 3.1.2: changes: bugfixes: - - "`nxos_facts` - Fixes parsing of module info json data when TABLE_modinfo - entry is a list (https://github.com/ansible-collections/cisco.nxos/issues/559)." + - "`nxos_facts` - Fixes parsing of module info json data when TABLE_modinfo entry is a list (https://github.com/ansible-collections/cisco.nxos/issues/559)." fragments: - nxos_facts.yaml release_date: "2022-09-19" @@ -871,8 +807,7 @@ releases: changes: bugfixes: - "`nxos_telemetry` - Allow destination-group & sensor-group id to be strings." - - "`nxos_telemetry` - Allow sensor-group paths to be generated without additional - properties." + - "`nxos_telemetry` - Allow sensor-group paths to be generated without additional properties." minor_changes: - "`nxos_l3_interfaces` - Add support for toggling ipv6 redirects (https://github.com/ansible-collections/cisco.nxos/issues/569)." fragments: @@ -884,12 +819,10 @@ releases: 4.0.0: changes: major_changes: - - Please use either of the following connection types - network_cli, httpapi - or netconf. + - Please use either of the following connection types - network_cli, httpapi or netconf. - "This release drops support for `connection: local` and provider dictionary." removed_features: - - This release removes the following deprecated plugins that have reached their - end-of-life. + - This release removes the following deprecated plugins that have reached their end-of-life. - nxos_acl - nxos_acl_interface - nxos_interface @@ -912,10 +845,8 @@ releases: changes: bugfixes: - "`nxos_acls` - Parse ICMP echo-reply and echo options correctly (https://github.com/ansible-collections/cisco.nxos/issues/583)." - - "`nxos_acls` - Parse ICMP port-unreachable and unreachable options correctly - (https://github.com/ansible-collections/cisco.nxos/issues/529)." - - "`nxos_acls` - Parse port-protocol options with hypenated names correctly - (https://github.com/ansible-collections/cisco.nxos/issues/557)." + - "`nxos_acls` - Parse ICMP port-unreachable and unreachable options correctly (https://github.com/ansible-collections/cisco.nxos/issues/529)." + - "`nxos_acls` - Parse port-protocol options with hypenated names correctly (https://github.com/ansible-collections/cisco.nxos/issues/557)." fragments: - nxos_acls.yaml - nxos_pim.yaml @@ -926,13 +857,10 @@ releases: - "`nxos_acls` - Fix how IPv6 prefixes are converted to hosts (https://github.com/ansible-collections/cisco.nxos/issues/623)." - "`nxos_file_copy` - stop prepending redundant bootflash: to remote file names" - nxos_acls - Detect duplicate ACE error message from CLI and fail (https://github.com/ansible-collections/cisco.nxos/issues/611). - - nxos_command - Run & evaluate commands at least once even when retries is - set to 0 (https://github.com/ansible-collections/cisco.nxos/issues/607). + - nxos_command - Run & evaluate commands at least once even when retries is set to 0 (https://github.com/ansible-collections/cisco.nxos/issues/607). minor_changes: - - "`nxos_acls` - Support ICMPv6 option. Please refer to module doc for all new - options (https://github.com/ansible-collections/cisco.nxos/issues/624)." - - "`nxos_facts` - Update facts gathering logic to ensure that `gather_network_resources: - all` does not fail for NX-OS on MDS switches." + - "`nxos_acls` - Support ICMPv6 option. Please refer to module doc for all new options (https://github.com/ansible-collections/cisco.nxos/issues/624)." + - "`nxos_facts` - Update facts gathering logic to ensure that `gather_network_resources: all` does not fail for NX-OS on MDS switches." - "`nxos_l2_interfaces` - Add new mode dot1q-tunnel (https://github.com/ansible-collections/cisco.nxos/issues/600)." fragments: - acls.yaml @@ -951,17 +879,14 @@ releases: changes: bugfixes: - "`bgp` - Fix parsing remote-as for Nexus 3K (https://github.com/ansible-collections/cisco.nxos/issues/653)." - - "`facts` - Attempt to execute json output commands with | json-pretty first - and fall back to | json if unsupported. This is a temporary workaround until + - "`facts` - Attempt to execute json output commands with | json-pretty first and fall back to | json if unsupported. This is a temporary workaround until https://github.com/ansible/pylibssh/issues/208 is fixed." - "`interfaces` - Correctly enable/disable VLAN interfaces (https://github.com/ansible-collections/cisco.nxos/issues/539)." - "`route_maps` - resolve route-map description parameter idempotency" - - "`snmp_server` - fix community option to produce proper configuration with - ipv4acl and ipv6acl." + - "`snmp_server` - fix community option to produce proper configuration with ipv4acl and ipv6acl." minor_changes: - "`nxos_route_maps` - add support for 'set ip next-hop <>' command in route-maps" - - "`nxos_vxlan_vtep` - add support for 'advertise virtual-rmac' command under - nve interface" + - "`nxos_vxlan_vtep` - add support for 'advertise virtual-rmac' command under nve interface" fragments: - bgp.yaml - bool.yaml @@ -976,9 +901,7 @@ releases: release_date: "2023-04-04" 4.3.0: changes: - release_summary: - Re-releasing v4.2.0 of this collection since the previously - build failed to upload in Automation Hub. + release_summary: Re-releasing v4.2.0 of this collection since the previously build failed to upload in Automation Hub. fragments: - release_430.yaml release_date: "2023-04-05" @@ -989,8 +912,7 @@ releases: - ntp_global - Fix incorrect handling of prefer option (https://github.com/ansible-collections/cisco.nxos/issues/670). - nxos_banner - Add support for a custom multiline delimiter - nxos_facts - Fix missing SVI facts (https://github.com/ansible-collections/cisco.nxos/issues/440). - - "terminal - attempt privilege escalation only when prompt does not end with - #" + - "terminal - attempt privilege escalation only when prompt does not end with #" doc_changes: - Fix docs of static-routes resource module. - nxos_interfaces - Fixed module documentation and examples. @@ -1014,10 +936,8 @@ releases: 5.0.0: changes: bugfixes: - - nxos_static_routes - Prevent action states to generate terminal configuration - command. - - nxos_static_routes - Update the delete operation of static routes to be similar - to other platforms. (https://github.com/ansible-collections/cisco.nxos/issues/666) + - nxos_static_routes - Prevent action states to generate terminal configuration command. + - nxos_static_routes - Update the delete operation of static routes to be similar to other platforms. (https://github.com/ansible-collections/cisco.nxos/issues/666) major_changes: - Refer to **Removed Features** section for details. - This release removes four of the previously deprecated modules from this collection. @@ -1043,3 +963,54 @@ releases: fragments: - cpu_utilization.yml release_date: "2023-07-05" + 5.2.0: + changes: + bugfixes: + - acls - Fix parsing error when ACE has a source port range (https://github.com/ansible-collections/cisco.nxos/issues/713). + - interfaces - Re-apply existing non-default MTU when changing mode to L2 (https://github.com/ansible-collections/cisco.nxos/issues/730). + - lag_interfaces - Allow force option to be idempotent (https://github.com/ansible-collections/cisco.nxos/issues/742). + - snmp_server - fix host delete when authentication options are present (https://github.com/ansible-collections/cisco.nxos/issues/439). + doc_changes: + - Update examples for bgp_address_family resource modules using yaml callback plugin. + - Update examples for bgp_global resource modules using yaml callback plugin. + - Update examples for bgp_neighbor_address_family resource modules using yaml callback plugin. + - Update examples for bgp_templates resource modules using yaml callback plugin. + - Update examples for ospf_interfaces resource modules using yaml callback plugin. + - Update examples for ospfv2 resource modules using yaml callback plugin. + - Update examples for ospfv3 resource modules using yaml callback plugin. + minor_changes: + - Added new module fc_interfaces + - bgp_global - support remote-as as a route-map (https://github.com/ansible-collections/cisco.nxos/issues/741). + - bgp_neighbor_address_family - support rewrite-rt-asn for ipv4 mvpn (https://github.com/ansible-collections/cisco.nxos/issues/741). + - bgp_templates - Add support for safi evpn (https://github.com/ansible-collections/cisco.nxos/issues/739). + - bgp_templates - Add support for send_community (https://github.com/ansible-collections/cisco.nxos/issues/740). + - route_maps - support extcommunity rt option (https://github.com/ansible-collections/cisco.nxos/issues/743). + fragments: + - _health_check_update_docs.yaml + - bgp_assorted.yaml + - bgp_templates.yaml + - codecov_pr.yml + - fix_713.yaml + - fix_730.yaml + - lag_interfaces.yaml + - nxos.yaml + - nxos_mds_fc.yaml + - route_maps.yaml + - snmp_server_fix.yml + modules: + - description: Fc Interfaces resource module + name: nxos_fc_interfaces + namespace: "" + release_date: "2023-09-14" + 5.2.1: + changes: + bugfixes: + - nxos_acls - fix parsing of ACE with named source/dest port range (https://github.com/ansible-collections/cisco.nxos/issues/763). + - vtp_version - allow VTP version 3 to be configured (https://github.com/ansible-collections/cisco.nxos/issues/704). + doc_changes: + - nxos_acls - update examples and use YAML output in them for better readibility. + fragments: + - acls.yaml + - fix_763.yaml + - vtp_version.yaml + release_date: "2023-10-03" diff --git a/changelogs/fragments/_health_check_update_docs.yaml b/changelogs/fragments/_health_check_update_docs.yaml deleted file mode 100644 index 908e0b5a7..000000000 --- a/changelogs/fragments/_health_check_update_docs.yaml +++ /dev/null @@ -1,9 +0,0 @@ ---- -doc_changes: - - Update examples for ospfv2 resource modules using yaml callback plugin. - - Update examples for ospfv3 resource modules using yaml callback plugin. - - Update examples for ospf_interfaces resource modules using yaml callback plugin. - - Update examples for bgp_global resource modules using yaml callback plugin. - - Update examples for bgp_address_family resource modules using yaml callback plugin. - - Update examples for bgp_templates resource modules using yaml callback plugin. - - Update examples for bgp_neighbor_address_family resource modules using yaml callback plugin. diff --git a/changelogs/fragments/codecov_pr.yml b/changelogs/fragments/codecov_pr.yml deleted file mode 100644 index ad3c08ca7..000000000 --- a/changelogs/fragments/codecov_pr.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - codecov - added a new codecov workflow and changing codecov.yml for added functionality. diff --git a/changelogs/fragments/fix_713.yaml b/changelogs/fragments/fix_713.yaml deleted file mode 100644 index b8bfdebad..000000000 --- a/changelogs/fragments/fix_713.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -bugfixes: - - "acls - Fix parsing error when ACE has a source port range (https://github.com/ansible-collections/cisco.nxos/issues/713)." diff --git a/changelogs/fragments/fix_730.yaml b/changelogs/fragments/fix_730.yaml deleted file mode 100644 index 501ad501f..000000000 --- a/changelogs/fragments/fix_730.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -bugfixes: - - "interfaces - Re-apply existing non-default MTU when changing mode to L2 (https://github.com/ansible-collections/cisco.nxos/issues/730)." diff --git a/changelogs/fragments/nxos.yaml b/changelogs/fragments/nxos.yaml deleted file mode 100644 index 53eb6356c..000000000 --- a/changelogs/fragments/nxos.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - Drop storage sub-directory and move MDS modules to top-level. diff --git a/changelogs/fragments/trivial.yaml b/changelogs/fragments/trivial.yaml new file mode 100644 index 000000000..3f0dfde5c --- /dev/null +++ b/changelogs/fragments/trivial.yaml @@ -0,0 +1,3 @@ +--- +trivial: + - Fix erroneous doc updates in nxos_acls. diff --git a/docs/cisco.nxos.nxos_acls_module.rst b/docs/cisco.nxos.nxos_acls_module.rst index 1c8801e8b..8a4c23f3d 100644 --- a/docs/cisco.nxos.nxos_acls_module.rst +++ b/docs/cisco.nxos.nxos_acls_module.rst @@ -3111,46 +3111,89 @@ Examples # Before state: # ------------- - # + # nxos-9k# show running-config | section '^ip(v6)* access-list' - - name: Merge new ACLs configuration + - name: Merge provided ACLs configuration with device configuration cisco.nxos.nxos_acls: + state: merged config: - - afi: ipv4 - acls: - - name: ACL1v4 - aces: - - grant: deny - destination: - address: 192.0.2.64 - wildcard_bits: 0.0.0.255 - source: - any: true - port_protocol: - lt: 55 - protocol: tcp - protocol_options: - tcp: - ack: true - fin: true - sequence: 50 + - afi: ipv4 + acls: + - name: ACL1v4 + aces: + - grant: deny + destination: + address: 192.0.2.64 + wildcard_bits: 0.0.0.255 + source: + any: true + port_protocol: + lt: 55 + protocol: tcp + protocol_options: + tcp: + ack: true + fin: true + sequence: 50 + + - afi: ipv6 + acls: + - name: ACL1v6 + aces: + - grant: permit + sequence: 10 + source: + any: true + destination: + prefix: 2001:db8:12::/32 + protocol: sctp + + # Task Output + # ----------- + # before: [] + # + # commands: + # - ip access-list ACL1v4 + # - 50 deny tcp any lt 55 192.0.2.64 0.0.0.255 ack fin + # - ipv6 access-list ACL1v6 + # - 10 permit sctp any 2001:db8:12::/32 + # + # after: + # - acls: + # - aces: + # - destination: + # prefix: 2001:db8:12::/32 + # grant: permit + # protocol: sctp + # sequence: 10 + # source: + # any: true + # name: ACL1v6 + # afi: ipv6 + # - acls: + # - aces: + # - destination: + # address: 192.0.2.64 + # wildcard_bits: 0.0.0.255 + # grant: deny + # protocol: tcp + # protocol_options: + # tcp: + # ack: true + # fin: true + # sequence: 50 + # source: + # any: true + # port_protocol: + # lt: '55' + # name: ACL1v4 + # afi: ipv4 - - afi: ipv6 - acls: - - name: ACL1v6 - aces: - - grant: permit - sequence: 10 - source: - any: true - destination: - prefix: 2001:db8:12::/32 - protocol: sctp - state: merged # After state: # ------------ # + # nxos-9k# show running-config | section '^ip(v6)* access-list' # ip access-list ACL1v4 # 50 deny tcp any lt 55 192.0.2.64 0.0.0.255 ack fin # ipv6 access-list ACL1v6 @@ -3160,94 +3203,269 @@ Examples # Before state: # ---------------- - # + # nxos-9k# show running-config | section '^ip(v6)* access-list' # ip access-list ACL1v4 # 10 permit ip any any # 20 deny udp any any # ip access-list ACL2v4 # 10 permit ahp 192.0.2.0 0.0.0.255 any - # ip access-list ACL1v6 + # ipv6 access-list ACL1v6 # 10 permit sctp any any # 20 remark IPv6 ACL - # ip access-list ACL2v6 + # ipv6 access-list ACL2v6 # 10 deny ipv6 any 2001:db8:3000::/36 # 20 permit tcp 2001:db8:2000:2::2/128 2001:db8:2000:ab::2/128 - name: Replace existing ACL configuration with provided configuration cisco.nxos.nxos_acls: config: - - afi: ipv4 - - afi: ipv6 - acls: - - name: ACL1v6 - aces: - - sequence: 20 - grant: permit - source: - any: true - destination: - any: true - protocol: pip - - - remark: Replaced ACE - - - name: ACL2v6 + - afi: ipv4 + - afi: ipv6 + acls: + - name: ACL1v6 + aces: + - sequence: 20 + grant: permit + source: + any: true + destination: + any: true + protocol: pim + + - remark: Replaced ACE + - name: ACL2v6 state: replaced + # Task Output + # ----------- + # before: + # - acls: + # - aces: + # - destination: + # any: true + # grant: permit + # protocol: sctp + # sequence: 10 + # source: + # any: true + # - remark: IPv6 ACL + # sequence: 20 + # name: ACL1v6 + # - aces: + # - destination: + # prefix: 2001:db8:3000::/36 + # grant: deny + # protocol: ipv6 + # sequence: 10 + # source: + # any: true + # - destination: + # host: 2001:db8:2000:ab::2 + # grant: permit + # protocol: tcp + # sequence: 20 + # source: + # host: 2001:db8:2000:2::2 + # name: ACL2v6 + # afi: ipv6 + # - acls: + # - aces: + # - destination: + # any: true + # grant: permit + # protocol: ip + # sequence: 10 + # source: + # any: true + # - destination: + # any: true + # grant: deny + # protocol: udp + # sequence: 20 + # source: + # any: true + # name: ACL1v4 + # - aces: + # - destination: + # any: true + # grant: permit + # protocol: ahp + # sequence: 10 + # source: + # address: 192.0.2.0 + # wildcard_bits: 0.0.0.255 + # name: ACL2v4 + # afi: ipv4 + # + # commands: + # - no ip access-list ACL1v4 + # - no ip access-list ACL2v4 + # - ipv6 access-list ACL1v6 + # - no 10 permit sctp any any + # - no 20 remark IPv6 ACL + # - remark Replaced ACE + # - 20 permit pim any any + # - ipv6 access-list ACL2v6 + # - no 10 deny ipv6 any 2001:db8:3000::/36 + # - no 20 permit tcp host 2001:db8:2000:2::2 host 2001:db8:2000:ab::2 + # + # after: + # - acls: + # - aces: + # - remark: Replaced ACE + # sequence: 10 + # - destination: + # any: true + # grant: permit + # protocol: pim + # sequence: 20 + # source: + # any: true + # name: ACL1v6 + # - name: ACL2v6 + # afi: ipv6 + # After state: # --------------- - # + # nxos-9k# show running-config | section '^ip(v6)* access-list' # ipv6 access-list ACL1v6 - # 20 permit pip any any - # 30 remark Replaced ACE + # 10 remark Replaced ACE + # 20 permit pim any any # ipv6 access-list ACL2v6 # Using overridden # Before state: # ---------------- - # + # nxos-9k# show running-config | section '^ip(v6)* access-list' # ip access-list ACL1v4 # 10 permit ip any any # 20 deny udp any any # ip access-list ACL2v4 # 10 permit ahp 192.0.2.0 0.0.0.255 any - # ip access-list ACL1v6 + # ipv6 access-list ACL1v6 # 10 permit sctp any any # 20 remark IPv6 ACL - # ip access-list ACL2v6 + # ipv6 access-list ACL2v6 # 10 deny ipv6 any 2001:db8:3000::/36 # 20 permit tcp 2001:db8:2000:2::2/128 2001:db8:2000:ab::2/128 - name: Override existing configuration with provided configuration cisco.nxos.nxos_acls: config: - - afi: ipv4 - acls: - - name: NewACL - aces: - - grant: deny - source: - address: 192.0.2.0 - wildcard_bits: 0.0.255.255 - destination: - any: true - protocol: eigrp - - remark: Example for overridden state + - afi: ipv4 + acls: + - name: NewACL + aces: + - grant: deny + source: + address: 192.0.2.0 + wildcard_bits: 0.0.255.255 + destination: + any: true + protocol: eigrp + - remark: Example for overridden state state: overridden + # Task Output + # ----------- + # + # before: + # - acls: + # - aces: + # - destination: + # any: true + # grant: permit + # protocol: sctp + # sequence: 10 + # source: + # any: true + # - remark: IPv6 ACL + # sequence: 20 + # name: ACL1v6 + # - aces: + # - destination: + # prefix: 2001:db8:3000::/36 + # grant: deny + # protocol: ipv6 + # sequence: 10 + # source: + # any: true + # - destination: + # host: 2001:db8:2000:ab::2 + # grant: permit + # protocol: tcp + # sequence: 20 + # source: + # host: 2001:db8:2000:2::2 + # name: ACL2v6 + # afi: ipv6 + # - acls: + # - aces: + # - destination: + # any: true + # grant: permit + # protocol: ip + # sequence: 10 + # source: + # any: true + # - destination: + # any: true + # grant: deny + # protocol: udp + # sequence: 20 + # source: + # any: true + # name: ACL1v4 + # - aces: + # - destination: + # any: true + # grant: permit + # protocol: ahp + # sequence: 10 + # source: + # address: 192.0.2.0 + # wildcard_bits: 0.0.0.255 + # name: ACL2v4 + # afi: ipv4 + # + # commands: + # - no ipv6 access-list ACL1v6 + # - no ipv6 access-list ACL2v6 + # - no ip access-list ACL1v4 + # - no ip access-list ACL2v4 + # - ip access-list NewACL + # - deny eigrp 192.0.2.0 0.0.255.255 any + # - remark Example for overridden state + # + # after: + # - acls: + # - aces: + # - destination: + # any: true + # grant: deny + # protocol: eigrp + # sequence: 10 + # source: + # address: 192.0.2.0 + # wildcard_bits: 0.0.255.255 + # - remark: Example for overridden state + # sequence: 20 + # name: NewACL + # afi: ipv4 + # After state: # ------------ - # + # nxos-9k# show running-config | section '^ip(v6)* access-list' # ip access-list NewACL # 10 deny eigrp 192.0.2.0 0.0.255.255 any # 20 remark Example for overridden state - # Using deleted: + # Using deleted - delete all # # Before state: # ------------- - # + # nxos-9k# show running-config | section '^ip(v6)* access-list' # ip access-list ACL1v4 # 10 permit ip any any # 20 deny udp any any @@ -3262,17 +3480,89 @@ Examples - name: Delete all ACLs cisco.nxos.nxos_acls: - config: state: deleted + # Task Output + # ----------- + # + # before: + # - acls: + # - aces: + # - destination: + # any: true + # grant: permit + # protocol: sctp + # sequence: 10 + # source: + # any: true + # - remark: IPv6 ACL + # sequence: 20 + # name: ACL1v6 + # - aces: + # - destination: + # prefix: 2001:db8:3000::/36 + # grant: deny + # protocol: ipv6 + # sequence: 10 + # source: + # any: true + # - destination: + # host: 2001:db8:2000:ab::2 + # grant: permit + # protocol: tcp + # sequence: 20 + # source: + # host: 2001:db8:2000:2::2 + # name: ACL2v6 + # afi: ipv6 + # - acls: + # - aces: + # - destination: + # any: true + # grant: permit + # protocol: ip + # sequence: 10 + # source: + # any: true + # - destination: + # any: true + # grant: deny + # protocol: udp + # sequence: 20 + # source: + # any: true + # name: ACL1v4 + # - aces: + # - destination: + # any: true + # grant: permit + # protocol: ahp + # sequence: 10 + # source: + # address: 192.0.2.0 + # wildcard_bits: 0.0.0.255 + # name: ACL2v4 + # afi: ipv4 + # + # commands: + # - no ip access-list ACL1v4 + # - no ip access-list ACL2v4 + # - no ipv6 access-list ACL1v6 + # - no ipv6 access-list ACL2v6 + # + # after: [] + + # After state: # ----------- + # nxos-9k# show running-config | section '^ip(v6)* access-list' # + # Using deleted - delete AFI # Before state: # ------------- - # + # nxos-9k# show running-config | section '^ip(v6)* access-list' # ip access-list ACL1v4 # 10 permit ip any any # 20 deny udp any any @@ -3291,9 +3581,106 @@ Examples - afi: ipv4 state: deleted + # Task Output + # ----------- + # + # before: + # - acls: + # - aces: + # - destination: + # any: true + # grant: permit + # protocol: sctp + # sequence: 10 + # source: + # any: true + # - remark: IPv6 ACL + # sequence: 20 + # name: ACL1v6 + # - aces: + # - destination: + # prefix: 2001:db8:3000::/36 + # grant: deny + # protocol: ipv6 + # sequence: 10 + # source: + # any: true + # - destination: + # host: 2001:db8:2000:ab::2 + # grant: permit + # protocol: tcp + # sequence: 20 + # source: + # host: 2001:db8:2000:2::2 + # name: ACL2v6 + # afi: ipv6 + # - acls: + # - aces: + # - destination: + # any: true + # grant: permit + # protocol: ip + # sequence: 10 + # source: + # any: true + # - destination: + # any: true + # grant: deny + # protocol: udp + # sequence: 20 + # source: + # any: true + # name: ACL1v4 + # - aces: + # - destination: + # any: true + # grant: permit + # protocol: ahp + # sequence: 10 + # source: + # address: 192.0.2.0 + # wildcard_bits: 0.0.0.255 + # name: ACL2v4 + # afi: ipv4 + # + # commands: + # - no ip access-list ACL1v4 + # - no ip access-list ACL2v4 + # + # after: + # - acls: + # - aces: + # - destination: + # any: true + # grant: permit + # protocol: sctp + # sequence: 10 + # source: + # any: true + # - remark: IPv6 ACL + # sequence: 20 + # name: ACL1v6 + # - aces: + # - destination: + # prefix: 2001:db8:3000::/36 + # grant: deny + # protocol: ipv6 + # sequence: 10 + # source: + # any: true + # - destination: + # host: 2001:db8:2000:ab::2 + # grant: permit + # protocol: tcp + # sequence: 20 + # source: + # host: 2001:db8:2000:2::2 + # name: ACL2v6 + # afi: ipv6 + # After state: # ------------ - # + # nxos-9k# show running-config | section '^ip(v6)* access-list' # ip access-list ACL1v6 # 10 permit sctp any any # 20 remark IPv6 ACL @@ -3301,11 +3688,11 @@ Examples # 10 deny ipv6 any 2001:db8:3000::/36 # 20 permit tcp 2001:db8:2000:2::2/128 2001:db8:2000:ab::2/128 - + # Using deleted - delete ACLs # Before state: # ------------- - # + # nxos-9k# show running-config | section '^ip(v6)* access-list' # ip access-list ACL1v4 # 10 permit ip any any # 20 deny udp any any @@ -3320,18 +3707,106 @@ Examples - name: Delete specific ACLs cisco.nxos.nxos_acls: - config: - - afi: ipv4 - acls: - - name: ACL1v4 - - name: ACL2v4 - - afi: ipv6 - acls: - - name: ACL1v6 state: deleted + config: + - afi: ipv4 + acls: + - name: ACL1v4 + - name: ACL2v4 + - afi: ipv6 + acls: + - name: ACL1v6 + + # Task Output + # ----------- + # + # before: + # - acls: + # - aces: + # - destination: + # any: true + # grant: permit + # protocol: sctp + # sequence: 10 + # source: + # any: true + # - remark: IPv6 ACL + # sequence: 20 + # name: ACL1v6 + # - aces: + # - destination: + # prefix: 2001:db8:3000::/36 + # grant: deny + # protocol: ipv6 + # sequence: 10 + # source: + # any: true + # - destination: + # host: 2001:db8:2000:ab::2 + # grant: permit + # protocol: tcp + # sequence: 20 + # source: + # host: 2001:db8:2000:2::2 + # name: ACL2v6 + # afi: ipv6 + # - acls: + # - aces: + # - destination: + # any: true + # grant: permit + # protocol: ip + # sequence: 10 + # source: + # any: true + # - destination: + # any: true + # grant: deny + # protocol: udp + # sequence: 20 + # source: + # any: true + # name: ACL1v4 + # - aces: + # - destination: + # any: true + # grant: permit + # protocol: ahp + # sequence: 10 + # source: + # address: 192.0.2.0 + # wildcard_bits: 0.0.0.255 + # name: ACL2v4 + # afi: ipv4 + # + # commands: + # - no ip access-list ACL1v4 + # - no ip access-list ACL2v4 + # - no ipv6 access-list ACL1v6 + # + # after: + # - acls: + # - aces: + # - destination: + # prefix: 2001:db8:3000::/36 + # grant: deny + # protocol: ipv6 + # sequence: 10 + # source: + # any: true + # - destination: + # host: 2001:db8:2000:ab::2 + # grant: permit + # protocol: tcp + # sequence: 20 + # source: + # host: 2001:db8:2000:2::2 + # name: ACL2v6 + # afi: ipv6 # After state: # ------------ + # nxos-9k# show running-config | section '^ip(v6)* access-list' # ipv6 access-list ACL2v6 # 10 deny ipv6 any 2001:db8:3000::/36 # 20 permit tcp 2001:db8:2000:2::2/128 2001:db8:2000:ab::2/128 @@ -3347,7 +3822,9 @@ Examples 10 permit sctp any any state: parsed - # returns: + # Task Output + # ------------ + # # parsed: # - afi: ipv4 # acls: @@ -3385,7 +3862,7 @@ Examples # Before state: # ------------ - # + # nxos-9k# show running-config | section '^ip(v6)* access-list' # ip access-list ACL1v4 # 50 deny tcp any lt 55 192.0.2.64 0.0.0.255 ack fin # ipv6 access-list ACL1v6 @@ -3395,7 +3872,9 @@ Examples cisco.nxos.nxos_acls: state: gathered - # returns: + # Task Output + # ----------- + # # gathered: # - afi: ipv4 # acls: @@ -3466,7 +3945,9 @@ Examples protocol: sctp state: rendered - # returns: + # Task Output + # ----------- + # # rendered: # ip access-list ACL1v4 # 50 deny tcp any lt 55 192.0.2.64 0.0.0.255 ack fin @@ -3540,6 +4021,57 @@ Common return values are documented `here ['ip access-list ACL1v4', '10 permit ip any any precedence critical log', '20 deny tcp any lt smtp host 192.0.2.64 ack fin'] + + +
+ gathered + +
+ list +
+ + when state is gathered + +
Facts about the network resource gathered from the remote device as structured data.
+
+
Sample:
+
This output will always be in the same format as the module argspec.
+ + + + +
+ parsed + +
+ list +
+ + when state is parsed + +
The device native config provided in running_config option parsed into structured data as per module argspec.
+
+
Sample:
+
This output will always be in the same format as the module argspec.
+ + + + +
+ rendered + +
+ list +
+ + when state is rendered + +
The provided configuration in the task rendered in device-native format (offline).
+
+
Sample:
+
['ip access-list ACL1v4', '10 permit ip any any precedence critical log', '20 deny tcp any lt smtp host 192.0.2.64 ack fin']
+ +

diff --git a/docs/cisco.nxos.nxos_bgp_global_module.rst b/docs/cisco.nxos.nxos_bgp_global_module.rst index c75def25f..1ef0c27b4 100644 --- a/docs/cisco.nxos.nxos_bgp_global_module.rst +++ b/docs/cisco.nxos.nxos_bgp_global_module.rst @@ -1887,6 +1887,23 @@ Parameters
Specify Autonomous System Number of the neighbor.
+ + + + +
+ remote_as_route_map + +
+ string +
+ + + + +
Route-map to match prefix peer AS number.
+ + @@ -4002,6 +4019,24 @@ Parameters
Specify Autonomous System Number of the neighbor.
+ + + + + +
+ remote_as_route_map + +
+ string +
+ + + + +
Route-map to match prefix peer AS number.
+ + diff --git a/docs/cisco.nxos.nxos_bgp_neighbor_address_family_module.rst b/docs/cisco.nxos.nxos_bgp_neighbor_address_family_module.rst index 5148c878c..96e3c5e53 100644 --- a/docs/cisco.nxos.nxos_bgp_neighbor_address_family_module.rst +++ b/docs/cisco.nxos.nxos_bgp_neighbor_address_family_module.rst @@ -853,6 +853,28 @@ Parameters
Auto generate RTs for EBGP neighbor.
+ + + + + +
+ rewrite_rt_asn + +
+ boolean +
+ + +
    Choices: +
  • no
  • +
  • yes
  • +
+ + +
Auto generate RTs for EBGP neighbor.
+ + @@ -2073,6 +2095,29 @@ Parameters
Auto generate RTs for EBGP neighbor.
+ + + + + + +
+ rewrite_rt_asn + +
+ boolean +
+ + +
    Choices: +
  • no
  • +
  • yes
  • +
+ + +
Auto generate RTs for EBGP neighbor.
+ + diff --git a/docs/cisco.nxos.nxos_bgp_templates_module.rst b/docs/cisco.nxos.nxos_bgp_templates_module.rst index bae0c7318..9287d7a60 100644 --- a/docs/cisco.nxos.nxos_bgp_templates_module.rst +++ b/docs/cisco.nxos.nxos_bgp_templates_module.rst @@ -906,12 +906,36 @@ Parameters
  • unicast
  • multicast
  • mvpn
  • +
  • evpn
  • Sub Address Family indicator.
    + + + + + +
    + send_community + +
    + string +
    + + +
      Choices: +
    • standard
    • +
    • extended
    • +
    • both
    • +
    + + +
    Send Community attribute to this neighbor.
    + + diff --git a/docs/cisco.nxos.nxos_fc_interfaces_module.rst b/docs/cisco.nxos.nxos_fc_interfaces_module.rst new file mode 100644 index 000000000..eaad900f2 --- /dev/null +++ b/docs/cisco.nxos.nxos_fc_interfaces_module.rst @@ -0,0 +1,777 @@ +.. _cisco.nxos.nxos_fc_interfaces_module: + + +***************************** +cisco.nxos.nxos_fc_interfaces +***************************** + +**Fc Interfaces resource module** + + +Version added: 5.2.0 + +.. contents:: + :local: + :depth: 1 + + +Synopsis +-------- +- This module manages the interface attributes of NX-OS fc interfaces. + + + + +Parameters +---------- + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParameterChoices/DefaultsComments
    +
    + config + +
    + list + / elements=dictionary +
    +
    + +
    A dictionary of interface options
    +
    +
    + analytics + +
    + string +
    +
    +
      Choices: +
    • fc-scsi
    • +
    • fc-nvme
    • +
    • fc-all
    • +
    +
    +
    Analytics type on the fc interface
    +
    +
    + description + +
    + string +
    +
    + +
    Interface description.
    +
    +
    + enabled + +
    + boolean +
    +
    +
      Choices: +
    • no
    • +
    • yes
    • +
    +
    +
    Administrative state of the interface. Set the value to true to administratively enable the interface or false to disable it
    +
    +
    + mode + +
    + string +
    +
    +
      Choices: +
    • auto
    • +
    • E
    • +
    • F
    • +
    • Fx
    • +
    • NP
    • +
    • SD
    • +
    +
    +
    Port mode of the fc interface
    +
    +
    + name + +
    + string + / required +
    +
    + +
    Full name of interface, e.g. fc1/1, fc18/48
    +
    +
    + speed + +
    + string +
    +
    +
      Choices: +
    • auto
    • +
    • 1000
    • +
    • 2000
    • +
    • 4000
    • +
    • 8000
    • +
    • 10000
    • +
    • 16000
    • +
    • 32000
    • +
    • 64000
    • +
    • auto max 2000
    • +
    • auto max 4000
    • +
    • auto max 8000
    • +
    • auto max 16000
    • +
    • auto max 32000
    • +
    • auto max 64000
    • +
    +
    +
    Interface link speed.
    +
    +
    + trunk_mode + +
    + string +
    +
    +
      Choices: +
    • auto
    • +
    • on
    • +
    • off
    • +
    +
    +
    Trunk mode of the fc interface
    +
    +
    + running_config + +
    + string +
    +
    + +
    This option is used only with state parsed.
    +
    The value of this option should be the output received from the NX-OS device by executing the command show running-config interface
    +
    The state parsed reads the configuration from running_config option and transforms it into Ansible structured data as per the resource module's argspec and the value is then returned in the parsed key within the result.
    +
    +
    + state + +
    + string +
    +
    +
      Choices: +
    • merged ←
    • +
    • replaced
    • +
    • overridden
    • +
    • deleted
    • +
    • gathered
    • +
    • rendered
    • +
    • parsed
    • +
    +
    +
    The state of the configuration after module completion
    +
    +
    + + +Notes +----- + +.. note:: + - Tested against NXOS 9.3(2) on Cisco MDS Switches + + + +Examples +-------- + +.. code-block:: yaml + + # Using merged + + # Before state: + # ------------- + # + # switch# show running-config interface all + # interface fc18/10 + # analytics type fc-nvme + # switchport speed auto max 16000 + # switchport mode auto + # switchport description $ + # switchport trunk mode on + # shutdown + + - name: Merge provided configuration with device configuration + cisco.nxos.nxos_fc_interfaces: + config: + - name: fc18/10 + analytics: fc-scsi + state: merged + + # Task Output + # ----------- + # + # before: + # - name: fc18/10 + # speed: auto max 16000 + # mode: auto + # trunk_mode: on + # enabled: False + # description: $ + # analytics: fc-nvme + # commands: + # - interface fc18/10 + # - analytics type fc-scsi + # after: + # - name: fc18/10 + # speed: auto max 16000 + # mode: auto + # trunk_mode: on + # enabled: False + # description: $ + # analytics: fc-all + + # After state: + # ------------ + # + # switch# show running-config interface all + # interface fc18/10 + # analytics type fc-scsi + # analytics type fc-nvme + # switchport speed auto max 16000 + # switchport mode auto + # switchport description $ + # switchport trunk mode on + # shutdown + + # Using replaced + + # Before state: + # ------------- + # + # switch# show running-config interface all + # interface fc18/12 + # analytics type fc-scsi + # analytics type fc-nvme + # switchport speed auto max 64000 + # switchport mode auto + # switchport description 1 + # switchport trunk mode on + # no shutdown + + - name: Replaces device configuration of listed interfaces with provided configuration + cisco.nxos.nxos_fc_interfaces: + config: + - name: fc18/12 + speed: auto max 64000 + mode: auto + trunk_mode: on + enabled: True + description: 1 + analytics: fc-scsi + state: replaced + + # Task Output + # ----------- + # + # before: + # - name: fc18/12 + # speed: auto max 64000 + # mode: auto + # trunk_mode: on + # enabled: True + # description: 1 + # analytics: fc-all + # commands: + # - interface fc18/12 + # - no analytics type fc-all + # - analytics type fc-scsi + # after: + # - name: fc18/12 + # speed: auto max 64000 + # mode: auto + # trunk_mode: on + # enabled: True + # description: 1 + # analytics: fc-scsi + + # After state: + # ------------ + # + # switch# show running-config interface all + # interface fc18/12 + # analytics type fc-scsi + # switchport speed auto max 64000 + # switchport mode auto + # switchport description 1 + # switchport trunk mode on + # no shutdown + + + # Using deleted + + # Before state: + # ------------- + # + # switch# show running-config interface all + # interface fc1/2 + # switchport speed 1000 + # switchport mode E + # no switchport description + # switchport trunk mode off + # no shutdown + + - name: Delete or return interface parameters to default settings + cisco.nxos.nxos_fc_interfaces: + config: + - name: fc1/2 + state: deleted + + # Task Output + # ----------- + # + # before: + # - name: fc1/2 + # speed: 1000 + # mode: E + # trunk_mode: off + # enabled: True + # commands: + # - interface fc1/2 + # - no switchport speed 1000 + # - no switchport mode E + # - switchport trunk mode on + # - shutdown + # after: + # - name: fc1/2 + # speed: auto + # mode: auto + # trunk_mode: on + # enabled: False + + # After state: + # ------------ + # + # switch# show running-config interface all + # interface fc1/2 + # switchport speed auto + # switchport mode auto + # no switchport description + # switchport trunk mode on + # shutdown + + # Using overridden + + # Before state: + # ------------- + # + # switch# show running-config interface all + # interface fc18/12 + # analytics type fc-scsi + # analytics type fc-nvme + # switchport speed auto max 64000 + # switchport mode auto + # switchport description 1 + # switchport trunk mode on + # no shutdown + # interface fc18/13 + # analytics type fc-scsi + # analytics type fc-nvme + # switchport speed auto max 64000 + # switchport mode auto + # switchport description 1 + # switchport trunk mode on + # no shutdown + + - name: Replaces device configuration of listed interfaces with provided configuration + cisco.nxos.nxos_fc_interfaces: + config: + - name: fc18/12 + speed: auto max 64000 + mode: auto + trunk_mode: on + enabled: True + description: 1 + analytics: fc-scsi + state: overridden + + # Task Output + # ----------- + # + # before: + # - name: fc18/12 + # speed: auto max 64000 + # mode: auto + # trunk_mode: on + # enabled: True + # description: 1 + # analytics: fc-all + # - name: fc18/13 + # speed: auto max 64000 + # mode: auto + # trunk_mode: on + # enabled: True + # description: 1 + # analytics: fc-all + # commands: + # - interface fc18/12 + # no analytics type fc-all + # analytics type fc-scsi + # - interface fc18/13 + # no switchport description + # no switchport speed auto max 64000 + # no switchport mode auto + # switchport trunk mode on + # shutdown + # after: + # - name: fc18/12 + # speed: auto max 64000 + # mode: auto + # trunk_mode: on + # enabled: True + # description: 1 + # analytics: fc-scsi + # - name: fc18/13 + # speed: auto max 64000 + # mode: auto + # trunk_mode: on + # enabled: False + + # After state: + # ------------ + # + # switch# show running-config interface all + # interface fc18/12 + # analytics type fc-scsi + # switchport speed auto max 64000 + # switchport mode auto + # switchport description 1 + # switchport trunk mode on + # no shutdown + # interface fc18/13 + # switchport mode auto + # switchport trunk mode on + # shutdown + + + + + + + + # Using rendered + + - name: Use rendered state to convert task input to device specific commands + cisco.nxos.nxos_fc_interfaces: + config: + - name: fc1/1 + speed: auto + mode: auto + trunk_mode: on + enabled: True + description: This is a sample line + - name: fc1/2 + speed: 1000 + mode: E + trunk_mode: off + enabled: True + state: rendered + + # Task Output + # ----------- + # + # rendered: + # interface fc1/1 + # switchport speed auto + # switchport mode auto + # switchport description This is a sample line + # switchport trunk mode on + # no shutdown + # + # interface fc1/2 + # switchport speed 1000 + # switchport mode E + # no switchport description + # switchport trunk mode off + # no shutdown + + # Using parsed + + # parsed.cfg + # ------------ + # + # interface fc1/1 + # switchport speed auto + # switchport mode auto + # switchport description This is a sample line + # switchport trunk mode on + # no shutdown + # + # interface fc1/2 + # switchport speed 1000 + # switchport mode E + # no switchport description + # switchport trunk mode off + # no shutdown + + - name: Use parsed state to convert externally supplied config to structured format + cisco.nxos.nxos_fc_interfaces: + running_config: "{{ lookup('file', 'parsed.cfg') }}" + state: parsed + + # Task output + # ----------- + # + # parsed: + # - name: fc1/1 + # speed: auto + # mode: auto + # trunk_mode: on + # enabled: True + # description: This is a sample line + # - name: fc1/2 + # speed: 1000 + # mode: E + # trunk_mode: off + # enabled: True + + # Using gathered + + # Before state: + # ------------- + # + # switch# show running-config | section interface + # interface fc1/1 + # switchport speed auto + # switchport mode auto + # switchport description This is a sample line + # switchport trunk mode on + # no shutdown + # + # interface fc1/2 + # switchport speed 1000 + # switchport mode E + # no switchport description + # switchport trunk mode off + # no shutdown + # + - name: Gather interfaces facts from the device using nxos_fc_interfaces + cisco.nxos.nxos_fc_interfaces: + state: gathered + # + # Task output + # ----------- + # + # - name: fc1/1 + # speed: auto + # mode: auto + # trunk_mode: on + # enabled: True + # description: This is a sample line + # - name: fc1/2 + # speed: 1000 + # mode: E + # trunk_mode: off + # enabled: True + + + +Return Values +------------- +Common return values are documented `here `_, the following are the fields unique to this module: + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    KeyReturnedDescription
    +
    + after + +
    + dictionary +
    +
    when changed +
    The resulting configuration after module execution.
    +
    +
    Sample:
    +
    This output will always be in the same format as the module argspec.
    +
    +
    + before + +
    + dictionary +
    +
    when state is merged, replaced, overridden, deleted or purged +
    The configuration prior to the module execution.
    +
    +
    Sample:
    +
    This output will always be in the same format as the module argspec.
    +
    +
    + commands + +
    + list +
    +
    when state is merged, replaced, overridden, deleted or purged +
    The set of commands pushed to the remote device.
    +
    +
    Sample:
    +
    ['interface fc1/1', 'description sample description', 'shutdown']
    +
    +
    + gathered + +
    + list +
    +
    when state is gathered +
    Facts about the network resource gathered from the remote device as structured data.
    +
    +
    Sample:
    +
    This output will always be in the same format as the module argspec.
    +
    +
    + parsed + +
    + list +
    +
    when state is parsed +
    The device native config provided in running_config option parsed into structured data as per module argspec.
    +
    +
    Sample:
    +
    This output will always be in the same format as the module argspec.
    +
    +
    + rendered + +
    + list +
    +
    when state is rendered +
    The provided configuration in the task rendered in device-native format (offline).
    +
    +
    Sample:
    +
    ['interface fc1/1', 'description sample description', 'shutdown']
    +
    +

    + + +Status +------ + + +Authors +~~~~~~~ + +- Suhas Bharadwaj (@srbharadwaj) diff --git a/docs/cisco.nxos.nxos_route_maps_module.rst b/docs/cisco.nxos.nxos_route_maps_module.rst index 817967670..6ced43a16 100644 --- a/docs/cisco.nxos.nxos_route_maps_module.rst +++ b/docs/cisco.nxos.nxos_route_maps_module.rst @@ -1882,6 +1882,91 @@ Parameters
    Set BGP extcommunity list (for deletion).
    + + + + + +
    + extcommunity + +
    + dictionary +
    + + + + +
    Set BGP extcommunity attribute.
    + + + + + + + + +
    + rt + +
    + dictionary +
    + + + + +
    Route-Target.
    + + + + + + + + + +
    + additive + +
    + boolean +
    + + +
      Choices: +
    • no
    • +
    • yes
    • +
    + + +
    Add to existing rt extcommunity.
    + + + + + + + + + +
    + extcommunity_numbers + +
    + list + / elements=string +
    + + + + +
    Extcommunity number.
    +
    Supported formats are ASN2:NN, ASN4:NN, IPV4:NN.
    + + + + diff --git a/docs/cisco.nxos.nxos_vtp_version_module.rst b/docs/cisco.nxos.nxos_vtp_version_module.rst index 9271dbe28..996e950ff 100644 --- a/docs/cisco.nxos.nxos_vtp_version_module.rst +++ b/docs/cisco.nxos.nxos_vtp_version_module.rst @@ -47,6 +47,7 @@ Parameters
      Choices:
    • 1
    • 2
    • +
    • 3
    @@ -80,9 +81,6 @@ Examples # ENSURE VTP VERSION IS 2 - cisco.nxos.nxos_vtp_version: version: 2 - host: '{{ inventory_hostname }}' - username: '{{ un }}' - password: '{{ pwd }}' diff --git a/galaxy.yml b/galaxy.yml index 9d1c6b596..18cc93af2 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -10,4 +10,4 @@ readme: README.md repository: https://github.com/ansible-collections/cisco.nxos issues: https://github.com/ansible-collections/cisco.nxos/issues tags: [cisco, nxos, networking, nxapi, netconf] -version: 5.1.0 +version: 5.2.1 diff --git a/plugins/module_utils/network/nxos/argspec/bgp_global/bgp_global.py b/plugins/module_utils/network/nxos/argspec/bgp_global/bgp_global.py index bfe4e5d66..3f17ccebc 100644 --- a/plugins/module_utils/network/nxos/argspec/bgp_global/bgp_global.py +++ b/plugins/module_utils/network/nxos/argspec/bgp_global/bgp_global.py @@ -235,6 +235,7 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 ], }, "remote_as": {"type": "str"}, + "remote_as_route_map": {"type": "str"}, "remove_private_as": { "type": "dict", "options": { @@ -470,6 +471,7 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 ], }, "remote_as": {"type": "str"}, + "remote_as_route_map": {"type": "str"}, "remove_private_as": { "type": "dict", "options": { diff --git a/plugins/module_utils/network/nxos/argspec/bgp_neighbor_address_family/bgp_neighbor_address_family.py b/plugins/module_utils/network/nxos/argspec/bgp_neighbor_address_family/bgp_neighbor_address_family.py index 4c97d2946..397acb1f4 100644 --- a/plugins/module_utils/network/nxos/argspec/bgp_neighbor_address_family/bgp_neighbor_address_family.py +++ b/plugins/module_utils/network/nxos/argspec/bgp_neighbor_address_family/bgp_neighbor_address_family.py @@ -158,6 +158,7 @@ class Bgp_neighbor_address_familyArgs(object): # pylint: disable=R0903 }, }, "rewrite_evpn_rt_asn": {"type": "bool"}, + "rewrite_rt_asn": {"type": "bool"}, "route_map": { "type": "dict", "options": { @@ -325,6 +326,7 @@ class Bgp_neighbor_address_familyArgs(object): # pylint: disable=R0903 }, }, "rewrite_evpn_rt_asn": {"type": "bool"}, + "rewrite_rt_asn": {"type": "bool"}, "route_map": { "type": "dict", "options": { diff --git a/plugins/module_utils/network/nxos/argspec/bgp_templates/bgp_templates.py b/plugins/module_utils/network/nxos/argspec/bgp_templates/bgp_templates.py index b0b122158..22a6666e5 100644 --- a/plugins/module_utils/network/nxos/argspec/bgp_templates/bgp_templates.py +++ b/plugins/module_utils/network/nxos/argspec/bgp_templates/bgp_templates.py @@ -58,7 +58,7 @@ class Bgp_templatesArgs(object): # pylint: disable=R0903 }, "safi": { "type": "str", - "choices": ["unicast", "multicast", "mvpn"], + "choices": ["unicast", "multicast", "mvpn", "evpn"], }, "advertise_map": { "type": "dict", @@ -157,6 +157,10 @@ class Bgp_templatesArgs(object): # pylint: disable=R0903 }, }, "route_reflector_client": {"type": "bool"}, + "send_community": { + "type": "str", + "choices": ["standard", "extended", "both"], + }, "soft_reconfiguration_inbound": { "type": "dict", "options": { diff --git a/plugins/module_utils/network/nxos/argspec/fc_interfaces/__init__.py b/plugins/module_utils/network/nxos/argspec/fc_interfaces/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/plugins/module_utils/network/nxos/argspec/fc_interfaces/fc_interfaces.py b/plugins/module_utils/network/nxos/argspec/fc_interfaces/fc_interfaces.py new file mode 100644 index 000000000..5a58d99e0 --- /dev/null +++ b/plugins/module_utils/network/nxos/argspec/fc_interfaces/fc_interfaces.py @@ -0,0 +1,76 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Red Hat +# 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 + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the +# ansible.content_builder. +# +# Manually editing this file is not advised. +# +# To update the argspec make the desired changes +# in the documentation in the module file and re-run +# ansible.content_builder commenting out +# the path to external 'docstring' in build.yaml. +# +############################################## + +""" +The arg spec for the nxos_fc_interfaces module +""" +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.rm_templates.fc_interfaces import ( + allowed_port_modes, + allowed_speed_values, +) + + +class Fc_interfacesArgs(object): # pylint: disable=R0903 + """The arg spec for the nxos_fc_interfaces module""" + + argument_spec = { + "running_config": {"type": "str"}, + "config": { + "type": "list", + "elements": "dict", + "options": { + "name": {"type": "str", "required": True}, + "description": {"type": "str"}, + "enabled": {"type": "bool"}, + "speed": { + "choices": allowed_speed_values, + "type": "str", + }, + "mode": { + "choices": allowed_port_modes, + "type": "str", + }, + "trunk_mode": {"choices": ["auto", "on", "off"], "type": "str"}, + "analytics": { + "choices": ["fc-scsi", "fc-nvme", "fc-all"], + "type": "str", + }, + }, + }, + "state": { + "type": "str", + "choices": [ + "merged", + "replaced", + "overridden", + "deleted", + "gathered", + "rendered", + "parsed", + ], + "default": "merged", + }, + } # pylint: disable=C0301 diff --git a/plugins/module_utils/network/nxos/argspec/route_maps/route_maps.py b/plugins/module_utils/network/nxos/argspec/route_maps/route_maps.py index 5572b234e..14dfa5b05 100644 --- a/plugins/module_utils/network/nxos/argspec/route_maps/route_maps.py +++ b/plugins/module_utils/network/nxos/argspec/route_maps/route_maps.py @@ -323,6 +323,21 @@ class Route_mapsArgs(object): # pylint: disable=R0903 }, }, "extcomm_list": {"type": "str"}, + "extcommunity": { + "type": "dict", + "options": { + "rt": { + "type": "dict", + "options": { + "additive": {"type": "bool"}, + "extcommunity_numbers": { + "type": "list", + "elements": "str", + }, + }, + }, + }, + }, "forwarding_address": {"type": "bool"}, "null_interface": {"type": "str"}, "ip": { diff --git a/plugins/module_utils/network/nxos/config/bgp_global/bgp_global.py b/plugins/module_utils/network/nxos/config/bgp_global/bgp_global.py index edb6e59bb..fe738d1af 100644 --- a/plugins/module_utils/network/nxos/config/bgp_global/bgp_global.py +++ b/plugins/module_utils/network/nxos/config/bgp_global/bgp_global.py @@ -234,7 +234,7 @@ def _compare_neighbors(self, want, have, vrf=None): self.compare(parsers=nbr_parsers, want=entry, have=have_nbr) self._compare_path_attribute(entry, have_nbr) - if len(self.commands) != begin: + if len(self.commands) != begin or (entry and not have_nbr): self.commands.insert(begin, self._tmplt.render(entry, "neighbor_address", False)) # cleanup remaining neighbors diff --git a/plugins/module_utils/network/nxos/config/bgp_neighbor_address_family/bgp_neighbor_address_family.py b/plugins/module_utils/network/nxos/config/bgp_neighbor_address_family/bgp_neighbor_address_family.py index 96902987d..0ab282a6c 100644 --- a/plugins/module_utils/network/nxos/config/bgp_neighbor_address_family/bgp_neighbor_address_family.py +++ b/plugins/module_utils/network/nxos/config/bgp_neighbor_address_family/bgp_neighbor_address_family.py @@ -65,6 +65,7 @@ def __init__(self, module): "prefix_list.inbound", "prefix_list.outbound", "rewrite_evpn_rt_asn", + "rewrite_rt_asn", "route_map.inbound", "route_map.outbound", "route_reflector_client", diff --git a/plugins/module_utils/network/nxos/config/bgp_templates/bgp_templates.py b/plugins/module_utils/network/nxos/config/bgp_templates/bgp_templates.py index dc2f98d53..648db72e6 100644 --- a/plugins/module_utils/network/nxos/config/bgp_templates/bgp_templates.py +++ b/plugins/module_utils/network/nxos/config/bgp_templates/bgp_templates.py @@ -17,7 +17,6 @@ necessary to bring the current configuration to its desired end-state is created. """ - from copy import deepcopy from ansible.module_utils.six import iteritems @@ -92,6 +91,8 @@ def __init__(self, module): "prefix_list.outbound", "route_map.inbound", "route_map.outbound", + "send_community_standard", + "send_community_extended", "route_reflector_client", "soft_reconfiguration_inbound", "soo", @@ -190,6 +191,16 @@ def _afs_compare(self, want, have): self.commands.append(self._tmplt.render(hentry, "address_family", True)) def _af_compare(self, want, have): + # "unpack" send_community + for item in [want, have]: + send_comm_val = item.get("send_community", "") + if send_comm_val: + if send_comm_val == "both": + item["send_community_extended"] = True + item["send_community_standard"] = True + else: + key = "send_community_%s" % send_comm_val + item[key] = True self.compare(parsers=self.af_parsers, want=want, have=have) def _list_to_dict(self, data): diff --git a/plugins/module_utils/network/nxos/config/fc_interfaces/__init__.py b/plugins/module_utils/network/nxos/config/fc_interfaces/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/plugins/module_utils/network/nxos/config/fc_interfaces/fc_interfaces.py b/plugins/module_utils/network/nxos/config/fc_interfaces/fc_interfaces.py new file mode 100644 index 000000000..e08a9ce1b --- /dev/null +++ b/plugins/module_utils/network/nxos/config/fc_interfaces/fc_interfaces.py @@ -0,0 +1,202 @@ +# +# -*- coding: utf-8 -*- +# Copyright 2023 Red Hat +# 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 + +""" +The nxos_fc_interfaces config file. +It is in this file where the current configuration (as dict) +is compared to the provided configuration (as dict) and the command set +necessary to bring the current configuration to its desired end-state is +created. +""" + + +from ansible.module_utils.six import iteritems +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module import ( + ResourceModule, +) +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( + dict_merge, +) + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.facts import Facts +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.rm_templates.fc_interfaces import ( + Fc_interfacesTemplate, +) +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.utils.utils import ( + normalize_interface, +) + + +class Fc_interfaces(ResourceModule): + """ + The nxos_fc_interfaces config class + """ + + def __init__(self, module): + super(Fc_interfaces, self).__init__( + empty_fact_val={}, + facts_module=Facts(module, chassis_type="mds"), + module=module, + resource="fc_interfaces", + tmplt=Fc_interfacesTemplate(), + ) + self.parsers = ["description", "speed", "mode", "trunk_mode", "analytics"] + + def execute_module(self): + """Execute the module + + :rtype: A dictionary + :returns: The result from module execution + """ + if self.state not in ["parsed", "gathered"]: + self.generate_commands() + self.run_commands() + return self.result + + def generate_commands(self): + """Generate configuration commands to send based on + want, have and desired state. + """ + + wantd = {entry["name"]: entry for entry in self.want} + haved = {entry["name"]: entry for entry in self.have} + + for each in wantd, haved: + self.normalize_interface_names(each) + + # if state is merged, merge want onto have and then compare + if self.state == "merged": + wantd = dict_merge(haved, wantd) + + # if state is deleted, empty out wantd and set haved to wantd + if self.state == "deleted": + haved = {k: v for k, v in iteritems(haved) if k in wantd or not wantd} + wantd = {} + + # remove superfluous config for overridden and deleted + if self.state in ["overridden", "deleted"]: + for k, have in iteritems(haved): + if k not in wantd: + self._compare(want={}, have=have) + + for k, want in iteritems(wantd): + self._compare(want=want, have=haved.pop(k, {})) + + modified_list = [ + "switchport trunk mode on" if item.startswith("no switchport trunk mode") else item + for item in self.commands + ] + self.commands = modified_list + + def _calculate_ana_config(self, want_ana, have_ana): + """ + get the cmds based on want_ana and have_ana and the state + + Args: + want_ana (str): analytics type which you want + have_ana (str): analytics type which you have + + +----------+----------+---------+ + | MERGED | + |----------+----------+---------+ + | want_ana | have_ana | outcome | + +----------+----------+---------+ + | "" | * | no op | + | fc-scsi | * | fc-scsi | + | fc-scsi | fc-all | no op | + | fc-nvme | * | fc-nvme | + | fc-nvme | fc-all | no op | + +----------+----------+---------+ + + + +----------+----------+-----------+ + | DELETED | + |----------+----------+-----------+ + | want_ana | have_ana | outcome | + +----------+----------+-----------+ + | * | fc-scsi | no fc-all | + | * | fc-nvme | no fc-all | + | * | fc-all | no fc-all | + | * | "" | no op | + +----------+----------+-----------+ + + + +----------+----------+---------------------+ + | REPLACED/OVERRIDEN | + |----------+----------+---------------------+ + | want_ana | have_ana | outcome | + +----------+----------+---------------------+ + | "" | * | no fc-all | + | fc-scsi | "" | fc-scsi | + | fc-nvme | "" | fc-nvme | + | fc-all | "" | fc-all | + | fc-scsi | * | no fc-all ; fc-scsi | + | fc-nvme | * | no fc-all ; fc-nvme | + | fc-all | * | fc-all | + +----------+----------+---------------------+ + + + """ + + if want_ana == have_ana: + return [] + val = [] + if self.state in ["overridden", "replaced"]: + if want_ana == "": + val = ["no analytics type fc-all"] + elif want_ana == "fc-all": + val = ["analytics type fc-all"] + elif have_ana == "": + val = [f"analytics type {want_ana}"] + else: + val = ["no analytics type fc-all", f"analytics type {want_ana}"] + elif self.state in ["deleted"]: + if have_ana: + val = ["no analytics type fc-all"] + elif self.state in ["merged"]: + if want_ana: + if have_ana != "fc-all": + val = [f"analytics type {want_ana}"] + return val + + def _compare(self, want, have): + """Leverages the base class `compare()` method and + populates the list of commands to be run by comparing + the `want` and `have` data with the `parsers` defined + for the Fc_interfaces network resource. + """ + + begin = len(self.commands) + self.compare(parsers=self.parsers, want=want, have=have) + if want.get("enabled") != have.get("enabled"): + if want.get("enabled"): + self.addcmd(want, "enabled", True) + else: + if want: + self.addcmd(want, "enabled", False) + elif have.get("enabled"): + # handles deleted as want be blank and only + # negates if no shutdown + self.addcmd(have, "enabled", False) + + ana_cmds = self._calculate_ana_config(want.get("analytics", ""), have.get("analytics", "")) + + self.commands.extend(ana_cmds) + + if len(self.commands) != begin: + self.commands.insert(begin, self._tmplt.render(want or have, "interface", False)) + + def normalize_interface_names(self, param): + if param: + for _k, val in iteritems(param): + val["name"] = normalize_interface(val["name"]) + return param diff --git a/plugins/module_utils/network/nxos/config/lag_interfaces/lag_interfaces.py b/plugins/module_utils/network/nxos/config/lag_interfaces/lag_interfaces.py index 495244b41..fc3202a7f 100644 --- a/plugins/module_utils/network/nxos/config/lag_interfaces/lag_interfaces.py +++ b/plugins/module_utils/network/nxos/config/lag_interfaces/lag_interfaces.py @@ -238,6 +238,7 @@ def diff_list_of_dicts(self, want, have): delta = dict_diff(h_item, w_item) if delta: if h_item: + delta["exists"] = True if ( "mode" in delta.keys() and delta["mode"] == "on" @@ -270,19 +271,27 @@ def add_commands(self, diff, name): commands = [] name = name.strip("port-channel") for d in diff: - commands.append("interface" + " " + d["member"]) - cmd = "" + sub_cmd = "" + final_cmd = "" + member_exists = d.get("exists", False) group_cmd = "channel-group {0}".format(name) - if d.get("force"): - cmd = group_cmd + " force " + + # force does not appear in config + # will only be applied for a net new member + if d.get("force") and not member_exists: + sub_cmd += " force" if "mode" in d: - if cmd: - cmd = cmd + " mode " + d["mode"] - else: - cmd = group_cmd + " mode " + d["mode"] - if not cmd: - cmd = group_cmd - commands.append(cmd) + sub_cmd += " mode %s" % d["mode"] + + if sub_cmd: + final_cmd = group_cmd + sub_cmd + elif not member_exists: + final_cmd = group_cmd + + if final_cmd: + commands.append("interface" + " " + d["member"]) + commands.append(final_cmd) + return commands def set_commands(self, w, have): diff --git a/plugins/module_utils/network/nxos/config/route_maps/route_maps.py b/plugins/module_utils/network/nxos/config/route_maps/route_maps.py index 14a9037b6..fa7d57b1b 100644 --- a/plugins/module_utils/network/nxos/config/route_maps/route_maps.py +++ b/plugins/module_utils/network/nxos/config/route_maps/route_maps.py @@ -159,6 +159,7 @@ def _compare_entries(self, want, have): begin = len(self.commands) self._compare_lists(wentry, hentry) + self._compare_extcomm(wentry, hentry) self.compare(parsers=self.linear_parsers, want=wentry, have=hentry) if len(self.commands) != begin: @@ -173,6 +174,20 @@ def _compare_entries(self, want, have): for _hk, hentry in iteritems(have): self.commands.append(self._tmplt.render(hentry, "route_map", True)) + def _compare_extcomm(self, want, have): + hentry = get_from_dict(data_dict=have, keypath="set.extcommunity.rt") or {} + wentry = get_from_dict(data_dict=want, keypath="set.extcommunity.rt") or {} + + h_nums = set(hentry.get("extcommunity_numbers", [])) + w_nums = set(wentry.get("extcommunity_numbers", [])) + + if h_nums != w_nums or wentry.get("additive") != hentry.get("additive"): + if self.state not in ["merged", "rendered"]: + # need to explicitly remove existing entry to correctly apply new one + self.commands.append(self._tmplt.render(hentry, "set.extcommunity.rt", negate=True)) + # default CLI behaviour is to 'merge' with existing entry + self.commands.append(self._tmplt.render(wentry, "set.extcommunity.rt", negate=False)) + def _compare_lists(self, want, have): for x in self.complex_parsers: wx = get_from_dict(want, x) or [] diff --git a/plugins/module_utils/network/nxos/facts/acls/acls.py b/plugins/module_utils/network/nxos/facts/acls/acls.py index bc3aeffb3..ca086bcf9 100644 --- a/plugins/module_utils/network/nxos/facts/acls/acls.py +++ b/plugins/module_utils/network/nxos/facts/acls/acls.py @@ -46,7 +46,7 @@ def __init__(self, module, subspec="config", options="options"): self.generated_spec = utils.generate_dict(facts_argument_spec) def get_device_data(self, connection): - data = connection.get("show running-config | section 'ip(v6)* access-list'") + data = connection.get("show running-config | section '^ip(v6)* access-list'") if data == "{}": return "" return data @@ -125,7 +125,7 @@ def get_endpoint(self, ace, pro): ace = re.sub(port_pro.group(1), "", ace, 1) ace = re.sub(port_pro.group(2), "", ace, 1) else: - limit = re.search(r"range\s(?P\w+)\s(?P\w+)", ace) + limit = re.search(r"range\s(?P\S+)\s(?P\S+)", ace) if limit: rstart = limit.groupdict()["rstart"] rend = limit.groupdict()["rend"] diff --git a/plugins/module_utils/network/nxos/facts/bgp_global/bgp_global.py b/plugins/module_utils/network/nxos/facts/bgp_global/bgp_global.py index 621e499fd..9e149d8f6 100644 --- a/plugins/module_utils/network/nxos/facts/bgp_global/bgp_global.py +++ b/plugins/module_utils/network/nxos/facts/bgp_global/bgp_global.py @@ -29,7 +29,7 @@ class Bgp_globalFacts(object): """The nxos bgp_global facts class""" - def __init__(self, module, subspec="config", options="options"): + def __init__(self, module): self._module = module self.argument_spec = Bgp_globalArgs.argument_spec diff --git a/plugins/module_utils/network/nxos/facts/bgp_neighbor_address_family/bgp_neighbor_address_family.py b/plugins/module_utils/network/nxos/facts/bgp_neighbor_address_family/bgp_neighbor_address_family.py index e26c1826a..625ed5082 100644 --- a/plugins/module_utils/network/nxos/facts/bgp_neighbor_address_family/bgp_neighbor_address_family.py +++ b/plugins/module_utils/network/nxos/facts/bgp_neighbor_address_family/bgp_neighbor_address_family.py @@ -28,7 +28,7 @@ class Bgp_neighbor_address_familyFacts(object): """The nxos bgp_neighbor_address_family facts class""" - def __init__(self, module, subspec="config", options="options"): + def __init__(self, module): self._module = module self.argument_spec = Bgp_neighbor_address_familyArgs.argument_spec diff --git a/plugins/module_utils/network/nxos/facts/bgp_templates/bgp_templates.py b/plugins/module_utils/network/nxos/facts/bgp_templates/bgp_templates.py index 7cdb3018e..021e518a7 100644 --- a/plugins/module_utils/network/nxos/facts/bgp_templates/bgp_templates.py +++ b/plugins/module_utils/network/nxos/facts/bgp_templates/bgp_templates.py @@ -74,6 +74,17 @@ def populate_facts(self, connection, ansible_facts, data=None): if "address_family" in x: x["address_family"] = list(x["address_family"].values()) + for nbr in objs.get("neighbor", []): + for af in nbr.get("address_family", []): + std = af.pop("send_community_std", False) + ext = af.pop("send_community_ext", False) + if std and ext: + af["send_community"] = "both" + elif std: + af["send_community"] = "standard" + elif ext: + af["send_community"] = "extended" + ansible_facts["ansible_network_resources"].pop("bgp_templates", None) params = utils.remove_empties( diff --git a/plugins/module_utils/network/nxos/facts/facts.py b/plugins/module_utils/network/nxos/facts/facts.py index 4daaa6b75..a7c2ab350 100644 --- a/plugins/module_utils/network/nxos/facts/facts.py +++ b/plugins/module_utils/network/nxos/facts/facts.py @@ -37,6 +37,9 @@ from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.bgp_templates.bgp_templates import ( Bgp_templatesFacts, ) +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.fc_interfaces.fc_interfaces import ( + Fc_interfacesFacts, +) from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.hostname.hostname import ( HostnameFacts, ) @@ -149,6 +152,7 @@ bgp_templates=Bgp_templatesFacts, ) MDS_FACT_RESOURCE_SUBSETS = dict( + fc_interfaces=Fc_interfacesFacts, logging_global=Logging_globalFacts, ntp_global=Ntp_globalFacts, snmp_server=Snmp_serverFacts, diff --git a/plugins/module_utils/network/nxos/facts/fc_interfaces/__init__.py b/plugins/module_utils/network/nxos/facts/fc_interfaces/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/plugins/module_utils/network/nxos/facts/fc_interfaces/fc_interfaces.py b/plugins/module_utils/network/nxos/facts/fc_interfaces/fc_interfaces.py new file mode 100644 index 000000000..e9d85c086 --- /dev/null +++ b/plugins/module_utils/network/nxos/facts/fc_interfaces/fc_interfaces.py @@ -0,0 +1,103 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Red Hat +# 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 + +import operator +import re + +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import utils + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.fc_interfaces.fc_interfaces import ( + Fc_interfacesArgs, +) +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.rm_templates.fc_interfaces import ( + Fc_interfacesTemplate, +) + + +__metaclass__ = type + +""" +The nxos fc_interfaces fact class +It is in this file the configuration is collected from the device +for a given resource, parsed, and the facts tree is populated +based on the configuration. +""" + + +class Fc_interfacesFacts(object): + """The nxos fc_interfaces facts class""" + + def __init__(self, module, subspec="config", options="options"): + self._module = module + self.argument_spec = Fc_interfacesArgs.argument_spec + + def get_interfaces_data(self, connection): + return connection.get("show running-config interface all") + + def populate_facts(self, connection, ansible_facts, data=None): + """Populate the facts for Fc_interfaces network resource + + :param connection: the device connection + :param ansible_facts: Facts dictionary + :param data: previously collected conf + + :rtype: dictionary + :returns: facts + """ + facts = {} + objs = [] + + if not data: + data = self.get_interfaces_data(connection) + + # parse native config using the Fc_interfaces template + fc_interfaces_parser = Fc_interfacesTemplate(lines=data.splitlines(), module=self._module) + + objs = list(fc_interfaces_parser.parse().values()) + + # - populate only fc interfaces + # - populate "analytics" value based on the presence or absense of "analytics_nvme" or "analytics_scsi" keys + # - dummy key "m" and "p" is added for sorting, which is removed after sorting + modified_objs = [] + # match only fc interface + regex = re.compile(r"^fc\d+\S+") + for parsed_data in objs: + if not re.match(regex, parsed_data["name"]): + continue + m, p = parsed_data["name"].strip("fc").split("/") + parsed_data["m"] = int(m) + parsed_data["p"] = int(p) + + if "analytics_scsi" in parsed_data: + parsed_data.pop("analytics_scsi") + if "analytics_nvme" in parsed_data: + parsed_data.pop("analytics_nvme") + parsed_data["analytics"] = "fc-all" + else: + parsed_data["analytics"] = "fc-scsi" + else: + if "analytics_nvme" in parsed_data: + parsed_data.pop("analytics_nvme") + parsed_data["analytics"] = "fc-nvme" + modified_objs.append(parsed_data) + + sorted_dict = sorted(modified_objs, key=operator.itemgetter("m", "p")) + objs = [ + {key: value for key, value in eachdict.items() if key not in ["m", "p"]} + for eachdict in sorted_dict + ] + + ansible_facts["ansible_network_resources"].pop("fc_interfaces", None) + + params = utils.remove_empties( + fc_interfaces_parser.validate_config(self.argument_spec, {"config": objs}, redact=True), + ) + + facts["fc_interfaces"] = params.get("config", []) + ansible_facts["ansible_network_resources"].update(facts) + + return ansible_facts diff --git a/plugins/module_utils/network/nxos/rm_templates/bgp_global.py b/plugins/module_utils/network/nxos/rm_templates/bgp_global.py index d2ca65aad..255ba7db2 100644 --- a/plugins/module_utils/network/nxos/rm_templates/bgp_global.py +++ b/plugins/module_utils/network/nxos/rm_templates/bgp_global.py @@ -634,10 +634,12 @@ def __init__(self, lines=None, module=None): "getval": re.compile( r""" \s+neighbor\s(?P\S+) + (\sremote-as\sroute-map\s(?P\S+))? (\sremote-as\s(?P\S+))? $""", re.VERBOSE, ), - "setval": "neighbor {{ neighbor_address }}", + "setval": "neighbor {{ neighbor_address }}" + "{{ (' remote-as route-map ' + remote_as_route_map) if remote_as_route_map|d(None) else '' }}", "result": { "vrfs": { '{{ "vrf_" + vrf|d() }}': { @@ -645,6 +647,7 @@ def __init__(self, lines=None, module=None): "{{ neighbor_address }}": { "neighbor_address": "{{ neighbor_address }}", "remote_as": "{{ remote_as }}", + "remote_as_route_map": "{{ remote_as_route_map }}", }, }, }, @@ -808,6 +811,7 @@ def __init__(self, lines=None, module=None): "getval": re.compile( r""" \s+neighbor\s(?P\S+) + (\sremote-as\sroute-map\s\S+)? \sdescription\s(?P\S+) $""", re.VERBOSE, ), diff --git a/plugins/module_utils/network/nxos/rm_templates/bgp_neighbor_address_family.py b/plugins/module_utils/network/nxos/rm_templates/bgp_neighbor_address_family.py index 26dad82af..7db4b860d 100644 --- a/plugins/module_utils/network/nxos/rm_templates/bgp_neighbor_address_family.py +++ b/plugins/module_utils/network/nxos/rm_templates/bgp_neighbor_address_family.py @@ -616,6 +616,32 @@ def __init__(self, lines=None): }, }, }, + { + "name": "rewrite_rt_asn", + "getval": re.compile( + r""" + (?Prewrite-rt-asn) + $""", + re.VERBOSE, + ), + "setval": "rewrite-rt-asn", + "result": { + "vrfs": { + "{{ 'vrf_' + vrf|d() }}": { + "vrf": "{{ vrf }}", + "neighbors": { + "{{ neighbor }}": { + "address_family": { + '{{ afi + "_" + safi|d() }}': { + "rewrite_rt_asn": "{{ not not rewrite_rt_asn }}", + }, + }, + }, + }, + }, + }, + }, + }, { "name": "route_map.inbound", "getval": re.compile( diff --git a/plugins/module_utils/network/nxos/rm_templates/bgp_templates.py b/plugins/module_utils/network/nxos/rm_templates/bgp_templates.py index 9628fdeca..7e7bb5828 100644 --- a/plugins/module_utils/network/nxos/rm_templates/bgp_templates.py +++ b/plugins/module_utils/network/nxos/rm_templates/bgp_templates.py @@ -1053,6 +1053,48 @@ def __init__(self, lines=None, module=None): }, }, }, + { + "name": "send_community_standard", + "getval": re.compile( + r""" + (?Psend-community) + $""", + re.VERBOSE, + ), + "setval": "send-community", + "result": { + "neighbor": { + "{{ name }}": { + "address_family": { + '{{ afi + "_" + safi|d() }}': { + "send_community_std": "{{ not not send_community_std }}", + }, + }, + }, + }, + }, + }, + { + "name": "send_community_extended", + "getval": re.compile( + r""" + (?Psend-community\sextended) + $""", + re.VERBOSE, + ), + "setval": "send-community extended", + "result": { + "neighbor": { + "{{ name }}": { + "address_family": { + '{{ afi + "_" + safi|d() }}': { + "send_community_ext": "{{ not not send_community_ext }}", + }, + }, + }, + }, + }, + }, { "name": "soft_reconfiguration_inbound", "getval": re.compile( diff --git a/plugins/module_utils/network/nxos/rm_templates/fc_interfaces.py b/plugins/module_utils/network/nxos/rm_templates/fc_interfaces.py new file mode 100644 index 000000000..1cc9d5973 --- /dev/null +++ b/plugins/module_utils/network/nxos/rm_templates/fc_interfaces.py @@ -0,0 +1,194 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Red Hat +# 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 + +""" +The Fc_interfaces parser templates file. This contains +a list of parser definitions and associated functions that +facilitates both facts gathering and native command generation for +the given network resource. +""" + +import re + +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.network_template import ( + NetworkTemplate, +) + + +allowed_speed_values = [ + "auto", + "1000", + "2000", + "4000", + "8000", + "10000", + "16000", + "32000", + "64000", + "auto max 2000", + "auto max 4000", + "auto max 8000", + "auto max 16000", + "auto max 32000", + "auto max 64000", +] + +allowed_port_modes = [ + "auto", + "E", + "F", + "Fx", + "NP", + "SD", +] + +allowed_values_pattern = "|".join(re.escape(val) for val in allowed_speed_values) + + +class Fc_interfacesTemplate(NetworkTemplate): + def __init__(self, lines=None, module=None): + super(Fc_interfacesTemplate, self).__init__(lines=lines, tmplt=self, module=module) + + # fmt: off + PARSERS = [ + { + "name": "interface", + "getval": re.compile( + r""" + ^interface\s + (?P\S+)$""", re.VERBOSE, + ), + "setval": "interface {{ name }}", + "result": { + "{{ name }}": { + "name": "{{ name }}", + }, + }, + "shared": True, + }, + { + "name": "description", + "getval": re.compile( + r""" + \s+switchport\s+description\s+(?P.*) + $""", re.VERBOSE, + ), + "setval": "switchport description {{ description }}", + "remval": "switchport description", + "result": { + "{{ name }}": { + "description": "{{ description }}", + }, + }, + }, + { + "name": "enabled", + "getval": re.compile( + r""" + (?P\s+no)? + (?P\s+shutdown) + $""", re.VERBOSE, + ), + "setval": "shutdown", + "result": { + "{{ name }}": { + "enabled": "{{ False if shutdown is defined and negate is not defined else True }}", + }, + }, + }, + { + "name": "speed", + "getval": re.compile( + rf"""\s+switchport\s+speed\s+(?P{allowed_values_pattern})$""", re.VERBOSE, + ), + "setval": "switchport speed {{ speed|string }}", + "result": { + "{{ name }}": { + "speed": "{{ speed|string }}", + }, + }, + }, + { + "name": "mode", + "getval": re.compile( + r""" + \s+switchport\s+mode\s+(?P\S+) + $""", re.VERBOSE, + ), + "setval": "switchport mode {{ mode|string }}", + "result": { + "{{ name }}": { + "mode": "{{ mode }}", + }, + }, + }, + { + "name": "trunk_mode", + "getval": re.compile( + r""" + \s+switchport\s+trunk\s+mode\s+(?P\S+) + $""", re.VERBOSE, + ), + "setval": "switchport trunk mode {{ trunk_mode|string }}", + "result": { + "{{ name }}": { + "trunk_mode": "{{ trunk_mode }}", + }, + }, + }, + + { + "name": "analytics_scsi", + "getval": re.compile( + r""" + (?P\s+no)? + \s+analytics\s+type\s+(?Pfc-scsi) + $""", re.VERBOSE, + ), + "setval": "analytics type {{ analytics_scsi|string }}", + "result": { + "{{ name }}": { + "analytics_scsi": "{{ analytics_scsi }}", + }, + }, + }, + { + "name": "analytics_nvme", + "getval": re.compile( + r""" + (?P\s+no)? + \s+analytics\s+type\s+(?Pfc-nvme) + $""", re.VERBOSE, + ), + "setval": "analytics type {{ analytics_nvme|string }}", + "result": { + "{{ name }}": { + "analytics_nvme": "{{ analytics_nvme }}", + }, + }, + }, + + { + "name": "analytics", + "getval": re.compile( + r""" + \s+analytics\s+type\s+(?P\S+) + $""", re.VERBOSE, + ), + # "setval": "analytics type {{ analytics|string }}", + "setval": "", + "result": { + "{{ name }}": { + "analytics": "{{ analytics }}", + }, + }, + }, + ] + # fmt: on diff --git a/plugins/module_utils/network/nxos/rm_templates/route_maps.py b/plugins/module_utils/network/nxos/rm_templates/route_maps.py index cf8f89507..7e876682a 100644 --- a/plugins/module_utils/network/nxos/rm_templates/route_maps.py +++ b/plugins/module_utils/network/nxos/rm_templates/route_maps.py @@ -22,6 +22,17 @@ ) +def _tmplt_set_extcomm_rt(data): + cmd = "set extcommunity rt" + extcomm_numbers = " ".join(data.get("extcommunity_numbers", [])) + if extcomm_numbers: + cmd += " " + extcomm_numbers + if data.get("additive"): + cmd += " additive" + + return cmd + + def _tmplt_match_ip_multicast(data): cmd = "match ip multicast" multicast = data["match"]["ip"]["multicast"] @@ -1019,6 +1030,34 @@ def __init__(self, lines=None, module=None): }, }, }, + { + "name": "set.extcommunity.rt", + "getval": re.compile( + r""" + \s+set\sextcommunity\srt + (?P(\s\S+:\S+)*)? + (\s(?Padditive))? + \s*$""", re.VERBOSE, + ), + "setval": _tmplt_set_extcomm_rt, + "result": { + "{{ route_map }}": { + "entries": { + "{{ sequence }}": { + "set": { + "extcommunity": { + "rt": { + "additive": "{{ not not additive }}", + "extcommunity_numbers": + "{{ extcommunity_numbers.strip().split(' ') if extcommunity_numbers|d('') else None }}", + }, + }, + }, + }, + }, + }, + }, + }, { "name": "set.forwarding_address", "getval": re.compile( diff --git a/plugins/module_utils/network/nxos/rm_templates/snmp_server.py b/plugins/module_utils/network/nxos/rm_templates/snmp_server.py index be25452df..35451a47b 100644 --- a/plugins/module_utils/network/nxos/rm_templates/snmp_server.py +++ b/plugins/module_utils/network/nxos/rm_templates/snmp_server.py @@ -1487,6 +1487,7 @@ def __init__(self, lines=None, module=None): $""", re.VERBOSE, ), "setval": _tmplt_users_auth, + "remval": "snmp-server user {{ user }}", "result": { "users": { "auth": [ diff --git a/plugins/modules/nxos_acls.py b/plugins/modules/nxos_acls.py index 51a665047..133bd3a44 100644 --- a/plugins/modules/nxos_acls.py +++ b/plugins/modules/nxos_acls.py @@ -507,46 +507,89 @@ # Before state: # ------------- -# +# nxos-9k# show running-config | section '^ip(v6)* access-list' -- name: Merge new ACLs configuration +- name: Merge provided ACLs configuration with device configuration cisco.nxos.nxos_acls: + state: merged config: - - afi: ipv4 - acls: - - name: ACL1v4 - aces: - - grant: deny - destination: - address: 192.0.2.64 - wildcard_bits: 0.0.0.255 - source: - any: true - port_protocol: - lt: 55 - protocol: tcp - protocol_options: - tcp: - ack: true - fin: true - sequence: 50 + - afi: ipv4 + acls: + - name: ACL1v4 + aces: + - grant: deny + destination: + address: 192.0.2.64 + wildcard_bits: 0.0.0.255 + source: + any: true + port_protocol: + lt: 55 + protocol: tcp + protocol_options: + tcp: + ack: true + fin: true + sequence: 50 + + - afi: ipv6 + acls: + - name: ACL1v6 + aces: + - grant: permit + sequence: 10 + source: + any: true + destination: + prefix: 2001:db8:12::/32 + protocol: sctp + +# Task Output +# ----------- +# before: [] +# +# commands: +# - ip access-list ACL1v4 +# - 50 deny tcp any lt 55 192.0.2.64 0.0.0.255 ack fin +# - ipv6 access-list ACL1v6 +# - 10 permit sctp any 2001:db8:12::/32 +# +# after: +# - acls: +# - aces: +# - destination: +# prefix: 2001:db8:12::/32 +# grant: permit +# protocol: sctp +# sequence: 10 +# source: +# any: true +# name: ACL1v6 +# afi: ipv6 +# - acls: +# - aces: +# - destination: +# address: 192.0.2.64 +# wildcard_bits: 0.0.0.255 +# grant: deny +# protocol: tcp +# protocol_options: +# tcp: +# ack: true +# fin: true +# sequence: 50 +# source: +# any: true +# port_protocol: +# lt: '55' +# name: ACL1v4 +# afi: ipv4 - - afi: ipv6 - acls: - - name: ACL1v6 - aces: - - grant: permit - sequence: 10 - source: - any: true - destination: - prefix: 2001:db8:12::/32 - protocol: sctp - state: merged # After state: # ------------ # +# nxos-9k# show running-config | section '^ip(v6)* access-list' # ip access-list ACL1v4 # 50 deny tcp any lt 55 192.0.2.64 0.0.0.255 ack fin # ipv6 access-list ACL1v6 @@ -556,94 +599,269 @@ # Before state: # ---------------- -# +# nxos-9k# show running-config | section '^ip(v6)* access-list' # ip access-list ACL1v4 # 10 permit ip any any # 20 deny udp any any # ip access-list ACL2v4 # 10 permit ahp 192.0.2.0 0.0.0.255 any -# ip access-list ACL1v6 +# ipv6 access-list ACL1v6 # 10 permit sctp any any # 20 remark IPv6 ACL -# ip access-list ACL2v6 +# ipv6 access-list ACL2v6 # 10 deny ipv6 any 2001:db8:3000::/36 # 20 permit tcp 2001:db8:2000:2::2/128 2001:db8:2000:ab::2/128 - name: Replace existing ACL configuration with provided configuration cisco.nxos.nxos_acls: config: - - afi: ipv4 - - afi: ipv6 - acls: - - name: ACL1v6 - aces: - - sequence: 20 - grant: permit - source: - any: true - destination: - any: true - protocol: pip - - - remark: Replaced ACE + - afi: ipv4 + - afi: ipv6 + acls: + - name: ACL1v6 + aces: + - sequence: 20 + grant: permit + source: + any: true + destination: + any: true + protocol: pim - - name: ACL2v6 + - remark: Replaced ACE + - name: ACL2v6 state: replaced +# Task Output +# ----------- +# before: +# - acls: +# - aces: +# - destination: +# any: true +# grant: permit +# protocol: sctp +# sequence: 10 +# source: +# any: true +# - remark: IPv6 ACL +# sequence: 20 +# name: ACL1v6 +# - aces: +# - destination: +# prefix: 2001:db8:3000::/36 +# grant: deny +# protocol: ipv6 +# sequence: 10 +# source: +# any: true +# - destination: +# host: 2001:db8:2000:ab::2 +# grant: permit +# protocol: tcp +# sequence: 20 +# source: +# host: 2001:db8:2000:2::2 +# name: ACL2v6 +# afi: ipv6 +# - acls: +# - aces: +# - destination: +# any: true +# grant: permit +# protocol: ip +# sequence: 10 +# source: +# any: true +# - destination: +# any: true +# grant: deny +# protocol: udp +# sequence: 20 +# source: +# any: true +# name: ACL1v4 +# - aces: +# - destination: +# any: true +# grant: permit +# protocol: ahp +# sequence: 10 +# source: +# address: 192.0.2.0 +# wildcard_bits: 0.0.0.255 +# name: ACL2v4 +# afi: ipv4 +# +# commands: +# - no ip access-list ACL1v4 +# - no ip access-list ACL2v4 +# - ipv6 access-list ACL1v6 +# - no 10 permit sctp any any +# - no 20 remark IPv6 ACL +# - remark Replaced ACE +# - 20 permit pim any any +# - ipv6 access-list ACL2v6 +# - no 10 deny ipv6 any 2001:db8:3000::/36 +# - no 20 permit tcp host 2001:db8:2000:2::2 host 2001:db8:2000:ab::2 +# +# after: +# - acls: +# - aces: +# - remark: Replaced ACE +# sequence: 10 +# - destination: +# any: true +# grant: permit +# protocol: pim +# sequence: 20 +# source: +# any: true +# name: ACL1v6 +# - name: ACL2v6 +# afi: ipv6 + # After state: # --------------- -# +# nxos-9k# show running-config | section '^ip(v6)* access-list' # ipv6 access-list ACL1v6 -# 20 permit pip any any -# 30 remark Replaced ACE +# 10 remark Replaced ACE +# 20 permit pim any any # ipv6 access-list ACL2v6 # Using overridden # Before state: # ---------------- -# +# nxos-9k# show running-config | section '^ip(v6)* access-list' # ip access-list ACL1v4 # 10 permit ip any any # 20 deny udp any any # ip access-list ACL2v4 # 10 permit ahp 192.0.2.0 0.0.0.255 any -# ip access-list ACL1v6 +# ipv6 access-list ACL1v6 # 10 permit sctp any any # 20 remark IPv6 ACL -# ip access-list ACL2v6 +# ipv6 access-list ACL2v6 # 10 deny ipv6 any 2001:db8:3000::/36 # 20 permit tcp 2001:db8:2000:2::2/128 2001:db8:2000:ab::2/128 - name: Override existing configuration with provided configuration cisco.nxos.nxos_acls: config: - - afi: ipv4 - acls: - - name: NewACL - aces: - - grant: deny - source: - address: 192.0.2.0 - wildcard_bits: 0.0.255.255 - destination: - any: true - protocol: eigrp - - remark: Example for overridden state + - afi: ipv4 + acls: + - name: NewACL + aces: + - grant: deny + source: + address: 192.0.2.0 + wildcard_bits: 0.0.255.255 + destination: + any: true + protocol: eigrp + - remark: Example for overridden state state: overridden +# Task Output +# ----------- +# +# before: +# - acls: +# - aces: +# - destination: +# any: true +# grant: permit +# protocol: sctp +# sequence: 10 +# source: +# any: true +# - remark: IPv6 ACL +# sequence: 20 +# name: ACL1v6 +# - aces: +# - destination: +# prefix: 2001:db8:3000::/36 +# grant: deny +# protocol: ipv6 +# sequence: 10 +# source: +# any: true +# - destination: +# host: 2001:db8:2000:ab::2 +# grant: permit +# protocol: tcp +# sequence: 20 +# source: +# host: 2001:db8:2000:2::2 +# name: ACL2v6 +# afi: ipv6 +# - acls: +# - aces: +# - destination: +# any: true +# grant: permit +# protocol: ip +# sequence: 10 +# source: +# any: true +# - destination: +# any: true +# grant: deny +# protocol: udp +# sequence: 20 +# source: +# any: true +# name: ACL1v4 +# - aces: +# - destination: +# any: true +# grant: permit +# protocol: ahp +# sequence: 10 +# source: +# address: 192.0.2.0 +# wildcard_bits: 0.0.0.255 +# name: ACL2v4 +# afi: ipv4 +# +# commands: +# - no ipv6 access-list ACL1v6 +# - no ipv6 access-list ACL2v6 +# - no ip access-list ACL1v4 +# - no ip access-list ACL2v4 +# - ip access-list NewACL +# - deny eigrp 192.0.2.0 0.0.255.255 any +# - remark Example for overridden state +# +# after: +# - acls: +# - aces: +# - destination: +# any: true +# grant: deny +# protocol: eigrp +# sequence: 10 +# source: +# address: 192.0.2.0 +# wildcard_bits: 0.0.255.255 +# - remark: Example for overridden state +# sequence: 20 +# name: NewACL +# afi: ipv4 + # After state: # ------------ -# +# nxos-9k# show running-config | section '^ip(v6)* access-list' # ip access-list NewACL # 10 deny eigrp 192.0.2.0 0.0.255.255 any # 20 remark Example for overridden state -# Using deleted: +# Using deleted - delete all # # Before state: # ------------- -# +# nxos-9k# show running-config | section '^ip(v6)* access-list' # ip access-list ACL1v4 # 10 permit ip any any # 20 deny udp any any @@ -658,17 +876,89 @@ - name: Delete all ACLs cisco.nxos.nxos_acls: - config: state: deleted +# Task Output +# ----------- +# +# before: +# - acls: +# - aces: +# - destination: +# any: true +# grant: permit +# protocol: sctp +# sequence: 10 +# source: +# any: true +# - remark: IPv6 ACL +# sequence: 20 +# name: ACL1v6 +# - aces: +# - destination: +# prefix: 2001:db8:3000::/36 +# grant: deny +# protocol: ipv6 +# sequence: 10 +# source: +# any: true +# - destination: +# host: 2001:db8:2000:ab::2 +# grant: permit +# protocol: tcp +# sequence: 20 +# source: +# host: 2001:db8:2000:2::2 +# name: ACL2v6 +# afi: ipv6 +# - acls: +# - aces: +# - destination: +# any: true +# grant: permit +# protocol: ip +# sequence: 10 +# source: +# any: true +# - destination: +# any: true +# grant: deny +# protocol: udp +# sequence: 20 +# source: +# any: true +# name: ACL1v4 +# - aces: +# - destination: +# any: true +# grant: permit +# protocol: ahp +# sequence: 10 +# source: +# address: 192.0.2.0 +# wildcard_bits: 0.0.0.255 +# name: ACL2v4 +# afi: ipv4 +# +# commands: +# - no ip access-list ACL1v4 +# - no ip access-list ACL2v4 +# - no ipv6 access-list ACL1v6 +# - no ipv6 access-list ACL2v6 +# +# after: [] + + # After state: # ----------- +# nxos-9k# show running-config | section '^ip(v6)* access-list' # +# Using deleted - delete AFI # Before state: # ------------- -# +# nxos-9k# show running-config | section '^ip(v6)* access-list' # ip access-list ACL1v4 # 10 permit ip any any # 20 deny udp any any @@ -687,9 +977,106 @@ - afi: ipv4 state: deleted +# Task Output +# ----------- +# +# before: +# - acls: +# - aces: +# - destination: +# any: true +# grant: permit +# protocol: sctp +# sequence: 10 +# source: +# any: true +# - remark: IPv6 ACL +# sequence: 20 +# name: ACL1v6 +# - aces: +# - destination: +# prefix: 2001:db8:3000::/36 +# grant: deny +# protocol: ipv6 +# sequence: 10 +# source: +# any: true +# - destination: +# host: 2001:db8:2000:ab::2 +# grant: permit +# protocol: tcp +# sequence: 20 +# source: +# host: 2001:db8:2000:2::2 +# name: ACL2v6 +# afi: ipv6 +# - acls: +# - aces: +# - destination: +# any: true +# grant: permit +# protocol: ip +# sequence: 10 +# source: +# any: true +# - destination: +# any: true +# grant: deny +# protocol: udp +# sequence: 20 +# source: +# any: true +# name: ACL1v4 +# - aces: +# - destination: +# any: true +# grant: permit +# protocol: ahp +# sequence: 10 +# source: +# address: 192.0.2.0 +# wildcard_bits: 0.0.0.255 +# name: ACL2v4 +# afi: ipv4 +# +# commands: +# - no ip access-list ACL1v4 +# - no ip access-list ACL2v4 +# +# after: +# - acls: +# - aces: +# - destination: +# any: true +# grant: permit +# protocol: sctp +# sequence: 10 +# source: +# any: true +# - remark: IPv6 ACL +# sequence: 20 +# name: ACL1v6 +# - aces: +# - destination: +# prefix: 2001:db8:3000::/36 +# grant: deny +# protocol: ipv6 +# sequence: 10 +# source: +# any: true +# - destination: +# host: 2001:db8:2000:ab::2 +# grant: permit +# protocol: tcp +# sequence: 20 +# source: +# host: 2001:db8:2000:2::2 +# name: ACL2v6 +# afi: ipv6 + # After state: # ------------ -# +# nxos-9k# show running-config | section '^ip(v6)* access-list' # ip access-list ACL1v6 # 10 permit sctp any any # 20 remark IPv6 ACL @@ -697,11 +1084,11 @@ # 10 deny ipv6 any 2001:db8:3000::/36 # 20 permit tcp 2001:db8:2000:2::2/128 2001:db8:2000:ab::2/128 - +# Using deleted - delete ACLs # Before state: # ------------- -# +# nxos-9k# show running-config | section '^ip(v6)* access-list' # ip access-list ACL1v4 # 10 permit ip any any # 20 deny udp any any @@ -716,18 +1103,106 @@ - name: Delete specific ACLs cisco.nxos.nxos_acls: - config: - - afi: ipv4 - acls: - - name: ACL1v4 - - name: ACL2v4 - - afi: ipv6 - acls: - - name: ACL1v6 state: deleted + config: + - afi: ipv4 + acls: + - name: ACL1v4 + - name: ACL2v4 + - afi: ipv6 + acls: + - name: ACL1v6 + +# Task Output +# ----------- +# +# before: +# - acls: +# - aces: +# - destination: +# any: true +# grant: permit +# protocol: sctp +# sequence: 10 +# source: +# any: true +# - remark: IPv6 ACL +# sequence: 20 +# name: ACL1v6 +# - aces: +# - destination: +# prefix: 2001:db8:3000::/36 +# grant: deny +# protocol: ipv6 +# sequence: 10 +# source: +# any: true +# - destination: +# host: 2001:db8:2000:ab::2 +# grant: permit +# protocol: tcp +# sequence: 20 +# source: +# host: 2001:db8:2000:2::2 +# name: ACL2v6 +# afi: ipv6 +# - acls: +# - aces: +# - destination: +# any: true +# grant: permit +# protocol: ip +# sequence: 10 +# source: +# any: true +# - destination: +# any: true +# grant: deny +# protocol: udp +# sequence: 20 +# source: +# any: true +# name: ACL1v4 +# - aces: +# - destination: +# any: true +# grant: permit +# protocol: ahp +# sequence: 10 +# source: +# address: 192.0.2.0 +# wildcard_bits: 0.0.0.255 +# name: ACL2v4 +# afi: ipv4 +# +# commands: +# - no ip access-list ACL1v4 +# - no ip access-list ACL2v4 +# - no ipv6 access-list ACL1v6 +# +# after: +# - acls: +# - aces: +# - destination: +# prefix: 2001:db8:3000::/36 +# grant: deny +# protocol: ipv6 +# sequence: 10 +# source: +# any: true +# - destination: +# host: 2001:db8:2000:ab::2 +# grant: permit +# protocol: tcp +# sequence: 20 +# source: +# host: 2001:db8:2000:2::2 +# name: ACL2v6 +# afi: ipv6 # After state: # ------------ +# nxos-9k# show running-config | section '^ip(v6)* access-list' # ipv6 access-list ACL2v6 # 10 deny ipv6 any 2001:db8:3000::/36 # 20 permit tcp 2001:db8:2000:2::2/128 2001:db8:2000:ab::2/128 @@ -743,7 +1218,9 @@ 10 permit sctp any any state: parsed -# returns: +# Task Output +# ------------ +# # parsed: # - afi: ipv4 # acls: @@ -781,7 +1258,7 @@ # Before state: # ------------ -# +# nxos-9k# show running-config | section '^ip(v6)* access-list' # ip access-list ACL1v4 # 50 deny tcp any lt 55 192.0.2.64 0.0.0.255 ack fin # ipv6 access-list ACL1v6 @@ -791,7 +1268,9 @@ cisco.nxos.nxos_acls: state: gathered -# returns: +# Task Output +# ----------- +# # gathered: # - afi: ipv4 # acls: @@ -862,7 +1341,9 @@ protocol: sctp state: rendered -# returns: +# Task Output +# ----------- +# # rendered: # ip access-list ACL1v4 # 50 deny tcp any lt 55 192.0.2.64 0.0.0.255 ack fin @@ -888,7 +1369,32 @@ description: The set of commands pushed to the remote device. returned: always type: list - sample: ['ip access-list ACL1v4', '10 permit ip any any precedence critical log', '20 deny tcp any lt smtp host 192.0.2.64 ack fin'] + sample: + - ip access-list ACL1v4 + - 10 permit ip any any precedence critical log + - 20 deny tcp any lt smtp host 192.0.2.64 ack fin +rendered: + description: The provided configuration in the task rendered in device-native format (offline). + returned: when I(state) is C(rendered) + type: list + sample: + - ip access-list ACL1v4 + - 10 permit ip any any precedence critical log + - 20 deny tcp any lt smtp host 192.0.2.64 ack fin +gathered: + description: Facts about the network resource gathered from the remote device as structured data. + returned: when I(state) is C(gathered) + type: list + sample: > + This output will always be in the same format as the + module argspec. +parsed: + description: The device native config provided in I(running_config) option parsed into structured data as per module argspec. + returned: when I(state) is C(parsed) + type: list + sample: > + This output will always be in the same format as the + module argspec. """ from ansible.module_utils.basic import AnsibleModule diff --git a/plugins/modules/nxos_bgp_global.py b/plugins/modules/nxos_bgp_global.py index 6a34bc777..29e016181 100644 --- a/plugins/modules/nxos_bgp_global.py +++ b/plugins/modules/nxos_bgp_global.py @@ -357,6 +357,9 @@ remote_as: description: Specify Autonomous System Number of the neighbor. type: str + remote_as_route_map: + description: Route-map to match prefix peer AS number. + type: str remove_private_as: description: Remove private AS number from outbound updates. type: dict diff --git a/plugins/modules/nxos_bgp_neighbor_address_family.py b/plugins/modules/nxos_bgp_neighbor_address_family.py index 299691bb7..e2b72ace3 100644 --- a/plugins/modules/nxos_bgp_neighbor_address_family.py +++ b/plugins/modules/nxos_bgp_neighbor_address_family.py @@ -187,6 +187,9 @@ rewrite_evpn_rt_asn: description: Auto generate RTs for EBGP neighbor. type: bool + rewrite_rt_asn: + description: Auto generate RTs for EBGP neighbor. + type: bool route_map: description: Apply route-map to neighbor. type: dict diff --git a/plugins/modules/nxos_bgp_templates.py b/plugins/modules/nxos_bgp_templates.py index 669c833c5..9ad53e348 100644 --- a/plugins/modules/nxos_bgp_templates.py +++ b/plugins/modules/nxos_bgp_templates.py @@ -62,7 +62,7 @@ safi: description: Sub Address Family indicator. type: str - choices: ["unicast", "multicast", "mvpn"] + choices: ["unicast", "multicast", "mvpn", "evpn"] advertise_map: description: Specify route-map for conditional advertisement. type: dict @@ -191,6 +191,10 @@ route_reflector_client: description: Configure a neighbor as Route reflector client. type: bool + send_community: + description: Send Community attribute to this neighbor. + type: str + choices: ["standard", "extended", "both"] soft_reconfiguration_inbound: description: Soft reconfiguration. type: dict diff --git a/plugins/modules/nxos_fc_interfaces.py b/plugins/modules/nxos_fc_interfaces.py new file mode 100644 index 000000000..b0c58a5e3 --- /dev/null +++ b/plugins/modules/nxos_fc_interfaces.py @@ -0,0 +1,590 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Copyright 2023 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +""" +The module file for nxos_fc_interfaces +""" + +from __future__ import absolute_import, division, print_function + + +__metaclass__ = type + +DOCUMENTATION = """ +--- +module: nxos_fc_interfaces +short_description: Fc Interfaces resource module +description: This module manages the interface attributes of NX-OS fc interfaces. +version_added: 5.2.0 +author: Suhas Bharadwaj (@srbharadwaj) +notes: + - Tested against NXOS 9.3(2) on Cisco MDS Switches +options: + running_config: + description: + - This option is used only with state I(parsed). + - The value of this option should be the output received from the NX-OS + device by executing the command B(show running-config interface) + - The state I(parsed) reads the configuration from C(running_config) + option and transforms it into Ansible structured data as per the + resource module's argspec and the value is then returned in the + I(parsed) key within the result. + type: str + config: + description: A dictionary of interface options + type: list + elements: dict + suboptions: + name: + description: + - Full name of interface, e.g. fc1/1, fc18/48 + type: str + required: true + description: + description: + - Interface description. + type: str + enabled: + description: + - Administrative state of the interface. Set the value to C(true) to + administratively enable the interface or C(false) to disable it + type: bool + speed: + description: + - Interface link speed. + choices: + - 'auto' + - '1000' + - '2000' + - '4000' + - '8000' + - '10000' + - '16000' + - '32000' + - '64000' + - 'auto max 2000' + - 'auto max 4000' + - 'auto max 8000' + - 'auto max 16000' + - 'auto max 32000' + - 'auto max 64000' + type: str + mode: + description: + - Port mode of the fc interface + choices: + - 'auto' + - 'E' + - 'F' + - 'Fx' + - 'NP' + - 'SD' + type: str + trunk_mode: + description: + - Trunk mode of the fc interface + choices: + - 'auto' + - 'on' + - 'off' + type: str + analytics: + description: + - Analytics type on the fc interface + choices: + - 'fc-scsi' + - 'fc-nvme' + - 'fc-all' + type: str + state: + description: + - The state of the configuration after module completion + type: str + choices: + - merged + - replaced + - overridden + - deleted + - gathered + - rendered + - parsed + default: merged +""" +EXAMPLES = """ +# Using merged + +# Before state: +# ------------- +# +# switch# show running-config interface all +# interface fc18/10 +# analytics type fc-nvme +# switchport speed auto max 16000 +# switchport mode auto +# switchport description $ +# switchport trunk mode on +# shutdown + +- name: Merge provided configuration with device configuration + cisco.nxos.nxos_fc_interfaces: + config: + - name: fc18/10 + analytics: fc-scsi + state: merged + +# Task Output +# ----------- +# +# before: +# - name: fc18/10 +# speed: auto max 16000 +# mode: auto +# trunk_mode: on +# enabled: False +# description: $ +# analytics: fc-nvme +# commands: +# - interface fc18/10 +# - analytics type fc-scsi +# after: +# - name: fc18/10 +# speed: auto max 16000 +# mode: auto +# trunk_mode: on +# enabled: False +# description: $ +# analytics: fc-all + +# After state: +# ------------ +# +# switch# show running-config interface all +# interface fc18/10 +# analytics type fc-scsi +# analytics type fc-nvme +# switchport speed auto max 16000 +# switchport mode auto +# switchport description $ +# switchport trunk mode on +# shutdown + +# Using replaced + +# Before state: +# ------------- +# +# switch# show running-config interface all +# interface fc18/12 +# analytics type fc-scsi +# analytics type fc-nvme +# switchport speed auto max 64000 +# switchport mode auto +# switchport description 1 +# switchport trunk mode on +# no shutdown + +- name: Replaces device configuration of listed interfaces with provided configuration + cisco.nxos.nxos_fc_interfaces: + config: + - name: fc18/12 + speed: auto max 64000 + mode: auto + trunk_mode: on + enabled: True + description: 1 + analytics: fc-scsi + state: replaced + +# Task Output +# ----------- +# +# before: +# - name: fc18/12 +# speed: auto max 64000 +# mode: auto +# trunk_mode: on +# enabled: True +# description: 1 +# analytics: fc-all +# commands: +# - interface fc18/12 +# - no analytics type fc-all +# - analytics type fc-scsi +# after: +# - name: fc18/12 +# speed: auto max 64000 +# mode: auto +# trunk_mode: on +# enabled: True +# description: 1 +# analytics: fc-scsi + +# After state: +# ------------ +# +# switch# show running-config interface all +# interface fc18/12 +# analytics type fc-scsi +# switchport speed auto max 64000 +# switchport mode auto +# switchport description 1 +# switchport trunk mode on +# no shutdown + + +# Using deleted + +# Before state: +# ------------- +# +# switch# show running-config interface all +# interface fc1/2 +# switchport speed 1000 +# switchport mode E +# no switchport description +# switchport trunk mode off +# no shutdown + +- name: Delete or return interface parameters to default settings + cisco.nxos.nxos_fc_interfaces: + config: + - name: fc1/2 + state: deleted + +# Task Output +# ----------- +# +# before: +# - name: fc1/2 +# speed: 1000 +# mode: E +# trunk_mode: off +# enabled: True +# commands: +# - interface fc1/2 +# - no switchport speed 1000 +# - no switchport mode E +# - switchport trunk mode on +# - shutdown +# after: +# - name: fc1/2 +# speed: auto +# mode: auto +# trunk_mode: on +# enabled: False + +# After state: +# ------------ +# +# switch# show running-config interface all +# interface fc1/2 +# switchport speed auto +# switchport mode auto +# no switchport description +# switchport trunk mode on +# shutdown + +# Using overridden + +# Before state: +# ------------- +# +# switch# show running-config interface all +# interface fc18/12 +# analytics type fc-scsi +# analytics type fc-nvme +# switchport speed auto max 64000 +# switchport mode auto +# switchport description 1 +# switchport trunk mode on +# no shutdown +# interface fc18/13 +# analytics type fc-scsi +# analytics type fc-nvme +# switchport speed auto max 64000 +# switchport mode auto +# switchport description 1 +# switchport trunk mode on +# no shutdown + +- name: Replaces device configuration of listed interfaces with provided configuration + cisco.nxos.nxos_fc_interfaces: + config: + - name: fc18/12 + speed: auto max 64000 + mode: auto + trunk_mode: on + enabled: True + description: 1 + analytics: fc-scsi + state: overridden + +# Task Output +# ----------- +# +# before: +# - name: fc18/12 +# speed: auto max 64000 +# mode: auto +# trunk_mode: on +# enabled: True +# description: 1 +# analytics: fc-all +# - name: fc18/13 +# speed: auto max 64000 +# mode: auto +# trunk_mode: on +# enabled: True +# description: 1 +# analytics: fc-all +# commands: +# - interface fc18/12 +# no analytics type fc-all +# analytics type fc-scsi +# - interface fc18/13 +# no switchport description +# no switchport speed auto max 64000 +# no switchport mode auto +# switchport trunk mode on +# shutdown +# after: +# - name: fc18/12 +# speed: auto max 64000 +# mode: auto +# trunk_mode: on +# enabled: True +# description: 1 +# analytics: fc-scsi +# - name: fc18/13 +# speed: auto max 64000 +# mode: auto +# trunk_mode: on +# enabled: False + +# After state: +# ------------ +# +# switch# show running-config interface all +# interface fc18/12 +# analytics type fc-scsi +# switchport speed auto max 64000 +# switchport mode auto +# switchport description 1 +# switchport trunk mode on +# no shutdown +# interface fc18/13 +# switchport mode auto +# switchport trunk mode on +# shutdown + + + + + + + +# Using rendered + +- name: Use rendered state to convert task input to device specific commands + cisco.nxos.nxos_fc_interfaces: + config: + - name: fc1/1 + speed: auto + mode: auto + trunk_mode: on + enabled: True + description: This is a sample line + - name: fc1/2 + speed: 1000 + mode: E + trunk_mode: off + enabled: True + state: rendered + +# Task Output +# ----------- +# +# rendered: +# interface fc1/1 +# switchport speed auto +# switchport mode auto +# switchport description This is a sample line +# switchport trunk mode on +# no shutdown +# +# interface fc1/2 +# switchport speed 1000 +# switchport mode E +# no switchport description +# switchport trunk mode off +# no shutdown + +# Using parsed + +# parsed.cfg +# ------------ +# +# interface fc1/1 +# switchport speed auto +# switchport mode auto +# switchport description This is a sample line +# switchport trunk mode on +# no shutdown +# +# interface fc1/2 +# switchport speed 1000 +# switchport mode E +# no switchport description +# switchport trunk mode off +# no shutdown + +- name: Use parsed state to convert externally supplied config to structured format + cisco.nxos.nxos_fc_interfaces: + running_config: "{{ lookup('file', 'parsed.cfg') }}" + state: parsed + +# Task output +# ----------- +# +# parsed: +# - name: fc1/1 +# speed: auto +# mode: auto +# trunk_mode: on +# enabled: True +# description: This is a sample line +# - name: fc1/2 +# speed: 1000 +# mode: E +# trunk_mode: off +# enabled: True + +# Using gathered + +# Before state: +# ------------- +# +# switch# show running-config | section interface +# interface fc1/1 +# switchport speed auto +# switchport mode auto +# switchport description This is a sample line +# switchport trunk mode on +# no shutdown +# +# interface fc1/2 +# switchport speed 1000 +# switchport mode E +# no switchport description +# switchport trunk mode off +# no shutdown +# +- name: Gather interfaces facts from the device using nxos_fc_interfaces + cisco.nxos.nxos_fc_interfaces: + state: gathered +# +# Task output +# ----------- +# +# - name: fc1/1 +# speed: auto +# mode: auto +# trunk_mode: on +# enabled: True +# description: This is a sample line +# - name: fc1/2 +# speed: 1000 +# mode: E +# trunk_mode: off +# enabled: True + + + + +""" + +RETURN = """ +before: + description: The configuration prior to the module execution. + returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged) + type: dict + sample: > + This output will always be in the same format as the + module argspec. +after: + description: The resulting configuration after module execution. + returned: when changed + type: dict + sample: > + This output will always be in the same format as the + module argspec. +commands: + description: The set of commands pushed to the remote device. + returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged) + type: list + sample: + - interface fc1/1 + - description sample description + - shutdown +rendered: + description: The provided configuration in the task rendered in device-native format (offline). + returned: when I(state) is C(rendered) + type: list + sample: + - interface fc1/1 + - description sample description + - shutdown +gathered: + description: Facts about the network resource gathered from the remote device as structured data. + returned: when I(state) is C(gathered) + type: list + sample: > + This output will always be in the same format as the + module argspec. +parsed: + description: The device native config provided in I(running_config) option parsed into structured data as per module argspec. + returned: when I(state) is C(parsed) + type: list + sample: > + This output will always be in the same format as the + module argspec. +""" + +from ansible.module_utils.basic import AnsibleModule + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.fc_interfaces.fc_interfaces import ( + Fc_interfacesArgs, +) +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.fc_interfaces.fc_interfaces import ( + Fc_interfaces, +) + + +def main(): + """ + Main entry point for module execution + + :returns: the result form module invocation + """ + module = AnsibleModule( + argument_spec=Fc_interfacesArgs.argument_spec, + mutually_exclusive=[["config", "running_config"]], + required_if=[ + ["state", "merged", ["config"]], + ["state", "replaced", ["config"]], + ["state", "overridden", ["config"]], + ["state", "rendered", ["config"]], + ["state", "parsed", ["running_config"]], + ], + supports_check_mode=True, + ) + + result = Fc_interfaces(module).execute_module() + module.exit_json(**result) + + +if __name__ == "__main__": + main() diff --git a/plugins/modules/nxos_route_maps.py b/plugins/modules/nxos_route_maps.py index 123566569..bcf7076f0 100644 --- a/plugins/modules/nxos_route_maps.py +++ b/plugins/modules/nxos_route_maps.py @@ -312,6 +312,23 @@ extcomm_list: description: Set BGP extcommunity list (for deletion). type: str + extcommunity: + description: Set BGP extcommunity attribute. + type: dict + suboptions: + rt: + description: Route-Target. + type: dict + suboptions: + additive: + description: Add to existing rt extcommunity. + type: bool + extcommunity_numbers: + description: + - Extcommunity number. + - "Supported formats are ASN2:NN, ASN4:NN, IPV4:NN." + type: list + elements: str forwarding_address: description: Set the forwarding address. type: bool diff --git a/plugins/modules/nxos_vtp_version.py b/plugins/modules/nxos_vtp_version.py index 8c5305a08..a98bff904 100644 --- a/plugins/modules/nxos_vtp_version.py +++ b/plugins/modules/nxos_vtp_version.py @@ -46,15 +46,13 @@ choices: - '1' - '2' + - '3' type: str """ EXAMPLES = """ # ENSURE VTP VERSION IS 2 - cisco.nxos.nxos_vtp_version: version: 2 - host: '{{ inventory_hostname }}' - username: '{{ un }}' - password: '{{ pwd }}' """ RETURN = """ @@ -163,7 +161,7 @@ def get_vtp_password(module): def main(): - argument_spec = dict(version=dict(type="str", choices=["1", "2"], required=True)) + argument_spec = dict(version=dict(type="str", choices=["1", "2", "3"], required=True)) module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) diff --git a/tests/config.yml b/tests/config.yml new file mode 100644 index 000000000..41f529264 --- /dev/null +++ b/tests/config.yml @@ -0,0 +1,3 @@ +--- +modules: + python_requires: ">=3.6" diff --git a/tests/integration/targets/nxos_lag_interfaces/tests/common/merged.yaml b/tests/integration/targets/nxos_lag_interfaces/tests/common/merged.yaml index 96b74273d..3a8e78976 100644 --- a/tests/integration/targets/nxos_lag_interfaces/tests/common/merged.yaml +++ b/tests/integration/targets/nxos_lag_interfaces/tests/common/merged.yaml @@ -35,9 +35,9 @@ - name: port-channel10 members: - member: "{{ test_int1 }}" - - member: "{{ test_int2 }}" - mode: true + mode: on # noqa yaml[truthy] + force: true state: merged - ansible.builtin.assert: diff --git a/tests/integration/targets/nxos_lag_interfaces/tests/common/overridden.yaml b/tests/integration/targets/nxos_lag_interfaces/tests/common/overridden.yaml index f2bafafb2..92c357f1d 100644 --- a/tests/integration/targets/nxos_lag_interfaces/tests/common/overridden.yaml +++ b/tests/integration/targets/nxos_lag_interfaces/tests/common/overridden.yaml @@ -92,7 +92,7 @@ that: - "result.changed == True" - "'interface Ethernet1/9' in result.commands" - - "'channel-group 20 force mode active' in result.commands" + - "'channel-group 20 force mode active' in result.commands" always: - name: Teardown diff --git a/tests/sanity/ignore-2.17.txt b/tests/sanity/ignore-2.17.txt new file mode 100644 index 000000000..46cfbc643 --- /dev/null +++ b/tests/sanity/ignore-2.17.txt @@ -0,0 +1 @@ +plugins/action/nxos.py action-plugin-docs # base class for deprecated network platform modules using `connection: local` diff --git a/tests/unit/modules/network/nxos/test_nxos_acls.py b/tests/unit/modules/network/nxos/test_nxos_acls.py index 631d72741..b7c0e8663 100644 --- a/tests/unit/modules/network/nxos/test_nxos_acls.py +++ b/tests/unit/modules/network/nxos/test_nxos_acls.py @@ -873,3 +873,90 @@ def test_nxos_acls_icmpv6_1(self): ] result = self.execute_module(changed=True) self.assertEqual(result["commands"], commands) + + def test_nxos_acls_ranges(self): + self.execute_show_command.return_value = dedent( + """\ + ip access-list acl1 + 10 permit tcp any any range ftp-data ftp + 20 permit tcp any range ftp-data ftp any range telnet time + 30 permit tcp any range ftp-data ftp any + """, + ) + set_module_args( + dict( + state="gathered", + ), + ) + + gathered = [ + { + "acls": [ + { + "name": "acl1", + "aces": [ + { + "sequence": 10, + "grant": "permit", + "protocol": "tcp", + "source": { + "any": True, + }, + "destination": { + "any": True, + "port_protocol": { + "range": { + "start": "ftp-data", + "end": "ftp", + }, + }, + }, + }, + { + "sequence": 20, + "grant": "permit", + "protocol": "tcp", + "source": { + "any": True, + "port_protocol": { + "range": { + "start": "ftp-data", + "end": "ftp", + }, + }, + }, + "destination": { + "any": True, + "port_protocol": { + "range": { + "start": "telnet", + "end": "time", + }, + }, + }, + }, + { + "sequence": 30, + "grant": "permit", + "protocol": "tcp", + "source": { + "any": True, + "port_protocol": { + "range": { + "start": "ftp-data", + "end": "ftp", + }, + }, + }, + "destination": { + "any": True, + }, + }, + ], + }, + ], + "afi": "ipv4", + }, + ] + result = self.execute_module(changed=False) + self.assertEqual(result["gathered"], gathered) diff --git a/tests/unit/modules/network/nxos/test_nxos_bgp_global.py b/tests/unit/modules/network/nxos/test_nxos_bgp_global.py index 9f2377fb6..22c9378eb 100644 --- a/tests/unit/modules/network/nxos/test_nxos_bgp_global.py +++ b/tests/unit/modules/network/nxos/test_nxos_bgp_global.py @@ -89,6 +89,11 @@ def test_nxos_bgp_global_merged(self): remote_as="65537", password=dict(encryption=7, key="12090404011C03162E"), ), + dict( + neighbor_address="2001:4000:4000:fff1::/64", + remote_as_route_map="rmap1", + description="TEST_NBR", + ), ], vrfs=[ dict( @@ -107,6 +112,11 @@ def test_nxos_bgp_global_merged(self): key="13D4D3549493D2877B1DC116EE27A6BE", ), ), + dict( + neighbor_address="2001:4000:5000:fff1::/64", + remote_as_route_map="rmap2", + description="TEST_NBR_2", + ), ], ), dict( @@ -134,6 +144,8 @@ def test_nxos_bgp_global_merged(self): "neighbor 198.51.100.21", "remote-as 65537", "password 7 12090404011C03162E", + "neighbor 2001:4000:4000:fff1::/64 remote-as route-map rmap1", + "description TEST_NBR", "vrf site-1", "local-as 200", "log-neighbor-changes", @@ -143,6 +155,8 @@ def test_nxos_bgp_global_merged(self): "description site-1-nbr-1", "password 3 13D4D3549493D2877B1DC116EE27A6BE", "timers 5 15", + "neighbor 2001:4000:5000:fff1::/64 remote-as route-map rmap2", + "description TEST_NBR_2", "vrf site-2", "local-as 300", "log-neighbor-changes", @@ -308,6 +322,8 @@ def test_nxos_bgp_global_merged_idempotent(self): neighbor 198.51.100.21 remote-as 65537 password 7 12090404011C03162E + neighbor 2001:4000:4000:fff1::/64 remote-as route-map rmap1 + description TEST_NBR vrf site-1 local-as 200 log-neighbor-changes @@ -344,6 +360,11 @@ def test_nxos_bgp_global_merged_idempotent(self): remote_as="65537", password=dict(encryption=7, key="12090404011C03162E"), ), + dict( + neighbor_address="2001:4000:4000:fff1::/64", + remote_as_route_map="rmap1", + description="TEST_NBR", + ), ], vrfs=[ dict( diff --git a/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_address_family.py b/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_address_family.py index 8f12a4279..b3943f370 100644 --- a/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_address_family.py +++ b/tests/unit/modules/network/nxos/test_nxos_bgp_neighbor_address_family.py @@ -2713,3 +2713,64 @@ def test_nxos_bgp_nbr_parsed_3K(self): ) result = self.execute_module(changed=False) self.assertEqual(result["parsed"], parsed) + + def test_nxos_bgp_nbr_af_rewrite_rt_asn(self): + # test merged for rewrite_rt_asn + self.get_config.return_value = dedent( + """\ + router bgp 65536 + neighbor 192.168.1.1 + vrf site-1 + neighbor 10.0.0.100 + """, + ) + set_module_args( + dict( + config=dict( + as_number="65536", + neighbors=[ + dict( + neighbor_address="192.168.1.1", + address_family=[ + dict( + afi="ipv4", + safi="mvpn", + rewrite_rt_asn=True, + ), + ], + ), + ], + vrfs=[ + dict( + vrf="site-1", + neighbors=[ + dict( + neighbor_address="10.0.0.100", + address_family=[ + dict( + afi="ipv4", + safi="mvpn", + rewrite_rt_asn=True, + ), + ], + ), + ], + ), + ], + ), + state="merged", + ), + ignore_provider_arg, + ) + commands = [ + "router bgp 65536", + "neighbor 192.168.1.1", + "address-family ipv4 mvpn", + "rewrite-rt-asn", + "vrf site-1", + "neighbor 10.0.0.100", + "address-family ipv4 mvpn", + "rewrite-rt-asn", + ] + result = self.execute_module(changed=True) + self.assertEqual(set(result["commands"]), set(commands)) diff --git a/tests/unit/modules/network/nxos/test_nxos_bgp_templates.py b/tests/unit/modules/network/nxos/test_nxos_bgp_templates.py index 1378c4411..8d2fd74b5 100644 --- a/tests/unit/modules/network/nxos/test_nxos_bgp_templates.py +++ b/tests/unit/modules/network/nxos/test_nxos_bgp_templates.py @@ -140,6 +140,13 @@ def test_nxos_bgp_templates_merged(self): set=True, ), ), + address_family=[ + dict( + afi="l2vpn", + safi="evpn", + send_community="both", + ), + ], ), ], ), @@ -179,6 +186,9 @@ def test_nxos_bgp_templates_merged(self): "update-source Ethernet1/1", "template peer tmplt_3", "bfd multihop", + "address-family l2vpn evpn", + "send-community", + "send-community extended", ] result = self.execute_module(changed=True) self.assertEqual(set(result["commands"]), set(commands)) @@ -799,3 +809,57 @@ def test_nxos_bgp_templates_af_idempotent(self): result = self.execute_module(changed=False) self.assertEqual(result["commands"], []) + + def test_nxos_bgp_templates_send_comm(self): + self.get_config.return_value = dedent( + """\ + router bgp 65536 + template peer tmplt_1 + address-family ipv4 unicast + send-community + send-community extended + template peer tmplt_2 + address-family l2vpn evpn + send-community extended + """, + ) + set_module_args( + dict( + config=dict( + as_number="65536", + neighbor=[ + dict( + name="tmplt_1", + address_family=[ + dict( + afi="ipv4", + safi="unicast", + send_community="both", + ), + ], + ), + dict( + name="tmplt_2", + address_family=[ + dict( + afi="l2vpn", + safi="evpn", + send_community="standard", + ), + ], + ), + ], + ), + state="merged", + ), + ignore_provider_arg, + ) + commands = [ + "router bgp 65536", + "template peer tmplt_2", + "address-family l2vpn evpn", + "no send-community extended", + "send-community", + ] + result = self.execute_module(changed=True) + self.assertEqual(set(result["commands"]), set(commands)) diff --git a/tests/unit/modules/network/nxos/test_nxos_fc_interfaces.py b/tests/unit/modules/network/nxos/test_nxos_fc_interfaces.py new file mode 100644 index 000000000..098a5b7ff --- /dev/null +++ b/tests/unit/modules/network/nxos/test_nxos_fc_interfaces.py @@ -0,0 +1,1744 @@ +# (c) 2023 Red Hat Inc. +# +# 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 + + +# remove purge +# add non fc interfaces to the sh run +# check else statements in config file + + +from __future__ import absolute_import, division, print_function + + +__metaclass__ = type + +from textwrap import dedent + +from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.rm_templates.fc_interfaces import ( + allowed_port_modes, + allowed_speed_values, +) +from ansible_collections.cisco.nxos.plugins.modules import nxos_fc_interfaces +from ansible_collections.cisco.nxos.tests.unit.compat.mock import patch + +from .nxos_module import TestNxosModule, set_module_args + + +ignore_provider_arg = True + +sh_run = """ +interface mgmt0 + ip address 10.126.94.175 255.255.255.0 + no switchport description + switchport speed auto + switchport duplex auto + snmp trap link-status + no shutdown + lldp transmit + lldp receive + cdp enable + spanning-tree port-priority 128 + spanning-tree cost auto + spanning-tree link-type auto + no spanning-tree bpduguard + no spanning-tree bpdufilter + +interface vsan1 + no shutdown + ip address 111.111.111.175 255.255.255.0 + spanning-tree port-priority 128 + spanning-tree cost auto + spanning-tree link-type auto + no spanning-tree bpduguard + no spanning-tree bpdufilter + + +interface fc1/1 + no out-of-service force + switchport speed auto + no transceiver-frequency ethernet + switchport rate-mode default + switchport fcrxbbcredit default + switchport mode auto + switchport description This is a sample line + switchport vl-credit default + switchport trunk mode on + no switchport beacon + switchport fcbbscn + link-state-trap + switchport fcrxbufsize 2112 + no switchport owner + switchport encap default + switchport fcrxbbcredit performance-buffers default + no switchport ignore bit-errors + no switchport ignore interrupt-thresholds + switchport fill-pattern ARBFF speed 8000 + switchport logical-type auto + switchport max-npiv-limit 0 + switchport trunk-max-npiv-limit 0 + no switchport link-diag + no shutdown + +interface fc1/2 + no out-of-service force + switchport speed 1000 + no transceiver-frequency ethernet + switchport rate-mode default + switchport fcrxbbcredit default + switchport mode E + no switchport description + switchport vl-credit default + switchport trunk mode off + no switchport beacon + switchport fcbbscn + link-state-trap + switchport fcrxbufsize 2112 + no port-license + no errdisable detect cause link-down + no errdisable detect cause trustsec-violation + no errdisable detect cause bit-errors + no errdisable detect cause signal-loss + no errdisable detect cause sync-loss + no errdisable detect cause link-reset + no errdisable detect cause credit-loss + no switchport owner + switchport encap default + switchport fcrxbbcredit performance-buffers default + no switchport ignore bit-errors + no switchport ignore interrupt-thresholds + switchport fill-pattern ARBFF speed 8000 + switchport logical-type auto + switchport max-npiv-limit 0 + switchport trunk-max-npiv-limit 0 + no switchport link-diag + no shutdown + +interface fc1/3 + no out-of-service force + switchport speed 2000 + no transceiver-frequency ethernet + switchport rate-mode default + switchport fcrxbbcredit default + switchport mode F + no switchport description + switchport vl-credit default + switchport trunk mode on + no switchport beacon + switchport fcbbscn + link-state-trap + switchport fcrxbufsize 2112 + no switchport owner + switchport encap default + switchport fcrxbbcredit performance-buffers default + no switchport ignore bit-errors + no switchport ignore interrupt-thresholds + switchport fill-pattern ARBFF speed 8000 + switchport logical-type auto + switchport max-npiv-limit 0 + switchport trunk-max-npiv-limit 0 + no switchport link-diag + no shutdown + +interface fc18/1 + no out-of-service force + switchport speed 4000 + no transceiver-frequency ethernet + switchport rate-mode default + switchport fcrxbbcredit default + switchport mode Fx + no switchport description + switchport vl-credit default + switchport trunk mode auto + no switchport beacon + switchport fcbbscn + link-state-trap + switchport fcrxbufsize 2112 + no port-license + no switchport owner + switchport encap default + switchport fcrxbbcredit performance-buffers default + no switchport ignore bit-errors + no switchport ignore interrupt-thresholds + switchport fill-pattern ARBFF speed 8000 + switchport logical-type auto + switchport max-npiv-limit 0 + switchport trunk-max-npiv-limit 0 + no switchport link-diag + no shutdown + +interface fc18/2 + no out-of-service force + switchport speed 8000 + no transceiver-frequency ethernet + switchport rate-mode default + switchport fcrxbbcredit default + switchport mode NP + no switchport description + switchport vl-credit default + switchport trunk mode on + no switchport beacon + switchport fcbbscn + link-state-trap + switchport fcrxbufsize 2112 + no port-license + no switchport owner + switchport encap default + switchport fcrxbbcredit performance-buffers default + no switchport ignore bit-errors + no switchport ignore interrupt-thresholds + switchport fill-pattern ARBFF speed 8000 + switchport logical-type auto + switchport max-npiv-limit 0 + switchport trunk-max-npiv-limit 0 + no switchport link-diag + no shutdown +interface fc18/3 + no out-of-service force + switchport speed 10000 + no transceiver-frequency ethernet + switchport rate-mode default + switchport fcrxbbcredit default + switchport mode SD + no switchport description + switchport vl-credit default + switchport trunk mode on + no switchport beacon + switchport fcbbscn + link-state-trap + switchport fcrxbufsize 2112 + no port-license + no switchport owner + switchport encap default + switchport fcrxbbcredit performance-buffers default + no switchport ignore bit-errors + no switchport ignore interrupt-thresholds + switchport fill-pattern ARBFF speed 8000 + switchport logical-type auto + switchport max-npiv-limit 0 + switchport trunk-max-npiv-limit 0 + no switchport link-diag + no shutdown + +interface fc18/4 + no out-of-service force + switchport speed 16000 + no transceiver-frequency ethernet + switchport rate-mode default + switchport fcrxbbcredit default + switchport mode auto + no switchport description + switchport vl-credit default + switchport trunk mode on + no switchport beacon + switchport fcbbscn + link-state-trap + switchport fcrxbufsize 2112 + no port-license + no switchport owner + switchport encap default + switchport fcrxbbcredit performance-buffers default + no switchport ignore bit-errors + no switchport ignore interrupt-thresholds + switchport fill-pattern ARBFF speed 8000 + switchport logical-type auto + switchport max-npiv-limit 0 + switchport trunk-max-npiv-limit 0 + no switchport link-diag + no shutdown +interface fc18/5 + no out-of-service force + switchport speed 32000 + no transceiver-frequency ethernet + switchport rate-mode default + switchport fcrxbbcredit default + switchport mode auto + no switchport description + switchport vl-credit default + switchport trunk mode on + no switchport beacon + switchport fcbbscn + link-state-trap + switchport fcrxbufsize 2112 + no port-license + no switchport owner + switchport encap default + switchport fcrxbbcredit performance-buffers default + no switchport ignore bit-errors + no switchport ignore interrupt-thresholds + switchport fill-pattern ARBFF speed 8000 + switchport logical-type auto + switchport max-npiv-limit 0 + switchport trunk-max-npiv-limit 0 + no switchport link-diag + no shutdown + +interface fc18/6 + no out-of-service force + switchport speed 64000 + no transceiver-frequency ethernet + switchport rate-mode default + switchport fcrxbbcredit default + switchport mode auto + no switchport description + switchport vl-credit default + switchport trunk mode on + no switchport beacon + switchport fcbbscn + link-state-trap + switchport fcrxbufsize 2112 + no port-license + no switchport owner + switchport encap default + switchport fcrxbbcredit performance-buffers default + no switchport ignore bit-errors + no switchport ignore interrupt-thresholds + switchport fill-pattern ARBFF speed 8000 + switchport logical-type auto + switchport max-npiv-limit 0 + switchport trunk-max-npiv-limit 0 + no switchport link-diag + no shutdown +interface fc18/7 + no out-of-service force + switchport speed auto max 2000 + no transceiver-frequency ethernet + switchport rate-mode default + switchport fcrxbbcredit default + switchport mode auto + no switchport description + switchport vl-credit default + switchport trunk mode on + no switchport beacon + switchport fcbbscn + link-state-trap + switchport fcrxbufsize 2112 + no port-license + no switchport owner + switchport encap default + switchport fcrxbbcredit performance-buffers default + no switchport ignore bit-errors + no switchport ignore interrupt-thresholds + switchport fill-pattern ARBFF speed 8000 + switchport logical-type auto + switchport max-npiv-limit 0 + switchport trunk-max-npiv-limit 0 + no switchport link-diag + no shutdown + +interface fc18/8 + no out-of-service force + switchport speed auto max 4000 + no transceiver-frequency ethernet + switchport rate-mode default + switchport fcrxbbcredit default + switchport mode auto + no switchport description + switchport vl-credit default + switchport trunk mode on + no switchport beacon + switchport fcbbscn + link-state-trap + switchport fcrxbufsize 2112 + no port-license + no switchport owner + switchport encap default + switchport fcrxbbcredit performance-buffers default + no switchport ignore bit-errors + no switchport ignore interrupt-thresholds + switchport fill-pattern ARBFF speed 8000 + switchport logical-type auto + switchport max-npiv-limit 0 + switchport trunk-max-npiv-limit 0 + no switchport link-diag + no shutdown +interface fc18/9 + no out-of-service force + switchport speed auto max 8000 + no transceiver-frequency ethernet + switchport rate-mode default + switchport fcrxbbcredit default + switchport mode auto + switchport description sample description + switchport vl-credit default + switchport trunk mode on + no switchport beacon + switchport fcbbscn + link-state-trap + switchport fcrxbufsize 2112 + no port-license + no switchport owner + switchport encap default + switchport fcrxbbcredit performance-buffers default + no switchport ignore bit-errors + no switchport ignore interrupt-thresholds + switchport fill-pattern ARBFF speed 8000 + switchport logical-type auto + switchport max-npiv-limit 0 + switchport trunk-max-npiv-limit 0 + no switchport link-diag + no shutdown + +interface fc18/10 + no out-of-service force + analytics type fc-nvme + switchport speed auto max 16000 + no transceiver-frequency ethernet + switchport rate-mode default + switchport fcrxbbcredit default + switchport mode auto + switchport description $ + switchport vl-credit default + switchport trunk mode on + no switchport beacon + switchport fcbbscn + link-state-trap + switchport fcrxbufsize 2112 + no port-license + no switchport owner + switchport encap default + switchport fcrxbbcredit performance-buffers default + no switchport ignore bit-errors + no switchport ignore interrupt-thresholds + switchport fill-pattern ARBFF speed 8000 + switchport logical-type auto + switchport max-npiv-limit 0 + switchport trunk-max-npiv-limit 0 + no switchport link-diag + shutdown + +interface fc18/11 + no out-of-service force + analytics type fc-scsi + switchport speed auto max 32000 + no transceiver-frequency ethernet + switchport rate-mode default + switchport fcrxbbcredit default + switchport mode auto + switchport description a + switchport vl-credit default + switchport trunk mode on + no switchport beacon + switchport fcbbscn + link-state-trap + switchport fcrxbufsize 2112 + no port-license + no switchport owner + switchport encap default + switchport fcrxbbcredit performance-buffers default + no switchport ignore bit-errors + no switchport ignore interrupt-thresholds + switchport fill-pattern ARBFF speed 8000 + switchport logical-type auto + switchport max-npiv-limit 0 + switchport trunk-max-npiv-limit 0 + no switchport link-diag + shutdown + +interface fc18/12 + no out-of-service force + analytics type fc-scsi + analytics type fc-nvme + switchport speed auto max 64000 + no transceiver-frequency ethernet + switchport rate-mode default + switchport fcrxbbcredit default + switchport mode auto + switchport description 1 + switchport vl-credit default + switchport trunk mode on + no switchport beacon + switchport fcbbscn + link-state-trap + switchport fcrxbufsize 2112 + no port-license + no switchport owner + switchport encap default + switchport fcrxbbcredit performance-buffers default + no switchport ignore bit-errors + no switchport ignore interrupt-thresholds + switchport fill-pattern ARBFF speed 8000 + switchport logical-type auto + switchport max-npiv-limit 0 + switchport trunk-max-npiv-limit 0 + no switchport link-diag + no shutdown + +interface fc18/13 + no out-of-service force + analytics type fc-scsi + analytics type fc-nvme + switchport speed auto max 64000 + no transceiver-frequency ethernet + switchport rate-mode default + switchport fcrxbbcredit default + switchport mode auto + switchport description 1 + switchport vl-credit default + switchport trunk mode on + no switchport beacon + switchport fcbbscn + link-state-trap + switchport fcrxbufsize 2112 + no port-license + no switchport owner + switchport encap default + switchport fcrxbbcredit performance-buffers default + no switchport ignore bit-errors + no switchport ignore interrupt-thresholds + switchport fill-pattern ARBFF speed 8000 + switchport logical-type auto + switchport max-npiv-limit 0 + switchport trunk-max-npiv-limit 0 + no switchport link-diag + no shutdown + """ + +gath_val = [ + { + "name": "fc1/1", + "speed": "auto", + "mode": "auto", + "trunk_mode": "on", + "enabled": True, + "description": "This is a sample line", + }, + { + "name": "fc1/2", + "speed": "1000", + "mode": "E", + "trunk_mode": "off", + "enabled": True, + }, + { + "name": "fc1/3", + "speed": "2000", + "mode": "F", + "trunk_mode": "on", + "enabled": True, + }, + { + "name": "fc18/1", + "speed": "4000", + "mode": "Fx", + "trunk_mode": "auto", + "enabled": True, + }, + { + "name": "fc18/2", + "speed": "8000", + "mode": "NP", + "trunk_mode": "on", + "enabled": True, + }, + { + "name": "fc18/3", + "speed": "10000", + "mode": "SD", + "trunk_mode": "on", + "enabled": True, + }, + { + "name": "fc18/4", + "speed": "16000", + "mode": "auto", + "trunk_mode": "on", + "enabled": True, + }, + { + "name": "fc18/5", + "speed": "32000", + "mode": "auto", + "trunk_mode": "on", + "enabled": True, + }, + { + "name": "fc18/6", + "speed": "64000", + "mode": "auto", + "trunk_mode": "on", + "enabled": True, + }, + { + "name": "fc18/7", + "speed": "auto max 2000", + "mode": "auto", + "trunk_mode": "on", + "enabled": True, + }, + { + "name": "fc18/8", + "speed": "auto max 4000", + "mode": "auto", + "trunk_mode": "on", + "enabled": True, + }, + { + "name": "fc18/9", + "speed": "auto max 8000", + "mode": "auto", + "trunk_mode": "on", + "enabled": True, + "description": "sample description", + }, + { + "name": "fc18/10", + "speed": "auto max 16000", + "mode": "auto", + "trunk_mode": "on", + "enabled": False, + "description": "$", + "analytics": "fc-nvme", + }, + { + "name": "fc18/11", + "speed": "auto max 32000", + "mode": "auto", + "trunk_mode": "on", + "enabled": False, + "description": "a", + "analytics": "fc-scsi", + }, + { + "name": "fc18/12", + "speed": "auto max 64000", + "mode": "auto", + "trunk_mode": "on", + "enabled": True, + "description": "1", + "analytics": "fc-all", + }, + { + "name": "fc18/13", + "speed": "auto max 64000", + "mode": "auto", + "trunk_mode": "on", + "enabled": True, + "description": "1", + "analytics": "fc-all", + }, +] + + +class TestNxosFcInterfacesModule(TestNxosModule): + module = nxos_fc_interfaces + + def setUp(self): + super(TestNxosFcInterfacesModule, self).setUp() + + self.mock_get_resource_connection = patch( + "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module_base.get_resource_connection", + ) + self.get_resource_connection = self.mock_get_resource_connection.start() + + self.mock_get_config = patch( + "ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.facts.fc_interfaces.fc_interfaces.Fc_interfacesFacts.get_interfaces_data", + ) + self.get_config = self.mock_get_config.start() + self.get_config.return_value = dedent(sh_run) + + self.maxDiff = None + + def tearDown(self): + super(TestNxosFcInterfacesModule, self).tearDown() + self.get_resource_connection.stop() + self.get_config.stop() + + def test_analytics_no_to_all_3_types(self): + args = dict( + config=[ + { + "name": "fc1/1", + "analytics": "fc-scsi", + "mode": "E", + }, + { + "name": "fc1/2", + "analytics": "fc-nvme", + }, + { + "name": "fc1/3", + "analytics": "fc-all", + }, + { + "name": "fc18/12", + "analytics": "fc-scsi", + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + [ + "interface fc1/1", + "switchport mode E", + "analytics type fc-scsi", + "interface fc1/2", + "analytics type fc-nvme", + "interface fc1/3", + "analytics type fc-all", + ], + ) + + def test_gathered(self): + # test gathered for config + set_module_args(dict(state="gathered"), ignore_provider_arg) + result = self.execute_module(changed=False) + self.assertEqual(result["gathered"], gath_val) + + def test_parsed(self): + # test parsed for config + set_module_args(dict(state="parsed", running_config=sh_run), ignore_provider_arg) + result = self.execute_module(changed=False) + self.assertEqual(result["parsed"], gath_val) + + def test_idempotency(self): + args = dict( + config=gath_val, + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=False) + self.assertEqual(result["commands"], []) + + def test_analytics_all_to_scsi(self): + args = dict( + config=[ + { + "name": "fc18/12", + "speed": "auto max 64000", + "mode": "auto", + "trunk_mode": "on", + "enabled": True, + "description": "1", + "analytics": "fc-scsi", + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=False) + self.assertEqual( + result["commands"], + [], + ) + + def test_analytics_all_to_scsi_replaced(self): + args = dict( + config=[ + { + "name": "fc18/12", + "speed": "auto max 64000", + "mode": "auto", + "trunk_mode": "on", + "enabled": True, + "description": "1", + "analytics": "fc-scsi", + }, + ], + state="replaced", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + ["interface fc18/12", "no analytics type fc-all", "analytics type fc-scsi"], + ) + + def test_analytics_all_to_nvme(self): + args = dict( + config=[ + { + "name": "fc18/12", + "speed": "auto max 64000", + "mode": "auto", + "trunk_mode": "on", + "enabled": True, + "description": "1", + "analytics": "fc-nvme", + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=False) + self.assertEqual( + result["commands"], + [], + ) + + def test_analytics_all_to_nvme_replaced(self): + args = dict( + config=[ + { + "name": "fc18/12", + "speed": "auto max 64000", + "mode": "auto", + "trunk_mode": "on", + "enabled": True, + "description": "1", + "analytics": "fc-nvme", + }, + ], + state="replaced", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + ["interface fc18/12", "no analytics type fc-all", "analytics type fc-nvme"], + ) + + def test_analytics_all_to_none_checkthis(self): + args = dict( + config=[ + { + "name": "fc18/12", + "speed": "auto max 64000", + "mode": "auto", + "trunk_mode": "on", + "enabled": True, + "description": "1", + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=False) + self.assertEqual(result["commands"], []) + + def test_analytics_all_to_none_desc_change(self): + args = dict( + config=[ + { + "name": "fc18/12", + "speed": "auto max 64000", + "mode": "auto", + "trunk_mode": "on", + "enabled": True, + "description": "2", + "analytics": "fc-all", + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual(result["commands"], ["interface fc18/12", "switchport description 2"]) + + def test_analytics_scsi_to_nvme(self): + args = dict( + config=[ + { + "name": "fc18/11", + "speed": "auto max 32000", + "mode": "auto", + "trunk_mode": "on", + "enabled": False, + "description": "a", + "analytics": "fc-nvme", + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + ["interface fc18/11", "analytics type fc-nvme"], + ) + + def test_analytics_scsi_to_nvme_replaced(self): + args = dict( + config=[ + { + "name": "fc18/11", + "speed": "auto max 32000", + "mode": "auto", + "trunk_mode": "on", + "enabled": False, + "description": "a", + "analytics": "fc-nvme", + }, + ], + state="replaced", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + ["interface fc18/11", "no analytics type fc-all", "analytics type fc-nvme"], + ) + + def test_analytics_scsi_to_all(self): + args = dict( + config=[ + { + "name": "fc18/11", + "speed": "auto max 32000", + "mode": "auto", + "trunk_mode": "on", + "enabled": False, + "description": "a", + "analytics": "fc-all", + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual(result["commands"], ["interface fc18/11", "analytics type fc-all"]) + + def test_analytics_scsi_to_all_replaced(self): + args = dict( + config=[ + { + "name": "fc18/11", + "speed": "auto max 32000", + "mode": "auto", + "trunk_mode": "on", + "enabled": False, + "description": "a", + "analytics": "fc-all", + }, + ], + state="replaced", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + ["interface fc18/11", "analytics type fc-all"], + ) + + def test_analytics_scsi_to_none_checkthis(self): + args = dict( + config=[ + { + "name": "fc18/11", + "speed": "auto max 32000", + "mode": "auto", + "trunk_mode": "on", + "enabled": False, + "description": "a", + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=False) + self.assertEqual(result["commands"], []) + + def test_analytics_nvme_to_scsi(self): + args = dict( + config=[ + { + "name": "fc18/10", + "analytics": "fc-scsi", + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + ["interface fc18/10", "analytics type fc-scsi"], + ) + + def test_analytics_nvme_to_scsi_replaced(self): + args = dict( + config=[ + { + "name": "fc18/10", + "analytics": "fc-scsi", + }, + ], + state="replaced", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + [ + "interface fc18/10", + "no switchport description", + "no switchport speed auto max 16000", + "no switchport mode auto", + "switchport trunk mode on", + "shutdown", + "no analytics type fc-all", + "analytics type fc-scsi", + ], + ) + + def test_analytics_nvme_to_all(self): + args = dict( + config=[ + { + "name": "fc18/10", + "analytics": "fc-all", + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + ["interface fc18/10", "analytics type fc-all"], + ) + + def test_analytics_nvme_to_all_replaced(self): + args = dict( + config=[ + { + "name": "fc18/10", + "analytics": "fc-all", + }, + ], + state="replaced", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + [ + "interface fc18/10", + "no switchport description", + "no switchport speed auto max 16000", + "no switchport mode auto", + "switchport trunk mode on", + "shutdown", + "analytics type fc-all", + ], + ) + + def test_analytics_none_to_scsi(self): + args = dict( + config=[ + { + "name": "fc1/1", + "analytics": "fc-scsi", + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual(result["commands"], ["interface fc1/1", "analytics type fc-scsi"]) + + def test_analytics_none_to_scsi_replaced(self): + args = dict( + config=[ + { + "name": "fc1/1", + "analytics": "fc-scsi", + }, + ], + state="replaced", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + [ + "interface fc1/1", + "no switchport description", + "no switchport speed auto", + "no switchport mode auto", + "switchport trunk mode on", + "shutdown", + "analytics type fc-scsi", + ], + ) + + def test_analytics_none_to_nvme(self): + args = dict( + config=[ + { + "name": "fc1/1", + "analytics": "fc-nvme", + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual(result["commands"], ["interface fc1/1", "analytics type fc-nvme"]) + + def test_analytics_none_to_nvme_replaced(self): + args = dict( + config=[ + { + "name": "fc1/1", + "analytics": "fc-nvme", + }, + ], + state="replaced", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + [ + "interface fc1/1", + "no switchport description", + "no switchport speed auto", + "no switchport mode auto", + "switchport trunk mode on", + "shutdown", + "analytics type fc-nvme", + ], + ) + + def test_analytics_none_to_nvme_overridden(self): + args = dict( + config=[ + { + "name": "fc1/1", + "analytics": "fc-nvme", + }, + ], + state="overridden", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + [ + "interface fc1/2", + "no switchport speed 1000", + "no switchport mode E", + "switchport trunk mode on", + "shutdown", + "interface fc1/3", + "no switchport speed 2000", + "no switchport mode F", + "switchport trunk mode on", + "shutdown", + "interface fc18/1", + "no switchport speed 4000", + "no switchport mode Fx", + "switchport trunk mode on", + "shutdown", + "interface fc18/2", + "no switchport speed 8000", + "no switchport mode NP", + "switchport trunk mode on", + "shutdown", + "interface fc18/3", + "no switchport speed 10000", + "no switchport mode SD", + "switchport trunk mode on", + "shutdown", + "interface fc18/4", + "no switchport speed 16000", + "no switchport mode auto", + "switchport trunk mode on", + "shutdown", + "interface fc18/5", + "no switchport speed 32000", + "no switchport mode auto", + "switchport trunk mode on", + "shutdown", + "interface fc18/6", + "no switchport speed 64000", + "no switchport mode auto", + "switchport trunk mode on", + "shutdown", + "interface fc18/7", + "no switchport speed auto max 2000", + "no switchport mode auto", + "switchport trunk mode on", + "shutdown", + "interface fc18/8", + "no switchport speed auto max 4000", + "no switchport mode auto", + "switchport trunk mode on", + "shutdown", + "interface fc18/9", + "no switchport description", + "no switchport speed auto max 8000", + "no switchport mode auto", + "switchport trunk mode on", + "shutdown", + "interface fc18/10", + "no switchport description", + "no switchport speed auto max 16000", + "no switchport mode auto", + "switchport trunk mode on", + "no analytics type fc-all", + "interface fc18/11", + "no switchport description", + "no switchport speed auto max 32000", + "no switchport mode auto", + "switchport trunk mode on", + "no analytics type fc-all", + "interface fc18/12", + "no switchport description", + "no switchport speed auto max 64000", + "no switchport mode auto", + "switchport trunk mode on", + "shutdown", + "no analytics type fc-all", + "interface fc18/13", + "no switchport description", + "no switchport speed auto max 64000", + "no switchport mode auto", + "switchport trunk mode on", + "shutdown", + "no analytics type fc-all", + "interface fc1/1", + "no switchport description", + "no switchport speed auto", + "no switchport mode auto", + "switchport trunk mode on", + "shutdown", + "analytics type fc-nvme", + ], + ) + + def test_analytics_none_to_all(self): + args = dict( + config=[ + { + "name": "fc1/1", + "analytics": "fc-all", + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual(result["commands"], ["interface fc1/1", "analytics type fc-all"]) + + def test_analytics_none_to_all_replaced(self): + args = dict( + config=[ + { + "name": "fc1/1", + "analytics": "fc-all", + }, + ], + state="replaced", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + [ + "interface fc1/1", + "no switchport description", + "no switchport speed auto", + "no switchport mode auto", + "switchport trunk mode on", + "shutdown", + "analytics type fc-all", + ], + ) + + def test_analytics_nvme_to_none_checkthis(self): + args = dict( + config=[ + { + "name": "fc18/10", + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=False) + self.assertEqual(result["commands"], []) + + def test_description_change_from_one_to_another(self): + args = dict( + config=[ + { + "name": "fc18/9", + "description": "changed from sample description to new description", + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + [ + "interface fc18/9", + "switchport description changed from sample description to new description", + ], + ) + + def test_description_change_from_none_to_new(self): + args = dict( + config=[ + { + "name": "fc18/8", + "description": "new sample description", + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + [ + "interface fc18/8", + "switchport description new sample description", + ], + ) + + def test_shut_to_noshut(self): + args = dict( + config=[ + { + "name": "fc18/10", + "enabled": True, + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + [ + "interface fc18/10", + "no shutdown", + ], + ) + + def test_noshut_to_shut(self): + args = dict( + config=[ + { + "name": "fc18/6", + "enabled": False, + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + ["interface fc18/6", "shutdown"], + ) + + def test_trunkmode_auto_to_off(self): + args = dict( + config=[ + { + "name": "fc18/1", + "trunk_mode": "off", + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + ["interface fc18/1", "switchport trunk mode off"], + ) + + def test_trunkmode_auto_to_on(self): + args = dict( + config=[ + { + "name": "fc18/1", + "trunk_mode": "on", + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + ["interface fc18/1", "switchport trunk mode on"], + ) + + def test_trunkmode_on_to_off(self): + args = dict( + config=[ + { + "name": "fc1/1", + "trunk_mode": "off", + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + ["interface fc1/1", "switchport trunk mode off"], + ) + + def test_trunkmode_on_to_auto(self): + args = dict( + config=[ + { + "name": "fc1/1", + "trunk_mode": "auto", + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + ["interface fc1/1", "switchport trunk mode auto"], + ) + + def test_trunkmode_off_to_on(self): + args = dict( + config=[ + { + "name": "fc1/2", + "trunk_mode": "on", + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + ["interface fc1/2", "switchport trunk mode on"], + ) + + def test_trunkmode_off_to_auto(self): + args = dict( + config=[ + { + "name": "fc1/2", + "trunk_mode": "auto", + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + ["interface fc1/2", "switchport trunk mode auto"], + ) + + def test_speed_combinations(self): + port_speed = "auto" + port_name = "fc1/1" + for each_speed in allowed_speed_values: + args = dict( + config=[ + { + "name": port_name, + "speed": each_speed, + }, + ], + state="merged", + ) + if each_speed == port_speed: + changed = False + cmds = [] + else: + changed = True + cmds = [f"interface {port_name}", f"switchport speed {each_speed}"] + + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=changed) + self.assertEqual( + result["commands"], + cmds, + ) + + def test_port_mode_combinations(self): + port_mode = "auto" + port_name = "fc1/1" + for each_mode in allowed_port_modes: + args = dict( + config=[ + { + "name": port_name, + "mode": each_mode, + }, + ], + state="merged", + ) + if each_mode == port_mode: + changed = False + cmds = [] + else: + changed = True + cmds = [f"interface {port_name}", f"switchport mode {each_mode}"] + + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=changed) + self.assertEqual( + result["commands"], + cmds, + ) + + def test_deleted_1(self): + # before- trunk mode on + args = dict( + config=[ + { + "name": "fc1/2", + }, + ], + state="deleted", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + [ + "interface fc1/2", + "no switchport speed 1000", + "no switchport mode E", + "switchport trunk mode on", + "shutdown", + ], + ) + + def test_deleted_2(self): + # before- trunk mode off + args = dict( + config=[ + { + "name": "fc1/3", + }, + ], + state="deleted", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + [ + "interface fc1/3", + "no switchport speed 2000", + "no switchport mode F", + "switchport trunk mode on", + "shutdown", + ], + ) + + def test_deleted_3(self): + # before- port shut and with description and analytics config + args = dict( + config=[ + { + "name": "fc18/10", + }, + ], + state="deleted", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + [ + "interface fc18/10", + "no switchport description", + "no switchport speed auto max 16000", + "no switchport mode auto", + "switchport trunk mode on", + "no analytics type fc-all", + ], + ) + + def test_replaced_move_to_def(self): + args = dict( + config=[ + { + "name": "fc18/10", + }, + ], + state="replaced", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + [ + "interface fc18/10", + "no switchport description", + "no switchport speed auto max 16000", + "no switchport mode auto", + "switchport trunk mode on", + "shutdown", + "no analytics type fc-all", + ], + ) + + def test_deleted_combined(self): + args = dict( + config=[ + { + "name": "fc1/2", + }, + { + "name": "fc1/3", + }, + { + "name": "fc18/10", + }, + ], + state="deleted", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + [ + "interface fc1/2", + "no switchport speed 1000", + "no switchport mode E", + "switchport trunk mode on", + "shutdown", + "interface fc1/3", + "no switchport speed 2000", + "no switchport mode F", + "switchport trunk mode on", + "shutdown", + "interface fc18/10", + "no switchport description", + "no switchport speed auto max 16000", + "no switchport mode auto", + "switchport trunk mode on", + "no analytics type fc-all", + ], + ) + + def test_most_of_them_combined(self): + args = dict( + config=[ + { + "name": "fc18/13", + "speed": "auto max 64000", + "mode": "auto", + "trunk_mode": "on", + "enabled": True, + "description": "1", + "analytics": "fc-all", + }, + { + "name": "fc18/12", + "speed": "auto max 64000", + "mode": "auto", + "trunk_mode": "on", + "enabled": True, + "description": "1", + "analytics": "fc-scsi", + }, + { + "name": "fc18/11", + "speed": "auto max 32000", + "mode": "auto", + "trunk_mode": "on", + "enabled": False, + "description": "a", + "analytics": "fc-all", + }, + { + "name": "fc18/10", + "analytics": "fc-scsi", + "enabled": True, + }, + { + "name": "fc18/9", + "description": "changed from sample description to new description", + }, + { + "name": "fc18/8", + "description": "new sample description", + }, + { + "name": "fc18/6", + "enabled": False, + }, + { + "name": "fc18/1", + "trunk_mode": "off", + }, + { + "name": "fc1/1", + "trunk_mode": "auto", + "analytics": "fc-all", + }, + { + "name": "fc1/2", + "trunk_mode": "on", + }, + ], + state="merged", + ) + set_module_args(args, ignore_provider_arg) + result = self.execute_module(changed=True) + self.assertEqual( + result["commands"], + [ + "interface fc1/1", + "switchport trunk mode auto", + "analytics type fc-all", + ] + + [ + "interface fc1/2", + "switchport trunk mode on", + ] + + [ + "interface fc18/1", + "switchport trunk mode off", + ] + + [ + "interface fc18/6", + "shutdown", + ] + + [ + "interface fc18/8", + "switchport description new sample description", + ] + + [ + "interface fc18/9", + "switchport description changed from sample description to new description", + ] + + [ + "interface fc18/10", + "no shutdown", + # "no analytics type fc-all", + "analytics type fc-scsi", + ] + + [ + "interface fc18/11", + "analytics type fc-all", + ], + # + [ + # "interface fc18/12", + # # "no analytics type fc-all", + # "analytics type fc-scsi", + # ], + ) diff --git a/tests/unit/modules/network/nxos/test_nxos_route_maps.py b/tests/unit/modules/network/nxos/test_nxos_route_maps.py index 53069a1e9..06d76fe38 100644 --- a/tests/unit/modules/network/nxos/test_nxos_route_maps.py +++ b/tests/unit/modules/network/nxos/test_nxos_route_maps.py @@ -1415,3 +1415,81 @@ def test_nxos_route_maps_next_hop_replaced(self): ] result = self.execute_module(changed=True) self.assertEqual(set(result["commands"]), set(commands)) + + def test_nxos_route_maps_extcomm_rt(self): + # test for extcommunity.rt + self.get_config.return_value = dedent( + """\ + route-map test-1 permit 10 + set extcommunity rt additive + route-map test-2 permit 11 + set extcommunity rt 65000:516590 65000:516591 65000:516592 additive + """, + ) + set_module_args( + dict( + config=[ + dict( + route_map="test-1", + entries=[ + dict( + action="permit", + sequence=10, + set=dict( + extcommunity=dict( + rt=dict( + extcommunity_numbers=[ + "65000:516586", + ], + additive=True, + ), + ), + ), + ), + ], + ), + ], + state="merged", + ), + ignore_provider_arg, + ) + commands = [ + "route-map test-1 permit 10", + "set extcommunity rt 65000:516586 additive", + ] + result = self.execute_module(changed=True) + self.assertEqual(set(result["commands"]), set(commands)) + + set_module_args( + dict( + config=[ + dict( + route_map="test-2", + entries=[ + dict( + action="permit", + sequence=11, + set=dict( + extcommunity=dict( + rt=dict( + extcommunity_numbers=[ + "65000:516590", + ], + ), + ), + ), + ), + ], + ), + ], + state="replaced", + ), + ignore_provider_arg, + ) + commands = [ + "route-map test-2 permit 11", + "no set extcommunity rt 65000:516590 65000:516591 65000:516592 additive", + "set extcommunity rt 65000:516590", + ] + result = self.execute_module(changed=True) + self.assertEqual(set(result["commands"]), set(commands)) diff --git a/tests/unit/modules/network/nxos/test_nxos_snmp_server.py b/tests/unit/modules/network/nxos/test_nxos_snmp_server.py index 1b66d6455..1b7672775 100644 --- a/tests/unit/modules/network/nxos/test_nxos_snmp_server.py +++ b/tests/unit/modules/network/nxos/test_nxos_snmp_server.py @@ -793,10 +793,8 @@ def test_nxos_snmp_server_users_replaced(self): ignore_provider_arg, ) commands = [ - "no snmp-server user user2 network-admin auth md5 0x5632724fb8ac3699296af262 priv" - " 0x5632724fb8ac3699296af262 localizedkey engineID 2:2:2:2:2", - "no snmp-server user user3 network-admin auth md5 0x5632724fb8ac3699296af262 priv" - " aes-128 0x5632724fb8ac3699296af262 localizedkey engineID 3:3:3:3:3", + "no snmp-server user user2", + "no snmp-server user user3", "snmp-server user user4 network-admin auth md5 0x5632724fb8ac3699296af262 priv aes-128" " 0x5632724fb8ac3699296af262 localizedkey engineID 3:3:3:3:3", ]