From f9c003485505e7d246296900a290ebe63ae7aeaf Mon Sep 17 00:00:00 2001 From: Markus Bergholz Date: Wed, 5 Apr 2023 07:35:47 +0200 Subject: [PATCH 1/9] fix --- plugins/modules/elb_target_group.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/modules/elb_target_group.py b/plugins/modules/elb_target_group.py index 784fa143a4f..561e2cc7b2d 100644 --- a/plugins/modules/elb_target_group.py +++ b/plugins/modules/elb_target_group.py @@ -731,7 +731,10 @@ def create_or_update_target_group(connection, module): instances_to_add = [] for target in params['Targets']: if target['Id'] in add_instances: - instances_to_add.append({'Id': target['Id'], 'Port': target['Port']}) + tmp_item = {'Id': target['Id'], 'Port': target['Port']} + if target.get('AvailabilityZone'): + tmp_item['AvailabilityZone'] = target['AvailabilityZone'] + instances_to_add.append(tmp_item) changed = True try: From 3f9ff3681fa9b5075e65898806c9688e4598f64a Mon Sep 17 00:00:00 2001 From: Markus Bergholz Date: Wed, 5 Apr 2023 07:49:27 +0200 Subject: [PATCH 2/9] darker --- plugins/modules/elb_target_group.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/modules/elb_target_group.py b/plugins/modules/elb_target_group.py index 561e2cc7b2d..16cafc958e3 100644 --- a/plugins/modules/elb_target_group.py +++ b/plugins/modules/elb_target_group.py @@ -729,11 +729,11 @@ def create_or_update_target_group(connection, module): if add_instances: instances_to_add = [] - for target in params['Targets']: - if target['Id'] in add_instances: - tmp_item = {'Id': target['Id'], 'Port': target['Port']} - if target.get('AvailabilityZone'): - tmp_item['AvailabilityZone'] = target['AvailabilityZone'] + for target in params["Targets"]: + if target["Id"] in add_instances: + tmp_item = {"Id": target["Id"], "Port": target["Port"]} + if target.get("AvailabilityZone"): + tmp_item["AvailabilityZone"] = target["AvailabilityZone"] instances_to_add.append(tmp_item) changed = True From 23697f511b3e61d2bf2955214ec343e505b98327 Mon Sep 17 00:00:00 2001 From: Markus Bergholz Date: Wed, 5 Apr 2023 07:49:31 +0200 Subject: [PATCH 3/9] add --- changelogs/fragments/1736-elb_target_group_property.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 changelogs/fragments/1736-elb_target_group_property.yml diff --git a/changelogs/fragments/1736-elb_target_group_property.yml b/changelogs/fragments/1736-elb_target_group_property.yml new file mode 100644 index 00000000000..6c467db387c --- /dev/null +++ b/changelogs/fragments/1736-elb_target_group_property.yml @@ -0,0 +1,2 @@ +bugfixes: + - elb_target_group - Property ``AvailabilityZone`` is kept when requested (https://github.com/ansible-collections/community.aws/pull/1767). From 297f7d289113b8fb0529630346699a7fb91620ae Mon Sep 17 00:00:00 2001 From: Markus Bergholz Date: Thu, 13 Apr 2023 21:06:37 +0200 Subject: [PATCH 4/9] fix --- .../targets/elb_target/tasks/ec2_target.yml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/tests/integration/targets/elb_target/tasks/ec2_target.yml b/tests/integration/targets/elb_target/tasks/ec2_target.yml index 4a99c41a8b0..bb471dd9f3d 100644 --- a/tests/integration/targets/elb_target/tasks/ec2_target.yml +++ b/tests/integration/targets/elb_target/tasks/ec2_target.yml @@ -168,14 +168,8 @@ tags: Name: "{{ resource_prefix }}-inst" user_data: | - #cloud-config - package_upgrade: true - package_update: true - packages: - - httpd - runcmd: - - "service httpd start" - - echo "HELLO ANSIBLE" > /var/www/html/index.html + #!/bin/bash + sudo nohup python3 -m http.server 80 & register: ec2 - set_fact: From b4c983ca429ef98e36a6abef2442865b13be0c2b Mon Sep 17 00:00:00 2001 From: Markus Bergholz Date: Mon, 17 Apr 2023 19:47:34 +0200 Subject: [PATCH 5/9] test --- .../targets/elb_target/tasks/ec2_target.yml | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/tests/integration/targets/elb_target/tasks/ec2_target.yml b/tests/integration/targets/elb_target/tasks/ec2_target.yml index bb471dd9f3d..3b47cf62f5a 100644 --- a/tests/integration/targets/elb_target/tasks/ec2_target.yml +++ b/tests/integration/targets/elb_target/tasks/ec2_target.yml @@ -474,6 +474,46 @@ - not result.changed - not result.target_health_descriptions + - name: create ip target group + elb_target_group: + name: "{{ tg_name }}-ip" + health_check_port: 443 + protocol: tcp + port: 443 + vpc_id: "{{ vpc.vpc.id }}" + state: present + target_type: ip + register: result + + - name: ip target group must be created + assert: + that: + - result.changed + - result.target_type == 'ip' + + - name: "mobify ip target group with AvailabilityZone: all" + elb_target_group: + name: "{{ tg_name }}-ip" + health_check_port: 443 + protocol: tcp + port: 443 + vpc_id: "{{ vpc.vpc.id }}" + state: present + target_type: ip + wait: false + modify_targets: true + targets: + - Id: 192.168.178.32 # must be a member of test vpc subnet 20.0.0.0/18 + Port: 443 + AvailabilityZone: all + register: result + + - name: ip target group must be modified + assert: + that: + - result.changed + - result.load_balancing_cross_zone_enabled == 'use_load_balancer_configuration' + # ============================================================ always: @@ -527,6 +567,7 @@ - "{{ tg_used_name }}" - "{{ tg_tcpudp_name }}" - "{{ tg_name }}-nlb" + - "{{ tg_name }}-ip" ignore_errors: true - name: remove routing rules From 29771952e1a39369e5e0af00dc5d05536e180d5c Mon Sep 17 00:00:00 2001 From: Markus Bergholz Date: Mon, 17 Apr 2023 19:48:30 +0200 Subject: [PATCH 6/9] rm --- tests/integration/targets/elb_target/tasks/ec2_target.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/targets/elb_target/tasks/ec2_target.yml b/tests/integration/targets/elb_target/tasks/ec2_target.yml index 3b47cf62f5a..611aca26f13 100644 --- a/tests/integration/targets/elb_target/tasks/ec2_target.yml +++ b/tests/integration/targets/elb_target/tasks/ec2_target.yml @@ -503,7 +503,7 @@ wait: false modify_targets: true targets: - - Id: 192.168.178.32 # must be a member of test vpc subnet 20.0.0.0/18 + - Id: 192.168.178.32 Port: 443 AvailabilityZone: all register: result From fa50f513b6dcbd45eb2e2f3a3437908ceb61b8ac Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Tue, 18 Apr 2023 09:49:00 +0200 Subject: [PATCH 7/9] Update changelogs/fragments/1736-elb_target_group_property.yml --- changelogs/fragments/1736-elb_target_group_property.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/fragments/1736-elb_target_group_property.yml b/changelogs/fragments/1736-elb_target_group_property.yml index 6c467db387c..7a760816add 100644 --- a/changelogs/fragments/1736-elb_target_group_property.yml +++ b/changelogs/fragments/1736-elb_target_group_property.yml @@ -1,2 +1,2 @@ bugfixes: - - elb_target_group - Property ``AvailabilityZone`` is kept when requested (https://github.com/ansible-collections/community.aws/pull/1767). + - elb_target_group - ensure ``AvailabilityZone`` is kept in target definitions when ``Id`` and ``Port`` are passed (https://github.com/ansible-collections/community.aws/issues/1736). From bce34b426f357405cb17d3fc10873b869010baf2 Mon Sep 17 00:00:00 2001 From: Markus Bergholz Date: Tue, 18 Apr 2023 10:02:15 +0200 Subject: [PATCH 8/9] Update changelogs/fragments/1736-elb_target_group_property.yml --- changelogs/fragments/1736-elb_target_group_property.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/fragments/1736-elb_target_group_property.yml b/changelogs/fragments/1736-elb_target_group_property.yml index 7a760816add..be3f32f2f9c 100644 --- a/changelogs/fragments/1736-elb_target_group_property.yml +++ b/changelogs/fragments/1736-elb_target_group_property.yml @@ -1,2 +1,2 @@ bugfixes: - - elb_target_group - ensure ``AvailabilityZone`` is kept in target definitions when ``Id`` and ``Port`` are passed (https://github.com/ansible-collections/community.aws/issues/1736). + - elb_target_group - ensure ``AvailabilityZone`` is kept in target definitions when ``Id`` and ``Port`` are passed (https://github.com/ansible-collections/community.aws/pull/1767). From 1f4a866cf82b15afa9f548592591b05741587cf4 Mon Sep 17 00:00:00 2001 From: Markus Bergholz Date: Tue, 18 Apr 2023 10:08:14 +0200 Subject: [PATCH 9/9] Update changelogs/fragments/1736-elb_target_group_property.yml --- changelogs/fragments/1736-elb_target_group_property.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/fragments/1736-elb_target_group_property.yml b/changelogs/fragments/1736-elb_target_group_property.yml index be3f32f2f9c..7a760816add 100644 --- a/changelogs/fragments/1736-elb_target_group_property.yml +++ b/changelogs/fragments/1736-elb_target_group_property.yml @@ -1,2 +1,2 @@ bugfixes: - - elb_target_group - ensure ``AvailabilityZone`` is kept in target definitions when ``Id`` and ``Port`` are passed (https://github.com/ansible-collections/community.aws/pull/1767). + - elb_target_group - ensure ``AvailabilityZone`` is kept in target definitions when ``Id`` and ``Port`` are passed (https://github.com/ansible-collections/community.aws/issues/1736).