-
Notifications
You must be signed in to change notification settings - Fork 341
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rds_instance: fix 'typeError'when tagging gp3 db (#1437)
rds_instance: fix 'typeError'when tagging gp3 db SUMMARY This PR fixes bug causing error when managing tags on a gp3 rds database instance, caused by a conditional statement comparing allocated_storage even when it is not provided. currently code returns TypeError: '>=' not supported between instances of 'NoneType' and 'int'. ISSUE TYPE Bugfix Pull Request COMPONENT NAME rds_instance ADDITIONAL INFORMATION Reviewed-by: Mark Chappell (cherry picked from commit f63d191)
- Loading branch information
1 parent
e19570c
commit 5c9b44b
Showing
5 changed files
with
213 additions
and
12 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
changelogs/fragments/1437-rds_instance-gp3-tagging-bugfix.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,2 @@ | ||
bugfixes: | ||
- rds_instance - Fixed ``TypeError`` when tagging RDS DB with storage type ``gp3`` (https://github.com/ansible-collections/amazon.aws/pull/1437). |
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
1 change: 1 addition & 0 deletions
1
tests/integration/targets/rds_instance_tagging/defaults/main.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
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
190 changes: 190 additions & 0 deletions
190
tests/integration/targets/rds_instance_tagging/tasks/test_tagging_gp3.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,190 @@ | ||
- block: | ||
- name: Ensure the resource doesn't exist | ||
rds_instance: | ||
id: '{{ instance_id_gp3 }}' | ||
state: absent | ||
skip_final_snapshot: true | ||
register: result | ||
|
||
- assert: | ||
that: | ||
- not result.changed | ||
ignore_errors: yes | ||
|
||
# Test invalid bad options | ||
- name: Create a DB instance with an invalid engine | ||
rds_instance: | ||
id: '{{ instance_id_gp3 }}' | ||
state: present | ||
engine: thisisnotavalidengine | ||
username: '{{ username }}' | ||
password: '{{ password }}' | ||
db_instance_class: '{{ db_instance_class }}' | ||
allocated_storage: '{{ allocated_storage }}' | ||
register: result | ||
ignore_errors: true | ||
|
||
- assert: | ||
that: | ||
- result.failed | ||
- '"value of engine must be one of" in result.msg' | ||
|
||
# Test creation, adding tags and enabling encryption | ||
- name: Create a mariadb instance | ||
rds_instance: | ||
id: '{{ instance_id_gp3 }}' | ||
state: present | ||
engine: mariadb | ||
username: '{{ username }}' | ||
password: '{{ password }}' | ||
db_instance_class: '{{ db_instance_class }}' | ||
allocated_storage: '{{ allocated_storage }}' | ||
storage_encrypted: true | ||
tags: | ||
Name: '{{ instance_id_gp3 }}' | ||
Created_by: Ansible rds_instance tests | ||
register: result | ||
|
||
- assert: | ||
that: | ||
- result.changed | ||
- result.db_instance_identifier == '{{ instance_id_gp3 }}' | ||
- result.tags | length == 2 | ||
- result.tags.Name == '{{ instance_id_gp3 }}' | ||
- result.tags.Created_by == 'Ansible rds_instance tests' | ||
- result.kms_key_id | ||
- result.storage_encrypted == true | ||
|
||
- name: Test idempotency omitting tags - check_mode | ||
rds_instance: | ||
id: '{{ instance_id_gp3 }}' | ||
state: present | ||
engine: mariadb | ||
username: '{{ username }}' | ||
password: '{{ password }}' | ||
db_instance_class: '{{ db_instance_class }}' | ||
allocated_storage: '{{ allocated_storage }}' | ||
register: result | ||
check_mode: yes | ||
|
||
- assert: | ||
that: | ||
- not result.changed | ||
|
||
- name: Test idempotency omitting tags | ||
rds_instance: | ||
id: '{{ instance_id_gp3 }}' | ||
state: present | ||
engine: mariadb | ||
username: '{{ username }}' | ||
password: '{{ password }}' | ||
db_instance_class: '{{ db_instance_class }}' | ||
allocated_storage: '{{ allocated_storage }}' | ||
register: result | ||
|
||
- assert: | ||
that: | ||
- not result.changed | ||
- result.db_instance_identifier == '{{ instance_id_gp3 }}' | ||
- result.tags | length == 2 | ||
|
||
- name: Idempotence with minimal options | ||
rds_instance: | ||
id: '{{ instance_id_gp3 }}' | ||
state: present | ||
register: result | ||
|
||
- assert: | ||
that: | ||
- not result.changed | ||
- result.db_instance_identifier == '{{ instance_id_gp3 }}' | ||
- result.tags | length == 2 | ||
|
||
- name: Test tags are not purged if purge_tags is False | ||
rds_instance: | ||
db_instance_identifier: '{{ instance_id_gp3 }}' | ||
state: present | ||
engine: mariadb | ||
username: '{{ username }}' | ||
password: '{{ password }}' | ||
db_instance_class: '{{ db_instance_class }}' | ||
allocated_storage: '{{ allocated_storage }}' | ||
tags: {} | ||
purge_tags: false | ||
register: result | ||
|
||
- assert: | ||
that: | ||
- not result.changed | ||
- result.tags | length == 2 | ||
|
||
- name: Add a tag and remove a tag - check_mode | ||
rds_instance: | ||
db_instance_identifier: '{{ instance_id_gp3 }}' | ||
state: present | ||
tags: | ||
Name: '{{ instance_id_gp3 }}-new' | ||
Created_by: Ansible rds_instance tests | ||
purge_tags: true | ||
register: result | ||
check_mode: yes | ||
|
||
- assert: | ||
that: | ||
- result.changed | ||
|
||
- name: Add a tag and remove a tag | ||
rds_instance: | ||
db_instance_identifier: '{{ instance_id_gp3 }}' | ||
state: present | ||
tags: | ||
Name: '{{ instance_id_gp3 }}-new' | ||
Created_by: Ansible rds_instance tests | ||
purge_tags: true | ||
register: result | ||
|
||
- assert: | ||
that: | ||
- result.changed | ||
- result.tags | length == 2 | ||
- result.tags.Name == '{{ instance_id_gp3 }}-new' | ||
|
||
- name: Add a tag and remove a tag (idempotence) - check_mode | ||
rds_instance: | ||
db_instance_identifier: '{{ instance_id_gp3 }}' | ||
state: present | ||
tags: | ||
Name: '{{ instance_id_gp3 }}-new' | ||
Created_by: Ansible rds_instance tests | ||
purge_tags: true | ||
register: result | ||
check_mode: yes | ||
|
||
- assert: | ||
that: | ||
- not result.changed | ||
|
||
- name: Add a tag and remove a tag (idempotence) | ||
rds_instance: | ||
db_instance_identifier: '{{ instance_id_gp3 }}' | ||
state: present | ||
tags: | ||
Name: '{{ instance_id_gp3 }}-new' | ||
Created_by: Ansible rds_instance tests | ||
purge_tags: true | ||
register: result | ||
|
||
- assert: | ||
that: | ||
- not result.changed | ||
- result.tags | length == 2 | ||
- result.tags.Name == '{{ instance_id_gp3 }}-new' | ||
|
||
always: | ||
- name: Remove DB instance | ||
rds_instance: | ||
id: '{{ instance_id_gp3 }}' | ||
state: absent | ||
skip_final_snapshot: true | ||
wait: false | ||
ignore_errors: yes |