From c43fb285e2cd6285ca8aac5f38234af8d7f0a532 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Wed, 15 Jun 2022 07:44:17 +0000 Subject: [PATCH] ecs_* - fix idempotence bug in ecs_service and dont require ``cluster`` (#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 --- .../1212-ecs_service-fix-broken-change-detect.yml | 4 ++++ plugins/modules/ecs_service.py | 9 ++++++--- plugins/modules/ecs_task.py | 6 ++++-- 3 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 changelogs/fragments/1212-ecs_service-fix-broken-change-detect.yml diff --git a/changelogs/fragments/1212-ecs_service-fix-broken-change-detect.yml b/changelogs/fragments/1212-ecs_service-fix-broken-change-detect.yml new file mode 100644 index 00000000000..78618b78466 --- /dev/null +++ b/changelogs/fragments/1212-ecs_service-fix-broken-change-detect.yml @@ -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). diff --git a/plugins/modules/ecs_service.py b/plugins/modules/ecs_service.py index ea90e9bb1ae..0dc2911d918 100644 --- a/plugins/modules/ecs_service.py +++ b/plugins/modules/ecs_service.py @@ -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. @@ -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 @@ -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'), diff --git a/plugins/modules/ecs_task.py b/plugins/modules/ecs_task.py index b2ca36e21de..277bbe4770d 100644 --- a/plugins/modules/ecs_task.py +++ b/plugins/modules/ecs_task.py @@ -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. @@ -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