summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbhijeet Kasurde <akasurde@redhat.com>2019-03-06 16:48:43 +0530
committeransibot <ansibot@users.noreply.github.com>2019-03-06 06:18:43 -0500
commit5b0eae75fa1ab10ec556b163291e00f4b60cde65 (patch)
tree3169ada1f2c360cb2c546ae8e4277ffa949a49f1
parente246e74843d841e93757ceef150847c2abc4a8c3 (diff)
downloadansible-5b0eae75fa1ab10ec556b163291e00f4b60cde65.tar.gz
tower: Handle AuthError (#53377)
Handle AuthError raised when user provides incorrect password for Tower admin user. Fixes: #50535 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
-rw-r--r--lib/ansible/modules/web_infrastructure/ansible_tower/tower_credential.py2
-rw-r--r--lib/ansible/modules/web_infrastructure/ansible_tower/tower_credential_type.py2
-rw-r--r--lib/ansible/modules/web_infrastructure/ansible_tower/tower_group.py2
-rw-r--r--lib/ansible/modules/web_infrastructure/ansible_tower/tower_host.py2
-rw-r--r--lib/ansible/modules/web_infrastructure/ansible_tower/tower_inventory.py2
-rw-r--r--lib/ansible/modules/web_infrastructure/ansible_tower/tower_inventory_source.py2
-rw-r--r--lib/ansible/modules/web_infrastructure/ansible_tower/tower_job_cancel.py2
-rw-r--r--lib/ansible/modules/web_infrastructure/ansible_tower/tower_job_launch.py2
-rw-r--r--lib/ansible/modules/web_infrastructure/ansible_tower/tower_job_list.py2
-rw-r--r--lib/ansible/modules/web_infrastructure/ansible_tower/tower_job_template.py2
-rw-r--r--lib/ansible/modules/web_infrastructure/ansible_tower/tower_job_wait.py2
-rw-r--r--lib/ansible/modules/web_infrastructure/ansible_tower/tower_label.py2
-rw-r--r--lib/ansible/modules/web_infrastructure/ansible_tower/tower_notification.py2
-rw-r--r--lib/ansible/modules/web_infrastructure/ansible_tower/tower_organization.py2
-rw-r--r--lib/ansible/modules/web_infrastructure/ansible_tower/tower_project.py2
-rw-r--r--lib/ansible/modules/web_infrastructure/ansible_tower/tower_receive.py2
-rw-r--r--lib/ansible/modules/web_infrastructure/ansible_tower/tower_role.py2
-rw-r--r--lib/ansible/modules/web_infrastructure/ansible_tower/tower_send.py2
-rw-r--r--lib/ansible/modules/web_infrastructure/ansible_tower/tower_settings.py2
-rw-r--r--lib/ansible/modules/web_infrastructure/ansible_tower/tower_team.py2
-rw-r--r--lib/ansible/modules/web_infrastructure/ansible_tower/tower_user.py2
-rw-r--r--lib/ansible/modules/web_infrastructure/ansible_tower/tower_workflow_launch.py2
-rw-r--r--lib/ansible/modules/web_infrastructure/ansible_tower/tower_workflow_template.py2
23 files changed, 23 insertions, 23 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 46152baebf..6fe95e59cb 100644
--- a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_credential.py
+++ b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_credential.py
@@ -307,7 +307,7 @@ def main():
result = credential.delete(**params)
except (exc.NotFound) as excinfo:
module.fail_json(msg='Failed to update credential, organization not found: {0}'.format(excinfo), changed=False)
- except (exc.ConnectionError, exc.BadRequest, exc.NotFound) as excinfo:
+ except (exc.ConnectionError, exc.BadRequest, exc.NotFound, exc.AuthError) as excinfo:
module.fail_json(msg='Failed to update credential: {0}'.format(excinfo), changed=False)
json_output['changed'] = result['changed']
diff --git a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_credential_type.py b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_credential_type.py
index e8f28d9867..12b75a4029 100644
--- a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_credential_type.py
+++ b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_credential_type.py
@@ -159,7 +159,7 @@ def main():
params['fail_on_missing'] = False
result = credential_type_res.delete(**params)
- except (exc.ConnectionError, exc.BadRequest) as excinfo:
+ except (exc.ConnectionError, exc.BadRequest, exc.AuthError) as excinfo:
module.fail_json(
msg='Failed to update credential type: {0}'.format(excinfo),
changed=False
diff --git a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_group.py b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_group.py
index 50772891ff..666b7386b8 100644
--- a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_group.py
+++ b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_group.py
@@ -166,7 +166,7 @@ def main():
result = group.delete(**params)
except (exc.NotFound) as excinfo:
module.fail_json(msg='Failed to update the group, inventory not found: {0}'.format(excinfo), changed=False)
- except (exc.ConnectionError, exc.BadRequest, exc.NotFound) as excinfo:
+ except (exc.ConnectionError, exc.BadRequest, exc.NotFound, exc.AuthError) as excinfo:
module.fail_json(msg='Failed to update the group: {0}'.format(excinfo), changed=False)
json_output['changed'] = result['changed']
diff --git a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_host.py b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_host.py
index 492c4842c0..6fd411a636 100644
--- a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_host.py
+++ b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_host.py
@@ -120,7 +120,7 @@ def main():
result = host.delete(name=name, inventory=inv['id'])
except (exc.NotFound) as excinfo:
module.fail_json(msg='Failed to update host, inventory not found: {0}'.format(excinfo), changed=False)
- except (exc.ConnectionError, exc.BadRequest) as excinfo:
+ except (exc.ConnectionError, exc.BadRequest, exc.AuthError) as excinfo:
module.fail_json(msg='Failed to update host: {0}'.format(excinfo), changed=False)
json_output['changed'] = result['changed']
diff --git a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_inventory.py b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_inventory.py
index 1be2477321..c709ab7c8a 100644
--- a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_inventory.py
+++ b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_inventory.py
@@ -119,7 +119,7 @@ def main():
result = inventory.delete(name=name, organization=org['id'])
except (exc.NotFound) as excinfo:
module.fail_json(msg='Failed to update inventory, organization not found: {0}'.format(excinfo), changed=False)
- except (exc.ConnectionError, exc.BadRequest) as excinfo:
+ except (exc.ConnectionError, exc.BadRequest, exc.AuthError) as excinfo:
module.fail_json(msg='Failed to update inventory: {0}'.format(excinfo), changed=False)
json_output['changed'] = result['changed']
diff --git a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_inventory_source.py b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_inventory_source.py
index 11c6439a1d..48a1e9ce1d 100644
--- a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_inventory_source.py
+++ b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_inventory_source.py
@@ -302,7 +302,7 @@ def main():
params['fail_on_missing'] = False
result = inventory_source.delete(**params)
- except (exc.ConnectionError, exc.BadRequest) as excinfo:
+ except (exc.ConnectionError, exc.BadRequest, exc.AuthError) as excinfo:
module.fail_json(msg='Failed to update inventory source: \
{0}'.format(excinfo), changed=False)
diff --git a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_job_cancel.py b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_job_cancel.py
index f2f5f8eada..02fa3b7b19 100644
--- a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_job_cancel.py
+++ b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_job_cancel.py
@@ -89,7 +89,7 @@ def main():
try:
result = job.cancel(job_id, **params)
json_output['id'] = job_id
- except (exc.ConnectionError, exc.BadRequest, exc.TowerCLIError) as excinfo:
+ except (exc.ConnectionError, exc.BadRequest, exc.TowerCLIError, exc.AuthError) as excinfo:
module.fail_json(msg='Unable to cancel job_id/{0}: {1}'.format(job_id, excinfo), changed=False)
json_output['changed'] = result['changed']
diff --git a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_job_launch.py b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_job_launch.py
index c34ec3dd23..d05abba097 100644
--- a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_job_launch.py
+++ b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_job_launch.py
@@ -134,7 +134,7 @@ def main():
result = job.launch(no_input=True, **params)
json_output['id'] = result['id']
json_output['status'] = result['status']
- except (exc.ConnectionError, exc.BadRequest) as excinfo:
+ except (exc.ConnectionError, exc.BadRequest, exc.AuthError) as excinfo:
module.fail_json(msg='Unable to launch job: {0}'.format(excinfo), changed=False)
json_output['changed'] = result['changed']
diff --git a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_job_list.py b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_job_list.py
index 51eda5ecdb..5665f8d935 100644
--- a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_job_list.py
+++ b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_job_list.py
@@ -118,7 +118,7 @@ def main():
if query:
params['query'] = query.items()
json_output = job.list(**params)
- except (exc.ConnectionError, exc.BadRequest) as excinfo:
+ except (exc.ConnectionError, exc.BadRequest, exc.AuthError) as excinfo:
module.fail_json(msg='Failed to list jobs: {0}'.format(excinfo), changed=False)
module.exit_json(**json_output)
diff --git a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_job_template.py b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_job_template.py
index 36106998a3..8e18195cb8 100644
--- a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_job_template.py
+++ b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_job_template.py
@@ -326,7 +326,7 @@ def main():
json_output['id'] = result['id']
elif state == 'absent':
result = jt.delete(**params)
- except (exc.ConnectionError, exc.BadRequest, exc.NotFound) as excinfo:
+ except (exc.ConnectionError, exc.BadRequest, exc.NotFound, exc.AuthError) as excinfo:
module.fail_json(msg='Failed to update job template: {0}'.format(excinfo), changed=False)
json_output['changed'] = result['changed']
diff --git a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_job_wait.py b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_job_wait.py
index 8974289157..42bbbb68ee 100644
--- a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_job_wait.py
+++ b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_job_wait.py
@@ -132,7 +132,7 @@ def main():
json_output['timeout'] = True
except exc.NotFound as excinfo:
fail_json = dict(msg='Unable to wait, no job_id {0} found: {1}'.format(job_id, excinfo), changed=False)
- except (exc.ConnectionError, exc.BadRequest) as excinfo:
+ except (exc.ConnectionError, exc.BadRequest, exc.AuthError) as excinfo:
fail_json = dict(msg='Unable to wait for job: {0}'.format(excinfo), changed=False)
if fail_json is not None:
diff --git a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_label.py b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_label.py
index 554d154cb1..eca8ea1b55 100644
--- a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_label.py
+++ b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_label.py
@@ -91,7 +91,7 @@ def main():
result = label.delete(name=name, organization=org['id'])
except (exc.NotFound) as excinfo:
module.fail_json(msg='Failed to update label, organization not found: {0}'.format(excinfo), changed=False)
- except (exc.ConnectionError, exc.BadRequest, exc.NotFound) as excinfo:
+ except (exc.ConnectionError, exc.BadRequest, exc.NotFound, exc.AuthError) as excinfo:
module.fail_json(msg='Failed to update label: {0}'.format(excinfo), changed=False)
json_output['changed'] = result['changed']
diff --git a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_notification.py b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_notification.py
index 4b6d74a233..ae3ab87f7e 100644
--- a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_notification.py
+++ b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_notification.py
@@ -382,7 +382,7 @@ def main():
result = notification_template.delete(name=name)
except (exc.NotFound) as excinfo:
module.fail_json(msg='Failed to update notification template, organization not found: {0}'.format(excinfo), changed=False)
- except (exc.ConnectionError, exc.BadRequest) as excinfo:
+ except (exc.ConnectionError, exc.BadRequest, exc.AuthError) as excinfo:
module.fail_json(msg='Failed to update notification template: {0}'.format(excinfo), changed=False)
json_output['changed'] = result['changed']
diff --git a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_organization.py b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_organization.py
index 8acbfd5108..bba58d8894 100644
--- a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_organization.py
+++ b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_organization.py
@@ -84,7 +84,7 @@ def main():
json_output['id'] = result['id']
elif state == 'absent':
result = organization.delete(name=name)
- except (exc.ConnectionError, exc.BadRequest) as excinfo:
+ except (exc.ConnectionError, exc.BadRequest, exc.AuthError) as excinfo:
module.fail_json(msg='Failed to update the organization: {0}'.format(excinfo), changed=False)
json_output['changed'] = result['changed']
diff --git a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_project.py b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_project.py
index 38adfd4a36..f8c380ce79 100644
--- a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_project.py
+++ b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_project.py
@@ -202,7 +202,7 @@ def main():
json_output['id'] = result['id']
elif state == 'absent':
result = project.delete(name=name)
- except (exc.ConnectionError, exc.BadRequest) as excinfo:
+ except (exc.ConnectionError, exc.BadRequest, exc.AuthError) as excinfo:
module.fail_json(msg='Failed to update project: {0}'.format(excinfo), changed=False)
json_output['changed'] = result['changed']
diff --git a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_receive.py b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_receive.py
index 1bbb006737..57fdd16df4 100644
--- a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_receive.py
+++ b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_receive.py
@@ -164,7 +164,7 @@ def main():
result['assets'] = receiver.export_assets(all=export_all, asset_input=assets_to_export)
module.exit_json(**result)
except TowerCLIError as e:
- result['message'] = e
+ result['message'] = e.message
module.fail_json(msg='Receive Failed', **result)
diff --git a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_role.py b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_role.py
index 38a56514b9..cc3ce15577 100644
--- a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_role.py
+++ b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_role.py
@@ -144,7 +144,7 @@ def main():
json_output['id'] = result['id']
elif state == 'absent':
result = role.revoke(**params)
- except (exc.ConnectionError, exc.BadRequest, exc.NotFound) as excinfo:
+ except (exc.ConnectionError, exc.BadRequest, exc.NotFound, exc.AuthError) as excinfo:
module.fail_json(msg='Failed to update role: {0}'.format(excinfo), changed=False)
json_output['changed'] = result['changed']
diff --git a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_send.py b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_send.py
index 387e82bcb7..4010ee7a1b 100644
--- a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_send.py
+++ b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_send.py
@@ -148,7 +148,7 @@ def main():
if sender.changed_messages > 0:
result['changed'] = True
except TowerCLIError as e:
- result['msg'] = e
+ result['msg'] = e.message
failed = True
finally:
if path is not None:
diff --git a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_settings.py b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_settings.py
index 1a2acbfb9e..6695fdf302 100644
--- a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_settings.py
+++ b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_settings.py
@@ -91,7 +91,7 @@ def main():
json_output['id'] = result['id']
json_output['value'] = result['value']
- except (exc.ConnectionError, exc.BadRequest) as excinfo:
+ except (exc.ConnectionError, exc.BadRequest, exc.AuthError) as excinfo:
module.fail_json(msg='Failed to modify the setting: {0}'.format(excinfo), changed=False)
json_output['changed'] = result['changed']
diff --git a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_team.py b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_team.py
index 4c49fd5447..5174d39ba7 100644
--- a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_team.py
+++ b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_team.py
@@ -96,7 +96,7 @@ def main():
result = team.delete(name=name, organization=org['id'])
except (exc.NotFound) as excinfo:
module.fail_json(msg='Failed to update team, organization not found: {0}'.format(excinfo), changed=False)
- except (exc.ConnectionError, exc.BadRequest, exc.NotFound) as excinfo:
+ except (exc.ConnectionError, exc.BadRequest, exc.NotFound, exc.AuthError) as excinfo:
module.fail_json(msg='Failed to update team: {0}'.format(excinfo), changed=False)
json_output['changed'] = result['changed']
diff --git a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_user.py b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_user.py
index 86baf18e90..a16a44d823 100644
--- a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_user.py
+++ b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_user.py
@@ -119,7 +119,7 @@ def main():
json_output['id'] = result['id']
elif state == 'absent':
result = user.delete(username=username)
- except (exc.ConnectionError, exc.BadRequest) as excinfo:
+ except (exc.ConnectionError, exc.BadRequest, exc.AuthError) as excinfo:
module.fail_json(msg='Failed to update the user: {0}'.format(excinfo), changed=False)
json_output['changed'] = result['changed']
diff --git a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_workflow_launch.py b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_workflow_launch.py
index a7174ec3b2..e55e800482 100644
--- a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_workflow_launch.py
+++ b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_workflow_launch.py
@@ -51,7 +51,7 @@ tower_version:
type: str
sample: '3.4.0'
job_info:
- description: dictionnary containing information about the workflow executed
+ description: dictionary containing information about the workflow executed
returned: If workflow launched
type: dict
'''
diff --git a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_workflow_template.py b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_workflow_template.py
index 89e0744411..ef8565c05e 100644
--- a/lib/ansible/modules/web_infrastructure/ansible_tower/tower_workflow_template.py
+++ b/lib/ansible/modules/web_infrastructure/ansible_tower/tower_workflow_template.py
@@ -168,7 +168,7 @@ def main():
elif state == 'absent':
params['fail_on_missing'] = False
result = wfjt_res.delete(**params)
- except (exc.ConnectionError, exc.BadRequest) as excinfo:
+ except (exc.ConnectionError, exc.BadRequest, exc.AuthError) as excinfo:
module.fail_json(msg='Failed to update workflow template: \
{0}'.format(excinfo), changed=False)