Skip to content

Commit

Permalink
ecs_* - fix idempotence bug in ecs_service and dont require ``cluster…
Browse files Browse the repository at this point in the history
…`` (ansible-collections#1212)

ecs_* - fix idempotence bug in ecs_service and dont require ``cluster``

SUMMARY

Don't require cluster param and use cluster name 'default' when not specified (see docs).
Fix bug when comparing health_check_grace_period_seconds when not input by user.


ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME

ecs_service
ecs_task

ADDITIONAL INFORMATION
Split up from ansible-collections#1209 to backport to stable-2

Reviewed-by: Markus Bergholz <git@osuv.de>
Reviewed-by: Alina Buzachis <None>
  • Loading branch information
jatorcasso committed Jun 8, 2022
1 parent 2d652cc commit bac2473
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
bugfixes:
- ecs_service - fix broken change detect of ``health_check_grace_period_seconds`` parameter when not specified (https://github.com/ansible-collections/community.aws/pull/1212).
- ecs_service - use default cluster name of ``default`` when not input (https://github.com/ansible-collections/community.aws/pull/1212).
- ecs_task - dont require ``cluster`` and use name of ``default`` when not input (https://github.com/ansible-collections/community.aws/pull/1212).
9 changes: 6 additions & 3 deletions plugins/modules/ecs_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@
cluster:
description:
- The name of the cluster in which the service exists.
- If not specified, the cluster name will be C(default).
required: false
type: str
default: 'default'
task_definition:
description:
- The task definition the service will run.
Expand Down Expand Up @@ -657,8 +659,9 @@ def is_matching_service(self, expected, existing):
if expected['task_definition'] != existing['taskDefinition'].split('/')[-1]:
return False

if expected.get('health_check_grace_period_seconds') != existing.get('healthCheckGracePeriodSeconds'):
return False
if expected.get('health_check_grace_period_seconds'):
if expected.get('health_check_grace_period_seconds') != existing.get('healthCheckGracePeriodSeconds'):
return False

if (expected['load_balancers'] or []) != existing['loadBalancers']:
return False
Expand Down Expand Up @@ -766,7 +769,7 @@ def main():
argument_spec = dict(
state=dict(required=True, choices=['present', 'absent', 'deleting']),
name=dict(required=True, type='str', aliases=['service']),
cluster=dict(required=False, type='str'),
cluster=dict(required=False, type='str', default='default'),
task_definition=dict(required=False, type='str'),
load_balancers=dict(required=False, default=[], type='list', elements='dict'),
desired_count=dict(required=False, type='int'),
Expand Down
6 changes: 4 additions & 2 deletions plugins/modules/ecs_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@
cluster:
description:
- The name of the cluster to run the task on.
required: True
- If not specified, the cluster name will be C(default).
required: False
type: str
default: 'default'
task_definition:
description:
- The task definition to start, run or stop.
Expand Down Expand Up @@ -342,7 +344,7 @@ def ecs_task_long_format_enabled(self):
def main():
argument_spec = dict(
operation=dict(required=True, choices=['run', 'start', 'stop']),
cluster=dict(required=True, type='str'), # R S P
cluster=dict(required=False, type='str', default='default'), # R S P
task_definition=dict(required=False, type='str'), # R* S*
overrides=dict(required=False, type='dict'), # R S
count=dict(required=False, type='int'), # R
Expand Down

0 comments on commit bac2473

Please sign in to comment.