From 19f54ac6f3b25188e9649d61cf1d4eaecc906df9 Mon Sep 17 00:00:00 2001 From: Alina Buzachis Date: Tue, 13 Sep 2022 17:15:59 +0200 Subject: [PATCH] Fix tests Signed-off-by: Alina Buzachis --- plugins/modules/rds_export_task.py | 24 +++++- .../targets/rds_export_task/aliases | 1 + .../targets/rds_export_task/tasks/main.yml | 74 ++++++++++--------- 3 files changed, 59 insertions(+), 40 deletions(-) create mode 100644 tests/integration/targets/rds_export_task/aliases diff --git a/plugins/modules/rds_export_task.py b/plugins/modules/rds_export_task.py index 2b659482832..e331736ed42 100644 --- a/plugins/modules/rds_export_task.py +++ b/plugins/modules/rds_export_task.py @@ -11,7 +11,7 @@ --- module: rds_export_task version_added: 5.0.0 -short_description: rds_export_task +short_description: Starts and cancels an export of a snapshot to Amazon S3 author: Alina Buzachis (@alinabuzachis) description: - Starts an export of a snapshot to Amazon S3. @@ -50,6 +50,8 @@ description: - The ID of the Amazon Web Services KMS customer master key (CMK) to use to encrypt the snapshot exported to Amazon S3. type: str + aliases: + - key_id s3_prefix: description: - The Amazon S3 bucket prefix to use as the file name and path of the exported snapshot. @@ -71,10 +73,24 @@ extends_documentation_fragment: - amazon.aws.aws - amazon.aws.ec2 +- amazon.aws.aws_boto3 """ EXAMPLES = r""" - +- name: Export snapshot to S3 + amazon.aws.rds_export_task: + export_task_id: "{{ export_task_id }}" + source_arn: "{{ db_snapshot_arn }}" + s3_bucket_name: "{{ bucket_name }}" + iam_role_arn: "{{ iam_role_arn }}" + kms_key_id: "{{ kms_key_arn }}" + state: present + register: _result_export_task + +- name: Delete an export task + amazon.aws.rds_export_task: + export_task_id: "{{ export_task_id }}" + state: absent """ RETURN = r""" @@ -169,7 +185,7 @@ def main(): source_arn=dict(type="str"), s3_bucket_name=dict(type="str", aliases=['s3_bucket']), iam_role_arn=dict(type="str", aliases=['iam_role']), - kms_key_id=dict(type="str"), + kms_key_id=dict(type="str", aliases=['key_id']), s3_prefix=dict(type="str"), export_only=dict(type="list", elements="str"), ) @@ -200,4 +216,4 @@ def main(): if __name__ == "__main__": - main() \ No newline at end of file + main() diff --git a/tests/integration/targets/rds_export_task/aliases b/tests/integration/targets/rds_export_task/aliases new file mode 100644 index 00000000000..4ef4b2067d0 --- /dev/null +++ b/tests/integration/targets/rds_export_task/aliases @@ -0,0 +1 @@ +cloud/aws diff --git a/tests/integration/targets/rds_export_task/tasks/main.yml b/tests/integration/targets/rds_export_task/tasks/main.yml index 7484ab5e866..357fed54949 100644 --- a/tests/integration/targets/rds_export_task/tasks/main.yml +++ b/tests/integration/targets/rds_export_task/tasks/main.yml @@ -30,7 +30,7 @@ ansible-test: '{{ resource_prefix }}' register: _result_create_key - - name: Create an s3 bucket + - name: Create an S3 bucket s3_bucket: name: '{{ bucket_name }}' state: present @@ -42,19 +42,19 @@ - _result_create_s3_bucket is changed - _result_create_s3_bucket.name == '{{ bucket_name }}' - # - name: Enable aws:kms encryption with KMS key - # s3_bucket: - # name: '{{ bucket_name }}' - # state: present - # encryption: "aws:kms" - # encryption_key_id: "{{ _result_create_key.key_arn }}" - # register: _result_s3_bucket + - name: Enable aws:kms encryption with KMS key + s3_bucket: + name: '{{ bucket_name }}' + state: present + encryption: "aws:kms" + encryption_key_id: "{{ _result_create_key.key_arn }}" + register: _result_s3_bucket - # - assert: - # that: - # - _result_s3_bucket.changed - # - _result_s3_bucket.encryption - # - _result_s3_bucket.encryption.SSEAlgorithm == 'aws:kms' + - assert: + that: + - _result_s3_bucket.changed + - _result_s3_bucket.encryption + - _result_s3_bucket.encryption.SSEAlgorithm == 'aws:kms' - name: Create a source mariadb instance rds_instance: @@ -82,13 +82,14 @@ - assert: that: - _result_instance_snapshot_info is successful - #- _result_instance_snapshot_info.snapshots | length == 1 + - _result_instance_snapshot_info.snapshots | length == 1 - name: Take a snapshot of the existing RDS instance rds_instance_snapshot: state: present db_instance_identifier: "{{ instance_id }}" db_snapshot_identifier: "{{ snapshot_id }}" + wait: true register: _result_instance_snapshot - assert: @@ -114,6 +115,7 @@ iam_role_arn: "{{ _result_create_iam_role.arn }}" kms_key_id: "{{ _result_create_key.key_arn }}" state: present + check_mode: true register: _result_export_task - name: Export snapshot to S3 @@ -135,31 +137,31 @@ kms_key_id: "{{ _result_create_key.key_arn }}" register: _result_export_task - # - name: Delete an export task (CHECK_MODE) - # rds_export_task: - # export_task_id: "{{ export_task_id }}" - # state: absent - # check_mode: true - # register: _result_delete + - name: Delete an export task (CHECK_MODE) + rds_export_task: + export_task_id: "{{ export_task_id }}" + state: absent + check_mode: true + register: _result_delete - # - name: Delete an export task - idempotence - # rds_export_task: - # export_task_id: "{{ export_task_id }}" - # state: absent - # check_mode: true - # register: _result_delete + - name: Delete an export task - idempotence + rds_export_task: + export_task_id: "{{ export_task_id }}" + state: absent + check_mode: true + register: _result_delete - # - name: Delete an export task - # rds_export_task: - # export_task_id: "{{ export_task_id }}" - # state: absent - # register: _result_delete + - name: Delete an export task + rds_export_task: + export_task_id: "{{ export_task_id }}" + state: absent + register: _result_delete - # - name: Delete an export task - idempotence - # rds_export_task: - # export_task_id: "{{ export_task_id }}" - # state: absent - # register: _result_delete + - name: Delete an export task - idempotence + rds_export_task: + export_task_id: "{{ export_task_id }}" + state: absent + register: _result_delete always: - name: Delete an export task