From 64281395938400baef627f8e1c2e739c453976e6 Mon Sep 17 00:00:00 2001 From: Mark Woolley Date: Fri, 22 Oct 2021 15:10:11 +0100 Subject: [PATCH] Rds enhanced monitoring bug fix (#747) Rds enhanced monitoring bug fix SUMMARY (a copy of #712 as I messed up my branch by accident) This is a fix for an issue when an RDS instance already exists and you wish to enable enhanced monitoring, for the full details see the linked old reported issue: ansible/ansible#51772 But in summary currently if you enable enhanced monitoring on an RDS instance that already exists where it isn't already enabled then the following is returned: An exception occurred during task execution. To see the full traceback, use -vvv. The error was: KeyError: 'MonitoringRoleArn' fatal: [localhost_eu-west-1-pdv-qa-1 -> 127.0.0.1]: FAILED! => changed=false module_stderr: |- Traceback (most recent call last): File "master:/opt/mitogen/mitogen-0.2.9/ansible_mitogen/runner.py", line 975, in _run self._run_code(code, mod) File "master:/opt/mitogen/mitogen-0.2.9/ansible_mitogen/runner.py", line 939, in _run_code exec(code, vars(mod)) File "master:/tmp/build/4bef5c86/framework/library/cloud/aws/rds_instance.py", line 1245, in File "master:/tmp/build/4bef5c86/framework/library/cloud/aws/rds_instance.py", line 1210, in main File "master:/tmp/build/4bef5c86/framework/library/cloud/aws/rds_instance.py", line 855, in get_parameters File "master:/tmp/build/4bef5c86/framework/library/cloud/aws/rds_instance.py", line 885, in get_options_with_changing_values File "master:/tmp/build/4bef5c86/framework/library/cloud/aws/rds_instance.py", line 983, in get_changing_options_with_consistent_keys KeyError: 'MonitoringRoleArn' module_stdout: '' msg: |- MODULE FAILURE See stdout/stderr for the exact error Originally-Depends-On: mattclay/aws-terminator#164 Other changes A load of issues have surfaced in the integration tests due to how slow RDS is to create / modify etc. I've condensed down the tests where possible reducing the number of inventory jobs to 6 and bumped serial to 6 so that hopefully all tests can run at once and finish within the 1 hr AWS session duration. ISSUE TYPE Bugfix Pull Request COMPONENT NAME rds_instance Reviewed-by: Mark Chappell Reviewed-by: Mark Woolley Reviewed-by: None This commit was initially merged in https://github.com/ansible-collections/community.aws See: https://github.com/ansible-collections/community.aws/commit/8fe00cb6972d3e9f5c40a49bf1253029667fea80 --- plugins/modules/rds_instance.py | 5 +- .../integration/targets/rds_instance/aliases | 4 +- .../targets/rds_instance/inventory | 9 +- .../integration/targets/rds_instance/main.yml | 2 +- .../roles/rds_instance/defaults/main.yml | 9 +- .../enhanced_monitoring_assume_policy.json | 13 + .../roles/rds_instance/tasks/test_aurora.yml | 2 + .../rds_instance/tasks/test_bad_options.yml | 31 -- .../rds_instance/tasks/test_encryption.yml | 42 -- .../tasks/test_final_snapshot.yml | 61 --- .../rds_instance/tasks/test_modification.yml | 205 --------- .../roles/rds_instance/tasks/test_modify.yml | 77 ++++ .../tasks/test_modify_complex.yml | 113 +++++ .../tasks/test_processor_features.yml | 31 +- .../rds_instance/tasks/test_read_replica.yml | 2 + .../tasks/test_restore_instance.yml | 20 +- .../rds_instance/tasks/test_snapshot.yml | 83 ---- .../roles/rds_instance/tasks/test_states.yml | 403 +++++++----------- .../roles/rds_instance/tasks/test_tagging.yml | 129 ++++++ .../roles/rds_instance/tasks/test_tags.yml | 241 ----------- .../tasks/test_vpc_security_groups.yml | 8 - 21 files changed, 518 insertions(+), 972 deletions(-) create mode 100644 tests/integration/targets/rds_instance/roles/rds_instance/files/enhanced_monitoring_assume_policy.json delete mode 100644 tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_bad_options.yml delete mode 100644 tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_encryption.yml delete mode 100644 tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_final_snapshot.yml delete mode 100644 tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_modification.yml create mode 100644 tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_modify.yml create mode 100644 tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_modify_complex.yml delete mode 100644 tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_snapshot.yml create mode 100644 tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_tagging.yml delete mode 100644 tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_tags.yml diff --git a/plugins/modules/rds_instance.py b/plugins/modules/rds_instance.py index c1f118db514..92d5e257cf0 100644 --- a/plugins/modules/rds_instance.py +++ b/plugins/modules/rds_instance.py @@ -989,13 +989,12 @@ def get_changing_options_with_inconsistent_keys(modify_params, instance, purge_c def get_changing_options_with_consistent_keys(modify_params, instance): - inconsistent_parameters = list(modify_params.keys()) changing_params = {} for param in modify_params: - current_option = instance.get('PendingModifiedValues', {}).get(param) + current_option = instance.get('PendingModifiedValues', {}).get(param, None) if current_option is None: - current_option = instance[param] + current_option = instance.get(param, None) if modify_params[param] != current_option: changing_params[param] = modify_params[param] diff --git a/tests/integration/targets/rds_instance/aliases b/tests/integration/targets/rds_instance/aliases index 283523234b9..e30a1801b1e 100644 --- a/tests/integration/targets/rds_instance/aliases +++ b/tests/integration/targets/rds_instance/aliases @@ -1,5 +1,3 @@ -# reason: missing-policy -# reason: slow -unsupported +slow cloud/aws diff --git a/tests/integration/targets/rds_instance/inventory b/tests/integration/targets/rds_instance/inventory index e19e0c76b3a..9daf5db1e07 100644 --- a/tests/integration/targets/rds_instance/inventory +++ b/tests/integration/targets/rds_instance/inventory @@ -1,15 +1,12 @@ [tests] states -tags -modification -bad_options +modify +modify_complex processor_features -encryption -final_snapshot read_replica vpc_security_groups restore_instance -snapshot +tagging # TODO: uncomment after adding rds_cluster module # aurora diff --git a/tests/integration/targets/rds_instance/main.yml b/tests/integration/targets/rds_instance/main.yml index fc2c909ec11..1b33dab5076 100644 --- a/tests/integration/targets/rds_instance/main.yml +++ b/tests/integration/targets/rds_instance/main.yml @@ -6,6 +6,6 @@ - hosts: all gather_facts: no strategy: free - serial: 5 + serial: 8 roles: - rds_instance diff --git a/tests/integration/targets/rds_instance/roles/rds_instance/defaults/main.yml b/tests/integration/targets/rds_instance/roles/rds_instance/defaults/main.yml index 33760c64660..e32df5478cd 100644 --- a/tests/integration/targets/rds_instance/roles/rds_instance/defaults/main.yml +++ b/tests/integration/targets/rds_instance/roles/rds_instance/defaults/main.yml @@ -8,6 +8,8 @@ storage_encrypted_db_instance_class: db.t3.small modified_db_instance_class: db.t3.medium allocated_storage: 20 modified_allocated_storage: 30 +monitoring_interval: 60 +preferred_maintenance_window: "mon:06:20-mon:06:50" # For aurora tests cluster_id: "{{ resource_prefix }}-cluster" @@ -16,13 +18,10 @@ aurora_db_instance_class: db.t3.medium # For oracle tests # Smallest instance that permits modification of the coreCount oracle_ee_db_instance_class: db.r5.2xlarge -processor_features: - coreCount: 2 - threadsPerCore: 1 modified_processor_features: coreCount: 4 threadsPerCore: 2 # For mariadb tests -mariadb_engine_version: 10.3.20 -mariadb_engine_version_2: 10.4.8 +mariadb_engine_version: 10.3.31 +mariadb_engine_version_2: 10.4.21 diff --git a/tests/integration/targets/rds_instance/roles/rds_instance/files/enhanced_monitoring_assume_policy.json b/tests/integration/targets/rds_instance/roles/rds_instance/files/enhanced_monitoring_assume_policy.json new file mode 100644 index 00000000000..29acf369fc9 --- /dev/null +++ b/tests/integration/targets/rds_instance/roles/rds_instance/files/enhanced_monitoring_assume_policy.json @@ -0,0 +1,13 @@ +{ + "Version": "2012-10-17", + "Statement": [ + { + "Sid": "", + "Effect": "Allow", + "Principal": { + "Service": "monitoring.rds.amazonaws.com" + }, + "Action": "sts:AssumeRole" + } + ] +} diff --git a/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_aurora.yml b/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_aurora.yml index c3a880d6bb1..031d0b8464e 100644 --- a/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_aurora.yml +++ b/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_aurora.yml @@ -113,6 +113,7 @@ id: "{{ item }}" state: absent skip_final_snapshot: True + wait: false loop: - "{{ instance_id }}" - "{{ modified_instance_id }}" @@ -123,4 +124,5 @@ cluster_id: "{{ cluster_id }}" state: absent skip_final_snapshot: True + wait: false ignore_errors: yes diff --git a/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_bad_options.yml b/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_bad_options.yml deleted file mode 100644 index 9fd2f4fa6e4..00000000000 --- a/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_bad_options.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- - - block: - - - name: Ensure the resource doesn't exist - rds_instance: - id: "{{ instance_id }}" - state: absent - skip_final_snapshot: True - register: result - - - assert: - that: - - not result.changed - ignore_errors: yes - - - name: Create a DB instance with an invalid engine - rds_instance: - id: "{{ instance_id }}" - 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 - - '"DB engine thisisnotavalidengine should be one of" in result.msg' diff --git a/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_encryption.yml b/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_encryption.yml deleted file mode 100644 index 6c3e81494e5..00000000000 --- a/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_encryption.yml +++ /dev/null @@ -1,42 +0,0 @@ ---- - - block: - - - name: Ensure the resource doesn't exist - rds_instance: - id: "{{ instance_id }}" - state: absent - skip_final_snapshot: True - register: result - - - assert: - that: - - not result.changed - ignore_errors: yes - - - name: Create a mariadb instance - rds_instance: - id: "{{ instance_id }}" - state: present - engine: mariadb - username: "{{ username }}" - password: "{{ password }}" - db_instance_class: "{{ storage_encrypted_db_instance_class }}" - allocated_storage: "{{ allocated_storage }}" - storage_encrypted: True - register: result - - - assert: - that: - - result.changed - - "result.db_instance_identifier == '{{ instance_id }}'" - - result.kms_key_id - - result.storage_encrypted == true - - always: - - - name: Delete DB instance - rds_instance: - id: "{{ instance_id }}" - state: absent - skip_final_snapshot: True - register: result diff --git a/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_final_snapshot.yml b/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_final_snapshot.yml deleted file mode 100644 index 922a008c353..00000000000 --- a/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_final_snapshot.yml +++ /dev/null @@ -1,61 +0,0 @@ ---- - - block: - - - name: Ensure the resource doesn't exist - rds_instance: - id: "{{ instance_id }}" - state: absent - skip_final_snapshot: True - register: result - - - assert: - that: - - not result.changed - ignore_errors: yes - - - name: Create a mariadb instance - rds_instance: - id: "{{ instance_id }}" - state: present - engine: mariadb - username: "{{ username }}" - password: "{{ password }}" - db_instance_class: "{{ db_instance_class }}" - allocated_storage: "{{ allocated_storage }}" - register: result - - - name: Delete the DB instance - rds_instance: - id: "{{ instance_id }}" - state: absent - final_snapshot_identifier: "{{ instance_id }}" - register: result - - - assert: - that: - - result.changed - - "result.final_snapshot.db_instance_identifier == '{{ instance_id }}'" - - - name: Check that snapshot exists - rds_snapshot_info: - db_snapshot_identifier: "{{ instance_id }}" - register: result - - - assert: - that: - - "result.snapshots | length == 1" - - "result.snapshots.0.engine == 'mariadb'" - - always: - - name: Remove the snapshot - rds_snapshot: - db_snapshot_identifier: "{{ instance_id }}" - state: absent - ignore_errors: yes - - - name: Remove the DB instance - rds_instance: - id: "{{ instance_id }}" - state: absent - skip_final_snapshot: True - ignore_errors: yes diff --git a/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_modification.yml b/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_modification.yml deleted file mode 100644 index 03e49967cae..00000000000 --- a/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_modification.yml +++ /dev/null @@ -1,205 +0,0 @@ ---- - #TODO: test availability_zone and multi_az - - block: - - - name: Ensure the resource doesn't exist - rds_instance: - id: "{{ instance_id }}" - state: absent - skip_final_snapshot: True - register: result - - - assert: - that: - - not result.changed - ignore_errors: yes - - - name: Create a mariadb instance - rds_instance: - id: "{{ instance_id }}" - state: present - engine: mariadb - engine_version: "{{ mariadb_engine_version }}" - username: "{{ username }}" - password: "{{ password }}" - db_instance_class: "{{ db_instance_class }}" - allocated_storage: "{{ allocated_storage }}" - register: result - - - assert: - that: - - result.changed - - "result.db_instance_identifier == '{{ instance_id }}'" - - - name: Modify the instance name without immediate application - rds_instance: - id: "{{ instance_id }}" - state: present - new_id: "{{ modified_instance_id }}" - apply_immediately: False - register: result - - - assert: - that: - - result.changed - - 'result.db_instance_identifier == "{{ instance_id }}"' - - - name: Immediately apply the pending update - rds_instance: - id: "{{ instance_id }}" - state: present - new_id: "{{ modified_instance_id }}" - apply_immediately: True - register: result - - - assert: - that: - - result.changed - - 'result.db_instance_identifier == "{{ modified_instance_id }}"' - - - name: Modify the instance immediately - rds_instance: - id: '{{ modified_instance_id }}' - state: present - new_id: '{{ instance_id }}' - apply_immediately: True - register: result - - - assert: - that: - - result.changed - - 'result.db_instance_identifier == "{{ instance_id }}"' - - - name: Check mode - modify the password - rds_instance: - id: '{{ instance_id }}' - state: present - password: '{{ password }}' - force_update_password: True - apply_immediately: True - register: result - check_mode: True - - - assert: - that: - - result.changed - - - name: Modify the password - rds_instance: - id: '{{ instance_id }}' - state: present - password: '{{ password }}' - force_update_password: True - apply_immediately: True - register: result - - - assert: - that: - - result.changed - - # TODO: test modifying db_subnet_group_name, db_security_groups, db_parameter_group_name, option_group_name, - # monitoring_role_arn, monitoring_interval, domain, domain_iam_role_name, cloudwatch_logs_export_configuration - - - name: Modify several attributes - 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: "{{ mariadb_engine_version_2 }}" - allow_major_version_upgrade: true - auto_minor_version_upgrade: false - port: 1150 - max_allocated_storage: 100 - apply_immediately: True - register: result - - - assert: - that: - - 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 == modified_db_instance_class' - - '"engine_version" in result.pending_modified_values or result.engine_version == mariadb_engine_version_2' - - - name: Idempotence modifying several pending attributes - 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: "{{ mariadb_engine_version_2 }}" - 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 == modified_db_instance_class' - - '"engine_version" in result.pending_modified_values or result.engine_version == mariadb_engine_version_2' - - - 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 }}' - state: absent - skip_final_snapshot: True - register: result - - - assert: - that: - - result.changed - - '"pending_modified_values" not in result' - - always: - - - name: Delete the instance - rds_instance: - id: '{{ item }}' - state: absent - skip_final_snapshot: True - loop: ['{{ instance_id }}', '{{ modified_instance_id }}'] - ignore_errors: yes diff --git a/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_modify.yml b/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_modify.yml new file mode 100644 index 00000000000..bfe04be2fbe --- /dev/null +++ b/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_modify.yml @@ -0,0 +1,77 @@ +--- +#TODO: test availability_zone and multi_az +- block: + - name: Ensure the resource doesn't exist + rds_instance: + id: "{{ instance_id }}" + state: absent + skip_final_snapshot: True + register: result + + - assert: + that: + - not result.changed + ignore_errors: yes + + - name: Create an enhanced monitoring role + iam_role: + assume_role_policy_document: "{{ lookup('file','files/enhanced_monitoring_assume_policy.json') }}" + name: "{{ instance_id }}-role" + state: present + managed_policy: "arn:aws:iam::aws:policy/service-role/AmazonRDSEnhancedMonitoringRole" + register: enhanced_monitoring_role + + - name: Create a mariadb instance + rds_instance: + id: "{{ instance_id }}" + state: present + engine: mariadb + engine_version: "{{ mariadb_engine_version }}" + allow_major_version_upgrade: true + username: "{{ username }}" + password: "{{ password }}" + db_instance_class: "{{ db_instance_class }}" + allocated_storage: "{{ allocated_storage }}" + register: result + + - assert: + that: + - result.changed + - "result.db_instance_identifier == '{{ instance_id }}'" + + - name: Modify the instance name without immediate application + rds_instance: + id: "{{ instance_id }}" + state: present + new_id: "{{ modified_instance_id }}" + password: "{{ password }}" + apply_immediately: False + register: result + + - assert: + that: + - result.changed + - 'result.db_instance_identifier == "{{ instance_id }}"' + + - name: Immediately apply the pending update + rds_instance: + id: "{{ instance_id }}" + state: present + new_id: "{{ modified_instance_id }}" + apply_immediately: True + register: result + + - assert: + that: + - result.changed + - 'result.db_instance_identifier == "{{ modified_instance_id }}"' + + always: + - name: Delete the instance + rds_instance: + id: "{{ item }}" + state: absent + skip_final_snapshot: True + wait: false + loop: ["{{ instance_id }}", "{{ modified_instance_id }}"] + ignore_errors: yes diff --git a/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_modify_complex.yml b/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_modify_complex.yml new file mode 100644 index 00000000000..066d35c11d9 --- /dev/null +++ b/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_modify_complex.yml @@ -0,0 +1,113 @@ +--- +#TODO: test availability_zone and multi_az +- block: + - name: Ensure the resource doesn't exist + rds_instance: + id: "{{ instance_id }}" + state: absent + skip_final_snapshot: True + register: result + + - assert: + that: + - not result.changed + ignore_errors: yes + + - name: Create an enhanced monitoring role + iam_role: + assume_role_policy_document: "{{ lookup('file','files/enhanced_monitoring_assume_policy.json') }}" + name: "{{ instance_id }}-role" + state: present + managed_policy: "arn:aws:iam::aws:policy/service-role/AmazonRDSEnhancedMonitoringRole" + register: enhanced_monitoring_role + + - name: Create a mariadb instance + rds_instance: + id: "{{ instance_id }}" + state: present + engine: mariadb + engine_version: "{{ mariadb_engine_version }}" + allow_major_version_upgrade: true + username: "{{ username }}" + password: "{{ password }}" + db_instance_class: "{{ db_instance_class }}" + allocated_storage: "{{ allocated_storage }}" + register: result + + - assert: + that: + - result.changed + - "result.db_instance_identifier == '{{ instance_id }}'" + + # TODO: test modifying db_subnet_group_name, db_security_groups, db_parameter_group_name, option_group_name, + # monitoring_role_arn, monitoring_interval, domain, domain_iam_role_name, cloudwatch_logs_export_configuration + + # Test multiple modifications including enabling enhanced monitoring + + - name: Modify several attributes + 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: "{{ preferred_maintenance_window }}" + engine_version: "{{ mariadb_engine_version_2 }}" + allow_major_version_upgrade: true + auto_minor_version_upgrade: false + monitoring_interval: "{{ monitoring_interval }}" + monitoring_role_arn: "{{ enhanced_monitoring_role.arn }}" + port: 1150 + max_allocated_storage: 100 + apply_immediately: True + register: result + + - assert: + that: + - 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 == modified_db_instance_class' + - '"engine_version" in result.pending_modified_values or result.engine_version == mariadb_engine_version_2' + - '"monitoring_interval" in result.pending_modified_values or result.monitoring_interval == monitoring_interval' + + - name: Idempotence modifying several pending attributes + 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: "{{ preferred_maintenance_window }}" + engine_version: "{{ mariadb_engine_version_2 }}" + allow_major_version_upgrade: true + auto_minor_version_upgrade: false + monitoring_interval: "{{ monitoring_interval }}" + monitoring_role_arn: "{{ enhanced_monitoring_role.arn }}" + 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 == modified_db_instance_class' + - '"engine_version" in result.pending_modified_values or result.engine_version == mariadb_engine_version_2' + + always: + - name: Delete the instance + rds_instance: + id: "{{ instance_id }}" + state: absent + skip_final_snapshot: True + wait: false + ignore_errors: yes diff --git a/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_processor_features.yml b/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_processor_features.yml index 78dd44be4f0..c0ba221cf34 100644 --- a/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_processor_features.yml +++ b/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_processor_features.yml @@ -23,14 +23,12 @@ db_instance_class: "{{ oracle_ee_db_instance_class }}" allocated_storage: "{{ allocated_storage }}" storage_encrypted: True - processor_features: "{{ processor_features }}" + processor_features: {} register: result - assert: that: - result.changed - - 'result.processor_features.coreCount == "{{ processor_features.coreCount }}"' - - 'result.processor_features.threadsPerCore == "{{ processor_features.threadsPerCore }}"' - name: Check mode - modify the processor features rds_instance: @@ -71,32 +69,6 @@ - 'result.pending_modified_values.processor_features.coreCount == "{{ modified_processor_features.coreCount }}"' - 'result.pending_modified_values.processor_features.threadsPerCore == "{{ modified_processor_features.threadsPerCore }}"' - - name: Check mode - use the default processor features - rds_instance: - id: "{{ instance_id }}" - state: present - processor_features: {} - apply_immediately: True - register: result - - - assert: - that: - - result.changed - - - name: Use the default processor features - rds_instance: - id: "{{ instance_id }}" - state: present - processor_features: {} - apply_immediately: True - register: result - - - assert: - that: - - result.changed - - 'result.pending_modified_values.processor_features.coreCount == "DEFAULT"' - - 'result.pending_modified_values.processor_features.threadsPerCore == "DEFAULT"' - always: - name: Delete the DB instance @@ -104,6 +76,7 @@ id: "{{ instance_id }}" state: absent skip_final_snapshot: True + wait: false register: result - assert: diff --git a/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_read_replica.yml b/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_read_replica.yml index 4aee2687d31..7ca19747dde 100644 --- a/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_read_replica.yml +++ b/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_read_replica.yml @@ -137,6 +137,7 @@ state: absent skip_final_snapshot: True region: "{{ region_src }}" + wait: false ignore_errors: yes - name: Remove the DB replica @@ -145,4 +146,5 @@ state: absent skip_final_snapshot: True region: "{{ region_dest }}" + wait: false ignore_errors: yes diff --git a/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_restore_instance.yml b/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_restore_instance.yml index 64a948211c3..3390f5759e7 100644 --- a/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_restore_instance.yml +++ b/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_restore_instance.yml @@ -16,7 +16,7 @@ - name: Create a source DB instance rds_instance: - id: "{{ instance_id }}" + id: "{{ instance_id }}-s" state: present engine: mysql backup_retention_period: 1 @@ -29,13 +29,13 @@ - assert: that: - source_db.changed - - "source_db.db_instance_identifier == '{{ instance_id }}'" + - "source_db.db_instance_identifier == '{{ instance_id }}-s'" - name: Create a point in time DB instance rds_instance: - id: "{{ instance_id }}-point-in-time" + id: "{{ instance_id }}" state: present - source_db_instance_identifier: "{{ instance_id }}" + source_db_instance_identifier: "{{ instance_id }}-s" creation_source: instance engine: mysql username: "{{ username }}" @@ -47,9 +47,9 @@ - name: Test idempotence with a point in time replica rds_instance: - id: "{{ instance_id }}-point-in-time" + id: "{{ instance_id }}" state: present - source_db_instance_identifier: "{{ instance_id }}" + source_db_instance_identifier: "{{ instance_id }}-s" creation_source: instance engine: mysql username: "{{ username }}" @@ -62,20 +62,22 @@ - assert: that: - not result.changed + - "result.db_instance_identifier == '{{ instance_id }}'" always: - name: Remove the DB instance rds_instance: - id: "{{ instance_id }}" + id: "{{ instance_id }}-s" state: absent skip_final_snapshot: True + wait: false ignore_errors: yes - - name: Remove the point in time restored DB rds_instance: - id: "{{ instance_id }}-point-in-time" + id: "{{ instance_id }}" state: absent skip_final_snapshot: True + wait: false ignore_errors: yes diff --git a/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_snapshot.yml b/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_snapshot.yml deleted file mode 100644 index 131f9753e88..00000000000 --- a/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_snapshot.yml +++ /dev/null @@ -1,83 +0,0 @@ ---- - - block: - - - name: Getting shared snapshots - rds_snapshot_info: - snapshot_type: "shared" - register: result - - - assert: - that: - - not result.changed - - result.cluster_snapshots is defined - - result.snapshots is defined - - - name: Ensure the resource doesn't exist - rds_instance: - db_instance_identifier: "{{ instance_id }}" - state: absent - skip_final_snapshot: True - register: result - - - assert: - that: - - not result.changed - ignore_errors: yes - - - name: Create a mariadb instance - rds_instance: - db_instance_identifier: "{{ instance_id }}" - state: present - engine: mariadb - username: "{{ username }}" - password: "{{ password }}" - db_instance_class: "{{ db_instance_class }}" - allocated_storage: "{{ allocated_storage }}" - tags: - Name: "{{ instance_id }}" - Created_by: Ansible rds_instance tests - register: result - - - assert: - that: - - result.changed - - "result.db_instance_identifier == '{{ instance_id }}'" - - "result.tags | length == 2" - - "result.tags.Name == '{{ instance_id }}'" - - "result.tags.Created_by == 'Ansible rds_instance tests'" - - - name: Getting public snapshots - rds_snapshot_info: - db_instance_identifier: "{{ instance_id }}" - snapshot_type: "public" - register: result - - - assert: - that: - - not result.changed - - result.cluster_snapshots is not defined - - result.snapshots is defined - - - name: Ensure the resource doesn't exist - rds_instance: - db_instance_identifier: "{{ instance_id }}" - state: absent - skip_final_snapshot: True - register: result - - - assert: - that: - - result.changed - - # TODO ideally we test with an actual shared snapshot - but we'd need a second account - making tests fairly complicated? - - always: - - - name: Delete the instance - rds_instance: - id: "{{ item }}" - state: absent - skip_final_snapshot: True - loop: - - "{{ instance_id }}" - ignore_errors: yes diff --git a/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_states.yml b/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_states.yml index 7b16f81a183..0321dc99d7c 100644 --- a/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_states.yml +++ b/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_states.yml @@ -1,246 +1,159 @@ --- - - block: - - - name: Ensure the resource doesn't exist - rds_instance: - id: "{{ instance_id }}" - state: absent - skip_final_snapshot: True - register: result - - - assert: - that: - - not result.changed - ignore_errors: yes - - - name: Check Mode - Create a mariadb instance - rds_instance: - id: "{{ instance_id }}" - 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: - - result.changed - - - name: Create a mariadb instance - rds_instance: - id: "{{ instance_id }}" - state: present - engine: mariadb - username: "{{ username }}" - password: "{{ password }}" - db_instance_class: "{{ db_instance_class }}" - allocated_storage: "{{ allocated_storage }}" - register: result - - - assert: - that: - - result.changed - - "result.db_instance_identifier == '{{ instance_id }}'" - - - name: Idempotence - rds_instance: - id: '{{ instance_id }}' - 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 - - - name: Idempotence with minimal options - rds_instance: - id: '{{ instance_id }}' - state: present - register: result - - - assert: - that: - - not result.changed - - result.db_instance_identifier - - - name: Check Mode - stop the instance - rds_instance: - id: '{{ instance_id }}' - state: stopped - register: result - check_mode: yes - - - assert: - that: - - result.changed - - - name: Stop the instance - rds_instance: - id: '{{ instance_id }}' - state: stopped - register: result - - - assert: - that: - - result.changed - - - name: Check Mode - idempotence - rds_instance: - id: '{{ instance_id }}' - state: stopped - register: result - check_mode: yes - - - assert: - that: - - not result.changed - - - name: Idempotence - rds_instance: - id: '{{ instance_id }}' - state: stopped - register: result - - - assert: - that: - - not result.changed - - - name: Check mode - reboot a stopped instance - rds_instance: - id: '{{ instance_id }}' - state: rebooted - register: result - check_mode: yes - - - assert: - that: - - result.changed - - - name: Reboot a stopped instance - rds_instance: - id: '{{ instance_id }}' - state: rebooted - register: result - - - assert: - that: - - result.changed - - - name: Check Mode - start the instance - rds_instance: - id: '{{ instance_id }}' - state: started - register: result - check_mode: yes - - - assert: - that: - - not result.changed - - - name: Stop the instance - rds_instance: - id: '{{ instance_id }}' - state: stopped - - - name: Start the instance - rds_instance: - id: '{{ instance_id }}' - state: started - register: result - - - assert: - that: - - result.changed - - - name: take a snapshot - rds_snapshot: - db_instance_identifier: '{{ instance_id }}' - db_snapshot_identifier: '{{ resource_prefix }}-test-snapshot' - state: present - wait: yes - - - name: take a snapshot - idempotence - rds_snapshot: - db_instance_identifier: '{{ instance_id }}' - db_snapshot_identifier: '{{ resource_prefix }}-test-snapshot' - state: present - register: result - - - assert: - that: - - not result.changed - - - name: check snapshot is ok - rds_snapshot_info: - db_snapshot_identifier: '{{ resource_prefix }}-test-snapshot' - register: result - - - assert: - that: - - (result.snapshots | length) == 1 - - - name: remove a snapshot without wait - rds_snapshot: - db_snapshot_identifier: '{{ resource_prefix }}-test-snapshot' - state: absent - register: result - - - assert: - that: - - result.changed - - - name: remove a snapshot without wait - idempotence - rds_snapshot: - db_snapshot_identifier: '{{ resource_prefix }}-test-snapshot' - state: absent - wait: yes - register: result - - - assert: - that: - - not result.changed - - - name: remove a snapshot with wait - idempotence - rds_snapshot: - db_snapshot_identifier: '{{ resource_prefix }}-test-snapshot' - state: absent - wait: yes - register: result - - - assert: - that: - - not result.changed - - - name: check snapshot is removed - rds_snapshot_info: - db_snapshot_identifier: '{{ resource_prefix }}-test-snapshot' - register: result - - - assert: - that: - - not result.snapshots - - always: - - - name: remove snapshot - rds_snapshot: - db_snapshot_identifier: '{{ resource_prefix }}-test-snapshot' - state: absent - wait: yes - ignore_errors: yes - - - name: Remove DB instance - rds_instance: - id: '{{ instance_id }}' - state: absent - skip_final_snapshot: True - ignore_errors: yes +- block: + - name: Ensure the resource doesn't exist + rds_instance: + id: "{{ instance_id }}" + state: absent + skip_final_snapshot: True + register: result + + - assert: + that: + - not result.changed + ignore_errors: yes + + - name: Create a mariadb instance + rds_instance: + id: "{{ instance_id }}" + state: present + engine: mariadb + username: "{{ username }}" + password: "{{ password }}" + db_instance_class: "{{ db_instance_class }}" + allocated_storage: "{{ allocated_storage }}" + tags: + Name: "{{ instance_id }}" + Created_by: Ansible rds_instance tests + register: result + + - assert: + that: + - result.changed + - "result.db_instance_identifier == '{{ instance_id }}'" + - "result.tags | length == 2" + - "result.tags.Name == '{{ instance_id }}'" + - "result.tags.Created_by == 'Ansible rds_instance tests'" + + # Test stopping / rebooting instances + - name: Check mode - reboot a stopped instance + rds_instance: + id: "{{ instance_id }}" + state: rebooted + register: result + check_mode: yes + + - assert: + that: + - result.changed + + - name: Reboot a stopped instance + rds_instance: + id: "{{ instance_id }}" + state: rebooted + register: result + + - assert: + that: + - result.changed + + - name: Check Mode - stop the instance + rds_instance: + id: "{{ instance_id }}" + state: stopped + register: result + check_mode: yes + + - assert: + that: + - result.changed + + - name: Stop the instance + rds_instance: + id: "{{ instance_id }}" + state: stopped + register: result + + - assert: + that: + - result.changed + + - name: Check Mode - idempotence + rds_instance: + id: "{{ instance_id }}" + state: stopped + register: result + check_mode: yes + + - assert: + that: + - not result.changed + + - name: Idempotence + rds_instance: + id: "{{ instance_id }}" + state: stopped + register: result + + - assert: + that: + - not result.changed + + - name: Check Mode - start the instance + rds_instance: + id: "{{ instance_id }}" + state: started + register: result + check_mode: yes + + - assert: + that: + - result.changed + + - name: Start the instance + rds_instance: + id: "{{ instance_id }}" + state: started + register: result + + - assert: + that: + - result.changed + + # Test final snapshot on deletion + - name: Delete the DB instance + rds_instance: + id: "{{ instance_id }}" + state: absent + final_snapshot_identifier: "{{ instance_id }}" + register: result + + - assert: + that: + - result.changed + - "result.final_snapshot.db_instance_identifier == '{{ instance_id }}'" + + - name: Check that snapshot exists + rds_snapshot_info: + db_snapshot_identifier: "{{ instance_id }}" + register: result + + - assert: + that: + - "result.snapshots | length == 1" + - "result.snapshots.0.engine == 'mariadb'" + + always: + - name: remove snapshot + rds_snapshot: + db_snapshot_identifier: "{{ resource_prefix }}-test-snapshot" + state: absent + wait: false + ignore_errors: yes + + - name: Remove DB instance + rds_instance: + id: "{{ instance_id }}" + state: absent + skip_final_snapshot: True + wait: false + ignore_errors: yes diff --git a/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_tagging.yml b/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_tagging.yml new file mode 100644 index 00000000000..0cdd9c1b7a5 --- /dev/null +++ b/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_tagging.yml @@ -0,0 +1,129 @@ +--- +- block: + - name: Ensure the resource doesn't exist + rds_instance: + id: "{{ instance_id }}" + 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 }}" + 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 + - '"DB engine thisisnotavalidengine should be one of" in result.msg' + + # Test creation, adding tags and enabling encryption + - name: Create a mariadb instance + rds_instance: + id: "{{ instance_id }}" + 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 }}" + Created_by: Ansible rds_instance tests + register: result + + - assert: + that: + - result.changed + - "result.db_instance_identifier == '{{ instance_id }}'" + - "result.tags | length == 2" + - "result.tags.Name == '{{ instance_id }}'" + - "result.tags.Created_by == 'Ansible rds_instance tests'" + - result.kms_key_id + - result.storage_encrypted == true + + - name: Test impotency omitting tags + rds_instance: + id: "{{ instance_id }}" + 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 + - "result.tags | length == 2" + + - name: Idempotence with minimal options + rds_instance: + id: "{{ instance_id }}" + state: present + register: result + + - assert: + that: + - not result.changed + - result.db_instance_identifier + - "result.tags | length == 2" + + - name: Test tags are not purged if purge_tags is False + rds_instance: + db_instance_identifier: "{{ instance_id }}" + 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 + rds_instance: + db_instance_identifier: "{{ instance_id }}" + state: present + tags: + Name: "{{ instance_id }}-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 }}-new'" + + always: + - name: Remove DB instance + rds_instance: + id: "{{ instance_id }}" + state: absent + skip_final_snapshot: True + wait: false + ignore_errors: yes diff --git a/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_tags.yml b/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_tags.yml deleted file mode 100644 index 353daec1f31..00000000000 --- a/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_tags.yml +++ /dev/null @@ -1,241 +0,0 @@ ---- - - block: - - - name: Ensure the resource doesn't exist - rds_instance: - db_instance_identifier: "{{ instance_id }}" - state: absent - skip_final_snapshot: True - register: result - - - assert: - that: - - not result.changed - ignore_errors: yes - - - name: Create a mariadb instance - rds_instance: - db_instance_identifier: "{{ instance_id }}" - state: present - engine: mariadb - username: "{{ username }}" - password: "{{ password }}" - db_instance_class: "{{ db_instance_class }}" - allocated_storage: "{{ allocated_storage }}" - tags: - Name: "{{ instance_id }}" - Created_by: Ansible rds_instance tests - register: result - - - assert: - that: - - result.changed - - "result.db_instance_identifier == '{{ instance_id }}'" - - "result.tags | length == 2" - - "result.tags.Name == '{{ instance_id }}'" - - "result.tags.Created_by == 'Ansible rds_instance tests'" - - - name: Test idempotence omitting tags - rds_instance: - db_instance_identifier: "{{ instance_id }}" - 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.tags | length == 2" - - - name: Test tags are not purged if purge_tags is False - rds_instance: - db_instance_identifier: "{{ instance_id }}" - 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 - rds_instance: - db_instance_identifier: "{{ instance_id }}" - state: present - tags: - Name: "{{ instance_id }}-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 }}-new'" - - - name: Remove all tags - rds_instance: - db_instance_identifier: "{{ instance_id }}" - state: present - engine: mariadb - username: "{{ username }}" - password: "{{ password }}" - db_instance_class: "{{ db_instance_class }}" - allocated_storage: "{{ allocated_storage }}" - tags: {} - register: result - - - assert: - that: - - result.changed - - not result.tags - - - name: snapshot instance without tags - rds_snapshot: - db_instance_identifier: "{{ instance_id }}" - db_snapshot_identifier: "{{ resource_prefix }}-test-tags" - state: present - wait: yes - register: result - - - assert: - that: - - result.changed - - not result.tags - - - name: add tags to snapshot - rds_snapshot: - db_instance_identifier: "{{ instance_id }}" - db_snapshot_identifier: "{{ resource_prefix }}-test-tags" - state: present - tags: - one: hello - two: world - register: result - - - assert: - that: - - result.changed - - result.tags | length == 2 - - - name: add tags to snapshot - idempotence - rds_snapshot: - db_instance_identifier: "{{ instance_id }}" - db_snapshot_identifier: "{{ resource_prefix }}-test-tags" - state: present - tags: - one: hello - two: world - register: result - - - assert: - that: - - not result.changed - - result.tags | length == 2 - - - name: add tag to snapshot using purge_tags False - rds_snapshot: - db_instance_identifier: "{{ instance_id }}" - db_snapshot_identifier: "{{ resource_prefix }}-test-tags" - state: present - tags: - one: hello - three: another - purge_tags: False - register: result - - - assert: - that: - - result.changed - - result.tags | length == 3 - - - name: rerun tags but not setting purge_tags - rds_snapshot: - db_instance_identifier: "{{ instance_id }}" - db_snapshot_identifier: "{{ resource_prefix }}-test-tags" - state: present - tags: - one: hello - three: another - register: result - - - assert: - that: - - result.changed - - result.tags | length == 2 - - - name: rerun tags but not setting purge_tags - idempotence - rds_snapshot: - db_instance_identifier: "{{ instance_id }}" - db_snapshot_identifier: "{{ resource_prefix }}-test-tags" - state: present - tags: - one: hello - three: another - register: result - - - assert: - that: - - not result.changed - - result.tags | length == 2 - - - name: remove snapshot - rds_snapshot: - db_instance_identifier: "{{ instance_id }}" - db_snapshot_identifier: "{{ resource_prefix }}-test-tags" - state: absent - wait: yes - register: result - - - assert: - that: - - result.changed - - - name: create snapshot with tags - rds_snapshot: - db_instance_identifier: "{{ instance_id }}" - db_snapshot_identifier: "{{ resource_prefix }}-test-tags" - state: present - tags: - one: hello - three: another - purge_tags: yes - wait: yes - register: result - - - assert: - that: - - result.changed - - result.tags | length == 2 - - always: - - - name: tidy up snapshot - rds_snapshot: - db_instance_identifier: "{{ instance_id }}" - db_snapshot_identifier: "{{ resource_prefix }}-test-tags" - state: absent - ignore_errors: yes - - - name: Ensure the resource doesn't exist - rds_instance: - db_instance_identifier: "{{ instance_id }}" - state: absent - skip_final_snapshot: True - register: result - - - assert: - that: - - result.changed diff --git a/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_vpc_security_groups.yml b/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_vpc_security_groups.yml index 940ce5b0fae..d797d965323 100644 --- a/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_vpc_security_groups.yml +++ b/tests/integration/targets/rds_instance/roles/rds_instance/tasks/test_vpc_security_groups.yml @@ -192,11 +192,3 @@ retries: 30 until: vpc_result is not failed delay: 10 - - - name: Ensure the resource doesn't exist - rds_instance: - id: "{{ instance_id }}" - state: absent - skip_final_snapshot: True - register: result - ignore_errors: yes