From b71c1b0f3d17134cb1f7a457cd1d0c868db28e87 Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Fri, 8 Jul 2022 19:12:57 +0200 Subject: [PATCH] Minor fixups - bad rebase resulted in a duplicated parameter - Fixup "changed" after adding initial support for tags --- plugins/modules/ecs_service.py | 7 ++--- requirements.txt | 4 +-- tests/integration/constraints.txt | 6 ++-- .../targets/ecs_cluster/tasks/main.yml | 29 ++++++++++++++++++- 4 files changed, 36 insertions(+), 10 deletions(-) diff --git a/plugins/modules/ecs_service.py b/plugins/modules/ecs_service.py index 3d06e79a1e7..dcf6e624124 100644 --- a/plugins/modules/ecs_service.py +++ b/plugins/modules/ecs_service.py @@ -738,7 +738,7 @@ def is_matching_service(self, expected, existing): # but the user is just entering # ansible-fargate-nginx:3 if expected['task_definition'] != existing['taskDefinition'].split('/')[-1]: - if existing['deploymentController']['type'] != 'CODE_DEPLOY': + if existing.get('deploymentController', {}).get('type', None) != 'CODE_DEPLOY': return False if expected.get('health_check_grace_period_seconds'): @@ -748,10 +748,10 @@ def is_matching_service(self, expected, existing): if (expected['load_balancers'] or []) != existing['loadBalancers']: return False - if expected['propagate_tags'] != existing['propagateTags']: + if (expected['propagate_tags'] or "NONE") != existing['propagateTags']: return False - if boto3_tag_list_to_ansible_dict(existing['tags']) != expected['tags']: + if boto3_tag_list_to_ansible_dict(existing.get('tags', [])) != (expected['tags'] or {}): return False # expected is params. DAEMON scheduling strategy returns desired count equal to @@ -1068,7 +1068,6 @@ def main(): network_configuration, serviceRegistries, module.params['launch_type'], - module.params['scheduling_strategy'], module.params['platform_version'], module.params['scheduling_strategy'], capacityProviders, diff --git a/requirements.txt b/requirements.txt index 50b872c182d..0a1981f46db 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,5 +2,5 @@ # - tests/unit/constraints.txt # - tests/integration/constraints.txt # - tests/integration/targets/setup_botocore_pip -botocore>=1.20.0 -boto3>=1.17.0 +botocore>=1.21.0 +boto3>=1.18.0 diff --git a/tests/integration/constraints.txt b/tests/integration/constraints.txt index f6d06c4243b..cd546e7c2a7 100644 --- a/tests/integration/constraints.txt +++ b/tests/integration/constraints.txt @@ -1,7 +1,7 @@ # Specifically run tests against the oldest versions that we support -boto3==1.17.0 -botocore==1.20.0 +boto3==1.18.0 +botocore==1.21.0 # AWS CLI has `botocore==` dependencies, provide the one that matches botocore # to avoid needing to download over a years worth of awscli wheels. -awscli==1.19.0 +awscli==1.20.0 diff --git a/tests/integration/targets/ecs_cluster/tasks/main.yml b/tests/integration/targets/ecs_cluster/tasks/main.yml index 6a6ca91d00f..6393d59661f 100644 --- a/tests/integration/targets/ecs_cluster/tasks/main.yml +++ b/tests/integration/targets/ecs_cluster/tasks/main.yml @@ -234,7 +234,7 @@ assert: that: - "ecs_service.service.placementConstraints[0].type == 'distinctInstance'" - + - name: check that ECS service was created with deployment_circuit_breaker assert: that: @@ -264,6 +264,32 @@ assert: that: - not ecs_service_again.changed + ignore_errors: True + + - name: Enable ExecuteCommand + ecs_service: + state: present + name: "{{ ecs_service_name }}" + cluster: "{{ ecs_cluster_name }}" + task_definition: "{{ ecs_task_name }}:{{ ecs_task_definition.taskdefinition.revision }}" + desired_count: 1 + deployment_configuration: "{{ ecs_service_deployment_configuration }}" + placement_strategy: "{{ ecs_service_placement_strategy }}" + placement_constraints: + - type: distinctInstance + health_check_grace_period_seconds: "{{ ecs_service_health_check_grace_period }}" + load_balancers: + - targetGroupArn: "{{ elb_target_group_instance.target_group_arn }}" + containerName: "{{ ecs_task_name }}" + containerPort: "{{ ecs_task_container_port }}" + role: "ecsServiceRole" + enable_execute_command: True + register: ecs_service_again + + - name: check that ECS service recreation changed nothing + assert: + that: + - ecs_service_again.changed - name: create same ECS service definition via force_new_deployment ecs_service: @@ -329,6 +355,7 @@ containerName: "{{ ecs_task_name }}" containerPort: "{{ ecs_task_container_port }}" role: "ecsServiceRole" + wait: true register: ecs_service_scale_down - name: assert that ECS service is scaled down