diff --git a/lib/ansible/module_utils/eos.py b/lib/ansible/module_utils/eos.py index c87bbb8e583..242d85c42c9 100644 --- a/lib/ansible/module_utils/eos.py +++ b/lib/ansible/module_utils/eos.py @@ -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 } diff --git a/lib/ansible/plugins/action/eos.py b/lib/ansible/plugins/action/eos.py index d3b94f7bd69..965536932b4 100644 --- a/lib/ansible/plugins/action/eos.py +++ b/lib/ansible/plugins/action/eos.py @@ -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