mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
Initial commit
This commit is contained in:
commit
aebc1b03fd
4861 changed files with 812621 additions and 0 deletions
0
plugins/action/__init__.py
Normal file
0
plugins/action/__init__.py
Normal file
79
plugins/action/aireos.py
Normal file
79
plugins/action/aireos.py
Normal file
|
@ -0,0 +1,79 @@
|
|||
#
|
||||
# (c) 2016 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import sys
|
||||
import copy
|
||||
|
||||
from ansible import constants as C
|
||||
from ansible_collections.ansible.netcommon.plugins.action.network import ActionModule as ActionNetworkModule
|
||||
from ansible_collections.community.general.plugins.module_utils.network.aireos.aireos import aireos_provider_spec
|
||||
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import load_provider
|
||||
from ansible.utils.display import Display
|
||||
|
||||
display = Display()
|
||||
|
||||
|
||||
class ActionModule(ActionNetworkModule):
|
||||
|
||||
def run(self, tmp=None, task_vars=None):
|
||||
del tmp # tmp no longer has any effect
|
||||
|
||||
module_name = self._task.action.split('.')[-1]
|
||||
self._config_module = True if module_name == 'aireos_config' else False
|
||||
|
||||
if self._play_context.connection != 'local':
|
||||
return dict(
|
||||
failed=True,
|
||||
msg='invalid connection specified, expected connection=local, '
|
||||
'got %s' % self._play_context.connection
|
||||
)
|
||||
|
||||
provider = load_provider(aireos_provider_spec, self._task.args)
|
||||
|
||||
pc = copy.deepcopy(self._play_context)
|
||||
pc.connection = 'network_cli'
|
||||
pc.network_os = 'aireos'
|
||||
pc.remote_addr = provider['host'] or self._play_context.remote_addr
|
||||
pc.port = int(provider['port'] or self._play_context.port or 22)
|
||||
pc.remote_user = provider['username'] or self._play_context.connection_user
|
||||
pc.password = provider['password'] or self._play_context.password
|
||||
command_timeout = int(provider['timeout'] or C.PERSISTENT_COMMAND_TIMEOUT)
|
||||
|
||||
display.vvv('using connection plugin %s (was local)' % pc.connection, pc.remote_addr)
|
||||
connection = self._shared_loader_obj.connection_loader.get('persistent', pc, sys.stdin, task_uuid=self._task._uuid)
|
||||
connection.set_options(direct={'persistent_command_timeout': command_timeout})
|
||||
|
||||
socket_path = connection.run()
|
||||
display.vvvv('socket_path: %s' % socket_path, pc.remote_addr)
|
||||
if not socket_path:
|
||||
return {'failed': True,
|
||||
'msg': 'unable to open shell. Please see: ' +
|
||||
'https://docs.ansible.com/ansible/network_debug_troubleshooting.html#unable-to-open-shell'}
|
||||
|
||||
task_vars['ansible_socket'] = socket_path
|
||||
|
||||
if self._play_context.become_method == 'enable':
|
||||
self._play_context.become = False
|
||||
self._play_context.become_method = None
|
||||
|
||||
result = super(ActionModule, self).run(task_vars=task_vars)
|
||||
|
||||
return result
|
79
plugins/action/aruba.py
Normal file
79
plugins/action/aruba.py
Normal file
|
@ -0,0 +1,79 @@
|
|||
#
|
||||
# (c) 2016 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import sys
|
||||
import copy
|
||||
|
||||
from ansible import constants as C
|
||||
from ansible_collections.ansible.netcommon.plugins.action.network import ActionModule as ActionNetworkModule
|
||||
from ansible_collections.community.general.plugins.module_utils.network.aruba.aruba import aruba_provider_spec
|
||||
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import load_provider
|
||||
from ansible.utils.display import Display
|
||||
|
||||
display = Display()
|
||||
|
||||
|
||||
class ActionModule(ActionNetworkModule):
|
||||
|
||||
def run(self, tmp=None, task_vars=None):
|
||||
del tmp # tmp no longer has any effect
|
||||
|
||||
module_name = self._task.action.split('.')[-1]
|
||||
self._config_module = True if module_name == 'aruba_config' else False
|
||||
|
||||
if self._play_context.connection != 'local':
|
||||
return dict(
|
||||
failed=True,
|
||||
msg='invalid connection specified, expected connection=local, '
|
||||
'got %s' % self._play_context.connection
|
||||
)
|
||||
|
||||
provider = load_provider(aruba_provider_spec, self._task.args)
|
||||
|
||||
pc = copy.deepcopy(self._play_context)
|
||||
pc.connection = 'network_cli'
|
||||
pc.network_os = 'aruba'
|
||||
pc.remote_addr = provider['host'] or self._play_context.remote_addr
|
||||
pc.port = int(provider['port'] or self._play_context.port or 22)
|
||||
pc.remote_user = provider['username'] or self._play_context.connection_user
|
||||
pc.password = provider['password'] or self._play_context.password
|
||||
pc.private_key_file = provider['ssh_keyfile'] or self._play_context.private_key_file
|
||||
command_timeout = int(provider['timeout'] or C.PERSISTENT_COMMAND_TIMEOUT)
|
||||
|
||||
display.vvv('using connection plugin %s (was local)' % pc.connection, pc.remote_addr)
|
||||
connection = self._shared_loader_obj.connection_loader.get('persistent', pc, sys.stdin, task_uuid=self._task._uuid)
|
||||
connection.set_options(direct={'persistent_command_timeout': command_timeout})
|
||||
|
||||
socket_path = connection.run()
|
||||
display.vvvv('socket_path: %s' % socket_path, pc.remote_addr)
|
||||
if not socket_path:
|
||||
return {'failed': True,
|
||||
'msg': 'unable to open shell. Please see: ' +
|
||||
'https://docs.ansible.com/ansible/network_debug_troubleshooting.html#unable-to-open-shell'}
|
||||
|
||||
task_vars['ansible_socket'] = socket_path
|
||||
|
||||
if self._play_context.become_method == 'enable':
|
||||
self._play_context.become = False
|
||||
self._play_context.become_method = None
|
||||
|
||||
result = super(ActionModule, self).run(task_vars=task_vars)
|
||||
return result
|
89
plugins/action/ce.py
Normal file
89
plugins/action/ce.py
Normal file
|
@ -0,0 +1,89 @@
|
|||
#
|
||||
# Copyright: (c) 2016, Red Hat Inc.
|
||||
|
||||
# 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
|
||||
|
||||
import sys
|
||||
import copy
|
||||
|
||||
from ansible import constants as C
|
||||
from ansible_collections.ansible.netcommon.plugins.action.network import ActionModule as ActionNetworkModule
|
||||
from ansible_collections.community.general.plugins.module_utils.network.cloudengine.ce import ce_provider_spec
|
||||
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import load_provider
|
||||
from ansible.utils.display import Display
|
||||
|
||||
display = Display()
|
||||
|
||||
CLI_SUPPORTED_MODULES = ['ce_rollback', 'ce_mlag_interface', 'ce_startup', 'ce_config',
|
||||
'ce_command', 'ce_facts', 'ce_evpn_global', 'ce_evpn_bgp_rr',
|
||||
'ce_mtu', 'ce_evpn_bgp', 'ce_snmp_location', 'ce_snmp_contact',
|
||||
'ce_snmp_traps', 'ce_netstream_global', 'ce_netstream_aging',
|
||||
'ce_netstream_export', 'ce_netstream_template', 'ce_ntp_auth',
|
||||
'ce_stp', 'ce_vxlan_global', 'ce_vxlan_arp', 'ce_vxlan_gateway',
|
||||
'ce_acl_interface']
|
||||
|
||||
|
||||
class ActionModule(ActionNetworkModule):
|
||||
|
||||
def run(self, tmp=None, task_vars=None):
|
||||
del tmp # tmp no longer has any effect
|
||||
|
||||
module_name = self._task.action.split('.')[-1]
|
||||
self._config_module = True if module_name == 'ce_config' else False
|
||||
socket_path = None
|
||||
persistent_connection = self._play_context.connection.split('.')[-1]
|
||||
|
||||
if self._play_context.connection == 'local':
|
||||
provider = load_provider(ce_provider_spec, self._task.args)
|
||||
transport = provider['transport'] or 'cli'
|
||||
|
||||
display.vvvv('connection transport is %s' % transport, self._play_context.remote_addr)
|
||||
|
||||
if transport == 'cli':
|
||||
pc = copy.deepcopy(self._play_context)
|
||||
pc.connection = 'network_cli'
|
||||
pc.network_os = 'ce'
|
||||
pc.remote_addr = provider['host'] or self._play_context.remote_addr
|
||||
pc.port = int(provider['port'] or self._play_context.port or 22)
|
||||
pc.remote_user = provider['username'] or self._play_context.connection_user
|
||||
pc.password = provider['password'] or self._play_context.password
|
||||
command_timeout = int(provider['timeout'] or C.PERSISTENT_COMMAND_TIMEOUT)
|
||||
self._task.args['provider'] = provider.update(
|
||||
host=pc.remote_addr,
|
||||
port=pc.port,
|
||||
username=pc.remote_user,
|
||||
password=pc.password
|
||||
)
|
||||
if module_name in ['ce_netconf'] or module_name not in CLI_SUPPORTED_MODULES:
|
||||
pc.connection = 'netconf'
|
||||
display.vvv('using connection plugin %s (was local)' % pc.connection, pc.remote_addr)
|
||||
connection = self._shared_loader_obj.connection_loader.get('persistent', pc, sys.stdin, task_uuid=self._task._uuid)
|
||||
connection.set_options(direct={'persistent_command_timeout': command_timeout})
|
||||
|
||||
socket_path = connection.run()
|
||||
display.vvvv('socket_path: %s' % socket_path, pc.remote_addr)
|
||||
if not socket_path:
|
||||
return {'failed': True,
|
||||
'msg': 'unable to open shell. Please see: ' +
|
||||
'https://docs.ansible.com/ansible/network_debug_troubleshooting.html#unable-to-open-shell'}
|
||||
|
||||
task_vars['ansible_socket'] = socket_path
|
||||
# make sure a transport value is set in args
|
||||
self._task.args['transport'] = transport
|
||||
self._task.args['provider'] = provider
|
||||
elif persistent_connection in ('netconf', 'network_cli'):
|
||||
provider = self._task.args.get('provider', {})
|
||||
if any(provider.values()):
|
||||
display.warning('provider is unnecessary when using %s and will be ignored' % self._play_context.connection)
|
||||
del self._task.args['provider']
|
||||
|
||||
if (persistent_connection == 'network_cli' and module_name not in CLI_SUPPORTED_MODULES) or \
|
||||
(persistent_connection == 'netconf' and module_name in CLI_SUPPORTED_MODULES):
|
||||
return {'failed': True, 'msg': "Connection type '%s' is not valid for '%s' module."
|
||||
% (self._play_context.connection, self._task.action)}
|
||||
|
||||
result = super(ActionModule, self).run(task_vars=task_vars)
|
||||
return result
|
104
plugins/action/ce_template.py
Normal file
104
plugins/action/ce_template.py
Normal file
|
@ -0,0 +1,104 @@
|
|||
#
|
||||
# Copyright 2015 Peter Sprygada <psprygada@ansible.com>
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import os
|
||||
import time
|
||||
import glob
|
||||
from ansible.module_utils.six.moves.urllib.parse import urlsplit
|
||||
|
||||
from ansible.module_utils._text import to_text
|
||||
from ansible_collections.community.general.plugins.action.ce import ActionModule as _ActionModule
|
||||
|
||||
|
||||
class ActionModule(_ActionModule):
|
||||
|
||||
def run(self, tmp=None, task_vars=None):
|
||||
|
||||
try:
|
||||
self._handle_template()
|
||||
except (ValueError, AttributeError) as exc:
|
||||
return dict(failed=True, msg=exc.message)
|
||||
|
||||
result = super(ActionModule, self).run(tmp, task_vars)
|
||||
del tmp # tmp no longer has any effect
|
||||
|
||||
if self._task.args.get('backup') and result.get('__backup__'):
|
||||
# User requested backup and no error occurred in module.
|
||||
# NOTE: If there is a parameter error, __backup__ key may not be in results.
|
||||
self._write_backup(task_vars['inventory_hostname'], result['__backup__'])
|
||||
|
||||
if '__backup__' in result:
|
||||
del result['__backup__']
|
||||
|
||||
return result
|
||||
|
||||
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 _write_backup(self, host, contents):
|
||||
backup_path = self._get_working_path() + '/backup'
|
||||
if not os.path.exists(backup_path):
|
||||
os.mkdir(backup_path)
|
||||
for fn in glob.glob('%s/%s*' % (backup_path, host)):
|
||||
os.remove(fn)
|
||||
tstamp = time.strftime("%Y-%m-%d@%H:%M:%S", time.localtime(time.time()))
|
||||
filename = '%s/%s_config.%s' % (backup_path, host, tstamp)
|
||||
open(filename, 'w').write(contents)
|
||||
|
||||
def _handle_template(self):
|
||||
src = self._task.args.get('src')
|
||||
if not src:
|
||||
raise ValueError('missing required arguments: src')
|
||||
|
||||
working_path = self._get_working_path()
|
||||
|
||||
if os.path.isabs(src) or urlsplit(src).scheme:
|
||||
source = src
|
||||
else:
|
||||
source = self._loader.path_dwim_relative(working_path, 'templates', src)
|
||||
if not source:
|
||||
source = self._loader.path_dwim_relative(working_path, src)
|
||||
|
||||
if not os.path.exists(source):
|
||||
return
|
||||
|
||||
try:
|
||||
with open(source, 'r') as f:
|
||||
template_data = to_text(f.read())
|
||||
except IOError:
|
||||
return dict(failed=True, msg='unable to load src file')
|
||||
|
||||
# Create a template search path in the following order:
|
||||
# [working_path, self_role_path, dependent_role_paths, dirname(source)]
|
||||
searchpath = [working_path]
|
||||
if self._task._role is not None:
|
||||
searchpath.append(self._task._role._role_path)
|
||||
if hasattr(self._task, "_block:"):
|
||||
dep_chain = self._task._block.get_dep_chain()
|
||||
if dep_chain is not None:
|
||||
for role in dep_chain:
|
||||
searchpath.append(role._role_path)
|
||||
searchpath.append(os.path.dirname(source))
|
||||
with self._templar.set_temporary_context(searchpath=searchpath):
|
||||
self._task.args['src'] = self._templar.template(template_data)
|
69
plugins/action/cnos.py
Normal file
69
plugins/action/cnos.py
Normal file
|
@ -0,0 +1,69 @@
|
|||
# (C) 2017 Red Hat Inc.
|
||||
# Copyright (C) 2017 Lenovo.
|
||||
#
|
||||
# GNU General Public License v3.0+
|
||||
#
|
||||
# This program 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.
|
||||
#
|
||||
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
#
|
||||
# Contains Action Plugin methods for CNOS Config Module
|
||||
# Lenovo Networking
|
||||
#
|
||||
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import sys
|
||||
import copy
|
||||
|
||||
from ansible import constants as C
|
||||
from ansible_collections.ansible.netcommon.plugins.action.network import ActionModule as ActionNetworkModule
|
||||
from ansible_collections.community.general.plugins.module_utils.network.cnos.cnos import cnos_provider_spec
|
||||
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import load_provider
|
||||
from ansible.utils.display import Display
|
||||
|
||||
display = Display()
|
||||
|
||||
|
||||
class ActionModule(ActionNetworkModule):
|
||||
|
||||
def run(self, tmp=None, task_vars=None):
|
||||
del tmp # tmp no longer has any effect
|
||||
|
||||
module_name = self._task.action.split('.')[-1]
|
||||
self._config_module = True if module_name == 'cnos_config' else False
|
||||
|
||||
if self._play_context.connection == 'local':
|
||||
provider = load_provider(cnos_provider_spec, self._task.args)
|
||||
pc = copy.deepcopy(self._play_context)
|
||||
pc.connection = 'network_cli'
|
||||
pc.network_os = 'cnos'
|
||||
pc.remote_addr = provider['host'] or self._play_context.remote_addr
|
||||
pc.port = provider['port'] or self._play_context.port or 22
|
||||
pc.remote_user = provider['username'] or self._play_context.connection_user
|
||||
pc.password = provider['password'] or self._play_context.password
|
||||
pc.private_key_file = provider['ssh_keyfile'] or self._play_context.private_key_file
|
||||
command_timeout = int(provider['timeout'] or C.PERSISTENT_COMMAND_TIMEOUT)
|
||||
pc.become = provider['authorize'] or True
|
||||
pc.become_pass = provider['auth_pass']
|
||||
pc.become_method = 'enable'
|
||||
|
||||
display.vvv('using connection plugin %s (was local)' % pc.connection, pc.remote_addr)
|
||||
connection = self._shared_loader_obj.connection_loader.get('persistent', pc, sys.stdin, task_uuid=self._task._uuid)
|
||||
connection.set_options(direct={'persistent_command_timeout': command_timeout})
|
||||
|
||||
socket_path = connection.run()
|
||||
display.vvvv('socket_path: %s' % socket_path, pc.remote_addr)
|
||||
if not socket_path:
|
||||
return {'failed': True,
|
||||
'msg': 'unable to open shell. Please see: ' +
|
||||
'https://docs.ansible.com/ansible/network_debug_troubleshooting.html#unable-to-open-shell'}
|
||||
|
||||
task_vars['ansible_socket'] = socket_path
|
||||
|
||||
result = super(ActionModule, self).run(task_vars=task_vars)
|
||||
return result
|
36
plugins/action/edgeos_config.py
Normal file
36
plugins/action/edgeos_config.py
Normal file
|
@ -0,0 +1,36 @@
|
|||
#
|
||||
# Copyright 2018 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
from ansible_collections.ansible.netcommon.plugins.action.network import ActionModule as ActionNetworkModule
|
||||
|
||||
|
||||
class ActionModule(ActionNetworkModule):
|
||||
|
||||
def run(self, tmp=None, task_vars=None):
|
||||
del tmp # tmp no longer has any effect
|
||||
|
||||
self._config_module = True
|
||||
|
||||
if self._play_context.connection.split('.')[-1] != 'network_cli':
|
||||
return {'failed': True, 'msg': 'Connection type %s is not valid for this module. Must use fully qualified'
|
||||
' name of network_cli connection type.' % self._play_context.connection}
|
||||
|
||||
return super(ActionModule, self).run(task_vars=task_vars)
|
69
plugins/action/enos.py
Normal file
69
plugins/action/enos.py
Normal file
|
@ -0,0 +1,69 @@
|
|||
# (C) 2017 Red Hat Inc.
|
||||
# Copyright (C) 2017 Lenovo.
|
||||
#
|
||||
# GNU General Public License v3.0+
|
||||
#
|
||||
# This program 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.
|
||||
#
|
||||
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
#
|
||||
# Contains Action Plugin methods for ENOS Config Module
|
||||
# Lenovo Networking
|
||||
#
|
||||
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import sys
|
||||
import copy
|
||||
|
||||
from ansible import constants as C
|
||||
from ansible_collections.ansible.netcommon.plugins.action.network import ActionModule as ActionNetworkModule
|
||||
from ansible_collections.community.general.plugins.module_utils.network.enos.enos import enos_provider_spec
|
||||
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import load_provider
|
||||
from ansible.utils.display import Display
|
||||
|
||||
display = Display()
|
||||
|
||||
|
||||
class ActionModule(ActionNetworkModule):
|
||||
|
||||
def run(self, tmp=None, task_vars=None):
|
||||
del tmp # tmp no longer has any effect
|
||||
|
||||
module_name = self._task.action.split('.')[-1]
|
||||
self._config_module = True if module_name == 'enos_config' else False
|
||||
|
||||
if self._play_context.connection == 'local':
|
||||
provider = load_provider(enos_provider_spec, self._task.args)
|
||||
pc = copy.deepcopy(self._play_context)
|
||||
pc.connection = 'network_cli'
|
||||
pc.network_os = 'enos'
|
||||
pc.remote_addr = provider['host'] or self._play_context.remote_addr
|
||||
pc.port = provider['port'] or self._play_context.port or 22
|
||||
pc.remote_user = provider['username'] or self._play_context.connection_user
|
||||
pc.password = provider['password'] or self._play_context.password
|
||||
pc.private_key_file = provider['ssh_keyfile'] or self._play_context.private_key_file
|
||||
command_timeout = int(provider['timeout'] or C.PERSISTENT_COMMAND_TIMEOUT)
|
||||
pc.become = provider['authorize'] or True
|
||||
pc.become_pass = provider['auth_pass']
|
||||
pc.become_method = 'enable'
|
||||
|
||||
display.vvv('using connection plugin %s (was local)' % pc.connection, pc.remote_addr)
|
||||
connection = self._shared_loader_obj.connection_loader.get('persistent', pc, sys.stdin, task_uuid=self._task._uuid)
|
||||
connection.set_options(direct={'persistent_command_timeout': command_timeout})
|
||||
|
||||
socket_path = connection.run()
|
||||
display.vvvv('socket_path: %s' % socket_path, pc.remote_addr)
|
||||
if not socket_path:
|
||||
return {'failed': True,
|
||||
'msg': 'unable to open shell. Please see: ' +
|
||||
'https://docs.ansible.com/ansible/network_debug_troubleshooting.html#unable-to-open-shell'}
|
||||
|
||||
task_vars['ansible_socket'] = socket_path
|
||||
|
||||
result = super(ActionModule, self).run(task_vars=task_vars)
|
||||
return result
|
45
plugins/action/exos.py
Normal file
45
plugins/action/exos.py
Normal file
|
@ -0,0 +1,45 @@
|
|||
#
|
||||
# Copyright 2015 Peter Sprygada <psprygada@ansible.com>
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
from ansible_collections.ansible.netcommon.plugins.action.network import ActionModule as ActionNetworkModule
|
||||
|
||||
|
||||
class ActionModule(ActionNetworkModule):
|
||||
|
||||
EXOS_NETWORK_CLI_MODULES = (
|
||||
'exos_facts',
|
||||
'exos_config',
|
||||
'exos_command')
|
||||
|
||||
def run(self, tmp=None, task_vars=None):
|
||||
del tmp # tmp no longer has any effect
|
||||
|
||||
module_name = self._task.action.split('.')[-1]
|
||||
self._config_module = True if module_name == 'exos_config' else False
|
||||
persistent_connection = self._play_context.connection.split('.')[-1]
|
||||
|
||||
if persistent_connection not in ('network_cli', 'httpapi'):
|
||||
return {'failed': True, 'msg': 'Connection type %s is not valid for this module' % self._play_context.connection}
|
||||
|
||||
if persistent_connection == 'network_cli' and module_name not in self.EXOS_NETWORK_CLI_MODULES:
|
||||
return {'failed': True, 'msg': "Connection type %s is not valid for this module" % self._play_context.connection}
|
||||
|
||||
return super(ActionModule, self).run(task_vars=task_vars)
|
80
plugins/action/ironware.py
Normal file
80
plugins/action/ironware.py
Normal file
|
@ -0,0 +1,80 @@
|
|||
#
|
||||
# (c) 2016 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import sys
|
||||
import copy
|
||||
|
||||
from ansible_collections.ansible.netcommon.plugins.action.network import ActionModule as ActionNetworkModule
|
||||
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import load_provider
|
||||
from ansible_collections.community.general.plugins.module_utils.network.ironware.ironware import ironware_provider_spec
|
||||
from ansible.utils.display import Display
|
||||
|
||||
display = Display()
|
||||
|
||||
|
||||
class ActionModule(ActionNetworkModule):
|
||||
|
||||
def run(self, tmp=None, task_vars=None):
|
||||
del tmp # tmp no longer has any effect
|
||||
|
||||
module_name = self._task.action.split('.')[-1]
|
||||
self._config_module = True if module_name == 'ironware_config' else False
|
||||
persistent_connection = self._play_context.connection.split('.')[-1]
|
||||
|
||||
if persistent_connection == 'network_cli':
|
||||
provider = self._task.args.get('provider', {})
|
||||
if any(provider.values()):
|
||||
display.warning('provider is unnecessary when using network_cli and will be ignored')
|
||||
del self._task.args['provider']
|
||||
elif self._play_context.connection == 'local':
|
||||
provider = load_provider(ironware_provider_spec, self._task.args)
|
||||
pc = copy.deepcopy(self._play_context)
|
||||
pc.connection = 'network_cli'
|
||||
pc.network_os = 'ironware'
|
||||
pc.remote_addr = provider['host'] or self._play_context.remote_addr
|
||||
pc.port = int(provider['port'] or self._play_context.port or 22)
|
||||
pc.remote_user = provider['username'] or self._play_context.connection_user
|
||||
pc.password = provider['password'] or self._play_context.password
|
||||
pc.private_key_file = provider['ssh_keyfile'] or self._play_context.private_key_file
|
||||
pc.become = provider['authorize'] or False
|
||||
if pc.become:
|
||||
pc.become_method = 'enable'
|
||||
pc.become_pass = provider['auth_pass']
|
||||
|
||||
display.vvv('using connection plugin %s (was local)' % pc.connection, pc.remote_addr)
|
||||
connection = self._shared_loader_obj.connection_loader.get('persistent', pc, sys.stdin, task_uuid=self._task._uuid)
|
||||
|
||||
command_timeout = int(provider['timeout']) if provider['timeout'] else connection.get_option('persistent_command_timeout')
|
||||
connection.set_options(direct={'persistent_command_timeout': command_timeout})
|
||||
|
||||
socket_path = connection.run()
|
||||
display.vvvv('socket_path: %s' % socket_path, pc.remote_addr)
|
||||
if not socket_path:
|
||||
return {'failed': True,
|
||||
'msg': 'unable to open shell. Please see: ' +
|
||||
'https://docs.ansible.com/ansible/network_debug_troubleshooting.html#unable-to-open-shell'}
|
||||
|
||||
task_vars['ansible_socket'] = socket_path
|
||||
else:
|
||||
return {'failed': True, 'msg': 'Connection type %s is not valid for this module' % self._play_context.connection}
|
||||
|
||||
result = super(ActionModule, self).run(task_vars=task_vars)
|
||||
return result
|
31
plugins/action/nos_config.py
Normal file
31
plugins/action/nos_config.py
Normal file
|
@ -0,0 +1,31 @@
|
|||
#
|
||||
# (c) 2018 Extreme Networks 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
from ansible_collections.ansible.netcommon.plugins.action.network import ActionModule as ActionNetworkModule
|
||||
|
||||
|
||||
class ActionModule(ActionNetworkModule):
|
||||
|
||||
def run(self, tmp=None, task_vars=None):
|
||||
del tmp # tmp no longer has any effect
|
||||
|
||||
self._config_module = True
|
||||
return super(ActionModule, self).run(task_vars=task_vars)
|
31
plugins/action/onyx_config.py
Normal file
31
plugins/action/onyx_config.py
Normal file
|
@ -0,0 +1,31 @@
|
|||
#
|
||||
# (c) 2017, 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
from ansible_collections.ansible.netcommon.plugins.action.network import ActionModule as ActionNetworkModule
|
||||
|
||||
|
||||
class ActionModule(ActionNetworkModule):
|
||||
|
||||
def run(self, tmp=None, task_vars=None):
|
||||
del tmp # tmp no longer has any effect
|
||||
|
||||
self._config_module = True
|
||||
return super(ActionModule, self).run(task_vars=task_vars)
|
40
plugins/action/slxos.py
Normal file
40
plugins/action/slxos.py
Normal file
|
@ -0,0 +1,40 @@
|
|||
#
|
||||
# (c) 2018 Extreme Networks 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import re
|
||||
|
||||
from ansible_collections.ansible.netcommon.plugins.action.network import ActionModule as ActionNetworkModule
|
||||
|
||||
PRIVATE_KEYS_RE = re.compile('__.+__')
|
||||
|
||||
|
||||
class ActionModule(ActionNetworkModule):
|
||||
|
||||
def run(self, tmp=None, task_vars=None):
|
||||
del tmp # tmp no longer has any effect
|
||||
|
||||
module_name = self._task.action.split('.')[-1]
|
||||
self._config_module = True if module_name == 'slxos_config' else False
|
||||
persistent_connection = self._play_context.connection.split('.')[-1]
|
||||
|
||||
if persistent_connection not in ('network_cli'):
|
||||
return {'failed': True, 'msg': 'Connection type %s is not valid for this module' % self._play_context.connection}
|
||||
return super(ActionModule, self).run(task_vars=task_vars)
|
77
plugins/action/sros.py
Normal file
77
plugins/action/sros.py
Normal file
|
@ -0,0 +1,77 @@
|
|||
#
|
||||
# (c) 2016 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import sys
|
||||
import copy
|
||||
|
||||
from ansible import constants as C
|
||||
from ansible_collections.ansible.netcommon.plugins.action.network import ActionModule as ActionNetworkModule
|
||||
from ansible_collections.community.general.plugins.module_utils.network.sros.sros import sros_provider_spec
|
||||
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import load_provider
|
||||
from ansible.utils.display import Display
|
||||
|
||||
display = Display()
|
||||
|
||||
|
||||
class ActionModule(ActionNetworkModule):
|
||||
|
||||
def run(self, tmp=None, task_vars=None):
|
||||
del tmp # tmp no longer has any effect
|
||||
|
||||
module_name = self._task.action.split('.')[-1]
|
||||
persistent_connection = self._play_context.connection.split('.')[-1]
|
||||
|
||||
self._config_module = True if module_name == 'sros_config' else False
|
||||
if persistent_connection == 'network_cli':
|
||||
provider = self._task.args.get('provider', {})
|
||||
if any(provider.values()):
|
||||
display.warning('provider is unnecessary when using network_cli and will be ignored')
|
||||
del self._task.args['provider']
|
||||
elif self._play_context.connection == 'local':
|
||||
provider = load_provider(sros_provider_spec, self._task.args)
|
||||
|
||||
pc = copy.deepcopy(self._play_context)
|
||||
pc.connection = 'network_cli'
|
||||
pc.network_os = 'sros'
|
||||
pc.remote_addr = provider['host'] or self._play_context.remote_addr
|
||||
pc.port = int(provider['port'] or self._play_context.port or 22)
|
||||
pc.remote_user = provider['username'] or self._play_context.connection_user
|
||||
pc.password = provider['password'] or self._play_context.password
|
||||
pc.private_key_file = provider['ssh_keyfile'] or self._play_context.private_key_file
|
||||
command_timeout = int(provider['timeout'] or C.PERSISTENT_COMMAND_TIMEOUT)
|
||||
|
||||
display.vvv('using connection plugin %s (was local)' % pc.connection, pc.remote_addr)
|
||||
connection = self._shared_loader_obj.connection_loader.get('persistent', pc, sys.stdin, task_uuid=self._task._uuid)
|
||||
connection.set_options(direct={'persistent_command_timeout': command_timeout})
|
||||
|
||||
socket_path = connection.run()
|
||||
display.vvvv('socket_path: %s' % socket_path, pc.remote_addr)
|
||||
if not socket_path:
|
||||
return {'failed': True,
|
||||
'msg': 'unable to open shell. Please see: ' +
|
||||
'https://docs.ansible.com/ansible/network_debug_troubleshooting.html#unable-to-open-shell'}
|
||||
|
||||
task_vars['ansible_socket'] = socket_path
|
||||
else:
|
||||
return {'failed': True, 'msg': 'Connection type %s is not valid for this module' % self._play_context.connection}
|
||||
|
||||
result = super(ActionModule, self).run(task_vars=task_vars)
|
||||
return result
|
36
plugins/action/voss.py
Normal file
36
plugins/action/voss.py
Normal file
|
@ -0,0 +1,36 @@
|
|||
#
|
||||
# (c) 2018 Extreme Networks 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
from ansible_collections.ansible.netcommon.plugins.action.network import ActionModule as ActionNetworkModule
|
||||
|
||||
|
||||
class ActionModule(ActionNetworkModule):
|
||||
|
||||
def run(self, tmp=None, task_vars=None):
|
||||
del tmp # tmp no longer has any effect
|
||||
|
||||
module_name = self._task.action.split('.')[-1]
|
||||
self._config_module = True if module_name == 'voss_config' else False
|
||||
persistent_connection = self._play_context.connection.split('.')[-1]
|
||||
|
||||
if persistent_connection not in ('network_cli'):
|
||||
return {'failed': True, 'msg': 'Connection type %s is not valid for this module' % self._play_context.connection}
|
||||
return super(ActionModule, self).run(task_vars=task_vars)
|
Loading…
Add table
Add a link
Reference in a new issue