From 6c8315e6971c323beb1d693a5b70ee7992196816 Mon Sep 17 00:00:00 2001 From: Nathaniel Case Date: Wed, 2 Dec 2020 11:26:38 -0500 Subject: [PATCH 1/5] Remove deprecated options --- .../fragments/remove-netconf_config-args.yaml | 2 + plugins/doc_fragments/netconf.py | 68 ------------------- plugins/modules/netconf_config.py | 57 ---------------- 3 files changed, 2 insertions(+), 125 deletions(-) create mode 100644 changelogs/fragments/remove-netconf_config-args.yaml delete mode 100644 plugins/doc_fragments/netconf.py diff --git a/changelogs/fragments/remove-netconf_config-args.yaml b/changelogs/fragments/remove-netconf_config-args.yaml new file mode 100644 index 000000000..ef80a60a8 --- /dev/null +++ b/changelogs/fragments/remove-netconf_config-args.yaml @@ -0,0 +1,2 @@ +major_changes: +- Remove deprecated connection arguments from netconf_config diff --git a/plugins/doc_fragments/netconf.py b/plugins/doc_fragments/netconf.py deleted file mode 100644 index e90ed8c76..000000000 --- a/plugins/doc_fragments/netconf.py +++ /dev/null @@ -1,68 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function - -__metaclass__ = type - -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) - - -class ModuleDocFragment(object): - - # Standard files documentation fragment - DOCUMENTATION = r"""options: - host: - description: - - Specifies the DNS host name or address for connecting to the remote device over - the specified transport. The value of host is used as the destination address - for the transport. - type: str - port: - description: - - Specifies the port to use when building the connection to the remote device. The - port value will default to port 830. - type: int - default: 830 - username: - description: - - Configures the username to use to authenticate the connection to the remote - device. This value is used to authenticate the SSH session. If the value is - not specified in the task, the value of environment variable C(ANSIBLE_NET_USERNAME) - will be used instead. - type: str - password: - description: - - Specifies the password to use to authenticate the connection to the remote device. This - value is used to authenticate the SSH session. If the value is not specified - in the task, the value of environment variable C(ANSIBLE_NET_PASSWORD) will - be used instead. - type: str - timeout: - description: - - Specifies the timeout in seconds for communicating with the network device for - either connecting or sending commands. If the timeout is exceeded before the - operation is completed, the module will error. - type: int - default: 10 - ssh_keyfile: - description: - - Specifies the SSH key to use to authenticate the connection to the remote device. This - value is the path to the key used to authenticate the SSH session. If the value - is not specified in the task, the value of environment variable C(ANSIBLE_NET_SSH_KEYFILE) - will be used instead. - type: path - hostkey_verify: - description: - - If set to C(yes), the ssh host key of the device must match a ssh key present - on the host if set to C(no), the ssh host key of the device is not checked. - type: bool - default: true - look_for_keys: - description: - - Enables looking in the usual locations for the ssh keys (e.g. :file:`~/.ssh/id_*`) - type: bool - default: true -notes: -- For information on using netconf see the :ref:`Platform Options guide using Netconf` -- For more information on using Ansible to manage network devices see the :ref:`Ansible - Network Guide ` -""" diff --git a/plugins/modules/netconf_config.py b/plugins/modules/netconf_config.py index 899f2b371..858634022 100644 --- a/plugins/modules/netconf_config.py +++ b/plugins/modules/netconf_config.py @@ -21,7 +21,6 @@ and detects if there was a configuration change. version_added: 1.0.0 extends_documentation_fragment: -- ansible.netcommon.netconf - ansible.netcommon.network_agnostic options: content: @@ -468,62 +467,6 @@ def main(): get_filter=dict(type="raw"), ) - # deprecated options - netconf_top_spec = { - "src": dict( - type="path", - removed_at_date="2020-12-01", - removed_from_collection="ansible.netcommon", - ), - "host": dict( - removed_at_date="2020-12-01", - removed_from_collection="ansible.netcommon", - ), - "port": dict( - removed_at_date="2020-12-01", - removed_from_collection="ansible.netcommon", - type="int", - default=830, - ), - "username": dict( - fallback=(env_fallback, ["ANSIBLE_NET_USERNAME"]), - removed_at_date="2020-12-01", - removed_from_collection="ansible.netcommon", - no_log=True, - ), - "password": dict( - fallback=(env_fallback, ["ANSIBLE_NET_PASSWORD"]), - removed_at_date="2020-12-01", - removed_from_collection="ansible.netcommon", - no_log=True, - ), - "ssh_keyfile": dict( - fallback=(env_fallback, ["ANSIBLE_NET_SSH_KEYFILE"]), - removed_at_date="2020-12-01", - removed_from_collection="ansible.netcommon", - type="path", - ), - "hostkey_verify": dict( - removed_at_date="2020-12-01", - removed_from_collection="ansible.netcommon", - type="bool", - default=True, - ), - "look_for_keys": dict( - removed_at_date="2020-12-01", - removed_from_collection="ansible.netcommon", - type="bool", - default=True, - ), - "timeout": dict( - removed_at_date="2020-12-01", - removed_from_collection="ansible.netcommon", - type="int", - default=10, - ), - } - argument_spec.update(netconf_top_spec) - mutually_exclusive = [ ("content", "src", "source_datastore", "delete", "confirm_commit") ] From 4e89032cfb11f88e3e0539a19b75feca7bf76283 Mon Sep 17 00:00:00 2001 From: Nathaniel Case Date: Wed, 2 Dec 2020 12:19:16 -0500 Subject: [PATCH 2/5] Special consideration for removing src --- plugins/modules/netconf_config.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/plugins/modules/netconf_config.py b/plugins/modules/netconf_config.py index 858634022..20d934d5e 100644 --- a/plugins/modules/netconf_config.py +++ b/plugins/modules/netconf_config.py @@ -166,13 +166,6 @@ capability. type: bool default: false - src: - description: - - Specifies the source path to the xml file that contains the configuration or - configuration template to load. The path to the source file can either be the - full path on the Ansible control host or a relative path from the playbook or - role root directory. This argument is mutually exclusive with I(xml). - type: path backup_options: description: - This is a dict object containing configurable options related to backup file @@ -468,10 +461,10 @@ def main(): ) mutually_exclusive = [ - ("content", "src", "source_datastore", "delete", "confirm_commit") + ("content", "source_datastore", "delete", "confirm_commit") ] required_one_of = [ - ("content", "src", "source_datastore", "delete", "confirm_commit") + ("content", "source_datastore", "delete", "confirm_commit") ] module = AnsibleModule( @@ -481,7 +474,7 @@ def main(): supports_check_mode=True, ) - config = module.params["content"] or module.params["src"] + config = module.params["content"] target = module.params["target"] lock = module.params["lock"] source = module.params["source_datastore"] From 21c25b9e7ca149553d22fe0a1fcf5ecbeeead894 Mon Sep 17 00:00:00 2001 From: Nathaniel Case Date: Thu, 3 Dec 2020 07:56:26 -0500 Subject: [PATCH 3/5] Drop unused import --- plugins/modules/netconf_config.py | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/modules/netconf_config.py b/plugins/modules/netconf_config.py index 20d934d5e..b8bd51e1e 100644 --- a/plugins/modules/netconf_config.py +++ b/plugins/modules/netconf_config.py @@ -391,7 +391,6 @@ """ from ansible.module_utils._text import to_text -from ansible.module_utils.basic import AnsibleModule, env_fallback from ansible.module_utils.connection import Connection, ConnectionError from ansible_collections.ansible.netcommon.plugins.module_utils.utils.data import ( validate_and_normalize_data, From 97b54eab175fd2e16f51fba07297d5ad36e960e5 Mon Sep 17 00:00:00 2001 From: Nathaniel Case Date: Thu, 28 Jan 2021 10:41:04 -0500 Subject: [PATCH 4/5] Update docs --- .gitignore | 2 +- ...nsible.netcommon.netconf_config_module.rst | 147 ------------------ .../prepare_iosxe_tests/tasks/main.yml | 2 +- .../cli_parse/fixtures/nxos_show_version.txt | 2 +- .../fixtures/nxos_show_version.cfg | 12 +- 5 files changed, 9 insertions(+), 156 deletions(-) diff --git a/.gitignore b/.gitignore index 7db61e6d0..894a44cc0 100644 --- a/.gitignore +++ b/.gitignore @@ -101,4 +101,4 @@ venv.bak/ /site # mypy -.mypy_cache/ \ No newline at end of file +.mypy_cache/ diff --git a/docs/ansible.netcommon.netconf_config_module.rst b/docs/ansible.netcommon.netconf_config_module.rst index 2f72e9080..53b1dfebb 100644 --- a/docs/ansible.netcommon.netconf_config_module.rst +++ b/docs/ansible.netcommon.netconf_config_module.rst @@ -281,40 +281,6 @@ Parameters
This argument specifies the XML string which acts as a filter to restrict the portions of the data retrieved from the remote device when comparing the before and after state of the device following calls to edit_config. When not specified, the entire configuration or state data is returned for comparison depending on the value of source option. The get_filter value can be either XML string or XPath or JSON string or native python dictionary, if the filter is in XPath format the NETCONF server running on remote host should support xpath capability else it will result in an error.
- - -
- host - -
- string -
- - - - -
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport.
- - - - -
- hostkey_verify - -
- boolean -
- - -
    Choices: -
  • no
  • -
  • yes ←
  • -
- - -
If set to yes, the ssh host key of the device must match a ssh key present on the host if set to no, the ssh host key of the device is not checked.
- -
@@ -335,56 +301,6 @@ Parameters
Instructs the module to explicitly lock the datastore specified as target. By setting the option value always is will explicitly lock the datastore mentioned in target option. It the value is never it will not lock the target datastore. The value if-supported lock the target datastore only if it is supported by the remote Netconf server.
- - -
- look_for_keys - -
- boolean -
- - -
    Choices: -
  • no
  • -
  • yes ←
  • -
- - -
Enables looking in the usual locations for the ssh keys (e.g. :file:`~/.ssh/id_*`)
- - - - -
- password - -
- string -
- - - - -
Specifies the password to use to authenticate the connection to the remote device. This value is used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_PASSWORD will be used instead.
- - - - -
- port - -
- integer -
- - - Default:
830
- - -
Specifies the port to use when building the connection to the remote device. The port value will default to port 830.
- -
@@ -420,36 +336,6 @@ Parameters

aliases: source
- - -
- src - -
- path -
- - - - -
Specifies the source path to the xml file that contains the configuration or configuration template to load. The path to the source file can either be the full path on the Ansible control host or a relative path from the playbook or role root directory. This argument is mutually exclusive with xml.
- - - - -
- ssh_keyfile - -
- path -
- - - - -
Specifies the SSH key to use to authenticate the connection to the remote device. This value is the path to the key used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_SSH_KEYFILE will be used instead.
- -
@@ -471,37 +357,6 @@ Parameters

aliases: datastore
- - -
- timeout - -
- integer -
- - - Default:
10
- - -
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error.
- - - - -
- username - -
- string -
- - - - -
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_USERNAME will be used instead.
- -
@@ -532,8 +387,6 @@ Notes - This module requires the netconf system service be enabled on the remote device being managed. - This module supports devices with and without the candidate and confirmed-commit capabilities. It will always use the safer feature. - This module supports the use of connection=netconf - - For information on using netconf see the :ref:`Platform Options guide using Netconf` - - For more information on using Ansible to manage network devices see the :ref:`Ansible Network Guide ` - This module is supported on ``ansible_network_os`` network platforms. See the :ref:`Network Platform Options ` for details. diff --git a/tests/integration/targets/prepare_iosxe_tests/tasks/main.yml b/tests/integration/targets/prepare_iosxe_tests/tasks/main.yml index a9c60e00f..a98c4b9bb 100644 --- a/tests/integration/targets/prepare_iosxe_tests/tasks/main.yml +++ b/tests/integration/targets/prepare_iosxe_tests/tasks/main.yml @@ -4,4 +4,4 @@ ansible.netcommon.cli_config: config: restconf vars: - ansible_network_os: cisco.ios.ios \ No newline at end of file + ansible_network_os: cisco.ios.ios diff --git a/tests/unit/plugins/action/cli_parse/fixtures/nxos_show_version.txt b/tests/unit/plugins/action/cli_parse/fixtures/nxos_show_version.txt index a50e66871..b797d71c7 100644 --- a/tests/unit/plugins/action/cli_parse/fixtures/nxos_show_version.txt +++ b/tests/unit/plugins/action/cli_parse/fixtures/nxos_show_version.txt @@ -35,4 +35,4 @@ Last reset plugin Core Plugin, Ethernet Plugin -Active Package(s): \ No newline at end of file +Active Package(s): diff --git a/tests/unit/plugins/cli_parsers/fixtures/nxos_show_version.cfg b/tests/unit/plugins/cli_parsers/fixtures/nxos_show_version.cfg index e5cad056e..c4c36b8d7 100644 --- a/tests/unit/plugins/cli_parsers/fixtures/nxos_show_version.cfg +++ b/tests/unit/plugins/cli_parsers/fixtures/nxos_show_version.cfg @@ -12,15 +12,15 @@ http://www.gnu.org/licenses/gpl.html. Nexus 9000v is a demo version of the Nexus Operating System Software - BIOS: version + BIOS: version NXOS: version 7.0(3)I7(1) - BIOS compile time: + BIOS compile time: NXOS image file is: bootflash:///nxos.7.0.3.I7.1.bin NXOS compile time: 8/31/2017 14:00:00 [08/31/2017 22:29:32] Hardware - cisco Nexus9000 9000v Chassis + cisco Nexus9000 9000v Chassis with 4041236 kB of memory. Processor Board ID 96NK4OUJH32 @@ -28,10 +28,10 @@ Hardware bootflash: 3509454 kB Kernel uptime is 12 day(s), 23 hour(s), 48 minute(s), 10 second(s) -Last reset +Last reset Reason: Unknown - System version: - Service: + System version: + Service: plugin Core Plugin, Ethernet Plugin From ed102dc1bf3295b9528085e88d15ce051d1e714b Mon Sep 17 00:00:00 2001 From: Nathaniel Case Date: Mon, 1 Feb 2021 11:21:09 -0500 Subject: [PATCH 5/5] Oops --- plugins/modules/netconf_config.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/modules/netconf_config.py b/plugins/modules/netconf_config.py index b8bd51e1e..5b42be52c 100644 --- a/plugins/modules/netconf_config.py +++ b/plugins/modules/netconf_config.py @@ -391,6 +391,7 @@ """ from ansible.module_utils._text import to_text +from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.connection import Connection, ConnectionError from ansible_collections.ansible.netcommon.plugins.module_utils.utils.data import ( validate_and_normalize_data,