From a32902427c8760c77623ba70873e90c3170c92ad Mon Sep 17 00:00:00 2001 From: Abhijeet Kasurde Date: Mon, 19 Nov 2018 22:46:41 +0530 Subject: [PATCH] linode_v4: correct usage of module.fail_json (#48882) Signed-off-by: Abhijeet Kasurde --- lib/ansible/modules/cloud/linode/linode_v4.py | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/lib/ansible/modules/cloud/linode/linode_v4.py b/lib/ansible/modules/cloud/linode/linode_v4.py index 7eecd2a86ea..4bf2aaa03d0 100644 --- a/lib/ansible/modules/cloud/linode/linode_v4.py +++ b/lib/ansible/modules/cloud/linode/linode_v4.py @@ -181,9 +181,7 @@ def create_linode(module, client, **kwargs): try: response = client.linode.instance_create(**kwargs) except Exception as exception: - raise module.fail_json(msg=( - 'Unable to query the Linode API. Saw: %s' - ) % exception) + module.fail_json(msg='Unable to query the Linode API. Saw: %s' % exception) try: if isinstance(response, tuple): @@ -194,11 +192,10 @@ def create_linode(module, client, **kwargs): else: return response._raw_json except TypeError: - raise module.fail_json(msg=( - 'Unable to parse Linode instance creation ' - 'response. Please raise a bug against this ' - 'module on https://github.com/ansible/ansible/issues' - )) + module.fail_json(msg='Unable to parse Linode instance creation' + ' response. Please raise a bug against this' + ' module on https://github.com/ansible/ansible/issues' + ) def maybe_instance_from_label(module, client): @@ -210,9 +207,7 @@ def maybe_instance_from_label(module, client): except IndexError: return None except Exception as exception: - raise module.fail_json(msg=( - 'Unable to query the Linode API. Saw: %s' - ) % exception) + module.fail_json(msg='Unable to query the Linode API. Saw: %s' % exception) def initialise_module(): @@ -262,8 +257,7 @@ def main(): module = initialise_module() if not HAS_LINODE_DEPENDENCY: - msg = 'The linode_v4 module requires the linode_api4 package' - raise module.fail_json(msg=msg) + module.fail_json(msg='The linode_v4 module requires the linode_api4 package') client = build_client(module) instance = maybe_instance_from_label(module, client)