forked from ansible-collections/community.aws
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
route53_health_check: Fix "Name" tag key removal idempotentcy issue (a…
…nsible-collections#1253) route53_health_check: Fix "Name" tag key removal idempotentcy issue SUMMARY Depends-On: ansible-collections#1280 Fixes ansible-collections#1188 When using health_check_name as unique identifier (setting use_unique_names: True and providing a health_check_name) and health_check tags are set, Current logic for adding name to a health_check causes an issue when rerunning the create/update task. While ideally it should be idempotent, it removes the 'Name' tag (used for health_check_name) causing removal of health check name. ISSUE TYPE Bugfix Pull Request COMPONENT NAME route53_health_check ADDITIONAL INFORMATION To test, run the following sample playbook task twice Expected output: Health check name should not disapper (i.e. 'Name' tag should not get removed on rerun) --- - hosts: localhost gather_facts: False tasks: - name: Create a health-check amazon.aws.route53_health_check: health_check_name: my-test-hc use_unique_names: true fqdn: my-test-xyz.com type: HTTPS resource_path: / request_interval: 30 failure_threshold: 3 tags: Service: my-service Owner: my-test-xyz Lifecycle: dev Reviewed-by: Mark Chappell <None> Reviewed-by: GomathiselviS <None> Reviewed-by: Mandar Kulkarni <mandar242@gmail.com> Reviewed-by: Mike Graves <mgraves@redhat.com> Reviewed-by: Gonéri Le Bouder <goneri@lebouder.net> Reviewed-by: Alina Buzachis <None>
- Loading branch information
Showing
5 changed files
with
285 additions
and
8 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
...elogs/fragments/1253-route53_health_check-fix-name-tag-key-removal-idempotentcy-issue.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
bugfixes: | ||
- route53_health_check - Fix "Name" tag key removal idempotentcy issue when creating health_check with `use_unique_names` and `tags` set (https://github.com/ansible-collections/amazon.aws/pull/1253). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
271 changes: 271 additions & 0 deletions
271
tests/integration/targets/route53_health_check/tasks/named_health_check_tag_operations.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,271 @@ | ||
--- | ||
- block: | ||
# Create Health Check ================================================================= | ||
- name: 'Create Health Check with name and tags' | ||
amazon.aws.route53_health_check: | ||
state: present | ||
name: '{{ tiny_prefix }}-{{ resource_path }}-test-hc-tag-operations' | ||
ip_address: '{{ ip_address }}' | ||
port: '{{ port }}' | ||
type: '{{ type_http }}' | ||
resource_path: '{{ resource_path }}' | ||
use_unique_names: true | ||
fqdn: '{{ fqdn }}' | ||
tags: | ||
Service: my-service | ||
Owner: my-test-xyz | ||
Lifecycle: dev | ||
register: create_result | ||
|
||
- name: Get Health Check tags | ||
amazon.aws.route53_info: | ||
query: health_check | ||
resource_id: "{{ create_result.health_check.id }}" | ||
health_check_method: tags | ||
register: health_check_tags | ||
- set_fact: | ||
tags_keys_list: "{{ health_check_tags.ResourceTagSets[0].Tags | map(attribute='Key') | list }}" | ||
|
||
- name: 'Check result - Create HTTP health check' | ||
assert: | ||
that: | ||
- create_result is not failed | ||
- create_result is changed | ||
- tags_keys_list | length == 4 | ||
- '"Service" in tags_keys_list' | ||
- '"Owner" in tags_keys_list' | ||
- '"Lifecycle" in tags_keys_list' | ||
- '"Name" in tags_keys_list' | ||
|
||
# Create Health Check - check Idempotenty ================================================================= | ||
- name: 'Create Health Check with name and tags - idempotency' | ||
amazon.aws.route53_health_check: | ||
state: present | ||
name: '{{ tiny_prefix }}-{{ resource_path }}-test-hc-tag-operations' | ||
ip_address: '{{ ip_address }}' | ||
port: '{{ port }}' | ||
type: '{{ type_http }}' | ||
resource_path: '{{ resource_path }}' | ||
use_unique_names: true | ||
tags: | ||
Service: my-service | ||
Owner: my-test-xyz | ||
Lifecycle: dev | ||
fqdn: '{{ fqdn }}' | ||
register: create_idem | ||
|
||
- name: Get Health Check tags | ||
amazon.aws.route53_info: | ||
query: health_check | ||
resource_id: "{{ create_idem.health_check.id }}" | ||
health_check_method: tags | ||
register: health_check_tags | ||
- set_fact: | ||
tags_keys_list: "{{ health_check_tags.ResourceTagSets[0].Tags | map(attribute='Key') | list }}" | ||
|
||
- name: 'Check result - Create HTTP health check - idempotency' | ||
assert: | ||
that: | ||
- create_idem is not failed | ||
- create_idem is not changed | ||
- tags_keys_list | length == 4 | ||
- '"Service" in tags_keys_list' | ||
- '"Owner" in tags_keys_list' | ||
- '"Lifecycle" in tags_keys_list' | ||
- '"Name" in tags_keys_list' | ||
|
||
# Create Health Check - Update Tags ================================================================= | ||
- name: 'Create Health Check with name and tags' | ||
amazon.aws.route53_health_check: | ||
state: present | ||
name: '{{ tiny_prefix }}-{{ resource_path }}-test-hc-tag-operations' | ||
ip_address: '{{ ip_address }}' | ||
port: '{{ port }}' | ||
type: '{{ type_http }}' | ||
resource_path: '{{ resource_path }}' | ||
use_unique_names: true | ||
tags: | ||
Service: my-service | ||
NewOwner: my-test-abcd | ||
fqdn: '{{ fqdn }}' | ||
register: create_hc_update_tags | ||
|
||
- name: Get Health Check tags | ||
amazon.aws.route53_info: | ||
query: health_check | ||
resource_id: "{{ create_hc_update_tags.health_check.id }}" | ||
health_check_method: tags | ||
register: health_check_tags | ||
- set_fact: | ||
tags_keys_list: "{{ health_check_tags.ResourceTagSets[0].Tags | map(attribute='Key') | list }}" | ||
|
||
- name: 'Check result - Create HTTP health check' | ||
assert: | ||
that: | ||
- create_hc_update_tags is not failed | ||
- create_hc_update_tags is changed | ||
- tags_keys_list | length == 3 | ||
- '"Service" in tags_keys_list' | ||
- '"NewOwner" in tags_keys_list' | ||
- '"Owner" not in tags_keys_list' | ||
- '"Lifecycle" not in tags_keys_list' | ||
- '"Name" in tags_keys_list' | ||
|
||
# Create Health Check - Update Tags - Idempotency ================================================================= | ||
- name: 'Create Health Check with name and tags - Idempotency' | ||
amazon.aws.route53_health_check: | ||
state: present | ||
name: '{{ tiny_prefix }}-{{ resource_path }}-test-hc-tag-operations' | ||
ip_address: '{{ ip_address }}' | ||
port: '{{ port }}' | ||
type: '{{ type_http }}' | ||
resource_path: '{{ resource_path }}' | ||
use_unique_names: true | ||
tags: | ||
Service: my-service | ||
NewOwner: my-test-abcd | ||
fqdn: '{{ fqdn }}' | ||
register: create_hc_update_tags_idem | ||
|
||
- name: Get Health Check tags | ||
amazon.aws.route53_info: | ||
query: health_check | ||
resource_id: "{{ create_hc_update_tags_idem.health_check.id }}" | ||
health_check_method: tags | ||
register: health_check_tags | ||
- set_fact: | ||
tags_keys_list: "{{ health_check_tags.ResourceTagSets[0].Tags | map(attribute='Key') | list }}" | ||
|
||
- name: 'Check result - Create HTTP health check' | ||
assert: | ||
that: | ||
- create_hc_update_tags_idem is not failed | ||
- create_hc_update_tags_idem is not changed | ||
- tags_keys_list | length == 3 | ||
- '"Service" in tags_keys_list' | ||
- '"NewOwner" in tags_keys_list' | ||
- '"Owner" not in tags_keys_list' | ||
- '"Lifecycle" not in tags_keys_list' | ||
- '"Name" in tags_keys_list' | ||
|
||
# Create Health Check - test purge_tags behavior ================================================================= | ||
|
||
- name: 'Create Health Check with name with tags={} and purge_tags=false (should not remove existing tags)' | ||
amazon.aws.route53_health_check: | ||
state: present | ||
name: '{{ tiny_prefix }}-{{ resource_path }}-test-hc-tag-operations' | ||
ip_address: '{{ ip_address }}' | ||
port: '{{ port }}' | ||
type: '{{ type_http }}' | ||
resource_path: '{{ resource_path }}' | ||
use_unique_names: true | ||
fqdn: '{{ fqdn }}' | ||
tags: {} | ||
purge_tags: false | ||
register: create_hc_update_tags | ||
|
||
- name: Get Health Check tags | ||
amazon.aws.route53_info: | ||
query: health_check | ||
resource_id: "{{ create_hc_update_tags.health_check.id }}" | ||
health_check_method: tags | ||
register: health_check_tags | ||
- set_fact: | ||
tags_keys_list: "{{ health_check_tags.ResourceTagSets[0].Tags | map(attribute='Key') | list }}" | ||
|
||
- name: 'Check result - Create HTTP health check' | ||
assert: | ||
that: | ||
- create_hc_update_tags is not failed | ||
- create_hc_update_tags is not changed | ||
- tags_keys_list | length == 3 | ||
- '"Service" in tags_keys_list' | ||
- '"NewOwner" in tags_keys_list' | ||
- '"Name" in tags_keys_list' | ||
|
||
- name: 'Create Health Check with name with tags=None with purge_tags=true (should not remove existing tags)' | ||
amazon.aws.route53_health_check: | ||
state: present | ||
name: '{{ tiny_prefix }}-{{ resource_path }}-test-hc-tag-operations' | ||
ip_address: '{{ ip_address }}' | ||
port: '{{ port }}' | ||
type: '{{ type_http }}' | ||
resource_path: '{{ resource_path }}' | ||
use_unique_names: true | ||
fqdn: '{{ fqdn }}' | ||
purge_tags: true | ||
register: create_hc_update_tags | ||
|
||
- name: Get Health Check tags | ||
amazon.aws.route53_info: | ||
query: health_check | ||
resource_id: "{{ create_hc_update_tags.health_check.id }}" | ||
health_check_method: tags | ||
register: health_check_tags | ||
- set_fact: | ||
tags_keys_list: "{{ health_check_tags.ResourceTagSets[0].Tags | map(attribute='Key') | list }}" | ||
|
||
- name: 'Check result - Create HTTP health check' | ||
assert: | ||
that: | ||
- create_hc_update_tags is not failed | ||
- create_hc_update_tags is not changed | ||
- tags_keys_list | length == 3 | ||
- '"Service" in tags_keys_list' | ||
- '"NewOwner" in tags_keys_list' | ||
- '"Name" in tags_keys_list' | ||
|
||
- name: 'Create Health Check with name with tags={} with purge_tags=true (should remove existing tags except Name)' | ||
amazon.aws.route53_health_check: | ||
state: present | ||
name: '{{ tiny_prefix }}-{{ resource_path }}-test-hc-tag-operations' | ||
ip_address: '{{ ip_address }}' | ||
port: '{{ port }}' | ||
type: '{{ type_http }}' | ||
resource_path: '{{ resource_path }}' | ||
use_unique_names: true | ||
fqdn: '{{ fqdn }}' | ||
tags: {} | ||
purge_tags: true | ||
register: create_hc_update_tags | ||
|
||
- name: Get Health Check tags | ||
amazon.aws.route53_info: | ||
query: health_check | ||
resource_id: "{{ create_hc_update_tags.health_check.id }}" | ||
health_check_method: tags | ||
register: health_check_tags | ||
- set_fact: | ||
tags_keys_list: "{{ health_check_tags.ResourceTagSets[0].Tags | map(attribute='Key') | list }}" | ||
|
||
- name: 'Check result - Create HTTP health check' | ||
assert: | ||
that: | ||
- create_hc_update_tags is not failed | ||
- create_hc_update_tags is changed | ||
- tags_keys_list | length == 1 | ||
- '"Service" not in tags_keys_list' | ||
- '"NewOwner" not in tags_keys_list' | ||
- '"Name" in tags_keys_list' | ||
|
||
# Cleanup starts here ================================================================= | ||
always: | ||
- name: 'Delete HTTP health check with use_unique_names' | ||
amazon.aws.route53_health_check: | ||
state: absent | ||
name: '{{ tiny_prefix }}-{{ resource_path }}-test-hc-tag-operations' | ||
ip_address: '{{ ip_address }}' | ||
port: '{{ port }}' | ||
type: '{{ type_http }}' | ||
resource_path: '{{ resource_path }}' | ||
use_unique_names: true | ||
fqdn: '{{ fqdn }}' | ||
tags: {} | ||
register: delete_result | ||
with_items: | ||
- '{{ resource_path }}' | ||
|
||
- assert: | ||
that: | ||
- delete_result is changed | ||
- delete_result is not failed |