1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

fixes nxos nxapi implementation (#21615)

* correctly maps play_context to nxapi values
* fixes bug in nxos_nxapi module detecting nxapi feature
* updates nxos shared lib provider values
* fixes missing ssh_keyfile in nxos shared lib
This commit is contained in:
Peter Sprygada 2017-02-18 11:20:26 -05:00 committed by GitHub
parent eb6956e1dd
commit 920f9f4815
3 changed files with 19 additions and 15 deletions

View file

@ -41,12 +41,16 @@ _DEVICE_CONNECTION = None
nxos_argument_spec = {
'host': dict(),
'port': dict(type='int'),
'username': dict(fallback=(env_fallback, ['ANSIBLE_NET_USERNAME'])),
'password': dict(fallback=(env_fallback, ['ANSIBLE_NET_PASSWORD']), no_log=True),
'ssh_keyfile': dict(fallback=(env_fallback, ['ANSIBLE_NET_SSH_KEYFILE'])),
'use_ssl': dict(type='bool'),
'validate_certs': dict(type='bool'),
'timeout': dict(type='int'),
'provider': dict(type='dict'),
'provider': dict(type='dict', no_log=True),
'transport': dict(choices=['cli', 'nxapi'])
}
@ -347,7 +351,7 @@ def get_config(module, flags=[]):
def run_commands(module, commands, check_rc=True):
conn = get_connection(module)
return conn.run_commands(to_command(module, commands))
return conn.run_commands(to_command(module, commands), check_rc)
def load_config(module, config):
conn = get_connection(module)

View file

@ -209,7 +209,7 @@ def parse_sandbox(data):
def map_config_to_obj(module):
out = run_commands(module, ['show nxapi'], check_rc=False)
if not out[0]:
if out[0] == '':
return {'state': 'absent'}
out = str(out[0]).strip()

View file

@ -57,6 +57,8 @@ class ActionModule(_ActionModule):
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
pc.timeout = provider['timeout'] or self._play_context.timeout
connection = self._shared_loader_obj.connection_loader.get('persistent', pc, sys.stdin)
@ -71,18 +73,16 @@ class ActionModule(_ActionModule):
task_vars['ansible_socket'] = socket_path
else:
if provider['host'] is None:
self._task.args['host'] = self._play_context.remote_addr
if provider['username'] is None:
self._task.args['username'] = self._play_context.connection_user
if provider['password'] is None:
self._task.args['password'] = self._play_context.password
if provider['timeout'] is None:
self._task.args['timeout'] = self._play_context.timeout
if task_vars.get('nxapi_use_ssl'):
self._task.args['use_ssl'] = task_vars['nxapi_use_ssl']
if task_vars.get('nxapi_validate_certs'):
self._task.args['validate_certs'] = task_vars['nxapi_validate_certs']
provider_arg = {
'host': self._play_context.remote_addr,
'port': provider.get('port'),
'username': provider.get('username') or self._play_context.connection_user,
'password': provider.get('password') or self._play_context.password,
'timeout': provider.get('timeout') or self._play_context.timeout,
'use_ssl': task_vars.get('nxapi_use_ssl') or False,
'validate_certs': task_vars.get('nxapi_validate_certs') or True
}
self._task.args['provider'] = provider_arg
result = super(ActionModule, self).run(tmp, task_vars)