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
…`` (#1212) (#1230)

[PR #1212/bac24736 backport][stable-2] ecs_* - fix idempotence bug in ecs_service and dont require ``cluster``

This is a backport of PR #1212 as merged into main (bac2473).
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 #1209 to backport to stable-2

Reviewed-by: Mark Chappell <None>
  • Loading branch information
patchback[bot] authored Jun 15, 2022
1 parent 753f339 commit c43fb28
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 @@ -595,8 +597,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 @@ -701,7 +704,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 @@ -27,8 +27,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 @@ -340,7 +342,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 c43fb28

Please sign in to comment.