def state_cloudformation(self, latest_result, show_resource_vars): """ Returns the status of executed ansible cloudformation tasls from captured output. """ result = {} cf = convert_str(latest_result['invocation']['module_args']) # we need to handle 'present' and 'absent' situations differently if cf['state'] == 'present': result['stack_name'] = cf['stack_name'] if show_resource_vars: result['resource_vars'] = latest_result['stack_outputs'] if (latest_result['output'] == 'Stack CREATE complete' or latest_result['output'] == 'Stack is already up-to-date.'): result['state'] = 'deployed' else: result['state'] = 'deploy-error' else: # state == 'absent'... # We need to deal with the case where the stack does not exist # in a particular fashion for the command line `descibe` and # `list commands. if (latest_result.get('output', '') == 'Stack Deleted' or 'does not exist' in latest_result.get('msg', '')): result['state'] = 'absent' else: result['state'] = 'teardown-error' return result
def state_cloudformation(self, latest_result, show_resource_vars): """ Parses the output from the ansible `cloudformation` module. We do this because there isn't an easy way to tell if a stack doesn't exist. https://github.com/ansible/ansible-modules-core/issues/1370#issuecomment-126083403 """ result = {} cf = convert_str(latest_result["invocation"]["module_args"]) # we need to handle 'present' and 'absent' situations differently if cf["state"] == "present": result["stack_name"] = cf["stack_name"] if show_resource_vars: result["resource_vars"] = latest_result["stack_outputs"] if (latest_result["output"] == "Stack CREATE complete" or latest_result["output"] == "Stack is already up-to-date."): result["state"] = "deployed" else: result["state"] = "deploy-error" else: # state == "absent"... # We need to deal with the case where the stack does not exist # in a particular fashion for the command line `descibe` and # `list commands. if (latest_result.get("output", "") == "Stack Deleted" or "does not exist" in latest_result.get("msg", "")): result["state"] = "absent" else: result["state"] = "teardown-error" return result