From 70e20bb57193c29dd119ad863804338f8ca641a7 Mon Sep 17 00:00:00 2001 From: Sloane Hertel Date: Wed, 30 Aug 2017 15:27:48 -0400 Subject: [PATCH] [cloud] cloudformation: create changeset when stack is in ROLLBACK_COMPLETE. Fixes #27853 (#28832) Fix appearance of failure when creating a cloudformation changeset after a rollback. When creating a cloudformation changeset it shouldn't matter if the last event was. _ROLLBACK_COMPLETE since creating a changeset is not an event. Fixes #27853. --- lib/ansible/modules/cloud/amazon/cloudformation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/cloud/amazon/cloudformation.py b/lib/ansible/modules/cloud/amazon/cloudformation.py index 156207acadb..b8d7daceec1 100644 --- a/lib/ansible/modules/cloud/amazon/cloudformation.py +++ b/lib/ansible/modules/cloud/amazon/cloudformation.py @@ -314,7 +314,7 @@ def create_changeset(module, stack_params, cfn): result = dict(changed=False, output='ChangeSet %s already exists.' % changeset_name, warnings=[warning]) else: cs = cfn.create_change_set(**stack_params) - result = stack_operation(cfn, stack_params['StackName'], 'UPDATE') + result = stack_operation(cfn, stack_params['StackName'], 'CREATE_CHANGESET') result['warnings'] = ['Created changeset named %s for stack %s' % (changeset_name, stack_params['StackName']), 'You can execute it using: aws cloudformation execute-change-set --change-set-name %s' % cs['Id'], 'NOTE that dependencies on this stack might fail due to pending changes!'] @@ -378,7 +378,7 @@ def stack_operation(cfn, stack_name, operation): return ret # it covers ROLLBACK_COMPLETE and UPDATE_ROLLBACK_COMPLETE # Possible states: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-describing-stacks.html#w1ab2c15c17c21c13 - elif stack['StackStatus'].endswith('ROLLBACK_COMPLETE'): + elif stack['StackStatus'].endswith('ROLLBACK_COMPLETE') and operation != 'CREATE_CHANGESET': ret.update({'changed': True, 'failed': True, 'output': 'Problem with %s. Rollback complete' % operation}) return ret # note the ordering of ROLLBACK_COMPLETE and COMPLETE, because otherwise COMPLETE will match both cases.