From 71c4355d58323297454ff3877fe6469eb36b6347 Mon Sep 17 00:00:00 2001 From: Andrew McGilvray Date: Fri, 7 Sep 2018 05:43:30 +1000 Subject: [PATCH] check for change of role arn in ecs task definition (#44942) * check role arn for ecs task definition If the task role in a ECS task definition changes ansible should create a new revsion of the task definition. --- .../modules/cloud/amazon/ecs_taskdefinition.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/ansible/modules/cloud/amazon/ecs_taskdefinition.py b/lib/ansible/modules/cloud/amazon/ecs_taskdefinition.py index e98c016742..495f06e9bc 100644 --- a/lib/ansible/modules/cloud/amazon/ecs_taskdefinition.py +++ b/lib/ansible/modules/cloud/amazon/ecs_taskdefinition.py @@ -390,10 +390,13 @@ def main(): return True - def _task_definition_matches(requested_volumes, requested_containers, existing_task_definition): + def _task_definition_matches(requested_volumes, requested_containers, requested_task_role_arn, existing_task_definition): if td['status'] != "ACTIVE": return None + if requested_task_role_arn != td.get('taskRoleArn', ""): + return None + existing_volumes = td.get('volumes', []) or [] if len(requested_volumes) != len(existing_volumes): @@ -433,9 +436,10 @@ def main(): # No revision explicitly specified. Attempt to find an active, matching revision that has all the properties requested for td in existing_definitions_in_family: - requested_volumes = module.params.get('volumes', []) or [] - requested_containers = module.params.get('containers', []) or [] - existing = _task_definition_matches(requested_volumes, requested_containers, td) + requested_volumes = module.params['volumes'] or [] + requested_containers = module.params['containers'] or [] + requested_task_role_arn = module.params['task_role_arn'] + existing = _task_definition_matches(requested_volumes, requested_containers, requested_task_role_arn, td) if existing: break