From fa66813696b372bc4b8e0d836968e226a56928c7 Mon Sep 17 00:00:00 2001 From: Ganesh Nalawade Date: Thu, 9 Jan 2020 18:42:00 +0530 Subject: [PATCH] Fix net_put module text file issue (#66065) * Modify the parent class for net_put and net_get module to refer from `ActionModule` class in network.py action plugin which contains the common code for network plugins. * Replace `_handle_template` with `_handle_src_option` function name which is defined in common class. --- changelogs/fragments/net_put_fix.yml | 2 ++ lib/ansible/plugins/action/net_get.py | 4 ++-- lib/ansible/plugins/action/net_put.py | 6 +++--- 3 files changed, 7 insertions(+), 5 deletions(-) create mode 100644 changelogs/fragments/net_put_fix.yml diff --git a/changelogs/fragments/net_put_fix.yml b/changelogs/fragments/net_put_fix.yml new file mode 100644 index 00000000000..46eb46de129 --- /dev/null +++ b/changelogs/fragments/net_put_fix.yml @@ -0,0 +1,2 @@ +bugfixes: +- Fix net_put module to handle text based files (https://github.com/ansible/ansible/issues/66059) diff --git a/lib/ansible/plugins/action/net_get.py b/lib/ansible/plugins/action/net_get.py index 4f96f9d9615..d9bc6e53981 100644 --- a/lib/ansible/plugins/action/net_get.py +++ b/lib/ansible/plugins/action/net_get.py @@ -25,14 +25,14 @@ import hashlib from ansible.errors import AnsibleError from ansible.module_utils._text import to_text, to_bytes from ansible.module_utils.connection import Connection, ConnectionError -from ansible.plugins.action import ActionBase +from ansible.plugins.action.network import ActionModule as ActionNetworkModule from ansible.module_utils.six.moves.urllib.parse import urlsplit from ansible.utils.display import Display display = Display() -class ActionModule(ActionBase): +class ActionModule(ActionNetworkModule): def run(self, tmp=None, task_vars=None): socket_path = None diff --git a/lib/ansible/plugins/action/net_put.py b/lib/ansible/plugins/action/net_put.py index a1b83fc6c42..e8aef23d420 100644 --- a/lib/ansible/plugins/action/net_put.py +++ b/lib/ansible/plugins/action/net_put.py @@ -24,14 +24,14 @@ import hashlib from ansible.errors import AnsibleError from ansible.module_utils._text import to_text, to_bytes from ansible.module_utils.connection import Connection, ConnectionError -from ansible.plugins.action import ActionBase +from ansible.plugins.action.network import ActionModule as ActionNetworkModule from ansible.module_utils.six.moves.urllib.parse import urlsplit from ansible.utils.display import Display display = Display() -class ActionModule(ActionBase): +class ActionModule(ActionNetworkModule): def run(self, tmp=None, task_vars=None): socket_path = None @@ -69,7 +69,7 @@ class ActionModule(ActionBase): if mode == 'text': try: - self._handle_template(convert_data=False) + self._handle_src_option(convert_data=False) except ValueError as exc: return dict(failed=True, msg=to_text(exc))