From 0e7106b106b68b2c4b9e2338ade4a75301bcc1e2 Mon Sep 17 00:00:00 2001 From: Ryan Petrello Date: Thu, 1 Mar 2018 15:22:29 -0500 Subject: [PATCH] properly pass /api/v1/ credential fields for older Towers (#36917) --- .../ansible_tower/tower_credential.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_credential.py b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_credential.py index b0d1c0d7d32..35d9d3410cd 100644 --- a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_credential.py +++ b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_credential.py @@ -282,7 +282,6 @@ def main(): team = team_res.get(name=module.params.get('team')) params['team'] = team['id'] - params['inputs'] = {} if module.params.get('ssh_key_data'): filename = module.params.get('ssh_key_data') if not os.path.exists(filename): @@ -290,15 +289,17 @@ def main(): if os.path.isdir(filename): module.fail_json(msg='attempted to read contents of directory: %s' % filename) with open(filename, 'rb') as f: - params['inputs']['ssh_key_data'] = f.read() + module.params['ssh_key_data'] = f.read() for key in ('authorize', 'authorize_password', 'client', 'secret', 'tenant', 'subscription', 'domain', 'become_method', 'become_username', 'become_password', 'vault_password', 'project', 'host', 'username', 'password', - 'ssh_key_unlock'): - if module.params.get(key): - params['inputs'][key] = module.params.get(key) + 'ssh_key_data', 'ssh_key_unlock'): + if 'kind' in params: + params[key] = module.params.get(key) + elif module.params.get(key): + params.setdefault('inputs', {})[key] = module.params.get(key) if state == 'present': result = credential.modify(**params)