Skip to content

Commit

Permalink
Support changing of launch type (ansible-collections#840)
Browse files Browse the repository at this point in the history
Support changing of launch type

SUMMARY
When changing the launch_type parameter for an ecs_taskdefition there was no change reported by the module. This adds a check to see if launch_type in the ecs_taskdefinition has changed. If there is a change detected the module reports back there is not a matching task definition and creates a new one.
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
ecs_taskdefinition

Reviewed-by: Alina Buzachis <None>
Reviewed-by: Michael Mayer <[email protected]>
Reviewed-by: Markus Bergholz <[email protected]>
  • Loading branch information
mjmayer authored Mar 18, 2022
1 parent 836e55b commit dd17472
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ecs_taskdefinition.py
Original file line number Diff line number Diff line change
Expand Up @@ -923,13 +923,16 @@ def _right_has_values_of_left(left, right):

return True

def _task_definition_matches(requested_volumes, requested_containers, requested_task_role_arn, existing_task_definition):
def _task_definition_matches(requested_volumes, requested_containers, requested_task_role_arn, requested_launch_type, existing_task_definition):
if td['status'] != "ACTIVE":
return None

if requested_task_role_arn != td.get('taskRoleArn', ""):
return None

if requested_launch_type is not None and requested_launch_type not in td.get('compatibilities', []):
return None

existing_volumes = td.get('volumes', []) or []

if len(requested_volumes) != len(existing_volumes):
Expand Down Expand Up @@ -972,7 +975,8 @@ def _task_definition_matches(requested_volumes, requested_containers, requested_
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)
requested_launch_type = module.params['launch_type']
existing = _task_definition_matches(requested_volumes, requested_containers, requested_task_role_arn, requested_launch_type, td)

if existing:
break
Expand Down

0 comments on commit dd17472

Please sign in to comment.