mirror of
https://github.com/ansible/awx.git
synced 2024-11-01 16:51:11 +03:00
Present the tower inventory sync failure in a better way
This allows it to be handled better by ansible 2.4+
This commit is contained in:
parent
e20599d7bb
commit
8a65c6e1c8
@ -68,8 +68,7 @@ def parse_configuration():
|
||||
if not inventory:
|
||||
errors.append("Missing TOWER_INVENTORY in environment")
|
||||
if errors:
|
||||
print("\n".join(errors))
|
||||
sys.exit(1)
|
||||
raise RuntimeError("\n".join(errors))
|
||||
|
||||
return dict(tower_host=host_name,
|
||||
tower_user=username,
|
||||
@ -92,12 +91,10 @@ def read_tower_inventory(tower_host, tower_user, tower_pass, inventory, license_
|
||||
if config_response.ok:
|
||||
source_type = config_response.json()['license_info']['license_type']
|
||||
if not source_type == license_type:
|
||||
print("Tower server licenses must match: source: {} local: {}".format(source_type,
|
||||
license_type))
|
||||
sys.exit(1)
|
||||
raise RuntimeError("Tower server licenses must match: source: {} local: {}".format(source_type,
|
||||
license_type))
|
||||
else:
|
||||
print("Failed to validate the license of the remote Tower: {}".format(config_response.data))
|
||||
sys.exit(1)
|
||||
raise RuntimeError("Failed to validate the license of the remote Tower: {}".format(config_response.data))
|
||||
|
||||
response = requests.get(inventory_url,
|
||||
auth=HTTPBasicAuth(tower_user, tower_pass),
|
||||
@ -110,8 +107,7 @@ def read_tower_inventory(tower_host, tower_user, tower_pass, inventory, license_
|
||||
reason = "Connection to remote host failed: {}".format(e)
|
||||
except json.JSONDecodeError, e:
|
||||
reason = "Failed to parse json from host: {}".format(e)
|
||||
print(reason)
|
||||
sys.exit(1)
|
||||
raise RuntimeError(reason)
|
||||
|
||||
|
||||
def main():
|
||||
@ -128,5 +124,6 @@ def main():
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
Loading…
Reference in New Issue
Block a user