summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/ansible/module_utils/network/common/utils.py6
-rw-r--r--lib/ansible/module_utils/network/eos/eos.py52
-rw-r--r--lib/ansible/module_utils/network/ios/ios.py12
-rw-r--r--lib/ansible/module_utils/network/iosxr/iosxr.py10
-rw-r--r--lib/ansible/module_utils/network/junos/facts/facts.py3
-rw-r--r--lib/ansible/module_utils/network/junos/facts/legacy/base.py37
-rw-r--r--lib/ansible/module_utils/network/junos/junos.py54
-rw-r--r--lib/ansible/module_utils/network/nxos/nxos.py44
-rw-r--r--lib/ansible/module_utils/network/vyos/vyos.py11
-rw-r--r--lib/ansible/modules/network/eos/eos_banner.py4
-rw-r--r--lib/ansible/modules/network/eos/eos_eapi.py14
-rw-r--r--lib/ansible/modules/network/eos/eos_user.py5
-rw-r--r--lib/ansible/modules/network/ios/ios_user.py10
-rw-r--r--lib/ansible/modules/network/iosxr/iosxr_user.py33
-rw-r--r--lib/ansible/modules/network/junos/junos_package.py33
-rw-r--r--lib/ansible/modules/network/junos/junos_scp.py32
-rw-r--r--lib/ansible/modules/network/nxos/nxos_hsrp.py5
-rw-r--r--lib/ansible/modules/network/vyos/vyos_user.py10
-rw-r--r--lib/ansible/plugins/doc_fragments/eos.py26
-rw-r--r--lib/ansible/plugins/doc_fragments/ios.py24
-rw-r--r--test/integration/targets/eos_interface/tests/cli/intent.yaml1
-rw-r--r--test/integration/targets/eos_interface/tests/eapi/intent.yaml1
-rw-r--r--test/integration/targets/eos_linkagg/tests/cli/basic.yaml10
-rw-r--r--test/integration/targets/eos_smoke/tasks/cli.yaml2
-rw-r--r--test/integration/targets/eos_smoke/tasks/eapi.yaml6
-rw-r--r--test/integration/targets/eos_smoke/tests/cli/common_utils.yaml5
-rw-r--r--test/integration/targets/eos_smoke/tests/eapi/common_utils.yaml5
-rw-r--r--test/integration/targets/eos_static_route/tests/cli/basic.yaml6
-rw-r--r--test/integration/targets/eos_static_route/tests/cli/net_static_route.yaml3
-rw-r--r--test/integration/targets/eos_user/tests/cli/auth.yaml2
-rw-r--r--test/integration/targets/eos_user/tests/cli/basic.yaml5
-rw-r--r--test/integration/targets/eos_user/tests/cli/net_user.yaml1
-rw-r--r--test/integration/targets/eos_vlan/tests/cli/basic.yaml17
-rw-r--r--test/integration/targets/eos_vlan/tests/cli/net_vlan.yaml3
-rw-r--r--test/integration/targets/eos_vrf/tests/cli/basic.yaml18
-rw-r--r--test/integration/targets/eos_vrf/tests/cli/net_vrf.yaml3
-rw-r--r--test/integration/targets/ios_ping/tests/cli/ping.yaml1
-rw-r--r--test/units/modules/network/eos/test_eos_banner.py17
-rw-r--r--test/units/modules/network/ios/test_ios_ping.py4
-rw-r--r--test/units/modules/network/junos/test_junos_package.py8
-rw-r--r--test/units/modules/network/nxos/test_nxos_hsrp.py2
41 files changed, 431 insertions, 114 deletions
diff --git a/lib/ansible/module_utils/network/common/utils.py b/lib/ansible/module_utils/network/common/utils.py
index 75fcc8759f..afe419aa89 100644
--- a/lib/ansible/module_utils/network/common/utils.py
+++ b/lib/ansible/module_utils/network/common/utils.py
@@ -430,10 +430,12 @@ def validate_prefix(prefix):
def load_provider(spec, args):
- provider = args.get('provider') or {}
+ provider = args.get('provider', {})
for key, value in iteritems(spec):
if key not in provider:
- if 'fallback' in value:
+ if key in args:
+ provider[key] = args[key]
+ elif 'fallback' in value:
provider[key] = _fallback(value['fallback'])
elif 'default' in value:
provider[key] = value['default']
diff --git a/lib/ansible/module_utils/network/eos/eos.py b/lib/ansible/module_utils/network/eos/eos.py
index 438554ebdf..ee8a13a6ce 100644
--- a/lib/ansible/module_utils/network/eos/eos.py
+++ b/lib/ansible/module_utils/network/eos/eos.py
@@ -36,6 +36,7 @@ from ansible.module_utils.basic import env_fallback
from ansible.module_utils.connection import Connection, ConnectionError
from ansible.module_utils.network.common.config import NetworkConfig, dumps
from ansible.module_utils.network.common.utils import to_list, ComplexList
+from ansible.module_utils.six import iteritems
from ansible.module_utils.urls import fetch_url
_DEVICE_CONNECTION = None
@@ -60,15 +61,41 @@ eos_provider_spec = {
eos_argument_spec = {
'provider': dict(type='dict', options=eos_provider_spec),
}
+eos_top_spec = {
+ 'host': dict(removed_in_version=2.9),
+ 'port': dict(removed_in_version=2.9, type='int'),
+ 'username': dict(removed_in_version=2.9),
+ 'password': dict(removed_in_version=2.9, no_log=True),
+ 'ssh_keyfile': dict(removed_in_version=2.9, type='path'),
+
+ 'authorize': dict(fallback=(env_fallback, ['ANSIBLE_NET_AUTHORIZE']), type='bool'),
+ 'auth_pass': dict(removed_in_version=2.9, no_log=True),
+
+ 'use_ssl': dict(removed_in_version=2.9, type='bool'),
+ 'validate_certs': dict(removed_in_version=2.9, type='bool'),
+ 'timeout': dict(removed_in_version=2.9, type='int'),
+
+ 'transport': dict(removed_in_version=2.9, choices=['cli', 'eapi'])
+}
+eos_argument_spec.update(eos_top_spec)
def get_provider_argspec():
return eos_provider_spec
+def load_params(module):
+ provider = module.params.get('provider') or dict()
+ for key, value in iteritems(provider):
+ if key in eos_argument_spec:
+ if module.params.get(key) is None and value is not None:
+ module.params[key] = value
+
+
def get_connection(module):
global _DEVICE_CONNECTION
if not _DEVICE_CONNECTION:
+ load_params(module)
if is_local_eapi(module):
conn = LocalEapi(module)
else:
@@ -183,24 +210,23 @@ class LocalEapi:
self._session_support = None
self._device_configs = {}
- provider = module.params.get("provider") or {}
- host = provider.get('host')
- port = provider.get('port')
+ host = module.params['provider']['host']
+ port = module.params['provider']['port']
- self._module.params['url_username'] = provider.get('username')
- self._module.params['url_password'] = provider.get('password')
+ self._module.params['url_username'] = self._module.params['username']
+ self._module.params['url_password'] = self._module.params['password']
- if provider.get('use_ssl'):
+ if module.params['provider']['use_ssl']:
proto = 'https'
else:
proto = 'http'
- module.params['validate_certs'] = provider.get('validate_certs')
+ module.params['validate_certs'] = module.params['provider']['validate_certs']
self._url = '%s://%s:%s/command-api' % (proto, host, port)
- if provider.get("auth_pass"):
- self._enable = {'cmd': 'enable', 'input': provider.get('auth_pass')}
+ if module.params['auth_pass']:
+ self._enable = {'cmd': 'enable', 'input': module.params['auth_pass']}
else:
self._enable = 'enable'
@@ -225,7 +251,7 @@ class LocalEapi:
data = self._module.jsonify(body)
headers = {'Content-Type': 'application/json-rpc'}
- timeout = self._module.params['provider']['timeout']
+ timeout = self._module.params['timeout']
use_proxy = self._module.params['provider']['use_proxy']
response, headers = fetch_url(
@@ -569,10 +595,12 @@ def is_json(cmd):
def is_local_eapi(module):
+ transports = []
+ transports.append(module.params.get('transport', ""))
provider = module.params.get('provider')
if provider:
- return provider.get('transport') == 'eapi'
- return False
+ transports.append(provider.get('transport', ""))
+ return 'eapi' in transports
def to_command(module, commands):
diff --git a/lib/ansible/module_utils/network/ios/ios.py b/lib/ansible/module_utils/network/ios/ios.py
index 1c05efd7ec..6aa24a83b6 100644
--- a/lib/ansible/module_utils/network/ios/ios.py
+++ b/lib/ansible/module_utils/network/ios/ios.py
@@ -48,6 +48,18 @@ ios_argument_spec = {
'provider': dict(type='dict', options=ios_provider_spec),
}
+ios_top_spec = {
+ 'host': dict(removed_in_version=2.9),
+ 'port': dict(removed_in_version=2.9, type='int'),
+ 'username': dict(removed_in_version=2.9),
+ 'password': dict(removed_in_version=2.9, no_log=True),
+ 'ssh_keyfile': dict(removed_in_version=2.9, type='path'),
+ 'authorize': dict(fallback=(env_fallback, ['ANSIBLE_NET_AUTHORIZE']), type='bool'),
+ 'auth_pass': dict(removed_in_version=2.9, no_log=True),
+ 'timeout': dict(removed_in_version=2.9, type='int')
+}
+ios_argument_spec.update(ios_top_spec)
+
def get_provider_argspec():
return ios_provider_spec
diff --git a/lib/ansible/module_utils/network/iosxr/iosxr.py b/lib/ansible/module_utils/network/iosxr/iosxr.py
index 7118b731ed..f5e74d301b 100644
--- a/lib/ansible/module_utils/network/iosxr/iosxr.py
+++ b/lib/ansible/module_utils/network/iosxr/iosxr.py
@@ -90,6 +90,16 @@ command_spec = {
'answer': dict(default=None)
}
+iosxr_top_spec = {
+ 'host': dict(removed_in_version=2.9),
+ 'port': dict(removed_in_version=2.9, type='int'),
+ 'username': dict(removed_in_version=2.9),
+ 'password': dict(removed_in_version=2.9, no_log=True),
+ 'ssh_keyfile': dict(removed_in_version=2.9, type='path'),
+ 'timeout': dict(removed_in_version=2.9, type='int'),
+}
+iosxr_argument_spec.update(iosxr_top_spec)
+
CONFIG_MISPLACED_CHILDREN = [
re.compile(r'^end-\s*(.+)$')
]
diff --git a/lib/ansible/module_utils/network/junos/facts/facts.py b/lib/ansible/module_utils/network/junos/facts/facts.py
index 4c9417e61f..888045d17c 100644
--- a/lib/ansible/module_utils/network/junos/facts/facts.py
+++ b/lib/ansible/module_utils/network/junos/facts/facts.py
@@ -10,8 +10,7 @@ calls the appropriate facts gathering function
"""
from ansible.module_utils.network.common.facts.facts import FactsBase
-from ansible.module_utils.network.junos.junos import HAS_PYEZ
-from ansible.module_utils.network.junos.facts.legacy.base import Default, Hardware, Config, Interfaces, OFacts
+from ansible.module_utils.network.junos.facts.legacy.base import Default, Hardware, Config, Interfaces, OFacts, HAS_PYEZ
from ansible.module_utils.network.junos.facts.interfaces.interfaces import InterfacesFacts
from ansible.module_utils.network.junos.facts.lacp.lacp import LacpFacts
from ansible.module_utils.network.junos.facts.lacp_interfaces.lacp_interfaces import Lacp_interfacesFacts
diff --git a/lib/ansible/module_utils/network/junos/facts/legacy/base.py b/lib/ansible/module_utils/network/junos/facts/legacy/base.py
index 61752a37d7..ed6af22854 100644
--- a/lib/ansible/module_utils/network/junos/facts/legacy/base.py
+++ b/lib/ansible/module_utils/network/junos/facts/legacy/base.py
@@ -11,8 +11,8 @@ based on the configuration.
import platform
from ansible.module_utils.network.common.netconf import exec_rpc
-from ansible.module_utils.network.junos.junos import tostring
-from ansible.module_utils.network.junos.junos import get_configuration, get_capabilities, get_device
+from ansible.module_utils.network.junos.junos import get_param, tostring
+from ansible.module_utils.network.junos.junos import get_configuration, get_capabilities
from ansible.module_utils._text import to_text
@@ -21,6 +21,13 @@ try:
except ImportError:
from xml.etree.ElementTree import Element, SubElement
+try:
+ from jnpr.junos import Device
+ from jnpr.junos.exception import ConnectError
+ HAS_PYEZ = True
+except ImportError:
+ HAS_PYEZ = False
+
class FactsBase(object):
@@ -177,9 +184,33 @@ class Interfaces(FactsBase):
class OFacts(FactsBase):
+ def _connect(self, module):
+ host = get_param(module, 'host')
+
+ kwargs = {
+ 'port': get_param(module, 'port') or 830,
+ 'user': get_param(module, 'username')
+ }
+
+ if get_param(module, 'password'):
+ kwargs['passwd'] = get_param(module, 'password')
+
+ if get_param(module, 'ssh_keyfile'):
+ kwargs['ssh_private_key_file'] = get_param(module, 'ssh_keyfile')
+
+ kwargs['gather_facts'] = False
+ try:
+ device = Device(host, **kwargs)
+ device.open()
+ device.timeout = get_param(module, 'timeout') or 10
+ except ConnectError as exc:
+ module.fail_json('unable to connect to %s: %s' % (host, to_text(exc)))
+
+ return device
+
def populate(self):
- device = get_device(self.module)
+ device = self._connect(self.module)
facts = dict(device.facts)
if '2RE' in facts:
diff --git a/lib/ansible/module_utils/network/junos/junos.py b/lib/ansible/module_utils/network/junos/junos.py
index 07b787b642..e5c38c80e2 100644
--- a/lib/ansible/module_utils/network/junos/junos.py
+++ b/lib/ansible/module_utils/network/junos/junos.py
@@ -33,13 +33,6 @@ except ImportError:
from xml.etree.ElementTree import Element, SubElement, tostring as xml_to_string
HAS_LXML = False
-try:
- from jnpr.junos import Device
- from jnpr.junos.exception import ConnectError
- HAS_PYEZ = True
-except ImportError:
- HAS_PYEZ = False
-
ACTIONS = frozenset(['merge', 'override', 'replace', 'update', 'set'])
JSON_ACTIONS = frozenset(['merge', 'override', 'update'])
FORMATS = frozenset(['xml', 'text', 'json'])
@@ -57,6 +50,16 @@ junos_provider_spec = {
junos_argument_spec = {
'provider': dict(type='dict', options=junos_provider_spec),
}
+junos_top_spec = {
+ 'host': dict(removed_in_version=2.9),
+ 'port': dict(removed_in_version=2.9, type='int'),
+ 'username': dict(removed_in_version=2.9),
+ 'password': dict(removed_in_version=2.9, no_log=True),
+ 'ssh_keyfile': dict(removed_in_version=2.9, type='path'),
+ 'timeout': dict(removed_in_version=2.9, type='int'),
+ 'transport': dict(removed_in_version=2.9)
+}
+junos_argument_spec.update(junos_top_spec)
def tostring(element, encoding='UTF-8'):
@@ -98,33 +101,6 @@ def get_capabilities(module):
return module._junos_capabilities
-def get_device(module):
- provider = module.params.get("provider") or {}
- host = provider.get('host')
-
- kwargs = {
- 'port': provider.get('port') or 830,
- 'user': provider.get('username')
- }
-
- if 'password' in provider:
- kwargs['passwd'] = provider.get('password')
-
- if 'ssh_keyfile' in provider:
- kwargs['ssh_private_key_file'] = provider.get('ssh_keyfile')
-
- kwargs['gather_facts'] = False
-
- try:
- device = Device(host, **kwargs)
- device.open()
- device.timeout = provider.get('timeout') or 10
- except ConnectError as exc:
- module.fail_json('unable to connect to %s: %s' % (host, to_text(exc)))
-
- return device
-
-
def is_netconf(module):
capabilities = get_capabilities(module)
return True if capabilities.get('network_api') == 'netconf' else False
@@ -276,6 +252,16 @@ def load_config(module, candidate, warnings, action='merge', format='xml'):
return get_diff(module)
+def get_param(module, key):
+ if module.params.get(key):
+ value = module.params[key]
+ elif module.params.get('provider'):
+ value = module.params['provider'].get(key)
+ else:
+ value = None
+ return value
+
+
def map_params_to_obj(module, param_to_xpath_map, param=None):
"""
Creates a new dictionary with key as xpath corresponding
diff --git a/lib/ansible/module_utils/network/nxos/nxos.py b/lib/ansible/module_utils/network/nxos/nxos.py
index 659ae54934..01a1f5c77b 100644
--- a/lib/ansible/module_utils/network/nxos/nxos.py
+++ b/lib/ansible/module_utils/network/nxos/nxos.py
@@ -83,15 +83,42 @@ nxos_provider_spec = {
nxos_argument_spec = {
'provider': dict(type='dict', options=nxos_provider_spec),
}
+nxos_top_spec = {
+ 'host': dict(type='str', removed_in_version=2.9),
+ 'port': dict(type='int', removed_in_version=2.9),
+
+ 'username': dict(type='str', removed_in_version=2.9),
+ 'password': dict(type='str', no_log=True, removed_in_version=2.9),
+ 'ssh_keyfile': dict(type='str', removed_in_version=2.9),
+
+ 'authorize': dict(type='bool', fallback=(env_fallback, ['ANSIBLE_NET_AUTHORIZE'])),
+ 'auth_pass': dict(type='str', no_log=True, removed_in_version=2.9),
+
+ 'use_ssl': dict(type='bool', removed_in_version=2.9),
+ 'validate_certs': dict(type='bool', removed_in_version=2.9),
+ 'timeout': dict(type='int', removed_in_version=2.9),
+
+ 'transport': dict(type='str', choices=['cli', 'nxapi'], removed_in_version=2.9)
+}
+nxos_argument_spec.update(nxos_top_spec)
def get_provider_argspec():
return nxos_provider_spec
+def load_params(module):
+ provider = module.params.get('provider') or dict()
+ for key, value in iteritems(provider):
+ if key in nxos_provider_spec:
+ if module.params.get(key) is None and value is not None:
+ module.params[key] = value
+
+
def get_connection(module):
global _DEVICE_CONNECTION
if not _DEVICE_CONNECTION:
+ load_params(module)
if is_local_nxapi(module):
conn = LocalNxapi(module)
else:
@@ -251,14 +278,13 @@ class LocalNxapi:
self._device_configs = {}
self._module_context = {}
- provider = self._module.params.get("provider") or {}
- self._module.params['url_username'] = provider.get('username')
- self._module.params['url_password'] = provider.get('password')
+ self._module.params['url_username'] = self._module.params['username']
+ self._module.params['url_password'] = self._module.params['password']
- host = provider.get('host')
- port = provider.get('port')
+ host = self._module.params['host']
+ port = self._module.params['port']
- if provider.get('use_ssl'):
+ if self._module.params['use_ssl']:
proto = 'https'
port = port or 443
else:
@@ -1148,10 +1174,10 @@ def is_text(cmd):
def is_local_nxapi(module):
+ transport = module.params.get('transport')
provider = module.params.get('provider')
- if provider:
- return provider.get("transport") == 'nxapi'
- return False
+ provider_transport = provider['transport'] if provider else None
+ return 'nxapi' in (transport, provider_transport)
def to_command(module, commands):
diff --git a/lib/ansible/module_utils/network/vyos/vyos.py b/lib/ansible/module_utils/network/vyos/vyos.py
index a37c954389..2aa7b49f9e 100644
--- a/lib/ansible/module_utils/network/vyos/vyos.py
+++ b/lib/ansible/module_utils/network/vyos/vyos.py
@@ -46,6 +46,17 @@ vyos_provider_spec = {
vyos_argument_spec = {
'provider': dict(type='dict', options=vyos_provider_spec),
}
+vyos_top_spec = {
+ 'host': dict(removed_in_version=2.9),
+ 'port': dict(removed_in_version=2.9, type='int'),
+
+ 'username': dict(removed_in_version=2.9),
+ 'password': dict(removed_in_version=2.9, no_log=True),
+ 'ssh_keyfile': dict(removed_in_version=2.9, type='path'),
+
+ 'timeout': dict(removed_in_version=2.9, type='int'),
+}
+vyos_argument_spec.update(vyos_top_spec)
def get_provider_argspec():
diff --git a/lib/ansible/modules/network/eos/eos_banner.py b/lib/ansible/modules/network/eos/eos_banner.py
index c716d192b6..50ac6cc7c8 100644
--- a/lib/ansible/modules/network/eos/eos_banner.py
+++ b/lib/ansible/modules/network/eos/eos_banner.py
@@ -89,7 +89,7 @@ session_name:
"""
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.network.eos.eos import load_config, run_commands
-from ansible.module_utils.network.eos.eos import eos_argument_spec, is_local_eapi
+from ansible.module_utils.network.eos.eos import eos_argument_spec
from ansible.module_utils.six import string_types
from ansible.module_utils._text import to_text
@@ -129,7 +129,7 @@ def map_config_to_obj(module):
output = run_commands(module, ['show banner %s' % module.params['banner']])
obj = {'banner': module.params['banner'], 'state': 'absent'}
if output:
- if is_local_eapi(module):
+ if module.params['transport'] == 'eapi':
# On EAPI we need to extract the banner text from dict key
# 'loginBanner'
if module.params['banner'] == 'login':
diff --git a/lib/ansible/modules/network/eos/eos_eapi.py b/lib/ansible/modules/network/eos/eos_eapi.py
index 01f65308bc..07eeaf93eb 100644
--- a/lib/ansible/modules/network/eos/eos_eapi.py
+++ b/lib/ansible/modules/network/eos/eos_eapi.py
@@ -101,12 +101,6 @@ options:
type: bool
default: 'no'
aliases: ['enable_socket']
- timeout:
- description:
- - The time (in seconds) to wait for the eAPI configuration to be
- reflected in the running-config.
- type: int
- default: 30
vrf:
description:
- The C(vrf) argument will configure eAPI to listen for connections
@@ -184,9 +178,10 @@ from ansible.module_utils.network.eos.eos import eos_argument_spec
def check_transport(module):
- transport = (module.params['provider'] or {}).get('transport')
+ transport = module.params['transport']
+ provider_transport = (module.params['provider'] or {}).get('transport')
- if transport == 'eapi':
+ if 'eapi' in (transport, provider_transport):
module.fail_json(msg='eos_eapi module is only supported over cli transport')
@@ -339,7 +334,7 @@ def verify_state(updates, module):
('local_http', 'localHttpServer'),
('socket', 'unixSocketServer')]
- timeout = module.params["timeout"]
+ timeout = module.params['timeout'] or 30
state = module.params['state']
while invalid_state:
@@ -386,7 +381,6 @@ def main():
local_http_port=dict(type='int'),
socket=dict(aliases=['enable_socket'], type='bool'),
- timeout=dict(type="int", default=30),
vrf=dict(default='default'),
diff --git a/lib/ansible/modules/network/eos/eos_user.py b/lib/ansible/modules/network/eos/eos_user.py
index d48fd0528d..f3efd78347 100644
--- a/lib/ansible/modules/network/eos/eos_user.py
+++ b/lib/ansible/modules/network/eos/eos_user.py
@@ -361,6 +361,11 @@ def main():
supports_check_mode=True)
warnings = list()
+ if module.params['password'] and not module.params['configured_password']:
+ warnings.append(
+ 'The "password" argument is used to authenticate the current connection. ' +
+ 'To set a user password use "configured_password" instead.'
+ )
result = {'changed': False}
if warnings:
diff --git a/lib/ansible/modules/network/ios/ios_user.py b/lib/ansible/modules/network/ios/ios_user.py
index 37afe741dd..0deb2d0fb8 100644
--- a/lib/ansible/modules/network/ios/ios_user.py
+++ b/lib/ansible/modules/network/ios/ios_user.py
@@ -505,7 +505,15 @@ def main():
supports_check_mode=True)
warnings = list()
- result = {'changed': False, 'warnings': warnings}
+ if module.params['password'] and not module.params['configured_password']:
+ warnings.append(
+ 'The "password" argument is used to authenticate the current connection. ' +
+ 'To set a user password use "configured_password" instead.'
+ )
+
+ result = {'changed': False}
+ if warnings:
+ result['warnings'] = warnings
want = map_params_to_obj(module)
have = map_config_to_obj(module)
diff --git a/lib/ansible/modules/network/iosxr/iosxr_user.py b/lib/ansible/modules/network/iosxr/iosxr_user.py
index 0e7d4188fb..061bf73ba1 100644
--- a/lib/ansible/modules/network/iosxr/iosxr_user.py
+++ b/lib/ansible/modules/network/iosxr/iosxr_user.py
@@ -251,18 +251,12 @@ class PublicKeyManager(object):
def copy_key_to_node(self, base64keyfile):
""" Copy key to IOS-XR node. We use SFTP because older IOS-XR versions don't handle SCP very well.
"""
- provider = self._module.params.get("provider") or {}
- node = provider.get('host')
- if node is None:
+ if (self._module.params['host'] is None or self._module.params['provider']['host'] is None):
return False
- user = provider.get('username')
- if user is None:
+ if (self._module.params['username'] is None or self._module.params['provider']['username'] is None):
return False
- password = provider.get('password')
- ssh_keyfile = provider.get('ssh_keyfile')
-
if self._module.params['aggregate']:
name = 'aggregate'
else:
@@ -271,6 +265,11 @@ class PublicKeyManager(object):
src = base64keyfile
dst = '/harddisk:/publickey_%s.b64' % (name)
+ user = self._module.params['username'] or self._module.params['provider']['username']
+ node = self._module.params['host'] or self._module.params['provider']['host']
+ password = self._module.params['password'] or self._module.params['provider']['password']
+ ssh_keyfile = self._module.params['ssh_keyfile'] or self._module.params['provider']['ssh_keyfile']
+
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
if not ssh_keyfile:
@@ -285,17 +284,16 @@ class PublicKeyManager(object):
def addremovekey(self, command):
""" Add or remove key based on command
"""
- provider = self._module.params.get("provider") or {}
- node = provider.get('host')
- if node is None:
+ if (self._module.params['host'] is None or self._module.params['provider']['host'] is None):
return False
- user = provider.get('username')
- if user is None:
+ if (self._module.params['username'] is None or self._module.params['provider']['username'] is None):
return False
- password = provider.get('password')
- ssh_keyfile = provider.get('ssh_keyfile')
+ user = self._module.params['username'] or self._module.params['provider']['username']
+ node = self._module.params['host'] or self._module.params['provider']['host']
+ password = self._module.params['password'] or self._module.params['provider']['password']
+ ssh_keyfile = self._module.params['ssh_keyfile'] or self._module.params['provider']['ssh_keyfile']
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
@@ -697,6 +695,11 @@ def main():
)
result = {'changed': False, 'warnings': []}
+ if module.params['password'] and not module.params['configured_password']:
+ result['warnings'].append(
+ 'The "password" argument is used to authenticate the current connection. ' +
+ 'To set a user password use "configured_password" instead.'
+ )
config_object = None
if is_cliconf(module):
diff --git a/lib/ansible/modules/network/junos/junos_package.py b/lib/ansible/modules/network/junos/junos_package.py
index 1e94dd88d9..38b5231c2a 100644
--- a/lib/ansible/modules/network/junos/junos_package.py
+++ b/lib/ansible/modules/network/junos/junos_package.py
@@ -114,15 +114,44 @@ EXAMPLES = """
reboot: no
"""
from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.network.junos.junos import junos_argument_spec, get_device
+from ansible.module_utils.network.junos.junos import junos_argument_spec, get_param
+from ansible.module_utils._text import to_native
try:
+ from jnpr.junos import Device
from jnpr.junos.utils.sw import SW
+ from jnpr.junos.exception import ConnectError
HAS_PYEZ = True
except ImportError:
HAS_PYEZ = False
+def connect(module):
+ host = get_param(module, 'host')
+
+ kwargs = {
+ 'port': get_param(module, 'port') or 830,
+ 'user': get_param(module, 'username')
+ }
+
+ if get_param(module, 'password'):
+ kwargs['passwd'] = get_param(module, 'password')
+
+ if get_param(module, 'ssh_keyfile'):
+ kwargs['ssh_private_key_file'] = get_param(module, 'ssh_keyfile')
+
+ kwargs['gather_facts'] = False
+
+ try:
+ device = Device(host, **kwargs)
+ device.open()
+ device.timeout = get_param(module, 'timeout') or 10
+ except ConnectError as exc:
+ module.fail_json(msg='unable to connect to %s: %s' % (host, to_native(exc)))
+
+ return device
+
+
def install_package(module, device):
junos = SW(device)
package = module.params['src']
@@ -179,7 +208,7 @@ def main():
do_upgrade = module.params['force'] or False
- device = get_device(module)
+ device = connect(module)
if not module.params['force']:
device.facts_refresh()
diff --git a/lib/ansible/modules/network/junos/junos_scp.py b/lib/ansible/modules/network/junos/junos_scp.py
index d8995df536..a05fa75e3e 100644
--- a/lib/ansible/modules/network/junos/junos_scp.py
+++ b/lib/ansible/modules/network/junos/junos_scp.py
@@ -82,16 +82,44 @@ changed:
type: bool
"""
from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.network.junos.junos import junos_argument_spec, get_device
+from ansible.module_utils.network.junos.junos import junos_argument_spec, get_param
from ansible.module_utils._text import to_native
try:
+ from jnpr.junos import Device
from jnpr.junos.utils.scp import SCP
+ from jnpr.junos.exception import ConnectError
HAS_PYEZ = True
except ImportError:
HAS_PYEZ = False
+def connect(module):
+ host = get_param(module, 'host')
+
+ kwargs = {
+ 'port': get_param(module, 'port') or 830,
+ 'user': get_param(module, 'username')
+ }
+
+ if get_param(module, 'password'):
+ kwargs['passwd'] = get_param(module, 'password')
+
+ if get_param(module, 'ssh_keyfile'):
+ kwargs['ssh_private_key_file'] = get_param(module, 'ssh_keyfile')
+
+ kwargs['gather_facts'] = False
+
+ try:
+ device = Device(host, **kwargs)
+ device.open()
+ device.timeout = get_param(module, 'timeout') or 10
+ except ConnectError as exc:
+ module.fail_json('unable to connect to %s: %s' % (host, to_native(exc)))
+
+ return device
+
+
def transfer_files(module, device):
dest = module.params['dest']
recursive = module.params['recursive']
@@ -134,7 +162,7 @@ def main():
if not module.check_mode:
# open pyez connection and transfer files via SCP
try:
- device = get_device(module)
+ device = connect(module)
transfer_files(module, device)
except Exception as ex:
module.fail_json(
diff --git a/lib/ansible/modules/network/nxos/nxos_hsrp.py b/lib/ansible/modules/network/nxos/nxos_hsrp.py
index 6d21fd4cbf..e1a3330f64 100644
--- a/lib/ansible/modules/network/nxos/nxos_hsrp.py
+++ b/lib/ansible/modules/network/nxos/nxos_hsrp.py
@@ -76,6 +76,7 @@ EXAMPLES = r'''
priority: 150
interface: vlan10
preempt: enabled
+ host: 68.170.147.165
- name: Ensure HSRP is configured with following params on a SVI
with clear text authentication
@@ -85,6 +86,7 @@ EXAMPLES = r'''
priority: 150
interface: vlan10
preempt: enabled
+ host: 68.170.147.165
auth_type: text
auth_string: CISCO
@@ -96,6 +98,7 @@ EXAMPLES = r'''
priority: 150
interface: vlan10
preempt: enabled
+ host: 68.170.147.165
auth_type: md5
auth_string: "0 1234"
@@ -107,6 +110,7 @@ EXAMPLES = r'''
priority: 150
interface: vlan10
preempt: enabled
+ host: 68.170.147.165
auth_type: md5
auth_string: "7 1234"
@@ -115,6 +119,7 @@ EXAMPLES = r'''
group: 10
interface: vlan10
vip: 10.1.1.1
+ host: 68.170.147.165
state: absent
'''
diff --git a/lib/ansible/modules/network/vyos/vyos_user.py b/lib/ansible/modules/network/vyos/vyos_user.py
index f60467f87c..cbe72c5c87 100644
--- a/lib/ansible/modules/network/vyos/vyos_user.py
+++ b/lib/ansible/modules/network/vyos/vyos_user.py
@@ -306,7 +306,15 @@ def main():
supports_check_mode=True)
warnings = list()
- result = {'changed': False, 'warnings': warnings}
+ if module.params['password'] and not module.params['configured_password']:
+ warnings.append(
+ 'The "password" argument is used to authenticate the current connection. ' +
+ 'To set a user password use "configured_password" instead.'
+ )
+
+ result = {'changed': False}
+ if warnings:
+ result['warnings'] = warnings
want = map_params_to_obj(module)
have = config_to_dict(module)
diff --git a/lib/ansible/plugins/doc_fragments/eos.py b/lib/ansible/plugins/doc_fragments/eos.py
index d6fbc1caf5..e77bc921f0 100644
--- a/lib/ansible/plugins/doc_fragments/eos.py
+++ b/lib/ansible/plugins/doc_fragments/eos.py
@@ -9,6 +9,32 @@ class ModuleDocFragment(object):
# Standard files documentation fragment
DOCUMENTATION = r'''
options:
+ authorize:
+ description:
+ - B(Deprecated)
+ - "Starting with Ansible 2.5 we recommend using C(connection: network_cli) and C(become: yes)."
+ - This option is only required if you are using eAPI.
+ - For more information please see the L(EOS Platform Options guide, ../network/user_guide/platform_eos.html).
+ - HORIZONTALLINE
+ - Instructs the module to enter privileged mode on the remote device
+ before sending any commands. If not specified, the device will
+ attempt to execute all commands in non-privileged mode. If the value
+ is not specified in the task, the value of environment variable
+ C(ANSIBLE_NET_AUTHORIZE) will be used instead.
+ type: bool
+ default: no
+ auth_pass:
+ description:
+ - B(Deprecated)
+ - "Starting with Ansible 2.5 we recommend using C(connection: network_cli) and C(become: yes) with C(become_pass)."
+ - This option is only required if you are using eAPI.
+ - For more information please see the L(EOS Platform Options guide, ../network/user_guide/platform_eos.html).
+ - HORIZONTALLINE
+ - Specifies the password to use if required to enter privileged mode
+ on the remote device. If I(authorize) is false, then this argument
+ does nothing. If the value is not specified in the task, the value of
+ environment variable C(ANSIBLE_NET_AUTH_PASS) will be used instead.
+ type: str
provider:
description:
- B(Deprecated)
diff --git a/lib/ansible/plugins/doc_fragments/ios.py b/lib/ansible/plugins/doc_fragments/ios.py
index 49e723516e..8a75dee3fa 100644
--- a/lib/ansible/plugins/doc_fragments/ios.py
+++ b/lib/ansible/plugins/doc_fragments/ios.py
@@ -9,6 +9,30 @@ class ModuleDocFragment(object):
# Standard files documentation fragment
DOCUMENTATION = r'''
options:
+ authorize:
+ description:
+ - B(Deprecated)
+ - "Starting with Ansible 2.5 we recommend using C(connection: network_cli) and C(become: yes)."
+ - For more information please see the L(IOS Platform Options guide, ../network/user_guide/platform_ios.html).
+ - HORIZONTALLINE
+ - Instructs the module to enter privileged mode on the remote device
+ before sending any commands. If not specified, the device will
+ attempt to execute all commands in non-privileged mode. If the value
+ is not specified in the task, the value of environment variable
+ C(ANSIBLE_NET_AUTHORIZE) will be used instead.
+ type: bool
+ default: no
+ auth_pass:
+ description:
+ - B(Deprecated)
+ - "Starting with Ansible 2.5 we recommend using C(connection: network_cli) and C(become: yes) with C(become_pass)."
+ - For more information please see the L(IOS Platform Options guide, ../network/user_guide/platform_ios.html).
+ - HORIZONTALLINE
+ - Specifies the password to use if required to enter privileged mode
+ on the remote device. If I(authorize) is false, then this argument
+ does nothing. If the value is not specified in the task, the value of
+ environment variable C(ANSIBLE_NET_AUTH_PASS) will be used instead.
+ type: str
provider:
description:
- B(Deprecated)
diff --git a/test/integration/targets/eos_interface/tests/cli/intent.yaml b/test/integration/targets/eos_interface/tests/cli/intent.yaml
index 1432636015..5dd4baa007 100644
--- a/test/integration/targets/eos_interface/tests/cli/intent.yaml
+++ b/test/integration/targets/eos_interface/tests/cli/intent.yaml
@@ -12,6 +12,7 @@
state: up
tx_rate: ge(0)
rx_rate: ge(0)
+ authorize: yes
become: yes
register: result
diff --git a/test/integration/targets/eos_interface/tests/eapi/intent.yaml b/test/integration/targets/eos_interface/tests/eapi/intent.yaml
index 1be696018e..797f99b2eb 100644
--- a/test/integration/targets/eos_interface/tests/eapi/intent.yaml
+++ b/test/integration/targets/eos_interface/tests/eapi/intent.yaml
@@ -17,6 +17,7 @@
state: up
tx_rate: ge(0)
rx_rate: ge(0)
+ authorize: yes
become: yes
register: result
diff --git a/test/integration/targets/eos_linkagg/tests/cli/basic.yaml b/test/integration/targets/eos_linkagg/tests/cli/basic.yaml
index e49dff8697..9986b61ec9 100644
--- a/test/integration/targets/eos_linkagg/tests/cli/basic.yaml
+++ b/test/integration/targets/eos_linkagg/tests/cli/basic.yaml
@@ -6,6 +6,7 @@
lines:
- no interface port-channel 20
- no interface port-channel 100
+ authorize: yes
provider: "{{ cli }}"
become: yes
@@ -13,6 +14,7 @@
eos_config:
lines:
- no channel-group 20
+ authorize: yes
provider: "{{ cli }}"
parents: "{{ item }}"
loop:
@@ -24,6 +26,7 @@
eos_linkagg: &create
group: 20
state: present
+ authorize: yes
provider: "{{ cli }}"
become: yes
register: result
@@ -49,6 +52,7 @@
members:
- Ethernet1
- Ethernet2
+ authorize: yes
provider: "{{ cli }}"
become: yes
register: result
@@ -76,6 +80,7 @@
mode: active
members:
- Ethernet2
+ authorize: yes
provider: "{{ cli }}"
become: yes
register: result
@@ -99,6 +104,7 @@
eos_linkagg: &remove
group: 20
state: absent
+ authorize: yes
provider: "{{ cli }}"
become: yes
register: result
@@ -122,6 +128,7 @@
aggregate:
- { group: 20, min_links: 3 }
- { group: 100, min_links: 4 }
+ authorize: yes
provider: "{{ cli }}"
become: yes
register: result
@@ -148,6 +155,7 @@
aggregate:
- { group: 20, min_links: 3 }
- { group: 100, min_links: 4 }
+ authorize: yes
provider: "{{ cli }}"
state: absent
become: yes
@@ -173,6 +181,7 @@
lines:
- no interface port-channel 20
- no interface port-channel 100
+ authorize: yes
provider: "{{ cli }}"
become: yes
@@ -180,6 +189,7 @@
eos_config:
lines:
- no channel-group 20
+ authorize: yes
provider: "{{ cli }}"
parents: "{{ item }}"
become: yes
diff --git a/test/integration/targets/eos_smoke/tasks/cli.yaml b/test/integration/targets/eos_smoke/tasks/cli.yaml
index 0f38c985e9..d6887cdbc7 100644
--- a/test/integration/targets/eos_smoke/tasks/cli.yaml
+++ b/test/integration/targets/eos_smoke/tasks/cli.yaml
@@ -14,11 +14,9 @@
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run
- tags: network_cli
- name: run test cases (connection=local)
include: "{{ test_case_to_run }} ansible_connection=local ansible_become=no"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run
- tags: local
diff --git a/test/integration/targets/eos_smoke/tasks/eapi.yaml b/test/integration/targets/eos_smoke/tasks/eapi.yaml
index 7d53536866..6ce80b3b74 100644
--- a/test/integration/targets/eos_smoke/tasks/eapi.yaml
+++ b/test/integration/targets/eos_smoke/tasks/eapi.yaml
@@ -3,8 +3,8 @@
find:
paths: "{{ role_path }}/tests/eapi"
patterns: "{{ testcase }}.yaml"
- register: test_cases
delegate_to: localhost
+ register: test_cases
- name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
@@ -14,11 +14,9 @@
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run
- tags: httpapi
-- name: run test cases (connection=local)
+- name: run test case (connection=local)
include: "{{ test_case_to_run }} ansible_connection=local"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run
- tags: local
diff --git a/test/integration/targets/eos_smoke/tests/cli/common_utils.yaml b/test/integration/targets/eos_smoke/tests/cli/common_utils.yaml
index 60c69b78ff..635248d79a 100644
--- a/test/integration/targets/eos_smoke/tests/cli/common_utils.yaml
+++ b/test/integration/targets/eos_smoke/tests/cli/common_utils.yaml
@@ -10,6 +10,7 @@
eos_config:
lines:
- no ip route 192.168.3.0/24 192.168.0.1
+ authorize: yes
provider: "{{ cli }}"
become: yes
@@ -18,6 +19,7 @@
address: 192.168.3.0/24
next_hop: 192.168.0.1
admin_distance: 2
+ authorize: yes
provider: "{{ cli }}"
become: yes
register: result
@@ -32,6 +34,7 @@
address: 192.168.3.0/250
next_hop: 192.168.0.1
admin_distance: 2
+ authorize: yes
provider: "{{ cli }}"
become: yes
register: result
@@ -45,6 +48,7 @@
eos_config:
lines:
- no ip route 192.168.3.0/24 192.168.0.1
+ authorize: yes
provider: "{{ cli }}"
become: yes
@@ -61,6 +65,7 @@
state: up
tx_rate: ge(0)
rx_rate: ge(0)
+ authorize: yes
provider: "{{ cli }}"
become: yes
register: result
diff --git a/test/integration/targets/eos_smoke/tests/eapi/common_utils.yaml b/test/integration/targets/eos_smoke/tests/eapi/common_utils.yaml
index 783c6e8a26..165cdc3816 100644
--- a/test/integration/targets/eos_smoke/tests/eapi/common_utils.yaml
+++ b/test/integration/targets/eos_smoke/tests/eapi/common_utils.yaml
@@ -10,6 +10,7 @@
eos_config:
lines:
- no ip route 192.168.3.0/24 192.168.0.1
+ authorize: yes
provider: "{{ eapi }}"
become: yes
@@ -18,6 +19,7 @@
address: 192.168.3.0/24
next_hop: 192.168.0.1
admin_distance: 2
+ authorize: yes
provider: "{{ eapi }}"
become: yes
register: result
@@ -32,6 +34,7 @@
address: 192.168.3.0/250
next_hop: 192.168.0.1
admin_distance: 2
+ authorize: yes
provider: "{{ eapi }}"
become: yes
register: result
@@ -45,6 +48,7 @@
eos_config:
lines:
- no ip route 192.168.3.0/24 192.168.0.1
+ authorize: yes
provider: "{{ eapi }}"
become: yes
@@ -61,6 +65,7 @@
state: up
tx_rate: ge(0)
rx_rate: ge(0)
+ authorize: yes
provider: "{{ eapi }}"
become: yes
register: result
diff --git a/test/integration/targets/eos_static_route/tests/cli/basic.yaml b/test/integration/targets/eos_static_route/tests/cli/basic.yaml
index 572dec4917..5fdd990da1 100644
--- a/test/integration/targets/eos_static_route/tests/cli/basic.yaml
+++ b/test/integration/targets/eos_static_route/tests/cli/basic.yaml
@@ -7,6 +7,7 @@
- no ip route 192.168.3.0/24 192.168.0.1
- no ip route 192.168.4.0/24 192.168.0.1
- no ip route 192.168.5.0/24 192.168.0.1
+ authorize: yes
provider: "{{ cli }}"
become: yes
@@ -15,6 +16,7 @@
address: 192.168.3.0/24
next_hop: 192.168.0.1
admin_distance: 2
+ authorize: yes
provider: "{{ cli }}"
become: yes
register: result
@@ -38,6 +40,7 @@
address: 192.168.3.0/24
next_hop: 192.168.0.1
admin_distance: 2
+ authorize: yes
provider: "{{ cli }}"
state: absent
become: yes
@@ -62,6 +65,7 @@
aggregate:
- { address: 192.168.4.0/24, next_hop: 192.168.0.1 }
- { address: 192.168.5.0/24, next_hop: 192.168.0.1 }
+ authorize: yes
provider: "{{ cli }}"
become: yes
register: result
@@ -86,6 +90,7 @@
aggregate:
- { address: 192.168.4.0/24, next_hop: 192.168.0.1 }
- { address: 192.168.5.0/24, next_hop: 192.168.0.1 }
+ authorize: yes
state: absent
provider: "{{ cli }}"
become: yes
@@ -112,6 +117,7 @@
- no ip route 192.168.3.0/24 192.168.0.1
- no ip route 192.168.4.0/24 192.168.0.1
- no ip route 192.168.5.0/24 192.168.0.1
+ authorize: yes
provider: "{{ cli }}"
become: yes
diff --git a/test/integration/targets/eos_static_route/tests/cli/net_static_route.yaml b/test/integration/targets/eos_static_route/tests/cli/net_static_route.yaml
index 5a69438b71..5c0b70dd7a 100644
--- a/test/integration/targets/eos_static_route/tests/cli/net_static_route.yaml
+++ b/test/integration/targets/eos_static_route/tests/cli/net_static_route.yaml
@@ -8,6 +8,7 @@
eos_config:
lines:
- no ip route 192.168.3.0/24 192.168.0.1
+ authorize: yes
provider: "{{ cli }}"
become: yes
@@ -16,6 +17,7 @@
address: 192.168.3.0/24
next_hop: 192.168.0.1
admin_distance: 2
+ authorize: yes
provider: "{{ cli }}"
become: yes
register: result
@@ -29,6 +31,7 @@
eos_config:
lines:
- no ip route 192.168.3.0/24 192.168.0.1
+ authorize: yes
provider: "{{ cli }}"
become: yes
diff --git a/test/integration/targets/eos_user/tests/cli/auth.yaml b/test/integration/targets/eos_user/tests/cli/auth.yaml
index bb7e022e51..04e6c90e1a 100644
--- a/test/integration/targets/eos_user/tests/cli/auth.yaml
+++ b/test/integration/targets/eos_user/tests/cli/auth.yaml
@@ -6,6 +6,7 @@
privilege: 15
role: network-operator
state: present
+ authorize: yes
provider: "{{ cli }}"
configured_password: pass123
become: yes
@@ -35,5 +36,6 @@
name: auth_user
state: absent
provider: "{{ cli }}"
+ authorize: yes
become: yes
register: result
diff --git a/test/integration/targets/eos_user/tests/cli/basic.yaml b/test/integration/targets/eos_user/tests/cli/basic.yaml
index cc12ab88fd..0efee72ff5 100644
--- a/test/integration/targets/eos_user/tests/cli/basic.yaml
+++ b/test/integration/targets/eos_user/tests/cli/basic.yaml
@@ -18,6 +18,7 @@
role: network-operator
state: present
configured_password: test1
+ authorize: yes
provider: "{{ cli }}"
become: yes
register: result
@@ -36,6 +37,7 @@
privilege: 15
state: present
configured_password: test1
+ authorize: yes
update_password: on_create
provider: "{{ cli }}"
become: yes
@@ -53,6 +55,7 @@
aggregate:
- { name: ansibletest2, configured_password: test2 }
- { name: ansibletest3, configured_password: test3 }
+ authorize: yes
state: present
role: network-operator
provider: "{{ cli }}"
@@ -74,6 +77,7 @@
name: faileduser1
privilege: 15
state: present
+ authorize: yes
provider: "{{ cli }}"
become: yes
ignore_errors: yes
@@ -93,4 +97,5 @@
- no username ansibletest3
- no username ansibletest4
provider: "{{ cli }}"
+ authorize: yes
become: yes
diff --git a/test/integration/targets/eos_user/tests/cli/net_user.yaml b/test/integration/targets/eos_user/tests/cli/net_user.yaml
index e5eeb5c181..e3cf836e26 100644
--- a/test/integration/targets/eos_user/tests/cli/net_user.yaml
+++ b/test/integration/targets/eos_user/tests/cli/net_user.yaml
@@ -18,6 +18,7 @@
role: network-operator
state: present
configured_password: test1
+ authorize: yes
provider: "{{ cli }}"
become: yes
register: result
diff --git a/test/integration/targets/eos_vlan/tests/cli/basic.yaml b/test/integration/targets/eos_vlan/tests/cli/basic.yaml
index 11b869d01c..1d1bd97920 100644
--- a/test/integration/targets/eos_vlan/tests/cli/basic.yaml
+++ b/test/integration/targets/eos_vlan/tests/cli/basic.yaml
@@ -6,6 +6,7 @@
- no vlan 4000
- no vlan 4001
- no vlan 4002
+ authorize: yes
provider: "{{ cli }}"
become: yes
@@ -15,6 +16,7 @@
- switchport
- no switchport access vlan 4000
parents: interface Ethernet1
+ authorize: yes
provider: "{{ cli }}"
become: yes
@@ -24,6 +26,7 @@
- switchport
- no switchport access vlan 4000
parents: interface Ethernet2
+ authorize: yes
provider: "{{ cli }}"
become: yes
@@ -32,6 +35,7 @@
vlan_id: 4000
name: vlan-4000
state: present
+ authorize: yes
provider: "{{ cli }}"
become: yes
register: result
@@ -49,6 +53,7 @@
vlan_id: 4000
name: vlan-4000
state: present
+ authorize: yes
provider: "{{ cli }}"
become: yes
register: result
@@ -65,6 +70,7 @@
vlan_id: 4000
name: vlan-4000-new
state: suspend
+ authorize: yes
provider: "{{ cli }}"
become: yes
register: result
@@ -83,6 +89,7 @@
vlan_id: 4000
name: vlan-4000-new
state: suspend
+ authorize: yes
provider: "{{ cli }}"
become: yes
register: result
@@ -98,6 +105,7 @@
eos_vlan:
vlan_id: 4000
state: active
+ authorize: yes
provider: "{{ cli }}"
become: yes
register: result
@@ -120,6 +128,7 @@
associated_interfaces:
- Ethernet1
- Ethernet2
+ authorize: yes
provider: "{{ cli }}"
become: yes
register: result
@@ -142,6 +151,7 @@
interfaces:
- Ethernet 1 # interface name space scenario
- Ethernet 2 # interface name space scenario
+ authorize: yes
provider: "{{ cli }}"
become: yes
register: result
@@ -159,6 +169,7 @@
state: present
associated_interfaces:
- test
+ authorize: yes
provider: "{{ cli }}"
become: yes
register: result
@@ -174,6 +185,7 @@
state: present
interfaces:
- Ethernet1
+ authorize: yes
provider: "{{ cli }}"
become: yes
register: result
@@ -193,6 +205,7 @@
state: present
interfaces:
- Ethernet 1 # space scenario
+ authorize: yes
provider: "{{ cli }}"
become: yes
register: result
@@ -210,6 +223,7 @@
- {vlan_id: 4000, state: absent}
- {vlan_id: 4001, name: vlan-4001}
state: present
+ authorize: yes
provider: "{{ cli }}"
become: yes
register: result
@@ -229,6 +243,7 @@
- {vlan_id: 4000, state: absent}
- {vlan_id: 4001, name: vlan-4001}
state: present
+ authorize: yes
provider: "{{ cli }}"
become: yes
register: result
@@ -247,6 +262,7 @@
name: vlan-4002
state: present
purge: yes
+ authorize: yes
provider: "{{ cli }}"
become: yes
register: result
@@ -267,6 +283,7 @@
name: vlan-4002
state: present
purge: yes
+ authorize: yes
provider: "{{ cli }}"
become: yes
register: result
diff --git a/test/integration/targets/eos_vlan/tests/cli/net_vlan.yaml b/test/integration/targets/eos_vlan/tests/cli/net_vlan.yaml
index 8fcb93b13d..4b8c886d8c 100644
--- a/test/integration/targets/eos_vlan/tests/cli/net_vlan.yaml
+++ b/test/integration/targets/eos_vlan/tests/cli/net_vlan.yaml
@@ -8,6 +8,7 @@
eos_config:
lines:
- no vlan 4000
+ authorize: yes
provider: "{{ cli }}"
become: yes
@@ -16,6 +17,7 @@
vlan_id: 4000
name: vlan-4000
state: present
+ authorize: yes
provider: "{{ cli }}"
become: yes
register: result
@@ -32,6 +34,7 @@
eos_config:
lines:
- no vlan 4000
+ authorize: yes
provider: "{{ cli }}"
become: yes
diff --git a/test/integration/targets/eos_vrf/tests/cli/basic.yaml b/test/integration/targets/eos_vrf/tests/cli/basic.yaml
index b702495705..7064c25d03 100644
--- a/test/integration/targets/eos_vrf/tests/cli/basic.yaml
+++ b/test/integration/targets/eos_vrf/tests/cli/basic.yaml
@@ -4,6 +4,7 @@
eos_vrf:
name: "{{ item }}"
state: absent
+ authorize: yes
provider: "{{ cli }}"
become: yes
with_items:
@@ -19,6 +20,7 @@
name: test
rd: 1:200
state: present
+ authorize: yes
provider: "{{ cli }}"
become: yes
register: result
@@ -36,6 +38,7 @@
name: test
rd: 1:200
state: present
+ authorize: yes
provider: "{{ cli }}"
become: yes
register: result
@@ -52,6 +55,7 @@
name: test
rd: 1:201
state: present
+ authorize: yes
provider: "{{ cli }}"
become: yes
register: result
@@ -69,6 +73,7 @@
name: test
rd: 1:201
state: present
+ authorize: yes
provider: "{{ cli }}"
become: yes
register: result
@@ -85,6 +90,7 @@
name: test
rd: 1:201
state: present
+ authorize: yes
interfaces:
- Ethernet2
associated_interfaces:
@@ -106,6 +112,7 @@
name: test
rd: 1:201
state: present
+ authorize: yes
interfaces:
- ethernet 2 # interface name modified to test case insensitive and space scenario
provider: "{{ cli }}"
@@ -123,6 +130,7 @@
eos_vrf:
name: test
state: present
+ authorize: yes
associated_interfaces:
- test
provider: "{{ cli }}"
@@ -139,6 +147,7 @@
name: test1
rd: 1:202
state: present
+ authorize: yes
interfaces:
- loopback10
- loopback11
@@ -175,6 +184,7 @@
name: test1
rd: 1:202
state: present
+ authorize: yes
interfaces:
- loopback10
- loopback11
@@ -196,6 +206,7 @@
eos_vrf:
name: "{{ item }}"
state: absent
+ authorize: yes
provider: "{{ cli }}"
become: yes
with_items:
@@ -209,6 +220,7 @@
- { name: test2, rd: "1:202" }
- { name: test3, rd: "1:203" }
state: present
+ authorize: yes
provider: "{{ cli }}"
become: yes
register: result
@@ -229,6 +241,7 @@
- { name: test2, rd: "1:202" }
- { name: test3, rd: "1:203" }
state: present
+ authorize: yes
provider: "{{ cli }}"
become: yes
register: result
@@ -247,6 +260,7 @@
- { name: test5, rd: "1:205" }
state: present
purge: yes
+ authorize: yes
provider: "{{ cli }}"
become: yes
register: result
@@ -268,6 +282,7 @@
eos_vrf:
name: test
state: absent
+ authorize: yes
provider: "{{ cli }}"
become: yes
@@ -275,6 +290,7 @@
eos_vrf:
name: test
state: absent
+ authorize: yes
provider: "{{ cli }}"
become: yes
@@ -287,6 +303,7 @@
- { name: test4 }
- { name: test5 }
state: absent
+ authorize: yes
provider: "{{ cli }}"
become: yes
@@ -299,6 +316,7 @@
- { name: test4 }
- { name: test5 }
state: absent
+ authorize: yes
provider: "{{ cli }}"
become: yes
diff --git a/test/integration/targets/eos_vrf/tests/cli/net_vrf.yaml b/test/integration/targets/eos_vrf/tests/cli/net_vrf.yaml
index c7abce9f20..708fabada8 100644
--- a/test/integration/targets/eos_vrf/tests/cli/net_vrf.yaml
+++ b/test/integration/targets/eos_vrf/tests/cli/net_vrf.yaml
@@ -8,6 +8,7 @@
net_vrf:
name: test
state: absent
+ authorize: yes
provider: "{{ cli }}"
become: yes
@@ -16,6 +17,7 @@
name: test
rd: 1:200
state: present
+ authorize: yes
provider: "{{ cli }}"
become: yes
register: result
@@ -32,6 +34,7 @@
net_vrf:
name: test
state: absent
+ authorize: yes
provider: "{{ cli }}"
become: yes
diff --git a/test/integration/targets/ios_ping/tests/cli/ping.yaml b/test/integration/targets/ios_ping/tests/cli/ping.yaml
index 3b6c96ce81..cddae60bf5 100644
--- a/test/integration/targets/ios_ping/tests/cli/ping.yaml
+++ b/test/integration/targets/ios_ping/tests/cli/ping.yaml
@@ -31,6 +31,7 @@
- name: unexpected unsuccessful ping
ios_ping: &invalid_ip
dest: '10.255.255.250'
+ timeout: 45
provider: "{{ cli }}"
register: uup
ignore_errors: yes
diff --git a/test/units/modules/network/eos/test_eos_banner.py b/test/units/modules/network/eos/test_eos_banner.py
index 611aff6dc5..db062d41f9 100644
--- a/test/units/modules/network/eos/test_eos_banner.py
+++ b/test/units/modules/network/eos/test_eos_banner.py
@@ -22,9 +22,6 @@ from ansible.modules.network.eos import eos_banner
from units.modules.utils import set_module_args
from .eos_module import TestEosModule, load_fixture
-CLI = dict(transport="cli")
-EAPI = dict(transport="eapi")
-
class TestEosBannerModule(TestEosModule):
@@ -54,32 +51,34 @@ class TestEosBannerModule(TestEosModule):
self.load_config.return_value = dict(diff=None, session='session')
def test_eos_banner_create_with_cli_transport(self):
- set_module_args(dict(banner='login', text='test\nbanner\nstring', provider=CLI))
+ set_module_args(dict(banner='login', text='test\nbanner\nstring',
+ transport='cli'))
commands = ['banner login', 'test', 'banner', 'string', 'EOF']
self.execute_module(changed=True, commands=commands)
def test_eos_banner_remove_with_cli_transport(self):
- set_module_args(dict(banner='login', state='absent', provider=CLI))
+ set_module_args(dict(banner='login', state='absent', transport='cli'))
commands = ['no banner login']
self.execute_module(changed=True, commands=commands)
def test_eos_banner_create_with_eapi_transport(self):
- set_module_args(dict(banner='login', text='test\nbanner\nstring', provider=EAPI))
+ set_module_args(dict(banner='login', text='test\nbanner\nstring',
+ transport='eapi'))
commands = ['banner login']
inputs = ['test\nbanner\nstring']
self.execute_module(changed=True, commands=commands, inputs=inputs, transport='eapi')
def test_eos_banner_remove_with_eapi_transport(self):
- set_module_args(dict(banner='login', state='absent', provider=EAPI))
+ set_module_args(dict(banner='login', state='absent', transport='eapi'))
commands = ['no banner login']
self.execute_module(changed=True, commands=commands, transport='eapi')
def test_eos_banner_nochange_with_cli_transport(self):
banner_text = load_fixture('eos_banner_show_banner.txt').strip()
- set_module_args(dict(banner='login', text=banner_text, provider=CLI))
+ set_module_args(dict(banner='login', text=banner_text, transport='cli'))
self.execute_module()
def test_eos_banner_nochange_with_eapi_transport(self):
banner_text = load_fixture('eos_banner_show_banner.txt').strip()
- set_module_args(dict(banner='login', text=banner_text, provider=EAPI))
+ set_module_args(dict(banner='login', text=banner_text, transport='eapi'))
self.execute_module(transport='eapi')
diff --git a/test/units/modules/network/ios/test_ios_ping.py b/test/units/modules/network/ios/test_ios_ping.py
index 2811663ea1..c221137e02 100644
--- a/test/units/modules/network/ios/test_ios_ping.py
+++ b/test/units/modules/network/ios/test_ios_ping.py
@@ -59,7 +59,7 @@ class TestIosPingModule(TestIosModule):
def test_ios_ping_expected_failure(self):
''' Test for unsuccessful pings when destination should not be reachable '''
- set_module_args(dict(count=2, dest="10.255.255.250", state="absent"))
+ set_module_args(dict(count=2, dest="10.255.255.250", state="absent", timeout=45))
self.execute_module()
def test_ios_ping_unexpected_success(self):
@@ -69,5 +69,5 @@ class TestIosPingModule(TestIosModule):
def test_ios_ping_unexpected_failure(self):
''' Test for unsuccessful pings when destination should be reachable - FAIL. '''
- set_module_args(dict(count=2, dest="10.255.255.250"))
+ set_module_args(dict(count=2, dest="10.255.255.250", timeout=45))
self.execute_module(failed=True)
diff --git a/test/units/modules/network/junos/test_junos_package.py b/test/units/modules/network/junos/test_junos_package.py
index 4e1dba3d87..57446550b8 100644
--- a/test/units/modules/network/junos/test_junos_package.py
+++ b/test/units/modules/network/junos/test_junos_package.py
@@ -37,10 +37,16 @@ module_patcher.start()
from ansible.modules.network.junos import junos_package
-class TestJunosPackageModule(TestJunosModule):
+class TestJunosCommandModule(TestJunosModule):
module = junos_package
+ def setUp(self):
+ super(TestJunosCommandModule, self).setUp()
+
+ def tearDown(self):
+ super(TestJunosCommandModule, self).tearDown()
+
def test_junos_package_src(self):
set_module_args(dict(src='junos-vsrx-12.1X46-D10.2-domestic.tgz'))
result = self.execute_module(changed=True)
diff --git a/test/units/modules/network/nxos/test_nxos_hsrp.py b/test/units/modules/network/nxos/test_nxos_hsrp.py
index dc459ab9cd..2cb84a224d 100644
--- a/test/units/modules/network/nxos/test_nxos_hsrp.py
+++ b/test/units/modules/network/nxos/test_nxos_hsrp.py
@@ -55,7 +55,7 @@ class TestNxosHsrpModule(TestNxosModule):
priority='150',
interface='Ethernet1/2',
preempt='enabled',
- ))
+ host='192.0.2.1'))
result = self.execute_module(changed=True)
self.assertEqual(sorted(result['commands']), sorted(['config t',
'interface ethernet1/2',