Skip to content

Commit

Permalink
rds_instance - fix idempotency when using non-lowercase for preferred…
Browse files Browse the repository at this point in the history
…_maintenance_window (ansible-collections#516)

* rds_instance - preferred_maintenance_window - force day of week into lowercase
* add integration test
* changelog
  • Loading branch information
tremble authored Apr 9, 2021
1 parent d616900 commit 8fbfead
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
2 changes: 2 additions & 0 deletions changelogs/516-rds_instance-preferred_maintenance_window.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- rds_instance - convert ``preferred_maintenance_window`` days into lowercase so changed returns properly (https://github.com/ansible-collections/community.aws/pull/516).
4 changes: 4 additions & 0 deletions plugins/modules/rds_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -1214,6 +1214,10 @@ def main():
if module.params['processor_features'] is not None:
module.params['processor_features'] = dict((k, to_text(v)) for k, v in module.params['processor_features'].items())

# Ensure dates are in lowercase
if module.params['preferred_maintenance_window']:
module.params['preferred_maintenance_window'] = module.params['preferred_maintenance_window'].lower()

client = module.client('rds')
changed = False
state = module.params['state']
Expand Down
28 changes: 28 additions & 0 deletions tests/integration/targets/rds_instance/tasks/test_modification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,34 @@
- '"db_instance_class" in result.pending_modified_values or result.db_instance_class == "db.t2.medium"'
- '"engine_version" in result.pending_modified_values or result.engine_version == "10.2.21"'

- name: Idempotence modifying several pending attributes - preferred_maintenance_window not lowercase
rds_instance:
id: '{{ instance_id }}'
state: present
allocated_storage: 30
db_instance_class: "{{ modified_db_instance_class }}"
backup_retention_period: 2
preferred_backup_window: "05:00-06:00"
preferred_maintenance_window: "Mon:06:20-Mon:06:50"
engine_version: "10.2.21"
allow_major_version_upgrade: true
auto_minor_version_upgrade: false
port: 1150
max_allocated_storage: 100
register: result
retries: 30
delay: 10
until: result is not failed

- assert:
that:
- not result.changed
- '"allocated_storage" in result.pending_modified_values or result.allocated_storage == 30'
- '"max_allocated_storage" in result.pending_modified_values or result.max_allocated_storage == 100'
- '"port" in result.pending_modified_values or result.endpoint.port == 1150'
- '"db_instance_class" in result.pending_modified_values or result.db_instance_class == "db.t2.medium"'
- '"engine_version" in result.pending_modified_values or result.engine_version == "10.2.21"'

- name: Delete the instance
rds_instance:
id: '{{ instance_id }}'
Expand Down

0 comments on commit 8fbfead

Please sign in to comment.