|
|
|
|
@ -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
|
|
|
|
|
|