Eos port default values (#23829)

* Hook port back up for eos cli transport

* The default values have moved

* Why not have conditional defaults?
This commit is contained in:
Nathaniel Case 2017-04-20 15:58:45 -04:00 committed by GitHub
parent b4b96143fe
commit 0c2a0c7bce
2 changed files with 8 additions and 8 deletions

View file

@ -60,7 +60,6 @@ eos_argument_spec = {
# Add argument's default value here
ARGS_DEFAULT_VALUE = {
'transport': 'cli',
'port': 443,
'use_ssl': True,
'validate_certs': True
}

View file

@ -24,9 +24,8 @@ import sys
import copy
from ansible.module_utils.basic import AnsibleFallbackNotFound
from ansible.module_utils.eos import eos_argument_spec
from ansible.module_utils.eos import ARGS_DEFAULT_VALUE, eos_argument_spec
from ansible.module_utils.six import iteritems
from ansible.module_utils._text import to_bytes
from ansible.plugins import connection_loader
from ansible.plugins.action.normal import ActionModule as _ActionModule
from ansible.utils.path import unfrackpath
@ -58,6 +57,7 @@ class ActionModule(_ActionModule):
pc.connection = 'network_cli'
pc.network_os = 'eos'
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
@ -96,8 +96,12 @@ class ActionModule(_ActionModule):
if provider.get('host') is None:
provider['host'] = self._play_context.remote_addr
if provider.get('use_ssl') is None:
provider['use_ssl'] = ARGS_DEFAULT_VALUE['use_ssl']
if provider.get('port') is None:
provider['port'] = eos_argument_spec['port']['default']
default_port = 443 if provider['use_ssl'] else 80
provider['port'] = self._play_context.port or default_port
if provider.get('timeout') is None:
provider['timeout'] = self._play_context.timeout
@ -111,11 +115,8 @@ class ActionModule(_ActionModule):
if provider.get('authorize') is None:
provider['authorize'] = False
if provider.get('use_ssl') is None:
provider['use_ssl'] = eos_argument_spec['use_ssl']['default']
if provider.get('validate_certs') is None:
provider['validate_certs'] = eos_argument_spec['validate_certs']['default']
provider['validate_certs'] = ARGS_DEFAULT_VALUE['validate_certs']
self._task.args['provider'] = provider