switched exit_json to be fail_json so it didn't trigger an error when attempting to utilize the missing_required_lib from ansible. Additionally fixed it for the second usage for correct usage. Given that it is an exception the correct one would not be to exit without failure, as exit_json does, but instead to use fail_json and be able to present the error

This commit is contained in:
Rebeccah 2020-10-01 18:28:26 -04:00
parent a9cfae70ff
commit 5df37d4279
No known key found for this signature in database
GPG Key ID: 40B19D22F2604B29

View File

@ -24,7 +24,7 @@ class TowerAWXKitModule(TowerModule):
# Die if we don't have AWX_KIT installed
if not HAS_AWX_KIT:
self.exit_json(msg=missing_required_lib('awxkit'))
self.fail_json(msg=missing_required_lib('awxkit'))
# Establish our conneciton object
self.connection = Connection(self.host, verify=self.verify_ssl)
@ -38,7 +38,7 @@ class TowerAWXKitModule(TowerModule):
self.connection.login(username=self.username, password=self.password)
self.authenticated = True
except Exception:
self.exit_json("Failed to authenticate")
self.fail_json("Failed to authenticate")
def get_api_v2_object(self):
if not self.apiV2Ref: