mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fix net_get and net_put task run failure (#56145)
* net_get and net_put action plugin class need to inherit from ActionBase class as the action class implements the entire get and put logic
This commit is contained in:
parent
0e0c2a7db7
commit
9271b4e368
2 changed files with 49 additions and 5 deletions
|
@ -23,16 +23,17 @@ import re
|
|||
import uuid
|
||||
import hashlib
|
||||
|
||||
from ansible.errors import AnsibleError
|
||||
from ansible.module_utils._text import to_text, to_bytes
|
||||
from ansible.module_utils.connection import Connection
|
||||
from ansible.plugins.action.network import ActionModule as NetworkActionModule
|
||||
from ansible.plugins.action import ActionBase
|
||||
from ansible.module_utils.six.moves.urllib.parse import urlsplit
|
||||
from ansible.utils.display import Display
|
||||
|
||||
display = Display()
|
||||
|
||||
|
||||
class ActionModule(NetworkActionModule):
|
||||
class ActionModule(ActionBase):
|
||||
|
||||
def run(self, tmp=None, task_vars=None):
|
||||
socket_path = None
|
||||
|
@ -48,7 +49,7 @@ class ActionModule(NetworkActionModule):
|
|||
return result
|
||||
|
||||
try:
|
||||
src = self._task.args.get('src')
|
||||
src = self._task.args['src']
|
||||
except KeyError as exc:
|
||||
return {'failed': True, 'msg': 'missing required argument: %s' % exc}
|
||||
|
||||
|
@ -152,3 +153,24 @@ class ActionModule(NetworkActionModule):
|
|||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
def _get_working_path(self):
|
||||
cwd = self._loader.get_basedir()
|
||||
if self._task._role is not None:
|
||||
cwd = self._task._role._role_path
|
||||
return cwd
|
||||
|
||||
def _get_network_os(self, task_vars):
|
||||
if 'network_os' in self._task.args and self._task.args['network_os']:
|
||||
display.vvvv('Getting network OS from task argument')
|
||||
network_os = self._task.args['network_os']
|
||||
elif self._play_context.network_os:
|
||||
display.vvvv('Getting network OS from inventory')
|
||||
network_os = self._play_context.network_os
|
||||
elif 'network_os' in task_vars.get('ansible_facts', {}) and task_vars['ansible_facts']['network_os']:
|
||||
display.vvvv('Getting network OS from fact')
|
||||
network_os = task_vars['ansible_facts']['network_os']
|
||||
else:
|
||||
raise AnsibleError('ansible_network_os must be specified on this host')
|
||||
|
||||
return network_os
|
||||
|
|
|
@ -25,16 +25,17 @@ import hashlib
|
|||
import sys
|
||||
import re
|
||||
|
||||
from ansible.errors import AnsibleError
|
||||
from ansible.module_utils._text import to_text, to_bytes
|
||||
from ansible.module_utils.connection import Connection
|
||||
from ansible.plugins.action.network import ActionModule as NetworkActionModule
|
||||
from ansible.plugins.action import ActionBase
|
||||
from ansible.module_utils.six.moves.urllib.parse import urlsplit
|
||||
from ansible.utils.display import Display
|
||||
|
||||
display = Display()
|
||||
|
||||
|
||||
class ActionModule(NetworkActionModule):
|
||||
class ActionModule(ActionBase):
|
||||
|
||||
def run(self, tmp=None, task_vars=None):
|
||||
changed = True
|
||||
|
@ -195,3 +196,24 @@ class ActionModule(NetworkActionModule):
|
|||
raise ValueError('path specified in src not found')
|
||||
|
||||
return source
|
||||
|
||||
def _get_working_path(self):
|
||||
cwd = self._loader.get_basedir()
|
||||
if self._task._role is not None:
|
||||
cwd = self._task._role._role_path
|
||||
return cwd
|
||||
|
||||
def _get_network_os(self, task_vars):
|
||||
if 'network_os' in self._task.args and self._task.args['network_os']:
|
||||
display.vvvv('Getting network OS from task argument')
|
||||
network_os = self._task.args['network_os']
|
||||
elif self._play_context.network_os:
|
||||
display.vvvv('Getting network OS from inventory')
|
||||
network_os = self._play_context.network_os
|
||||
elif 'network_os' in task_vars.get('ansible_facts', {}) and task_vars['ansible_facts']['network_os']:
|
||||
display.vvvv('Getting network OS from fact')
|
||||
network_os = task_vars['ansible_facts']['network_os']
|
||||
else:
|
||||
raise AnsibleError('ansible_network_os must be specified on this host')
|
||||
|
||||
return network_os
|
||||
|
|
Loading…
Reference in a new issue