From dfb1d27bf6de70c118a36b86db181dcc26405c00 Mon Sep 17 00:00:00 2001 From: Jill Rouleau Date: Thu, 30 Nov 2023 15:16:25 -0700 Subject: [PATCH 1/9] Avoid unsafe conditionals in integration tests Update a batch of assertions in integration tests to avoid templating See: https://github.com/ansible/ansible-documentation/pull/866 and https://github.com/ansible/ansible-documentation/pull/866 --- .../roles/ec2_asg/tasks/instance_detach.yml | 18 ++-- .../targets/backup_selection/tasks/main.yml | 32 +++---- .../tasks/test_disable_rollback.yml | 2 +- .../targets/cloudtrail/tasks/main.yml | 18 ++-- .../tasks/test_create_attached_multiple.yml | 6 +- .../ec2_instance_block_devices/tasks/main.yml | 4 +- .../tasks/main.yml | 14 +-- .../ec2_instance_cpu_options/tasks/main.yml | 10 +- .../tasks/main.yml | 4 +- .../ec2_instance_ebs_optimized/tasks/main.yml | 2 +- .../tasks/main.yml | 10 +- .../tasks/main.yml | 10 +- .../tasks/main.yml | 4 +- .../tasks/main.yml | 4 +- .../tasks/main.yml | 8 +- .../tasks/main.yml | 10 +- .../tasks/main.yml | 6 +- .../tasks/main.yml | 20 ++-- .../ec2_instance_uptime/tasks/main.yml | 6 +- .../targets/ec2_key/tasks/main.yml | 4 +- .../playbooks/test_metadata.yml | 2 +- .../ec2_security_group/tasks/group_info.yml | 2 +- .../targets/ec2_snapshot/tasks/main.yml | 4 +- .../targets/ec2_vol/tasks/main.yml | 18 ++-- .../targets/ec2_vpc_igw/tasks/main.yml | 2 +- .../ec2_vpc_route_table/tasks/main.yml | 24 ++--- .../targets/elb_application_lb/tasks/main.yml | 20 ++-- .../elb_classic_lb/tasks/basic_internal.yml | 8 +- .../elb_classic_lb/tasks/basic_public.yml | 8 +- .../elb_classic_lb/tasks/https_listeners.yml | 8 +- .../iam_instance_profile/tasks/main.yml | 22 ++--- .../rds_cluster_create/tasks/main.yaml | 6 +- .../rds_cluster_create_sgs/tasks/main.yaml | 12 +-- .../rds_cluster_modify/tasks/main.yaml | 10 +- .../rds_cluster_promote/tasks/main.yaml | 8 +- .../rds_cluster_restore/tasks/main.yaml | 14 +-- .../rds_cluster_snapshot/tasks/main.yml | 56 +++++------ .../targets/rds_cluster_states/tasks/main.yml | 8 +- .../targets/rds_cluster_tag/tasks/main.yaml | 40 ++++---- .../rds_instance_modify/tasks/main.yml | 4 +- .../rds_instance_snapshot/tasks/main.yml | 94 +++++++++---------- .../rds_instance_snapshot_mgmt/tasks/main.yml | 12 +-- .../targets/rds_option_group/tasks/main.yml | 74 +++++++-------- .../targets/route53/tasks/main.yml | 2 +- .../tasks/update_delete_by_id.yml | 2 +- .../targets/s3_object/tasks/main.yml | 4 +- 46 files changed, 328 insertions(+), 328 deletions(-) diff --git a/tests/integration/targets/autoscaling_group/roles/ec2_asg/tasks/instance_detach.yml b/tests/integration/targets/autoscaling_group/roles/ec2_asg/tasks/instance_detach.yml index b64432da642..93a96eaeab7 100644 --- a/tests/integration/targets/autoscaling_group/roles/ec2_asg/tasks/instance_detach.yml +++ b/tests/integration/targets/autoscaling_group/roles/ec2_asg/tasks/instance_detach.yml @@ -145,10 +145,10 @@ that: - asg_info_replaced.results[0].desired_capacity == 3 - asg_info_replaced.results[0].instances | length == 3 - - "'{{ init_instance_1 }}' not in {{ asg_instance_detach_replace }}" - - "'{{ init_instance_2 }}' not in {{ asg_instance_detach_replace }}" - - "'{{ detached_instances_info.instances[0].state.name }}' == 'running'" - - "'{{ detached_instances_info.instances[1].state.name }}' == 'running'" + - init_instance_1 not in asg_instance_detach_replace + - init_instance_2 not in asg_instance_detach_replace + - detached_instances_info.instances[0].state.name == 'running' + - detached_instances_info.instances[1].state.name == 'running' #---------------------------------------------------------------------- @@ -191,11 +191,11 @@ that: - asg_info_decrement.results[0].instances | length == 1 - asg_info_decrement.results[0].desired_capacity == 1 - - "'{{ instance_replace_1 }}' not in {{ asg_instance_detach_decrement }}" - - "'{{ instance_replace_2 }}' not in {{ asg_instance_detach_decrement }}" - - "'{{ detached_instances_info.instances[0].state.name }}' == 'running'" - - "'{{ detached_instances_info.instances[1].state.name }}' == 'running'" - - "'{{ instance_replace_3 }}' == '{{ instance_detach_decrement }}'" + - instance_replace_1 not in asg_instance_detach_decrement + - instance_replace_2 not in asg_instance_detach_decrement + - detached_instances_info.instances[0].state.name == 'running' + - detached_instances_info.instances[1].state.name == 'running' + - instance_replace_3 == instance_detach_decrement #---------------------------------------------------------------------- diff --git a/tests/integration/targets/backup_selection/tasks/main.yml b/tests/integration/targets/backup_selection/tasks/main.yml index da8d3ecbe44..517a5da2abe 100644 --- a/tests/integration/targets/backup_selection/tasks/main.yml +++ b/tests/integration/targets/backup_selection/tasks/main.yml @@ -123,7 +123,7 @@ - _result_create_selection_with_all_options.changed - "'backup_selection' in _result_create_selection_with_all_options" - _result_create_selection_with_all_options.backup_selection.iam_role_arn == iam_role.iam_role.arn - - _result_create_selection_with_all_options.backup_selection.selection_name == "all-options-{{ backup_selection_name }}" + - _result_create_selection_with_all_options.backup_selection.selection_name == "all-options-"+backup_selection_name - name: Create an AWS Backup selection with all options (idempotency) amazon.aws.backup_selection: @@ -136,7 +136,7 @@ - not _result_create_selection_with_all_options_idempotency.changed - "'backup_selection' in _result_create_selection_with_all_options_idempotency" - _result_create_selection_with_all_options_idempotency.backup_selection.iam_role_arn == iam_role.iam_role.arn - - _result_create_selection_with_all_options_idempotency.backup_selection.selection_name == "all-options-{{ backup_selection_name }}" + - _result_create_selection_with_all_options_idempotency.backup_selection.selection_name == "all-options-"+backup_selection_name - name: Get detailed information about the AWS Backup selection amazon.aws.backup_selection_info: @@ -150,7 +150,7 @@ that: - _result_backup_selection_info.backup_selections | length == 1 - _result_backup_selection_info.backup_selections[0].iam_role_arn == iam_role.iam_role.arn - - _result_backup_selection_info.backup_selections[0].selection_name == "all-options-{{ backup_selection_name }}" + - _result_backup_selection_info.backup_selections[0].selection_name == "all-options-"+backup_selection_name - _result_backup_selection_info.backup_selections[0].resources == ['arn:aws:s3:::a-bucket'] - _result_backup_selection_info.backup_selections[0].not_resources == ['arn:aws:s3:::another-bucket'] - _result_backup_selection_info.backup_selections[0].list_of_tags[0].condition_value == "daily" @@ -205,7 +205,7 @@ - _result_create_selection_with_minimal_options.changed - "'backup_selection' in _result_create_selection_with_minimal_options" - _result_create_selection_with_minimal_options.backup_selection.iam_role_arn == iam_role.iam_role.arn - - _result_create_selection_with_minimal_options.backup_selection.selection_name == "{{ backup_selection_name }}" + - _result_create_selection_with_minimal_options.backup_selection.selection_name == backup_selection_name - name: Create an AWS Backup selection with minimal options (idempotency) amazon.aws.backup_selection: @@ -218,7 +218,7 @@ - not _result_create_selection_with_minimal_options_idempotency.changed - "'backup_selection' in _result_create_selection_with_minimal_options_idempotency" - _result_create_selection_with_minimal_options_idempotency.backup_selection.iam_role_arn == iam_role.iam_role.arn - - _result_create_selection_with_minimal_options_idempotency.backup_selection.selection_name == "{{ backup_selection_name }}" + - _result_create_selection_with_minimal_options_idempotency.backup_selection.selection_name == backup_selection_name - name: Get detailed information about the AWS Backup selection amazon.aws.backup_selection_info: @@ -232,7 +232,7 @@ that: - _result_backup_selection_info.backup_selections | length == 1 - _result_backup_selection_info.backup_selections[0].iam_role_arn == iam_role.iam_role.arn - - _result_backup_selection_info.backup_selections[0].selection_name == "{{ backup_selection_name }}" + - _result_backup_selection_info.backup_selections[0].selection_name == backup_selection_name - _result_backup_selection_info.backup_selections[0].resources == ['arn:aws:s3:::a-bucket'] - _result_backup_selection_info.backup_selections[0].not_resources == [] - _result_backup_selection_info.backup_selections[0].list_of_tags | length == 0 @@ -282,7 +282,7 @@ - name: Verify list_of_tags was not added in check mode ansible.builtin.assert: that: - - _result_backup_selection_info.backup_selections[0].selection_name == "{{ backup_selection_name }}" + - _result_backup_selection_info.backup_selections[0].selection_name == backup_selection_name - _result_backup_selection_info.backup_selections[0].list_of_tags == [] - name: Modify an AWS Backup selection - add list_of_tags @@ -316,7 +316,7 @@ ansible.builtin.assert: that: - _result_backup_selection_info.backup_selections[0].iam_role_arn == iam_role.iam_role.arn - - _result_backup_selection_info.backup_selections[0].selection_name == "{{ backup_selection_name }}" + - _result_backup_selection_info.backup_selections[0].selection_name == backup_selection_name - _result_backup_selection_info.backup_selections[0].resources == [ 'arn:aws:s3:::a-bucket'] - _result_backup_selection_info.backup_selections[0].not_resources == [] - _result_backup_selection_info.backup_selections[0].list_of_tags[0].condition_value == "weekly" @@ -363,7 +363,7 @@ - name: Verify backup selection conditions were not added in check mode ansible.builtin.assert: that: - - _result_backup_selection_info.backup_selections[0].selection_name == "{{ backup_selection_name }}" + - _result_backup_selection_info.backup_selections[0].selection_name == backup_selection_name - _result_backup_selection_info.backup_selections[0].conditions.string_not_equals == [] - name: Modify an AWS Backup selection - add conditions @@ -397,7 +397,7 @@ ansible.builtin.assert: that: - _result_backup_selection_info.backup_selections[0].iam_role_arn == iam_role.iam_role.arn - - _result_backup_selection_info.backup_selections[0].selection_name == "{{ backup_selection_name }}" + - _result_backup_selection_info.backup_selections[0].selection_name == backup_selection_name - _result_backup_selection_info.backup_selections[0].resources == ['arn:aws:s3:::a-bucket'] - _result_backup_selection_info.backup_selections[0].not_resources == [] - _result_backup_selection_info.backup_selections[0].list_of_tags[0].condition_value == "weekly" @@ -446,7 +446,7 @@ - name: Verify backup selection options were not updated in check mode ansible.builtin.assert: that: - - _result_backup_selection_info.backup_selections[0].selection_name == "{{ backup_selection_name }}" + - _result_backup_selection_info.backup_selections[0].selection_name == backup_selection_name - _result_backup_selection_info.backup_selections[0].resources == ['arn:aws:s3:::a-bucket'] - _result_backup_selection_info.backup_selections[0].not_resources == [] - _result_backup_selection_info.backup_selections[0].list_of_tags[0].condition_value == "weekly" @@ -483,7 +483,7 @@ ansible.builtin.assert: that: - _result_backup_selection_info.backup_selections[0].iam_role_arn == iam_role.iam_role.arn - - _result_backup_selection_info.backup_selections[0].selection_name == "{{ backup_selection_name }}" + - _result_backup_selection_info.backup_selections[0].selection_name == backup_selection_name - _result_backup_selection_info.backup_selections[0].resources == ['arn:aws:s3:::another-bucket'] - _result_backup_selection_info.backup_selections[0].not_resources == ['arn:aws:s3:::a-bucket'] - _result_backup_selection_info.backup_selections[0].list_of_tags[0].condition_value == "daily" @@ -528,7 +528,7 @@ - name: Verify list_of_tags was not removed in check mode ansible.builtin.assert: that: - - _result_backup_selection_info.backup_selections[0].selection_name == "{{ backup_selection_name }}" + - _result_backup_selection_info.backup_selections[0].selection_name == backup_selection_name - _result_backup_selection_info.backup_selections[0].resources == ['arn:aws:s3:::another-bucket'] - _result_backup_selection_info.backup_selections[0].not_resources == ['arn:aws:s3:::a-bucket'] - _result_backup_selection_info.backup_selections[0].list_of_tags [0].condition_value == "daily" @@ -565,7 +565,7 @@ ansible.builtin.assert: that: - _result_backup_selection_info.backup_selections[0].iam_role_arn == iam_role.iam_role.arn - - _result_backup_selection_info.backup_selections[0].selection_name == "{{ backup_selection_name }}" + - _result_backup_selection_info.backup_selections[0].selection_name == backup_selection_name - _result_backup_selection_info.backup_selections[0].resources == ['arn:aws:s3:::another-bucket'] - _result_backup_selection_info.backup_selections[0].not_resources == ['arn:aws:s3:::a-bucket'] - _result_backup_selection_info.backup_selections[0].list_of_tags == [] @@ -606,7 +606,7 @@ - name: Verify conditions were not removed in check mode ansible.builtin.assert: that: - - _result_backup_selection_info.backup_selections[0].selection_name == "{{ backup_selection_name }}" + - _result_backup_selection_info.backup_selections[0].selection_name == backup_selection_name - _result_backup_selection_info.backup_selections[0].resources == ['arn:aws:s3:::another-bucket'] - _result_backup_selection_info.backup_selections[0].not_resources == ['arn:aws:s3:::a-bucket'] - _result_backup_selection_info.backup_selections[0].list_of_tags == [] @@ -643,7 +643,7 @@ ansible.builtin.assert: that: - _result_backup_selection_info.backup_selections[0].iam_role_arn == iam_role.iam_role.arn - - _result_backup_selection_info.backup_selections[0].selection_name == "{{ backup_selection_name }}" + - _result_backup_selection_info.backup_selections[0].selection_name == backup_selection_name - _result_backup_selection_info.backup_selections[0].resources == ['arn:aws:s3:::another-bucket'] - _result_backup_selection_info.backup_selections[0].not_resources == ['arn:aws:s3:::a-bucket'] - _result_backup_selection_info.backup_selections[0].list_of_tags == [] diff --git a/tests/integration/targets/cloudformation/tasks/test_disable_rollback.yml b/tests/integration/targets/cloudformation/tasks/test_disable_rollback.yml index c38dcfa8483..2df27d57c99 100644 --- a/tests/integration/targets/cloudformation/tasks/test_disable_rollback.yml +++ b/tests/integration/targets/cloudformation/tasks/test_disable_rollback.yml @@ -202,7 +202,7 @@ that: - cf_stack.changed - cf_stack.output == "Stack UPDATE complete" - - stack_info.cloudformation["{{ stack_name }}-failtest"].stack_description.stack_status == "UPDATE_COMPLETE" + - stack_info.cloudformation[stack_name+"-failtest"].stack_description.stack_status == "UPDATE_COMPLETE" always: diff --git a/tests/integration/targets/cloudtrail/tasks/main.yml b/tests/integration/targets/cloudtrail/tasks/main.yml index 86fc7bdc605..cacd47a9ef5 100644 --- a/tests/integration/targets/cloudtrail/tasks/main.yml +++ b/tests/integration/targets/cloudtrail/tasks/main.yml @@ -333,7 +333,7 @@ that: - output is changed - output.trail.name == cloudtrail_name - - 'output.trail.s3_key_prefix == "{{ cloudtrail_prefix }}-2"' + - 'output.trail.s3_key_prefix == cloudtrail_prefix+"-2"' - name: 'Update S3 prefix (no change)' cloudtrail: @@ -345,7 +345,7 @@ that: - output is not changed - output.trail.name == cloudtrail_name - - 'output.trail.s3_key_prefix == "{{ cloudtrail_prefix }}-2"' + - 'output.trail.s3_key_prefix == cloudtrail_prefix+"-2"' - name: 'Get the trail info after updating S3 prefix' cloudtrail_info: @@ -356,7 +356,7 @@ - name: 'Assert that the s3_key_prefix is correct' assert: that: - - 'info.trail_list[0].s3_key_prefix == "{{ cloudtrail_prefix }}-2"' + - 'info.trail_list[0].s3_key_prefix == cloudtrail_prefix+"-2"' - name: 'Remove S3 prefix (CHECK MODE)' cloudtrail: @@ -488,7 +488,7 @@ that: - output is changed - output.trail.name == cloudtrail_name - - 'output.trail.sns_topic_name == "{{ sns_topic }}-2"' + - 'output.trail.sns_topic_name == sns_topic+"-2"' - name: 'Update SNS Topic (no change)' cloudtrail: @@ -500,7 +500,7 @@ that: - output is not changed - output.trail.name == cloudtrail_name - - 'output.trail.sns_topic_name == "{{ sns_topic }}-2"' + - 'output.trail.sns_topic_name == sns_topic+"-2"' - name: 'Get the trail info with SNS topic after update' cloudtrail_info: @@ -511,7 +511,7 @@ - name: 'Assert that the sns_topic is correctly set' assert: that: - - 'info.trail_list[0].sns_topic_name == "{{ sns_topic }}-2"' + - 'info.trail_list[0].sns_topic_name == sns_topic+"-2"' #- name: 'Remove SNS Topic (CHECK MODE)' # cloudtrail: @@ -735,7 +735,7 @@ that: - output is changed - output.trail.name == cloudtrail_name - - 'output.trail.s3_bucket_name == "{{ s3_bucket_name }}-2"' + - 'output.trail.s3_bucket_name == s3_bucket_name+"-2"' - name: 'Update S3 bucket (no change)' cloudtrail: @@ -747,7 +747,7 @@ that: - output is not changed - output.trail.name == cloudtrail_name - - 'output.trail.s3_bucket_name == "{{ s3_bucket_name }}-2"' + - 'output.trail.s3_bucket_name == s3_bucket_name+"-2"' - name: 'Get the trail info with S3 bucket name' cloudtrail_info: @@ -758,7 +758,7 @@ - name: 'Assert that the S3 Bucket name is correctly set' assert: that: - - 'info.trail_list[0].s3_bucket_name == "{{ s3_bucket_name }}-2"' + - 'info.trail_list[0].s3_bucket_name == s3_bucket_name+"-2"' - name: 'Reset S3 bucket' cloudtrail: diff --git a/tests/integration/targets/ec2_eni/tasks/test_create_attached_multiple.yml b/tests/integration/targets/ec2_eni/tasks/test_create_attached_multiple.yml index c8213914040..28e05680d54 100644 --- a/tests/integration/targets/ec2_eni/tasks/test_create_attached_multiple.yml +++ b/tests/integration/targets/ec2_eni/tasks/test_create_attached_multiple.yml @@ -37,7 +37,7 @@ - result is not failed - instance_info_result.instances[0].network_interfaces | length == 1 - '"Would have created ENI if not in check mode." in result.msg' - - "'ec2:CreateNetworkInterface' not in {{ result.resource_actions }}" + - 'ec2:CreateNetworkInterface' not in result.resource_actions - name: Create and attach another interface to above instance amazon.aws.ec2_eni: @@ -97,8 +97,8 @@ - result is not failed - instance_info_result.instances[0].network_interfaces | length == 2 - '"Would have modified ENI: {{ eni_id_attached_multiple }} if not in check mode" in result.msg' - - "'ec2:CreateNetworkInterface' not in {{ result.resource_actions }}" - - "'ec2:ModifyNetworkInterfaceAttribute' not in {{ result.resource_actions }}" + - 'ec2:CreateNetworkInterface' not in result.resource_actions + - 'ec2:ModifyNetworkInterfaceAttribute' not in result.resource_actions #================================================================= diff --git a/tests/integration/targets/ec2_instance_block_devices/tasks/main.yml b/tests/integration/targets/ec2_instance_block_devices/tasks/main.yml index a12a893f664..14ee2b6b977 100644 --- a/tests/integration/targets/ec2_instance_block_devices/tasks/main.yml +++ b/tests/integration/targets/ec2_instance_block_devices/tasks/main.yml @@ -73,12 +73,12 @@ - name: Confirm instance was created without check mode ansible.builtin.assert: that: - - "{{ presented_instance_fact.instances | length }} > 0" + - presented_instance_fact.instances | length > 0 - name: Confirm instance was not created with check mode ansible.builtin.assert: that: - - "{{ checkmode_instance_fact.instances | length }} == 0" + - checkmode_instance_fact.instances | length == 0 - name: Terminate instances amazon.aws.ec2_instance: diff --git a/tests/integration/targets/ec2_instance_checkmode_tests/tasks/main.yml b/tests/integration/targets/ec2_instance_checkmode_tests/tasks/main.yml index 72ec2ed0c58..d208c9c1f75 100644 --- a/tests/integration/targets/ec2_instance_checkmode_tests/tasks/main.yml +++ b/tests/integration/targets/ec2_instance_checkmode_tests/tasks/main.yml @@ -47,8 +47,8 @@ - name: "Confirm whether the check mode is working normally." assert: that: - - "{{ presented_instance_fact.instances | length }} > 0" - - "{{ checkmode_instance_fact.instances | length }} == 0" + - presented_instance_fact.instances | length > 0 + - checkmode_instance_fact.instances | length == 0 - name: "Stop instance (check mode)" ec2_instance: @@ -112,7 +112,7 @@ - name: "Verify that it was not running." assert: that: - - '"{{ confirm_checkmode_runninginstance_fact.instances[0].state.name }}" != "running"' + - confirm_checkmode_runninginstance_fact.instances[0].state.name != "running" - name: "Running instance." ec2_instance: @@ -132,7 +132,7 @@ - name: "Verify that it was running." assert: that: - - '"{{ confirm_runninginstance_fact.instances[0].state.name }}" == "running"' + - confirm_runninginstance_fact.instances[0].state.name == "running" - name: "Tag instance." ec2_instance: @@ -153,7 +153,7 @@ - name: "Verify that it hasn't been re-tagged." assert: that: - - '"{{ confirm_not_tagged.instances[0].tags.TestTag }}" == "Some Value"' + - confirm_not_tagged.instances[0].tags.TestTag == "Some Value" - name: "Terminate instance in check mode." ec2_instance: @@ -175,7 +175,7 @@ - name: "Verify that it was not terminated," assert: that: - - '"{{ confirm_checkmode_terminatedinstance_fact.instances[0].state.name }}" != "terminated"' + - confirm_checkmode_terminatedinstance_fact.instances[0].state.name != "terminated" - name: "Terminate instance." ec2_instance: @@ -196,7 +196,7 @@ - name: "Verify that it was terminated," assert: that: - - '"{{ confirm_terminatedinstance_fact.instances[0].state.name }}" == "terminated"' + - confirm_terminatedinstance_fact.instances[0].state.name == "terminated" always: - name: "Terminate checkmode instances" diff --git a/tests/integration/targets/ec2_instance_cpu_options/tasks/main.yml b/tests/integration/targets/ec2_instance_cpu_options/tasks/main.yml index 4aea79c047a..59f5a21dbea 100644 --- a/tests/integration/targets/ec2_instance_cpu_options/tasks/main.yml +++ b/tests/integration/targets/ec2_instance_cpu_options/tasks/main.yml @@ -53,10 +53,10 @@ that: - cpu_options_update is success - cpu_options_update is not changed - - "{{ presented_instance_fact.instances | length }} > 0" - - "'{{ presented_instance_fact.instances.0.state.name }}' in ['running','pending']" - - "{{ presented_instance_fact.instances.0.cpu_options.core_count }} == 1" - - "{{ presented_instance_fact.instances.0.cpu_options.threads_per_core }} == 1" + - presented_instance_fact.instances | length > 0 + - presented_instance_fact.instances.0.state.name in ['running','pending'] + - presented_instance_fact.instances.0.cpu_options.core_count == 1 + - presented_instance_fact.instances.0.cpu_options.threads_per_core == 1 - name: "create t3.nano instance with cpu_options(check mode)" ec2_instance: @@ -82,4 +82,4 @@ - name: "Confirm existence of instance id." assert: that: - - "{{ checkmode_instance_fact.instances | length }} == 0" + - checkmode_instance_fact.instances | length == 0 diff --git a/tests/integration/targets/ec2_instance_default_vpc_tests/tasks/main.yml b/tests/integration/targets/ec2_instance_default_vpc_tests/tasks/main.yml index de9735fc0f9..9ff13744385 100644 --- a/tests/integration/targets/ec2_instance_default_vpc_tests/tasks/main.yml +++ b/tests/integration/targets/ec2_instance_default_vpc_tests/tasks/main.yml @@ -43,8 +43,8 @@ - name: "Confirm whether the check mode is working normally." assert: that: - - "{{ presented_instance_fact.instances | length }} > 0" - - "{{ checkmode_instance_fact.instances | length }} == 0" + - presented_instance_fact.instances | length > 0 + - checkmode_instance_fact.instances | length == 0 - name: "Terminate instances" ec2_instance: diff --git a/tests/integration/targets/ec2_instance_ebs_optimized/tasks/main.yml b/tests/integration/targets/ec2_instance_ebs_optimized/tasks/main.yml index e469a3a66e9..5a2bd330ef9 100644 --- a/tests/integration/targets/ec2_instance_ebs_optimized/tasks/main.yml +++ b/tests/integration/targets/ec2_instance_ebs_optimized/tasks/main.yml @@ -28,4 +28,4 @@ - name: "Assert instance is ebs_optimized" assert: that: - - "{{ ebs_opt_instance_info.instances.0.ebs_optimized }}" + - ebs_opt_instance_info.instances.0.ebs_optimized diff --git a/tests/integration/targets/ec2_instance_external_resource_attach/tasks/main.yml b/tests/integration/targets/ec2_instance_external_resource_attach/tasks/main.yml index 259c14712c2..9458e80293a 100644 --- a/tests/integration/targets/ec2_instance_external_resource_attach/tasks/main.yml +++ b/tests/integration/targets/ec2_instance_external_resource_attach/tasks/main.yml @@ -57,7 +57,7 @@ - assert: that: - - 'in_test_vpc_instance.instances.0.key_name == "{{ resource_prefix }}_test_key"' + - in_test_vpc_instance.instances.0.key_name == resource_prefix+"_test_key" - '(in_test_vpc_instance.instances.0.network_interfaces | length) == 1' - name: "Add a second interface (check_mode=true)" @@ -90,7 +90,7 @@ - name: Validate that only 1 ENI is attached to instance as we run using check_mode=true assert: that: - - 'in_test_vpc_instance.instances.0.key_name == "{{ resource_prefix }}_test_key"' + - 'in_test_vpc_instance.instances.0.key_name == resource_prefix+"_test_key"' - '(in_test_vpc_instance.instances.0.network_interfaces | length) == 1' - name: "Add a second interface" @@ -122,7 +122,7 @@ - name: Validate that only 1 ENI is attached to instance as we run using check_mode=true assert: that: - - 'in_test_vpc_instance.instances.0.key_name == "{{ resource_prefix }}_test_key"' + - 'in_test_vpc_instance.instances.0.key_name == resource_prefix+"_test_key"' - '(in_test_vpc_instance.instances.0.network_interfaces | length) == 2' when: add_interface is successful @@ -157,5 +157,5 @@ - name: "Confirm existence of instance id." assert: that: - - "{{ presented_instance_fact.instances | length }} > 0" - - "{{ checkmode_instance_fact.instances | length }} == 0" + - presented_instance_fact.instances | length > 0 + - checkmode_instance_fact.instances | length == 0 diff --git a/tests/integration/targets/ec2_instance_hibernation_options/tasks/main.yml b/tests/integration/targets/ec2_instance_hibernation_options/tasks/main.yml index 5bd8e5ce14c..3b278feb6a7 100644 --- a/tests/integration/targets/ec2_instance_hibernation_options/tasks/main.yml +++ b/tests/integration/targets/ec2_instance_hibernation_options/tasks/main.yml @@ -56,9 +56,9 @@ - name: Check return values of the create instance task assert: that: - - "{{ create_instance_results.instances | length }} > 0" - - "'{{ create_instance_results.instances.0.state.name }}' == 'running'" - - "'{{ create_instance_results.spec.HibernationOptions.Configured }}'" + - create_instance_results.instances | length > 0 + - create_instance_results.instances.0.state.name == 'running' + - create_instance_results.spec.HibernationOptions.Configured - name: Gather information about the instance to get the hibernation status ec2_instance_info: @@ -118,8 +118,8 @@ - name: Check return values of the create instance task assert: that: - - "{{ not create_instance_results.changed }}" - - "{{ create_instance_results.instances | length }} > 0" + - not create_instance_results.changed + - create_instance_results.instances | length > 0 - name: Create instance with hibernation options configured with unencrypted volume ec2_instance: diff --git a/tests/integration/targets/ec2_instance_iam_instance_role/tasks/main.yml b/tests/integration/targets/ec2_instance_iam_instance_role/tasks/main.yml index d5d203eae49..0e4818a8d3c 100644 --- a/tests/integration/targets/ec2_instance_iam_instance_role/tasks/main.yml +++ b/tests/integration/targets/ec2_instance_iam_instance_role/tasks/main.yml @@ -75,8 +75,8 @@ - name: "Confirm whether the check mode is working normally." assert: that: - - "{{ presented_instance_fact.instances | length }} > 0" - - "{{ checkmode_instance_fact.instances | length }} == 0" + - presented_instance_fact.instances | length > 0 + - checkmode_instance_fact.instances | length == 0 - name: "Update instance with new instance_role" ec2_instance: diff --git a/tests/integration/targets/ec2_instance_instance_no_wait/tasks/main.yml b/tests/integration/targets/ec2_instance_instance_no_wait/tasks/main.yml index dba54be912c..68b086d6548 100644 --- a/tests/integration/targets/ec2_instance_instance_no_wait/tasks/main.yml +++ b/tests/integration/targets/ec2_instance_instance_no_wait/tasks/main.yml @@ -54,5 +54,5 @@ - name: "Confirm whether the check mode is working normally." assert: that: - - "{{ real_instance_fact.instances | length }} > 0" - - "{{ checkmode_instance_fact.instances | length }} == 0" + - real_instance_fact.instances | length > 0 + - checkmode_instance_fact.instances | length == 0 diff --git a/tests/integration/targets/ec2_instance_metadata_options/tasks/main.yml b/tests/integration/targets/ec2_instance_metadata_options/tasks/main.yml index f51c067b61b..593ade14074 100644 --- a/tests/integration/targets/ec2_instance_metadata_options/tasks/main.yml +++ b/tests/integration/targets/ec2_instance_metadata_options/tasks/main.yml @@ -58,7 +58,7 @@ that: - metadata_options_update is success - metadata_options_update is not changed - - "{{ presented_instance_fact.instances | length }} > 0" - - "'{{ presented_instance_fact.instances.0.state.name }}' in ['running','pending']" - - "'{{ presented_instance_fact.instances.0.metadata_options.http_endpoint }}' == 'enabled'" - - "'{{ presented_instance_fact.instances.0.metadata_options.http_tokens }}' == 'required'" + - presented_instance_fact.instances | length > 0 + - presented_instance_fact.instances.0.state.name in ['running','pending']" + - presented_instance_fact.instances.0.metadata_options.http_endpoint == 'enabled'" + - presented_instance_fact.instances.0.metadata_options.http_tokens == 'required'" diff --git a/tests/integration/targets/ec2_instance_state_config_updates/tasks/main.yml b/tests/integration/targets/ec2_instance_state_config_updates/tasks/main.yml index ae4cee18aa0..eab86e1e961 100644 --- a/tests/integration/targets/ec2_instance_state_config_updates/tasks/main.yml +++ b/tests/integration/targets/ec2_instance_state_config_updates/tasks/main.yml @@ -33,7 +33,7 @@ - '"instances" in create_result' - '"instance_ids" in create_result' - '"spec" in create_result' - - create_result.instances[0].security_groups[0].group_id == "{{ sg.group_id }}" + - create_result.instances[0].security_groups[0].group_id == sg.group_id - create_result.spec.DisableApiTermination == False - name: Change sg and termination protection while instance is in state running @@ -58,7 +58,7 @@ - '"instance_ids" in change_params_result' - '"changes" in change_params_result' - change_params_result.changes[0].DisableApiTermination.Value == True - - change_params_result.changes[1].Groups[0] == "{{ sg2.group_id }}" + - change_params_result.changes[1].Groups[0] == sg2.group_id - name: Verify security groups were updated (can take time to complete) amazon.aws.ec2_instance_info: @@ -91,7 +91,7 @@ - '"changes" in change_state_params_result' - '"stop_success" in change_state_params_result' - '"stop_failed" in change_state_params_result' - - change_state_params_result.instances[0].security_groups[0].group_id == "{{ sg.group_id }}" + - change_state_params_result.instances[0].security_groups[0].group_id == sg.group_id - change_state_params_result.changes[0].DisableApiTermination.Value == False - name: Change sg and termination protection while instance is in state stopped @@ -115,7 +115,7 @@ - '"instances" in change_params_stopped_result' - '"instance_ids" in change_params_stopped_result' - '"changes" in change_params_stopped_result' - - change_params_stopped_result.instances[0].security_groups[0].group_id == "{{ sg2.group_id }}" + - change_params_stopped_result.instances[0].security_groups[0].group_id == sg2.group_id - change_params_stopped_result.changes[0].DisableApiTermination.Value == True - name: Change instance state from stopped to running, and change sg and termination protection @@ -142,5 +142,5 @@ - '"changes" in change_params_start_result' - '"start_success" in change_params_start_result' - '"start_failed" in change_params_start_result' - - change_params_start_result.instances[0].security_groups[0].group_id == "{{ sg.group_id }}" + - change_params_start_result.instances[0].security_groups[0].group_id == sg.group_id - change_params_start_result.changes[0].DisableApiTermination.Value == False diff --git a/tests/integration/targets/ec2_instance_tags_and_vpc_settings/tasks/main.yml b/tests/integration/targets/ec2_instance_tags_and_vpc_settings/tasks/main.yml index fda07227299..757d436d9da 100644 --- a/tests/integration/targets/ec2_instance_tags_and_vpc_settings/tasks/main.yml +++ b/tests/integration/targets/ec2_instance_tags_and_vpc_settings/tasks/main.yml @@ -85,8 +85,8 @@ - name: "Confirm whether the check mode is working normally." assert: that: - - "{{ presented_instance_fact.instances | length }} > 0" - - "{{ checkmode_instance_fact.instances | length }} == 0" + - presented_instance_fact.instances | length > 0 + - checkmode_instance_fact.instances | length == 0 - name: "Alter it by adding tags" ec2_instance: @@ -142,7 +142,7 @@ assert: that: - check_tags.instances[0].tags.Name.startswith(resource_prefix) - - "'{{ check_tags.instances[0].state.name }}' in ['pending', 'running']" + - check_tags.instances[0].state.name in ['pending', 'running'] - name: "Try setting purge_tags to True without specifiying tags (should NOT purge tags)" ec2_instance: diff --git a/tests/integration/targets/ec2_instance_termination_protection/tasks/main.yml b/tests/integration/targets/ec2_instance_termination_protection/tasks/main.yml index 5d3c20f3873..7a0f0949388 100644 --- a/tests/integration/targets/ec2_instance_termination_protection/tasks/main.yml +++ b/tests/integration/targets/ec2_instance_termination_protection/tasks/main.yml @@ -46,9 +46,9 @@ - name: Check return values of the create instance task assert: that: - - "{{ create_instance_results.instances | length }} > 0" - - "'{{ create_instance_results.instances.0.state.name }}' == 'running'" - - "'{{ create_instance_results.spec.DisableApiTermination }}'" + - create_instance_results.instances | length > 0 + - create_instance_results.instances.0.state.name == 'running' + - create_instance_results.spec.DisableApiTermination - name: Get info on termination protection command: 'aws ec2 describe-instance-attribute --attribute disableApiTermination --instance-id {{ instance_id }}' @@ -105,8 +105,8 @@ - name: Check return values of the create instance task assert: that: - - "{{ not create_instance_results.changed }}" - - "{{ create_instance_results.instances | length }} > 0" + - not create_instance_results.changed + - create_instance_results.instances | length > 0 - name: Try to terminate the instance (expected to fail) ec2_instance: @@ -131,7 +131,7 @@ - name: Check return value assert: that: - - "{{ set_termination_protectioncheck_mode_results.changed }}" + - set_termination_protectioncheck_mode_results.changed - name: Get info on termination protection command: 'aws ec2 describe-instance-attribute --attribute disableApiTermination --instance-id {{ instance_id }}' @@ -197,7 +197,7 @@ - name: Check return value assert: that: - - "{{ not set_termination_protection_results.changed }}" + - not set_termination_protection_results.changed - name: Set termination protection to true ec2_instance: @@ -213,8 +213,8 @@ - name: Check return value assert: that: - - "{{ set_termination_protection_results.changed }}" - - "{{ set_termination_protection_results.changes[0].DisableApiTermination.Value }}" + - set_termination_protection_results.changed + - set_termination_protection_results.changes[0].DisableApiTermination.Value - name: Set termination protection to true (idempotent) ec2_instance: @@ -230,7 +230,7 @@ - name: Check return value assert: that: - - "{{ not set_termination_protection_results.changed }}" + - not set_termination_protection_results.changed - name: Set termination protection to false (so we can terminate instance) ec2_instance: diff --git a/tests/integration/targets/ec2_instance_uptime/tasks/main.yml b/tests/integration/targets/ec2_instance_uptime/tasks/main.yml index 7dbc19bd88d..23391ead5b1 100644 --- a/tests/integration/targets/ec2_instance_uptime/tasks/main.yml +++ b/tests/integration/targets/ec2_instance_uptime/tasks/main.yml @@ -28,7 +28,7 @@ - name: "Confirm existence of instance id." assert: that: - - "{{ instance_facts.instances | length }} == 1" + - instance_facts.instances | length == 1 - name: "check using uptime 100 hours - should find nothing" ec2_instance_info: @@ -42,7 +42,7 @@ - name: "Confirm there is no running instance" assert: that: - - "{{ instance_facts.instances | length }} == 0" + - instance_facts.instances | length == 0 - name: Sleep for 61 seconds and continue with play wait_for: @@ -61,4 +61,4 @@ - name: "Confirm there is one running instance" assert: that: - - "{{ instance_facts.instances | length }} == 1" + - instance_facts.instances | length == 1 diff --git a/tests/integration/targets/ec2_key/tasks/main.yml b/tests/integration/targets/ec2_key/tasks/main.yml index dc192517bd7..72baf657a3b 100644 --- a/tests/integration/targets/ec2_key/tasks/main.yml +++ b/tests/integration/targets/ec2_key/tasks/main.yml @@ -591,7 +591,7 @@ assert: that: - 'not result.changed' - - 'result.key.fingerprint == "{{ fingerprint }}"' + - 'result.key.fingerprint == fingerprint' # ============================================================ @@ -605,7 +605,7 @@ assert: that: - 'result.changed' - - 'result.key.fingerprint != "{{ fingerprint }}"' + - 'result.key.fingerprint != fingerprint' # ============================================================ - name: test state=absent (expect changed=true) diff --git a/tests/integration/targets/ec2_metadata_facts/playbooks/test_metadata.yml b/tests/integration/targets/ec2_metadata_facts/playbooks/test_metadata.yml index eba96f916fa..36f48ab6bb6 100644 --- a/tests/integration/targets/ec2_metadata_facts/playbooks/test_metadata.yml +++ b/tests/integration/targets/ec2_metadata_facts/playbooks/test_metadata.yml @@ -12,7 +12,7 @@ that: - ansible_ec2_ami_id == image_id - ansible_ec2_placement_availability_zone == availability_zone - - ansible_ec2_security_groups == "{{ resource_prefix }}-sg" + - ansible_ec2_security_groups == resource_prefix+"-sg" - ansible_ec2_user_data == "None" - ansible_ec2_instance_tags_keys is defined - ansible_ec2_instance_tags_keys | length == 3 diff --git a/tests/integration/targets/ec2_security_group/tasks/group_info.yml b/tests/integration/targets/ec2_security_group/tasks/group_info.yml index fa94abe58ce..1cecc0d7e2f 100644 --- a/tests/integration/targets/ec2_security_group/tasks/group_info.yml +++ b/tests/integration/targets/ec2_security_group/tasks/group_info.yml @@ -23,7 +23,7 @@ that: - group_info_test_setup.tags | length == 1 - "'test' in group_info_test_setup.tags" - - group_info_test_setup.tags.test == "{{ resource_prefix }}_ec2_group_info_module" + - group_info_test_setup.tags.test == resource_prefix+"_ec2_group_info_module" - "'ec2:CreateTags' not in group_info_test_setup.resource_actions" - "'ec2:DeleteTags' not in group_info_test_setup.resource_actions" diff --git a/tests/integration/targets/ec2_snapshot/tasks/main.yml b/tests/integration/targets/ec2_snapshot/tasks/main.yml index cc2019df558..06043e62b3a 100644 --- a/tests/integration/targets/ec2_snapshot/tasks/main.yml +++ b/tests/integration/targets/ec2_snapshot/tasks/main.yml @@ -213,8 +213,8 @@ - tagged_result is changed - tagged_result.tags| length == 2 - tag_info_result.snapshots| length == 1 - - tagged_result.tags.MyTag == "{{ resource_prefix }}" - - '"{{ tagged_result.snapshot_id }}" == "{{ tagged_snapshot_id }}"' + - tagged_result.tags.MyTag == resource_prefix + - tagged_result.snapshot_id == tagged_snapshot_id - name: Get info about all snapshots for this test ec2_snapshot_info: diff --git a/tests/integration/targets/ec2_vol/tasks/main.yml b/tests/integration/targets/ec2_vol/tasks/main.yml index 07992a9bbce..d62c422ef46 100644 --- a/tests/integration/targets/ec2_vol/tasks/main.yml +++ b/tests/integration/targets/ec2_vol/tasks/main.yml @@ -114,7 +114,7 @@ - volume1.volume.attachment_set | length == 0 - not ("Name" in volume1.volume.tags) - not volume1.volume.encrypted - - volume1.volume.tags.ResourcePrefix == "{{ resource_prefix }}" + - volume1.volume.tags.ResourcePrefix == resource_prefix # no idempotency check needed here @@ -142,9 +142,9 @@ - volume2.volume_type == 'io1' - volume2.volume.iops == 101 - volume2.volume.size == 4 - - volume2.volume.tags.Name == "{{ resource_prefix }}" + - volume2.volume.tags.Name == resource_prefix - volume2.volume.encrypted - - volume2.volume.tags.ResourcePrefix == "{{ resource_prefix }}" + - volume2.volume.tags.ResourcePrefix == resource_prefix - name: create another volume (override module defaults) (idempotent) ec2_vol: @@ -393,7 +393,7 @@ that: - new_vol_attach_result.changed - "'volume_id' in new_vol_attach_result" - - new_vol_attach_result.volume_id == "{{ new_vol_attach_result.volume_id }}" + - new_vol_attach_result.volume_id == new_vol_attach_result.volume_id - "'attachment_set' in new_vol_attach_result.volume" - "'create_time' in new_vol_attach_result.volume" - "'id' in new_vol_attach_result.volume" @@ -430,7 +430,7 @@ that: - new_vol_attach_result.changed - "'volume_id' in new_vol_attach_result" - - new_vol_attach_result.volume_id == "{{ new_vol_attach_result.volume_id }}" + - new_vol_attach_result.volume_id == new_vol_attach_result.volume_id - "'attachment_set' in new_vol_attach_result.volume" - "'create_time' in new_vol_attach_result.volume" - "'id' in new_vol_attach_result.volume" @@ -536,7 +536,7 @@ that: - changed_gp3_volume.changed - "'volume_id' in changed_gp3_volume" - - changed_gp3_volume.volume_id == "{{ new_vol_attach_result.volume_id }}" + - changed_gp3_volume.volume_id == new_vol_attach_result.volume_id - "'attachment_set' in changed_gp3_volume.volume" - "'create_time' in changed_gp3_volume.volume" - "'id' in changed_gp3_volume.volume" @@ -570,7 +570,7 @@ that: - not changed_gp3_volume.changed - "'volume_id' in changed_gp3_volume" - - changed_gp3_volume.volume_id == "{{ new_vol_attach_result.volume_id }}" + - changed_gp3_volume.volume_id == new_vol_attach_result.volume_id - "'attachment_set' in changed_gp3_volume.volume" - "'create_time' in changed_gp3_volume.volume" - "'id' in changed_gp3_volume.volume" @@ -721,7 +721,7 @@ - dot_volume.volume.iops == 100 - "'tags' in dot_volume.volume" - (dot_volume.volume.tags | length ) == 2 - - dot_volume.volume.tags["Name"] == "{{ resource_prefix }}_delete_on_terminate" + - dot_volume.volume.tags["Name"] == resource_prefix+"_delete_on_terminate" - dot_volume.volume.tags["Tag Name with Space-and-dash"] == 'Tag Value with Space-and-dash' - name: Gather volume info without any filters @@ -801,7 +801,7 @@ - gp3_volume.volume.throughput == 130 - "'tags' in gp3_volume.volume" - (gp3_volume.volume.tags | length ) == 2 - - gp3_volume.volume.tags["ResourcePrefix"] == "{{ resource_prefix }}" + - gp3_volume.volume.tags["ResourcePrefix"] == resource_prefix - name: Read volume information to validate throughput ec2_vol_info: diff --git a/tests/integration/targets/ec2_vpc_igw/tasks/main.yml b/tests/integration/targets/ec2_vpc_igw/tasks/main.yml index 326a19d4a98..035eb20fa62 100644 --- a/tests/integration/targets/ec2_vpc_igw/tasks/main.yml +++ b/tests/integration/targets/ec2_vpc_igw/tasks/main.yml @@ -36,7 +36,7 @@ - vpc_result.vpc.state == 'available' - '"tags" in vpc_result.vpc' - vpc_result.vpc.tags | length == 2 - - vpc_result.vpc.tags["Name"] == "{{ resource_prefix }}-vpc" + - vpc_result.vpc.tags["Name"] == resource_prefix+"-vpc" - vpc_result.vpc.tags["Description"] == "Created by ansible-test" # ============================================================ diff --git a/tests/integration/targets/ec2_vpc_route_table/tasks/main.yml b/tests/integration/targets/ec2_vpc_route_table/tasks/main.yml index 0592310a41c..746d39b52e0 100644 --- a/tests/integration/targets/ec2_vpc_route_table/tasks/main.yml +++ b/tests/integration/targets/ec2_vpc_route_table/tasks/main.yml @@ -157,7 +157,7 @@ - "'Public' in create_public_table.route_table.tags" - create_public_table.route_table.tags['Public'] == 'true' - create_public_table.route_table.associations | length == 0 - - create_public_table.route_table.vpc_id == "{{ vpc.vpc.id }}" + - create_public_table.route_table.vpc_id == vpc.vpc.id - create_public_table.route_table.propagating_vgws | length == 0 # One route for IPv4, one route for IPv6 - create_public_table.route_table.routes | length == 2 @@ -190,7 +190,7 @@ - "'Public' in create_public_table.route_table.tags" - create_public_table.route_table.tags['Public'] == 'true' - create_public_table.route_table.associations | length == 0 - - create_public_table.route_table.vpc_id == "{{ vpc.vpc.id }}" + - create_public_table.route_table.vpc_id == vpc.vpc.id - create_public_table.route_table.propagating_vgws | length == 0 - create_public_table.route_table.routes | length == 2 @@ -237,7 +237,7 @@ # Amazon-provide IPv6 block - add_routes.route_table.routes | length == 4 - add_routes.route_table.associations | length == 0 - - add_routes.route_table.vpc_id == "{{ vpc.vpc.id }}" + - add_routes.route_table.vpc_id == vpc.vpc.id - add_routes.route_table.propagating_vgws | length == 0 - name: CHECK MODE - re-add route to public route table @@ -1013,7 +1013,7 @@ - "'Public' in create_gateway_table.route_table.tags" - create_gateway_table.route_table.tags['Public'] == 'true' - create_gateway_table.route_table.routes | length == 3 - - "{{ create_gateway_table.route_table.associations | map(attribute='association_state') | selectattr('state', '==', 'associated') | length == 1 }}" + - create_gateway_table.route_table.associations | map(attribute='association_state') | selectattr('state', '==', 'associated') | length == 1 - create_gateway_table.route_table.vpc_id == vpc.vpc.id - create_gateway_table.route_table.propagating_vgws | length == 0 @@ -1057,7 +1057,7 @@ - "'Public' in create_gateway_table.route_table.tags" - create_gateway_table.route_table.tags['Public'] == 'true' - create_gateway_table.route_table.routes | length == 3 - - "{{ create_gateway_table.route_table.associations | map(attribute='association_state') | selectattr('state', '==', 'associated') | length == 0 }}" + - create_gateway_table.route_table.associations | map(attribute='association_state') | selectattr('state', '==', 'associated') | length == 0 - create_gateway_table.route_table.vpc_id == vpc.vpc.id - create_gateway_table.route_table.propagating_vgws | length == 0 @@ -1099,7 +1099,7 @@ - "'Public' in create_gateway_table.route_table.tags" - create_gateway_table.route_table.tags['Public'] == 'true' - create_gateway_table.route_table.routes | length == 3 - - "{{ create_gateway_table.route_table.associations | map(attribute='association_state') | selectattr('state', '==', 'associated') | length == 0 }}" + - create_gateway_table.route_table.associations | map(attribute='association_state') | selectattr('state', '==', 'associated') | length == 0 - create_gateway_table.route_table.vpc_id == vpc.vpc.id - create_gateway_table.route_table.propagating_vgws | length == 0 @@ -1138,7 +1138,7 @@ - create_gateway_table.route_table.tags['Public'] == 'true' - create_gateway_table.route_table.routes | length == 3 - create_gateway_table.route_table.associations | length == 1 - - "{{ create_gateway_table.route_table.associations | map(attribute='association_state') | selectattr('state', '==', 'associated') | length == 1 }}" + - create_gateway_table.route_table.associations | map(attribute='association_state') | selectattr('state', '==', 'associated') | length == 1 - create_gateway_table.route_table.vpc_id == vpc.vpc.id - create_gateway_table.route_table.propagating_vgws | length == 0 @@ -1175,7 +1175,7 @@ - create_gateway_table.route_table.tags['Public'] == 'true' - create_gateway_table.route_table.routes | length == 3 - create_gateway_table.route_table.associations | length == 1 - - "{{ create_gateway_table.route_table.associations | map(attribute='association_state') | selectattr('state', '==', 'associated') | length == 1 }}" + - create_gateway_table.route_table.associations | map(attribute='association_state') | selectattr('state', '==', 'associated') | length == 1 - create_gateway_table.route_table.vpc_id == vpc.vpc.id - create_gateway_table.route_table.propagating_vgws | length == 0 @@ -1219,7 +1219,7 @@ - "'Public' in create_gateway_table.route_table.tags" - create_gateway_table.route_table.tags['Public'] == 'true' - create_gateway_table.route_table.routes | length == 3 - - "{{ create_gateway_table.route_table.associations | map(attribute='association_state') | selectattr('state', '==', 'associated') | length == 0 }}" + - create_gateway_table.route_table.associations | map(attribute='association_state') | selectattr('state', '==', 'associated') | length == 0 - create_gateway_table.route_table.vpc_id == vpc.vpc.id - create_gateway_table.route_table.propagating_vgws | length == 0 @@ -1261,7 +1261,7 @@ - "'Public' in create_gateway_table.route_table.tags" - create_gateway_table.route_table.tags['Public'] == 'true' - create_gateway_table.route_table.routes | length == 3 - - "{{ create_gateway_table.route_table.associations | map(attribute='association_state') | selectattr('state', '==', 'associated') | length == 0 }}" + - create_gateway_table.route_table.associations | map(attribute='association_state') | selectattr('state', '==', 'associated') | length == 0 - create_gateway_table.route_table.vpc_id == vpc.vpc.id - create_gateway_table.route_table.propagating_vgws | length == 0 @@ -1308,7 +1308,7 @@ - create_gateway_table.route_table.tags['Public'] == 'true' - create_gateway_table.route_table.routes | length == 3 - create_gateway_table.route_table.associations | length == 2 - - "{{ create_gateway_table.route_table.associations | map(attribute='association_state') | selectattr('state', '==', 'associated') | length == 1 }}" + - create_gateway_table.route_table.associations | map(attribute='association_state') | selectattr('state', '==', 'associated') | length == 1 - create_gateway_table.route_table.vpc_id == vpc.vpc.id - create_gateway_table.route_table.propagating_vgws | length == 0 @@ -1345,7 +1345,7 @@ - create_gateway_table.route_table.tags['Public'] == 'true' - create_gateway_table.route_table.routes | length == 3 - create_gateway_table.route_table.associations | length == 2 - - "{{ create_gateway_table.route_table.associations | map(attribute='association_state') | selectattr('state', '==', 'associated') | length == 1 }}" + - create_gateway_table.route_table.associations | map(attribute='association_state') | selectattr('state', '==', 'associated') | length == 1 - create_gateway_table.route_table.vpc_id == vpc.vpc.id - create_gateway_table.route_table.propagating_vgws | length == 0 diff --git a/tests/integration/targets/elb_application_lb/tasks/main.yml b/tests/integration/targets/elb_application_lb/tasks/main.yml index 10a8da283da..8f099b1f445 100644 --- a/tests/integration/targets/elb_application_lb/tasks/main.yml +++ b/tests/integration/targets/elb_application_lb/tasks/main.yml @@ -356,7 +356,7 @@ - alb_2.security_groups[0] == sec_group.group_id - alb_2.ip_address_type == 'dualstack' - alb_2.access_logs_s3_enabled | bool - - alb_2.access_logs_s3_bucket == "{{ s3_bucket_name }}" + - alb_2.access_logs_s3_bucket == s3_bucket_name - alb_2.access_logs_s3_prefix == "alb-logs" - not alb_2.routing_http2_enabled | bool - alb_2.routing_http_desync_mitigation_mode == 'monitor' @@ -430,7 +430,7 @@ - alb_2.security_groups[0] == sec_group.group_id - alb_2.ip_address_type == 'dualstack' - alb_2.access_logs_s3_enabled | bool - - alb_2.access_logs_s3_bucket == "{{ s3_bucket_name }}" + - alb_2.access_logs_s3_bucket == s3_bucket_name - alb_2.access_logs_s3_prefix == "alb-logs" - not alb_2.routing_http2_enabled | bool - alb_2.routing_http_desync_mitigation_mode == 'monitor' @@ -821,7 +821,7 @@ that: - alb is changed - alb.listeners[0].rules | length == 2 - - "'1' in {{ alb.listeners[0].rules | map(attribute='priority') }}" + - '1' in +alb.listeners[0].rules | map(attribute='priority') - name: Update an ALB with different listener by adding rule (idempotence) - check_mode elb_application_lb: @@ -877,7 +877,7 @@ that: - alb is not changed - alb.listeners[0].rules | length == 2 - - "'1' in {{ alb.listeners[0].rules | map(attribute='priority') }}" + - '1' in +alb.listeners[0].rules | map(attribute='priority') # ------------------------------------------------------------------------------------------ @@ -935,7 +935,7 @@ that: - alb is changed - alb.listeners[0].rules | length == 2 - - "'2' in {{ alb.listeners[0].rules | map(attribute='priority') }}" + - '2' in +alb.listeners[0].rules | map(attribute='priority') - name: Update an ALB with different listener by modifying rule (idempotence) - check_mode @@ -992,7 +992,7 @@ that: - alb is not changed - alb.listeners[0].rules | length == 2 - - "'2' in {{ alb.listeners[0].rules | map(attribute='priority') }}" + - '2' in +alb.listeners[0].rules | map(attribute='priority') # ------------------------------------------------------------------------------------------ @@ -1034,7 +1034,7 @@ that: - alb is changed - alb.listeners[0].rules | length == 1 - - "'2' not in {{ alb.listeners[0].rules | map(attribute='priority') }}" + - '2' not in +alb.listeners[0].rules | map(attribute='priority') - name: Update an ALB with different listener by deleting rule (idempotence) - check_mode elb_application_lb: @@ -1074,7 +1074,7 @@ that: - alb is not changed - alb.listeners[0].rules | length == 1 - - "'2' not in {{ alb.listeners[0].rules | map(attribute='priority') }}" + - '2' not in +alb.listeners[0].rules | map(attribute='priority') # ------------------------------------------------------------------------------------------ @@ -1161,7 +1161,7 @@ - assert: that: - alb is changed - - 'alb.tags == {"created_by": "ALB test {{ resource_prefix }}"}' + - alb.tags == "created_by": "ALB test" resource_prefix - name: Update an ALB by adding tags (idempotence) - check_mode elb_application_lb: @@ -1190,7 +1190,7 @@ - assert: that: - alb is not changed - - 'alb.tags == {"created_by": "ALB test {{ resource_prefix }}"}' + - 'alb.tags == {"created_by": "ALB test +resource_prefix}' # ------------------------------------------------------------------------------------------ diff --git a/tests/integration/targets/elb_classic_lb/tasks/basic_internal.yml b/tests/integration/targets/elb_classic_lb/tasks/basic_internal.yml index 28207ba6985..35c07408b55 100644 --- a/tests/integration/targets/elb_classic_lb/tasks/basic_internal.yml +++ b/tests/integration/targets/elb_classic_lb/tasks/basic_internal.yml @@ -234,7 +234,7 @@ assert: that: - result is changed - - 'result.elb.name == "{{ elb_name }}"' + - 'result.elb.name == elb_name' - 'result.elb.status == "deleted"' - name: remove the test load balancer completely @@ -248,7 +248,7 @@ assert: that: - result is changed - - 'result.elb.name == "{{ elb_name }}"' + - 'result.elb.name == elb_name' - 'result.elb.status == "deleted"' - name: remove the test load balancer completely (idempotency) (check_mode) @@ -263,7 +263,7 @@ assert: that: - result is not changed - - 'result.elb.name == "{{ elb_name }}"' + - 'result.elb.name == elb_name' - 'result.elb.status == "gone"' - name: remove the test load balancer completely (idempotency) @@ -277,7 +277,7 @@ assert: that: - result is not changed - - 'result.elb.name == "{{ elb_name }}"' + - 'result.elb.name == elb_name' - 'result.elb.status == "gone"' always: diff --git a/tests/integration/targets/elb_classic_lb/tasks/basic_public.yml b/tests/integration/targets/elb_classic_lb/tasks/basic_public.yml index d76f62be89a..5e46031ac90 100644 --- a/tests/integration/targets/elb_classic_lb/tasks/basic_public.yml +++ b/tests/integration/targets/elb_classic_lb/tasks/basic_public.yml @@ -215,7 +215,7 @@ assert: that: - result is changed - - 'result.elb.name == "{{ elb_name }}"' + - 'result.elb.name == elb_name' - 'result.elb.status == "deleted"' - name: remove the test load balancer completely @@ -229,7 +229,7 @@ assert: that: - result is changed - - 'result.elb.name == "{{ elb_name }}"' + - 'result.elb.name == elb_name' - 'result.elb.status == "deleted"' - name: remove the test load balancer completely (idempotency) (check_mode) @@ -244,7 +244,7 @@ assert: that: - result is not changed - - 'result.elb.name == "{{ elb_name }}"' + - 'result.elb.name == elb_name' - 'result.elb.status == "gone"' - name: remove the test load balancer completely (idempotency) @@ -258,7 +258,7 @@ assert: that: - result is not changed - - 'result.elb.name == "{{ elb_name }}"' + - 'result.elb.name == elb_name' - 'result.elb.status == "gone"' always: diff --git a/tests/integration/targets/elb_classic_lb/tasks/https_listeners.yml b/tests/integration/targets/elb_classic_lb/tasks/https_listeners.yml index 27e9c85ee77..35a10a726ff 100644 --- a/tests/integration/targets/elb_classic_lb/tasks/https_listeners.yml +++ b/tests/integration/targets/elb_classic_lb/tasks/https_listeners.yml @@ -73,7 +73,7 @@ - elb_create_result is changed - elb_create_result.elb.status == "created" - elb_create_result.load_balancer | length == 0 - - "'elasticloadbalancing:CreateLoadBalancer' not in {{ elb_create_result.resource_actions }}" + - 'elasticloadbalancing:CreateLoadBalancer' not in elb_create_result.resource_actions - name: Create a classic ELB with https method listeners amazon.aws.elb_classic_lb: "{{ elb_definition }}" @@ -83,7 +83,7 @@ - elb_create_result is changed - elb_create_result.elb.status == "created" - elb_create_result.load_balancer | length != 0 - - "'elasticloadbalancing:CreateLoadBalancer' in {{ elb_create_result.resource_actions }}" + - 'elasticloadbalancing:CreateLoadBalancer' in elb_create_result.resource_actions - name: Create a classic ELB with https method listeners - idempotency - check_mode amazon.aws.elb_classic_lb: "{{ elb_definition }}" @@ -95,7 +95,7 @@ - elb_create_result.elb.status != "created" - elb_create_result.elb.status == "exists" - elb_create_result.load_balancer | length != 0 - - "'elasticloadbalancing:CreateLoadBalancer' not in {{ elb_create_result.resource_actions }}" + - 'elasticloadbalancing:CreateLoadBalancer' not in elb_create_result.resource_actions - name: Create a classic ELB with https method listeners - idempotency amazon.aws.elb_classic_lb: "{{ elb_definition }}" @@ -106,7 +106,7 @@ - elb_create_result.elb.status != "created" - elb_create_result.elb.status == "exists" - elb_create_result.load_balancer | length != 0 - - "'elasticloadbalancing:CreateLoadBalancer' not in {{ elb_create_result.resource_actions }}" + - 'elasticloadbalancing:CreateLoadBalancer' not in elb_create_result.resource_actions # Remove ELB and certificate created during this test diff --git a/tests/integration/targets/iam_instance_profile/tasks/main.yml b/tests/integration/targets/iam_instance_profile/tasks/main.yml index 5fc6eb109ba..fcf9480fd1d 100644 --- a/tests/integration/targets/iam_instance_profile/tasks/main.yml +++ b/tests/integration/targets/iam_instance_profile/tasks/main.yml @@ -270,10 +270,10 @@ - assert: that: - profile_info.iam_instance_profiles | length >= 4 - - '"{{ test_role }}" in profile_names' - - '"{{ test_role }}-2" in profile_names' - - '"{{ test_profile }}" in profile_names' - - '"{{ test_profile_complex }}" in profile_names' + - 'test_role in profile_names' + - 'test_role+"-2" in profile_names' + - 'test_profile in profile_names' + - 'test_profile_complex in profile_names' - '"arn" in complex_profile' - '"create_date" in complex_profile' @@ -291,7 +291,7 @@ - complex_profile.roles[0].path == test_path - '"role_id" in complex_profile.roles[0]' - '"role_name" in complex_profile.roles[0]' - - complex_profile.roles[0].role_name == "{{ test_role }}-2" + - complex_profile.roles[0].role_name == test_role+"-2" vars: profile_names: '{{ profile_info.iam_instance_profiles | map(attribute="instance_profile_name") }}' complex_profile: '{{ profile_info.iam_instance_profiles | selectattr("instance_profile_name", "match", test_profile_complex) | first}}' @@ -304,9 +304,9 @@ - assert: that: - profile_info.iam_instance_profiles | length == 3 - - '"{{ test_role }}" in profile_names' - - '"{{ test_role }}-2" in profile_names' - - '"{{ test_profile_complex }}" in profile_names' + - 'test_role in profile_names' + - 'test_role+"-2" in profile_names' + - 'test_profile_complex in profile_names' - '"arn" in complex_profile' - '"create_date" in complex_profile' @@ -324,7 +324,7 @@ - complex_profile.roles[0].path == test_path - '"role_id" in complex_profile.roles[0]' - '"role_name" in complex_profile.roles[0]' - - complex_profile.roles[0].role_name == "{{ test_role }}-2" + - complex_profile.roles[0].role_name == test_role+"-2" vars: profile_names: '{{ profile_info.iam_instance_profiles | map(attribute="instance_profile_name") }}' complex_profile: '{{ profile_info.iam_instance_profiles | selectattr("instance_profile_name", "match", test_profile_complex) | first}}' @@ -337,7 +337,7 @@ - assert: that: - profile_info.iam_instance_profiles | length == 1 - - '"{{ test_profile_complex }}" in profile_names' + - 'test_profile_complex in profile_names' - '"arn" in complex_profile' - '"create_date" in complex_profile' @@ -357,7 +357,7 @@ - complex_profile.roles[0].path == test_path - '"role_id" in complex_profile.roles[0]' - '"role_name" in complex_profile.roles[0]' - - complex_profile.roles[0].role_name == "{{ test_role }}-2" + - complex_profile.roles[0].role_name == test_role+"-2" - '"tags" in complex_profile.roles[0]' - complex_profile.roles[0].tags == {} vars: diff --git a/tests/integration/targets/rds_cluster_create/tasks/main.yaml b/tests/integration/targets/rds_cluster_create/tasks/main.yaml index 09ef74acd98..ed59e649621 100644 --- a/tests/integration/targets/rds_cluster_create/tasks/main.yaml +++ b/tests/integration/targets/rds_cluster_create/tasks/main.yaml @@ -61,17 +61,17 @@ - _result_create_db_cluster.copy_tags_to_snapshot == false - "'db_cluster_arn' in _result_create_db_cluster" - "'db_cluster_identifier' in _result_create_db_cluster" - - _result_create_db_cluster.db_cluster_identifier == "{{ cluster_id }}" + - _result_create_db_cluster.db_cluster_identifier == cluster_id - "'db_cluster_parameter_group' in _result_create_db_cluster" - "'db_cluster_resource_id' in _result_create_db_cluster" - "'endpoint' in _result_create_db_cluster" - "'engine' in _result_create_db_cluster" - - _result_create_db_cluster.engine == "{{ engine }}" + - _result_create_db_cluster.engine == engine - "'engine_mode' in _result_create_db_cluster" - _result_create_db_cluster.engine_mode == "provisioned" - "'engine_version' in _result_create_db_cluster" - "'master_username' in _result_create_db_cluster" - - _result_create_db_cluster.master_username == "{{ username }}" + - _result_create_db_cluster.master_username == username - "'port' in _result_create_db_cluster" - _result_create_db_cluster.port == {{ port }} - "'status' in _result_create_db_cluster" diff --git a/tests/integration/targets/rds_cluster_create_sgs/tasks/main.yaml b/tests/integration/targets/rds_cluster_create_sgs/tasks/main.yaml index 040444d4964..5bde01514ca 100644 --- a/tests/integration/targets/rds_cluster_create_sgs/tasks/main.yaml +++ b/tests/integration/targets/rds_cluster_create_sgs/tasks/main.yaml @@ -70,17 +70,17 @@ - _result_create_db_cluster.copy_tags_to_snapshot == false - "'db_cluster_arn' in _result_create_db_cluster" - "'db_cluster_identifier' in _result_create_db_cluster" - - _result_create_db_cluster.db_cluster_identifier == "{{ cluster_id }}" + - _result_create_db_cluster.db_cluster_identifier == cluster_id - "'db_cluster_parameter_group' in _result_create_db_cluster" - "'db_cluster_resource_id' in _result_create_db_cluster" - "'endpoint' in _result_create_db_cluster" - "'engine' in _result_create_db_cluster" - - _result_create_db_cluster.engine == "{{ engine }}" + - _result_create_db_cluster.engine == engine - "'engine_mode' in _result_create_db_cluster" - _result_create_db_cluster.engine_mode == "provisioned" - "'engine_version' in _result_create_db_cluster" - "'master_username' in _result_create_db_cluster" - - _result_create_db_cluster.master_username == "{{ username }}" + - _result_create_db_cluster.master_username == username - "'port' in _result_create_db_cluster" - _result_create_db_cluster.port == {{ port }} - "'status' in _result_create_db_cluster" @@ -125,17 +125,17 @@ - _result_create_db_cluster.copy_tags_to_snapshot == false - "'db_cluster_arn' in _result_create_db_cluster" - "'db_cluster_identifier' in _result_create_db_cluster" - - _result_create_db_cluster.db_cluster_identifier == "{{ cluster_id }}" + - _result_create_db_cluster.db_cluster_identifier == cluster_id - "'db_cluster_parameter_group' in _result_create_db_cluster" - "'db_cluster_resource_id' in _result_create_db_cluster" - "'endpoint' in _result_create_db_cluster" - "'engine' in _result_create_db_cluster" - - _result_create_db_cluster.engine == "{{ engine }}" + - _result_create_db_cluster.engine == engine - "'engine_mode' in _result_create_db_cluster" - _result_create_db_cluster.engine_mode == "provisioned" - "'engine_version' in _result_create_db_cluster" - "'master_username' in _result_create_db_cluster" - - _result_create_db_cluster.master_username == "{{ username }}" + - _result_create_db_cluster.master_username == username - "'port' in _result_create_db_cluster" - _result_create_db_cluster.port == {{ port }} - "'status' in _result_create_db_cluster" diff --git a/tests/integration/targets/rds_cluster_modify/tasks/main.yaml b/tests/integration/targets/rds_cluster_modify/tasks/main.yaml index d7118807fe8..aa3f3b3504a 100644 --- a/tests/integration/targets/rds_cluster_modify/tasks/main.yaml +++ b/tests/integration/targets/rds_cluster_modify/tasks/main.yaml @@ -58,7 +58,7 @@ - _result_create_source_db_cluster.engine_mode == "provisioned" - "'engine_version' in _result_create_source_db_cluster" - "'master_username' in _result_create_source_db_cluster" - - _result_create_source_db_cluster.master_username == "{{ username }}" + - _result_create_source_db_cluster.master_username == username - "'port' in _result_create_source_db_cluster" - _result_create_source_db_cluster.port == {{ port }} - "'status' in _result_create_source_db_cluster" @@ -93,7 +93,7 @@ - _result_modify_password.engine_mode == "provisioned" - "'engine_version' in _result_modify_password" - "'master_username' in _result_modify_password" - - _result_modify_password.master_username == "{{ username }}" + - _result_modify_password.master_username == username - "'port' in _result_create_source_db_cluster" - _result_modify_password.port == {{ port }} - "'status' in _result_modify_password" @@ -126,7 +126,7 @@ - _result_modify_port.engine_mode == "provisioned" - "'engine_version' in _result_modify_port" - "'master_username' in _result_modify_port" - - _result_modify_port.master_username == "{{ username }}" + - _result_modify_port.master_username == username - "'port' in _result_modify_port" - _result_modify_port.port == {{ new_port }} - "'status' in _result_modify_port" @@ -161,7 +161,7 @@ - _result_modify_id.engine_mode == "provisioned" - "'engine_version' in _result_modify_id" - "'master_username' in _result_modify_id" - - _result_modify_id.master_username == "{{ username }}" + - _result_modify_id.master_username == username - "'port' in _result_modify_id" - _result_modify_id.port == {{ new_port }} - "'status' in _result_modify_id" @@ -220,7 +220,7 @@ - _result_modify_db_parameter_group_name.engine_mode == "provisioned" - "'engine_version' in _result_modify_db_parameter_group_name" - "'master_username' in _result_modify_db_parameter_group_name" - - _result_modify_db_parameter_group_name.master_username == "{{ username }}" + - _result_modify_db_parameter_group_name.master_username == username - "'port' in _result_modify_db_parameter_group_name" - _result_modify_db_parameter_group_name.db_cluster_parameter_group == "{{ new_db_parameter_group_name }}" diff --git a/tests/integration/targets/rds_cluster_promote/tasks/main.yaml b/tests/integration/targets/rds_cluster_promote/tasks/main.yaml index bec0bb9ccd9..4b571427ecb 100644 --- a/tests/integration/targets/rds_cluster_promote/tasks/main.yaml +++ b/tests/integration/targets/rds_cluster_promote/tasks/main.yaml @@ -51,12 +51,12 @@ - "'db_cluster_resource_id' in _result_create_src_db_cluster" - "'endpoint' in _result_create_src_db_cluster" - "'engine' in _result_create_src_db_cluster" - - _result_create_src_db_cluster.engine == "{{ engine }}" + - _result_create_src_db_cluster.engine == engine - "'engine_mode' in _result_create_src_db_cluster" - _result_create_src_db_cluster.engine_mode == "serverless" - "'engine_version' in _result_create_src_db_cluster" - "'master_username' in _result_create_src_db_cluster" - - _result_create_src_db_cluster.master_username == "{{ username }}" + - _result_create_src_db_cluster.master_username == username - "'port' in _result_create_src_db_cluster" - _result_create_src_db_cluster.port == {{ port }} - "'status' in _result_create_src_db_cluster" @@ -107,12 +107,12 @@ - "'db_cluster_resource_id' in _result_create_replica_db_cluster" - "'endpoint' in _result_create_replica_db_cluster" - "'engine' in _result_create_replica_db_cluster" - - _result_create_replica_db_cluster.engine == "{{ engine }}" + - _result_create_replica_db_cluster.engine == engine - "'engine_mode' in _result_create_replica_db_cluster" - _result_create_replica_db_cluster.engine_mode == "serverless" - "'engine_version' in _result_create_replica_db_cluster" - "'master_username' in _result_create_replica_db_cluster" - - _result_create_replica_db_cluster.master_username == "{{ username }}" + - _result_create_replica_db_cluster.master_username == username - "'port' in _result_create_replica_db_cluster" - _result_create_replica_db_cluster.port == {{ port }} - "'status' in _result_create_replica_db_cluster" diff --git a/tests/integration/targets/rds_cluster_restore/tasks/main.yaml b/tests/integration/targets/rds_cluster_restore/tasks/main.yaml index d2ddab2918e..d4241c80c51 100644 --- a/tests/integration/targets/rds_cluster_restore/tasks/main.yaml +++ b/tests/integration/targets/rds_cluster_restore/tasks/main.yaml @@ -40,17 +40,17 @@ - _result_create_source_db_cluster.copy_tags_to_snapshot == false - "'db_cluster_arn' in _result_create_source_db_cluster" - "'db_cluster_identifier' in _result_create_source_db_cluster" - - _result_create_source_db_cluster.db_cluster_identifier == "{{ cluster_id }}" + - _result_create_source_db_cluster.db_cluster_identifier == cluster_id - "'db_cluster_parameter_group' in _result_create_source_db_cluster" - "'db_cluster_resource_id' in _result_create_source_db_cluster" - "'endpoint' in _result_create_source_db_cluster" - "'engine' in _result_create_source_db_cluster" - - _result_create_source_db_cluster.engine == "{{ engine }}" + - _result_create_source_db_cluster.engine == engine - "'engine_mode' in _result_create_source_db_cluster" - _result_create_source_db_cluster.engine_mode == "provisioned" - "'engine_version' in _result_create_source_db_cluster" - "'master_username' in _result_create_source_db_cluster" - - _result_create_source_db_cluster.master_username == "{{ username }}" + - _result_create_source_db_cluster.master_username == username - "'port' in _result_create_source_db_cluster" - _result_create_source_db_cluster.port == {{ port }} - "'status' in _result_create_source_db_cluster" @@ -87,12 +87,12 @@ - "'db_cluster_resource_id' in _result_restored_db_cluster" - "'endpoint' in _result_restored_db_cluster" - "'engine' in _result_restored_db_cluster" - - _result_restored_db_cluster.engine == "{{ engine }}" + - _result_restored_db_cluster.engine == engine - "'engine_mode' in _result_restored_db_cluster" - _result_restored_db_cluster.engine_mode == "provisioned" - "'engine_version' in _result_restored_db_cluster" - "'master_username' in _result_restored_db_cluster" - - _result_restored_db_cluster.master_username == "{{ username }}" + - _result_restored_db_cluster.master_username == username - "'port' in _result_restored_db_cluster" - _result_restored_db_cluster.port == {{ port }} - "'status' in _result_restored_db_cluster" @@ -156,12 +156,12 @@ - "'db_cluster_resource_id' in _result_restored_db_cluster" - "'endpoint' in _result_restored_db_cluster" - "'engine' in _result_restored_db_cluster" - - _result_restored_db_cluster.engine == "{{ engine }}" + - _result_restored_db_cluster.engine == engine - "'engine_mode' in _result_restored_db_cluster" - _result_restored_db_cluster.engine_mode == "provisioned" - "'engine_version' in _result_restored_db_cluster" - "'master_username' in _result_restored_db_cluster" - - _result_restored_db_cluster.master_username == "{{ username }}" + - _result_restored_db_cluster.master_username == username - "'port' in _result_restored_db_cluster" - _result_restored_db_cluster.port == {{ port }} - "'status' in _result_restored_db_cluster" diff --git a/tests/integration/targets/rds_cluster_snapshot/tasks/main.yml b/tests/integration/targets/rds_cluster_snapshot/tasks/main.yml index 01030b7d831..9b19ec12dbb 100644 --- a/tests/integration/targets/rds_cluster_snapshot/tasks/main.yml +++ b/tests/integration/targets/rds_cluster_snapshot/tasks/main.yml @@ -27,19 +27,19 @@ - "'cluster_create_time' in _result_create_source_db_cluster" - _result_create_source_db_cluster.copy_tags_to_snapshot == false - "'db_cluster_arn' in _result_create_source_db_cluster" - - _result_create_source_db_cluster.db_cluster_identifier == "{{ cluster_id }}" + - _result_create_source_db_cluster.db_cluster_identifier == cluster_id - "'db_cluster_parameter_group' in _result_create_source_db_cluster" - "'db_cluster_resource_id' in _result_create_source_db_cluster" - "'endpoint' in _result_create_source_db_cluster" - "'engine' in _result_create_source_db_cluster" - - _result_create_source_db_cluster.engine == "{{ engine }}" + - _result_create_source_db_cluster.engine == engine - "'engine_mode' in _result_create_source_db_cluster" - _result_create_source_db_cluster.engine_mode == "provisioned" - "'engine_version' in _result_create_source_db_cluster" - "'master_username' in _result_create_source_db_cluster" - - _result_create_source_db_cluster.master_username == "{{ username }}" + - _result_create_source_db_cluster.master_username == username - "'port' in _result_create_source_db_cluster" - - "_result_create_source_db_cluster.port == {{ port }}" + - _result_create_source_db_cluster.port == port - "'status' in _result_create_source_db_cluster" - _result_create_source_db_cluster.status == "available" - "'tags' in _result_create_source_db_cluster" @@ -81,19 +81,19 @@ - "'allocated_storage' in _result_cluster_snapshot" - "'cluster_create_time' in _result_cluster_snapshot" - "'db_cluster_identifier' in _result_cluster_snapshot" - - _result_cluster_snapshot.db_cluster_identifier == "{{ cluster_id }}" + - _result_cluster_snapshot.db_cluster_identifier == cluster_id - "'db_cluster_snapshot_identifier' in _result_cluster_snapshot" - - _result_cluster_snapshot.db_cluster_snapshot_identifier == "{{ snapshot_id }}" + - _result_cluster_snapshot.db_cluster_snapshot_identifier == snapshot_id - "'db_cluster_snapshot_arn' in _result_cluster_snapshot" - "'engine' in _result_cluster_snapshot" - - _result_cluster_snapshot.engine == "{{ engine }}" + - _result_cluster_snapshot.engine == engine # - "'engine_mode' in _result_cluster_snapshot" # - _result_cluster_snapshot.engine_mode == "serverless" - "'engine_version' in _result_cluster_snapshot" - "'iam_database_authentication_enabled' in _result_cluster_snapshot" - "'license_model' in _result_cluster_snapshot" - "'master_username' in _result_cluster_snapshot" - - _result_cluster_snapshot.master_username == "{{ username }}" + - _result_cluster_snapshot.master_username == username - "'snapshot_create_time' in _result_cluster_snapshot" - "'snapshot_type' in _result_cluster_snapshot" - "'status' in _result_cluster_snapshot" @@ -110,8 +110,8 @@ - assert: that: - _result_cluster_snapshot_info is successful - - _result_cluster_snapshot_info.cluster_snapshots[0].db_cluster_identifier == "{{ cluster_id }}" - - _result_cluster_snapshot_info.cluster_snapshots[0].db_cluster_snapshot_identifier == "{{ snapshot_id }}" + - _result_cluster_snapshot_info.cluster_snapshots[0].db_cluster_identifier == cluster_id + - _result_cluster_snapshot_info.cluster_snapshots[0].db_cluster_snapshot_identifier == snapshot_id - name: Get info of the existing DB cluster rds_cluster_info: @@ -146,14 +146,14 @@ - "'db_cluster_resource_id' in _result_create_source_db_cluster" - "'endpoint' in _result_create_source_db_cluster" - "'engine' in _result_create_source_db_cluster" - - _result_create_source_db_cluster.engine == "{{ engine }}" + - _result_create_source_db_cluster.engine == engine - "'engine_mode' in _result_create_source_db_cluster" - _result_create_source_db_cluster.engine_mode == "provisioned" - "'engine_version' in _result_create_source_db_cluster" - "'master_username' in _result_create_source_db_cluster" - - _result_create_source_db_cluster.master_username == "{{ username }}" + - _result_create_source_db_cluster.master_username == username - "'port' in _result_create_source_db_cluster" - - "_result_create_source_db_cluster.port == {{ port }}" + - "_result_create_source_db_cluster.port == port - "'status' in _result_create_source_db_cluster" - _result_create_source_db_cluster.status == "available" - "'tags' in _result_create_source_db_cluster" @@ -178,14 +178,14 @@ - _result_cluster_snapshot.db_cluster_snapshot_identifier == "{{ snapshot_id }}-b" - "'db_cluster_snapshot_arn' in _result_cluster_snapshot" - "'engine' in _result_cluster_snapshot" - - _result_cluster_snapshot.engine == "{{ engine }}" + - _result_cluster_snapshot.engine == engine # - "'engine_mode' in _result_cluster_snapshot" # - _result_cluster_snapshot.engine_mode == "serverless" - "'engine_version' in _result_cluster_snapshot" - "'iam_database_authentication_enabled' in _result_cluster_snapshot" - "'license_model' in _result_cluster_snapshot" - "'master_username' in _result_cluster_snapshot" - - _result_cluster_snapshot.master_username == "{{ username }}" + - _result_cluster_snapshot.master_username == username - "'snapshot_create_time' in _result_cluster_snapshot" - "'snapshot_type' in _result_cluster_snapshot" - "'status' in _result_cluster_snapshot" @@ -251,19 +251,19 @@ - "'allocated_storage' in _result_cluster_snapshot" - "'cluster_create_time' in _result_cluster_snapshot" - "'db_cluster_identifier' in _result_cluster_snapshot" - - _result_cluster_snapshot.db_cluster_identifier == "{{ cluster_id }}" + - _result_cluster_snapshot.db_cluster_identifier == cluster_id - "'db_cluster_snapshot_identifier' in _result_cluster_snapshot" - _result_cluster_snapshot.db_cluster_snapshot_identifier == "{{ snapshot_id }}-b" - "'db_cluster_snapshot_arn' in _result_cluster_snapshot" - "'engine' in _result_cluster_snapshot" - - _result_cluster_snapshot.engine == "{{ engine }}" + - _result_cluster_snapshot.engine == engine # - "'engine_mode' in _result_cluster_snapshot" # - _result_cluster_snapshot.engine_mode == "serverless" - "'engine_version' in _result_cluster_snapshot" - "'iam_database_authentication_enabled' in _result_cluster_snapshot" - "'license_model' in _result_cluster_snapshot" - "'master_username' in _result_cluster_snapshot" - - _result_cluster_snapshot.master_username == "{{ username }}" + - _result_cluster_snapshot.master_username == username - "'snapshot_create_time' in _result_cluster_snapshot" - "'snapshot_type' in _result_cluster_snapshot" - "'status' in _result_cluster_snapshot" @@ -306,19 +306,19 @@ - "'allocated_storage' in _result_cluster_snapshot" - "'cluster_create_time' in _result_cluster_snapshot" - "'db_cluster_identifier' in _result_cluster_snapshot" - - _result_cluster_snapshot.db_cluster_identifier == "{{ cluster_id }}" + - _result_cluster_snapshot.db_cluster_identifier == cluster_id - "'db_cluster_snapshot_identifier' in _result_cluster_snapshot" - _result_cluster_snapshot.db_cluster_snapshot_identifier == "{{ snapshot_id }}-b" - "'db_cluster_snapshot_arn' in _result_cluster_snapshot" - "'engine' in _result_cluster_snapshot" - - _result_cluster_snapshot.engine == "{{ engine }}" + - _result_cluster_snapshot.engine == engine # - "'engine_mode' in _result_cluster_snapshot" # - _result_cluster_snapshot.engine_mode == "serverless" - "'engine_version' in _result_cluster_snapshot" - "'iam_database_authentication_enabled' in _result_cluster_snapshot" - "'license_model' in _result_cluster_snapshot" - "'master_username' in _result_cluster_snapshot" - - _result_cluster_snapshot.master_username == "{{ username }}" + - _result_cluster_snapshot.master_username == username - "'snapshot_create_time' in _result_cluster_snapshot" - "'snapshot_type' in _result_cluster_snapshot" - "'status' in _result_cluster_snapshot" @@ -346,19 +346,19 @@ - "'allocated_storage' in _result_cluster_snapshot" - "'cluster_create_time' in _result_cluster_snapshot" - "'db_cluster_identifier' in _result_cluster_snapshot" - - _result_cluster_snapshot.db_cluster_identifier == "{{ cluster_id }}" + - _result_cluster_snapshot.db_cluster_identifier == cluster_id - "'db_cluster_snapshot_identifier' in _result_cluster_snapshot" - _result_cluster_snapshot.db_cluster_snapshot_identifier == "{{ snapshot_id }}-b" - "'db_cluster_snapshot_arn' in _result_cluster_snapshot" - "'engine' in _result_cluster_snapshot" - - _result_cluster_snapshot.engine == "{{ engine }}" + - _result_cluster_snapshot.engine == engine # - "'engine_mode' in _result_cluster_snapshot" # - _result_cluster_snapshot.engine_mode == "serverless" - "'engine_version' in _result_cluster_snapshot" - "'iam_database_authentication_enabled' in _result_cluster_snapshot" - "'license_model' in _result_cluster_snapshot" - "'master_username' in _result_cluster_snapshot" - - _result_cluster_snapshot.master_username == "{{ username }}" + - _result_cluster_snapshot.master_username == username - "'snapshot_create_time' in _result_cluster_snapshot" - "'snapshot_type' in _result_cluster_snapshot" - "'status' in _result_cluster_snapshot" @@ -413,8 +413,8 @@ - assert: that: - _result_cluster_copy_snapshot.changed - - _result_cluster_copy_snapshot.db_cluster_identifier == "{{ cluster_id }}" - - _result_cluster_copy_snapshot.source_db_cluster_snapshot_arn == "{{ _snapshot_arn }}" + - _result_cluster_copy_snapshot.db_cluster_identifier == cluster_id + - _result_cluster_copy_snapshot.source_db_cluster_snapshot_arn == _snapshot_arn - _result_cluster_copy_snapshot.db_cluster_snapshot_identifier == "{{ snapshot_id }}-copy" - "'tags' in _result_cluster_copy_snapshot" - _result_cluster_copy_snapshot.tags | length == 3 @@ -446,8 +446,8 @@ - assert: that: - not _result_cluster_copy_snapshot.changed - - _result_cluster_copy_snapshot.db_cluster_identifier == "{{ cluster_id }}" - - _result_cluster_copy_snapshot.source_db_cluster_snapshot_arn == "{{ _snapshot_arn }}" + - _result_cluster_copy_snapshot.db_cluster_identifier == cluster_id + - _result_cluster_copy_snapshot.source_db_cluster_snapshot_arn == _snapshot_arn - _result_cluster_copy_snapshot.db_cluster_snapshot_identifier == "{{ snapshot_id }}-copy" - "'tags' in _result_cluster_copy_snapshot" - _result_cluster_copy_snapshot.tags | length == 3 diff --git a/tests/integration/targets/rds_cluster_states/tasks/main.yml b/tests/integration/targets/rds_cluster_states/tasks/main.yml index 7ec91a3d5de..00d15fe9d39 100644 --- a/tests/integration/targets/rds_cluster_states/tasks/main.yml +++ b/tests/integration/targets/rds_cluster_states/tasks/main.yml @@ -50,7 +50,7 @@ - _result_create_source_db_cluster.engine_mode == "provisioned" - "'engine_version' in _result_create_source_db_cluster" - "'master_username' in _result_create_source_db_cluster" - - _result_create_source_db_cluster.master_username == "{{ username }}" + - _result_create_source_db_cluster.master_username == username - "'port' in _result_create_source_db_cluster" - "'status' in _result_create_source_db_cluster" - _result_create_source_db_cluster.status == "available" @@ -192,17 +192,17 @@ - "'cluster_create_time' in mysql_cluster" - mysql_cluster.copy_tags_to_snapshot == false - "'db_cluster_arn' in mysql_cluster" - - mysql_cluster.db_cluster_identifier == "{{ mysql_cluster_id }}" + - mysql_cluster.db_cluster_identifier == mysql_cluster_id - "'db_cluster_parameter_group' in mysql_cluster" - "'db_cluster_resource_id' in mysql_cluster" - "'endpoint' in mysql_cluster" - "'engine' in mysql_cluster" - - mysql_cluster.engine == "{{ mysql_engine }}" + - mysql_cluster.engine == mysql_engine - "'engine_mode' in mysql_cluster" - mysql_cluster.engine_mode == "provisioned" - "'engine_version' in mysql_cluster" - "'master_username' in mysql_cluster" - - mysql_cluster.master_username == "{{ username }}" + - mysql_cluster.master_username == username - "'port' in mysql_cluster" - "'status' in mysql_cluster" - mysql_cluster.status == "available" diff --git a/tests/integration/targets/rds_cluster_tag/tasks/main.yaml b/tests/integration/targets/rds_cluster_tag/tasks/main.yaml index e1fecb5b6d7..fbfa30bc20e 100644 --- a/tests/integration/targets/rds_cluster_tag/tasks/main.yaml +++ b/tests/integration/targets/rds_cluster_tag/tasks/main.yaml @@ -38,17 +38,17 @@ - _result_create_db_cluster.copy_tags_to_snapshot == false - "'db_cluster_arn' in _result_create_db_cluster" - "'db_cluster_identifier' in _result_create_db_cluster" - - _result_create_db_cluster.db_cluster_identifier == "{{ cluster_id }}" + - _result_create_db_cluster.db_cluster_identifier == cluster_id - "'db_cluster_parameter_group' in _result_create_db_cluster" - "'db_cluster_resource_id' in _result_create_db_cluster" - "'endpoint' in _result_create_db_cluster" - "'engine' in _result_create_db_cluster" - - _result_create_db_cluster.engine == "{{ engine }}" + - _result_create_db_cluster.engine == engine - "'engine_mode' in _result_create_db_cluster" - _result_create_db_cluster.engine_mode == "provisioned" - "'engine_version' in _result_create_db_cluster" - "'master_username' in _result_create_db_cluster" - - _result_create_db_cluster.master_username == "{{ username }}" + - _result_create_db_cluster.master_username == username - "'port' in _result_create_db_cluster" - _result_create_db_cluster.port == {{ port }} - "'status' in _result_create_db_cluster" @@ -80,17 +80,17 @@ - _result_tag_db_cluster.copy_tags_to_snapshot == false - "'db_cluster_arn' in _result_tag_db_cluster" - "'db_cluster_identifier' in _result_tag_db_cluster" - - _result_tag_db_cluster.db_cluster_identifier == "{{ cluster_id }}" + - _result_tag_db_cluster.db_cluster_identifier == cluster_id - "'db_cluster_parameter_group' in _result_tag_db_cluster" - "'db_cluster_resource_id' in _result_tag_db_cluster" - "'endpoint' in _result_tag_db_cluster" - "'engine' in _result_tag_db_cluster" - - _result_tag_db_cluster.engine == "{{ engine }}" + - _result_tag_db_cluster.engine == engine - "'engine_mode' in _result_tag_db_cluster" - _result_tag_db_cluster.engine_mode == "provisioned" - "'engine_version' in _result_tag_db_cluster" - "'master_username' in _result_tag_db_cluster" - - _result_tag_db_cluster.master_username == "{{ username }}" + - _result_tag_db_cluster.master_username == username - "'port' in _result_tag_db_cluster" - _result_tag_db_cluster.port == {{ port }} - "'status' in _result_tag_db_cluster" @@ -100,7 +100,7 @@ - _result_tag_db_cluster.tags | length == 2 - _result_tag_db_cluster.tags["Created_By"] == "{{ tags_create["Created_By"] }}" - - _result_tag_db_cluster.tags["Name"] == "{{ tags_create["Name"] }}" + - _result_tag_db_cluster.tags["Name"] == tags_create["Name"] - "'vpc_security_groups' in _result_tag_db_cluster" - name: Add a tag and remove a tag (purge_tags is True) @@ -119,17 +119,17 @@ - _result_tag_db_cluster.copy_tags_to_snapshot == false - "'db_cluster_arn' in _result_tag_db_cluster" - "'db_cluster_identifier' in _result_tag_db_cluster" - - _result_tag_db_cluster.db_cluster_identifier == "{{ cluster_id }}" + - _result_tag_db_cluster.db_cluster_identifier == cluster_id - "'db_cluster_parameter_group' in _result_tag_db_cluster" - "'db_cluster_resource_id' in _result_tag_db_cluster" - "'endpoint' in _result_tag_db_cluster" - "'engine' in _result_tag_db_cluster" - - _result_tag_db_cluster.engine == "{{ engine }}" + - _result_tag_db_cluster.engine == engine - "'engine_mode' in _result_tag_db_cluster" - _result_tag_db_cluster.engine_mode == "provisioned" - "'engine_version' in _result_tag_db_cluster" - "'master_username' in _result_tag_db_cluster" - - _result_tag_db_cluster.master_username == "{{ username }}" + - _result_tag_db_cluster.master_username == username - "'port' in _result_tag_db_cluster" - _result_tag_db_cluster.port == {{ port }} - "'status' in _result_tag_db_cluster" @@ -137,7 +137,7 @@ - _result_tag_db_cluster.storage_encrypted == false - "'tags' in _result_tag_db_cluster" - _result_tag_db_cluster.tags | length == 2 - - _result_tag_db_cluster.tags["Name"] == "{{ tags_patch['Name'] }}" + - _result_tag_db_cluster.tags["Name"] == tags_patch['Name'] - "'vpc_security_groups' in _result_tag_db_cluster" - name: Purge a tag from the cluster (CHECK MODE) @@ -174,17 +174,17 @@ - _result_tag_db_cluster.copy_tags_to_snapshot == false - "'db_cluster_arn' in _result_tag_db_cluster" - "'db_cluster_identifier' in _result_tag_db_cluster" - - _result_tag_db_cluster.db_cluster_identifier == "{{ cluster_id }}" + - _result_tag_db_cluster.db_cluster_identifier == cluster_id - "'db_cluster_parameter_group' in _result_tag_db_cluster" - "'db_cluster_resource_id' in _result_tag_db_cluster" - "'endpoint' in _result_tag_db_cluster" - "'engine' in _result_tag_db_cluster" - - _result_tag_db_cluster.engine == "{{ engine }}" + - _result_tag_db_cluster.engine == engine - "'engine_mode' in _result_tag_db_cluster" - _result_tag_db_cluster.engine_mode == "provisioned" - "'engine_version' in _result_tag_db_cluster" - "'master_username' in _result_tag_db_cluster" - - _result_tag_db_cluster.master_username == "{{ username }}" + - _result_tag_db_cluster.master_username == username - "'port' in _result_tag_db_cluster" - _result_tag_db_cluster.port == {{ port }} - "'status' in _result_tag_db_cluster" @@ -229,17 +229,17 @@ - _result_tag_db_cluster.copy_tags_to_snapshot == false - "'db_cluster_arn' in _result_tag_db_cluster" - "'db_cluster_identifier' in _result_tag_db_cluster" - - _result_tag_db_cluster.db_cluster_identifier == "{{ cluster_id }}" + - _result_tag_db_cluster.db_cluster_identifier == cluster_id - "'db_cluster_parameter_group' in _result_tag_db_cluster" - "'db_cluster_resource_id' in _result_tag_db_cluster" - "'endpoint' in _result_tag_db_cluster" - "'engine' in _result_tag_db_cluster" - - _result_tag_db_cluster.engine == "{{ engine }}" + - _result_tag_db_cluster.engine == engine - "'engine_mode' in _result_tag_db_cluster" - _result_tag_db_cluster.engine_mode == "provisioned" - "'engine_version' in _result_tag_db_cluster" - "'master_username' in _result_tag_db_cluster" - - _result_tag_db_cluster.master_username == "{{ username }}" + - _result_tag_db_cluster.master_username == username - "'port' in _result_tag_db_cluster" - _result_tag_db_cluster.port == {{ port }} - "'status' in _result_tag_db_cluster" @@ -268,17 +268,17 @@ - _result_tag_db_cluster.copy_tags_to_snapshot == false - "'db_cluster_arn' in _result_tag_db_cluster" - "'db_cluster_identifier' in _result_tag_db_cluster" - - _result_tag_db_cluster.db_cluster_identifier == "{{ cluster_id }}" + - _result_tag_db_cluster.db_cluster_identifier == cluster_id - "'db_cluster_parameter_group' in _result_tag_db_cluster" - "'db_cluster_resource_id' in _result_tag_db_cluster" - "'endpoint' in _result_tag_db_cluster" - "'engine' in _result_tag_db_cluster" - - _result_tag_db_cluster.engine == "{{ engine }}" + - _result_tag_db_cluster.engine == engine - "'engine_mode' in _result_tag_db_cluster" - _result_tag_db_cluster.engine_mode == "provisioned" - "'engine_version' in _result_tag_db_cluster" - "'master_username' in _result_tag_db_cluster" - - _result_tag_db_cluster.master_username == "{{ username }}" + - _result_tag_db_cluster.master_username == username - "'port' in _result_tag_db_cluster" - _result_tag_db_cluster.port == {{ port }} - "'status' in _result_tag_db_cluster" diff --git a/tests/integration/targets/rds_instance_modify/tasks/main.yml b/tests/integration/targets/rds_instance_modify/tasks/main.yml index eda3a89ff65..33248acf04e 100644 --- a/tests/integration/targets/rds_instance_modify/tasks/main.yml +++ b/tests/integration/targets/rds_instance_modify/tasks/main.yml @@ -165,7 +165,7 @@ - assert: that: - result.changed - - result.db_instance_identifier == "{{ instance_id }}" + - result.db_instance_identifier == instance_id - name: Immediately apply the pending update - check_mode rds_instance: @@ -191,7 +191,7 @@ - assert: that: - result.changed - - result.db_instance_identifier == "{{ modified_instance_id }}" + - result.db_instance_identifier == modified_instance_id # Test modifying CA certificate identifier ------------------------------------------- diff --git a/tests/integration/targets/rds_instance_snapshot/tasks/main.yml b/tests/integration/targets/rds_instance_snapshot/tasks/main.yml index 5b8b6b08efb..0a9dd449f22 100644 --- a/tests/integration/targets/rds_instance_snapshot/tasks/main.yml +++ b/tests/integration/targets/rds_instance_snapshot/tasks/main.yml @@ -26,7 +26,7 @@ - assert: that: - _result_create_instance.changed - - _result_create_instance.db_instance_identifier == "{{ instance_id }}" + - _result_create_instance.db_instance_identifier == instance_id - name: Get all RDS snapshots for the existing instance rds_snapshot_info: @@ -64,20 +64,20 @@ - "'availability_zone' in _result_instance_snapshot" - "'instance_create_time' in _result_instance_snapshot" - "'db_instance_identifier' in _result_instance_snapshot" - - _result_instance_snapshot.db_instance_identifier == "{{ instance_id }}" + - _result_instance_snapshot.db_instance_identifier == instance_id - "'db_snapshot_identifier' in _result_instance_snapshot" - - _result_instance_snapshot.db_snapshot_identifier == "{{ snapshot_id }}" + - _result_instance_snapshot.db_snapshot_identifier == snapshot_id - "'db_snapshot_arn' in _result_instance_snapshot" - "'dbi_resource_id' in _result_instance_snapshot" - "'encrypted' in _result_instance_snapshot" - "'engine' in _result_instance_snapshot" - - _result_instance_snapshot.engine == "{{ engine }}" + - _result_instance_snapshot.engine == engine - "'engine_version' in _result_instance_snapshot" - - _result_instance_snapshot.engine_version == "{{ mariadb_engine_version }}" + - _result_instance_snapshot.engine_version == mariadb_engine_version - "'iam_database_authentication_enabled' in _result_instance_snapshot" - "'license_model' in _result_instance_snapshot" - "'master_username' in _result_instance_snapshot" - - _result_instance_snapshot.master_username == "{{ username }}" + - _result_instance_snapshot.master_username == username - "'snapshot_create_time' in _result_instance_snapshot" - "'snapshot_type' in _result_instance_snapshot" - "'status' in _result_instance_snapshot" @@ -116,20 +116,20 @@ - "'availability_zone' in _result_instance_snapshot" - "'instance_create_time' in _result_instance_snapshot" - "'db_instance_identifier' in _result_instance_snapshot" - - _result_instance_snapshot.db_instance_identifier == "{{ instance_id }}" + - _result_instance_snapshot.db_instance_identifier == instance_id - "'db_snapshot_identifier' in _result_instance_snapshot" - - _result_instance_snapshot.db_snapshot_identifier == "{{ snapshot_id }}" + - _result_instance_snapshot.db_snapshot_identifier == snapshot_id - "'db_snapshot_arn' in _result_instance_snapshot" - "'dbi_resource_id' in _result_instance_snapshot" - "'encrypted' in _result_instance_snapshot" - "'engine' in _result_instance_snapshot" - - _result_instance_snapshot.engine == "{{ engine }}" + - _result_instance_snapshot.engine == engine - "'engine_version' in _result_instance_snapshot" - - _result_instance_snapshot.engine_version == "{{ mariadb_engine_version }}" + - _result_instance_snapshot.engine_version == mariadb_engine_version - "'iam_database_authentication_enabled' in _result_instance_snapshot" - "'license_model' in _result_instance_snapshot" - "'master_username' in _result_instance_snapshot" - - _result_instance_snapshot.master_username == "{{ username }}" + - _result_instance_snapshot.master_username == username - "'snapshot_create_time' in _result_instance_snapshot" - "'snapshot_type' in _result_instance_snapshot" - "'status' in _result_instance_snapshot" @@ -150,8 +150,8 @@ - assert: that: - _result_instance_snapshot_info is successful - - _result_instance_snapshot_info.snapshots[0].db_instance_identifier == "{{ instance_id }}" - - _result_instance_snapshot_info.snapshots[0].db_snapshot_identifier == "{{ snapshot_id }}" + - _result_instance_snapshot_info.snapshots[0].db_instance_identifier == instance_id + - _result_instance_snapshot_info.snapshots[0].db_snapshot_identifier == snapshot_id - name: Take another snapshot of the existing RDS instance rds_instance_snapshot: @@ -167,20 +167,20 @@ - "'availability_zone' in _result_instance_snapshot" - "'instance_create_time' in _result_instance_snapshot" - "'db_instance_identifier' in _result_instance_snapshot" - - _result_instance_snapshot.db_instance_identifier == "{{ instance_id }}" + - _result_instance_snapshot.db_instance_identifier == instance_id - "'db_snapshot_identifier' in _result_instance_snapshot" - - _result_instance_snapshot.db_snapshot_identifier == "{{ snapshot_id }}-b" + - _result_instance_snapshot.db_snapshot_identifier == snapshot_id+"-b" - "'db_snapshot_arn' in _result_instance_snapshot" - "'dbi_resource_id' in _result_instance_snapshot" - "'encrypted' in _result_instance_snapshot" - "'engine' in _result_instance_snapshot" - - _result_instance_snapshot.engine == "{{ engine }}" + - _result_instance_snapshot.engine == engine - "'engine_version' in _result_instance_snapshot" - - _result_instance_snapshot.engine_version == "{{ mariadb_engine_version }}" + - _result_instance_snapshot.engine_version == mariadb_engine_version - "'iam_database_authentication_enabled' in _result_instance_snapshot" - "'license_model' in _result_instance_snapshot" - "'master_username' in _result_instance_snapshot" - - _result_instance_snapshot.master_username == "{{ username }}" + - _result_instance_snapshot.master_username == username - "'snapshot_create_time' in _result_instance_snapshot" - "'snapshot_type' in _result_instance_snapshot" - "'status' in _result_instance_snapshot" @@ -262,20 +262,20 @@ - "'availability_zone' in _result_instance_snapshot" - "'instance_create_time' in _result_instance_snapshot" - "'db_instance_identifier' in _result_instance_snapshot" - - _result_instance_snapshot.db_instance_identifier == "{{ instance_id }}" + - _result_instance_snapshot.db_instance_identifier == instance_id - "'db_snapshot_identifier' in _result_instance_snapshot" - - _result_instance_snapshot.db_snapshot_identifier == "{{ snapshot_id }}-b" + - _result_instance_snapshot.db_snapshot_identifier == snapshot_id+"-b" - "'db_snapshot_arn' in _result_instance_snapshot" - "'dbi_resource_id' in _result_instance_snapshot" - "'encrypted' in _result_instance_snapshot" - "'engine' in _result_instance_snapshot" - - _result_instance_snapshot.engine == "{{ engine }}" + - _result_instance_snapshot.engine == engine - "'engine_version' in _result_instance_snapshot" - - _result_instance_snapshot.engine_version == "{{ mariadb_engine_version }}" + - _result_instance_snapshot.engine_version == mariadb_engine_version - "'iam_database_authentication_enabled' in _result_instance_snapshot" - "'license_model' in _result_instance_snapshot" - "'master_username' in _result_instance_snapshot" - - _result_instance_snapshot.master_username == "{{ username }}" + - _result_instance_snapshot.master_username == username - "'snapshot_create_time' in _result_instance_snapshot" - "'snapshot_type' in _result_instance_snapshot" - "'status' in _result_instance_snapshot" @@ -287,7 +287,7 @@ - _result_instance_snapshot.storage_type == "gp2" - "'tags' in _result_instance_snapshot" - _result_instance_snapshot.tags | length == 2 - - _result_instance_snapshot.tags["tag_one"] == "{{ snapshot_id }}-b One" + - _result_instance_snapshot.tags["tag_one"] == snapshot_id+"-b One" - _result_instance_snapshot.tags["Tag Two"] == "two {{ snapshot_id }}-b" - "'vpc_id' in _result_instance_snapshot" @@ -322,20 +322,20 @@ - "'availability_zone' in _result_instance_snapshot" - "'instance_create_time' in _result_instance_snapshot" - "'db_instance_identifier' in _result_instance_snapshot" - - _result_instance_snapshot.db_instance_identifier == "{{ instance_id }}" + - _result_instance_snapshot.db_instance_identifier == instance_id - "'db_snapshot_identifier' in _result_instance_snapshot" - - _result_instance_snapshot.db_snapshot_identifier == "{{ snapshot_id }}-b" + - _result_instance_snapshot.db_snapshot_identifier == snapshot_id+"-b" - "'db_snapshot_arn' in _result_instance_snapshot" - "'dbi_resource_id' in _result_instance_snapshot" - "'encrypted' in _result_instance_snapshot" - "'engine' in _result_instance_snapshot" - - _result_instance_snapshot.engine == "{{ engine }}" + - _result_instance_snapshot.engine == engine - "'engine_version' in _result_instance_snapshot" - - _result_instance_snapshot.engine_version == "{{ mariadb_engine_version }}" + - _result_instance_snapshot.engine_version == mariadb_engine_version - "'iam_database_authentication_enabled' in _result_instance_snapshot" - "'license_model' in _result_instance_snapshot" - "'master_username' in _result_instance_snapshot" - - _result_instance_snapshot.master_username == "{{ username }}" + - _result_instance_snapshot.master_username == username - "'snapshot_create_time' in _result_instance_snapshot" - "'snapshot_type' in _result_instance_snapshot" - "'status' in _result_instance_snapshot" @@ -347,7 +347,7 @@ - _result_instance_snapshot.storage_type == "gp2" - "'tags' in _result_instance_snapshot" - _result_instance_snapshot.tags | length == 2 - - _result_instance_snapshot.tags["tag_three"] == "{{ snapshot_id }}-b Three" + - _result_instance_snapshot.tags["tag_three"] == snapshot_id+"-b Three" - _result_instance_snapshot.tags["Tag Two"] == "two {{ snapshot_id }}-b" - "'vpc_id' in _result_instance_snapshot" @@ -367,20 +367,20 @@ - "'availability_zone' in _result_instance_snapshot" - "'instance_create_time' in _result_instance_snapshot" - "'db_instance_identifier' in _result_instance_snapshot" - - _result_instance_snapshot.db_instance_identifier == "{{ instance_id }}" + - _result_instance_snapshot.db_instance_identifier == instance_id - "'db_snapshot_identifier' in _result_instance_snapshot" - - _result_instance_snapshot.db_snapshot_identifier == "{{ snapshot_id }}-b" + - _result_instance_snapshot.db_snapshot_identifier == snapshot_id+"-b" - "'db_snapshot_arn' in _result_instance_snapshot" - "'dbi_resource_id' in _result_instance_snapshot" - "'encrypted' in _result_instance_snapshot" - "'engine' in _result_instance_snapshot" - - _result_instance_snapshot.engine == "{{ engine }}" + - _result_instance_snapshot.engine == engine - "'engine_version' in _result_instance_snapshot" - - _result_instance_snapshot.engine_version == "{{ mariadb_engine_version }}" + - _result_instance_snapshot.engine_version == mariadb_engine_version - "'iam_database_authentication_enabled' in _result_instance_snapshot" - "'license_model' in _result_instance_snapshot" - "'master_username' in _result_instance_snapshot" - - _result_instance_snapshot.master_username == "{{ username }}" + - _result_instance_snapshot.master_username == username - "'snapshot_create_time' in _result_instance_snapshot" - "'snapshot_type' in _result_instance_snapshot" - "'status' in _result_instance_snapshot" @@ -392,9 +392,9 @@ - _result_instance_snapshot.storage_type == "gp2" - "'tags' in _result_instance_snapshot" - _result_instance_snapshot.tags | length == 3 - - _result_instance_snapshot.tags["tag_one"] == "{{ snapshot_id }}-b One" + - _result_instance_snapshot.tags["tag_one"] == snapshot_id+"-b One" - _result_instance_snapshot.tags["Tag Two"] == "two {{ snapshot_id }}-b" - - _result_instance_snapshot.tags["tag_three"] == "{{ snapshot_id }}-b Three" + - _result_instance_snapshot.tags["tag_three"] == snapshot_id+"-b Three" - "'vpc_id' in _result_instance_snapshot" - name: Take another snapshot of the existing RDS instance and do not specify any tag to ensure previous tags are not removed @@ -440,14 +440,14 @@ - assert: that: - _result_instance_snapshot.changed - - _result_instance_snapshot.db_instance_identifier == "{{ instance_id }}" - - _result_instance_snapshot.source_db_snapshot_identifier == "{{ _snapshot_arn }}" - - _result_instance_snapshot.db_snapshot_identifier == "{{ snapshot_id }}-copy" + - _result_instance_snapshot.db_instance_identifier == instance_id + - _result_instance_snapshot.source_db_snapshot_identifier == _snapshot_arn + - _result_instance_snapshot.db_snapshot_identifier == snapshot_id+"-copy" - "'tags' in _result_instance_snapshot" - _result_instance_snapshot.tags | length == 3 - - _result_instance_snapshot.tags["tag_one"] == "{{ snapshot_id }}-b One" + - _result_instance_snapshot.tags["tag_one"] == snapshot_id+"-b One" - _result_instance_snapshot.tags["Tag Two"] == "two {{ snapshot_id }}-b" - - _result_instance_snapshot.tags["tag_three"] == "{{ snapshot_id }}-b Three" + - _result_instance_snapshot.tags["tag_three"] == snapshot_id+"-b Three" - name: Copy a snapshot (idempotence - check mode) rds_instance_snapshot: @@ -473,14 +473,14 @@ - assert: that: - not _result_instance_snapshot.changed - - _result_instance_snapshot.db_instance_identifier == "{{ instance_id }}" - - _result_instance_snapshot.source_db_snapshot_identifier == "{{ _snapshot_arn }}" - - _result_instance_snapshot.db_snapshot_identifier == "{{ snapshot_id }}-copy" + - _result_instance_snapshot.db_instance_identifier == instance_id + - _result_instance_snapshot.source_db_snapshot_identifier == _snapshot_arn + - _result_instance_snapshot.db_snapshot_identifier == snapshot_id+"-copy" - "'tags' in _result_instance_snapshot" - _result_instance_snapshot.tags | length == 3 - - _result_instance_snapshot.tags["tag_one"] == "{{ snapshot_id }}-b One" + - _result_instance_snapshot.tags["tag_one"] == snapshot_id+"-b One" - _result_instance_snapshot.tags["Tag Two"] == "two {{ snapshot_id }}-b" - - _result_instance_snapshot.tags["tag_three"] == "{{ snapshot_id }}-b Three" + - _result_instance_snapshot.tags["tag_three"] == snapshot_id+"-b Three" always: - name: Delete the existing DB instance snapshots diff --git a/tests/integration/targets/rds_instance_snapshot_mgmt/tasks/main.yml b/tests/integration/targets/rds_instance_snapshot_mgmt/tasks/main.yml index 9b5670d116e..c7bcbb6ef64 100644 --- a/tests/integration/targets/rds_instance_snapshot_mgmt/tasks/main.yml +++ b/tests/integration/targets/rds_instance_snapshot_mgmt/tasks/main.yml @@ -53,8 +53,8 @@ - assert: that: - result.changed - - result.db_instance_identifier == "{{ instance_id }}" - - result.db_snapshot_identifier == "{{ snapshot_id }}" + - result.db_instance_identifier == instance_id + - result.db_snapshot_identifier == snapshot_id # ------------------------------------------------------------------------------------------ # Test restoring db from snapshot @@ -85,9 +85,9 @@ - assert: that: - result.changed - - result.db_instance_identifier == "{{ snapshot_id }}" + - result.db_instance_identifier == snapshot_id - result.tags | length == 2 - - result.tags.Name == "{{ instance_id }}" + - result.tags.Name == instance_id - result.tags.Created_by == 'Ansible rds_instance tests' - result.db_instance_status == 'available' @@ -117,9 +117,9 @@ - assert: that: - not result.changed - - result.db_instance_identifier == "{{ snapshot_id }}" + - result.db_instance_identifier == snapshot_id - result.tags | length == 2 - - result.tags.Name == "{{ instance_id }}" + - result.tags.Name == instance_id - result.tags.Created_by == 'Ansible rds_instance tests' - result.db_instance_status == 'available' diff --git a/tests/integration/targets/rds_option_group/tasks/main.yml b/tests/integration/targets/rds_option_group/tasks/main.yml index f32f155cac4..26f1421338d 100644 --- a/tests/integration/targets/rds_option_group/tasks/main.yml +++ b/tests/integration/targets/rds_option_group/tasks/main.yml @@ -154,7 +154,7 @@ that: - new_rds_mysql_option_group.changed - "'engine_name' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.engine_name == "{{ engine_name }}" + - new_rds_mysql_option_group.engine_name == engine_name - "'major_engine_version' in new_rds_mysql_option_group" - new_rds_mysql_option_group.major_engine_version == "{{ major_engine_version }}" @@ -163,7 +163,7 @@ - new_rds_mysql_option_group.option_group_description == "{{ option_group_description }}" - "'option_group_name' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.option_group_name == "{{ option_group_name }}" + - new_rds_mysql_option_group.option_group_name == option_group_name - "'vpc_id' in new_rds_mysql_option_group" - new_rds_mysql_option_group.vpc_id == vpc_id - "'options' in new_rds_mysql_option_group" @@ -200,15 +200,15 @@ - option_groups_result is successful - (option_groups_result.result | length) == 1 - "'engine_name' in option_groups_list" - - option_groups_list.engine_name == "{{ engine_name }}" + - option_groups_list.engine_name == engine_name - "'major_engine_version' in option_groups_list" - - option_groups_list.major_engine_version == "{{ major_engine_version }}" + - option_groups_list.major_engine_version == major_engine_version - "'option_group_arn' in option_groups_list" - "'option_group_description' in option_groups_list" - option_groups_list.option_group_description == "{{ option_group_description }}" - "'option_group_name' in option_groups_list" - - option_groups_list.option_group_name == "{{ option_group_name }}" + - option_groups_list.option_group_name == option_group_name - "'vpc_id' in option_groups_list" - new_rds_mysql_option_group.vpc_id == vpc_id - "'options' in option_groups_list" @@ -256,7 +256,7 @@ that: - not new_rds_mysql_option_group.changed - "'engine_name' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.engine_name == "{{ engine_name }}" + - new_rds_mysql_option_group.engine_name == engine_name - "'major_engine_version' in new_rds_mysql_option_group" - new_rds_mysql_option_group.major_engine_version == "{{ major_engine_version }}" @@ -265,7 +265,7 @@ - new_rds_mysql_option_group.option_group_description == "{{ option_group_description }}" - "'option_group_name' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.option_group_name == "{{ option_group_name }}" + - new_rds_mysql_option_group.option_group_name == option_group_name - "'vpc_id' in new_rds_mysql_option_group" - new_rds_mysql_option_group.vpc_id == vpc_id - "'options' in new_rds_mysql_option_group" @@ -313,7 +313,7 @@ that: - not new_rds_mysql_option_group.changed - "'engine_name' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.engine_name == "{{ engine_name }}" + - new_rds_mysql_option_group.engine_name == engine_name - "'major_engine_version' in new_rds_mysql_option_group" - new_rds_mysql_option_group.major_engine_version == "{{ major_engine_version }}" @@ -322,7 +322,7 @@ - new_rds_mysql_option_group.option_group_description == "{{ option_group_description }}" - "'option_group_name' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.option_group_name == "{{ option_group_name }}" + - new_rds_mysql_option_group.option_group_name == option_group_name - "'vpc_id' in new_rds_mysql_option_group" - new_rds_mysql_option_group.vpc_id == vpc_id - "'options' in new_rds_mysql_option_group" @@ -385,7 +385,7 @@ that: - new_rds_mysql_option_group.changed - "'engine_name' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.engine_name == "{{ engine_name }}" + - new_rds_mysql_option_group.engine_name == engine_name - "'major_engine_version' in new_rds_mysql_option_group" - new_rds_mysql_option_group.major_engine_version == "{{ major_engine_version }}" @@ -394,7 +394,7 @@ - new_rds_mysql_option_group.option_group_description == "{{ option_group_description }}" - "'option_group_name' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.option_group_name == "{{ option_group_name }}" + - new_rds_mysql_option_group.option_group_name == option_group_name - "'vpc_id' in new_rds_mysql_option_group" - new_rds_mysql_option_group.vpc_id == vpc_id - "'options' in new_rds_mysql_option_group" @@ -426,15 +426,15 @@ - option_groups_result is successful - (option_groups_result.result | length) == 1 - "'engine_name' in option_groups_list" - - option_groups_list.engine_name == "{{ engine_name }}" + - option_groups_list.engine_name == engine_name - "'major_engine_version' in option_groups_list" - - option_groups_list.major_engine_version == "{{ major_engine_version }}" + - option_groups_list.major_engine_version == major_engine_version - "'option_group_arn' in option_groups_list" - "'option_group_description' in option_groups_list" - option_groups_list.option_group_description == "{{ option_group_description }}" - "'option_group_name' in option_groups_list" - - option_groups_list.option_group_name == "{{ option_group_name }}" + - option_groups_list.option_group_name == option_group_name - "'vpc_id' in option_groups_list" - new_rds_mysql_option_group.vpc_id == vpc_id - "'options' in option_groups_list" @@ -483,7 +483,7 @@ that: - new_rds_mysql_option_group.changed - "'engine_name' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.engine_name == "{{ engine_name }}" + - new_rds_mysql_option_group.engine_name == engine_name - "'major_engine_version' in new_rds_mysql_option_group" - new_rds_mysql_option_group.major_engine_version == "{{ major_engine_version }}" @@ -492,7 +492,7 @@ - new_rds_mysql_option_group.option_group_description == "{{ option_group_description }}" - "'option_group_name' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.option_group_name == "{{ option_group_name }}" + - new_rds_mysql_option_group.option_group_name == option_group_name - "'vpc_id' in new_rds_mysql_option_group" - new_rds_mysql_option_group.vpc_id == vpc_id - "'tags' in new_rds_mysql_option_group" @@ -540,7 +540,7 @@ that: - new_rds_mysql_option_group.changed - "'engine_name' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.engine_name == "{{ engine_name }}" + - new_rds_mysql_option_group.engine_name == engine_name - "'major_engine_version' in new_rds_mysql_option_group" - new_rds_mysql_option_group.major_engine_version == "{{ major_engine_version }}" @@ -549,13 +549,13 @@ - new_rds_mysql_option_group.option_group_description == "{{ option_group_description }}" - "'option_group_name' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.option_group_name == "{{ option_group_name }}" + - new_rds_mysql_option_group.option_group_name == option_group_name - "'vpc_id' in new_rds_mysql_option_group" - new_rds_mysql_option_group.vpc_id == vpc_id - "'tags' in new_rds_mysql_option_group" - (new_rds_mysql_option_group.tags | length) == 2 - - new_rds_mysql_option_group.tags["tag_one"] == "{{ option_group_name }} One" - - new_rds_mysql_option_group.tags["Tag Two"] == "two {{ option_group_name }}" + - new_rds_mysql_option_group.tags["tag_one"] == option_group_name+" One" + - new_rds_mysql_option_group.tags["Tag Two"] == "two +option_group_name - "'options' in new_rds_mysql_option_group" - (new_rds_mysql_option_group.options | length) > 0 - "'option_name' in option" @@ -602,7 +602,7 @@ that: - not new_rds_mysql_option_group.changed - "'engine_name' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.engine_name == "{{ engine_name }}" + - new_rds_mysql_option_group.engine_name == engine_name - "'major_engine_version' in new_rds_mysql_option_group" - new_rds_mysql_option_group.major_engine_version == "{{ major_engine_version }}" @@ -611,13 +611,13 @@ - new_rds_mysql_option_group.option_group_description == "{{ option_group_description }}" - "'option_group_name' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.option_group_name == "{{ option_group_name }}" + - new_rds_mysql_option_group.option_group_name == option_group_name - "'vpc_id' in new_rds_mysql_option_group" - new_rds_mysql_option_group.vpc_id == vpc_id - "'tags' in new_rds_mysql_option_group" - (new_rds_mysql_option_group.tags | length) == 2 - - new_rds_mysql_option_group.tags["tag_one"] == "{{ option_group_name }} One" - - new_rds_mysql_option_group.tags["Tag Two"] == "two {{ option_group_name }}" + - new_rds_mysql_option_group.tags["tag_one"] == option_group_name+" One" + - new_rds_mysql_option_group.tags["Tag Two"] == "two +option_group_name - "'options' in new_rds_mysql_option_group" - (new_rds_mysql_option_group.options | length) > 0 - "'option_name' in option" @@ -664,7 +664,7 @@ that: - new_rds_mysql_option_group.changed - "'engine_name' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.engine_name == "{{ engine_name }}" + - new_rds_mysql_option_group.engine_name == engine_name - "'major_engine_version' in new_rds_mysql_option_group" - new_rds_mysql_option_group.major_engine_version == "{{ major_engine_version }}" @@ -673,13 +673,13 @@ - new_rds_mysql_option_group.option_group_description == "{{ option_group_description }}" - "'option_group_name' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.option_group_name == "{{ option_group_name }}" + - new_rds_mysql_option_group.option_group_name == option_group_name - "'vpc_id' in new_rds_mysql_option_group" - new_rds_mysql_option_group.vpc_id == vpc_id - "'tags' in new_rds_mysql_option_group" - (new_rds_mysql_option_group.tags | length) == 2 - - new_rds_mysql_option_group.tags["tag_three"] == "{{ option_group_name }} Three" - - new_rds_mysql_option_group.tags["Tag Two"] == "two {{ option_group_name }}" + - new_rds_mysql_option_group.tags["tag_three"] == option_group_name+" Three" + - new_rds_mysql_option_group.tags["Tag Two"] == "two +option_group_name - "'options' in new_rds_mysql_option_group" - (new_rds_mysql_option_group.options | length) > 0 - "'option_name' in option" @@ -726,7 +726,7 @@ that: - new_rds_mysql_option_group.changed - "'engine_name' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.engine_name == "{{ engine_name }}" + - new_rds_mysql_option_group.engine_name == engine_name - "'major_engine_version' in new_rds_mysql_option_group" - new_rds_mysql_option_group.major_engine_version == "{{ major_engine_version }}" @@ -735,14 +735,14 @@ - new_rds_mysql_option_group.option_group_description == "{{ option_group_description }}" - "'option_group_name' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.option_group_name == "{{ option_group_name }}" + - new_rds_mysql_option_group.option_group_name == option_group_name - "'vpc_id' in new_rds_mysql_option_group" - new_rds_mysql_option_group.vpc_id == vpc_id - "'tags' in new_rds_mysql_option_group" - (new_rds_mysql_option_group.tags | length) == 3 - - new_rds_mysql_option_group.tags["Tag Two"] == "two {{ option_group_name }}" - - new_rds_mysql_option_group.tags["tag_one"] == "{{ option_group_name }} One" - - new_rds_mysql_option_group.tags["tag_three"] == "{{ option_group_name }} Three" + - new_rds_mysql_option_group.tags["Tag Two"] == "two +option_group_name + - new_rds_mysql_option_group.tags["tag_one"] == option_group_name+" One" + - new_rds_mysql_option_group.tags["tag_three"] == option_group_name+" Three" - "'options' in new_rds_mysql_option_group" - (new_rds_mysql_option_group.options | length) > 0 - "'option_name' in option" @@ -791,7 +791,7 @@ that: - new_rds_mysql_option_group.changed - "'engine_name' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.engine_name == "{{ engine_name }}" + - new_rds_mysql_option_group.engine_name == engine_name - "'major_engine_version' in new_rds_mysql_option_group" - new_rds_mysql_option_group.major_engine_version == "{{ major_engine_version }}" @@ -800,7 +800,7 @@ - new_rds_mysql_option_group.option_group_description == "{{ option_group_description }}" - "'option_group_name' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.option_group_name == "{{ option_group_name }}" + - new_rds_mysql_option_group.option_group_name == option_group_name - "'vpc_id' in new_rds_mysql_option_group" - new_rds_mysql_option_group.vpc_id == vpc_id - "'tags' in new_rds_mysql_option_group" @@ -851,7 +851,7 @@ that: - not new_rds_mysql_option_group.changed - "'engine_name' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.engine_name == "{{ engine_name }}" + - new_rds_mysql_option_group.engine_name == engine_name - "'major_engine_version' in new_rds_mysql_option_group" - new_rds_mysql_option_group.major_engine_version == "{{ major_engine_version }}" @@ -860,7 +860,7 @@ - new_rds_mysql_option_group.option_group_description == "{{ option_group_description }}" - "'option_group_name' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.option_group_name == "{{ option_group_name }}" + - new_rds_mysql_option_group.option_group_name == option_group_name - "'vpc_id' in new_rds_mysql_option_group" - new_rds_mysql_option_group.vpc_id == vpc_id - "'tags' in new_rds_mysql_option_group" diff --git a/tests/integration/targets/route53/tasks/main.yml b/tests/integration/targets/route53/tasks/main.yml index b43c7e5e061..9607b2307a0 100644 --- a/tests/integration/targets/route53/tasks/main.yml +++ b/tests/integration/targets/route53/tasks/main.yml @@ -507,7 +507,7 @@ - assert: that: - get_result.nameservers|length > 0 - - get_result.set.Name == "qdn_test.{{ zone_two }}" + - get_result.set.Name == "qdn_test."+zone_two - get_result.set.ResourceRecords[0].Value == "192.0.2.1" - get_result.set.Type == "A" diff --git a/tests/integration/targets/route53_health_check/tasks/update_delete_by_id.yml b/tests/integration/targets/route53_health_check/tasks/update_delete_by_id.yml index e4d242a2021..32fcd527586 100644 --- a/tests/integration/targets/route53_health_check/tasks/update_delete_by_id.yml +++ b/tests/integration/targets/route53_health_check/tasks/update_delete_by_id.yml @@ -129,7 +129,7 @@ - update_result is not failed - update_result is changed - health_check_info.HealthCheck.HealthCheckConfig.IPAddress == '1.2.3.4' - - health_check_info.HealthCheck.HealthCheckConfig.FullyQualifiedDomainName == "{{ fqdn_1 }}" + - health_check_info.HealthCheck.HealthCheckConfig.FullyQualifiedDomainName == fqdn_1 - name: 'Update Health Check by ID - Update IP address and FQDN - idempotency - check_mode' diff --git a/tests/integration/targets/s3_object/tasks/main.yml b/tests/integration/targets/s3_object/tasks/main.yml index 8cb9970ab70..556fbb5b646 100644 --- a/tests/integration/targets/s3_object/tasks/main.yml +++ b/tests/integration/targets/s3_object/tasks/main.yml @@ -892,7 +892,7 @@ - result is changed - "'tags' in result" - (result.tags | length) == 1 - - result.tags["tag_one"] == "{{ resource_prefix }} One" + - result.tags["tag_one"] == resource_prefix+" One" - "'Tag Two' not in result.tags" - name: Remove the tag from an S3 object (idempotency) @@ -911,7 +911,7 @@ - result is not changed - "'tags' in result" - (result.tags | length) == 1 - - result.tags["tag_one"] == "{{ resource_prefix }} One" + - result.tags["tag_one"] == resource_prefix+" One" - "'Tag Two' not in result.tags" - name: Add a tag for an S3 object with purge_tags False From e0eafce6cf2524c4a47e23f6ba94dc79d1db736e Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Fri, 1 Dec 2023 09:06:49 +0100 Subject: [PATCH 2/9] Syntax fixups --- .../targets/ec2_instance_metadata_options/tasks/main.yml | 6 +++--- .../targets/elb_classic_lb/tasks/https_listeners.yml | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/integration/targets/ec2_instance_metadata_options/tasks/main.yml b/tests/integration/targets/ec2_instance_metadata_options/tasks/main.yml index 593ade14074..f1d30b82a01 100644 --- a/tests/integration/targets/ec2_instance_metadata_options/tasks/main.yml +++ b/tests/integration/targets/ec2_instance_metadata_options/tasks/main.yml @@ -59,6 +59,6 @@ - metadata_options_update is success - metadata_options_update is not changed - presented_instance_fact.instances | length > 0 - - presented_instance_fact.instances.0.state.name in ['running','pending']" - - presented_instance_fact.instances.0.metadata_options.http_endpoint == 'enabled'" - - presented_instance_fact.instances.0.metadata_options.http_tokens == 'required'" + - presented_instance_fact.instances.0.state.name in ['running','pending'] + - presented_instance_fact.instances.0.metadata_options.http_endpoint == 'enabled' + - presented_instance_fact.instances.0.metadata_options.http_tokens == 'required' diff --git a/tests/integration/targets/elb_classic_lb/tasks/https_listeners.yml b/tests/integration/targets/elb_classic_lb/tasks/https_listeners.yml index 35a10a726ff..63fb96c23f1 100644 --- a/tests/integration/targets/elb_classic_lb/tasks/https_listeners.yml +++ b/tests/integration/targets/elb_classic_lb/tasks/https_listeners.yml @@ -73,7 +73,7 @@ - elb_create_result is changed - elb_create_result.elb.status == "created" - elb_create_result.load_balancer | length == 0 - - 'elasticloadbalancing:CreateLoadBalancer' not in elb_create_result.resource_actions + - "'elasticloadbalancing:CreateLoadBalancer' not in elb_create_result.resource_actions" - name: Create a classic ELB with https method listeners amazon.aws.elb_classic_lb: "{{ elb_definition }}" @@ -83,7 +83,7 @@ - elb_create_result is changed - elb_create_result.elb.status == "created" - elb_create_result.load_balancer | length != 0 - - 'elasticloadbalancing:CreateLoadBalancer' in elb_create_result.resource_actions + - "'elasticloadbalancing:CreateLoadBalancer' in elb_create_result.resource_actions" - name: Create a classic ELB with https method listeners - idempotency - check_mode amazon.aws.elb_classic_lb: "{{ elb_definition }}" @@ -95,7 +95,7 @@ - elb_create_result.elb.status != "created" - elb_create_result.elb.status == "exists" - elb_create_result.load_balancer | length != 0 - - 'elasticloadbalancing:CreateLoadBalancer' not in elb_create_result.resource_actions + - "'elasticloadbalancing:CreateLoadBalancer' not in elb_create_result.resource_actions" - name: Create a classic ELB with https method listeners - idempotency amazon.aws.elb_classic_lb: "{{ elb_definition }}" @@ -106,7 +106,7 @@ - elb_create_result.elb.status != "created" - elb_create_result.elb.status == "exists" - elb_create_result.load_balancer | length != 0 - - 'elasticloadbalancing:CreateLoadBalancer' not in elb_create_result.resource_actions + - "'elasticloadbalancing:CreateLoadBalancer' not in elb_create_result.resource_actions" # Remove ELB and certificate created during this test From c7372fd4ecf48ac8de63ffad36f0976f87add053 Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Fri, 1 Dec 2023 17:23:15 +0100 Subject: [PATCH 3/9] More syntax fixes Co-authored-by: Bikouo Aubin <79859644+abikouo@users.noreply.github.com> --- .../targets/elb_application_lb/tasks/main.yml | 14 +++++++------- .../targets/rds_cluster_snapshot/tasks/main.yml | 2 +- .../targets/rds_option_group/tasks/main.yml | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/integration/targets/elb_application_lb/tasks/main.yml b/tests/integration/targets/elb_application_lb/tasks/main.yml index 8f099b1f445..17f7af86a55 100644 --- a/tests/integration/targets/elb_application_lb/tasks/main.yml +++ b/tests/integration/targets/elb_application_lb/tasks/main.yml @@ -821,7 +821,7 @@ that: - alb is changed - alb.listeners[0].rules | length == 2 - - '1' in +alb.listeners[0].rules | map(attribute='priority') + - "'1' in alb.listeners[0].rules | map(attribute='priority')" - name: Update an ALB with different listener by adding rule (idempotence) - check_mode elb_application_lb: @@ -877,7 +877,7 @@ that: - alb is not changed - alb.listeners[0].rules | length == 2 - - '1' in +alb.listeners[0].rules | map(attribute='priority') + - "'1' in alb.listeners[0].rules | map(attribute='priority')" # ------------------------------------------------------------------------------------------ @@ -935,7 +935,7 @@ that: - alb is changed - alb.listeners[0].rules | length == 2 - - '2' in +alb.listeners[0].rules | map(attribute='priority') + - "'2' in alb.listeners[0].rules | map(attribute='priority')" - name: Update an ALB with different listener by modifying rule (idempotence) - check_mode @@ -992,7 +992,7 @@ that: - alb is not changed - alb.listeners[0].rules | length == 2 - - '2' in +alb.listeners[0].rules | map(attribute='priority') + - "'2' in alb.listeners[0].rules | map(attribute='priority')" # ------------------------------------------------------------------------------------------ @@ -1034,7 +1034,7 @@ that: - alb is changed - alb.listeners[0].rules | length == 1 - - '2' not in +alb.listeners[0].rules | map(attribute='priority') + - "'2' not in alb.listeners[0].rules | map(attribute='priority')" - name: Update an ALB with different listener by deleting rule (idempotence) - check_mode elb_application_lb: @@ -1074,7 +1074,7 @@ that: - alb is not changed - alb.listeners[0].rules | length == 1 - - '2' not in +alb.listeners[0].rules | map(attribute='priority') + - "'2' not in alb.listeners[0].rules | map(attribute='priority')" # ------------------------------------------------------------------------------------------ @@ -1161,7 +1161,7 @@ - assert: that: - alb is changed - - alb.tags == "created_by": "ALB test" resource_prefix + - alb.tags == {"created_by": "ALB test" +resource_prefix} - name: Update an ALB by adding tags (idempotence) - check_mode elb_application_lb: diff --git a/tests/integration/targets/rds_cluster_snapshot/tasks/main.yml b/tests/integration/targets/rds_cluster_snapshot/tasks/main.yml index 9b19ec12dbb..cfa448e5513 100644 --- a/tests/integration/targets/rds_cluster_snapshot/tasks/main.yml +++ b/tests/integration/targets/rds_cluster_snapshot/tasks/main.yml @@ -153,7 +153,7 @@ - "'master_username' in _result_create_source_db_cluster" - _result_create_source_db_cluster.master_username == username - "'port' in _result_create_source_db_cluster" - - "_result_create_source_db_cluster.port == port + - _result_create_source_db_cluster.port == port - "'status' in _result_create_source_db_cluster" - _result_create_source_db_cluster.status == "available" - "'tags' in _result_create_source_db_cluster" diff --git a/tests/integration/targets/rds_option_group/tasks/main.yml b/tests/integration/targets/rds_option_group/tasks/main.yml index 26f1421338d..98b5fd18d3c 100644 --- a/tests/integration/targets/rds_option_group/tasks/main.yml +++ b/tests/integration/targets/rds_option_group/tasks/main.yml @@ -202,7 +202,7 @@ - "'engine_name' in option_groups_list" - option_groups_list.engine_name == engine_name - "'major_engine_version' in option_groups_list" - - option_groups_list.major_engine_version == major_engine_version + - (option_groups_list.major_engine_version | string) == (major_engine_version | string) - "'option_group_arn' in option_groups_list" - "'option_group_description' in option_groups_list" - option_groups_list.option_group_description == "{{ option_group_description @@ -428,7 +428,7 @@ - "'engine_name' in option_groups_list" - option_groups_list.engine_name == engine_name - "'major_engine_version' in option_groups_list" - - option_groups_list.major_engine_version == major_engine_version + - (option_groups_list.major_engine_version | string) == (major_engine_version | string) - "'option_group_arn' in option_groups_list" - "'option_group_description' in option_groups_list" - option_groups_list.option_group_description == "{{ option_group_description From 80931338d2d17e8411e123a7ba3f4847238a5e8a Mon Sep 17 00:00:00 2001 From: Jill Rouleau Date: Fri, 1 Dec 2023 16:16:10 -0700 Subject: [PATCH 4/9] fix some syntax errors --- .../ec2_eni/tasks/test_create_attached_multiple.yml | 8 ++++---- .../targets/elb_application_lb/tasks/main.yml | 9 +++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/tests/integration/targets/ec2_eni/tasks/test_create_attached_multiple.yml b/tests/integration/targets/ec2_eni/tasks/test_create_attached_multiple.yml index 28e05680d54..b4021ce3ab2 100644 --- a/tests/integration/targets/ec2_eni/tasks/test_create_attached_multiple.yml +++ b/tests/integration/targets/ec2_eni/tasks/test_create_attached_multiple.yml @@ -37,7 +37,7 @@ - result is not failed - instance_info_result.instances[0].network_interfaces | length == 1 - '"Would have created ENI if not in check mode." in result.msg' - - 'ec2:CreateNetworkInterface' not in result.resource_actions + - "'ec2:CreateNetworkInterface' not in result.resource_actions" - name: Create and attach another interface to above instance amazon.aws.ec2_eni: @@ -96,9 +96,9 @@ - result is changed - result is not failed - instance_info_result.instances[0].network_interfaces | length == 2 - - '"Would have modified ENI: {{ eni_id_attached_multiple }} if not in check mode" in result.msg' - - 'ec2:CreateNetworkInterface' not in result.resource_actions - - 'ec2:ModifyNetworkInterfaceAttribute' not in result.resource_actions + - '"Would have modified ENI: "+eni_id_attached_multiple+" if not in check mode" in result.msg' + - "'ec2:CreateNetworkInterface' not in result.resource_actions" + - "'ec2:ModifyNetworkInterfaceAttribute' not in result.resource_actions" #================================================================= diff --git a/tests/integration/targets/elb_application_lb/tasks/main.yml b/tests/integration/targets/elb_application_lb/tasks/main.yml index 17f7af86a55..dc117ce59c7 100644 --- a/tests/integration/targets/elb_application_lb/tasks/main.yml +++ b/tests/integration/targets/elb_application_lb/tasks/main.yml @@ -1161,7 +1161,7 @@ - assert: that: - alb is changed - - alb.tags == {"created_by": "ALB test" +resource_prefix} + - alb.tags == "created_by": "'ALB test '+resource_prefix" - name: Update an ALB by adding tags (idempotence) - check_mode elb_application_lb: @@ -1190,7 +1190,7 @@ - assert: that: - alb is not changed - - 'alb.tags == {"created_by": "ALB test +resource_prefix}' + - alb.tags == "created_by": "'ALB test '+resource_prefix" # ------------------------------------------------------------------------------------------ @@ -1221,7 +1221,8 @@ - assert: that: - alb is changed - - 'alb.tags == {"created_by": "ALB test {{ resource_prefix }}-2"}' + - alb.tags == "created_by": "'ALB test '+resource_prefix+'-2'" + - name: Update an ALB by modifying tags (idempotence) - check_mode elb_application_lb: @@ -1250,7 +1251,7 @@ - assert: that: - alb is not changed - - 'alb.tags == {"created_by": "ALB test {{ resource_prefix }}-2"}' + - alb.tags == "created_by": "'ALB test '+resource_prefix+'-2'" # ------------------------------------------------------------------------------------------ From 540ba67bbb146fa77fb4f5f1dedd12a1646a74e2 Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Mon, 4 Dec 2023 10:00:20 +0100 Subject: [PATCH 5/9] More fixups --- .../targets/elb_application_lb/tasks/main.yml | 20 ++- .../targets/rds_option_group/tasks/main.yml | 139 ++++++++---------- 2 files changed, 75 insertions(+), 84 deletions(-) diff --git a/tests/integration/targets/elb_application_lb/tasks/main.yml b/tests/integration/targets/elb_application_lb/tasks/main.yml index dc117ce59c7..1b0762e25af 100644 --- a/tests/integration/targets/elb_application_lb/tasks/main.yml +++ b/tests/integration/targets/elb_application_lb/tasks/main.yml @@ -1161,7 +1161,10 @@ - assert: that: - alb is changed - - alb.tags == "created_by": "'ALB test '+resource_prefix" + - alb.tags == created_tags + vars: + created_tags: + created_by: 'ALB test {{ resource_prefix }}' - name: Update an ALB by adding tags (idempotence) - check_mode elb_application_lb: @@ -1190,7 +1193,10 @@ - assert: that: - alb is not changed - - alb.tags == "created_by": "'ALB test '+resource_prefix" + - alb.tags == created_tags + vars: + created_tags: + created_by: 'ALB test {{ resource_prefix }}' # ------------------------------------------------------------------------------------------ @@ -1221,7 +1227,10 @@ - assert: that: - alb is changed - - alb.tags == "created_by": "'ALB test '+resource_prefix+'-2'" + - alb.tags == created_tags + vars: + created_tags: + created_by: 'ALB test {{ resource_prefix }}-2' - name: Update an ALB by modifying tags (idempotence) - check_mode @@ -1251,7 +1260,10 @@ - assert: that: - alb is not changed - - alb.tags == "created_by": "'ALB test '+resource_prefix+'-2'" + - alb.tags == created_tags + vars: + created_tags: + created_by: 'ALB test {{ resource_prefix }}-2' # ------------------------------------------------------------------------------------------ diff --git a/tests/integration/targets/rds_option_group/tasks/main.yml b/tests/integration/targets/rds_option_group/tasks/main.yml index 98b5fd18d3c..6ade26c2597 100644 --- a/tests/integration/targets/rds_option_group/tasks/main.yml +++ b/tests/integration/targets/rds_option_group/tasks/main.yml @@ -156,12 +156,10 @@ - "'engine_name' in new_rds_mysql_option_group" - new_rds_mysql_option_group.engine_name == engine_name - "'major_engine_version' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.major_engine_version == "{{ major_engine_version - }}" + - (new_rds_mysql_option_group.major_engine_version | string) == (major_engine_version | string) - "'option_group_arn' in new_rds_mysql_option_group" - "'option_group_description' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.option_group_description == "{{ option_group_description - }}" + - new_rds_mysql_option_group.option_group_description == option_group_description - "'option_group_name' in new_rds_mysql_option_group" - new_rds_mysql_option_group.option_group_name == option_group_name - "'vpc_id' in new_rds_mysql_option_group" @@ -176,8 +174,7 @@ - option.port == 11211 - "'vpc_security_group_memberships' in option" - (option.vpc_security_group_memberships | length) == 1 - - option.vpc_security_group_memberships[0].vpc_security_group_id == "{{ sg_1 - }}" + - option.vpc_security_group_memberships[0].vpc_security_group_id == sg_1 - "'option_settings' in option" - (option_settings | length) > 0 - option_settings | selectattr('name','equalto','MAX_SIMULTANEOUS_CONNECTIONS') @@ -205,8 +202,7 @@ - (option_groups_list.major_engine_version | string) == (major_engine_version | string) - "'option_group_arn' in option_groups_list" - "'option_group_description' in option_groups_list" - - option_groups_list.option_group_description == "{{ option_group_description - }}" + - option_groups_list.option_group_description == option_group_description - "'option_group_name' in option_groups_list" - option_groups_list.option_group_name == option_group_name - "'vpc_id' in option_groups_list" @@ -221,8 +217,7 @@ - options.port == 11211 - "'vpc_security_group_memberships' in options" - (options.vpc_security_group_memberships | length) == 1 - - options.vpc_security_group_memberships[0].vpc_security_group_id == "{{ sg_1 - }}" + - options.vpc_security_group_memberships[0].vpc_security_group_id == sg_1 - "'option_settings' in options" - (options.option_settings | length) > 0 vars: @@ -258,12 +253,10 @@ - "'engine_name' in new_rds_mysql_option_group" - new_rds_mysql_option_group.engine_name == engine_name - "'major_engine_version' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.major_engine_version == "{{ major_engine_version - }}" + - (new_rds_mysql_option_group.major_engine_version | string) == (major_engine_version | string) - "'option_group_arn' in new_rds_mysql_option_group" - "'option_group_description' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.option_group_description == "{{ option_group_description - }}" + - new_rds_mysql_option_group.option_group_description == option_group_description - "'option_group_name' in new_rds_mysql_option_group" - new_rds_mysql_option_group.option_group_name == option_group_name - "'vpc_id' in new_rds_mysql_option_group" @@ -278,8 +271,7 @@ - option.port == 11211 - "'vpc_security_group_memberships' in option" - (option.vpc_security_group_memberships | length) == 1 - - option.vpc_security_group_memberships[0].vpc_security_group_id == "{{ sg_1 - }}" + - option.vpc_security_group_memberships[0].vpc_security_group_id == sg_1 - "'option_settings' in option" - (option_settings | length) > 0 - option_settings | selectattr('name','equalto','MAX_SIMULTANEOUS_CONNECTIONS') @@ -315,12 +307,10 @@ - "'engine_name' in new_rds_mysql_option_group" - new_rds_mysql_option_group.engine_name == engine_name - "'major_engine_version' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.major_engine_version == "{{ major_engine_version - }}" + - (new_rds_mysql_option_group.major_engine_version | string) == (major_engine_version | string) - "'option_group_arn' in new_rds_mysql_option_group" - "'option_group_description' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.option_group_description == "{{ option_group_description - }}" + - new_rds_mysql_option_group.option_group_description == option_group_description - "'option_group_name' in new_rds_mysql_option_group" - new_rds_mysql_option_group.option_group_name == option_group_name - "'vpc_id' in new_rds_mysql_option_group" @@ -335,8 +325,7 @@ - option.port == 11211 - "'vpc_security_group_memberships' in option" - (option.vpc_security_group_memberships | length) == 1 - - option.vpc_security_group_memberships[0].vpc_security_group_id == "{{ sg_1 - }}" + - option.vpc_security_group_memberships[0].vpc_security_group_id == sg_1 - "'option_settings' in option" - (option_settings | length) > 0 - option_settings | selectattr('name','equalto','MAX_SIMULTANEOUS_CONNECTIONS') @@ -387,12 +376,10 @@ - "'engine_name' in new_rds_mysql_option_group" - new_rds_mysql_option_group.engine_name == engine_name - "'major_engine_version' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.major_engine_version == "{{ major_engine_version - }}" + - (new_rds_mysql_option_group.major_engine_version | string) == (major_engine_version | string) - "'option_group_arn' in new_rds_mysql_option_group" - "'option_group_description' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.option_group_description == "{{ option_group_description - }}" + - new_rds_mysql_option_group.option_group_description == option_group_description - "'option_group_name' in new_rds_mysql_option_group" - new_rds_mysql_option_group.option_group_name == option_group_name - "'vpc_id' in new_rds_mysql_option_group" @@ -431,8 +418,7 @@ - (option_groups_list.major_engine_version | string) == (major_engine_version | string) - "'option_group_arn' in option_groups_list" - "'option_group_description' in option_groups_list" - - option_groups_list.option_group_description == "{{ option_group_description - }}" + - option_groups_list.option_group_description == option_group_description - "'option_group_name' in option_groups_list" - option_groups_list.option_group_name == option_group_name - "'vpc_id' in option_groups_list" @@ -485,12 +471,10 @@ - "'engine_name' in new_rds_mysql_option_group" - new_rds_mysql_option_group.engine_name == engine_name - "'major_engine_version' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.major_engine_version == "{{ major_engine_version - }}" + - (new_rds_mysql_option_group.major_engine_version | string) == (major_engine_version | string) - "'option_group_arn' in new_rds_mysql_option_group" - "'option_group_description' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.option_group_description == "{{ option_group_description - }}" + - new_rds_mysql_option_group.option_group_description == option_group_description - "'option_group_name' in new_rds_mysql_option_group" - new_rds_mysql_option_group.option_group_name == option_group_name - "'vpc_id' in new_rds_mysql_option_group" @@ -542,20 +526,16 @@ - "'engine_name' in new_rds_mysql_option_group" - new_rds_mysql_option_group.engine_name == engine_name - "'major_engine_version' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.major_engine_version == "{{ major_engine_version - }}" + - (new_rds_mysql_option_group.major_engine_version | string) == (major_engine_version | string) - "'option_group_arn' in new_rds_mysql_option_group" - "'option_group_description' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.option_group_description == "{{ option_group_description - }}" + - new_rds_mysql_option_group.option_group_description == option_group_description - "'option_group_name' in new_rds_mysql_option_group" - new_rds_mysql_option_group.option_group_name == option_group_name - "'vpc_id' in new_rds_mysql_option_group" - new_rds_mysql_option_group.vpc_id == vpc_id - "'tags' in new_rds_mysql_option_group" - - (new_rds_mysql_option_group.tags | length) == 2 - - new_rds_mysql_option_group.tags["tag_one"] == option_group_name+" One" - - new_rds_mysql_option_group.tags["Tag Two"] == "two +option_group_name + - (new_rds_mysql_option_group.tags == option_tags - "'options' in new_rds_mysql_option_group" - (new_rds_mysql_option_group.options | length) > 0 - "'option_name' in option" @@ -573,6 +553,9 @@ vars: option: '{{ new_rds_mysql_option_group.options[0] }}' option_settings: '{{ new_rds_mysql_option_group.options[0].option_settings }}' + option_tags: + tag_one: '{{ option_group_name }} One' + Tag Two: two {{ option_group_name }} - name: RDS Mysql option group - apply tags (idempotency) @@ -604,20 +587,16 @@ - "'engine_name' in new_rds_mysql_option_group" - new_rds_mysql_option_group.engine_name == engine_name - "'major_engine_version' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.major_engine_version == "{{ major_engine_version - }}" + - (new_rds_mysql_option_group.major_engine_version | string) == (major_engine_version | string) - "'option_group_arn' in new_rds_mysql_option_group" - "'option_group_description' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.option_group_description == "{{ option_group_description - }}" + - new_rds_mysql_option_group.option_group_description == option_group_description - "'option_group_name' in new_rds_mysql_option_group" - new_rds_mysql_option_group.option_group_name == option_group_name - "'vpc_id' in new_rds_mysql_option_group" - new_rds_mysql_option_group.vpc_id == vpc_id - "'tags' in new_rds_mysql_option_group" - - (new_rds_mysql_option_group.tags | length) == 2 - - new_rds_mysql_option_group.tags["tag_one"] == option_group_name+" One" - - new_rds_mysql_option_group.tags["Tag Two"] == "two +option_group_name + - new_rds_mysql_option_group.tags == option_tags - "'options' in new_rds_mysql_option_group" - (new_rds_mysql_option_group.options | length) > 0 - "'option_name' in option" @@ -635,8 +614,10 @@ vars: option: '{{ new_rds_mysql_option_group.options[0] }}' option_settings: '{{ new_rds_mysql_option_group.options[0].option_settings }}' + option_tags: + tag_one: '{{ option_group_name }} One' + Tag Two: two {{ option_group_name }} - - name: RDS Mysql option group - update tags rds_option_group: state: present @@ -666,20 +647,16 @@ - "'engine_name' in new_rds_mysql_option_group" - new_rds_mysql_option_group.engine_name == engine_name - "'major_engine_version' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.major_engine_version == "{{ major_engine_version - }}" + - (new_rds_mysql_option_group.major_engine_version | string) == (major_engine_version | string) - "'option_group_arn' in new_rds_mysql_option_group" - "'option_group_description' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.option_group_description == "{{ option_group_description - }}" + - new_rds_mysql_option_group.option_group_description == option_group_description - "'option_group_name' in new_rds_mysql_option_group" - new_rds_mysql_option_group.option_group_name == option_group_name - "'vpc_id' in new_rds_mysql_option_group" - new_rds_mysql_option_group.vpc_id == vpc_id - "'tags' in new_rds_mysql_option_group" - - (new_rds_mysql_option_group.tags | length) == 2 - - new_rds_mysql_option_group.tags["tag_three"] == option_group_name+" Three" - - new_rds_mysql_option_group.tags["Tag Two"] == "two +option_group_name + - new_rds_mysql_option_group.tags == option_tags - "'options' in new_rds_mysql_option_group" - (new_rds_mysql_option_group.options | length) > 0 - "'option_name' in option" @@ -697,6 +674,9 @@ vars: option: '{{ new_rds_mysql_option_group.options[0] }}' option_settings: '{{ new_rds_mysql_option_group.options[0].option_settings }}' + option_tags: + tag_three: '{{ option_group_name }} Three' + Tag Two: two {{ option_group_name }} - name: RDS Mysql option group - update tags without purge (expected changed=true) @@ -728,21 +708,16 @@ - "'engine_name' in new_rds_mysql_option_group" - new_rds_mysql_option_group.engine_name == engine_name - "'major_engine_version' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.major_engine_version == "{{ major_engine_version - }}" + - (new_rds_mysql_option_group.major_engine_version | string) == (major_engine_version | string) - "'option_group_arn' in new_rds_mysql_option_group" - "'option_group_description' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.option_group_description == "{{ option_group_description - }}" + - new_rds_mysql_option_group.option_group_description == option_group_description - "'option_group_name' in new_rds_mysql_option_group" - new_rds_mysql_option_group.option_group_name == option_group_name - "'vpc_id' in new_rds_mysql_option_group" - new_rds_mysql_option_group.vpc_id == vpc_id - "'tags' in new_rds_mysql_option_group" - - (new_rds_mysql_option_group.tags | length) == 3 - - new_rds_mysql_option_group.tags["Tag Two"] == "two +option_group_name - - new_rds_mysql_option_group.tags["tag_one"] == option_group_name+" One" - - new_rds_mysql_option_group.tags["tag_three"] == option_group_name+" Three" + - new_rds_mysql_option_group.tags == option_tags - "'options' in new_rds_mysql_option_group" - (new_rds_mysql_option_group.options | length) > 0 - "'option_name' in option" @@ -760,6 +735,10 @@ vars: option: '{{ new_rds_mysql_option_group.options[0] }}' option_settings: '{{ new_rds_mysql_option_group.options[0].option_settings }}' + option_tags: + tag_one: '{{ option_group_name }} One' + Tag Two: two {{ option_group_name }} + tag_three: '{{ option_group_name }} Three' - name: RDS Mysql option group - update with CamelCase tags (expected changed=true) @@ -793,22 +772,16 @@ - "'engine_name' in new_rds_mysql_option_group" - new_rds_mysql_option_group.engine_name == engine_name - "'major_engine_version' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.major_engine_version == "{{ major_engine_version - }}" + - (new_rds_mysql_option_group.major_engine_version | string) == (major_engine_version | string) - "'option_group_arn' in new_rds_mysql_option_group" - "'option_group_description' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.option_group_description == "{{ option_group_description - }}" + - new_rds_mysql_option_group.option_group_description == option_group_description - "'option_group_name' in new_rds_mysql_option_group" - new_rds_mysql_option_group.option_group_name == option_group_name - "'vpc_id' in new_rds_mysql_option_group" - new_rds_mysql_option_group.vpc_id == vpc_id - "'tags' in new_rds_mysql_option_group" - - (new_rds_mysql_option_group.tags | length) == 4 - - new_rds_mysql_option_group.tags["lowercase spaced"] == 'hello cruel world' - - new_rds_mysql_option_group.tags["Title Case"] == 'Hello Cruel World' - - new_rds_mysql_option_group.tags["CamelCase"] == 'SimpleCamelCase' - - new_rds_mysql_option_group.tags["snake_case"] == 'simple_snake_case' + - new_rds_mysql_option_group.tags == option_tags - "'options' in new_rds_mysql_option_group" - (new_rds_mysql_option_group.options | length) > 0 - "'option_name' in option" @@ -826,6 +799,12 @@ vars: option: '{{ new_rds_mysql_option_group.options[0] }}' option_settings: '{{ new_rds_mysql_option_group.options[0].option_settings }}' + option_tags: + lowercase spaced: hello cruel world + Title Case: Hello Cruel World + CamelCase: SimpleCamelCase + snake_case: simple_snake_case + - name: RDS Mysql option group - do not specify any tag to ensure previous tags are not removed rds_option_group: @@ -853,22 +832,16 @@ - "'engine_name' in new_rds_mysql_option_group" - new_rds_mysql_option_group.engine_name == engine_name - "'major_engine_version' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.major_engine_version == "{{ major_engine_version - }}" + - (new_rds_mysql_option_group.major_engine_version | string) == (major_engine_version | string) - "'option_group_arn' in new_rds_mysql_option_group" - "'option_group_description' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.option_group_description == "{{ option_group_description - }}" + - new_rds_mysql_option_group.option_group_description == option_group_description - "'option_group_name' in new_rds_mysql_option_group" - new_rds_mysql_option_group.option_group_name == option_group_name - "'vpc_id' in new_rds_mysql_option_group" - new_rds_mysql_option_group.vpc_id == vpc_id - "'tags' in new_rds_mysql_option_group" - - (new_rds_mysql_option_group.tags | length) == 4 - - new_rds_mysql_option_group.tags["lowercase spaced"] == 'hello cruel world' - - new_rds_mysql_option_group.tags["Title Case"] == 'Hello Cruel World' - - new_rds_mysql_option_group.tags["CamelCase"] == 'SimpleCamelCase' - - new_rds_mysql_option_group.tags["snake_case"] == 'simple_snake_case' + - new_rds_mysql_option_group.tags == option_tags - "'options' in new_rds_mysql_option_group" - (new_rds_mysql_option_group.options | length) > 0 - "'option_name' in option" @@ -886,6 +859,12 @@ vars: option: '{{ new_rds_mysql_option_group.options[0] }}' option_settings: '{{ new_rds_mysql_option_group.options[0].option_settings }}' + option_tags: + lowercase spaced: hello cruel world + Title Case: Hello Cruel World + CamelCase: SimpleCamelCase + snake_case: simple_snake_case + - name: Delete an RDS Mysql option group - CHECK_MODE rds_option_group: state: absent From e6c2e9fc27cabe9c19b045461a0597b3ee6fe85f Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Mon, 4 Dec 2023 10:13:51 +0100 Subject: [PATCH 6/9] ansible-lint --- .../elb_application_lb/defaults/main.yml | 6 +- .../targets/elb_application_lb/tasks/main.yml | 3207 ++++++++--------- .../rds_option_group/defaults/main.yml | 17 +- .../targets/rds_option_group/meta/main.yml | 1 + .../targets/rds_option_group/tasks/main.yml | 1824 +++++----- 5 files changed, 2516 insertions(+), 2539 deletions(-) diff --git a/tests/integration/targets/elb_application_lb/defaults/main.yml b/tests/integration/targets/elb_application_lb/defaults/main.yml index 71985192471..b591e4ae635 100644 --- a/tests/integration/targets/elb_application_lb/defaults/main.yml +++ b/tests/integration/targets/elb_application_lb/defaults/main.yml @@ -1,6 +1,7 @@ +--- # defaults file for elb_application_lb -resource_short: "{{ '%0.8x'%((16**8) | random(seed=resource_prefix)) }}" +resource_short: "{{ '%0.8x' % ((16**8) | random(seed=resource_prefix)) }}" alb_name: alb-test-{{ resource_short }} alb_2_name: alb-test-2-{{ resource_short }} tg_name: alb-test-{{ resource_short }} @@ -24,5 +25,4 @@ elb_access_log_account_id_map: us-gov-east-1: "190560391635" us-gov-west-1: "048591011584" - -elb_account_id: '{{ elb_access_log_account_id_map[aws_region] }}' +elb_account_id: "{{ elb_access_log_account_id_map[aws_region] }}" diff --git a/tests/integration/targets/elb_application_lb/tasks/main.yml b/tests/integration/targets/elb_application_lb/tasks/main.yml index 1b0762e25af..37ef332001b 100644 --- a/tests/integration/targets/elb_application_lb/tasks/main.yml +++ b/tests/integration/targets/elb_application_lb/tasks/main.yml @@ -1,1659 +1,1652 @@ -- name: elb_application_lb integration tests +--- +- name: Elb_application_lb integration tests module_defaults: group/aws: - access_key: '{{ aws_access_key }}' - secret_key: '{{ aws_secret_key }}' - session_token: '{{ security_token | default(omit) }}' - region: '{{ aws_region }}' + access_key: "{{ aws_access_key }}" + secret_key: "{{ aws_secret_key }}" + session_token: "{{ security_token | default(omit) }}" + region: "{{ aws_region }}" block: - - name: Create a test VPC - ec2_vpc_net: - cidr_block: '{{ vpc_cidr }}' - name: '{{ resource_prefix }}_vpc' - state: present - ipv6_cidr: true - tags: - Name: elb_application_lb testing - ResourcePrefix: '{{ resource_prefix }}' - register: vpc - - name: 'Set fact: VPC ID' - set_fact: - vpc_id: '{{ vpc.vpc.id }}' - - name: Get VPC's default security group - ec2_security_group_info: - filters: - vpc-id: '{{ vpc_id }}' - register: default_sg - - name: Create an internet gateway - ec2_vpc_igw: - vpc_id: '{{ vpc_id }}' - state: present - tags: - Name: '{{ resource_prefix }}' - register: igw - - name: Create private subnets - ec2_vpc_subnet: - cidr: '{{ item.cidr }}' - az: '{{ aws_region }}{{ item.az }}' - vpc_id: '{{ vpc_id }}' - state: present - tags: - Public: 'False' - Name: private-{{ item.az }} - with_items: - - cidr: '{{ private_subnet_cidr_1 }}' - az: a - - cidr: '{{ private_subnet_cidr_2 }}' - az: b - register: private_subnets - - name: Create public subnets with ipv6 - ec2_vpc_subnet: - cidr: '{{ item.cidr }}' - az: '{{ aws_region }}{{ item.az }}' - vpc_id: '{{ vpc_id }}' - state: present - ipv6_cidr: '{{ item.vpc_ipv6_cidr }}' - tags: - Public: 'True' - Name: public-{{ item.az }} - with_items: - - cidr: '{{ public_subnet_cidr_1 }}' - az: a - vpc_ipv6_cidr: "{{ vpc.vpc.ipv6_cidr_block_association_set[0].ipv6_cidr_block\ - \ | replace('0::/56','0::/64') }}" - - cidr: '{{ public_subnet_cidr_2 }}' - az: b - vpc_ipv6_cidr: "{{ vpc.vpc.ipv6_cidr_block_association_set[0].ipv6_cidr_block\ - \ | replace('0::/56','1::/64') }}" - register: public_subnets - - name: Create list of subnet ids - set_fact: - public_subnets: "{{ public_subnets.results | map(attribute='subnet') | map(attribute='id')\ - \ }}" - private_subnets: "{{ private_subnets.results | map(attribute='subnet') | map(attribute='id')\ - \ }}" - - name: Create a route table - ec2_vpc_route_table: - vpc_id: '{{ vpc_id }}' - tags: - Name: igw-route - Created: '{{ resource_prefix }}' - subnets: '{{ public_subnets + private_subnets }}' - routes: - - dest: 0.0.0.0/0 - gateway_id: '{{ igw.gateway_id }}' - register: route_table - - name: Create a security group for Ansible ALB integration tests - ec2_security_group: - name: '{{ resource_prefix }}' - description: security group for Ansible ALB integration tests - state: present - vpc_id: '{{ vpc_id }}' - rules: - - proto: tcp - from_port: 1 - to_port: 65535 - cidr_ip: 0.0.0.0/0 - register: sec_group - - name: Create another security group for Ansible ALB integration tests - ec2_security_group: - name: '{{ resource_prefix }}-2' - description: security group for Ansible ALB integration tests - state: present - vpc_id: '{{ vpc_id }}' - rules: - - proto: tcp - from_port: 1 - to_port: 65535 - cidr_ip: 0.0.0.0/0 - register: sec_group2 - - name: Create a target group for testing - elb_target_group: - name: '{{ tg_name }}' - protocol: http - port: 80 - vpc_id: '{{ vpc_id }}' - state: present - register: tg - - name: Create a second target group for testing - community.aws.elb_target_group: - name: '{{ tg_2_name }}' - protocol: http - port: 80 - vpc_id: '{{ vpc_id }}' - state: present - register: tg_2 - - name: Get ARN of calling user - amazon.aws.aws_caller_info: - register: aws_caller_info - - name: Register account id - ansible.builtin.set_fact: - aws_account: "{{ aws_caller_info.account }}" - - name: Create S3 bucket for testing - amazon.aws.s3_bucket: - name: "{{ s3_bucket_name }}" - state: present - encryption: "aws:kms" - policy: "{{ lookup('template', 'policy.json') }}" - - - name: Create an ALB (invalid - SslPolicy is required when Protocol == HTTPS) - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group.group_id }}' - state: present - listeners: - - Protocol: HTTPS - Port: 80 - DefaultActions: - - Type: forward - TargetGroupName: '{{ tg_name }}' - ignore_errors: yes - register: alb - - assert: - that: - - alb is failed - - alb.msg is match("'SslPolicy' is a required listener dict key when Protocol - = HTTPS") - - - name: Create an ALB (invalid - didn't provide required listener options) - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group.group_id }}' - state: present - listeners: - - Port: 80 - ignore_errors: yes - register: alb - - assert: - that: - - alb is failed - - alb.msg is match("missing required arguments:\ DefaultActions, Protocol found - in listeners") - - - name: Create an ALB (invalid - invalid listener option type) - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group.group_id }}' - state: present - listeners: - - Protocol: HTTP - Port: bad type - DefaultActions: - - Type: forward - TargetGroupName: '{{ tg_name }}' - ignore_errors: yes - register: alb - - assert: - that: - - alb is failed - - "'unable to convert to int' in alb.msg" - - - name: Create an ALB (invalid - invalid ip address type) - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group.group_id }}' - state: present - listeners: - - Protocol: HTTP - Port: 80 - DefaultActions: - - Type: forward - TargetGroupName: '{{ tg_name }}' - ip_address_type: ip_addr_v4_v6 - ignore_errors: yes - register: alb - - assert: - that: - - alb is failed + - name: Create a test VPC + amazon.aws.ec2_vpc_net: + cidr_block: "{{ vpc_cidr }}" + name: "{{ resource_prefix }}_vpc" + state: present + ipv6_cidr: true + tags: + Name: elb_application_lb testing + ResourcePrefix: "{{ resource_prefix }}" + register: vpc + - name: "Set fact: VPC ID" + ansible.builtin.set_fact: + vpc_id: "{{ vpc.vpc.id }}" + - name: Get VPC's default security group + amazon.aws.ec2_security_group_info: + filters: + vpc-id: "{{ vpc_id }}" + register: default_sg + - name: Create an internet gateway + amazon.aws.ec2_vpc_igw: + vpc_id: "{{ vpc_id }}" + state: present + tags: + Name: "{{ resource_prefix }}" + register: igw + - name: Create private subnets + amazon.aws.ec2_vpc_subnet: + cidr: "{{ item.cidr }}" + az: "{{ aws_region }}{{ item.az }}" + vpc_id: "{{ vpc_id }}" + state: present + tags: + Public: "False" + Name: private-{{ item.az }} + with_items: + - cidr: "{{ private_subnet_cidr_1 }}" + az: a + - cidr: "{{ private_subnet_cidr_2 }}" + az: b + register: private_subnets + - name: Create public subnets with ipv6 + amazon.aws.ec2_vpc_subnet: + cidr: "{{ item.cidr }}" + az: "{{ aws_region }}{{ item.az }}" + vpc_id: "{{ vpc_id }}" + state: present + ipv6_cidr: "{{ item.vpc_ipv6_cidr }}" + tags: + Public: "True" + Name: public-{{ item.az }} + with_items: + - cidr: "{{ public_subnet_cidr_1 }}" + az: a + vpc_ipv6_cidr: "{{ vpc.vpc.ipv6_cidr_block_association_set[0].ipv6_cidr_block | replace('0::/56', '0::/64') }}" + - cidr: "{{ public_subnet_cidr_2 }}" + az: b + vpc_ipv6_cidr: "{{ vpc.vpc.ipv6_cidr_block_association_set[0].ipv6_cidr_block | replace('0::/56', '1::/64') }}" + register: public_subnets + - name: Create list of subnet ids + ansible.builtin.set_fact: + public_subnets: "{{ public_subnets.results | map(attribute='subnet') | map(attribute='id') }}" + private_subnets: "{{ private_subnets.results | map(attribute='subnet') | map(attribute='id') }}" + - name: Create a route table + amazon.aws.ec2_vpc_route_table: + vpc_id: "{{ vpc_id }}" + tags: + Name: igw-route + Created: "{{ resource_prefix }}" + subnets: "{{ public_subnets + private_subnets }}" + routes: + - dest: "0.0.0.0/0" + gateway_id: "{{ igw.gateway_id }}" + register: route_table + - name: Create a security group for Ansible ALB integration tests + amazon.aws.ec2_security_group: + name: "{{ resource_prefix }}" + description: security group for Ansible ALB integration tests + state: present + vpc_id: "{{ vpc_id }}" + rules: + - proto: tcp + from_port: 1 + to_port: 65535 + cidr_ip: "0.0.0.0/0" + register: sec_group + - name: Create another security group for Ansible ALB integration tests + amazon.aws.ec2_security_group: + name: "{{ resource_prefix }}-2" + description: security group for Ansible ALB integration tests + state: present + vpc_id: "{{ vpc_id }}" + rules: + - proto: tcp + from_port: 1 + to_port: 65535 + cidr_ip: "0.0.0.0/0" + register: sec_group2 + - name: Create a target group for testing + community.aws.elb_target_group: + name: "{{ tg_name }}" + protocol: http + port: 80 + vpc_id: "{{ vpc_id }}" + state: present + register: tg + - name: Create a second target group for testing + community.aws.elb_target_group: + name: "{{ tg_2_name }}" + protocol: http + port: 80 + vpc_id: "{{ vpc_id }}" + state: present + register: tg_2 + - name: Get ARN of calling user + amazon.aws.aws_caller_info: + register: aws_caller_info + - name: Register account id + ansible.builtin.set_fact: + aws_account: "{{ aws_caller_info.account }}" + - name: Create S3 bucket for testing + amazon.aws.s3_bucket: + name: "{{ s3_bucket_name }}" + state: present + encryption: aws:kms + policy: "{{ lookup('template', 'policy.json') }}" + + - name: Create an ALB (invalid - SslPolicy is required when Protocol == HTTPS) + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group.group_id }}" + state: present + listeners: + - Protocol: HTTPS + Port: 80 + DefaultActions: + - Type: forward + TargetGroupName: "{{ tg_name }}" + ignore_errors: true # noqa: ignore-errors + register: alb + - ansible.builtin.assert: + that: + - alb is failed + - alb.msg is match("'SslPolicy' is a required listener dict key when Protocol = HTTPS") + + - name: Create an ALB (invalid - didn't provide required listener options) + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group.group_id }}" + state: present + listeners: + - Port: 80 + ignore_errors: true # noqa: ignore-errors + register: alb + - ansible.builtin.assert: + that: + - alb is failed + - alb.msg is match("missing required arguments:\ DefaultActions, Protocol found in listeners") + + - name: Create an ALB (invalid - invalid listener option type) + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group.group_id }}" + state: present + listeners: + - Protocol: HTTP + Port: bad type + DefaultActions: + - Type: forward + TargetGroupName: "{{ tg_name }}" + ignore_errors: true # noqa: ignore-errors + register: alb + - ansible.builtin.assert: + that: + - alb is failed + - "'unable to convert to int' in alb.msg" + + - name: Create an ALB (invalid - invalid ip address type) + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group.group_id }}" + state: present + listeners: + - Protocol: HTTP + Port: 80 + DefaultActions: + - Type: forward + TargetGroupName: "{{ tg_name }}" + ip_address_type: ip_addr_v4_v6 + ignore_errors: true # noqa: ignore-errors + register: alb + - ansible.builtin.assert: + that: + - alb is failed # ------------------------------------------------------------------------------------------ - - name: Create an ALB with defaults - check_mode - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: [] - state: present - listeners: - - Protocol: HTTP - Port: 80 - DefaultActions: - - Type: forward - TargetGroupName: '{{ tg_name }}' - register: alb - check_mode: yes - - assert: - that: - - alb is changed - - alb.msg is match('Would have created ALB if not in check mode.') - - - name: Create an ALB with defaults - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: [] - state: present - listeners: - - Protocol: HTTP - Port: 80 - DefaultActions: - - Type: forward - TargetGroupName: '{{ tg_name }}' - register: alb - - assert: - that: - - alb is changed - - alb.listeners[0].rules | length == 1 - - alb.security_groups | length == 1 - - alb.security_groups[0] == default_sg.security_groups[0].group_id - - - name: Create an ALB with defaults (idempotence) - check_mode - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: [] - state: present - listeners: - - Protocol: HTTP - Port: 80 - DefaultActions: - - Type: forward - TargetGroupName: '{{ tg_name }}' - register: alb - check_mode: yes - - assert: - that: - - alb is not changed - - alb.msg is match('IN CHECK MODE - no changes to make to ALB specified.') - - - name: Create an ALB with defaults (idempotence) - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: [] - state: present - listeners: - - Protocol: HTTP - Port: 80 - DefaultActions: - - Type: forward - TargetGroupName: '{{ tg_name }}' - register: alb - - assert: - that: - - alb is not changed - - alb.listeners[0].rules | length == 1 - - alb.security_groups[0] == default_sg.security_groups[0].group_id + - name: Create an ALB with defaults - check_mode + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: [] + state: present + listeners: + - Protocol: HTTP + Port: 80 + DefaultActions: + - Type: forward + TargetGroupName: "{{ tg_name }}" + register: alb + check_mode: true + - ansible.builtin.assert: + that: + - alb is changed + - alb.msg is match('Would have created ALB if not in check mode.') + + - name: Create an ALB with defaults + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: [] + state: present + listeners: + - Protocol: HTTP + Port: 80 + DefaultActions: + - Type: forward + TargetGroupName: "{{ tg_name }}" + register: alb + - ansible.builtin.assert: + that: + - alb is changed + - alb.listeners[0].rules | length == 1 + - alb.security_groups | length == 1 + - alb.security_groups[0] == default_sg.security_groups[0].group_id + + - name: Create an ALB with defaults (idempotence) - check_mode + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: [] + state: present + listeners: + - Protocol: HTTP + Port: 80 + DefaultActions: + - Type: forward + TargetGroupName: "{{ tg_name }}" + register: alb + check_mode: true + - ansible.builtin.assert: + that: + - alb is not changed + - alb.msg is match('IN CHECK MODE - no changes to make to ALB specified.') + + - name: Create an ALB with defaults (idempotence) + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: [] + state: present + listeners: + - Protocol: HTTP + Port: 80 + DefaultActions: + - Type: forward + TargetGroupName: "{{ tg_name }}" + register: alb + - ansible.builtin.assert: + that: + - alb is not changed + - alb.listeners[0].rules | length == 1 + - alb.security_groups[0] == default_sg.security_groups[0].group_id # ------------------------------------------------------------------------------------------ - - name: Create an ALB with attributes - check_mode - amazon.aws.elb_application_lb: - name: '{{ alb_2_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group.group_id }}' - state: present - listeners: - - Protocol: HTTP - Port: 80 - DefaultActions: - - Type: forward - TargetGroupName: '{{ tg_2_name }}' - access_logs_enabled: true - access_logs_s3_bucket: "{{ s3_bucket_name }}" - access_logs_s3_prefix: "alb-logs" - ip_address_type: dualstack - http2: false - http_desync_mitigation_mode: monitor - http_drop_invalid_header_fields: true - http_x_amzn_tls_version_and_cipher_suite: true - http_xff_client_port: true - waf_fail_open: true - register: alb_2 - check_mode: true - - - name: Verify check mode response - ansible.builtin.assert: - that: - - alb_2 is changed - - alb_2.msg is match('Would have created ALB if not in check mode.') - - - name: Create an ALB with attributes - amazon.aws.elb_application_lb: - name: '{{ alb_2_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group.group_id }}' - state: present - listeners: - - Protocol: HTTP - Port: 80 - DefaultActions: - - Type: forward - TargetGroupName: '{{ tg_2_name }}' - access_logs_enabled: true - access_logs_s3_bucket: "{{ s3_bucket_name }}" - access_logs_s3_prefix: "alb-logs" - http2: false - http_desync_mitigation_mode: monitor - http_drop_invalid_header_fields: true - http_x_amzn_tls_version_and_cipher_suite: true - http_xff_client_port: true - idle_timeout: 120 - ip_address_type: dualstack - waf_fail_open: true - register: alb_2 - - - name: Verify ALB was created with correct attributes - ansible.builtin.assert: - that: - - alb_2 is changed - - alb_2.listeners[0].rules | length == 1 - - alb_2.security_groups | length == 1 - - alb_2.security_groups[0] == sec_group.group_id - - alb_2.ip_address_type == 'dualstack' - - alb_2.access_logs_s3_enabled | bool - - alb_2.access_logs_s3_bucket == s3_bucket_name - - alb_2.access_logs_s3_prefix == "alb-logs" - - not alb_2.routing_http2_enabled | bool - - alb_2.routing_http_desync_mitigation_mode == 'monitor' - - alb_2.routing_http_drop_invalid_header_fields_enabled | bool - - alb_2.routing_http_x_amzn_tls_version_and_cipher_suite_enabled | bool - - alb_2.routing_http_xff_client_port_enabled | bool - - alb_2.idle_timeout_timeout_seconds == "120" - - alb_2.waf_fail_open_enabled | bool - - - name: Create an ALB with attributes (idempotence) - check_mode - amazon.aws.elb_application_lb: - name: '{{ alb_2_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group.group_id }}' - state: present - listeners: - - Protocol: HTTP - Port: 80 - DefaultActions: - - Type: forward - TargetGroupName: '{{ tg_2_name }}' - access_logs_enabled: true - access_logs_s3_bucket: "{{ s3_bucket_name }}" - access_logs_s3_prefix: "alb-logs" - ip_address_type: dualstack - http2: false - http_desync_mitigation_mode: monitor - http_drop_invalid_header_fields: true - http_x_amzn_tls_version_and_cipher_suite: true - http_xff_client_port: true - waf_fail_open: true - register: alb_2 - check_mode: true - - - name: Verify idempotence check mode response - ansible.builtin.assert: - that: - - alb_2 is not changed - - alb_2.msg is match('IN CHECK MODE - no changes to make to ALB specified.') - - - name: Create an ALB with attributes (idempotence) - amazon.aws.elb_application_lb: - name: '{{ alb_2_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group.group_id }}' - state: present - listeners: - - Protocol: HTTP - Port: 80 - DefaultActions: - - Type: forward - TargetGroupName: '{{ tg_2_name }}' - access_logs_enabled: true - access_logs_s3_bucket: "{{ s3_bucket_name }}" - access_logs_s3_prefix: "alb-logs" - ip_address_type: dualstack - http2: false - http_desync_mitigation_mode: monitor - http_drop_invalid_header_fields: true - http_x_amzn_tls_version_and_cipher_suite: true - http_xff_client_port: true - waf_fail_open: true - register: alb_2 - - - name: Verify ALB was not changed - ansible.builtin.assert: - that: - - alb_2 is not changed - - alb_2.listeners[0].rules | length == 1 - - alb_2.security_groups | length == 1 - - alb_2.security_groups[0] == sec_group.group_id - - alb_2.ip_address_type == 'dualstack' - - alb_2.access_logs_s3_enabled | bool - - alb_2.access_logs_s3_bucket == s3_bucket_name - - alb_2.access_logs_s3_prefix == "alb-logs" - - not alb_2.routing_http2_enabled | bool - - alb_2.routing_http_desync_mitigation_mode == 'monitor' - - alb_2.routing_http_drop_invalid_header_fields_enabled | bool - - alb_2.routing_http_x_amzn_tls_version_and_cipher_suite_enabled | bool - - alb_2.routing_http_xff_client_port_enabled | bool - - alb_2.idle_timeout_timeout_seconds == "120" - - alb_2.waf_fail_open_enabled | bool + - name: Create an ALB with attributes - check_mode + amazon.aws.elb_application_lb: + name: "{{ alb_2_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group.group_id }}" + state: present + listeners: + - Protocol: HTTP + Port: 80 + DefaultActions: + - Type: forward + TargetGroupName: "{{ tg_2_name }}" + access_logs_enabled: true + access_logs_s3_bucket: "{{ s3_bucket_name }}" + access_logs_s3_prefix: alb-logs + ip_address_type: dualstack + http2: false + http_desync_mitigation_mode: monitor + http_drop_invalid_header_fields: true + http_x_amzn_tls_version_and_cipher_suite: true + http_xff_client_port: true + waf_fail_open: true + register: alb_2 + check_mode: true + + - name: Verify check mode response + ansible.builtin.assert: + that: + - alb_2 is changed + - alb_2.msg is match('Would have created ALB if not in check mode.') + + - name: Create an ALB with attributes + amazon.aws.elb_application_lb: + name: "{{ alb_2_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group.group_id }}" + state: present + listeners: + - Protocol: HTTP + Port: 80 + DefaultActions: + - Type: forward + TargetGroupName: "{{ tg_2_name }}" + access_logs_enabled: true + access_logs_s3_bucket: "{{ s3_bucket_name }}" + access_logs_s3_prefix: alb-logs + http2: false + http_desync_mitigation_mode: monitor + http_drop_invalid_header_fields: true + http_x_amzn_tls_version_and_cipher_suite: true + http_xff_client_port: true + idle_timeout: 120 + ip_address_type: dualstack + waf_fail_open: true + register: alb_2 + + - name: Verify ALB was created with correct attributes + ansible.builtin.assert: + that: + - alb_2 is changed + - alb_2.listeners[0].rules | length == 1 + - alb_2.security_groups | length == 1 + - alb_2.security_groups[0] == sec_group.group_id + - alb_2.ip_address_type == 'dualstack' + - alb_2.access_logs_s3_enabled | bool + - alb_2.access_logs_s3_bucket == s3_bucket_name + - alb_2.access_logs_s3_prefix == "alb-logs" + - not alb_2.routing_http2_enabled | bool + - alb_2.routing_http_desync_mitigation_mode == 'monitor' + - alb_2.routing_http_drop_invalid_header_fields_enabled | bool + - alb_2.routing_http_x_amzn_tls_version_and_cipher_suite_enabled | bool + - alb_2.routing_http_xff_client_port_enabled | bool + - alb_2.idle_timeout_timeout_seconds == "120" + - alb_2.waf_fail_open_enabled | bool + + - name: Create an ALB with attributes (idempotence) - check_mode + amazon.aws.elb_application_lb: + name: "{{ alb_2_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group.group_id }}" + state: present + listeners: + - Protocol: HTTP + Port: 80 + DefaultActions: + - Type: forward + TargetGroupName: "{{ tg_2_name }}" + access_logs_enabled: true + access_logs_s3_bucket: "{{ s3_bucket_name }}" + access_logs_s3_prefix: alb-logs + ip_address_type: dualstack + http2: false + http_desync_mitigation_mode: monitor + http_drop_invalid_header_fields: true + http_x_amzn_tls_version_and_cipher_suite: true + http_xff_client_port: true + waf_fail_open: true + register: alb_2 + check_mode: true + + - name: Verify idempotence check mode response + ansible.builtin.assert: + that: + - alb_2 is not changed + - alb_2.msg is match('IN CHECK MODE - no changes to make to ALB specified.') + + - name: Create an ALB with attributes (idempotence) + amazon.aws.elb_application_lb: + name: "{{ alb_2_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group.group_id }}" + state: present + listeners: + - Protocol: HTTP + Port: 80 + DefaultActions: + - Type: forward + TargetGroupName: "{{ tg_2_name }}" + access_logs_enabled: true + access_logs_s3_bucket: "{{ s3_bucket_name }}" + access_logs_s3_prefix: alb-logs + ip_address_type: dualstack + http2: false + http_desync_mitigation_mode: monitor + http_drop_invalid_header_fields: true + http_x_amzn_tls_version_and_cipher_suite: true + http_xff_client_port: true + waf_fail_open: true + register: alb_2 + + - name: Verify ALB was not changed + ansible.builtin.assert: + that: + - alb_2 is not changed + - alb_2.listeners[0].rules | length == 1 + - alb_2.security_groups | length == 1 + - alb_2.security_groups[0] == sec_group.group_id + - alb_2.ip_address_type == 'dualstack' + - alb_2.access_logs_s3_enabled | bool + - alb_2.access_logs_s3_bucket == s3_bucket_name + - alb_2.access_logs_s3_prefix == "alb-logs" + - not alb_2.routing_http2_enabled | bool + - alb_2.routing_http_desync_mitigation_mode == 'monitor' + - alb_2.routing_http_drop_invalid_header_fields_enabled | bool + - alb_2.routing_http_x_amzn_tls_version_and_cipher_suite_enabled | bool + - alb_2.routing_http_xff_client_port_enabled | bool + - alb_2.idle_timeout_timeout_seconds == "120" + - alb_2.waf_fail_open_enabled | bool # ------------------------------------------------------------------------------------------ - - name: Update an ALB with ip address type - check_mode - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group.group_id }}' - state: present - listeners: - - Protocol: HTTP - Port: 80 - DefaultActions: - - Type: forward - TargetGroupName: '{{ tg_name }}' - ip_address_type: dualstack - register: alb - check_mode: yes - - assert: - that: - - alb is changed - - alb.msg is match('Would have updated ALB if not in check mode.') - - - name: Update an ALB with ip address type - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group.group_id }}' - state: present - listeners: - - Protocol: HTTP - Port: 80 - DefaultActions: - - Type: forward - TargetGroupName: '{{ tg_name }}' - ip_address_type: dualstack - register: alb - - assert: - that: - - alb is changed - - alb.ip_address_type == 'dualstack' - - alb.listeners[0].rules | length == 1 - - alb.routing_http2_enabled | bool - - alb.routing_http_desync_mitigation_mode == 'defensive' - - not alb.routing_http_drop_invalid_header_fields_enabled | bool - - not alb.routing_http_x_amzn_tls_version_and_cipher_suite_enabled | bool - - not alb.routing_http_xff_client_port_enabled | bool - - not alb.waf_fail_open_enabled | bool - - - name: Create an ALB with ip address type (idempotence) - check_mode - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group.group_id }}' - state: present - listeners: - - Protocol: HTTP - Port: 80 - DefaultActions: - - Type: forward - TargetGroupName: '{{ tg_name }}' - ip_address_type: dualstack - register: alb - check_mode: yes - - assert: - that: - - alb is not changed - - alb.msg is match('IN CHECK MODE - no changes to make to ALB specified.') - - - name: Create an ALB with ip address type (idempotence) - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group.group_id }}' - state: present - listeners: - - Protocol: HTTP - Port: 80 - DefaultActions: - - Type: forward - TargetGroupName: '{{ tg_name }}' - ip_address_type: dualstack - register: alb - - assert: - that: - - alb is not changed - - alb.ip_address_type == 'dualstack' - - alb.routing_http2_enabled | bool - - alb.routing_http_desync_mitigation_mode == 'defensive' - - not alb.routing_http_drop_invalid_header_fields_enabled | bool - - not alb.routing_http_x_amzn_tls_version_and_cipher_suite_enabled | bool - - not alb.routing_http_xff_client_port_enabled | bool - - not alb.waf_fail_open_enabled | bool + - name: Update an ALB with ip address type - check_mode + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group.group_id }}" + state: present + listeners: + - Protocol: HTTP + Port: 80 + DefaultActions: + - Type: forward + TargetGroupName: "{{ tg_name }}" + ip_address_type: dualstack + register: alb + check_mode: true + - ansible.builtin.assert: + that: + - alb is changed + - alb.msg is match('Would have updated ALB if not in check mode.') + + - name: Update an ALB with ip address type + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group.group_id }}" + state: present + listeners: + - Protocol: HTTP + Port: 80 + DefaultActions: + - Type: forward + TargetGroupName: "{{ tg_name }}" + ip_address_type: dualstack + register: alb + - ansible.builtin.assert: + that: + - alb is changed + - alb.ip_address_type == 'dualstack' + - alb.listeners[0].rules | length == 1 + - alb.routing_http2_enabled | bool + - alb.routing_http_desync_mitigation_mode == 'defensive' + - not alb.routing_http_drop_invalid_header_fields_enabled | bool + - not alb.routing_http_x_amzn_tls_version_and_cipher_suite_enabled | bool + - not alb.routing_http_xff_client_port_enabled | bool + - not alb.waf_fail_open_enabled | bool + + - name: Create an ALB with ip address type (idempotence) - check_mode + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group.group_id }}" + state: present + listeners: + - Protocol: HTTP + Port: 80 + DefaultActions: + - Type: forward + TargetGroupName: "{{ tg_name }}" + ip_address_type: dualstack + register: alb + check_mode: true + - ansible.builtin.assert: + that: + - alb is not changed + - alb.msg is match('IN CHECK MODE - no changes to make to ALB specified.') + + - name: Create an ALB with ip address type (idempotence) + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group.group_id }}" + state: present + listeners: + - Protocol: HTTP + Port: 80 + DefaultActions: + - Type: forward + TargetGroupName: "{{ tg_name }}" + ip_address_type: dualstack + register: alb + - ansible.builtin.assert: + that: + - alb is not changed + - alb.ip_address_type == 'dualstack' + - alb.routing_http2_enabled | bool + - alb.routing_http_desync_mitigation_mode == 'defensive' + - not alb.routing_http_drop_invalid_header_fields_enabled | bool + - not alb.routing_http_x_amzn_tls_version_and_cipher_suite_enabled | bool + - not alb.routing_http_xff_client_port_enabled | bool + - not alb.waf_fail_open_enabled | bool # ------------------------------------------------------------------------------------------ - - name: Update an ALB with different attributes - check_mode - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group.group_id }}' - state: present - listeners: - - Protocol: HTTP - Port: 80 - DefaultActions: - - Type: forward - TargetGroupName: '{{ tg_name }}' - ip_address_type: dualstack - http2: no - http_desync_mitigation_mode: monitor - http_drop_invalid_header_fields: yes - http_x_amzn_tls_version_and_cipher_suite: yes - http_xff_client_port: yes - waf_fail_open: yes - register: alb - check_mode: yes - - assert: - that: - - alb is changed - - alb.msg is match('Would have updated ALB if not in check mode.') - - - name: Update an ALB with different attributes - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group.group_id }}' - state: present - listeners: - - Protocol: HTTP - Port: 80 - DefaultActions: - - Type: forward - TargetGroupName: '{{ tg_name }}' - ip_address_type: dualstack - http2: no - http_desync_mitigation_mode: monitor - http_drop_invalid_header_fields: yes - http_x_amzn_tls_version_and_cipher_suite: yes - http_xff_client_port: yes - waf_fail_open: yes - register: alb - - assert: - that: - - alb is changed - - alb.ip_address_type == 'dualstack' - - not alb.routing_http2_enabled | bool - - alb.routing_http_desync_mitigation_mode == 'monitor' - - alb.routing_http_drop_invalid_header_fields_enabled | bool - - alb.routing_http_x_amzn_tls_version_and_cipher_suite_enabled | bool - - alb.routing_http_xff_client_port_enabled | bool - - alb.waf_fail_open_enabled | bool - - - name: Update an ALB with different attributes (idempotence) - check_mode - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group.group_id }}' - state: present - listeners: - - Protocol: HTTP - Port: 80 - DefaultActions: - - Type: forward - TargetGroupName: '{{ tg_name }}' - ip_address_type: dualstack - http2: no - http_desync_mitigation_mode: monitor - http_drop_invalid_header_fields: yes - http_x_amzn_tls_version_and_cipher_suite: yes - http_xff_client_port: yes - waf_fail_open: yes - register: alb - check_mode: yes - - assert: - that: - - alb is not changed - - alb.msg is match('IN CHECK MODE - no changes to make to ALB specified.') - - - name: Update an ALB with different attributes (idempotence) - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group.group_id }}' - state: present - listeners: - - Protocol: HTTP - Port: 80 - DefaultActions: - - Type: forward - TargetGroupName: '{{ tg_name }}' - ip_address_type: dualstack - http2: no - http_desync_mitigation_mode: monitor - http_drop_invalid_header_fields: yes - http_x_amzn_tls_version_and_cipher_suite: yes - http_xff_client_port: yes - waf_fail_open: yes - register: alb - - assert: - that: - - alb is not changed - - alb.ip_address_type == 'dualstack' - - not alb.routing_http2_enabled | bool - - alb.routing_http_desync_mitigation_mode == 'monitor' - - alb.routing_http_drop_invalid_header_fields_enabled | bool - - alb.routing_http_x_amzn_tls_version_and_cipher_suite_enabled | bool - - alb.routing_http_xff_client_port_enabled | bool - - alb.waf_fail_open_enabled | bool + - name: Update an ALB with different attributes - check_mode + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group.group_id }}" + state: present + listeners: + - Protocol: HTTP + Port: 80 + DefaultActions: + - Type: forward + TargetGroupName: "{{ tg_name }}" + ip_address_type: dualstack + http2: false + http_desync_mitigation_mode: monitor + http_drop_invalid_header_fields: true + http_x_amzn_tls_version_and_cipher_suite: true + http_xff_client_port: true + waf_fail_open: true + register: alb + check_mode: true + - ansible.builtin.assert: + that: + - alb is changed + - alb.msg is match('Would have updated ALB if not in check mode.') + + - name: Update an ALB with different attributes + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group.group_id }}" + state: present + listeners: + - Protocol: HTTP + Port: 80 + DefaultActions: + - Type: forward + TargetGroupName: "{{ tg_name }}" + ip_address_type: dualstack + http2: false + http_desync_mitigation_mode: monitor + http_drop_invalid_header_fields: true + http_x_amzn_tls_version_and_cipher_suite: true + http_xff_client_port: true + waf_fail_open: true + register: alb + - ansible.builtin.assert: + that: + - alb is changed + - alb.ip_address_type == 'dualstack' + - not alb.routing_http2_enabled | bool + - alb.routing_http_desync_mitigation_mode == 'monitor' + - alb.routing_http_drop_invalid_header_fields_enabled | bool + - alb.routing_http_x_amzn_tls_version_and_cipher_suite_enabled | bool + - alb.routing_http_xff_client_port_enabled | bool + - alb.waf_fail_open_enabled | bool + + - name: Update an ALB with different attributes (idempotence) - check_mode + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group.group_id }}" + state: present + listeners: + - Protocol: HTTP + Port: 80 + DefaultActions: + - Type: forward + TargetGroupName: "{{ tg_name }}" + ip_address_type: dualstack + http2: false + http_desync_mitigation_mode: monitor + http_drop_invalid_header_fields: true + http_x_amzn_tls_version_and_cipher_suite: true + http_xff_client_port: true + waf_fail_open: true + register: alb + check_mode: true + - ansible.builtin.assert: + that: + - alb is not changed + - alb.msg is match('IN CHECK MODE - no changes to make to ALB specified.') + + - name: Update an ALB with different attributes (idempotence) + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group.group_id }}" + state: present + listeners: + - Protocol: HTTP + Port: 80 + DefaultActions: + - Type: forward + TargetGroupName: "{{ tg_name }}" + ip_address_type: dualstack + http2: false + http_desync_mitigation_mode: monitor + http_drop_invalid_header_fields: true + http_x_amzn_tls_version_and_cipher_suite: true + http_xff_client_port: true + waf_fail_open: true + register: alb + - ansible.builtin.assert: + that: + - alb is not changed + - alb.ip_address_type == 'dualstack' + - not alb.routing_http2_enabled | bool + - alb.routing_http_desync_mitigation_mode == 'monitor' + - alb.routing_http_drop_invalid_header_fields_enabled | bool + - alb.routing_http_x_amzn_tls_version_and_cipher_suite_enabled | bool + - alb.routing_http_xff_client_port_enabled | bool + - alb.waf_fail_open_enabled | bool # ------------------------------------------------------------------------------------------ - - name: Update an ALB with different ip address type - check_mode - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group.group_id }}' - state: present - listeners: - - Protocol: HTTP - Port: 80 - DefaultActions: - - Type: forward - TargetGroupName: '{{ tg_name }}' - ip_address_type: ipv4 - http2: no - http_desync_mitigation_mode: monitor - http_drop_invalid_header_fields: yes - http_x_amzn_tls_version_and_cipher_suite: yes - http_xff_client_port: yes - waf_fail_open: yes - register: alb - check_mode: yes - - assert: - that: - - alb is changed - - alb.msg is match('Would have updated ALB if not in check mode.') - - - name: Update an ALB with different ip address type - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group.group_id }}' - state: present - listeners: - - Protocol: HTTP - Port: 80 - DefaultActions: - - Type: forward - TargetGroupName: '{{ tg_name }}' - ip_address_type: ipv4 - http2: no - http_desync_mitigation_mode: monitor - http_drop_invalid_header_fields: yes - http_x_amzn_tls_version_and_cipher_suite: yes - http_xff_client_port: yes - waf_fail_open: yes - register: alb - - assert: - that: - - alb is changed - - alb.ip_address_type == 'ipv4' - - not alb.routing_http2_enabled | bool - - alb.routing_http_desync_mitigation_mode == 'monitor' - - alb.routing_http_drop_invalid_header_fields_enabled | bool - - alb.routing_http_x_amzn_tls_version_and_cipher_suite_enabled | bool - - alb.routing_http_xff_client_port_enabled | bool - - alb.waf_fail_open_enabled | bool - - - name: Update an ALB with different ip address type (idempotence) - check_mode - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group.group_id }}' - state: present - listeners: - - Protocol: HTTP - Port: 80 - DefaultActions: - - Type: forward - TargetGroupName: '{{ tg_name }}' - ip_address_type: ipv4 - http2: no - http_desync_mitigation_mode: monitor - http_drop_invalid_header_fields: yes - http_x_amzn_tls_version_and_cipher_suite: yes - http_xff_client_port: yes - waf_fail_open: yes - register: alb - check_mode: yes - - assert: - that: - - alb is not changed - - alb.msg is match('IN CHECK MODE - no changes to make to ALB specified.') - - - name: Update an ALB with different ip address type (idempotence) - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group.group_id }}' - state: present - listeners: - - Protocol: HTTP - Port: 80 - DefaultActions: - - Type: forward - TargetGroupName: '{{ tg_name }}' - ip_address_type: ipv4 - http2: no - http_desync_mitigation_mode: monitor - http_drop_invalid_header_fields: yes - http_x_amzn_tls_version_and_cipher_suite: yes - http_xff_client_port: yes - waf_fail_open: yes - register: alb - - assert: - that: - - alb is not changed - - alb.ip_address_type == 'ipv4' - - not alb.routing_http2_enabled | bool - - alb.routing_http_desync_mitigation_mode == 'monitor' - - alb.routing_http_drop_invalid_header_fields_enabled | bool - - alb.routing_http_x_amzn_tls_version_and_cipher_suite_enabled | bool - - alb.routing_http_xff_client_port_enabled | bool - - alb.waf_fail_open_enabled | bool + - name: Update an ALB with different ip address type - check_mode + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group.group_id }}" + state: present + listeners: + - Protocol: HTTP + Port: 80 + DefaultActions: + - Type: forward + TargetGroupName: "{{ tg_name }}" + ip_address_type: ipv4 + http2: false + http_desync_mitigation_mode: monitor + http_drop_invalid_header_fields: true + http_x_amzn_tls_version_and_cipher_suite: true + http_xff_client_port: true + waf_fail_open: true + register: alb + check_mode: true + - ansible.builtin.assert: + that: + - alb is changed + - alb.msg is match('Would have updated ALB if not in check mode.') + + - name: Update an ALB with different ip address type + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group.group_id }}" + state: present + listeners: + - Protocol: HTTP + Port: 80 + DefaultActions: + - Type: forward + TargetGroupName: "{{ tg_name }}" + ip_address_type: ipv4 + http2: false + http_desync_mitigation_mode: monitor + http_drop_invalid_header_fields: true + http_x_amzn_tls_version_and_cipher_suite: true + http_xff_client_port: true + waf_fail_open: true + register: alb + - ansible.builtin.assert: + that: + - alb is changed + - alb.ip_address_type == 'ipv4' + - not alb.routing_http2_enabled | bool + - alb.routing_http_desync_mitigation_mode == 'monitor' + - alb.routing_http_drop_invalid_header_fields_enabled | bool + - alb.routing_http_x_amzn_tls_version_and_cipher_suite_enabled | bool + - alb.routing_http_xff_client_port_enabled | bool + - alb.waf_fail_open_enabled | bool + + - name: Update an ALB with different ip address type (idempotence) - check_mode + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group.group_id }}" + state: present + listeners: + - Protocol: HTTP + Port: 80 + DefaultActions: + - Type: forward + TargetGroupName: "{{ tg_name }}" + ip_address_type: ipv4 + http2: false + http_desync_mitigation_mode: monitor + http_drop_invalid_header_fields: true + http_x_amzn_tls_version_and_cipher_suite: true + http_xff_client_port: true + waf_fail_open: true + register: alb + check_mode: true + - ansible.builtin.assert: + that: + - alb is not changed + - alb.msg is match('IN CHECK MODE - no changes to make to ALB specified.') + + - name: Update an ALB with different ip address type (idempotence) + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group.group_id }}" + state: present + listeners: + - Protocol: HTTP + Port: 80 + DefaultActions: + - Type: forward + TargetGroupName: "{{ tg_name }}" + ip_address_type: ipv4 + http2: false + http_desync_mitigation_mode: monitor + http_drop_invalid_header_fields: true + http_x_amzn_tls_version_and_cipher_suite: true + http_xff_client_port: true + waf_fail_open: true + register: alb + - ansible.builtin.assert: + that: + - alb is not changed + - alb.ip_address_type == 'ipv4' + - not alb.routing_http2_enabled | bool + - alb.routing_http_desync_mitigation_mode == 'monitor' + - alb.routing_http_drop_invalid_header_fields_enabled | bool + - alb.routing_http_x_amzn_tls_version_and_cipher_suite_enabled | bool + - alb.routing_http_xff_client_port_enabled | bool + - alb.waf_fail_open_enabled | bool # ------------------------------------------------------------------------------------------ - - name: Update an ALB with different listener by adding rule - check_mode - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group.group_id }}' - state: present - listeners: - - Protocol: HTTP - Port: 80 - DefaultActions: - - Type: forward - TargetGroupName: '{{ tg_name }}' - Rules: - - Conditions: - - Field: path-pattern - Values: - - /test - Priority: '1' - Actions: - - TargetGroupName: '{{ tg_name }}' - Type: forward - register: alb - check_mode: yes - - assert: - that: - - alb is changed - - alb.msg is match('Would have updated ALB if not in check mode.') - - - name: Update an ALB with different listener by adding rule - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group.group_id }}' - state: present - listeners: - - Protocol: HTTP - Port: 80 - DefaultActions: - - Type: forward - TargetGroupName: '{{ tg_name }}' - Rules: - - Conditions: - - Field: path-pattern - Values: - - /test - Priority: '1' - Actions: - - TargetGroupName: '{{ tg_name }}' - Type: forward - register: alb - - assert: - that: - - alb is changed - - alb.listeners[0].rules | length == 2 - - "'1' in alb.listeners[0].rules | map(attribute='priority')" - - - name: Update an ALB with different listener by adding rule (idempotence) - check_mode - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group.group_id }}' - state: present - listeners: - - Protocol: HTTP - Port: 80 - DefaultActions: - - Type: forward - TargetGroupName: '{{ tg_name }}' - Rules: - - Conditions: - - Field: path-pattern - Values: - - /test - Priority: '1' - Actions: - - TargetGroupName: '{{ tg_name }}' - Type: forward - register: alb - check_mode: yes - - assert: - that: - - alb is not changed - - alb.msg is match('IN CHECK MODE - no changes to make to ALB specified.') - - - name: Update an ALB with different listener by adding rule (idempotence) - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group.group_id }}' - state: present - listeners: - - Protocol: HTTP - Port: 80 - DefaultActions: - - Type: forward - TargetGroupName: '{{ tg_name }}' - Rules: - - Conditions: - - Field: path-pattern - Values: - - /test - Priority: '1' - Actions: - - TargetGroupName: '{{ tg_name }}' - Type: forward - register: alb - - assert: - that: - - alb is not changed - - alb.listeners[0].rules | length == 2 - - "'1' in alb.listeners[0].rules | map(attribute='priority')" + - name: Update an ALB with different listener by adding rule - check_mode + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group.group_id }}" + state: present + listeners: + - Protocol: HTTP + Port: 80 + DefaultActions: + - Type: forward + TargetGroupName: "{{ tg_name }}" + Rules: + - Conditions: + - Field: path-pattern + Values: + - /test + Priority: "1" + Actions: + - TargetGroupName: "{{ tg_name }}" + Type: forward + register: alb + check_mode: true + - ansible.builtin.assert: + that: + - alb is changed + - alb.msg is match('Would have updated ALB if not in check mode.') + + - name: Update an ALB with different listener by adding rule + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group.group_id }}" + state: present + listeners: + - Protocol: HTTP + Port: 80 + DefaultActions: + - Type: forward + TargetGroupName: "{{ tg_name }}" + Rules: + - Conditions: + - Field: path-pattern + Values: + - /test + Priority: "1" + Actions: + - TargetGroupName: "{{ tg_name }}" + Type: forward + register: alb + - ansible.builtin.assert: + that: + - alb is changed + - alb.listeners[0].rules | length == 2 + - "'1' in alb.listeners[0].rules | map(attribute='priority')" + + - name: Update an ALB with different listener by adding rule (idempotence) - check_mode + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group.group_id }}" + state: present + listeners: + - Protocol: HTTP + Port: 80 + DefaultActions: + - Type: forward + TargetGroupName: "{{ tg_name }}" + Rules: + - Conditions: + - Field: path-pattern + Values: + - /test + Priority: "1" + Actions: + - TargetGroupName: "{{ tg_name }}" + Type: forward + register: alb + check_mode: true + - ansible.builtin.assert: + that: + - alb is not changed + - alb.msg is match('IN CHECK MODE - no changes to make to ALB specified.') + + - name: Update an ALB with different listener by adding rule (idempotence) + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group.group_id }}" + state: present + listeners: + - Protocol: HTTP + Port: 80 + DefaultActions: + - Type: forward + TargetGroupName: "{{ tg_name }}" + Rules: + - Conditions: + - Field: path-pattern + Values: + - /test + Priority: "1" + Actions: + - TargetGroupName: "{{ tg_name }}" + Type: forward + register: alb + - ansible.builtin.assert: + that: + - alb is not changed + - alb.listeners[0].rules | length == 2 + - "'1' in alb.listeners[0].rules | map(attribute='priority')" # ------------------------------------------------------------------------------------------ - - name: Update an ALB with different listener by modifying rule - check_mode - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group.group_id }}' - state: present - listeners: - - Protocol: HTTP - Port: 80 - DefaultActions: - - Type: forward - TargetGroupName: '{{ tg_name }}' - Rules: - - Conditions: - - Field: path-pattern - Values: - - /test - Priority: '2' - Actions: - - TargetGroupName: '{{ tg_name }}' - Type: forward - register: alb - check_mode: yes - - assert: - that: - - alb is changed - - alb.msg is match('Would have updated ALB if not in check mode.') - - - name: Update an ALB with different listener by modifying rule - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group.group_id }}' - state: present - listeners: - - Protocol: HTTP - Port: 80 - DefaultActions: - - Type: forward - TargetGroupName: '{{ tg_name }}' - Rules: - - Conditions: - - Field: path-pattern - Values: - - /test - Priority: '2' - Actions: - - TargetGroupName: '{{ tg_name }}' - Type: forward - register: alb - - assert: - that: - - alb is changed - - alb.listeners[0].rules | length == 2 - - "'2' in alb.listeners[0].rules | map(attribute='priority')" - - - name: Update an ALB with different listener by modifying rule (idempotence) - - check_mode - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group.group_id }}' - state: present - listeners: - - Protocol: HTTP - Port: 80 - DefaultActions: - - Type: forward - TargetGroupName: '{{ tg_name }}' - Rules: - - Conditions: - - Field: path-pattern - Values: - - /test - Priority: '2' - Actions: - - TargetGroupName: '{{ tg_name }}' - Type: forward - register: alb - check_mode: yes - - assert: - that: - - alb is not changed - - alb.msg is match('IN CHECK MODE - no changes to make to ALB specified.') - - - name: Update an ALB with different listener by modifying rule (idempotence) - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group.group_id }}' - state: present - listeners: - - Protocol: HTTP - Port: 80 - DefaultActions: - - Type: forward - TargetGroupName: '{{ tg_name }}' - Rules: - - Conditions: - - Field: path-pattern - Values: - - /test - Priority: '2' - Actions: - - TargetGroupName: '{{ tg_name }}' - Type: forward - register: alb - - assert: - that: - - alb is not changed - - alb.listeners[0].rules | length == 2 - - "'2' in alb.listeners[0].rules | map(attribute='priority')" + - name: Update an ALB with different listener by modifying rule - check_mode + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group.group_id }}" + state: present + listeners: + - Protocol: HTTP + Port: 80 + DefaultActions: + - Type: forward + TargetGroupName: "{{ tg_name }}" + Rules: + - Conditions: + - Field: path-pattern + Values: + - /test + Priority: "2" + Actions: + - TargetGroupName: "{{ tg_name }}" + Type: forward + register: alb + check_mode: true + - ansible.builtin.assert: + that: + - alb is changed + - alb.msg is match('Would have updated ALB if not in check mode.') + + - name: Update an ALB with different listener by modifying rule + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group.group_id }}" + state: present + listeners: + - Protocol: HTTP + Port: 80 + DefaultActions: + - Type: forward + TargetGroupName: "{{ tg_name }}" + Rules: + - Conditions: + - Field: path-pattern + Values: + - /test + Priority: "2" + Actions: + - TargetGroupName: "{{ tg_name }}" + Type: forward + register: alb + - ansible.builtin.assert: + that: + - alb is changed + - alb.listeners[0].rules | length == 2 + - "'2' in alb.listeners[0].rules | map(attribute='priority')" + + - name: Update an ALB with different listener by modifying rule (idempotence) - check_mode + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group.group_id }}" + state: present + listeners: + - Protocol: HTTP + Port: 80 + DefaultActions: + - Type: forward + TargetGroupName: "{{ tg_name }}" + Rules: + - Conditions: + - Field: path-pattern + Values: + - /test + Priority: "2" + Actions: + - TargetGroupName: "{{ tg_name }}" + Type: forward + register: alb + check_mode: true + - ansible.builtin.assert: + that: + - alb is not changed + - alb.msg is match('IN CHECK MODE - no changes to make to ALB specified.') + + - name: Update an ALB with different listener by modifying rule (idempotence) + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group.group_id }}" + state: present + listeners: + - Protocol: HTTP + Port: 80 + DefaultActions: + - Type: forward + TargetGroupName: "{{ tg_name }}" + Rules: + - Conditions: + - Field: path-pattern + Values: + - /test + Priority: "2" + Actions: + - TargetGroupName: "{{ tg_name }}" + Type: forward + register: alb + - ansible.builtin.assert: + that: + - alb is not changed + - alb.listeners[0].rules | length == 2 + - "'2' in alb.listeners[0].rules | map(attribute='priority')" # ------------------------------------------------------------------------------------------ - - name: Update an ALB with different listener by deleting rule - check_mode - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group.group_id }}' - state: present - listeners: - - Protocol: HTTP - Port: 80 - DefaultActions: - - Type: forward - TargetGroupName: '{{ tg_name }}' - Rules: [] - register: alb - check_mode: yes - - assert: - that: - - alb is changed - - alb.msg is match('Would have updated ALB if not in check mode.') - - - name: Update an ALB with different listener by deleting rule - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group.group_id }}' - state: present - listeners: - - Protocol: HTTP - Port: 80 - DefaultActions: - - Type: forward - TargetGroupName: '{{ tg_name }}' - Rules: [] - register: alb - - assert: - that: - - alb is changed - - alb.listeners[0].rules | length == 1 - - "'2' not in alb.listeners[0].rules | map(attribute='priority')" - - - name: Update an ALB with different listener by deleting rule (idempotence) - check_mode - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group.group_id }}' - state: present - listeners: - - Protocol: HTTP - Port: 80 - DefaultActions: - - Type: forward - TargetGroupName: '{{ tg_name }}' - Rules: [] - register: alb - check_mode: yes - - assert: - that: - - alb is not changed - - alb.msg is match('IN CHECK MODE - no changes to make to ALB specified.') - - - name: Update an ALB with different listener by deleting rule (idempotence) - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group.group_id }}' - state: present - listeners: - - Protocol: HTTP - Port: 80 - DefaultActions: - - Type: forward - TargetGroupName: '{{ tg_name }}' - Rules: [] - register: alb - - assert: - that: - - alb is not changed - - alb.listeners[0].rules | length == 1 - - "'2' not in alb.listeners[0].rules | map(attribute='priority')" + - name: Update an ALB with different listener by deleting rule - check_mode + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group.group_id }}" + state: present + listeners: + - Protocol: HTTP + Port: 80 + DefaultActions: + - Type: forward + TargetGroupName: "{{ tg_name }}" + Rules: [] + register: alb + check_mode: true + - ansible.builtin.assert: + that: + - alb is changed + - alb.msg is match('Would have updated ALB if not in check mode.') + + - name: Update an ALB with different listener by deleting rule + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group.group_id }}" + state: present + listeners: + - Protocol: HTTP + Port: 80 + DefaultActions: + - Type: forward + TargetGroupName: "{{ tg_name }}" + Rules: [] + register: alb + - ansible.builtin.assert: + that: + - alb is changed + - alb.listeners[0].rules | length == 1 + - "'2' not in alb.listeners[0].rules | map(attribute='priority')" + + - name: Update an ALB with different listener by deleting rule (idempotence) - check_mode + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group.group_id }}" + state: present + listeners: + - Protocol: HTTP + Port: 80 + DefaultActions: + - Type: forward + TargetGroupName: "{{ tg_name }}" + Rules: [] + register: alb + check_mode: true + - ansible.builtin.assert: + that: + - alb is not changed + - alb.msg is match('IN CHECK MODE - no changes to make to ALB specified.') + + - name: Update an ALB with different listener by deleting rule (idempotence) + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group.group_id }}" + state: present + listeners: + - Protocol: HTTP + Port: 80 + DefaultActions: + - Type: forward + TargetGroupName: "{{ tg_name }}" + Rules: [] + register: alb + - ansible.builtin.assert: + that: + - alb is not changed + - alb.listeners[0].rules | length == 1 + - "'2' not in alb.listeners[0].rules | map(attribute='priority')" # ------------------------------------------------------------------------------------------ - - name: Update an ALB by deleting listener - check_mode - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group.group_id }}' - state: present - listeners: [] - register: alb - check_mode: yes - - assert: - that: - - alb is changed - - alb.msg is match('Would have updated ALB if not in check mode.') - - - name: Update an ALB by deleting listener - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group.group_id }}' - state: present - listeners: [] - register: alb - - assert: - that: - - alb is changed - - not alb.listeners - - - name: Update an ALB by deleting listener (idempotence) - check_mode - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group.group_id }}' - state: present - listeners: [] - register: alb - check_mode: yes - - assert: - that: - - alb is not changed - - alb.msg is match('IN CHECK MODE - no changes to make to ALB specified.') - - - name: Update an ALB by deleting listener (idempotence) - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group.group_id }}' - state: present - listeners: [] - register: alb - - assert: - that: - - alb is not changed - - not alb.listeners + - name: Update an ALB by deleting listener - check_mode + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group.group_id }}" + state: present + listeners: [] + register: alb + check_mode: true + - ansible.builtin.assert: + that: + - alb is changed + - alb.msg is match('Would have updated ALB if not in check mode.') + + - name: Update an ALB by deleting listener + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group.group_id }}" + state: present + listeners: [] + register: alb + - ansible.builtin.assert: + that: + - alb is changed + - not alb.listeners + + - name: Update an ALB by deleting listener (idempotence) - check_mode + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group.group_id }}" + state: present + listeners: [] + register: alb + check_mode: true + - ansible.builtin.assert: + that: + - alb is not changed + - alb.msg is match('IN CHECK MODE - no changes to make to ALB specified.') + + - name: Update an ALB by deleting listener (idempotence) + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group.group_id }}" + state: present + listeners: [] + register: alb + - ansible.builtin.assert: + that: + - alb is not changed + - not alb.listeners # ------------------------------------------------------------------------------------------ - - name: Update an ALB by adding tags - check_mode - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group.group_id }}' - state: present - tags: - created_by: ALB test {{ resource_prefix }} - register: alb - check_mode: yes - - assert: - that: - - alb is changed - - alb.msg is match('Would have updated ALB if not in check mode.') - - - name: Update an ALB by adding tags - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group.group_id }}' - state: present - tags: - created_by: ALB test {{ resource_prefix }} - register: alb - - assert: - that: - - alb is changed - - alb.tags == created_tags - vars: - created_tags: - created_by: 'ALB test {{ resource_prefix }}' - - - name: Update an ALB by adding tags (idempotence) - check_mode - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group.group_id }}' - state: present - tags: - created_by: ALB test {{ resource_prefix }} - register: alb - check_mode: yes - - assert: - that: - - alb is not changed - - alb.msg is match('IN CHECK MODE - no changes to make to ALB specified.') - - - name: Update an ALB by adding tags (idempotence) - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group.group_id }}' - state: present - tags: - created_by: ALB test {{ resource_prefix }} - register: alb - - assert: - that: - - alb is not changed - - alb.tags == created_tags - vars: - created_tags: - created_by: 'ALB test {{ resource_prefix }}' + - name: Update an ALB by adding tags - check_mode + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group.group_id }}" + state: present + tags: + created_by: ALB test {{ resource_prefix }} + register: alb + check_mode: true + - ansible.builtin.assert: + that: + - alb is changed + - alb.msg is match('Would have updated ALB if not in check mode.') + + - name: Update an ALB by adding tags + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group.group_id }}" + state: present + tags: + created_by: ALB test {{ resource_prefix }} + register: alb + - ansible.builtin.assert: + that: + - alb is changed + - alb.tags == created_tags + vars: + created_tags: + created_by: ALB test {{ resource_prefix }} + + - name: Update an ALB by adding tags (idempotence) - check_mode + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group.group_id }}" + state: present + tags: + created_by: ALB test {{ resource_prefix }} + register: alb + check_mode: true + - ansible.builtin.assert: + that: + - alb is not changed + - alb.msg is match('IN CHECK MODE - no changes to make to ALB specified.') + + - name: Update an ALB by adding tags (idempotence) + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group.group_id }}" + state: present + tags: + created_by: ALB test {{ resource_prefix }} + register: alb + - ansible.builtin.assert: + that: + - alb is not changed + - alb.tags == created_tags + vars: + created_tags: + created_by: ALB test {{ resource_prefix }} # ------------------------------------------------------------------------------------------ - - name: Update an ALB by modifying tags - check_mode - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group.group_id }}' - state: present - tags: - created_by: ALB test {{ resource_prefix }}-2 - register: alb - check_mode: yes - - assert: - that: - - alb is changed - - alb.msg is match('Would have updated ALB if not in check mode.') - - - name: Update an ALB by modifying tags - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group.group_id }}' - state: present - tags: - created_by: ALB test {{ resource_prefix }}-2 - register: alb - - assert: - that: - - alb is changed - - alb.tags == created_tags - vars: - created_tags: - created_by: 'ALB test {{ resource_prefix }}-2' - - - - name: Update an ALB by modifying tags (idempotence) - check_mode - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group.group_id }}' - state: present - tags: - created_by: ALB test {{ resource_prefix }}-2 - register: alb - check_mode: yes - - assert: - that: - - alb is not changed - - alb.msg is match('IN CHECK MODE - no changes to make to ALB specified.') - - - name: Update an ALB by modifying tags (idempotence) - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group.group_id }}' - state: present - tags: - created_by: ALB test {{ resource_prefix }}-2 - register: alb - - assert: - that: - - alb is not changed - - alb.tags == created_tags - vars: - created_tags: - created_by: 'ALB test {{ resource_prefix }}-2' + - name: Update an ALB by modifying tags - check_mode + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group.group_id }}" + state: present + tags: + created_by: ALB test {{ resource_prefix }}-2 + register: alb + check_mode: true + - ansible.builtin.assert: + that: + - alb is changed + - alb.msg is match('Would have updated ALB if not in check mode.') + + - name: Update an ALB by modifying tags + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group.group_id }}" + state: present + tags: + created_by: ALB test {{ resource_prefix }}-2 + register: alb + - ansible.builtin.assert: + that: + - alb is changed + - alb.tags == created_tags + vars: + created_tags: + created_by: ALB test {{ resource_prefix }}-2 + + - name: Update an ALB by modifying tags (idempotence) - check_mode + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group.group_id }}" + state: present + tags: + created_by: ALB test {{ resource_prefix }}-2 + register: alb + check_mode: true + - ansible.builtin.assert: + that: + - alb is not changed + - alb.msg is match('IN CHECK MODE - no changes to make to ALB specified.') + + - name: Update an ALB by modifying tags (idempotence) + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group.group_id }}" + state: present + tags: + created_by: ALB test {{ resource_prefix }}-2 + register: alb + - ansible.builtin.assert: + that: + - alb is not changed + - alb.tags == created_tags + vars: + created_tags: + created_by: ALB test {{ resource_prefix }}-2 # ------------------------------------------------------------------------------------------ - - name: Update an ALB by removing tags - check_mode - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group.group_id }}' - state: present - tags: {} - register: alb - check_mode: yes - - assert: - that: - - alb is changed - - alb.msg is match('Would have updated ALB if not in check mode.') - - - name: Update an ALB by removing tags - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group.group_id }}' - state: present - tags: {} - register: alb - - assert: - that: - - alb is changed - - not alb.tags - - - name: Update an ALB by removing tags (idempotence) - check_mode - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group.group_id }}' - state: present - tags: {} - register: alb - check_mode: yes - - assert: - that: - - alb is not changed - - alb.msg is match('IN CHECK MODE - no changes to make to ALB specified.') - - - name: Update an ALB by removing tags (idempotence) - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group.group_id }}' - state: present - tags: {} - register: alb - - assert: - that: - - alb is not changed - - not alb.tags + - name: Update an ALB by removing tags - check_mode + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group.group_id }}" + state: present + tags: {} + register: alb + check_mode: true + - ansible.builtin.assert: + that: + - alb is changed + - alb.msg is match('Would have updated ALB if not in check mode.') + + - name: Update an ALB by removing tags + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group.group_id }}" + state: present + tags: {} + register: alb + - ansible.builtin.assert: + that: + - alb is changed + - not alb.tags + + - name: Update an ALB by removing tags (idempotence) - check_mode + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group.group_id }}" + state: present + tags: {} + register: alb + check_mode: true + - ansible.builtin.assert: + that: + - alb is not changed + - alb.msg is match('IN CHECK MODE - no changes to make to ALB specified.') + + - name: Update an ALB by removing tags (idempotence) + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group.group_id }}" + state: present + tags: {} + register: alb + - ansible.builtin.assert: + that: + - alb is not changed + - not alb.tags # ------------------------------------------------------------------------------------------ - - name: Update an ALB by changing security group - check_mode - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group2.group_id }}' - state: present - register: alb - check_mode: yes - - assert: - that: - - alb is changed - - alb.msg is match('Would have updated ALB if not in check mode.') - - - name: Update an ALB by changing security group - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group2.group_id }}' - state: present - register: alb - - assert: - that: - - alb is changed - - alb.security_groups[0] == sec_group2.group_id - - - name: Update an ALB by changing security group (idempotence) - check_mode - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group2.group_id }}' - state: present - register: alb - check_mode: yes - - assert: - that: - - alb is not changed - - alb.msg is match('IN CHECK MODE - no changes to make to ALB specified.') - - - name: Update an ALB by changing security group (idempotence) - elb_application_lb: - name: '{{ alb_name }}' - subnets: '{{ public_subnets }}' - security_groups: '{{ sec_group2.group_id }}' - state: present - register: alb - - assert: - that: - - alb is not changed - - alb.security_groups[0] == sec_group2.group_id + - name: Update an ALB by changing security group - check_mode + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group2.group_id }}" + state: present + register: alb + check_mode: true + - ansible.builtin.assert: + that: + - alb is changed + - alb.msg is match('Would have updated ALB if not in check mode.') + + - name: Update an ALB by changing security group + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group2.group_id }}" + state: present + register: alb + - ansible.builtin.assert: + that: + - alb is changed + - alb.security_groups[0] == sec_group2.group_id + + - name: Update an ALB by changing security group (idempotence) - check_mode + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group2.group_id }}" + state: present + register: alb + check_mode: true + - ansible.builtin.assert: + that: + - alb is not changed + - alb.msg is match('IN CHECK MODE - no changes to make to ALB specified.') + + - name: Update an ALB by changing security group (idempotence) + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + subnets: "{{ public_subnets }}" + security_groups: "{{ sec_group2.group_id }}" + state: present + register: alb + - ansible.builtin.assert: + that: + - alb is not changed + - alb.security_groups[0] == sec_group2.group_id # ------------------------------------------------------------------------------------------ - - name: Ensure elb_application_lb_info supports check_mode - elb_application_lb_info: - register: alb_info - check_mode: yes - - assert: - that: - - alb_info.load_balancers | length > 0 - - - name: Get ALB application info using no args - elb_application_lb_info: - register: alb_info - - assert: - that: - - alb_info.load_balancers | length > 0 - - - name: Get ALB application info using load balancer arn - elb_application_lb_info: - load_balancer_arns: - - '{{ alb.load_balancer_arn }}' - register: alb_info - - assert: - that: - - alb_info.load_balancers[0].security_groups[0] == sec_group2.group_id - - - name: Get ALB application info using load balancer name - elb_application_lb_info: - names: - - '{{ alb.load_balancer_name }}' - register: alb_info - - assert: - that: - - alb_info.load_balancers[0].security_groups[0] == sec_group2.group_id - - - name: Get ALB application info without skipping anything - elb_application_lb_info: - register: alb_info - - assert: - that: - - alb_info.load_balancers | selectattr('access_logs_s3_bucket', 'defined') | length > 0 - - alb_info.load_balancers | selectattr('access_logs_s3_enabled', 'defined') | length > 0 - - alb_info.load_balancers | selectattr('access_logs_s3_prefix', 'defined') | length > 0 - - alb_info.load_balancers | selectattr('deletion_protection_enabled', 'defined') | length > 0 - - alb_info.load_balancers | selectattr('idle_timeout_timeout_seconds', 'defined') | length > 0 - - alb_info.load_balancers | selectattr('load_balancing_cross_zone_enabled', 'defined') | length > 0 - - alb_info.load_balancers | selectattr('routing_http2_enabled', 'defined') | length > 0 - - alb_info.load_balancers | selectattr('routing_http_desync_mitigation_mode', 'defined') | length > 0 - - alb_info.load_balancers | selectattr('routing_http_drop_invalid_header_fields_enabled', 'defined') | length > 0 - - alb_info.load_balancers | selectattr('routing_http_x_amzn_tls_version_and_cipher_suite_enabled', 'defined') | length > 0 - - alb_info.load_balancers | selectattr('routing_http_xff_client_port_enabled', 'defined') | length > 0 - - alb_info.load_balancers | selectattr('waf_fail_open_enabled', 'defined') | length > 0 - - alb_info.load_balancers | selectattr('listeners', 'defined') | length > 0 - - alb_info.load_balancers | map(attribute='listeners') | flatten | selectattr('rules', 'defined') | length > 0 - - - name: Get ALB application info excluding attributes - elb_application_lb_info: - include_attributes: false - register: alb_info - - assert: - that: - - alb_info.load_balancers | selectattr('access_logs_s3_bucket', 'defined') | length == 0 - - alb_info.load_balancers | selectattr('access_logs_s3_enabled', 'defined') | length == 0 - - alb_info.load_balancers | selectattr('access_logs_s3_prefix', 'defined') | length == 0 - - alb_info.load_balancers | selectattr('deletion_protection_enabled', 'defined') | length == 0 - - alb_info.load_balancers | selectattr('idle_timeout_timeout_seconds', 'defined') | length == 0 - - alb_info.load_balancers | selectattr('load_balancing_cross_zone_enabled', 'defined') | length == 0 - - alb_info.load_balancers | selectattr('routing_http2_enabled', 'defined') | length == 0 - - alb_info.load_balancers | selectattr('routing_http_desync_mitigation_mode', 'defined') | length == 0 - - alb_info.load_balancers | selectattr('routing_http_drop_invalid_header_fields_enabled', 'defined') | length == 0 - - alb_info.load_balancers | selectattr('routing_http_x_amzn_tls_version_and_cipher_suite_enabled', 'defined') | length == 0 - - alb_info.load_balancers | selectattr('routing_http_xff_client_port_enabled', 'defined') | length == 0 - - alb_info.load_balancers | selectattr('waf_fail_open_enabled', 'defined') | length == 0 - - - name: Get ALB application info without listeners, but with rules - elb_application_lb_info: - include_listeners: false - register: alb_info - - assert: - that: - - alb_info.load_balancers | selectattr('listeners', 'defined') | length > 0 - - alb_info.load_balancers[0].listeners | length > 0 - - - name: Get ALB application info without listeners or rules - elb_application_lb_info: - include_listeners: false - include_listener_rules: false - register: alb_info - - assert: - that: - - alb_info.load_balancers | selectattr('listeners', 'defined') | length == 0 - - - name: Get ALB application info without listener rules - elb_application_lb_info: - include_listener_rules: false - register: alb_info - - assert: - that: - - alb_info.load_balancers | selectattr('listeners', 'defined') | length > 0 - - alb_info.load_balancers | map(attribute='listeners') | flatten | selectattr('rules', 'defined') | length == 0 - - - name: Get ALB application minimal info - elb_application_lb_info: - include_attributes: false - include_listeners: false - include_listener_rules: false - register: alb_info - - assert: - that: - - alb_info.load_balancers | selectattr('access_logs_s3_bucket', 'defined') | length == 0 - - alb_info.load_balancers | selectattr('access_logs_s3_enabled', 'defined') | length == 0 - - alb_info.load_balancers | selectattr('access_logs_s3_prefix', 'defined') | length == 0 - - alb_info.load_balancers | selectattr('deletion_protection_enabled', 'defined') | length == 0 - - alb_info.load_balancers | selectattr('idle_timeout_timeout_seconds', 'defined') | length == 0 - - alb_info.load_balancers | selectattr('load_balancing_cross_zone_enabled', 'defined') | length == 0 - - alb_info.load_balancers | selectattr('routing_http2_enabled', 'defined') | length == 0 - - alb_info.load_balancers | selectattr('routing_http_desync_mitigation_mode', 'defined') | length == 0 - - alb_info.load_balancers | selectattr('routing_http_drop_invalid_header_fields_enabled', 'defined') | length == 0 - - alb_info.load_balancers | selectattr('routing_http_x_amzn_tls_version_and_cipher_suite_enabled', 'defined') | length == 0 - - alb_info.load_balancers | selectattr('routing_http_xff_client_port_enabled', 'defined') | length == 0 - - alb_info.load_balancers | selectattr('waf_fail_open_enabled', 'defined') | length == 0 - - alb_info.load_balancers | selectattr('listeners', 'defined') | length == 0 + - name: Ensure elb_application_lb_info supports check_mode + amazon.aws.elb_application_lb_info: + register: alb_info + check_mode: true + - ansible.builtin.assert: + that: + - alb_info.load_balancers | length > 0 + + - name: Get ALB application info using no args + amazon.aws.elb_application_lb_info: + register: alb_info + - ansible.builtin.assert: + that: + - alb_info.load_balancers | length > 0 + + - name: Get ALB application info using load balancer arn + amazon.aws.elb_application_lb_info: + load_balancer_arns: + - "{{ alb.load_balancer_arn }}" + register: alb_info + - ansible.builtin.assert: + that: + - alb_info.load_balancers[0].security_groups[0] == sec_group2.group_id + + - name: Get ALB application info using load balancer name + amazon.aws.elb_application_lb_info: + names: + - "{{ alb.load_balancer_name }}" + register: alb_info + - ansible.builtin.assert: + that: + - alb_info.load_balancers[0].security_groups[0] == sec_group2.group_id + + - name: Get ALB application info without skipping anything + amazon.aws.elb_application_lb_info: + register: alb_info + - ansible.builtin.assert: + that: + - alb_info.load_balancers | selectattr('access_logs_s3_bucket', 'defined') | length > 0 + - alb_info.load_balancers | selectattr('access_logs_s3_enabled', 'defined') | length > 0 + - alb_info.load_balancers | selectattr('access_logs_s3_prefix', 'defined') | length > 0 + - alb_info.load_balancers | selectattr('deletion_protection_enabled', 'defined') | length > 0 + - alb_info.load_balancers | selectattr('idle_timeout_timeout_seconds', 'defined') | length > 0 + - alb_info.load_balancers | selectattr('load_balancing_cross_zone_enabled', 'defined') | length > 0 + - alb_info.load_balancers | selectattr('routing_http2_enabled', 'defined') | length > 0 + - alb_info.load_balancers | selectattr('routing_http_desync_mitigation_mode', 'defined') | length > 0 + - alb_info.load_balancers | selectattr('routing_http_drop_invalid_header_fields_enabled', 'defined') | length > 0 + - alb_info.load_balancers | selectattr('routing_http_x_amzn_tls_version_and_cipher_suite_enabled', 'defined') | length > 0 + - alb_info.load_balancers | selectattr('routing_http_xff_client_port_enabled', 'defined') | length > 0 + - alb_info.load_balancers | selectattr('waf_fail_open_enabled', 'defined') | length > 0 + - alb_info.load_balancers | selectattr('listeners', 'defined') | length > 0 + - alb_info.load_balancers | map(attribute='listeners') | flatten | selectattr('rules', 'defined') | length > 0 + + - name: Get ALB application info excluding attributes + amazon.aws.elb_application_lb_info: + include_attributes: false + register: alb_info + - ansible.builtin.assert: + that: + - alb_info.load_balancers | selectattr('access_logs_s3_bucket', 'defined') | length == 0 + - alb_info.load_balancers | selectattr('access_logs_s3_enabled', 'defined') | length == 0 + - alb_info.load_balancers | selectattr('access_logs_s3_prefix', 'defined') | length == 0 + - alb_info.load_balancers | selectattr('deletion_protection_enabled', 'defined') | length == 0 + - alb_info.load_balancers | selectattr('idle_timeout_timeout_seconds', 'defined') | length == 0 + - alb_info.load_balancers | selectattr('load_balancing_cross_zone_enabled', 'defined') | length == 0 + - alb_info.load_balancers | selectattr('routing_http2_enabled', 'defined') | length == 0 + - alb_info.load_balancers | selectattr('routing_http_desync_mitigation_mode', 'defined') | length == 0 + - alb_info.load_balancers | selectattr('routing_http_drop_invalid_header_fields_enabled', 'defined') | length == 0 + - alb_info.load_balancers | selectattr('routing_http_x_amzn_tls_version_and_cipher_suite_enabled', 'defined') | length == 0 + - alb_info.load_balancers | selectattr('routing_http_xff_client_port_enabled', 'defined') | length == 0 + - alb_info.load_balancers | selectattr('waf_fail_open_enabled', 'defined') | length == 0 + + - name: Get ALB application info without listeners, but with rules + amazon.aws.elb_application_lb_info: + include_listeners: false + register: alb_info + - ansible.builtin.assert: + that: + - alb_info.load_balancers | selectattr('listeners', 'defined') | length > 0 + - alb_info.load_balancers[0].listeners | length > 0 + + - name: Get ALB application info without listeners or rules + amazon.aws.elb_application_lb_info: + include_listeners: false + include_listener_rules: false + register: alb_info + - ansible.builtin.assert: + that: + - alb_info.load_balancers | selectattr('listeners', 'defined') | length == 0 + + - name: Get ALB application info without listener rules + amazon.aws.elb_application_lb_info: + include_listener_rules: false + register: alb_info + - ansible.builtin.assert: + that: + - alb_info.load_balancers | selectattr('listeners', 'defined') | length > 0 + - alb_info.load_balancers | map(attribute='listeners') | flatten | selectattr('rules', 'defined') | length == 0 + + - name: Get ALB application minimal info + amazon.aws.elb_application_lb_info: + include_attributes: false + include_listeners: false + include_listener_rules: false + register: alb_info + - ansible.builtin.assert: + that: + - alb_info.load_balancers | selectattr('access_logs_s3_bucket', 'defined') | length == 0 + - alb_info.load_balancers | selectattr('access_logs_s3_enabled', 'defined') | length == 0 + - alb_info.load_balancers | selectattr('access_logs_s3_prefix', 'defined') | length == 0 + - alb_info.load_balancers | selectattr('deletion_protection_enabled', 'defined') | length == 0 + - alb_info.load_balancers | selectattr('idle_timeout_timeout_seconds', 'defined') | length == 0 + - alb_info.load_balancers | selectattr('load_balancing_cross_zone_enabled', 'defined') | length == 0 + - alb_info.load_balancers | selectattr('routing_http2_enabled', 'defined') | length == 0 + - alb_info.load_balancers | selectattr('routing_http_desync_mitigation_mode', 'defined') | length == 0 + - alb_info.load_balancers | selectattr('routing_http_drop_invalid_header_fields_enabled', 'defined') | length == 0 + - alb_info.load_balancers | selectattr('routing_http_x_amzn_tls_version_and_cipher_suite_enabled', 'defined') | length == 0 + - alb_info.load_balancers | selectattr('routing_http_xff_client_port_enabled', 'defined') | length == 0 + - alb_info.load_balancers | selectattr('waf_fail_open_enabled', 'defined') | length == 0 + - alb_info.load_balancers | selectattr('listeners', 'defined') | length == 0 # ------------------------------------------------------------------------------------------ - - name: Delete an ALB - check_mode - elb_application_lb: - name: '{{ alb_name }}' - state: absent - register: alb - check_mode: yes - - assert: - that: - - alb is changed - - alb.msg is match('Would have deleted ALB if not in check mode.') - - - name: Delete an ALB - elb_application_lb: - name: '{{ alb_name }}' - state: absent - register: alb - - assert: - that: - - alb is changed - - - name: Delete an ALB (idempotence) - check_mode - elb_application_lb: - name: '{{ alb_name }}' - state: absent - register: alb - check_mode: yes - - assert: - that: - - alb is not changed - - alb.msg is match('IN CHECK MODE - ALB already absent.') - - - name: Delete an ALB (idempotence) - elb_application_lb: - name: '{{ alb_name }}' - state: absent - register: alb - - assert: - that: - - alb is not changed + - name: Delete an ALB - check_mode + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + state: absent + register: alb + check_mode: true + - ansible.builtin.assert: + that: + - alb is changed + - alb.msg is match('Would have deleted ALB if not in check mode.') + + - name: Delete an ALB + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + state: absent + register: alb + - ansible.builtin.assert: + that: + - alb is changed + + - name: Delete an ALB (idempotence) - check_mode + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + state: absent + register: alb + check_mode: true + - ansible.builtin.assert: + that: + - alb is not changed + - alb.msg is match('IN CHECK MODE - ALB already absent.') + + - name: Delete an ALB (idempotence) + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + state: absent + register: alb + - ansible.builtin.assert: + that: + - alb is not changed # ----- Cleanup ------------------------------------------------------------------------------ always: - - name: Destroy ALB - elb_application_lb: - name: '{{ alb_name }}' - state: absent - wait: true - wait_timeout: 600 - ignore_errors: true - - name: Destroy ALB 2 - amazon.aws.elb_application_lb: - name: '{{ alb_2_name }}' - state: absent - wait: true - wait_timeout: 600 - ignore_errors: true - - name: Destroy target group if it was created - elb_target_group: - name: '{{ tg_name }}' - protocol: http - port: 80 - vpc_id: '{{ vpc_id }}' - state: absent - wait: true - wait_timeout: 600 - register: remove_tg - retries: 5 - delay: 3 - until: remove_tg is success - when: tg is defined - ignore_errors: true - - name: Destroy target group 2 if it was created - community.aws.elb_target_group: - name: '{{ tg_2_name }}' - protocol: http - port: 80 - vpc_id: '{{ vpc_id }}' - state: absent - wait: true - wait_timeout: 600 - register: remove_tg_2 - retries: 5 - delay: 3 - until: remove_tg_2 is success - when: tg_2 is defined - ignore_errors: true - - name: Destroy sec groups - ec2_security_group: - name: '{{ item }}' - description: security group for Ansible ALB integration tests - state: absent - vpc_id: '{{ vpc_id }}' - register: remove_sg - retries: 10 - delay: 5 - until: remove_sg is success - ignore_errors: true - with_items: - - '{{ resource_prefix }}' - - '{{ resource_prefix }}-2' - - - name: Destroy route table - ec2_vpc_route_table: - vpc_id: '{{ vpc_id }}' - route_table_id: '{{ route_table.route_table.route_table_id }}' - lookup: id - state: absent - register: remove_rt - retries: 10 - delay: 5 - until: remove_rt is success - ignore_errors: true - - name: Destroy subnets - ec2_vpc_subnet: - cidr: '{{ item }}' - vpc_id: '{{ vpc_id }}' - state: absent - register: remove_subnet - retries: 10 - delay: 5 - until: remove_subnet is success - with_items: - - '{{ private_subnet_cidr_1 }}' - - '{{ private_subnet_cidr_2 }}' - - '{{ public_subnet_cidr_1 }}' - - '{{ public_subnet_cidr_2 }}' - ignore_errors: true - - name: Destroy internet gateway - ec2_vpc_igw: - vpc_id: '{{ vpc_id }}' - tags: - Name: '{{ resource_prefix }}' - state: absent - register: remove_igw - retries: 10 - delay: 5 - until: remove_igw is success - ignore_errors: true - - name: Destroy VPC - ec2_vpc_net: - cidr_block: '{{ vpc_cidr }}' - name: '{{ resource_prefix }}_vpc' - state: absent - register: remove_vpc - retries: 10 - delay: 5 - until: remove_vpc is success - ignore_errors: true - - name: Destroy ELB acccess log test file - amazon.aws.s3_object: - bucket: "{{ s3_bucket_name }}" - mode: delobj - object: "alb-logs/AWSLogs/{{ aws_account }}/ELBAccessLogTestFile" - - name: Destroy S3 bucket - amazon.aws.s3_bucket: - name: "{{ s3_bucket_name }}" - state: absent - force: true + - name: Destroy ALB + amazon.aws.elb_application_lb: + name: "{{ alb_name }}" + state: absent + wait: true + wait_timeout: 600 + ignore_errors: true # noqa: ignore-errors + - name: Destroy ALB 2 + amazon.aws.elb_application_lb: + name: "{{ alb_2_name }}" + state: absent + wait: true + wait_timeout: 600 + ignore_errors: true # noqa: ignore-errors + - name: Destroy target group if it was created + community.aws.elb_target_group: + name: "{{ tg_name }}" + protocol: http + port: 80 + vpc_id: "{{ vpc_id }}" + state: absent + wait: true + wait_timeout: 600 + register: remove_tg + retries: 5 + delay: 3 + until: remove_tg is success + when: tg is defined + ignore_errors: true # noqa: ignore-errors + - name: Destroy target group 2 if it was created + community.aws.elb_target_group: + name: "{{ tg_2_name }}" + protocol: http + port: 80 + vpc_id: "{{ vpc_id }}" + state: absent + wait: true + wait_timeout: 600 + register: remove_tg_2 + retries: 5 + delay: 3 + until: remove_tg_2 is success + when: tg_2 is defined + ignore_errors: true # noqa: ignore-errors + - name: Destroy sec groups + amazon.aws.ec2_security_group: + name: "{{ item }}" + description: security group for Ansible ALB integration tests + state: absent + vpc_id: "{{ vpc_id }}" + register: remove_sg + retries: 10 + delay: 5 + until: remove_sg is success + ignore_errors: true # noqa: ignore-errors + with_items: + - "{{ resource_prefix }}" + - "{{ resource_prefix }}-2" + + - name: Destroy route table + amazon.aws.ec2_vpc_route_table: + vpc_id: "{{ vpc_id }}" + route_table_id: "{{ route_table.route_table.route_table_id }}" + lookup: id + state: absent + register: remove_rt + retries: 10 + delay: 5 + until: remove_rt is success + ignore_errors: true # noqa: ignore-errors + - name: Destroy subnets + amazon.aws.ec2_vpc_subnet: + cidr: "{{ item }}" + vpc_id: "{{ vpc_id }}" + state: absent + register: remove_subnet + retries: 10 + delay: 5 + until: remove_subnet is success + with_items: + - "{{ private_subnet_cidr_1 }}" + - "{{ private_subnet_cidr_2 }}" + - "{{ public_subnet_cidr_1 }}" + - "{{ public_subnet_cidr_2 }}" + ignore_errors: true # noqa: ignore-errors + - name: Destroy internet gateway + amazon.aws.ec2_vpc_igw: + vpc_id: "{{ vpc_id }}" + tags: + Name: "{{ resource_prefix }}" + state: absent + register: remove_igw + retries: 10 + delay: 5 + until: remove_igw is success + ignore_errors: true # noqa: ignore-errors + - name: Destroy VPC + amazon.aws.ec2_vpc_net: + cidr_block: "{{ vpc_cidr }}" + name: "{{ resource_prefix }}_vpc" + state: absent + register: remove_vpc + retries: 10 + delay: 5 + until: remove_vpc is success + ignore_errors: true # noqa: ignore-errors + - name: Destroy ELB acccess log test file + amazon.aws.s3_object: + bucket: "{{ s3_bucket_name }}" + mode: delobj + object: alb-logs/AWSLogs/{{ aws_account }}/ELBAccessLogTestFile + - name: Destroy S3 bucket + amazon.aws.s3_bucket: + name: "{{ s3_bucket_name }}" + state: absent + force: true diff --git a/tests/integration/targets/rds_option_group/defaults/main.yml b/tests/integration/targets/rds_option_group/defaults/main.yml index d99a379640b..e0f04005f98 100644 --- a/tests/integration/targets/rds_option_group/defaults/main.yml +++ b/tests/integration/targets/rds_option_group/defaults/main.yml @@ -1,17 +1,18 @@ -option_group_name: '{{ resource_prefix }}rds-option-group' +--- +option_group_name: "{{ resource_prefix }}rds-option-group" engine_name: mysql major_engine_version: 5.6 -option_group_description: '{{ resource_prefix }}rds-option-group test' -instance_id: '{{ resource_prefix }}' +option_group_description: "{{ resource_prefix }}rds-option-group test" +instance_id: "{{ resource_prefix }}" username: test password: test12345678 db_instance_class: db.t2.small storage_encrypted_db_instance_class: db.t2.small allocated_storage: 20 -vpc_name: '{{ resource_prefix }}-vpc' -vpc_seed: '{{ resource_prefix }}' +vpc_name: "{{ resource_prefix }}-vpc" +vpc_seed: "{{ resource_prefix }}" vpc_cidr: 10.0.0.0/16 subnet_cidr: 10.0.{{ 256 | random(seed=vpc_seed) }}.0/24 -sg_1_name: '{{ resource_prefix }}-sg-1' -sg_2_name: '{{ resource_prefix }}-sg-2' -sg_3_name: '{{ resource_prefix }}-sg-3' +sg_1_name: "{{ resource_prefix }}-sg-1" +sg_2_name: "{{ resource_prefix }}-sg-2" +sg_3_name: "{{ resource_prefix }}-sg-3" diff --git a/tests/integration/targets/rds_option_group/meta/main.yml b/tests/integration/targets/rds_option_group/meta/main.yml index 32cf5dda7ed..23d65c7ef45 100644 --- a/tests/integration/targets/rds_option_group/meta/main.yml +++ b/tests/integration/targets/rds_option_group/meta/main.yml @@ -1 +1,2 @@ +--- dependencies: [] diff --git a/tests/integration/targets/rds_option_group/tasks/main.yml b/tests/integration/targets/rds_option_group/tasks/main.yml index 6ade26c2597..8bb66c519f7 100644 --- a/tests/integration/targets/rds_option_group/tasks/main.yml +++ b/tests/integration/targets/rds_option_group/tasks/main.yml @@ -1,927 +1,909 @@ -- name: rds_option_group tests +--- +- name: Rds_option_group tests module_defaults: group/aws: - region: '{{ aws_region }}' - access_key: '{{ aws_access_key }}' - secret_key: '{{ aws_secret_key }}' - session_token: '{{ security_token | default(omit) }}' - + region: "{{ aws_region }}" + access_key: "{{ aws_access_key }}" + secret_key: "{{ aws_secret_key }}" + session_token: "{{ security_token | default(omit) }}" block: - - name: create a VPC - ec2_vpc_net: - name: '{{ vpc_name }}' - state: present - cidr_block: '{{ vpc_cidr }}' - register: vpc_result - - - name: Assert success - assert: - that: - - vpc_result is successful - - '"vpc" in vpc_result' - - '"cidr_block" in vpc_result.vpc' - - vpc_result.vpc.cidr_block == vpc_cidr - - '"id" in vpc_result.vpc' - - vpc_result.vpc.id.startswith("vpc-") - - '"state" in vpc_result.vpc' - - vpc_result.vpc.state == 'available' - - '"tags" in vpc_result.vpc' - - - name: 'set fact: VPC ID' - set_fact: - vpc_id: '{{ vpc_result.vpc.id }}' - - - name: create subnet - ec2_vpc_subnet: - cidr: '{{ subnet_cidr}}' - vpc_id: '{{ vpc_id }}' - state: present - register: subnet_result - - - name: Assert success - assert: - that: - - subnet_result is successful - - '"subnet" in subnet_result' - - '"cidr_block" in subnet_result.subnet' - - subnet_result.subnet.cidr_block == subnet_cidr - - '"id" in subnet_result.subnet' - - subnet_result.subnet.id.startswith("subnet-") - - '"state" in subnet_result.subnet' - - subnet_result.subnet.state == 'available' - - '"tags" in subnet_result.subnet' - - subnet_result.subnet.vpc_id == vpc_id - - - name: 'set fact: VPC subnet ID' - set_fact: - subnet_id: '{{ subnet_result.subnet.id }}' - - - - name: Create security groups - ec2_security_group: - name: '{{ item }}' - description: created by rds_instance integration tests - state: present - vpc_id: '{{ vpc_id }}' - register: sgs_result - loop: - - '{{ sg_1_name }}' - - '{{ sg_2_name }}' - - '{{ sg_3_name }}' - - - name: Assert success - assert: - that: - - sgs_result is successful - - - name: 'set fact: security groups ID' - set_fact: - sg_1: '{{ sgs_result.results.0.group_id }}' - sg_2: '{{ sgs_result.results.1.group_id }}' - sg_3: '{{ sgs_result.results.2.group_id }}' - - - - name: List all the option groups - CHECK_MODE - rds_option_group_info: - register: option_groups_result - check_mode: true - - - name: Assert success - CHECK_MODE - assert: - that: - - option_groups_result is successful - - - - name: List all the option groups - rds_option_group_info: - register: option_groups_result - check_mode: true - - - name: Assert success - assert: - that: - - option_groups_result is successful - - - name: Create an RDS Mysql option group - CHECK_MODE - rds_option_group: - state: present - option_group_name: '{{ option_group_name }}' - engine_name: '{{ engine_name }}' - major_engine_version: '{{ major_engine_version }}' - option_group_description: '{{ option_group_description }}' - apply_immediately: true - options: - - option_name: MEMCACHED - port: 11211 - vpc_security_group_memberships: - - '{{ sg_1 }}' - option_settings: - - name: MAX_SIMULTANEOUS_CONNECTIONS - value: '20' - - name: CHUNK_SIZE_GROWTH_FACTOR - value: '1.25' - check_mode: true - register: new_rds_mysql_option_group - - - name: Assert success - CHECK_MODE - assert: - that: - - new_rds_mysql_option_group.changed - - - - name: Create an RDS Mysql option group - rds_option_group: - state: present - option_group_name: '{{ option_group_name }}' - engine_name: '{{ engine_name }}' - major_engine_version: '{{ major_engine_version }}' - option_group_description: '{{ option_group_description }}' - apply_immediately: true - options: - - option_name: MEMCACHED - port: 11211 - vpc_security_group_memberships: - - '{{ sg_1 }}' - option_settings: - - name: MAX_SIMULTANEOUS_CONNECTIONS - value: '20' - - name: CHUNK_SIZE_GROWTH_FACTOR - value: '1.25' - register: new_rds_mysql_option_group - - - assert: - that: - - new_rds_mysql_option_group.changed - - "'engine_name' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.engine_name == engine_name - - "'major_engine_version' in new_rds_mysql_option_group" - - (new_rds_mysql_option_group.major_engine_version | string) == (major_engine_version | string) - - "'option_group_arn' in new_rds_mysql_option_group" - - "'option_group_description' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.option_group_description == option_group_description - - "'option_group_name' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.option_group_name == option_group_name - - "'vpc_id' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.vpc_id == vpc_id - - "'options' in new_rds_mysql_option_group" - - (new_rds_mysql_option_group.options | length) > 0 - - "'option_name' in option" - - option.option_name == "MEMCACHED" - - "'permanent' in option" - - "'persistent' in option" - - "'port' in option" - - option.port == 11211 - - "'vpc_security_group_memberships' in option" - - (option.vpc_security_group_memberships | length) == 1 - - option.vpc_security_group_memberships[0].vpc_security_group_id == sg_1 - - "'option_settings' in option" - - (option_settings | length) > 0 - - option_settings | selectattr('name','equalto','MAX_SIMULTANEOUS_CONNECTIONS') - | list | count > 0 - - option_settings | selectattr('name','equalto','CHUNK_SIZE_GROWTH_FACTOR') - | list | count > 0 - vars: - option: '{{ new_rds_mysql_option_group.options[0] }}' - option_settings: '{{ new_rds_mysql_option_group.options[0].option_settings }}' - - - - name: List specific option group - rds_option_group_info: - option_group_name: '{{ option_group_name }}' - register: option_groups_result - - - name: Assert success - assert: - that: - - option_groups_result is successful - - (option_groups_result.result | length) == 1 - - "'engine_name' in option_groups_list" - - option_groups_list.engine_name == engine_name - - "'major_engine_version' in option_groups_list" - - (option_groups_list.major_engine_version | string) == (major_engine_version | string) - - "'option_group_arn' in option_groups_list" - - "'option_group_description' in option_groups_list" - - option_groups_list.option_group_description == option_group_description - - "'option_group_name' in option_groups_list" - - option_groups_list.option_group_name == option_group_name - - "'vpc_id' in option_groups_list" - - new_rds_mysql_option_group.vpc_id == vpc_id - - "'options' in option_groups_list" - - (option_groups_list.options | length) > 0 - - "'option_name' in options" - - options.option_name == "MEMCACHED" - - "'permanent' in options" - - "'persistent' in options" - - "'port' in options" - - options.port == 11211 - - "'vpc_security_group_memberships' in options" - - (options.vpc_security_group_memberships | length) == 1 - - options.vpc_security_group_memberships[0].vpc_security_group_id == sg_1 - - "'option_settings' in options" - - (options.option_settings | length) > 0 - vars: - option_groups_list: '{{ option_groups_result.result[0] }}' - options: '{{ option_groups_result.result[0].options[0] }}' - - - - name: Create an RDS Mysql option group (idempotency) - CHECK_MODE - rds_option_group: - state: present - option_group_name: '{{ option_group_name }}' - engine_name: '{{ engine_name }}' - major_engine_version: '{{ major_engine_version }}' - option_group_description: '{{ option_group_description }}' - apply_immediately: true - options: - - option_name: MEMCACHED - port: 11211 - vpc_security_group_memberships: - - '{{ sg_1 }}' - option_settings: - - name: MAX_SIMULTANEOUS_CONNECTIONS - value: '20' - - name: CHUNK_SIZE_GROWTH_FACTOR - value: '1.25' - check_mode: true - register: new_rds_mysql_option_group - - - name: Assert success - CHECK_MODE - assert: - that: - - not new_rds_mysql_option_group.changed - - "'engine_name' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.engine_name == engine_name - - "'major_engine_version' in new_rds_mysql_option_group" - - (new_rds_mysql_option_group.major_engine_version | string) == (major_engine_version | string) - - "'option_group_arn' in new_rds_mysql_option_group" - - "'option_group_description' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.option_group_description == option_group_description - - "'option_group_name' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.option_group_name == option_group_name - - "'vpc_id' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.vpc_id == vpc_id - - "'options' in new_rds_mysql_option_group" - - (new_rds_mysql_option_group.options | length) > 0 - - "'option_name' in option" - - option.option_name == "MEMCACHED" - - "'permanent' in option" - - "'persistent' in option" - - "'port' in option" - - option.port == 11211 - - "'vpc_security_group_memberships' in option" - - (option.vpc_security_group_memberships | length) == 1 - - option.vpc_security_group_memberships[0].vpc_security_group_id == sg_1 - - "'option_settings' in option" - - (option_settings | length) > 0 - - option_settings | selectattr('name','equalto','MAX_SIMULTANEOUS_CONNECTIONS') - | list | count > 0 - - option_settings | selectattr('name','equalto','CHUNK_SIZE_GROWTH_FACTOR') - | list | count > 0 - vars: - option: '{{ new_rds_mysql_option_group.options[0] }}' - option_settings: '{{ new_rds_mysql_option_group.options[0].option_settings }}' - - name: Create an RDS Mysql option group (idempotency) - rds_option_group: - state: present - option_group_name: '{{ option_group_name }}' - engine_name: '{{ engine_name }}' - major_engine_version: '{{ major_engine_version }}' - option_group_description: '{{ option_group_description }}' - apply_immediately: true - options: - - option_name: MEMCACHED - port: 11211 - vpc_security_group_memberships: - - '{{ sg_1 }}' - option_settings: - - name: MAX_SIMULTANEOUS_CONNECTIONS - value: '20' - - name: CHUNK_SIZE_GROWTH_FACTOR - value: '1.25' - register: new_rds_mysql_option_group - - - assert: - that: - - not new_rds_mysql_option_group.changed - - "'engine_name' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.engine_name == engine_name - - "'major_engine_version' in new_rds_mysql_option_group" - - (new_rds_mysql_option_group.major_engine_version | string) == (major_engine_version | string) - - "'option_group_arn' in new_rds_mysql_option_group" - - "'option_group_description' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.option_group_description == option_group_description - - "'option_group_name' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.option_group_name == option_group_name - - "'vpc_id' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.vpc_id == vpc_id - - "'options' in new_rds_mysql_option_group" - - (new_rds_mysql_option_group.options | length) > 0 - - "'option_name' in option" - - option.option_name == "MEMCACHED" - - "'permanent' in option" - - "'persistent' in option" - - "'port' in option" - - option.port == 11211 - - "'vpc_security_group_memberships' in option" - - (option.vpc_security_group_memberships | length) == 1 - - option.vpc_security_group_memberships[0].vpc_security_group_id == sg_1 - - "'option_settings' in option" - - (option_settings | length) > 0 - - option_settings | selectattr('name','equalto','MAX_SIMULTANEOUS_CONNECTIONS') - | list | count > 0 - - option_settings | selectattr('name','equalto','CHUNK_SIZE_GROWTH_FACTOR') - | list | count > 0 - vars: - option: '{{ new_rds_mysql_option_group.options[0] }}' - option_settings: '{{ new_rds_mysql_option_group.options[0].option_settings }}' - - - - name: List option groups with specific (engine_name and major_engine_version) - rds_option_group_info: - engine_name: '{{ engine_name }}' - major_engine_version: '{{ major_engine_version }}' - register: option_groups_result - - - name: Assert success - assert: - that: - - option_groups_result is successful - - (option_groups_result.result | length) > 0 - - - - name: Create an RDS Mysql option group - apply different changes (expected changed=true) - rds_option_group: - state: present - option_group_name: '{{ option_group_name }}' - engine_name: '{{ engine_name }}' - major_engine_version: '{{ major_engine_version }}' - option_group_description: '{{ option_group_description }}' - apply_immediately: true - options: - - option_name: MEMCACHED - port: 11211 - vpc_security_group_memberships: - - '{{ sg_1 }}' - - '{{ sg_2 }}' - - '{{ sg_3 }}' - option_settings: - - name: MAX_SIMULTANEOUS_CONNECTIONS - value: '30' - register: new_rds_mysql_option_group - - - assert: - that: - - new_rds_mysql_option_group.changed - - "'engine_name' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.engine_name == engine_name - - "'major_engine_version' in new_rds_mysql_option_group" - - (new_rds_mysql_option_group.major_engine_version | string) == (major_engine_version | string) - - "'option_group_arn' in new_rds_mysql_option_group" - - "'option_group_description' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.option_group_description == option_group_description - - "'option_group_name' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.option_group_name == option_group_name - - "'vpc_id' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.vpc_id == vpc_id - - "'options' in new_rds_mysql_option_group" - - (new_rds_mysql_option_group.options | length) > 0 - - "'option_name' in option" - - option.option_name == "MEMCACHED" - - "'permanent' in option" - - "'persistent' in option" - - "'port' in option" - - option.port == 11211 - - "'vpc_security_group_memberships' in option" - - (option.vpc_security_group_memberships | length) == 3 - - "'option_settings' in option" - - (option_settings | length) > 0 - - option_settings | selectattr('name','equalto','CHUNK_SIZE_GROWTH_FACTOR') - | list | count > 0 - vars: - option: '{{ new_rds_mysql_option_group.options[0] }}' - option_settings: '{{ new_rds_mysql_option_group.options[0].option_settings }}' - - name: Get info about an option group - CHECK_MODE - rds_option_group_info: - option_group_name: '{{ option_group_name }}' - check_mode: true - register: option_groups_result - - - name: Assert success - CHECK_MODE - assert: - that: - - option_groups_result is successful - - (option_groups_result.result | length) == 1 - - "'engine_name' in option_groups_list" - - option_groups_list.engine_name == engine_name - - "'major_engine_version' in option_groups_list" - - (option_groups_list.major_engine_version | string) == (major_engine_version | string) - - "'option_group_arn' in option_groups_list" - - "'option_group_description' in option_groups_list" - - option_groups_list.option_group_description == option_group_description - - "'option_group_name' in option_groups_list" - - option_groups_list.option_group_name == option_group_name - - "'vpc_id' in option_groups_list" - - new_rds_mysql_option_group.vpc_id == vpc_id - - "'options' in option_groups_list" - - (option_groups_list.options | length) > 0 - - "'option_name' in options" - - options.option_name == "MEMCACHED" - - "'permanent' in options" - - "'persistent' in options" - - "'port' in options" - - options.port == 11211 - - "'vpc_security_group_memberships' in options" - - (options.vpc_security_group_memberships | length) == 3 - - "'option_settings' in options" - - (options.option_settings | length) > 0 - vars: - option_groups_list: '{{ option_groups_result.result[0] }}' - options: '{{ option_groups_result.result[0].options[0] }}' - - - - name: RDS Mysql option group - apply tags - CHECK_MODE - rds_option_group: - state: present - option_group_name: '{{ option_group_name }}' - engine_name: '{{ engine_name }}' - major_engine_version: '{{ major_engine_version }}' - option_group_description: '{{ option_group_description }}' - apply_immediately: true - options: - - option_name: MEMCACHED - port: 11211 - vpc_security_group_memberships: - - '{{ sg_1 }}' - - '{{ sg_2 }}' - - '{{ sg_3 }}' - option_settings: - - name: CHUNK_SIZE_GROWTH_FACTOR - value: '1.2' - tags: - tag_one: '{{ option_group_name }} One' - Tag Two: two {{ option_group_name }} - check_mode: true - register: new_rds_mysql_option_group - - - name: Assert success - CHECK_MODE - assert: - that: - - new_rds_mysql_option_group.changed - - "'engine_name' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.engine_name == engine_name - - "'major_engine_version' in new_rds_mysql_option_group" - - (new_rds_mysql_option_group.major_engine_version | string) == (major_engine_version | string) - - "'option_group_arn' in new_rds_mysql_option_group" - - "'option_group_description' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.option_group_description == option_group_description - - "'option_group_name' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.option_group_name == option_group_name - - "'vpc_id' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.vpc_id == vpc_id - - "'tags' in new_rds_mysql_option_group" - - "'options' in new_rds_mysql_option_group" - - (new_rds_mysql_option_group.options | length) > 0 - - "'option_name' in option" - - option.option_name == "MEMCACHED" - - "'permanent' in option" - - "'persistent' in option" - - "'port' in option" - - option.port == 11211 - - "'vpc_security_group_memberships' in option" - - (option.vpc_security_group_memberships | length) == 3 - - "'option_settings' in option" - - (option_settings | length) > 0 - - option_settings | selectattr('name','equalto','CHUNK_SIZE_GROWTH_FACTOR') - | list | count > 0 - vars: - option: '{{ new_rds_mysql_option_group.options[0] }}' - option_settings: '{{ new_rds_mysql_option_group.options[0].option_settings }}' - - name: RDS Mysql option group - apply tags - rds_option_group: - state: present - option_group_name: '{{ option_group_name }}' - engine_name: '{{ engine_name }}' - major_engine_version: '{{ major_engine_version }}' - option_group_description: '{{ option_group_description }}' - apply_immediately: true - options: - - option_name: MEMCACHED - port: 11211 - vpc_security_group_memberships: - - '{{ sg_1 }}' - - '{{ sg_2 }}' - - '{{ sg_3 }}' - option_settings: - - name: CHUNK_SIZE_GROWTH_FACTOR - value: '1.2' - tags: - tag_one: '{{ option_group_name }} One' - Tag Two: two {{ option_group_name }} - register: new_rds_mysql_option_group - - - assert: - that: - - new_rds_mysql_option_group.changed - - "'engine_name' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.engine_name == engine_name - - "'major_engine_version' in new_rds_mysql_option_group" - - (new_rds_mysql_option_group.major_engine_version | string) == (major_engine_version | string) - - "'option_group_arn' in new_rds_mysql_option_group" - - "'option_group_description' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.option_group_description == option_group_description - - "'option_group_name' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.option_group_name == option_group_name - - "'vpc_id' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.vpc_id == vpc_id - - "'tags' in new_rds_mysql_option_group" - - (new_rds_mysql_option_group.tags == option_tags - - "'options' in new_rds_mysql_option_group" - - (new_rds_mysql_option_group.options | length) > 0 - - "'option_name' in option" - - option.option_name == "MEMCACHED" - - "'permanent' in option" - - "'persistent' in option" - - "'port' in option" - - option.port == 11211 - - "'vpc_security_group_memberships' in option" - - (option.vpc_security_group_memberships | length) == 3 - - "'option_settings' in option" - - (option_settings | length) > 0 - - option_settings | selectattr('name','equalto','CHUNK_SIZE_GROWTH_FACTOR') - | list | count > 0 - vars: - option: '{{ new_rds_mysql_option_group.options[0] }}' - option_settings: '{{ new_rds_mysql_option_group.options[0].option_settings }}' - option_tags: - tag_one: '{{ option_group_name }} One' - Tag Two: two {{ option_group_name }} - - - - name: RDS Mysql option group - apply tags (idempotency) - rds_option_group: - state: present - option_group_name: '{{ option_group_name }}' - engine_name: '{{ engine_name }}' - major_engine_version: '{{ major_engine_version }}' - option_group_description: '{{ option_group_description }}' - apply_immediately: true - options: - - option_name: MEMCACHED - port: 11211 - vpc_security_group_memberships: - - '{{ sg_1 }}' - - '{{ sg_2 }}' - - '{{ sg_3 }}' - option_settings: - - name: CHUNK_SIZE_GROWTH_FACTOR - value: '1.2' - tags: - tag_one: '{{ option_group_name }} One' - Tag Two: two {{ option_group_name }} - register: new_rds_mysql_option_group - - - assert: - that: - - not new_rds_mysql_option_group.changed - - "'engine_name' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.engine_name == engine_name - - "'major_engine_version' in new_rds_mysql_option_group" - - (new_rds_mysql_option_group.major_engine_version | string) == (major_engine_version | string) - - "'option_group_arn' in new_rds_mysql_option_group" - - "'option_group_description' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.option_group_description == option_group_description - - "'option_group_name' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.option_group_name == option_group_name - - "'vpc_id' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.vpc_id == vpc_id - - "'tags' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.tags == option_tags - - "'options' in new_rds_mysql_option_group" - - (new_rds_mysql_option_group.options | length) > 0 - - "'option_name' in option" - - option.option_name == "MEMCACHED" - - "'permanent' in option" - - "'persistent' in option" - - "'port' in option" - - option.port == 11211 - - "'vpc_security_group_memberships' in option" - - (option.vpc_security_group_memberships | length) == 3 - - "'option_settings' in option" - - (option_settings | length) > 0 - - option_settings | selectattr('name','equalto','CHUNK_SIZE_GROWTH_FACTOR') - | list | count > 0 - vars: - option: '{{ new_rds_mysql_option_group.options[0] }}' - option_settings: '{{ new_rds_mysql_option_group.options[0].option_settings }}' - option_tags: - tag_one: '{{ option_group_name }} One' - Tag Two: two {{ option_group_name }} - - - name: RDS Mysql option group - update tags - rds_option_group: - state: present - option_group_name: '{{ option_group_name }}' - engine_name: '{{ engine_name }}' - major_engine_version: '{{ major_engine_version }}' - option_group_description: '{{ option_group_description }}' - apply_immediately: true - options: - - option_name: MEMCACHED - port: 11211 - vpc_security_group_memberships: - - '{{ sg_1 }}' - - '{{ sg_2 }}' - - '{{ sg_3 }}' - option_settings: - - name: CHUNK_SIZE_GROWTH_FACTOR - value: '1.2' - tags: - tag_three: '{{ option_group_name }} Three' - Tag Two: two {{ option_group_name }} - register: new_rds_mysql_option_group - - - assert: - that: - - new_rds_mysql_option_group.changed - - "'engine_name' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.engine_name == engine_name - - "'major_engine_version' in new_rds_mysql_option_group" - - (new_rds_mysql_option_group.major_engine_version | string) == (major_engine_version | string) - - "'option_group_arn' in new_rds_mysql_option_group" - - "'option_group_description' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.option_group_description == option_group_description - - "'option_group_name' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.option_group_name == option_group_name - - "'vpc_id' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.vpc_id == vpc_id - - "'tags' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.tags == option_tags - - "'options' in new_rds_mysql_option_group" - - (new_rds_mysql_option_group.options | length) > 0 - - "'option_name' in option" - - option.option_name == "MEMCACHED" - - "'permanent' in option" - - "'persistent' in option" - - "'port' in option" - - option.port == 11211 - - "'vpc_security_group_memberships' in option" - - (option.vpc_security_group_memberships | length) == 3 - - "'option_settings' in option" - - (option_settings | length) > 0 - - option_settings | selectattr('name','equalto','CHUNK_SIZE_GROWTH_FACTOR') - | list | count > 0 - vars: - option: '{{ new_rds_mysql_option_group.options[0] }}' - option_settings: '{{ new_rds_mysql_option_group.options[0].option_settings }}' - option_tags: - tag_three: '{{ option_group_name }} Three' - Tag Two: two {{ option_group_name }} - - - - name: RDS Mysql option group - update tags without purge (expected changed=true) - rds_option_group: - state: present - option_group_name: '{{ option_group_name }}' - engine_name: '{{ engine_name }}' - major_engine_version: '{{ major_engine_version }}' - option_group_description: '{{ option_group_description }}' - apply_immediately: true - options: - - option_name: MEMCACHED - port: 11211 - vpc_security_group_memberships: - - '{{ sg_1 }}' - - '{{ sg_2 }}' - - '{{ sg_3 }}' - option_settings: - - name: CHUNK_SIZE_GROWTH_FACTOR - value: '1.2' - purge_tags: no - tags: - tag_one: '{{ option_group_name }} One' - register: new_rds_mysql_option_group - - - assert: - that: - - new_rds_mysql_option_group.changed - - "'engine_name' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.engine_name == engine_name - - "'major_engine_version' in new_rds_mysql_option_group" - - (new_rds_mysql_option_group.major_engine_version | string) == (major_engine_version | string) - - "'option_group_arn' in new_rds_mysql_option_group" - - "'option_group_description' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.option_group_description == option_group_description - - "'option_group_name' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.option_group_name == option_group_name - - "'vpc_id' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.vpc_id == vpc_id - - "'tags' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.tags == option_tags - - "'options' in new_rds_mysql_option_group" - - (new_rds_mysql_option_group.options | length) > 0 - - "'option_name' in option" - - option.option_name == "MEMCACHED" - - "'permanent' in option" - - "'persistent' in option" - - "'port' in option" - - option.port == 11211 - - "'vpc_security_group_memberships' in option" - - (option.vpc_security_group_memberships | length) == 3 - - "'option_settings' in option" - - (option_settings | length) > 0 - - option_settings | selectattr('name','equalto','CHUNK_SIZE_GROWTH_FACTOR') - | list | count > 0 - vars: - option: '{{ new_rds_mysql_option_group.options[0] }}' - option_settings: '{{ new_rds_mysql_option_group.options[0].option_settings }}' - option_tags: - tag_one: '{{ option_group_name }} One' - Tag Two: two {{ option_group_name }} - tag_three: '{{ option_group_name }} Three' - - - - name: RDS Mysql option group - update with CamelCase tags (expected changed=true) - rds_option_group: - state: present - option_group_name: '{{ option_group_name }}' - engine_name: '{{ engine_name }}' - major_engine_version: '{{ major_engine_version }}' - option_group_description: '{{ option_group_description }}' - apply_immediately: true - options: - - option_name: MEMCACHED - port: 11211 - vpc_security_group_memberships: - - '{{ sg_1 }}' - - '{{ sg_2 }}' - - '{{ sg_3 }}' - option_settings: - - name: CHUNK_SIZE_GROWTH_FACTOR - value: '1.2' - tags: - lowercase spaced: hello cruel world - Title Case: Hello Cruel World - CamelCase: SimpleCamelCase - snake_case: simple_snake_case - register: new_rds_mysql_option_group - - - assert: - that: - - new_rds_mysql_option_group.changed - - "'engine_name' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.engine_name == engine_name - - "'major_engine_version' in new_rds_mysql_option_group" - - (new_rds_mysql_option_group.major_engine_version | string) == (major_engine_version | string) - - "'option_group_arn' in new_rds_mysql_option_group" - - "'option_group_description' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.option_group_description == option_group_description - - "'option_group_name' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.option_group_name == option_group_name - - "'vpc_id' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.vpc_id == vpc_id - - "'tags' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.tags == option_tags - - "'options' in new_rds_mysql_option_group" - - (new_rds_mysql_option_group.options | length) > 0 - - "'option_name' in option" - - option.option_name == "MEMCACHED" - - "'permanent' in option" - - "'persistent' in option" - - "'port' in option" - - option.port == 11211 - - "'vpc_security_group_memberships' in option" - - (option.vpc_security_group_memberships | length) == 3 - - "'option_settings' in option" - - (option_settings | length) > 0 - - option_settings | selectattr('name','equalto','CHUNK_SIZE_GROWTH_FACTOR') - | list | count > 0 - vars: - option: '{{ new_rds_mysql_option_group.options[0] }}' - option_settings: '{{ new_rds_mysql_option_group.options[0].option_settings }}' - option_tags: - lowercase spaced: hello cruel world - Title Case: Hello Cruel World - CamelCase: SimpleCamelCase - snake_case: simple_snake_case - - - name: RDS Mysql option group - do not specify any tag to ensure previous tags - are not removed - rds_option_group: - state: present - option_group_name: '{{ option_group_name }}' - engine_name: '{{ engine_name }}' - major_engine_version: '{{ major_engine_version }}' - option_group_description: '{{ option_group_description }}' - apply_immediately: true - options: - - option_name: MEMCACHED - port: 11211 - vpc_security_group_memberships: - - '{{ sg_1 }}' - - '{{ sg_2 }}' - - '{{ sg_3 }}' - option_settings: - - name: CHUNK_SIZE_GROWTH_FACTOR - value: '1.2' - register: new_rds_mysql_option_group - - - assert: - that: - - not new_rds_mysql_option_group.changed - - "'engine_name' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.engine_name == engine_name - - "'major_engine_version' in new_rds_mysql_option_group" - - (new_rds_mysql_option_group.major_engine_version | string) == (major_engine_version | string) - - "'option_group_arn' in new_rds_mysql_option_group" - - "'option_group_description' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.option_group_description == option_group_description - - "'option_group_name' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.option_group_name == option_group_name - - "'vpc_id' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.vpc_id == vpc_id - - "'tags' in new_rds_mysql_option_group" - - new_rds_mysql_option_group.tags == option_tags - - "'options' in new_rds_mysql_option_group" - - (new_rds_mysql_option_group.options | length) > 0 - - "'option_name' in option" - - option.option_name == "MEMCACHED" - - "'permanent' in option" - - "'persistent' in option" - - "'port' in option" - - option.port == 11211 - - "'vpc_security_group_memberships' in option" - - (option.vpc_security_group_memberships | length) == 3 - - "'option_settings' in option" - - (option_settings | length) > 0 - - option_settings | selectattr('name','equalto','CHUNK_SIZE_GROWTH_FACTOR') - | list | count > 0 - vars: - option: '{{ new_rds_mysql_option_group.options[0] }}' - option_settings: '{{ new_rds_mysql_option_group.options[0].option_settings }}' - option_tags: - lowercase spaced: hello cruel world - Title Case: Hello Cruel World - CamelCase: SimpleCamelCase - snake_case: simple_snake_case - - - name: Delete an RDS Mysql option group - CHECK_MODE - rds_option_group: - state: absent - option_group_name: '{{ option_group_name }}' - check_mode: yes - register: deleted_rds_mysql_option_group - - - name: Assert success - CHECK_MODE - assert: - that: - - deleted_rds_mysql_option_group.changed - - - - name: Delete an RDS Mysql option group - rds_option_group: - state: absent - option_group_name: '{{ option_group_name }}' - register: deleted_rds_mysql_option_group - - - name: Assert success - assert: - that: - - deleted_rds_mysql_option_group.changed - + - name: Create a VPC + amazon.aws.ec2_vpc_net: + name: "{{ vpc_name }}" + state: present + cidr_block: "{{ vpc_cidr }}" + register: vpc_result + + - name: Assert success + ansible.builtin.assert: + that: + - vpc_result is successful + - '"vpc" in vpc_result' + - '"cidr_block" in vpc_result.vpc' + - vpc_result.vpc.cidr_block == vpc_cidr + - '"id" in vpc_result.vpc' + - vpc_result.vpc.id.startswith("vpc-") + - '"state" in vpc_result.vpc' + - vpc_result.vpc.state == 'available' + - '"tags" in vpc_result.vpc' + + - name: "Set fact: VPC ID" + ansible.builtin.set_fact: + vpc_id: "{{ vpc_result.vpc.id }}" + + - name: Create subnet + amazon.aws.ec2_vpc_subnet: + cidr: "{{ subnet_cidr }}" + vpc_id: "{{ vpc_id }}" + state: present + register: subnet_result + + - name: Assert success + ansible.builtin.assert: + that: + - subnet_result is successful + - '"subnet" in subnet_result' + - '"cidr_block" in subnet_result.subnet' + - subnet_result.subnet.cidr_block == subnet_cidr + - '"id" in subnet_result.subnet' + - subnet_result.subnet.id.startswith("subnet-") + - '"state" in subnet_result.subnet' + - subnet_result.subnet.state == 'available' + - '"tags" in subnet_result.subnet' + - subnet_result.subnet.vpc_id == vpc_id + + - name: "Set fact: VPC subnet ID" + ansible.builtin.set_fact: + subnet_id: "{{ subnet_result.subnet.id }}" + + - name: Create security groups + amazon.aws.ec2_security_group: + name: "{{ item }}" + description: created by rds_instance integration tests + state: present + vpc_id: "{{ vpc_id }}" + register: sgs_result + loop: + - "{{ sg_1_name }}" + - "{{ sg_2_name }}" + - "{{ sg_3_name }}" + + - name: Assert success + ansible.builtin.assert: + that: + - sgs_result is successful + + - name: "Set fact: security groups ID" + ansible.builtin.set_fact: + sg_1: "{{ sgs_result.results.0.group_id }}" + sg_2: "{{ sgs_result.results.1.group_id }}" + sg_3: "{{ sgs_result.results.2.group_id }}" + + - name: List all the option groups - CHECK_MODE + amazon.aws.rds_option_group_info: + register: option_groups_result + check_mode: true + + - name: Assert success - CHECK_MODE + ansible.builtin.assert: + that: + - option_groups_result is successful + + - name: List all the option groups + amazon.aws.rds_option_group_info: + register: option_groups_result + check_mode: true + + - name: Assert success + ansible.builtin.assert: + that: + - option_groups_result is successful + + - name: Create an RDS Mysql option group - CHECK_MODE + amazon.aws.rds_option_group: + state: present + option_group_name: "{{ option_group_name }}" + engine_name: "{{ engine_name }}" + major_engine_version: "{{ major_engine_version }}" + option_group_description: "{{ option_group_description }}" + apply_immediately: true + options: + - option_name: MEMCACHED + port: 11211 + vpc_security_group_memberships: + - "{{ sg_1 }}" + option_settings: + - name: MAX_SIMULTANEOUS_CONNECTIONS + value: "20" + - name: CHUNK_SIZE_GROWTH_FACTOR + value: "1.25" + check_mode: true + register: new_rds_mysql_option_group + + - name: Assert success - CHECK_MODE + ansible.builtin.assert: + that: + - new_rds_mysql_option_group.changed + + - name: Create an RDS Mysql option group + amazon.aws.rds_option_group: + state: present + option_group_name: "{{ option_group_name }}" + engine_name: "{{ engine_name }}" + major_engine_version: "{{ major_engine_version }}" + option_group_description: "{{ option_group_description }}" + apply_immediately: true + options: + - option_name: MEMCACHED + port: 11211 + vpc_security_group_memberships: + - "{{ sg_1 }}" + option_settings: + - name: MAX_SIMULTANEOUS_CONNECTIONS + value: "20" + - name: CHUNK_SIZE_GROWTH_FACTOR + value: "1.25" + register: new_rds_mysql_option_group + + - name: Validate return values + ansible.builtin.assert: + that: + - new_rds_mysql_option_group.changed + - "'engine_name' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.engine_name == engine_name + - "'major_engine_version' in new_rds_mysql_option_group" + - (new_rds_mysql_option_group.major_engine_version | string) == (major_engine_version | string) + - "'option_group_arn' in new_rds_mysql_option_group" + - "'option_group_description' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.option_group_description == option_group_description + - "'option_group_name' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.option_group_name == option_group_name + - "'vpc_id' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.vpc_id == vpc_id + - "'options' in new_rds_mysql_option_group" + - (new_rds_mysql_option_group.options | length) > 0 + - "'option_name' in option" + - option.option_name == "MEMCACHED" + - "'permanent' in option" + - "'persistent' in option" + - "'port' in option" + - option.port == 11211 + - "'vpc_security_group_memberships' in option" + - (option.vpc_security_group_memberships | length) == 1 + - option.vpc_security_group_memberships[0].vpc_security_group_id == sg_1 + - "'option_settings' in option" + - (option_settings | length) > 0 + - option_settings | selectattr('name','equalto','MAX_SIMULTANEOUS_CONNECTIONS') | list | count > 0 + - option_settings | selectattr('name','equalto','CHUNK_SIZE_GROWTH_FACTOR') | list | count > 0 + vars: + option: "{{ new_rds_mysql_option_group.options[0] }}" + option_settings: "{{ new_rds_mysql_option_group.options[0].option_settings }}" + + - name: List specific option group + amazon.aws.rds_option_group_info: + option_group_name: "{{ option_group_name }}" + register: option_groups_result + + - name: Assert success + ansible.builtin.assert: + that: + - option_groups_result is successful + - (option_groups_result.result | length) == 1 + - "'engine_name' in option_groups_list" + - option_groups_list.engine_name == engine_name + - "'major_engine_version' in option_groups_list" + - (option_groups_list.major_engine_version | string) == (major_engine_version | string) + - "'option_group_arn' in option_groups_list" + - "'option_group_description' in option_groups_list" + - option_groups_list.option_group_description == option_group_description + - "'option_group_name' in option_groups_list" + - option_groups_list.option_group_name == option_group_name + - "'vpc_id' in option_groups_list" + - new_rds_mysql_option_group.vpc_id == vpc_id + - "'options' in option_groups_list" + - (option_groups_list.options | length) > 0 + - "'option_name' in options" + - options.option_name == "MEMCACHED" + - "'permanent' in options" + - "'persistent' in options" + - "'port' in options" + - options.port == 11211 + - "'vpc_security_group_memberships' in options" + - (options.vpc_security_group_memberships | length) == 1 + - options.vpc_security_group_memberships[0].vpc_security_group_id == sg_1 + - "'option_settings' in options" + - (options.option_settings | length) > 0 + vars: + option_groups_list: "{{ option_groups_result.result[0] }}" + options: "{{ option_groups_result.result[0].options[0] }}" + + - name: Create an RDS Mysql option group (idempotency) - CHECK_MODE + amazon.aws.rds_option_group: + state: present + option_group_name: "{{ option_group_name }}" + engine_name: "{{ engine_name }}" + major_engine_version: "{{ major_engine_version }}" + option_group_description: "{{ option_group_description }}" + apply_immediately: true + options: + - option_name: MEMCACHED + port: 11211 + vpc_security_group_memberships: + - "{{ sg_1 }}" + option_settings: + - name: MAX_SIMULTANEOUS_CONNECTIONS + value: "20" + - name: CHUNK_SIZE_GROWTH_FACTOR + value: "1.25" + check_mode: true + register: new_rds_mysql_option_group + + - name: Assert success - CHECK_MODE + ansible.builtin.assert: + that: + - not new_rds_mysql_option_group.changed + - "'engine_name' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.engine_name == engine_name + - "'major_engine_version' in new_rds_mysql_option_group" + - (new_rds_mysql_option_group.major_engine_version | string) == (major_engine_version | string) + - "'option_group_arn' in new_rds_mysql_option_group" + - "'option_group_description' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.option_group_description == option_group_description + - "'option_group_name' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.option_group_name == option_group_name + - "'vpc_id' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.vpc_id == vpc_id + - "'options' in new_rds_mysql_option_group" + - (new_rds_mysql_option_group.options | length) > 0 + - "'option_name' in option" + - option.option_name == "MEMCACHED" + - "'permanent' in option" + - "'persistent' in option" + - "'port' in option" + - option.port == 11211 + - "'vpc_security_group_memberships' in option" + - (option.vpc_security_group_memberships | length) == 1 + - option.vpc_security_group_memberships[0].vpc_security_group_id == sg_1 + - "'option_settings' in option" + - (option_settings | length) > 0 + - option_settings | selectattr('name','equalto','MAX_SIMULTANEOUS_CONNECTIONS') | list | count > 0 + - option_settings | selectattr('name','equalto','CHUNK_SIZE_GROWTH_FACTOR') | list | count > 0 + vars: + option: "{{ new_rds_mysql_option_group.options[0] }}" + option_settings: "{{ new_rds_mysql_option_group.options[0].option_settings }}" + + - name: Create an RDS Mysql option group (idempotency) + amazon.aws.rds_option_group: + state: present + option_group_name: "{{ option_group_name }}" + engine_name: "{{ engine_name }}" + major_engine_version: "{{ major_engine_version }}" + option_group_description: "{{ option_group_description }}" + apply_immediately: true + options: + - option_name: MEMCACHED + port: 11211 + vpc_security_group_memberships: + - "{{ sg_1 }}" + option_settings: + - name: MAX_SIMULTANEOUS_CONNECTIONS + value: "20" + - name: CHUNK_SIZE_GROWTH_FACTOR + value: "1.25" + register: new_rds_mysql_option_group + + - name: Validate return values + ansible.builtin.assert: + that: + - not new_rds_mysql_option_group.changed + - "'engine_name' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.engine_name == engine_name + - "'major_engine_version' in new_rds_mysql_option_group" + - (new_rds_mysql_option_group.major_engine_version | string) == (major_engine_version | string) + - "'option_group_arn' in new_rds_mysql_option_group" + - "'option_group_description' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.option_group_description == option_group_description + - "'option_group_name' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.option_group_name == option_group_name + - "'vpc_id' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.vpc_id == vpc_id + - "'options' in new_rds_mysql_option_group" + - (new_rds_mysql_option_group.options | length) > 0 + - "'option_name' in option" + - option.option_name == "MEMCACHED" + - "'permanent' in option" + - "'persistent' in option" + - "'port' in option" + - option.port == 11211 + - "'vpc_security_group_memberships' in option" + - (option.vpc_security_group_memberships | length) == 1 + - option.vpc_security_group_memberships[0].vpc_security_group_id == sg_1 + - "'option_settings' in option" + - (option_settings | length) > 0 + - option_settings | selectattr('name','equalto','MAX_SIMULTANEOUS_CONNECTIONS') | list | count > 0 + - option_settings | selectattr('name','equalto','CHUNK_SIZE_GROWTH_FACTOR') | list | count > 0 + vars: + option: "{{ new_rds_mysql_option_group.options[0] }}" + option_settings: "{{ new_rds_mysql_option_group.options[0].option_settings }}" + + - name: List option groups with specific (engine_name and major_engine_version) + amazon.aws.rds_option_group_info: + engine_name: "{{ engine_name }}" + major_engine_version: "{{ major_engine_version }}" + register: option_groups_result + + - name: Assert success + ansible.builtin.assert: + that: + - option_groups_result is successful + - (option_groups_result.result | length) > 0 + + - name: Create an RDS Mysql option group - apply different changes (expected changed=true) + amazon.aws.rds_option_group: + state: present + option_group_name: "{{ option_group_name }}" + engine_name: "{{ engine_name }}" + major_engine_version: "{{ major_engine_version }}" + option_group_description: "{{ option_group_description }}" + apply_immediately: true + options: + - option_name: MEMCACHED + port: 11211 + vpc_security_group_memberships: + - "{{ sg_1 }}" + - "{{ sg_2 }}" + - "{{ sg_3 }}" + option_settings: + - name: MAX_SIMULTANEOUS_CONNECTIONS + value: "30" + register: new_rds_mysql_option_group + + - name: Validate return values + ansible.builtin.assert: + that: + - new_rds_mysql_option_group.changed + - "'engine_name' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.engine_name == engine_name + - "'major_engine_version' in new_rds_mysql_option_group" + - (new_rds_mysql_option_group.major_engine_version | string) == (major_engine_version | string) + - "'option_group_arn' in new_rds_mysql_option_group" + - "'option_group_description' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.option_group_description == option_group_description + - "'option_group_name' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.option_group_name == option_group_name + - "'vpc_id' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.vpc_id == vpc_id + - "'options' in new_rds_mysql_option_group" + - (new_rds_mysql_option_group.options | length) > 0 + - "'option_name' in option" + - option.option_name == "MEMCACHED" + - "'permanent' in option" + - "'persistent' in option" + - "'port' in option" + - option.port == 11211 + - "'vpc_security_group_memberships' in option" + - (option.vpc_security_group_memberships | length) == 3 + - "'option_settings' in option" + - (option_settings | length) > 0 + - option_settings | selectattr('name','equalto','CHUNK_SIZE_GROWTH_FACTOR') | list | count > 0 + vars: + option: "{{ new_rds_mysql_option_group.options[0] }}" + option_settings: "{{ new_rds_mysql_option_group.options[0].option_settings }}" + + - name: Get info about an option group - CHECK_MODE + amazon.aws.rds_option_group_info: + option_group_name: "{{ option_group_name }}" + check_mode: true + register: option_groups_result + + - name: Assert success - CHECK_MODE + ansible.builtin.assert: + that: + - option_groups_result is successful + - (option_groups_result.result | length) == 1 + - "'engine_name' in option_groups_list" + - option_groups_list.engine_name == engine_name + - "'major_engine_version' in option_groups_list" + - (option_groups_list.major_engine_version | string) == (major_engine_version | string) + - "'option_group_arn' in option_groups_list" + - "'option_group_description' in option_groups_list" + - option_groups_list.option_group_description == option_group_description + - "'option_group_name' in option_groups_list" + - option_groups_list.option_group_name == option_group_name + - "'vpc_id' in option_groups_list" + - new_rds_mysql_option_group.vpc_id == vpc_id + - "'options' in option_groups_list" + - (option_groups_list.options | length) > 0 + - "'option_name' in options" + - options.option_name == "MEMCACHED" + - "'permanent' in options" + - "'persistent' in options" + - "'port' in options" + - options.port == 11211 + - "'vpc_security_group_memberships' in options" + - (options.vpc_security_group_memberships | length) == 3 + - "'option_settings' in options" + - (options.option_settings | length) > 0 + vars: + option_groups_list: "{{ option_groups_result.result[0] }}" + options: "{{ option_groups_result.result[0].options[0] }}" + + - name: RDS Mysql option group - apply tags - CHECK_MODE + amazon.aws.rds_option_group: + state: present + option_group_name: "{{ option_group_name }}" + engine_name: "{{ engine_name }}" + major_engine_version: "{{ major_engine_version }}" + option_group_description: "{{ option_group_description }}" + apply_immediately: true + options: + - option_name: MEMCACHED + port: 11211 + vpc_security_group_memberships: + - "{{ sg_1 }}" + - "{{ sg_2 }}" + - "{{ sg_3 }}" + option_settings: + - name: CHUNK_SIZE_GROWTH_FACTOR + value: "1.2" + tags: + tag_one: "{{ option_group_name }} One" + Tag Two: two {{ option_group_name }} + check_mode: true + register: new_rds_mysql_option_group + + - name: Assert success - CHECK_MODE + ansible.builtin.assert: + that: + - new_rds_mysql_option_group.changed + - "'engine_name' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.engine_name == engine_name + - "'major_engine_version' in new_rds_mysql_option_group" + - (new_rds_mysql_option_group.major_engine_version | string) == (major_engine_version | string) + - "'option_group_arn' in new_rds_mysql_option_group" + - "'option_group_description' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.option_group_description == option_group_description + - "'option_group_name' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.option_group_name == option_group_name + - "'vpc_id' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.vpc_id == vpc_id + - "'tags' in new_rds_mysql_option_group" + - "'options' in new_rds_mysql_option_group" + - (new_rds_mysql_option_group.options | length) > 0 + - "'option_name' in option" + - option.option_name == "MEMCACHED" + - "'permanent' in option" + - "'persistent' in option" + - "'port' in option" + - option.port == 11211 + - "'vpc_security_group_memberships' in option" + - (option.vpc_security_group_memberships | length) == 3 + - "'option_settings' in option" + - (option_settings | length) > 0 + - option_settings | selectattr('name','equalto','CHUNK_SIZE_GROWTH_FACTOR') | list | count > 0 + vars: + option: "{{ new_rds_mysql_option_group.options[0] }}" + option_settings: "{{ new_rds_mysql_option_group.options[0].option_settings }}" + + - name: RDS Mysql option group - apply tags + amazon.aws.rds_option_group: + state: present + option_group_name: "{{ option_group_name }}" + engine_name: "{{ engine_name }}" + major_engine_version: "{{ major_engine_version }}" + option_group_description: "{{ option_group_description }}" + apply_immediately: true + options: + - option_name: MEMCACHED + port: 11211 + vpc_security_group_memberships: + - "{{ sg_1 }}" + - "{{ sg_2 }}" + - "{{ sg_3 }}" + option_settings: + - name: CHUNK_SIZE_GROWTH_FACTOR + value: "1.2" + tags: + tag_one: "{{ option_group_name }} One" + Tag Two: two {{ option_group_name }} + register: new_rds_mysql_option_group + + - name: Validate return values + ansible.builtin.assert: + that: + - new_rds_mysql_option_group.changed + - "'engine_name' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.engine_name == engine_name + - "'major_engine_version' in new_rds_mysql_option_group" + - (new_rds_mysql_option_group.major_engine_version | string) == (major_engine_version | string) + - "'option_group_arn' in new_rds_mysql_option_group" + - "'option_group_description' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.option_group_description == option_group_description + - "'option_group_name' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.option_group_name == option_group_name + - "'vpc_id' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.vpc_id == vpc_id + - "'tags' in new_rds_mysql_option_group" + - (new_rds_mysql_option_group.tags == option_tags + - "'options' in new_rds_mysql_option_group" + - (new_rds_mysql_option_group.options | length) > 0 + - "'option_name' in option" + - option.option_name == "MEMCACHED" + - "'permanent' in option" + - "'persistent' in option" + - "'port' in option" + - option.port == 11211 + - "'vpc_security_group_memberships' in option" + - (option.vpc_security_group_memberships | length) == 3 + - "'option_settings' in option" + - (option_settings | length) > 0 + - option_settings | selectattr('name','equalto','CHUNK_SIZE_GROWTH_FACTOR') | list | count > 0 + vars: + option: "{{ new_rds_mysql_option_group.options[0] }}" + option_settings: "{{ new_rds_mysql_option_group.options[0].option_settings }}" + option_tags: + tag_one: "{{ option_group_name }} One" + Tag Two: two {{ option_group_name }} + + - name: RDS Mysql option group - apply tags (idempotency) + amazon.aws.rds_option_group: + state: present + option_group_name: "{{ option_group_name }}" + engine_name: "{{ engine_name }}" + major_engine_version: "{{ major_engine_version }}" + option_group_description: "{{ option_group_description }}" + apply_immediately: true + options: + - option_name: MEMCACHED + port: 11211 + vpc_security_group_memberships: + - "{{ sg_1 }}" + - "{{ sg_2 }}" + - "{{ sg_3 }}" + option_settings: + - name: CHUNK_SIZE_GROWTH_FACTOR + value: "1.2" + tags: + tag_one: "{{ option_group_name }} One" + Tag Two: two {{ option_group_name }} + register: new_rds_mysql_option_group + + - name: Validate return values + ansible.builtin.assert: + that: + - not new_rds_mysql_option_group.changed + - "'engine_name' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.engine_name == engine_name + - "'major_engine_version' in new_rds_mysql_option_group" + - (new_rds_mysql_option_group.major_engine_version | string) == (major_engine_version | string) + - "'option_group_arn' in new_rds_mysql_option_group" + - "'option_group_description' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.option_group_description == option_group_description + - "'option_group_name' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.option_group_name == option_group_name + - "'vpc_id' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.vpc_id == vpc_id + - "'tags' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.tags == option_tags + - "'options' in new_rds_mysql_option_group" + - (new_rds_mysql_option_group.options | length) > 0 + - "'option_name' in option" + - option.option_name == "MEMCACHED" + - "'permanent' in option" + - "'persistent' in option" + - "'port' in option" + - option.port == 11211 + - "'vpc_security_group_memberships' in option" + - (option.vpc_security_group_memberships | length) == 3 + - "'option_settings' in option" + - (option_settings | length) > 0 + - option_settings | selectattr('name','equalto','CHUNK_SIZE_GROWTH_FACTOR') | list | count > 0 + vars: + option: "{{ new_rds_mysql_option_group.options[0] }}" + option_settings: "{{ new_rds_mysql_option_group.options[0].option_settings }}" + option_tags: + tag_one: "{{ option_group_name }} One" + Tag Two: two {{ option_group_name }} + + - name: RDS Mysql option group - update tags + amazon.aws.rds_option_group: + state: present + option_group_name: "{{ option_group_name }}" + engine_name: "{{ engine_name }}" + major_engine_version: "{{ major_engine_version }}" + option_group_description: "{{ option_group_description }}" + apply_immediately: true + options: + - option_name: MEMCACHED + port: 11211 + vpc_security_group_memberships: + - "{{ sg_1 }}" + - "{{ sg_2 }}" + - "{{ sg_3 }}" + option_settings: + - name: CHUNK_SIZE_GROWTH_FACTOR + value: "1.2" + tags: + tag_three: "{{ option_group_name }} Three" + Tag Two: two {{ option_group_name }} + register: new_rds_mysql_option_group + + - name: Validate return values + ansible.builtin.assert: + that: + - new_rds_mysql_option_group.changed + - "'engine_name' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.engine_name == engine_name + - "'major_engine_version' in new_rds_mysql_option_group" + - (new_rds_mysql_option_group.major_engine_version | string) == (major_engine_version | string) + - "'option_group_arn' in new_rds_mysql_option_group" + - "'option_group_description' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.option_group_description == option_group_description + - "'option_group_name' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.option_group_name == option_group_name + - "'vpc_id' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.vpc_id == vpc_id + - "'tags' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.tags == option_tags + - "'options' in new_rds_mysql_option_group" + - (new_rds_mysql_option_group.options | length) > 0 + - "'option_name' in option" + - option.option_name == "MEMCACHED" + - "'permanent' in option" + - "'persistent' in option" + - "'port' in option" + - option.port == 11211 + - "'vpc_security_group_memberships' in option" + - (option.vpc_security_group_memberships | length) == 3 + - "'option_settings' in option" + - (option_settings | length) > 0 + - option_settings | selectattr('name','equalto','CHUNK_SIZE_GROWTH_FACTOR') | list | count > 0 + vars: + option: "{{ new_rds_mysql_option_group.options[0] }}" + option_settings: "{{ new_rds_mysql_option_group.options[0].option_settings }}" + option_tags: + tag_three: "{{ option_group_name }} Three" + Tag Two: two {{ option_group_name }} + + - name: RDS Mysql option group - update tags without purge (expected changed=true) + amazon.aws.rds_option_group: + state: present + option_group_name: "{{ option_group_name }}" + engine_name: "{{ engine_name }}" + major_engine_version: "{{ major_engine_version }}" + option_group_description: "{{ option_group_description }}" + apply_immediately: true + options: + - option_name: MEMCACHED + port: 11211 + vpc_security_group_memberships: + - "{{ sg_1 }}" + - "{{ sg_2 }}" + - "{{ sg_3 }}" + option_settings: + - name: CHUNK_SIZE_GROWTH_FACTOR + value: "1.2" + purge_tags: false + tags: + tag_one: "{{ option_group_name }} One" + register: new_rds_mysql_option_group + + - name: Validate return values + ansible.builtin.assert: + that: + - new_rds_mysql_option_group.changed + - "'engine_name' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.engine_name == engine_name + - "'major_engine_version' in new_rds_mysql_option_group" + - (new_rds_mysql_option_group.major_engine_version | string) == (major_engine_version | string) + - "'option_group_arn' in new_rds_mysql_option_group" + - "'option_group_description' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.option_group_description == option_group_description + - "'option_group_name' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.option_group_name == option_group_name + - "'vpc_id' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.vpc_id == vpc_id + - "'tags' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.tags == option_tags + - "'options' in new_rds_mysql_option_group" + - (new_rds_mysql_option_group.options | length) > 0 + - "'option_name' in option" + - option.option_name == "MEMCACHED" + - "'permanent' in option" + - "'persistent' in option" + - "'port' in option" + - option.port == 11211 + - "'vpc_security_group_memberships' in option" + - (option.vpc_security_group_memberships | length) == 3 + - "'option_settings' in option" + - (option_settings | length) > 0 + - option_settings | selectattr('name','equalto','CHUNK_SIZE_GROWTH_FACTOR') | list | count > 0 + vars: + option: "{{ new_rds_mysql_option_group.options[0] }}" + option_settings: "{{ new_rds_mysql_option_group.options[0].option_settings }}" + option_tags: + tag_one: "{{ option_group_name }} One" + Tag Two: two {{ option_group_name }} + tag_three: "{{ option_group_name }} Three" + + - name: RDS Mysql option group - update with CamelCase tags (expected changed=true) + amazon.aws.rds_option_group: + state: present + option_group_name: "{{ option_group_name }}" + engine_name: "{{ engine_name }}" + major_engine_version: "{{ major_engine_version }}" + option_group_description: "{{ option_group_description }}" + apply_immediately: true + options: + - option_name: MEMCACHED + port: 11211 + vpc_security_group_memberships: + - "{{ sg_1 }}" + - "{{ sg_2 }}" + - "{{ sg_3 }}" + option_settings: + - name: CHUNK_SIZE_GROWTH_FACTOR + value: "1.2" + tags: + lowercase spaced: hello cruel world + Title Case: Hello Cruel World + CamelCase: SimpleCamelCase + snake_case: simple_snake_case + register: new_rds_mysql_option_group + + - name: Validate return values + ansible.builtin.assert: + that: + - new_rds_mysql_option_group.changed + - "'engine_name' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.engine_name == engine_name + - "'major_engine_version' in new_rds_mysql_option_group" + - (new_rds_mysql_option_group.major_engine_version | string) == (major_engine_version | string) + - "'option_group_arn' in new_rds_mysql_option_group" + - "'option_group_description' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.option_group_description == option_group_description + - "'option_group_name' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.option_group_name == option_group_name + - "'vpc_id' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.vpc_id == vpc_id + - "'tags' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.tags == option_tags + - "'options' in new_rds_mysql_option_group" + - (new_rds_mysql_option_group.options | length) > 0 + - "'option_name' in option" + - option.option_name == "MEMCACHED" + - "'permanent' in option" + - "'persistent' in option" + - "'port' in option" + - option.port == 11211 + - "'vpc_security_group_memberships' in option" + - (option.vpc_security_group_memberships | length) == 3 + - "'option_settings' in option" + - (option_settings | length) > 0 + - option_settings | selectattr('name','equalto','CHUNK_SIZE_GROWTH_FACTOR') | list | count > 0 + vars: + option: "{{ new_rds_mysql_option_group.options[0] }}" + option_settings: "{{ new_rds_mysql_option_group.options[0].option_settings }}" + option_tags: + lowercase spaced: hello cruel world + Title Case: Hello Cruel World + CamelCase: SimpleCamelCase + snake_case: simple_snake_case + + - name: RDS Mysql option group - do not specify any tag to ensure previous tags are not removed + amazon.aws.rds_option_group: + state: present + option_group_name: "{{ option_group_name }}" + engine_name: "{{ engine_name }}" + major_engine_version: "{{ major_engine_version }}" + option_group_description: "{{ option_group_description }}" + apply_immediately: true + options: + - option_name: MEMCACHED + port: 11211 + vpc_security_group_memberships: + - "{{ sg_1 }}" + - "{{ sg_2 }}" + - "{{ sg_3 }}" + option_settings: + - name: CHUNK_SIZE_GROWTH_FACTOR + value: "1.2" + register: new_rds_mysql_option_group + + - name: Validate return values + ansible.builtin.assert: + that: + - not new_rds_mysql_option_group.changed + - "'engine_name' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.engine_name == engine_name + - "'major_engine_version' in new_rds_mysql_option_group" + - (new_rds_mysql_option_group.major_engine_version | string) == (major_engine_version | string) + - "'option_group_arn' in new_rds_mysql_option_group" + - "'option_group_description' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.option_group_description == option_group_description + - "'option_group_name' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.option_group_name == option_group_name + - "'vpc_id' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.vpc_id == vpc_id + - "'tags' in new_rds_mysql_option_group" + - new_rds_mysql_option_group.tags == option_tags + - "'options' in new_rds_mysql_option_group" + - (new_rds_mysql_option_group.options | length) > 0 + - "'option_name' in option" + - option.option_name == "MEMCACHED" + - "'permanent' in option" + - "'persistent' in option" + - "'port' in option" + - option.port == 11211 + - "'vpc_security_group_memberships' in option" + - (option.vpc_security_group_memberships | length) == 3 + - "'option_settings' in option" + - (option_settings | length) > 0 + - option_settings | selectattr('name','equalto','CHUNK_SIZE_GROWTH_FACTOR') | list | count > 0 + vars: + option: "{{ new_rds_mysql_option_group.options[0] }}" + option_settings: "{{ new_rds_mysql_option_group.options[0].option_settings }}" + option_tags: + lowercase spaced: hello cruel world + Title Case: Hello Cruel World + CamelCase: SimpleCamelCase + snake_case: simple_snake_case + + - name: Delete an RDS Mysql option group - CHECK_MODE + amazon.aws.rds_option_group: + state: absent + option_group_name: "{{ option_group_name }}" + check_mode: true + register: deleted_rds_mysql_option_group + + - name: Assert success - CHECK_MODE + ansible.builtin.assert: + that: + - deleted_rds_mysql_option_group.changed + + - name: Delete an RDS Mysql option group + amazon.aws.rds_option_group: + state: absent + option_group_name: "{{ option_group_name }}" + register: deleted_rds_mysql_option_group + + - name: Assert success + ansible.builtin.assert: + that: + - deleted_rds_mysql_option_group.changed always: - - - name: Delete an RDS Mysql option group - rds_option_group: - state: absent - option_group_name: '{{ option_group_name }}' - register: deleted_rds_mysql_option_group - ignore_errors: yes - - - name: Remove security groups - ec2_security_group: - name: '{{ item }}' - description: created by rds_instance integration tests - state: absent - register: sgs_result - loop: - - '{{ sg_1_name }}' - - '{{ sg_2_name }}' - - '{{ sg_3_name }}' - ignore_errors: yes - - - name: remove subnet - ec2_vpc_subnet: - cidr: '{{ subnet_cidr }}' - vpc_id: '{{ vpc_id }}' - state: absent - ignore_errors: yes - - - name: Delete VPC - ec2_vpc_net: - name: '{{ vpc_name }}' - cidr_block: '{{ vpc_cidr }}' - state: absent - purge_cidrs: yes - ignore_errors: yes + - name: Delete an RDS Mysql option group + amazon.aws.rds_option_group: + state: absent + option_group_name: "{{ option_group_name }}" + register: deleted_rds_mysql_option_group + ignore_errors: true # noqa: ignore-errors + + - name: Remove security groups + amazon.aws.ec2_security_group: + name: "{{ item }}" + description: created by rds_instance integration tests + state: absent + register: sgs_result + loop: + - "{{ sg_1_name }}" + - "{{ sg_2_name }}" + - "{{ sg_3_name }}" + ignore_errors: true # noqa: ignore-errors + + - name: Remove subnet + amazon.aws.ec2_vpc_subnet: + cidr: "{{ subnet_cidr }}" + vpc_id: "{{ vpc_id }}" + state: absent + ignore_errors: true # noqa: ignore-errors + + - name: Delete VPC + amazon.aws.ec2_vpc_net: + name: "{{ vpc_name }}" + cidr_block: "{{ vpc_cidr }}" + state: absent + purge_cidrs: true + ignore_errors: true # noqa: ignore-errors From 71ae47d683b24f1d6361f01c35dfc1d838d85f0e Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Mon, 4 Dec 2023 11:30:04 +0100 Subject: [PATCH 7/9] minor syntax fix --- tests/integration/targets/rds_option_group/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/targets/rds_option_group/tasks/main.yml b/tests/integration/targets/rds_option_group/tasks/main.yml index 8bb66c519f7..8f4412a3cdc 100644 --- a/tests/integration/targets/rds_option_group/tasks/main.yml +++ b/tests/integration/targets/rds_option_group/tasks/main.yml @@ -525,7 +525,7 @@ - "'vpc_id' in new_rds_mysql_option_group" - new_rds_mysql_option_group.vpc_id == vpc_id - "'tags' in new_rds_mysql_option_group" - - (new_rds_mysql_option_group.tags == option_tags + - new_rds_mysql_option_group.tags == option_tags - "'options' in new_rds_mysql_option_group" - (new_rds_mysql_option_group.options | length) > 0 - "'option_name' in option" From 49ef1b75050876be69c54a0996335182bebbc8e8 Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Mon, 4 Dec 2023 14:52:31 +0100 Subject: [PATCH 8/9] Search ALBs by name when testing include_, to ensure we get the ALB we're expecting (and it has the things we're testing for) --- .../targets/elb_application_lb/tasks/main.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/integration/targets/elb_application_lb/tasks/main.yml b/tests/integration/targets/elb_application_lb/tasks/main.yml index 37ef332001b..9919f9da733 100644 --- a/tests/integration/targets/elb_application_lb/tasks/main.yml +++ b/tests/integration/targets/elb_application_lb/tasks/main.yml @@ -1403,6 +1403,8 @@ - name: Get ALB application info without skipping anything amazon.aws.elb_application_lb_info: + names: + - "{{ alb_2_name }}" register: alb_info - ansible.builtin.assert: that: @@ -1423,6 +1425,8 @@ - name: Get ALB application info excluding attributes amazon.aws.elb_application_lb_info: + names: + - "{{ alb_2_name }}" include_attributes: false register: alb_info - ansible.builtin.assert: @@ -1442,6 +1446,8 @@ - name: Get ALB application info without listeners, but with rules amazon.aws.elb_application_lb_info: + names: + - "{{ alb_2_name }}" include_listeners: false register: alb_info - ansible.builtin.assert: @@ -1451,6 +1457,8 @@ - name: Get ALB application info without listeners or rules amazon.aws.elb_application_lb_info: + names: + - "{{ alb_2_name }}" include_listeners: false include_listener_rules: false register: alb_info @@ -1460,6 +1468,8 @@ - name: Get ALB application info without listener rules amazon.aws.elb_application_lb_info: + names: + - "{{ alb_2_name }}" include_listener_rules: false register: alb_info - ansible.builtin.assert: @@ -1469,6 +1479,8 @@ - name: Get ALB application minimal info amazon.aws.elb_application_lb_info: + names: + - "{{ alb_2_name }}" include_attributes: false include_listeners: false include_listener_rules: false From ee3f0c92110411aa72ecec6512817967a41ca6a2 Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Mon, 4 Dec 2023 20:42:46 +0100 Subject: [PATCH 9/9] iam_group --- .../targets/iam_group/defaults/main.yml | 8 +- .../targets/iam_group/meta/main.yml | 1 + .../targets/iam_group/tasks/deletion.yml | 32 ++--- .../targets/iam_group/tasks/main.yml | 93 ++++++------ .../targets/iam_group/tasks/path.yml | 32 ++--- .../targets/iam_group/tasks/policy_update.yml | 133 +++++++++--------- .../targets/iam_group/tasks/users.yml | 52 +++---- 7 files changed, 176 insertions(+), 175 deletions(-) diff --git a/tests/integration/targets/iam_group/defaults/main.yml b/tests/integration/targets/iam_group/defaults/main.yml index d9fbdbae481..390ceee3e5e 100644 --- a/tests/integration/targets/iam_group/defaults/main.yml +++ b/tests/integration/targets/iam_group/defaults/main.yml @@ -1,7 +1,7 @@ --- -test_user: '{{ resource_prefix }}-user' -test_group: '{{ resource_prefix }}-group' -test_path: '/{{ resource_prefix }}-prefix/' +test_user: "{{ resource_prefix }}-user" +test_group: "{{ resource_prefix }}-group" +test_path: /{{ resource_prefix }}-prefix/ safe_managed_policy: AWSDenyAll -custom_policy_name: '{{ resource_prefix }}-denyall' +custom_policy_name: "{{ resource_prefix }}-denyall" diff --git a/tests/integration/targets/iam_group/meta/main.yml b/tests/integration/targets/iam_group/meta/main.yml index 32cf5dda7ed..23d65c7ef45 100644 --- a/tests/integration/targets/iam_group/meta/main.yml +++ b/tests/integration/targets/iam_group/meta/main.yml @@ -1 +1,2 @@ +--- dependencies: [] diff --git a/tests/integration/targets/iam_group/tasks/deletion.yml b/tests/integration/targets/iam_group/tasks/deletion.yml index b0441e04c5f..fc644f196e2 100644 --- a/tests/integration/targets/iam_group/tasks/deletion.yml +++ b/tests/integration/targets/iam_group/tasks/deletion.yml @@ -1,42 +1,42 @@ --- -- name: remove group (check_mode) - iam_group: - name: '{{ test_group }}' +- name: Remove group (check_mode) + amazon.aws.iam_group: + name: "{{ test_group }}" state: absent register: iam_group check_mode: true -- assert: +- ansible.builtin.assert: that: - iam_group is changed -- name: remove group - iam_group: - name: '{{ test_group }}' +- name: Remove group + amazon.aws.iam_group: + name: "{{ test_group }}" state: absent register: iam_group -- assert: +- ansible.builtin.assert: that: - iam_group is changed -- name: re-remove group (check_mode) - iam_group: - name: '{{ test_group }}' +- name: Re-remove group (check_mode) + amazon.aws.iam_group: + name: "{{ test_group }}" state: absent register: iam_group check_mode: true -- assert: +- ansible.builtin.assert: that: - iam_group is not changed -- name: re-remove group - iam_group: - name: '{{ test_group }}' +- name: Re-remove group + amazon.aws.iam_group: + name: "{{ test_group }}" state: absent register: iam_group -- assert: +- ansible.builtin.assert: that: - iam_group is not changed diff --git a/tests/integration/targets/iam_group/tasks/main.yml b/tests/integration/targets/iam_group/tasks/main.yml index 74d03296581..54015a446c7 100644 --- a/tests/integration/targets/iam_group/tasks/main.yml +++ b/tests/integration/targets/iam_group/tasks/main.yml @@ -1,5 +1,5 @@ --- -- name: set up aws connection info +- name: Set up aws connection info module_defaults: group/aws: access_key: "{{ aws_access_key }}" @@ -9,57 +9,56 @@ collections: - amazon.aws block: - - name: ensure ansible user exists - iam_user: - name: '{{ test_user }}' - state: present + - name: Ensure ansible user exists + amazon.aws.iam_user: + name: "{{ test_user }}" + state: present - - name: Create Safe IAM Managed Policy - iam_managed_policy: - state: present - policy_name: '{{ custom_policy_name }}' - policy_description: A safe (deny-all) managed policy - policy: "{{ lookup('file', 'deny-all.json') }}" - register: create_managed_policy + - name: Create Safe IAM Managed Policy + community.aws.iam_managed_policy: + state: present + policy_name: "{{ custom_policy_name }}" + policy_description: A safe (deny-all) managed policy + policy: "{{ lookup('file', 'deny-all.json') }}" + register: create_managed_policy - - assert: - that: - - create_managed_policy is succeeded + - ansible.builtin.assert: + that: + - create_managed_policy is succeeded - - name: ensure group exists - iam_group: - name: '{{ test_group }}' - users: - - '{{ test_user }}' - state: present - register: iam_group + - name: Ensure group exists + amazon.aws.iam_group: + name: "{{ test_group }}" + users: + - "{{ test_user }}" + state: present + register: iam_group - - assert: - that: - - "'users' in iam_group.iam_group" - - "'group' in iam_group.iam_group" - - "'attached_policies' in iam_group.iam_group" - - iam_group is changed - - iam_group.iam_group.group.group_name == test_group - - iam_group.iam_group.group.path == "/" - - - include_tasks: users.yml - - include_tasks: path.yml - - include_tasks: policy_update.yml - - include_tasks: deletion.yml + - ansible.builtin.assert: + that: + - "'users' in iam_group.iam_group" + - "'group' in iam_group.iam_group" + - "'attached_policies' in iam_group.iam_group" + - iam_group is changed + - iam_group.iam_group.group.group_name == test_group + - iam_group.iam_group.group.path == "/" + - ansible.builtin.include_tasks: users.yml + - ansible.builtin.include_tasks: path.yml + - ansible.builtin.include_tasks: policy_update.yml + - ansible.builtin.include_tasks: deletion.yml always: - - name: remove group - iam_group: - name: '{{ test_group }}' - state: absent + - name: Remove group + amazon.aws.iam_group: + name: "{{ test_group }}" + state: absent - - name: Remove Safe IAM Managed Policy - iam_managed_policy: - state: absent - policy_name: '{{ custom_policy_name }}' + - name: Remove Safe IAM Managed Policy + community.aws.iam_managed_policy: + state: absent + policy_name: "{{ custom_policy_name }}" - - name: remove ansible user - iam_user: - name: '{{ test_user }}' - state: absent + - name: Remove ansible user + amazon.aws.iam_user: + name: "{{ test_user }}" + state: absent diff --git a/tests/integration/targets/iam_group/tasks/path.yml b/tests/integration/targets/iam_group/tasks/path.yml index 6f2e440c8e1..f49a2f9b321 100644 --- a/tests/integration/targets/iam_group/tasks/path.yml +++ b/tests/integration/targets/iam_group/tasks/path.yml @@ -2,25 +2,25 @@ # Path management - name: Set path (check_mode) - iam_group: - name: '{{ test_group }}' - path: '{{ test_path }}' + amazon.aws.iam_group: + name: "{{ test_group }}" + path: "{{ test_path }}" state: present register: iam_group check_mode: true -- assert: +- ansible.builtin.assert: that: - iam_group is changed - name: Set path - iam_group: - name: '{{ test_group }}' - path: '{{ test_path }}' + amazon.aws.iam_group: + name: "{{ test_group }}" + path: "{{ test_path }}" state: present register: iam_group -- assert: +- ansible.builtin.assert: that: - iam_group is changed - "'users' in iam_group.iam_group" @@ -29,25 +29,25 @@ - iam_group.iam_group.group.path == test_path - name: Retry set path (check_mode) - iam_group: - name: '{{ test_group }}' - path: '{{ test_path }}' + amazon.aws.iam_group: + name: "{{ test_group }}" + path: "{{ test_path }}" state: present register: iam_group check_mode: true -- assert: +- ansible.builtin.assert: that: - iam_group is not changed - name: Retry set path - iam_group: - name: '{{ test_group }}' - path: '{{ test_path }}' + amazon.aws.iam_group: + name: "{{ test_group }}" + path: "{{ test_path }}" state: present register: iam_group -- assert: +- ansible.builtin.assert: that: - iam_group is not changed - "'users' in iam_group.iam_group" diff --git a/tests/integration/targets/iam_group/tasks/policy_update.yml b/tests/integration/targets/iam_group/tasks/policy_update.yml index 4ccc9bf86f6..b1c907df211 100644 --- a/tests/integration/targets/iam_group/tasks/policy_update.yml +++ b/tests/integration/targets/iam_group/tasks/policy_update.yml @@ -1,25 +1,26 @@ +--- - name: Add Managed Policy (CHECK MODE) - iam_group: - name: '{{ test_group }}' + amazon.aws.iam_group: + name: "{{ test_group }}" state: present - purge_policies: no + purge_policies: false managed_policy: - - '{{ safe_managed_policy }}' - check_mode: yes + - "{{ safe_managed_policy }}" + check_mode: true register: iam_group -- assert: +- ansible.builtin.assert: that: - iam_group is changed - name: Add Managed Policy - iam_group: - name: '{{ test_group }}' + amazon.aws.iam_group: + name: "{{ test_group }}" state: present - purge_policies: no + purge_policies: false managed_policy: - - '{{ safe_managed_policy }}' + - "{{ safe_managed_policy }}" register: iam_group -- assert: +- ansible.builtin.assert: that: - iam_group is changed - iam_group.iam_group.group.group_name == test_group @@ -27,27 +28,27 @@ - iam_group.iam_group.attached_policies[0].policy_name == safe_managed_policy - name: Add Managed Policy (no change) - check mode - iam_group: - name: '{{ test_group }}' + amazon.aws.iam_group: + name: "{{ test_group }}" state: present - purge_policies: no + purge_policies: false managed_policy: - - '{{ safe_managed_policy }}' + - "{{ safe_managed_policy }}" register: iam_group - check_mode: yes -- assert: + check_mode: true +- ansible.builtin.assert: that: - iam_group is not changed - name: Add Managed Policy (no change) - iam_group: - name: '{{ test_group }}' + amazon.aws.iam_group: + name: "{{ test_group }}" state: present - purge_policies: no + purge_policies: false managed_policy: - - '{{ safe_managed_policy }}' + - "{{ safe_managed_policy }}" register: iam_group -- assert: +- ansible.builtin.assert: that: - iam_group is not changed - iam_group.iam_group.group.group_name == test_group @@ -57,27 +58,27 @@ # ------------------------------------------------------------------------------------------ - name: Update Managed Policy without purge (CHECK MODE) - iam_group: - name: '{{ test_group }}' + amazon.aws.iam_group: + name: "{{ test_group }}" state: present - purge_policies: no + purge_policies: false managed_policy: - - '{{ custom_policy_name }}' - check_mode: yes + - "{{ custom_policy_name }}" + check_mode: true register: iam_group -- assert: +- ansible.builtin.assert: that: - iam_group is changed - name: Update Managed Policy without purge - iam_group: - name: '{{ test_group }}' + amazon.aws.iam_group: + name: "{{ test_group }}" state: present - purge_policies: no + purge_policies: false managed_policy: - - '{{ custom_policy_name }}' + - "{{ custom_policy_name }}" register: iam_group -- assert: +- ansible.builtin.assert: that: - iam_group is changed - iam_group.iam_group.group.group_name == test_group @@ -88,27 +89,27 @@ attached_policy_names: "{{ iam_group.iam_group.attached_policies | map(attribute='policy_name') }}" - name: Update Managed Policy without purge (no change) - check mode - iam_group: - name: '{{ test_group }}' + amazon.aws.iam_group: + name: "{{ test_group }}" state: present - purge_policies: no + purge_policies: false managed_policy: - - '{{ custom_policy_name }}' + - "{{ custom_policy_name }}" register: iam_group - check_mode: yes -- assert: + check_mode: true +- ansible.builtin.assert: that: - iam_group is not changed - name: Update Managed Policy without purge (no change) - iam_group: - name: '{{ test_group }}' + amazon.aws.iam_group: + name: "{{ test_group }}" state: present - purge_policies: no + purge_policies: false managed_policy: - - '{{ custom_policy_name }}' + - "{{ custom_policy_name }}" register: iam_group -- assert: +- ansible.builtin.assert: that: - iam_group is not changed - iam_group.iam_group.group.group_name == test_group @@ -121,27 +122,27 @@ # ------------------------------------------------------------------------------------------ - name: Update Managed Policy with purge (CHECK MODE) - iam_group: - name: '{{ test_group }}' + amazon.aws.iam_group: + name: "{{ test_group }}" state: present managed_policy: - - '{{ custom_policy_name }}' - purge_policies: yes - check_mode: yes + - "{{ custom_policy_name }}" + purge_policies: true + check_mode: true register: iam_group -- assert: +- ansible.builtin.assert: that: - iam_group is changed - name: Update Managed Policy with purge - iam_group: - name: '{{ test_group }}' + amazon.aws.iam_group: + name: "{{ test_group }}" state: present managed_policy: - - '{{ custom_policy_name }}' - purge_policies: yes + - "{{ custom_policy_name }}" + purge_policies: true register: iam_group -- assert: +- ansible.builtin.assert: that: - iam_group is changed - iam_group.iam_group.group.group_name == test_group @@ -152,27 +153,27 @@ attached_policy_names: "{{ iam_group.iam_group.attached_policies | map(attribute='policy_name') }}" - name: Update Managed Policy with purge (no change) - check mode - iam_group: - name: '{{ test_group }}' + amazon.aws.iam_group: + name: "{{ test_group }}" state: present managed_policy: - - '{{ custom_policy_name }}' - purge_policies: yes + - "{{ custom_policy_name }}" + purge_policies: true register: iam_group - check_mode: yes -- assert: + check_mode: true +- ansible.builtin.assert: that: - iam_group is not changed - name: Update Managed Policy with purge (no change) - iam_group: - name: '{{ test_group }}' + amazon.aws.iam_group: + name: "{{ test_group }}" state: present managed_policy: - - '{{ custom_policy_name }}' - purge_policies: yes + - "{{ custom_policy_name }}" + purge_policies: true register: iam_group -- assert: +- ansible.builtin.assert: that: - iam_group is not changed - iam_group.iam_group.group.group_name == test_group diff --git a/tests/integration/targets/iam_group/tasks/users.yml b/tests/integration/targets/iam_group/tasks/users.yml index 461c522ec20..9755198c116 100644 --- a/tests/integration/targets/iam_group/tasks/users.yml +++ b/tests/integration/targets/iam_group/tasks/users.yml @@ -1,57 +1,57 @@ --- -- name: add non existent user to group - iam_group: - name: '{{ test_group }}' +- name: Add non existent user to group + amazon.aws.iam_group: + name: "{{ test_group }}" users: - - '{{ test_user }}' + - "{{ test_user }}" - NonExistentUser state: present - ignore_errors: yes + ignore_errors: true register: iam_group -- name: assert that adding non existent user to group fails with helpful message - assert: +- name: Assert that adding non existent user to group fails with helpful message + ansible.builtin.assert: that: - iam_group is failed - - iam_group.msg.startswith("Couldn't add user NonExistentUser to group {{ test_group }}") + - iam_group.msg.startswith("Couldn't add user NonExistentUser to group " + test_group) -- name: remove a user - iam_group: - name: '{{ test_group }}' - purge_users: True +- name: Remove a user + amazon.aws.iam_group: + name: "{{ test_group }}" + purge_users: true users: [] state: present register: iam_group -- assert: +- ansible.builtin.assert: that: - iam_group is changed - '"users" in iam_group.iam_group' - iam_group.iam_group.users | length == 0 -- name: re-remove a user (no change) - iam_group: - name: '{{ test_group }}' - purge_users: True +- name: Re-remove a user (no change) + amazon.aws.iam_group: + name: "{{ test_group }}" + purge_users: true users: [] state: present register: iam_group -- assert: +- ansible.builtin.assert: that: - iam_group is not changed - '"users" in iam_group.iam_group' - iam_group.iam_group.users | length == 0 - name: Add the user again - iam_group: - name: '{{ test_group }}' + amazon.aws.iam_group: + name: "{{ test_group }}" users: - - '{{ test_user }}' + - "{{ test_user }}" state: present register: iam_group -- assert: +- ansible.builtin.assert: that: - iam_group is changed - '"users" in iam_group.iam_group' @@ -59,14 +59,14 @@ - iam_group.iam_group.users[0].user_name == test_user - name: Re-add the user - iam_group: - name: '{{ test_group }}' + amazon.aws.iam_group: + name: "{{ test_group }}" users: - - '{{ test_user }}' + - "{{ test_user }}" state: present register: iam_group -- assert: +- ansible.builtin.assert: that: - iam_group is not changed - '"users" in iam_group.iam_group'