diff --git a/tests/integration/requirements.txt b/tests/integration/requirements.txt index a8fb1eab213..b20ec357dbe 100644 --- a/tests/integration/requirements.txt +++ b/tests/integration/requirements.txt @@ -9,3 +9,5 @@ virtualenv awscli # Used for comparing SSH Public keys to the Amazon fingerprints cryptography +# Used for recordings +placebo diff --git a/tests/integration/targets/autoscaling_group/main.yml b/tests/integration/targets/autoscaling_group/main.yml index 709499c4470..25f79ccefb2 100644 --- a/tests/integration/targets/autoscaling_group/main.yml +++ b/tests/integration/targets/autoscaling_group/main.yml @@ -3,7 +3,8 @@ # To add new tests you'll need to add a new host to the inventory and a matching # '{{ inventory_hostname }}'.yml file in roles/ec2_asg/tasks/ # Prepare the VPC and figure out which AMI to use -- hosts: all +- name: Prepare VPC for ASG tests + hosts: all gather_facts: false tasks: - module_defaults: @@ -26,7 +27,8 @@ - ansible.builtin.fail: msg: Environment preparation failed run_once: true -- hosts: all +- name: Run Auto Scaling Group tests (in parallel) + hosts: all gather_facts: false strategy: free serial: 6 diff --git a/tests/integration/targets/autoscaling_group/roles/ec2_asg/defaults/main.yml b/tests/integration/targets/autoscaling_group/roles/ec2_asg/defaults/main.yml index d3a7707d8b8..553e143c41e 100644 --- a/tests/integration/targets/autoscaling_group/roles/ec2_asg/defaults/main.yml +++ b/tests/integration/targets/autoscaling_group/roles/ec2_asg/defaults/main.yml @@ -1,3 +1,3 @@ --- -load_balancer_name: "{{ tiny_prefix }}-lb" +ec2_asg_load_balancer_name: "{{ tiny_prefix }}-lb" ec2_asg_setup_run_once: true diff --git a/tests/integration/targets/autoscaling_group/roles/ec2_asg/tasks/create_update_delete.yml b/tests/integration/targets/autoscaling_group/roles/ec2_asg/tasks/create_update_delete.yml index 61ada471835..f2282796827 100644 --- a/tests/integration/targets/autoscaling_group/roles/ec2_asg/tasks/create_update_delete.yml +++ b/tests/integration/targets/autoscaling_group/roles/ec2_asg/tasks/create_update_delete.yml @@ -5,19 +5,19 @@ block: # ============================================================ - - name: test without specifying required module options + - name: Test without specifying required module options amazon.aws.autoscaling_group: access_key: "{{ aws_access_key }}" secret_key: "{{ aws_secret_key }}" session_token: "{{ security_token | default(omit) }}" ignore_errors: true register: result - - name: assert name is a required module option + - name: Assert name is a required module option ansible.builtin.assert: that: - "result.msg == 'missing required arguments: name'" - - name: ensure launch configs exist + - name: Ensure launch configs exist community.aws.autoscaling_launch_config: name: "{{ item }}" assign_public_ip: true @@ -38,7 +38,7 @@ # ============================================================ - - name: launch asg and wait for instances to be deemed healthy (no ELB) + - name: Launch asg and wait for instances to be deemed healthy (no ELB) amazon.aws.autoscaling_group: name: "{{ resource_prefix }}-asg" launch_config_name: "{{ resource_prefix }}-lc" @@ -113,13 +113,13 @@ that: - output is not changed - - name: kill asg + - name: Kill asg amazon.aws.autoscaling_group: name: "{{ resource_prefix }}-asg" state: absent wait_timeout: 800 async: 400 - - name: launch asg and do not wait for instances to be deemed healthy (no ELB) + - name: Launch asg and do not wait for instances to be deemed healthy (no ELB) amazon.aws.autoscaling_group: name: "{{ resource_prefix }}-asg" launch_config_name: "{{ resource_prefix }}-lc" @@ -134,7 +134,7 @@ that: - output.viable_instances == 0 - - name: kill asg + - name: Kill asg amazon.aws.autoscaling_group: name: "{{ resource_prefix }}-asg" state: absent @@ -144,7 +144,7 @@ until: output is succeeded delay: 10 async: 400 - - name: create asg with asg metrics enabled + - name: Create asg with asg metrics enabled amazon.aws.autoscaling_group: name: "{{ resource_prefix }}-asg" metrics_collection: true @@ -159,15 +159,15 @@ that: - "'Group' in output.metrics_collection.0.Metric" - - name: kill asg + - name: Kill asg amazon.aws.autoscaling_group: name: "{{ resource_prefix }}-asg" state: absent wait_timeout: 800 async: 400 - - name: launch load balancer + - name: Launch load balancer amazon.aws.elb_classic_lb: - name: "{{ load_balancer_name }}" + name: "{{ ec2_asg_load_balancer_name }}" state: present security_group_ids: - "{{ sg.group_id }}" @@ -186,7 +186,7 @@ unhealthy_threshold: 4 healthy_threshold: 2 register: load_balancer - - name: launch asg and wait for instances to be deemed healthy (ELB) + - name: Launch asg and wait for instances to be deemed healthy (ELB) amazon.aws.autoscaling_group: name: "{{ resource_prefix }}-asg" launch_config_name: "{{ resource_prefix }}-lc" @@ -196,7 +196,7 @@ max_size: 1 health_check_period: 300 vpc_zone_identifier: "{{ testing_subnet.subnet.id }}" - load_balancers: "{{ load_balancer_name }}" + load_balancers: "{{ ec2_asg_load_balancer_name }}" wait_for_instances: true wait_timeout: 900 state: present @@ -208,7 +208,7 @@ # ============================================================ # grow scaling group to 3 - - name: add 2 more instances wait for instances to be deemed healthy (ELB) + - name: Add 2 more instances wait for instances to be deemed healthy (ELB) amazon.aws.autoscaling_group: name: "{{ resource_prefix }}-asg" launch_config_name: "{{ resource_prefix }}-lc" @@ -218,7 +218,7 @@ max_size: 5 health_check_period: 600 vpc_zone_identifier: "{{ testing_subnet.subnet.id }}" - load_balancers: "{{ load_balancer_name }}" + load_balancers: "{{ ec2_asg_load_balancer_name }}" wait_for_instances: true wait_timeout: 1200 state: present @@ -230,32 +230,32 @@ # ============================================================ # Test max_instance_lifetime option - - name: enable asg max_instance_lifetime + - name: Enable asg max_instance_lifetime amazon.aws.autoscaling_group: name: "{{ resource_prefix }}-asg" max_instance_lifetime: 604801 register: output - - name: ensure max_instance_lifetime is set + - name: Ensure max_instance_lifetime is set ansible.builtin.assert: that: - output.max_instance_lifetime == 604801 - - name: run without max_instance_lifetime + - name: Run without max_instance_lifetime amazon.aws.autoscaling_group: name: "{{ resource_prefix }}-asg" launch_config_name: "{{ resource_prefix }}-lc" - - name: ensure max_instance_lifetime not affected by defaults + - name: Ensure max_instance_lifetime not affected by defaults ansible.builtin.assert: that: - output.max_instance_lifetime == 604801 - - name: disable asg max_instance_lifetime + - name: Disable asg max_instance_lifetime amazon.aws.autoscaling_group: name: "{{ resource_prefix }}-asg" launch_config_name: "{{ resource_prefix }}-lc" max_instance_lifetime: 0 register: output - - name: ensure max_instance_lifetime is not set + - name: Ensure max_instance_lifetime is not set ansible.builtin.assert: that: - not output.max_instance_lifetime @@ -263,7 +263,7 @@ # ============================================================ # perform rolling replace with different launch configuration - - name: perform rolling update to new AMI + - name: Perform rolling update to new AMI amazon.aws.autoscaling_group: name: "{{ resource_prefix }}-asg" launch_config_name: "{{ resource_prefix }}-lc-2" @@ -272,7 +272,7 @@ min_size: 1 max_size: 5 health_check_period: 900 - load_balancers: "{{ load_balancer_name }}" + load_balancers: "{{ ec2_asg_load_balancer_name }}" vpc_zone_identifier: "{{ testing_subnet.subnet.id }}" wait_for_instances: true replace_all_instances: true @@ -290,7 +290,7 @@ # ============================================================ # perform rolling replace with the original launch configuration - - name: perform rolling update to new AMI while removing the load balancer + - name: Perform rolling update to new AMI while removing the load balancer amazon.aws.autoscaling_group: name: "{{ resource_prefix }}-asg" launch_config_name: "{{ resource_prefix }}-lc" @@ -317,7 +317,7 @@ # ============================================================ # perform rolling replace with new launch configuration and lc_check:false - - name: "perform rolling update to new AMI with lc_check: false" + - name: "Perform rolling update to new AMI with lc_check: false" amazon.aws.autoscaling_group: name: "{{ resource_prefix }}-asg" launch_config_name: "{{ resource_prefix }}-lc-2" @@ -334,7 +334,7 @@ lc_check: false wait_timeout: 1800 state: present - - name: get autoscaling_group info + - name: Get autoscaling_group info amazon.aws.autoscaling_group_info: name: "{{ resource_prefix }}-asg" register: output @@ -344,13 +344,13 @@ # ============================================================ - - name: kill asg + - name: Kill asg amazon.aws.autoscaling_group: name: "{{ resource_prefix }}-asg" state: absent wait_timeout: 800 async: 400 - - name: "new asg with lc_check: false" + - name: "New asg with lc_check: false" amazon.aws.autoscaling_group: name: "{{ resource_prefix }}-asg" launch_config_name: "{{ resource_prefix }}-lc" @@ -367,7 +367,7 @@ lc_check: false wait_timeout: 1800 state: present - - name: get autoscaling_group information + - name: Get autoscaling_group information amazon.aws.autoscaling_group_info: name: "{{ resource_prefix }}-asg" register: output @@ -376,7 +376,7 @@ - output.results[0].instances | length == 3 # we need a launch template, otherwise we cannot test the mixed instance policy - - name: create launch template for autoscaling group to test its mixed instances policy + - name: Create launch template for autoscaling group to test its mixed instances policy amazon.aws.ec2_launch_template: template_name: "{{ resource_prefix }}-lt" image_id: "{{ ec2_ami_id }}" @@ -390,7 +390,7 @@ groups: - "{{ sg.group_id }}" - - name: update autoscaling group with mixed-instances policy with mixed instances types - check_mode + - name: Update autoscaling group with mixed-instances policy with mixed instances types - check_mode amazon.aws.autoscaling_group: name: "{{ resource_prefix }}-asg" launch_template: @@ -413,7 +413,7 @@ - output is not failed - '"autoscaling:CreateOrUpdateTags" not in output.resource_actions' - - name: update autoscaling group with mixed-instances policy with mixed instances types + - name: Update autoscaling group with mixed-instances policy with mixed instances types amazon.aws.autoscaling_group: name: "{{ resource_prefix }}-asg" launch_template: @@ -435,7 +435,7 @@ - output.mixed_instances_policy[0] == 't3.micro' - output.mixed_instances_policy[1] == 't2.nano' - - name: update autoscaling group with mixed-instances policy with instances_distribution + - name: Update autoscaling group with mixed-instances policy with instances_distribution amazon.aws.autoscaling_group: name: "{{ resource_prefix }}-asg" launch_template: @@ -465,9 +465,9 @@ # Target group names have max length of 32 characters - ansible.builtin.set_fact: - tg1_name: ansible-test-{{tiny_prefix}}-asg-t1 - tg2_name: ansible-test-{{tiny_prefix}}-asg-t2 - - name: create target group 1 + tg1_name: ansible-test-{{ tiny_prefix }}-asg-t1 + tg2_name: ansible-test-{{ tiny_prefix }}-asg-t2 + - name: Create target group 1 community.aws.elb_target_group: name: "{{ tg1_name }}" protocol: tcp @@ -479,7 +479,7 @@ vpc_id: "{{ testing_vpc.vpc.id }}" state: present register: out_tg1 - - name: create target group 2 + - name: Create target group 2 community.aws.elb_target_group: name: "{{ tg2_name }}" protocol: tcp @@ -491,7 +491,7 @@ vpc_id: "{{ testing_vpc.vpc.id }}" state: present register: out_tg2 - - name: update autoscaling group with tg1 + - name: Update autoscaling group with tg1 amazon.aws.autoscaling_group: name: "{{ resource_prefix }}-asg" launch_template: @@ -508,7 +508,7 @@ that: - output.target_group_arns[0] == out_tg1.target_group_arn - - name: update autoscaling group add tg2 + - name: Update autoscaling group add tg2 amazon.aws.autoscaling_group: name: "{{ resource_prefix }}-asg" launch_template: @@ -526,7 +526,7 @@ that: - output.target_group_arns | length == 2 - - name: update autoscaling group remove tg1 + - name: Update autoscaling group remove tg1 amazon.aws.autoscaling_group: name: "{{ resource_prefix }}-asg" launch_template: @@ -544,7 +544,7 @@ - output.target_group_arns | length == 1 - output.target_group_arns[0] == out_tg2.target_group_arn - - name: update autoscaling group remove tg2 and add tg1 + - name: Update autoscaling group remove tg2 and add tg1 amazon.aws.autoscaling_group: name: "{{ resource_prefix }}-asg" launch_template: @@ -562,7 +562,7 @@ - output.target_group_arns | length == 1 - output.target_group_arns[0] == out_tg1.target_group_arn - - name: target group no change + - name: Target group no change amazon.aws.autoscaling_group: name: "{{ resource_prefix }}-asg" launch_template: diff --git a/tests/integration/targets/autoscaling_group/roles/ec2_asg/tasks/env_cleanup.yml b/tests/integration/targets/autoscaling_group/roles/ec2_asg/tasks/env_cleanup.yml index 3072c508136..77222bb3b09 100644 --- a/tests/integration/targets/autoscaling_group/roles/ec2_asg/tasks/env_cleanup.yml +++ b/tests/integration/targets/autoscaling_group/roles/ec2_asg/tasks/env_cleanup.yml @@ -1,5 +1,5 @@ --- -- name: kill asg +- name: Kill asg amazon.aws.autoscaling_group: name: "{{ resource_prefix }}-asg" state: absent @@ -7,7 +7,7 @@ until: removed is not failed ignore_errors: true retries: 10 -- name: remove target group +- name: Remove target group community.aws.elb_target_group: name: "{{ item }}" state: absent @@ -19,9 +19,9 @@ - "{{ tg1_name }}" - "{{ tg2_name }}" -- name: remove the load balancer +- name: Remove the load balancer amazon.aws.elb_classic_lb: - name: "{{ load_balancer_name }}" + name: "{{ ec2_asg_load_balancer_name }}" state: absent security_group_ids: - "{{ sg.group_id }}" @@ -44,7 +44,7 @@ until: removed is not failed ignore_errors: true retries: 10 -- name: remove launch configs +- name: Remove launch configs community.aws.autoscaling_launch_config: name: "{{ item }}" state: absent @@ -56,7 +56,7 @@ - "{{ resource_prefix }}-lc" - "{{ resource_prefix }}-lc-2" -- name: delete launch template +- name: Delete launch template amazon.aws.ec2_launch_template: name: "{{ resource_prefix }}-lt" state: absent @@ -64,7 +64,7 @@ retries: 10 until: del_lt is not failed ignore_errors: true -- name: remove the security group +- name: Remove the security group amazon.aws.ec2_security_group: name: "{{ resource_prefix }}-sg" description: a security group for ansible tests @@ -74,7 +74,7 @@ until: removed is not failed ignore_errors: true retries: 10 -- name: remove routing rules +- name: Remove routing rules amazon.aws.ec2_vpc_route_table: state: absent vpc_id: "{{ testing_vpc.vpc.id }}" @@ -89,7 +89,7 @@ until: removed is not failed ignore_errors: true retries: 10 -- name: remove internet gateway +- name: Remove internet gateway amazon.aws.ec2_vpc_igw: vpc_id: "{{ testing_vpc.vpc.id }}" state: absent @@ -97,7 +97,7 @@ until: removed is not failed ignore_errors: true retries: 10 -- name: remove the subnet +- name: Remove the subnet amazon.aws.ec2_vpc_subnet: state: absent vpc_id: "{{ testing_vpc.vpc.id }}" @@ -106,7 +106,7 @@ until: removed is not failed ignore_errors: true retries: 10 -- name: remove the VPC +- name: Remove the VPC amazon.aws.ec2_vpc_net: name: "{{ resource_prefix }}-vpc" cidr_block: 10.55.77.0/24 diff --git a/tests/integration/targets/autoscaling_group/roles/ec2_asg/tasks/env_setup.yml b/tests/integration/targets/autoscaling_group/roles/ec2_asg/tasks/env_setup.yml index 8584423e5f2..2776dec3061 100644 --- a/tests/integration/targets/autoscaling_group/roles/ec2_asg/tasks/env_setup.yml +++ b/tests/integration/targets/autoscaling_group/roles/ec2_asg/tasks/env_setup.yml @@ -23,7 +23,7 @@ resource_tags: Name: "{{ resource_prefix }}-subnet" register: testing_subnet - - name: create routing rules + - name: Create routing rules amazon.aws.ec2_vpc_route_table: vpc_id: "{{ testing_vpc.vpc.id }}" tags: @@ -34,7 +34,7 @@ subnets: - "{{ testing_subnet.subnet.id }}" - - name: create a security group with the vpc created in the ec2_setup + - name: Create a security group with the vpc created in the ec2_setup amazon.aws.ec2_security_group: name: "{{ resource_prefix }}-sg" description: a security group for ansible tests 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 bc8b22910b4..23ba96a75f7 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 @@ -1,8 +1,8 @@ --- - name: Running instance detach tests block: - #---------------------------------------------------------------------- - - name: create a launch configuration + # ---------------------------------------------------------------------- + - name: Create a launch configuration community.aws.autoscaling_launch_config: name: "{{ resource_prefix }}-lc-detach-test" image_id: "{{ ec2_ami_id }}" @@ -10,16 +10,16 @@ instance_type: t2.micro assign_public_ip: true register: create_lc - - name: ensure that lc is created + - name: Ensure that lc is created ansible.builtin.assert: that: - create_lc is changed - create_lc.failed is false - '"autoscaling:CreateLaunchConfiguration" in create_lc.resource_actions' - #---------------------------------------------------------------------- + # ---------------------------------------------------------------------- - - name: create a AutoScalingGroup to be used for instance_detach test - check_mode + - name: Create a AutoScalingGroup to be used for instance_detach test - check_mode amazon.aws.autoscaling_group: name: "{{ resource_prefix }}-asg-detach-test" launch_config_name: "{{ resource_prefix }}-lc-detach-test" @@ -38,7 +38,7 @@ - create_asg is not failed - '"autoscaling:CreateAutoScalingGroup" not in create_asg.resource_actions' - - name: create a AutoScalingGroup to be used for instance_detach test + - name: Create a AutoScalingGroup to be used for instance_detach test amazon.aws.autoscaling_group: name: "{{ resource_prefix }}-asg-detach-test" launch_config_name: "{{ resource_prefix }}-lc-detach-test" @@ -50,7 +50,7 @@ desired_capacity: 3 region: "{{ aws_region }}" register: create_asg - - name: ensure that AutoScalingGroup is created + - name: Ensure that AutoScalingGroup is created ansible.builtin.assert: that: - create_asg is changed @@ -60,7 +60,7 @@ - create_asg.in_service_instances == 3 - '"autoscaling:CreateAutoScalingGroup" in create_asg.resource_actions' - - name: gather info about asg, get instance ids + - name: Gather info about asg, get instance ids amazon.aws.autoscaling_group_info: name: "{{ resource_prefix }}-asg-detach-test" register: asg_info @@ -82,9 +82,9 @@ - instances_info.instances[1].state.name == "running" - instances_info.instances[2].state.name == "running" - #---------------------------------------------------------------------- + # ---------------------------------------------------------------------- - - name: detach 2 instance from the asg and replace with other instances - check_mode + - name: Detach 2 instance from the asg and replace with other instances - check_mode amazon.aws.autoscaling_group: name: "{{ resource_prefix }}-asg-detach-test" launch_config_name: "{{ resource_prefix }}-lc-detach-test" @@ -105,7 +105,7 @@ - detach_result is not failed - '"autoscaling:DetachInstances" not in detach_result.resource_actions' - - name: detach 2 instance from the asg and replace with other instances + - name: Detach 2 instance from the asg and replace with other instances amazon.aws.autoscaling_group: name: "{{ resource_prefix }}-asg-detach-test" launch_config_name: "{{ resource_prefix }}-lc-detach-test" @@ -147,10 +147,10 @@ - detached_instances_info.instances[0].state.name == 'running' - detached_instances_info.instances[1].state.name == 'running' - #---------------------------------------------------------------------- + # ---------------------------------------------------------------------- # detach 2 instances from the asg and reduce the desired capacity from 3 to 1 - - name: detach 2 instance from the asg and reduce the desired capacity from 3 to 1 + - name: Detach 2 instance from the asg and reduce the desired capacity from 3 to 1 amazon.aws.autoscaling_group: name: "{{ resource_prefix }}-asg-detach-test" launch_config_name: "{{ resource_prefix }}-lc-detach-test" @@ -191,10 +191,10 @@ - detached_instances_info.instances[1].state.name == 'running' - instance_replace_3 == instance_detach_decrement - #---------------------------------------------------------------------- + # ---------------------------------------------------------------------- always: - - name: terminate any instances created during this test + - name: Terminate any instances created during this test amazon.aws.ec2_instance: instance_ids: - "{{ item }}" @@ -207,7 +207,7 @@ - "{{ instance_replace_2 }}" - "{{ instance_replace_3 }}" - - name: kill asg created in this test - check_mode + - name: Kill asg created in this test - check_mode amazon.aws.autoscaling_group: name: "{{ resource_prefix }}-asg-detach-test" state: absent @@ -219,7 +219,7 @@ - removed is not failed - '"autoscaling:DeleteAutoScalingGroup" not in removed.resource_actions' - - name: kill asg created in this test + - name: Kill asg created in this test amazon.aws.autoscaling_group: name: "{{ resource_prefix }}-asg-detach-test" state: absent @@ -227,7 +227,7 @@ until: removed is not failed ignore_errors: true retries: 10 - - name: kill asg created in this test - check_mode (idempotent) + - name: Kill asg created in this test - check_mode (idempotent) amazon.aws.autoscaling_group: name: "{{ resource_prefix }}-asg-detach-test" state: absent @@ -239,7 +239,7 @@ - removed is not failed - '"autoscaling:DeleteAutoScalingGroup" not in removed.resource_actions' - - name: remove launch config created in this test + - name: Remove launch config created in this test community.aws.autoscaling_launch_config: name: "{{ resource_prefix }}-lc-detach-test" state: absent diff --git a/tests/integration/targets/autoscaling_group/roles/ec2_asg/tasks/main.yml b/tests/integration/targets/autoscaling_group/roles/ec2_asg/tasks/main.yml index ba7482ba0f7..45f37924951 100644 --- a/tests/integration/targets/autoscaling_group/roles/ec2_asg/tasks/main.yml +++ b/tests/integration/targets/autoscaling_group/roles/ec2_asg/tasks/main.yml @@ -23,10 +23,10 @@ when: (lookup('env', 'HOME')) - ansible.builtin.debug: - msg: "{{ inventory_hostname }} start: {{ lookup('pipe','date') }}" + msg: "{{ inventory_hostname }} start: {{ lookup('pipe', 'date') }}" - ansible.builtin.include_tasks: "{{ inventory_hostname }}.yml" - ansible.builtin.debug: - msg: "{{ inventory_hostname }} finish: {{ lookup('pipe','date') }}" + msg: "{{ inventory_hostname }} finish: {{ lookup('pipe', 'date') }}" always: - ansible.builtin.set_fact: _role_complete: true diff --git a/tests/integration/targets/autoscaling_group/roles/ec2_asg/tasks/tag_operations.yml b/tests/integration/targets/autoscaling_group/roles/ec2_asg/tasks/tag_operations.yml index 51c69e67712..6752015813b 100644 --- a/tests/integration/targets/autoscaling_group/roles/ec2_asg/tasks/tag_operations.yml +++ b/tests/integration/targets/autoscaling_group/roles/ec2_asg/tasks/tag_operations.yml @@ -1,8 +1,8 @@ --- - name: Running AutoScalingGroup Tag operations test block: - #---------------------------------------------------------------------- - - name: create a launch configuration + # ---------------------------------------------------------------------- + - name: Create a launch configuration community.aws.autoscaling_launch_config: name: "{{ resource_prefix }}-lc-tag-test" image_id: "{{ ec2_ami_id }}" @@ -10,15 +10,15 @@ instance_type: t2.micro assign_public_ip: true register: create_lc - - name: ensure that lc is created + - name: Ensure that lc is created ansible.builtin.assert: that: - create_lc is changed - create_lc.failed is false - '"autoscaling:CreateLaunchConfiguration" in create_lc.resource_actions' - #---------------------------------------------------------------------- - - name: create a AutoScalingGroup to be used for tag_operations test + # ---------------------------------------------------------------------- + - name: Create a AutoScalingGroup to be used for tag_operations test amazon.aws.autoscaling_group: name: "{{ resource_prefix }}-asg-tag-test" launch_config_name: "{{ resource_prefix }}-lc-tag-test" @@ -30,14 +30,14 @@ desired_capacity: 1 region: "{{ aws_region }}" register: create_asg - - name: ensure that AutoScalingGroup is created + - name: Ensure that AutoScalingGroup is created ansible.builtin.assert: that: - create_asg is changed - create_asg.failed is false - '"autoscaling:CreateAutoScalingGroup" in create_asg.resource_actions' - #---------------------------------------------------------------------- + # ---------------------------------------------------------------------- - name: Get asg info amazon.aws.autoscaling_group_info: @@ -316,10 +316,10 @@ - '"autoscaling:CreateOrUpdateTags" not in add_empty.resource_actions' - '"autoscaling:DeleteTags" in add_empty.resource_actions' - #---------------------------------------------------------------------- + # ---------------------------------------------------------------------- always: - - name: kill asg created in this test + - name: Kill asg created in this test amazon.aws.autoscaling_group: name: "{{ resource_prefix }}-asg-tag-test" state: absent @@ -327,7 +327,7 @@ until: removed is not failed ignore_errors: true retries: 10 - - name: remove launch config created in this test + - name: Remove launch config created in this test community.aws.autoscaling_launch_config: name: "{{ resource_prefix }}-lc-tag-test" state: absent diff --git a/tests/integration/targets/autoscaling_instance/tasks/attach_detach.yml b/tests/integration/targets/autoscaling_instance/tasks/attach_detach.yml index 74de7b9cc94..31428bb2ef8 100644 --- a/tests/integration/targets/autoscaling_instance/tasks/attach_detach.yml +++ b/tests/integration/targets/autoscaling_instance/tasks/attach_detach.yml @@ -4,15 +4,15 @@ # All current instances passed, no purge requested # - no change should happen -- name: instance_ids - idempotency/all - no purge - check_mode +- name: Instance_ids - idempotency/all - no purge - check_mode amazon.aws.autoscaling_instance: instance_ids: "{{ initial_instances }}" group_name: "{{ default_resource_name }}" state: present - purge_instances: False - diff: True + purge_instances: false + diff: true register: present_no_change - check_mode: True + check_mode: true - ansible.builtin.assert: that: @@ -39,13 +39,13 @@ listed_instance_ids: "{{ present_no_change.auto_scaling_instances | map(attribute='instance_id') | list }}" specific_instance_info: "{{ present_no_change.auto_scaling_instances[0] }}" -- name: instance_ids - idempotency/all - no purge +- name: Instance_ids - idempotency/all - no purge amazon.aws.autoscaling_instance: instance_ids: "{{ initial_instances }}" group_name: "{{ default_resource_name }}" state: present - purge_instances: False - diff: True + purge_instances: false + diff: true register: present_no_change - ansible.builtin.assert: @@ -75,15 +75,15 @@ # One of the current instances passed, no purge requested # - no change should happen -- name: instance_ids - idempotency/partial - no purge - check_mode +- name: Instance_ids - idempotency/partial - no purge - check_mode amazon.aws.autoscaling_instance: instance_ids: "{{ initial_instances[0] }}" group_name: "{{ default_resource_name }}" state: present - purge_instances: False - diff: True + purge_instances: false + diff: true register: present_no_change - check_mode: True + check_mode: true - ansible.builtin.assert: that: @@ -110,13 +110,13 @@ listed_instance_ids: "{{ present_no_change.auto_scaling_instances | map(attribute='instance_id') | list }}" specific_instance_info: "{{ present_no_change.auto_scaling_instances[0] }}" -- name: instance_ids - idempotency/partial - no purge +- name: Instance_ids - idempotency/partial - no purge amazon.aws.autoscaling_instance: instance_ids: "{{ initial_instances[0] }}" group_name: "{{ default_resource_name }}" state: present - purge_instances: False - diff: True + purge_instances: false + diff: true register: present_no_change - ansible.builtin.assert: @@ -146,15 +146,15 @@ # All current instances passed, purge requested # - no change should happen as there are no instances that are attached but not requested -- name: instance_ids - idempotency/all - purge - check_mode +- name: Instance_ids - idempotency/all - purge - check_mode amazon.aws.autoscaling_instance: instance_ids: "{{ initial_instances }}" group_name: "{{ default_resource_name }}" - purge_instances: True + purge_instances: true state: present - diff: True + diff: true register: present_no_change - check_mode: True + check_mode: true - ansible.builtin.assert: that: @@ -183,15 +183,15 @@ ### instance_ids - attach/detach # Detach a specific instance -- name: instance_ids - single instance - detach - check_mode +- name: Instance_ids - single instance - detach - check_mode amazon.aws.autoscaling_instance: instance_ids: "{{ initial_instances[0] }}" group_name: "{{ default_resource_name }}" state: detached - decrement_desired_capacity: True - diff: True + decrement_desired_capacity: true + diff: true register: absent_one - check_mode: True + check_mode: true - ansible.builtin.assert: that: @@ -218,13 +218,13 @@ listed_instance_ids: "{{ absent_one.auto_scaling_instances | map(attribute='instance_id') | list }}" specific_instance_info: "{{ absent_one.auto_scaling_instances | selectattr('instance_id', 'equalto', initial_instances[1]) | first }}" -- name: instance_ids - single instance - detach +- name: Instance_ids - single instance - detach amazon.aws.autoscaling_instance: instance_ids: "{{ initial_instances[0] }}" group_name: "{{ default_resource_name }}" state: detached - decrement_desired_capacity: True - diff: True + decrement_desired_capacity: true + diff: true register: absent_one - ansible.builtin.assert: @@ -252,47 +252,47 @@ specific_instance_info: "{{ absent_one.auto_scaling_instances | selectattr('instance_id', 'equalto', initial_instances[1]) | first }}" # Ensure present state (not using standby - should be the same as attached) -- name: instance_ids - single instance - attach/present - check_mode +- name: Instance_ids - single instance - attach/present - check_mode amazon.aws.autoscaling_instance: instance_ids: "{{ initial_instances[0] }}" group_name: "{{ default_resource_name }}" state: present - diff: True + diff: true register: present_one - check_mode: True + check_mode: true -- name: instance_ids - single instance - attach/present +- name: Instance_ids - single instance - attach/present amazon.aws.autoscaling_instance: instance_ids: "{{ initial_instances[0] }}" group_name: "{{ default_resource_name }}" state: present - diff: True + diff: true register: present_one # Detach it again so we can reattach -- name: instance_ids - single instance - detach (again - prepare to attach) +- name: Instance_ids - single instance - detach (again - prepare to attach) amazon.aws.autoscaling_instance: instance_ids: "{{ initial_instances[0] }}" group_name: "{{ default_resource_name }}" state: detached - decrement_desired_capacity: True - diff: True + decrement_desired_capacity: true + diff: true register: detach_one # Ensure attached state (not using standby - should be the same as attached) -- name: instance_ids - single instance - attach/attach - check_mode +- name: Instance_ids - single instance - attach/attach - check_mode amazon.aws.autoscaling_instance: instance_ids: "{{ initial_instances[0] }}" group_name: "{{ default_resource_name }}" state: attached - diff: True + diff: true register: attached_one - check_mode: True + check_mode: true -- name: instance_ids - single instance - attach/attach +- name: Instance_ids - single instance - attach/attach amazon.aws.autoscaling_instance: instance_ids: "{{ initial_instances[0] }}" group_name: "{{ default_resource_name }}" state: attached - diff: True + diff: true register: attached_one diff --git a/tests/integration/targets/autoscaling_instance/tasks/describe.yml b/tests/integration/targets/autoscaling_instance/tasks/describe.yml index 0415290b4f0..0c4618dcdfe 100644 --- a/tests/integration/targets/autoscaling_instance/tasks/describe.yml +++ b/tests/integration/targets/autoscaling_instance/tasks/describe.yml @@ -7,25 +7,25 @@ - ansible.builtin.assert: that: - - "'auto_scaling_instances' in instance_info" - - instance_info.auto_scaling_instances | length >= 2 - - initial_instances[0] in listed_instance_ids - - initial_instances[1] in listed_instance_ids - - "'auto_scaling_group_name' in specific_instance_info" - - specific_instance_info.auto_scaling_group_name == default_resource_name - - "'availability_zone' in specific_instance_info" - - "'health_status' in specific_instance_info" - - specific_instance_info.health_status == "HEALTHY" - - "'instance_id' in specific_instance_info" - - specific_instance_info.instance_id == initial_instances[0] - - "'instance_type' in specific_instance_info" - - specific_instance_info.instance_type == "t3.micro" - - "'launch_template' in specific_instance_info" - - specific_instance_info.launch_template.launch_template_name.startswith(default_resource_name) - - "'lifecycle_state' in specific_instance_info" - - specific_instance_info.lifecycle_state == "InService" - - "'protected_from_scale_in' in specific_instance_info" - - specific_instance_info.protected_from_scale_in == False + - "'auto_scaling_instances' in instance_info" + - instance_info.auto_scaling_instances | length >= 2 + - initial_instances[0] in listed_instance_ids + - initial_instances[1] in listed_instance_ids + - "'auto_scaling_group_name' in specific_instance_info" + - specific_instance_info.auto_scaling_group_name == default_resource_name + - "'availability_zone' in specific_instance_info" + - "'health_status' in specific_instance_info" + - specific_instance_info.health_status == "HEALTHY" + - "'instance_id' in specific_instance_info" + - specific_instance_info.instance_id == initial_instances[0] + - "'instance_type' in specific_instance_info" + - specific_instance_info.instance_type == "t3.micro" + - "'launch_template' in specific_instance_info" + - specific_instance_info.launch_template.launch_template_name.startswith(default_resource_name) + - "'lifecycle_state' in specific_instance_info" + - specific_instance_info.lifecycle_state == "InService" + - "'protected_from_scale_in' in specific_instance_info" + - specific_instance_info.protected_from_scale_in == False vars: listed_instance_ids: "{{ instance_info.auto_scaling_instances | map(attribute='instance_id') | list }}" specific_instance_info: "{{ instance_info.auto_scaling_instances | selectattr('instance_id', 'equalto', initial_instances[0]) | first }}" @@ -37,33 +37,33 @@ - ansible.builtin.assert: that: - - "'auto_scaling_instances' in instance_info" - - instance_info.auto_scaling_instances | length == 2 - - initial_instances[0] in listed_instance_ids - - initial_instances[1] in listed_instance_ids - - "'auto_scaling_group_name' in instance_info.auto_scaling_instances[0]" - - "'availability_zone' in instance_info.auto_scaling_instances[0]" - - "'health_status' in instance_info.auto_scaling_instances[0]" - - "'instance_id' in instance_info.auto_scaling_instances[0]" - - "'instance_type' in instance_info.auto_scaling_instances[0]" - - "'launch_template' in instance_info.auto_scaling_instances[0]" - - "'lifecycle_state' in instance_info.auto_scaling_instances[0]" - - "'protected_from_scale_in' in instance_info.auto_scaling_instances[0]" - - "'auto_scaling_group_name' in instance_info.auto_scaling_instances[1]" - - "'availability_zone' in instance_info.auto_scaling_instances[1]" - - "'health_status' in instance_info.auto_scaling_instances[1]" - - "'instance_id' in instance_info.auto_scaling_instances[1]" - - "'instance_type' in instance_info.auto_scaling_instances[1]" - - "'launch_template' in instance_info.auto_scaling_instances[1]" - - "'lifecycle_state' in instance_info.auto_scaling_instances[1]" - - "'protected_from_scale_in' in instance_info.auto_scaling_instances[1]" - - specific_instance_info.auto_scaling_group_name == default_resource_name - - specific_instance_info.health_status == "HEALTHY" - - specific_instance_info.instance_id == initial_instances[0] - - specific_instance_info.instance_type == "t3.micro" - - specific_instance_info.launch_template.launch_template_name.startswith(default_resource_name) - - specific_instance_info.lifecycle_state == "InService" - - specific_instance_info.protected_from_scale_in == False + - "'auto_scaling_instances' in instance_info" + - instance_info.auto_scaling_instances | length == 2 + - initial_instances[0] in listed_instance_ids + - initial_instances[1] in listed_instance_ids + - "'auto_scaling_group_name' in instance_info.auto_scaling_instances[0]" + - "'availability_zone' in instance_info.auto_scaling_instances[0]" + - "'health_status' in instance_info.auto_scaling_instances[0]" + - "'instance_id' in instance_info.auto_scaling_instances[0]" + - "'instance_type' in instance_info.auto_scaling_instances[0]" + - "'launch_template' in instance_info.auto_scaling_instances[0]" + - "'lifecycle_state' in instance_info.auto_scaling_instances[0]" + - "'protected_from_scale_in' in instance_info.auto_scaling_instances[0]" + - "'auto_scaling_group_name' in instance_info.auto_scaling_instances[1]" + - "'availability_zone' in instance_info.auto_scaling_instances[1]" + - "'health_status' in instance_info.auto_scaling_instances[1]" + - "'instance_id' in instance_info.auto_scaling_instances[1]" + - "'instance_type' in instance_info.auto_scaling_instances[1]" + - "'launch_template' in instance_info.auto_scaling_instances[1]" + - "'lifecycle_state' in instance_info.auto_scaling_instances[1]" + - "'protected_from_scale_in' in instance_info.auto_scaling_instances[1]" + - specific_instance_info.auto_scaling_group_name == default_resource_name + - specific_instance_info.health_status == "HEALTHY" + - specific_instance_info.instance_id == initial_instances[0] + - specific_instance_info.instance_type == "t3.micro" + - specific_instance_info.launch_template.launch_template_name.startswith(default_resource_name) + - specific_instance_info.lifecycle_state == "InService" + - specific_instance_info.protected_from_scale_in == False vars: listed_instance_ids: "{{ instance_info.auto_scaling_instances | map(attribute='instance_id') | list }}" specific_instance_info: "{{ instance_info.auto_scaling_instances | selectattr('instance_id', 'equalto', initial_instances[0]) | first }}" @@ -74,33 +74,33 @@ - ansible.builtin.assert: that: - - "'auto_scaling_instances' in instance_info" - - instance_info.auto_scaling_instances | length == 2 - - initial_instances[0] in listed_instance_ids - - initial_instances[1] in listed_instance_ids - - "'auto_scaling_group_name' in instance_info.auto_scaling_instances[0]" - - "'availability_zone' in instance_info.auto_scaling_instances[0]" - - "'health_status' in instance_info.auto_scaling_instances[0]" - - "'instance_id' in instance_info.auto_scaling_instances[0]" - - "'instance_type' in instance_info.auto_scaling_instances[0]" - - "'launch_template' in instance_info.auto_scaling_instances[0]" - - "'lifecycle_state' in instance_info.auto_scaling_instances[0]" - - "'protected_from_scale_in' in instance_info.auto_scaling_instances[0]" - - "'auto_scaling_group_name' in instance_info.auto_scaling_instances[1]" - - "'availability_zone' in instance_info.auto_scaling_instances[1]" - - "'health_status' in instance_info.auto_scaling_instances[1]" - - "'instance_id' in instance_info.auto_scaling_instances[1]" - - "'instance_type' in instance_info.auto_scaling_instances[1]" - - "'launch_template' in instance_info.auto_scaling_instances[1]" - - "'lifecycle_state' in instance_info.auto_scaling_instances[1]" - - "'protected_from_scale_in' in instance_info.auto_scaling_instances[1]" - - specific_instance_info.auto_scaling_group_name == default_resource_name - - specific_instance_info.health_status == "HEALTHY" - - specific_instance_info.instance_id == initial_instances[0] - - specific_instance_info.instance_type == "t3.micro" - - specific_instance_info.launch_template.launch_template_name.startswith(default_resource_name) - - specific_instance_info.lifecycle_state == "InService" - - specific_instance_info.protected_from_scale_in == False + - "'auto_scaling_instances' in instance_info" + - instance_info.auto_scaling_instances | length == 2 + - initial_instances[0] in listed_instance_ids + - initial_instances[1] in listed_instance_ids + - "'auto_scaling_group_name' in instance_info.auto_scaling_instances[0]" + - "'availability_zone' in instance_info.auto_scaling_instances[0]" + - "'health_status' in instance_info.auto_scaling_instances[0]" + - "'instance_id' in instance_info.auto_scaling_instances[0]" + - "'instance_type' in instance_info.auto_scaling_instances[0]" + - "'launch_template' in instance_info.auto_scaling_instances[0]" + - "'lifecycle_state' in instance_info.auto_scaling_instances[0]" + - "'protected_from_scale_in' in instance_info.auto_scaling_instances[0]" + - "'auto_scaling_group_name' in instance_info.auto_scaling_instances[1]" + - "'availability_zone' in instance_info.auto_scaling_instances[1]" + - "'health_status' in instance_info.auto_scaling_instances[1]" + - "'instance_id' in instance_info.auto_scaling_instances[1]" + - "'instance_type' in instance_info.auto_scaling_instances[1]" + - "'launch_template' in instance_info.auto_scaling_instances[1]" + - "'lifecycle_state' in instance_info.auto_scaling_instances[1]" + - "'protected_from_scale_in' in instance_info.auto_scaling_instances[1]" + - specific_instance_info.auto_scaling_group_name == default_resource_name + - specific_instance_info.health_status == "HEALTHY" + - specific_instance_info.instance_id == initial_instances[0] + - specific_instance_info.instance_type == "t3.micro" + - specific_instance_info.launch_template.launch_template_name.startswith(default_resource_name) + - specific_instance_info.lifecycle_state == "InService" + - specific_instance_info.protected_from_scale_in == False vars: listed_instance_ids: "{{ instance_info.auto_scaling_instances | map(attribute='instance_id') | list }}" specific_instance_info: "{{ instance_info.auto_scaling_instances | selectattr('instance_id', 'equalto', initial_instances[0]) | first }}" @@ -111,24 +111,24 @@ - ansible.builtin.assert: that: - - "'auto_scaling_instances' in instance_info" - - instance_info.auto_scaling_instances | length == 1 - - initial_instances[0] in listed_instance_ids - - "'auto_scaling_group_name' in specific_instance_info" - - specific_instance_info.auto_scaling_group_name == default_resource_name - - "'availability_zone' in specific_instance_info" - - "'health_status' in specific_instance_info" - - specific_instance_info.health_status == "HEALTHY" - - "'instance_id' in specific_instance_info" - - specific_instance_info.instance_id == initial_instances[0] - - "'instance_type' in specific_instance_info" - - specific_instance_info.instance_type == "t3.micro" - - "'launch_template' in specific_instance_info" - - specific_instance_info.launch_template.launch_template_name.startswith(default_resource_name) - - "'lifecycle_state' in specific_instance_info" - - specific_instance_info.lifecycle_state == "InService" - - "'protected_from_scale_in' in specific_instance_info" - - specific_instance_info.protected_from_scale_in == False + - "'auto_scaling_instances' in instance_info" + - instance_info.auto_scaling_instances | length == 1 + - initial_instances[0] in listed_instance_ids + - "'auto_scaling_group_name' in specific_instance_info" + - specific_instance_info.auto_scaling_group_name == default_resource_name + - "'availability_zone' in specific_instance_info" + - "'health_status' in specific_instance_info" + - specific_instance_info.health_status == "HEALTHY" + - "'instance_id' in specific_instance_info" + - specific_instance_info.instance_id == initial_instances[0] + - "'instance_type' in specific_instance_info" + - specific_instance_info.instance_type == "t3.micro" + - "'launch_template' in specific_instance_info" + - specific_instance_info.launch_template.launch_template_name.startswith(default_resource_name) + - "'lifecycle_state' in specific_instance_info" + - specific_instance_info.lifecycle_state == "InService" + - "'protected_from_scale_in' in specific_instance_info" + - specific_instance_info.protected_from_scale_in == False vars: listed_instance_ids: "{{ instance_info.auto_scaling_instances | map(attribute='instance_id') | list }}" specific_instance_info: "{{ instance_info.auto_scaling_instances[0] }}" diff --git a/tests/integration/targets/autoscaling_instance/tasks/env_cleanup.yml b/tests/integration/targets/autoscaling_instance/tasks/env_cleanup.yml index c99fff99d8a..b16e8c0f82b 100644 --- a/tests/integration/targets/autoscaling_instance/tasks/env_cleanup.yml +++ b/tests/integration/targets/autoscaling_instance/tasks/env_cleanup.yml @@ -1,5 +1,5 @@ --- -- name: kill asg +- name: Kill asg amazon.aws.autoscaling_group: name: "{{ default_resource_name }}" state: absent @@ -13,13 +13,13 @@ amazon.aws.ec2_instance: state: absent instance_ids: "{{ all_instances }}" - wait: True + wait: true register: removed until: removed is not failed ignore_errors: true retries: 10 -- name: remove target group +- name: Remove target group community.aws.elb_target_group: name: "{{ item }}" state: absent @@ -31,7 +31,7 @@ - "{{ default_tiny_name }}-1" - "{{ default_tiny_name }}-2" -- name: remove launch templates +- name: Remove launch templates amazon.aws.ec2_launch_template: name: "{{ item }}" state: absent @@ -47,3 +47,5 @@ - ansible.builtin.include_role: name: setup_ec2_vpc tasks_from: cleanup.yml + vars: + setup_ec2_vpc_id: "{{ vpc_id }}" diff --git a/tests/integration/targets/autoscaling_instance/tasks/env_setup.yml b/tests/integration/targets/autoscaling_instance/tasks/env_setup.yml index 5eead8fcc59..fe7ab6d70c7 100644 --- a/tests/integration/targets/autoscaling_instance/tasks/env_setup.yml +++ b/tests/integration/targets/autoscaling_instance/tasks/env_setup.yml @@ -28,7 +28,7 @@ Name: "{{ default_resource_name }}" register: testing_subnet -- name: create routing rules +- name: Create routing rules amazon.aws.ec2_vpc_route_table: vpc_id: "{{ vpc_id }}" tags: @@ -39,7 +39,7 @@ subnets: - "{{ testing_subnet.subnet.id }}" -- name: create a security group with the vpc created in the ec2_setup +- name: Create a security group with the vpc created in the ec2_setup amazon.aws.ec2_security_group: name: "{{ default_resource_name }}" description: a security group for ansible tests @@ -57,7 +57,7 @@ # Note: main autoscaling tests use ASG "Launch Configs", these are being phased out in favour of EC2 # Launch Templates -- name: ensure launch templates exist +- name: Ensure launch templates exist amazon.aws.ec2_launch_template: name: "{{ item }}" network_interfaces: @@ -74,7 +74,7 @@ - "{{ default_resource_name }}-1" - "{{ default_resource_name }}-2" -- name: create asg and wait for instances to be deemed healthy (no ELB) +- name: Create asg and wait for instances to be deemed healthy (no ELB) amazon.aws.autoscaling_group: name: "{{ default_resource_name }}" launch_template: diff --git a/tests/integration/targets/autoscaling_instance/tasks/health.yml b/tests/integration/targets/autoscaling_instance/tasks/health.yml index 521ba37dfee..ccfd056e1a9 100644 --- a/tests/integration/targets/autoscaling_instance/tasks/health.yml +++ b/tests/integration/targets/autoscaling_instance/tasks/health.yml @@ -20,15 +20,15 @@ timeout: 10 # Set all to Healthy - no change -- name: instance_ids - all Healthy (idempotency) - check_mode +- name: Instance_ids - all Healthy (idempotency) - check_mode amazon.aws.autoscaling_instance: instance_ids: "{{ initial_instances }}" group_name: "{{ default_resource_name }}" state: present health: Healthy - diff: True + diff: true register: healthy_all - check_mode: True + check_mode: true - ansible.builtin.assert: that: @@ -55,13 +55,13 @@ specific_instance_info: "{{ current_result.auto_scaling_instances | selectattr('instance_id', 'equalto', initial_instances[1]) | first }}" other_instance_info: "{{ current_result.auto_scaling_instances | selectattr('instance_id', 'equalto', initial_instances[0]) | first }}" -- name: instance_ids - all Healthy (idempotency) +- name: Instance_ids - all Healthy (idempotency) amazon.aws.autoscaling_instance: instance_ids: "{{ initial_instances }}" group_name: "{{ default_resource_name }}" state: present health: Healthy - diff: True + diff: true register: healthy_all - ansible.builtin.assert: @@ -90,15 +90,15 @@ other_instance_info: "{{ current_result.auto_scaling_instances | selectattr('instance_id', 'equalto', initial_instances[0]) | first }}" # Set all to UnHealthy -- name: instance_ids - all Unhealthy - check_mode +- name: Instance_ids - all Unhealthy - check_mode amazon.aws.autoscaling_instance: instance_ids: "{{ initial_instances }}" group_name: "{{ default_resource_name }}" state: present health: Unhealthy - diff: True + diff: true register: unhealthy_all - check_mode: True + check_mode: true - ansible.builtin.assert: that: @@ -125,13 +125,13 @@ specific_instance_info: "{{ current_result.auto_scaling_instances | selectattr('instance_id', 'equalto', initial_instances[1]) | first }}" other_instance_info: "{{ current_result.auto_scaling_instances | selectattr('instance_id', 'equalto', initial_instances[0]) | first }}" -- name: instance_ids - all Unhealthy +- name: Instance_ids - all Unhealthy amazon.aws.autoscaling_instance: instance_ids: "{{ initial_instances }}" group_name: "{{ default_resource_name }}" state: present health: Unhealthy - diff: True + diff: true register: unhealthy_all - ansible.builtin.assert: @@ -159,15 +159,15 @@ specific_instance_info: "{{ current_result.auto_scaling_instances | selectattr('instance_id', 'equalto', initial_instances[1]) | first }}" other_instance_info: "{{ current_result.auto_scaling_instances | selectattr('instance_id', 'equalto', initial_instances[0]) | first }}" -- name: instance_ids - all Unhealthy (idempotency) - check_mode +- name: Instance_ids - all Unhealthy (idempotency) - check_mode amazon.aws.autoscaling_instance: instance_ids: "{{ initial_instances }}" group_name: "{{ default_resource_name }}" state: present health: Unhealthy - diff: True + diff: true register: unhealthy_all - check_mode: True + check_mode: true - ansible.builtin.assert: that: @@ -194,13 +194,13 @@ specific_instance_info: "{{ current_result.auto_scaling_instances | selectattr('instance_id', 'equalto', initial_instances[1]) | first }}" other_instance_info: "{{ current_result.auto_scaling_instances | selectattr('instance_id', 'equalto', initial_instances[0]) | first }}" -- name: instance_ids - all Unhealthy (idempotency) +- name: Instance_ids - all Unhealthy (idempotency) amazon.aws.autoscaling_instance: instance_ids: "{{ initial_instances }}" group_name: "{{ default_resource_name }}" state: present health: Unhealthy - diff: True + diff: true register: unhealthy_all - ansible.builtin.assert: @@ -229,15 +229,15 @@ other_instance_info: "{{ current_result.auto_scaling_instances | selectattr('instance_id', 'equalto', initial_instances[0]) | first }}" # Set all to Healthy again -- name: instance_ids - all Healthy - check_mode +- name: Instance_ids - all Healthy - check_mode amazon.aws.autoscaling_instance: instance_ids: "{{ initial_instances }}" group_name: "{{ default_resource_name }}" state: present health: Healthy - diff: True + diff: true register: healthy_all - check_mode: True + check_mode: true - ansible.builtin.assert: that: @@ -264,13 +264,13 @@ specific_instance_info: "{{ current_result.auto_scaling_instances | selectattr('instance_id', 'equalto', initial_instances[1]) | first }}" other_instance_info: "{{ current_result.auto_scaling_instances | selectattr('instance_id', 'equalto', initial_instances[0]) | first }}" -- name: instance_ids - all Healthy +- name: Instance_ids - all Healthy amazon.aws.autoscaling_instance: instance_ids: "{{ initial_instances }}" group_name: "{{ default_resource_name }}" state: present health: Healthy - diff: True + diff: true register: healthy_all - ansible.builtin.assert: @@ -301,12 +301,12 @@ # -- implicit instance list -- # implicitly change all -- name: no instance_ids - all Unhealthy +- name: No instance_ids - all Unhealthy amazon.aws.autoscaling_instance: group_name: "{{ default_resource_name }}" state: present health: Unhealthy - diff: True + diff: true register: unhealthy_all - ansible.builtin.assert: @@ -335,12 +335,12 @@ other_instance_info: "{{ current_result.auto_scaling_instances | selectattr('instance_id', 'equalto', initial_instances[0]) | first }}" # implicitly change all -- name: no instance_ids - all Healthy +- name: No instance_ids - all Healthy amazon.aws.autoscaling_instance: group_name: "{{ default_resource_name }}" state: present health: Healthy - diff: True + diff: true register: healthy_all - ansible.builtin.assert: @@ -373,15 +373,15 @@ # ===================================================== # Set to Healthy - no change -- name: instance_ids - one Healthy (idempotency) - check_mode +- name: Instance_ids - one Healthy (idempotency) - check_mode amazon.aws.autoscaling_instance: instance_ids: "{{ initial_instances[1] }}" group_name: "{{ default_resource_name }}" state: present health: Healthy - diff: True + diff: true register: healthy_one - check_mode: True + check_mode: true - ansible.builtin.assert: that: @@ -408,13 +408,13 @@ specific_instance_info: "{{ current_result.auto_scaling_instances | selectattr('instance_id', 'equalto', initial_instances[1]) | first }}" other_instance_info: "{{ current_result.auto_scaling_instances | selectattr('instance_id', 'equalto', initial_instances[0]) | first }}" -- name: instance_ids - one Healthy (idempotency) +- name: Instance_ids - one Healthy (idempotency) amazon.aws.autoscaling_instance: instance_ids: "{{ initial_instances[1] }}" group_name: "{{ default_resource_name }}" state: present health: Healthy - diff: True + diff: true register: healthy_one - ansible.builtin.assert: @@ -443,15 +443,15 @@ other_instance_info: "{{ current_result.auto_scaling_instances | selectattr('instance_id', 'equalto', initial_instances[0]) | first }}" # Set to UnHealthy -- name: instance_ids - one Unhealthy - check_mode +- name: Instance_ids - one Unhealthy - check_mode amazon.aws.autoscaling_instance: instance_ids: "{{ initial_instances[1] }}" group_name: "{{ default_resource_name }}" state: present health: Unhealthy - diff: True + diff: true register: unhealthy_one - check_mode: True + check_mode: true - ansible.builtin.assert: that: @@ -478,13 +478,13 @@ specific_instance_info: "{{ current_result.auto_scaling_instances | selectattr('instance_id', 'equalto', initial_instances[1]) | first }}" other_instance_info: "{{ current_result.auto_scaling_instances | selectattr('instance_id', 'equalto', initial_instances[0]) | first }}" -- name: instance_ids - one Unhealthy +- name: Instance_ids - one Unhealthy amazon.aws.autoscaling_instance: instance_ids: "{{ initial_instances[1] }}" group_name: "{{ default_resource_name }}" state: present health: Unhealthy - diff: True + diff: true register: unhealthy_one - ansible.builtin.assert: @@ -512,15 +512,15 @@ specific_instance_info: "{{ current_result.auto_scaling_instances | selectattr('instance_id', 'equalto', initial_instances[1]) | first }}" other_instance_info: "{{ current_result.auto_scaling_instances | selectattr('instance_id', 'equalto', initial_instances[0]) | first }}" -- name: instance_ids - one Unhealthy (idempotency) - check_mode +- name: Instance_ids - one Unhealthy (idempotency) - check_mode amazon.aws.autoscaling_instance: instance_ids: "{{ initial_instances[1] }}" group_name: "{{ default_resource_name }}" state: present health: Unhealthy - diff: True + diff: true register: unhealthy_one - check_mode: True + check_mode: true - ansible.builtin.assert: that: @@ -547,13 +547,13 @@ specific_instance_info: "{{ current_result.auto_scaling_instances | selectattr('instance_id', 'equalto', initial_instances[1]) | first }}" other_instance_info: "{{ current_result.auto_scaling_instances | selectattr('instance_id', 'equalto', initial_instances[0]) | first }}" -- name: instance_ids - one Unhealthy (idempotency) +- name: Instance_ids - one Unhealthy (idempotency) amazon.aws.autoscaling_instance: instance_ids: "{{ initial_instances[1] }}" group_name: "{{ default_resource_name }}" state: present health: Unhealthy - diff: True + diff: true register: unhealthy_one - ansible.builtin.assert: @@ -582,15 +582,15 @@ other_instance_info: "{{ current_result.auto_scaling_instances | selectattr('instance_id', 'equalto', initial_instances[0]) | first }}" # Set to Healthy again -- name: instance_ids - one Healthy - check_mode +- name: Instance_ids - one Healthy - check_mode amazon.aws.autoscaling_instance: instance_ids: "{{ initial_instances[1] }}" group_name: "{{ default_resource_name }}" state: present health: Healthy - diff: True + diff: true register: healthy_one - check_mode: True + check_mode: true - ansible.builtin.assert: that: @@ -617,13 +617,13 @@ specific_instance_info: "{{ current_result.auto_scaling_instances | selectattr('instance_id', 'equalto', initial_instances[1]) | first }}" other_instance_info: "{{ current_result.auto_scaling_instances | selectattr('instance_id', 'equalto', initial_instances[0]) | first }}" -- name: instance_ids - one Healthy +- name: Instance_ids - one Healthy amazon.aws.autoscaling_instance: instance_ids: "{{ initial_instances[1] }}" group_name: "{{ default_resource_name }}" state: present health: Healthy - diff: True + diff: true register: healthy_one - ansible.builtin.assert: diff --git a/tests/integration/targets/autoscaling_instance/tasks/protection.yml b/tests/integration/targets/autoscaling_instance/tasks/protection.yml index 23608d8ed47..ef9f78779c4 100644 --- a/tests/integration/targets/autoscaling_instance/tasks/protection.yml +++ b/tests/integration/targets/autoscaling_instance/tasks/protection.yml @@ -4,15 +4,15 @@ # ===================================================== # Set all to Unprotected - no change -- name: instance_ids - all Unprotected (idempotency) - check_mode +- name: Instance_ids - all Unprotected (idempotency) - check_mode amazon.aws.autoscaling_instance: instance_ids: "{{ initial_instances }}" group_name: "{{ default_resource_name }}" state: present - protection: False - diff: True + protection: false + diff: true register: unprotected_all - check_mode: True + check_mode: true - ansible.builtin.assert: that: @@ -39,13 +39,13 @@ specific_instance_info: "{{ current_result.auto_scaling_instances | selectattr('instance_id', 'equalto', initial_instances[1]) | first }}" other_instance_info: "{{ current_result.auto_scaling_instances | selectattr('instance_id', 'equalto', initial_instances[0]) | first }}" -- name: instance_ids - all Unprotected (idempotency) +- name: Instance_ids - all Unprotected (idempotency) amazon.aws.autoscaling_instance: instance_ids: "{{ initial_instances }}" group_name: "{{ default_resource_name }}" state: present - protection: False - diff: True + protection: false + diff: true register: unprotected_all - ansible.builtin.assert: @@ -74,15 +74,15 @@ other_instance_info: "{{ current_result.auto_scaling_instances | selectattr('instance_id', 'equalto', initial_instances[0]) | first }}" # Set all to Protected -- name: instance_ids - all Protected - check_mode +- name: Instance_ids - all Protected - check_mode amazon.aws.autoscaling_instance: instance_ids: "{{ initial_instances }}" group_name: "{{ default_resource_name }}" state: present - protection: True - diff: True + protection: true + diff: true register: protected_all - check_mode: True + check_mode: true - ansible.builtin.assert: that: @@ -109,13 +109,13 @@ specific_instance_info: "{{ current_result.auto_scaling_instances | selectattr('instance_id', 'equalto', initial_instances[1]) | first }}" other_instance_info: "{{ current_result.auto_scaling_instances | selectattr('instance_id', 'equalto', initial_instances[0]) | first }}" -- name: instance_ids - all Protected +- name: Instance_ids - all Protected amazon.aws.autoscaling_instance: instance_ids: "{{ initial_instances }}" group_name: "{{ default_resource_name }}" state: present - protection: True - diff: True + protection: true + diff: true register: protected_all - ansible.builtin.assert: @@ -143,15 +143,15 @@ specific_instance_info: "{{ current_result.auto_scaling_instances | selectattr('instance_id', 'equalto', initial_instances[1]) | first }}" other_instance_info: "{{ current_result.auto_scaling_instances | selectattr('instance_id', 'equalto', initial_instances[0]) | first }}" -- name: instance_ids - all Protected (idempotency) - check_mode +- name: Instance_ids - all Protected (idempotency) - check_mode amazon.aws.autoscaling_instance: instance_ids: "{{ initial_instances }}" group_name: "{{ default_resource_name }}" state: present - protection: True - diff: True + protection: true + diff: true register: protected_all - check_mode: True + check_mode: true - ansible.builtin.assert: that: @@ -178,13 +178,13 @@ specific_instance_info: "{{ current_result.auto_scaling_instances | selectattr('instance_id', 'equalto', initial_instances[1]) | first }}" other_instance_info: "{{ current_result.auto_scaling_instances | selectattr('instance_id', 'equalto', initial_instances[0]) | first }}" -- name: instance_ids - all Protected (idempotency) +- name: Instance_ids - all Protected (idempotency) amazon.aws.autoscaling_instance: instance_ids: "{{ initial_instances }}" group_name: "{{ default_resource_name }}" state: present - protection: True - diff: True + protection: true + diff: true register: protected_all - ansible.builtin.assert: @@ -213,15 +213,15 @@ other_instance_info: "{{ current_result.auto_scaling_instances | selectattr('instance_id', 'equalto', initial_instances[0]) | first }}" # Set all to Unprotected again -- name: instance_ids - all Unprotected - check_mode +- name: Instance_ids - all Unprotected - check_mode amazon.aws.autoscaling_instance: instance_ids: "{{ initial_instances }}" group_name: "{{ default_resource_name }}" state: present - protection: False - diff: True + protection: false + diff: true register: unprotected_all - check_mode: True + check_mode: true - ansible.builtin.assert: that: @@ -248,13 +248,13 @@ specific_instance_info: "{{ current_result.auto_scaling_instances | selectattr('instance_id', 'equalto', initial_instances[1]) | first }}" other_instance_info: "{{ current_result.auto_scaling_instances | selectattr('instance_id', 'equalto', initial_instances[0]) | first }}" -- name: instance_ids - all Unprotected +- name: Instance_ids - all Unprotected amazon.aws.autoscaling_instance: instance_ids: "{{ initial_instances }}" group_name: "{{ default_resource_name }}" state: present - protection: False - diff: True + protection: false + diff: true register: unprotected_all - ansible.builtin.assert: @@ -285,12 +285,12 @@ # -- implicit instance list -- # implicitly change all -- name: no instance_ids - all Protected +- name: No instance_ids - all Protected amazon.aws.autoscaling_instance: group_name: "{{ default_resource_name }}" state: present - protection: True - diff: True + protection: true + diff: true register: protected_all - ansible.builtin.assert: @@ -319,12 +319,12 @@ other_instance_info: "{{ current_result.auto_scaling_instances | selectattr('instance_id', 'equalto', initial_instances[0]) | first }}" # implicitly change all -- name: no instance_ids - all Unprotected +- name: No instance_ids - all Unprotected amazon.aws.autoscaling_instance: group_name: "{{ default_resource_name }}" state: present - protection: False - diff: True + protection: false + diff: true register: unprotected_all - ansible.builtin.assert: @@ -357,80 +357,80 @@ # ===================================================== # Set to Unprotected - no change -- name: instance_ids - one Unprotected (idempotency) - check_mode +- name: Instance_ids - one Unprotected (idempotency) - check_mode amazon.aws.autoscaling_instance: instance_ids: "{{ initial_instances[1] }}" group_name: "{{ default_resource_name }}" state: present - protection: False - diff: True + protection: false + diff: true register: unprotected_one - check_mode: True + check_mode: true -- name: instance_ids - one Unprotected (idempotency) +- name: Instance_ids - one Unprotected (idempotency) amazon.aws.autoscaling_instance: instance_ids: "{{ initial_instances[1] }}" group_name: "{{ default_resource_name }}" state: present - protection: False - diff: True + protection: false + diff: true register: unprotected_one # Set to Protected -- name: instance_ids - one Protected - check_mode +- name: Instance_ids - one Protected - check_mode amazon.aws.autoscaling_instance: instance_ids: "{{ initial_instances[1] }}" group_name: "{{ default_resource_name }}" state: present - protection: True - diff: True + protection: true + diff: true register: protected_one - check_mode: True + check_mode: true -- name: instance_ids - one Protected +- name: Instance_ids - one Protected amazon.aws.autoscaling_instance: instance_ids: "{{ initial_instances[1] }}" group_name: "{{ default_resource_name }}" state: present - protection: True - diff: True + protection: true + diff: true register: protected_one -- name: instance_ids - one Protected (idempotency) - check_mode +- name: Instance_ids - one Protected (idempotency) - check_mode amazon.aws.autoscaling_instance: instance_ids: "{{ initial_instances[1] }}" group_name: "{{ default_resource_name }}" state: present - protection: True - diff: True + protection: true + diff: true register: protected_one - check_mode: True + check_mode: true -- name: instance_ids - one Protected (idempotency) +- name: Instance_ids - one Protected (idempotency) amazon.aws.autoscaling_instance: instance_ids: "{{ initial_instances[1] }}" group_name: "{{ default_resource_name }}" state: present - protection: True - diff: True + protection: true + diff: true register: protected_one # Set to Unprotected again -- name: instance_ids - one Unprotected - check_mode +- name: Instance_ids - one Unprotected - check_mode amazon.aws.autoscaling_instance: instance_ids: "{{ initial_instances[1] }}" group_name: "{{ default_resource_name }}" state: present - protection: False - diff: True + protection: false + diff: true register: unprotected_one - check_mode: True + check_mode: true -- name: instance_ids - one Unprotected +- name: Instance_ids - one Unprotected amazon.aws.autoscaling_instance: instance_ids: "{{ initial_instances[1] }}" group_name: "{{ default_resource_name }}" state: present - protection: False - diff: True + protection: false + diff: true register: unprotected_one diff --git a/tests/integration/targets/autoscaling_instance_refresh/defaults/main.yml b/tests/integration/targets/autoscaling_instance_refresh/defaults/main.yml index 08e57d2558e..5004fbf9ccf 100644 --- a/tests/integration/targets/autoscaling_instance_refresh/defaults/main.yml +++ b/tests/integration/targets/autoscaling_instance_refresh/defaults/main.yml @@ -1,16 +1,16 @@ --- # defaults file for ec2_asg -vpc_seed: '{{ tiny_prefix }}' -subnet_a_cidr: '10.{{ 256 | random(seed=vpc_seed) }}.32.0/24' +vpc_seed: "{{ tiny_prefix }}" +subnet_a_cidr: "10.{{ 256 | random(seed=vpc_seed) }}.32.0/24" -default_resource_name: '{{ resource_prefix }}-asg-refresh' -short_resource_name: '{{ tiny_prefix }}-asg-refresh' +default_resource_name: "{{ resource_prefix }}-asg-refresh" +short_resource_name: "{{ tiny_prefix }}-asg-refresh" -vpc_name: '{{ default_resource_name }}' -subnet_name: '{{ default_resource_name }}' -route_name: '{{ default_resource_name }}' -sg_name: '{{ default_resource_name }}' -asg_name: '{{ default_resource_name }}' -lc_name_1: '{{ default_resource_name }}-1' -lc_name_2: '{{ default_resource_name }}-2' -load_balancer_name: '{{ short_resource_name }}' +vpc_name: "{{ default_resource_name }}" +subnet_name: "{{ default_resource_name }}" +route_name: "{{ default_resource_name }}" +sg_name: "{{ default_resource_name }}" +asg_name: "{{ default_resource_name }}" +lc_name_1: "{{ default_resource_name }}-1" +lc_name_2: "{{ default_resource_name }}-2" +load_balancer_name: "{{ short_resource_name }}" diff --git a/tests/integration/targets/autoscaling_instance_refresh/meta/main.yml b/tests/integration/targets/autoscaling_instance_refresh/meta/main.yml index 1471b11f658..fcadd50dc68 100644 --- a/tests/integration/targets/autoscaling_instance_refresh/meta/main.yml +++ b/tests/integration/targets/autoscaling_instance_refresh/meta/main.yml @@ -1,2 +1,3 @@ +--- dependencies: - setup_ec2_facts diff --git a/tests/integration/targets/autoscaling_instance_refresh/tasks/instance_refresh_info.yml b/tests/integration/targets/autoscaling_instance_refresh/tasks/instance_refresh_info.yml index b3590867899..3fc5cc3c06d 100644 --- a/tests/integration/targets/autoscaling_instance_refresh/tasks/instance_refresh_info.yml +++ b/tests/integration/targets/autoscaling_instance_refresh/tasks/instance_refresh_info.yml @@ -12,7 +12,7 @@ - name: Test using fake refresh ID amazon.aws.autoscaling_instance_refresh_info: name: "{{ asg_name }}" - ids: ['0e367f58-blabla-bla-bla-ca870dc5dbfe'] + ids: ["0e367f58-blabla-bla-bla-ca870dc5dbfe"] register: output - name: Assert that no record is returned @@ -23,7 +23,7 @@ - name: Test using a real refresh ID amazon.aws.autoscaling_instance_refresh_info: name: "{{ asg_name }}" - ids: [ '{{ refreshout.instance_refreshes.instance_refresh_id }}' ] + ids: ["{{ refreshout.instance_refreshes.instance_refresh_id }}"] register: output - name: Assert that the correct record is returned @@ -40,7 +40,8 @@ - name: Assert that module failed to return record ansible.builtin.assert: that: - - "'Failed to describe InstanceRefreshes: An error occurred (ValidationError) when calling the DescribeInstanceRefreshes operation: AutoScalingGroup name not found - AutoScalingGroup n0n3x1stentname27b not found' in output.msg" + - "'Failed to describe InstanceRefreshes: An error occurred (ValidationError) when calling the DescribeInstanceRefreshes operation: AutoScalingGroup name not + found - AutoScalingGroup n0n3x1stentname27b not found' in output.msg" - name: Retrieve instance refresh info amazon.aws.autoscaling_instance_refresh_info: @@ -62,7 +63,8 @@ - name: Assert that valid message with fake-token is returned ansible.builtin.assert: that: - - '"Failed to describe InstanceRefreshes: An error occurred (InvalidNextToken) when calling the DescribeInstanceRefreshes operation: The token ''********'' is invalid." in output.msg' + - '"Failed to describe InstanceRefreshes: An error occurred (InvalidNextToken) when calling the DescribeInstanceRefreshes operation: The token ''********'' + is invalid." in output.msg' - name: Retrieve instance refresh info using max_records amazon.aws.autoscaling_instance_refresh_info: diff --git a/tests/integration/targets/autoscaling_instance_refresh/tasks/main.yml b/tests/integration/targets/autoscaling_instance_refresh/tasks/main.yml index 3fee7c53c1f..bdb256e7d5a 100644 --- a/tests/integration/targets/autoscaling_instance_refresh/tasks/main.yml +++ b/tests/integration/targets/autoscaling_instance_refresh/tasks/main.yml @@ -1,5 +1,5 @@ --- -- name: setup credentials and region +- name: Setup credentials and region module_defaults: group/aws: access_key: "{{ aws_access_key }}" @@ -12,7 +12,7 @@ - name: Create VPC for use in testing amazon.aws.ec2_vpc_net: name: "{{ vpc_name }}" - cidr_block: '{{ subnet_a_cidr }}' + cidr_block: "{{ subnet_a_cidr }}" tenancy: default register: testing_vpc @@ -26,7 +26,7 @@ amazon.aws.ec2_vpc_subnet: state: present vpc_id: "{{ testing_vpc.vpc.id }}" - cidr: '{{ subnet_a_cidr }}' + cidr: "{{ subnet_a_cidr }}" az: "{{ aws_region }}a" resource_tags: Name: "{{ subnet_name }}" @@ -85,19 +85,19 @@ min_size: 1 max_size: 1 vpc_zone_identifier: "{{ testing_subnet.subnet.id }}" - wait_for_instances: no + wait_for_instances: false state: present register: output - name: Assert that there is no viable instance ansible.builtin.assert: that: - - "output.viable_instances == 0" + - "output.viable_instances == 0" - # ============================================================ + # ============================================================ - name: Run test with start_cancel_instance_refresh.yml ansible.builtin.include_tasks: start_cancel_instance_refresh.yml - + # ============================================================ - name: Run test with refresh_and_cancel_three_times.yml @@ -108,7 +108,6 @@ ansible.builtin.include_tasks: instance_refresh_info.yml always: - - name: Kill asg amazon.aws.autoscaling_group: name: "{{ asg_name }}" @@ -133,13 +132,13 @@ load_balancer_port: 80 instance_port: 80 health_check: - ping_protocol: tcp - ping_port: 80 - ping_path: "/" - response_timeout: 5 - interval: 10 - unhealthy_threshold: 4 - healthy_threshold: 2 + ping_protocol: tcp + ping_port: 80 + ping_path: "/" + response_timeout: 5 + interval: 10 + unhealthy_threshold: 4 + healthy_threshold: 2 register: removed until: removed is not failed ignore_errors: true @@ -197,7 +196,7 @@ amazon.aws.ec2_vpc_subnet: state: absent vpc_id: "{{ testing_vpc.vpc.id }}" - cidr: '{{ subnet_a_cidr }}' + cidr: "{{ subnet_a_cidr }}" register: removed until: removed is not failed ignore_errors: true @@ -206,7 +205,7 @@ - name: Remove the VPC amazon.aws.ec2_vpc_net: name: "{{ vpc_name }}" - cidr_block: '{{ subnet_a_cidr }}' + cidr_block: "{{ subnet_a_cidr }}" state: absent register: removed until: removed is not failed diff --git a/tests/integration/targets/autoscaling_instance_refresh/tasks/start_cancel_instance_refresh.yml b/tests/integration/targets/autoscaling_instance_refresh/tasks/start_cancel_instance_refresh.yml index 24d6b9d67ab..87e3b5e0d72 100644 --- a/tests/integration/targets/autoscaling_instance_refresh/tasks/start_cancel_instance_refresh.yml +++ b/tests/integration/targets/autoscaling_instance_refresh/tasks/start_cancel_instance_refresh.yml @@ -1,5 +1,5 @@ --- -- name: test invalid cancelation - V1 - (pre-refresh) +- name: Test invalid cancelation - V1 - (pre-refresh) amazon.aws.autoscaling_instance_refresh: name: "{{ asg_name }}" state: "cancelled" @@ -9,7 +9,8 @@ - name: Assert that module failed with proper message ansible.builtin.assert: that: - - "'An error occurred (ActiveInstanceRefreshNotFound) when calling the CancelInstanceRefresh operation: No in progress or pending Instance Refresh found for Auto Scaling group ' ~ resource_prefix ~ '-asg' in result.msg" + - "'An error occurred (ActiveInstanceRefreshNotFound) when calling the CancelInstanceRefresh operation: No in progress or pending Instance Refresh found for + Auto Scaling group ' ~ resource_prefix ~ '-asg' in result.msg" - name: Test starting a refresh with a valid ASG name - check_mode amazon.aws.autoscaling_instance_refresh: @@ -46,7 +47,8 @@ ansible.builtin.assert: that: - output is not changed - - '"Failed to start InstanceRefresh: An error occurred (InstanceRefreshInProgress) when calling the StartInstanceRefresh operation: An Instance Refresh is already in progress and blocks the execution of this Instance Refresh." in output.msg' + - '"Failed to start InstanceRefresh: An error occurred (InstanceRefreshInProgress) when calling the StartInstanceRefresh operation: An Instance Refresh is already + in progress and blocks the execution of this Instance Refresh." in output.msg' - name: Test starting a refresh with a valid ASG name - Idempotent (check_mode) amazon.aws.autoscaling_instance_refresh: @@ -71,7 +73,8 @@ - name: Assert that module failed with proper message ansible.builtin.assert: that: - - "'Failed to start InstanceRefresh: An error occurred (ValidationError) when calling the StartInstanceRefresh operation: AutoScalingGroup name not found' in result.msg" + - "'Failed to start InstanceRefresh: An error occurred (ValidationError) when calling the StartInstanceRefresh operation: AutoScalingGroup name not found' in + result.msg" - name: Test canceling a refresh with an ASG name - check_mode amazon.aws.autoscaling_instance_refresh: diff --git a/tests/integration/targets/aws_az_info/main.yml b/tests/integration/targets/aws_az_info/main.yml deleted file mode 100644 index 10456f724ad..00000000000 --- a/tests/integration/targets/aws_az_info/main.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -- hosts: localhost - connection: local - environment: "{{ ansible_test.environment }}" - tasks: - - ansible.builtin.include_tasks: tasks/main.yml diff --git a/tests/integration/targets/aws_az_info/tasks/main.yml b/tests/integration/targets/aws_az_info/tasks/main.yml index 0f8a14eeca9..8d839612fc1 100644 --- a/tests/integration/targets/aws_az_info/tasks/main.yml +++ b/tests/integration/targets/aws_az_info/tasks/main.yml @@ -11,7 +11,7 @@ amazon.aws.aws_az_info: register: region_azs - - name: check task return attributes + - name: Check task return attributes vars: first_az: "{{ region_azs.availability_zones[0] }}" ansible.builtin.assert: @@ -33,7 +33,7 @@ check_mode: true register: check_azs - - name: check task return attributes + - name: Check task return attributes vars: first_az: "{{ check_azs.availability_zones[0] }}" ansible.builtin.assert: diff --git a/tests/integration/targets/aws_caller_info/tasks/main.yaml b/tests/integration/targets/aws_caller_info/tasks/main.yaml index 37da2df014c..8106a040ec6 100644 --- a/tests/integration/targets/aws_caller_info/tasks/main.yaml +++ b/tests/integration/targets/aws_caller_info/tasks/main.yaml @@ -6,11 +6,11 @@ secret_key: "{{ aws_secret_key }}" session_token: "{{ security_token | default(omit) }}" block: - - name: retrieve caller facts + - name: Retrieve caller facts amazon.aws.aws_caller_info: register: result - - name: assert correct keys are returned + - name: Assert correct keys are returned ansible.builtin.assert: that: - result.account is not none diff --git a/tests/integration/targets/aws_region_info/tasks/main.yml b/tests/integration/targets/aws_region_info/tasks/main.yml index 0b07bec7759..3d6d6a4a010 100644 --- a/tests/integration/targets/aws_region_info/tasks/main.yml +++ b/tests/integration/targets/aws_region_info/tasks/main.yml @@ -9,7 +9,7 @@ - name: List available Regions amazon.aws.aws_region_info: register: regions - - name: check task return attributes + - name: Check task return attributes vars: first_region: "{{ regions.regions[0] }}" ansible.builtin.assert: @@ -24,7 +24,7 @@ - name: List available Regions - check_mode amazon.aws.aws_region_info: register: check_regions - - name: check task return attributes - check_mode + - name: Check task return attributes - check_mode vars: first_region: "{{ check_regions.regions[0] }}" ansible.builtin.assert: @@ -41,7 +41,7 @@ filters: region-name: us-west-1 register: us_west_1 - - name: check task return attributes - filtering using - + - name: Check task return attributes - filtering using - vars: first_region: "{{ us_west_1.regions[0] }}" ansible.builtin.assert: @@ -62,7 +62,7 @@ filters: region_name: us-west-2 register: us_west_2 - - name: check task return attributes - filtering using _ + - name: Check task return attributes - filtering using _ vars: first_region: "{{ us_west_2.regions[0] }}" ansible.builtin.assert: @@ -84,7 +84,7 @@ region-name: eu-west-1 region_name: eu-central-1 register: regions_prededence - - name: check task return attributes - precedence + - name: Check task return attributes - precedence vars: first_region: "{{ regions_prededence.regions[0] }}" ansible.builtin.assert: diff --git a/tests/integration/targets/backup_vault/defaults/main.yml b/tests/integration/targets/backup_vault/defaults/main.yml index 1a944ea5fc4..c8c1805f935 100644 --- a/tests/integration/targets/backup_vault/defaults/main.yml +++ b/tests/integration/targets/backup_vault/defaults/main.yml @@ -1,4 +1,4 @@ --- # defaults file for test_backup_vault backup_vault_name: "{{ tiny_prefix }}-backup-vault" -kms_key_alias: ansible-test-{{ inventory_hostname | replace('_','-') }}{{ tiny_prefix }} +kms_key_alias: ansible-test-{{ inventory_hostname | replace('_', '-') }}{{ tiny_prefix }} diff --git a/tests/integration/targets/backup_vault/tasks/main.yml b/tests/integration/targets/backup_vault/tasks/main.yml index a4bd68882fd..cb5ceb4153e 100644 --- a/tests/integration/targets/backup_vault/tasks/main.yml +++ b/tests/integration/targets/backup_vault/tasks/main.yml @@ -6,7 +6,7 @@ session_token: "{{ security_token | default(omit) }}" region: "{{ aws_region }}" block: - - name: create a key + - name: Create a key amazon.aws.kms_key: alias: "{{ kms_key_alias }}" state: present @@ -251,7 +251,7 @@ state: absent ignore_errors: true - - name: finish off by deleting keys + - name: Finish off by deleting keys amazon.aws.kms_key: state: absent alias: "{{ kms_key_alias }}" diff --git a/tests/integration/targets/callback_aws_resource_actions/main.yml b/tests/integration/targets/callback_aws_resource_actions/main.yml index 9a90044434a..11ff4c5f16a 100644 --- a/tests/integration/targets/callback_aws_resource_actions/main.yml +++ b/tests/integration/targets/callback_aws_resource_actions/main.yml @@ -1,5 +1,6 @@ --- -- hosts: localhost +- name: Run simple test with AWS Resource Actions callback enabled + hosts: localhost gather_facts: false module_defaults: group/aws: diff --git a/tests/integration/targets/cloudformation/tasks/main.yml b/tests/integration/targets/cloudformation/tasks/main.yml index c75e821a5e7..f903d0919a1 100644 --- a/tests/integration/targets/cloudformation/tasks/main.yml +++ b/tests/integration/targets/cloudformation/tasks/main.yml @@ -36,7 +36,7 @@ - name: Create a cloudformation stack (Check mode) amazon.aws.cloudformation: stack_name: "{{ stack_name }}" - template_body: "{{ lookup('file','cf_template.json') }}" + template_body: "{{ lookup('file', 'cf_template.json') }}" template_parameters: InstanceType: t3.nano ImageId: "{{ ec2_ami_id }}" @@ -56,7 +56,7 @@ - name: Create a cloudformation stack amazon.aws.cloudformation: stack_name: "{{ stack_name }}" - template_body: "{{ lookup('file','cf_template.json') }}" + template_body: "{{ lookup('file', 'cf_template.json') }}" template_parameters: InstanceType: t3.nano ImageId: "{{ ec2_ami_id }}" @@ -78,7 +78,7 @@ - name: Create a cloudformation stack (Check mode) (idempotent) amazon.aws.cloudformation: stack_name: "{{ stack_name }}" - template_body: "{{ lookup('file','cf_template.json') }}" + template_body: "{{ lookup('file', 'cf_template.json') }}" template_parameters: InstanceType: t3.nano ImageId: "{{ ec2_ami_id }}" @@ -97,7 +97,7 @@ - name: Create a cloudformation stack (idempotent) amazon.aws.cloudformation: stack_name: "{{ stack_name }}" - template_body: "{{ lookup('file','cf_template.json') }}" + template_body: "{{ lookup('file', 'cf_template.json') }}" template_parameters: InstanceType: t3.nano ImageId: "{{ ec2_ami_id }}" @@ -198,7 +198,7 @@ stack_name: "{{ stack_name }}" create_changeset: true changeset_name: test-changeset - template_body: "{{ lookup('file','cf_template.json') }}" + template_body: "{{ lookup('file', 'cf_template.json') }}" template_parameters: InstanceType: t3.micro ImageId: "{{ ec2_ami_id }}" @@ -243,7 +243,7 @@ amazon.aws.cloudformation: stack_name: "{{ stack_name }}" create_changeset: true - template_body: "{{ lookup('file','cf_template.json') }}" + template_body: "{{ lookup('file', 'cf_template.json') }}" template_parameters: InstanceType: t3.nano ImageId: "{{ ec2_ami_id }}" @@ -265,7 +265,7 @@ amazon.aws.cloudformation: stack_name: "{{ stack_name }}" termination_protection: true - template_body: "{{ lookup('file','cf_template.json') }}" + template_body: "{{ lookup('file', 'cf_template.json') }}" template_parameters: InstanceType: t3.nano ImageId: "{{ ec2_ami_id }}" @@ -306,7 +306,7 @@ amazon.aws.cloudformation: stack_name: "{{ stack_name }}" termination_protection: false - template_body: "{{ lookup('file','cf_template.json') }}" + template_body: "{{ lookup('file', 'cf_template.json') }}" template_parameters: InstanceType: t3.nano ImageId: "{{ ec2_ami_id }}" @@ -348,8 +348,8 @@ - name: Setting an stack policy with json body amazon.aws.cloudformation: stack_name: "{{ stack_name }}" - stack_policy_body: "{{ lookup('file','update_policy.json') }}" - template_body: "{{ lookup('file','cf_template.json') }}" + stack_policy_body: "{{ lookup('file', 'update_policy.json') }}" + template_body: "{{ lookup('file', 'cf_template.json') }}" template_parameters: InstanceType: t3.nano ImageId: "{{ ec2_ami_id }}" @@ -367,8 +367,8 @@ - name: Setting an stack policy on update amazon.aws.cloudformation: stack_name: "{{ stack_name }}" - stack_policy_on_update_body: "{{ lookup('file','update_policy.json') }}" - template_body: "{{ lookup('file','cf_template.json') }}" + stack_policy_on_update_body: "{{ lookup('file', 'update_policy.json') }}" + template_body: "{{ lookup('file', 'cf_template.json') }}" template_parameters: InstanceType: t3.nano ImageId: "{{ ec2_ami_id }}" diff --git a/tests/integration/targets/cloudformation/tasks/test_disable_rollback.yml b/tests/integration/targets/cloudformation/tasks/test_disable_rollback.yml index b4bcae645e9..a7b097b50b4 100644 --- a/tests/integration/targets/cloudformation/tasks/test_disable_rollback.yml +++ b/tests/integration/targets/cloudformation/tasks/test_disable_rollback.yml @@ -7,7 +7,7 @@ stack_name: "{{ stack_name_disable_rollback_true }}" state: present disable_rollback: true - template_body: "{{ lookup('file','cf_template.json') }}" + template_body: "{{ lookup('file', 'cf_template.json') }}" template_parameters: InstanceType: t3.nano ImageId: "{{ ec2_ami_id }}" @@ -26,7 +26,7 @@ stack_name: "{{ stack_name_disable_rollback_true }}" state: present disable_rollback: true - template_body: "{{ lookup('file','cf_template.json') }}" + template_body: "{{ lookup('file', 'cf_template.json') }}" template_parameters: InstanceType: t3.nano ImageId: "{{ ec2_ami_id }}" @@ -51,7 +51,7 @@ stack_name: "{{ stack_name_disable_rollback_false }}" state: present disable_rollback: false - template_body: "{{ lookup('file','cf_template.json') }}" + template_body: "{{ lookup('file', 'cf_template.json') }}" template_parameters: InstanceType: t3.nano ImageId: "{{ ec2_ami_id }}" @@ -70,7 +70,7 @@ stack_name: "{{ stack_name_disable_rollback_false }}" state: present disable_rollback: false - template_body: "{{ lookup('file','cf_template.json') }}" + template_body: "{{ lookup('file', 'cf_template.json') }}" template_parameters: InstanceType: t3.nano ImageId: "{{ ec2_ami_id }}" @@ -94,7 +94,7 @@ amazon.aws.cloudformation: stack_name: "{{ stack_name }}" state: present - template_body: "{{ lookup('file','cf_template.json') }}" + template_body: "{{ lookup('file', 'cf_template.json') }}" template_parameters: InstanceType: t3.nano ImageId: "{{ ec2_ami_id }}" @@ -112,7 +112,7 @@ amazon.aws.cloudformation: stack_name: "{{ stack_name }}" state: present - template_body: "{{ lookup('file','cf_template.json') }}" + template_body: "{{ lookup('file', 'cf_template.json') }}" template_parameters: InstanceType: t3.nano ImageId: "{{ ec2_ami_id }}" @@ -143,7 +143,7 @@ amazon.aws.cloudformation: stack_name: "{{ stack_name }}-failtest" state: present - template_body: "{{ lookup('file','cf_template.json') }}" + template_body: "{{ lookup('file', 'cf_template.json') }}" disable_rollback: false template_parameters: InstanceType: t3.nano @@ -156,7 +156,7 @@ amazon.aws.cloudformation: stack_name: "{{ stack_name }}-failtest" state: present - template_body: "{{ lookup('file','cf_template.json') }}" + template_body: "{{ lookup('file', 'cf_template.json') }}" disable_rollback: true template_parameters: InstanceType: t3.nano @@ -170,7 +170,7 @@ amazon.aws.cloudformation: stack_name: "{{ stack_name }}-failtest" state: present - template_body: "{{ lookup('file','cf_template.json') }}" + template_body: "{{ lookup('file', 'cf_template.json') }}" disable_rollback: false template_parameters: InstanceType: t3.nano @@ -183,7 +183,7 @@ amazon.aws.cloudformation: stack_name: "{{ stack_name }}-failtest" state: present - template_body: "{{ lookup('file','cf_template.json') }}" + template_body: "{{ lookup('file', 'cf_template.json') }}" disable_rollback: true template_parameters: InstanceType: t3.nano diff --git a/tests/integration/targets/cloudformation/tasks/test_update_termination_protection.yml b/tests/integration/targets/cloudformation/tasks/test_update_termination_protection.yml index a0f329ac4f3..a104a8c4e19 100644 --- a/tests/integration/targets/cloudformation/tasks/test_update_termination_protection.yml +++ b/tests/integration/targets/cloudformation/tasks/test_update_termination_protection.yml @@ -6,7 +6,7 @@ stack_name: "{{ stack_name_update_termination_protection }}" state: present disable_rollback: true - template_body: "{{ lookup('file','cf_template.json') }}" + template_body: "{{ lookup('file', 'cf_template.json') }}" create_changeset: true termination_protection: true template_parameters: @@ -36,7 +36,7 @@ stack_name: "{{ stack_name_update_termination_protection }}" state: present disable_rollback: true - template_body: "{{ lookup('file','cf_template.json') }}" + template_body: "{{ lookup('file', 'cf_template.json') }}" create_changeset: true termination_protection: false template_parameters: @@ -66,7 +66,7 @@ stack_name: "{{ stack_name_update_termination_protection }}" state: present disable_rollback: true - template_body: "{{ lookup('file','cf_template.json') }}" + template_body: "{{ lookup('file', 'cf_template.json') }}" create_changeset: true termination_protection: true template_parameters: @@ -96,7 +96,7 @@ stack_name: "{{ stack_name_update_termination_protection }}" state: present disable_rollback: true - template_body: "{{ lookup('file','cf_template.json') }}" + template_body: "{{ lookup('file', 'cf_template.json') }}" create_changeset: true termination_protection: false template_parameters: diff --git a/tests/integration/targets/cloudtrail/tasks/main.yml b/tests/integration/targets/cloudtrail/tasks/main.yml index a60ececd62d..ee03091a18a 100644 --- a/tests/integration/targets/cloudtrail/tasks/main.yml +++ b/tests/integration/targets/cloudtrail/tasks/main.yml @@ -71,17 +71,17 @@ - '"parameters are required together" in output.msg' - '"cloudwatch_logs_role_arn" in output.msg' - #- name: 'Global Logging must be enabled when enabling Multi-region' - # amazon.aws.cloudtrail: - # state: present - # name: '{{ cloudtrail_name }}' - # include_global_events: no - # is_multi_region_trail: yes - # register: output - # ignore_errors: yes - #- assert: - # that: - # - output is failed + # - name: 'Global Logging must be enabled when enabling Multi-region' + # amazon.aws.cloudtrail: + # state: present + # name: '{{ cloudtrail_name }}' + # include_global_events: no + # is_multi_region_trail: yes + # register: output + # ignore_errors: yes + # - assert: + # that: + # - output is failed # ============================================================ # Preparation @@ -173,7 +173,7 @@ - arn:aws:iam::aws:policy/AWSCloudTrail_FullAccess register: output_cloudwatch_no_kms_role - - name: pause to ensure role exists before attaching policy + - name: Pause to ensure role exists before attaching policy ansible.builtin.pause: seconds: 15 @@ -507,40 +507,40 @@ that: - info.trail_list[0].sns_topic_name == sns_topic+"-2" - #- name: 'Remove SNS Topic (CHECK MODE)' - # amazon.aws.cloudtrail: - # state: present - # name: '{{ cloudtrail_name }}' - # sns_topic_name: '' - # register: output - # check_mode: yes - #- assert: - # that: - # - output is changed - - #- name: 'Remove SNS Topic' - # amazon.aws.cloudtrail: - # state: present - # name: '{{ cloudtrail_name }}' - # sns_topic_name: '' - # register: output - #- assert: - # that: - # - output is changed - # - output.trail.name == cloudtrail_name - # - output.trail.sns_topic_name is none - - #- name: 'Remove SNS Topic (no change)' - # amazon.aws.cloudtrail: - # state: present - # name: '{{ cloudtrail_name }}' - # sns_topic_name: '' - # register: output - #- assert: - # that: - # - output is not changed - # - output.trail.name == cloudtrail_name - # - output.trail.sns_topic_name is none + # - name: 'Remove SNS Topic (CHECK MODE)' + # amazon.aws.cloudtrail: + # state: present + # name: '{{ cloudtrail_name }}' + # sns_topic_name: '' + # register: output + # check_mode: yes + # - assert: + # that: + # - output is changed + + # - name: 'Remove SNS Topic' + # amazon.aws.cloudtrail: + # state: present + # name: '{{ cloudtrail_name }}' + # sns_topic_name: '' + # register: output + # - assert: + # that: + # - output is changed + # - output.trail.name == cloudtrail_name + # - output.trail.sns_topic_name is none + + # - name: 'Remove SNS Topic (no change)' + # amazon.aws.cloudtrail: + # state: present + # name: '{{ cloudtrail_name }}' + # sns_topic_name: '' + # register: output + # - assert: + # that: + # - output is not changed + # - output.trail.name == cloudtrail_name + # - output.trail.sns_topic_name is none # ============================================================ @@ -662,48 +662,48 @@ - info.trail_list[0].cloud_watch_logs_log_group_arn == output_cloudwatch_log_group2.arn - info.trail_list[0].cloud_watch_logs_role_arn == output_cloudwatch_role.iam_role.arn - #- name: 'Remove CloudWatch Log Group (CHECK MODE)' - # amazon.aws.cloudtrail: - # state: present - # name: '{{ cloudtrail_name }}' - # cloudwatch_logs_log_group_arn: '' - # cloudwatch_logs_role_arn: '' - # register: output - # check_mode: yes - #- assert: - # that: - # - output is changed - # - output.trail.name == cloudtrail_name - # - output.trail.cloud_watch_logs_log_group_arn is none - # - output.trail.cloud_watch_logs_role_arn is none - - #- name: 'Remove CloudWatch Log Group' - # amazon.aws.cloudtrail: - # state: present - # name: '{{ cloudtrail_name }}' - # cloudwatch_logs_log_group_arn: '' - # cloudwatch_logs_role_arn: '' - # register: output - #- assert: - # that: - # - output is changed - # - output.trail.name == cloudtrail_name - # - output.trail.cloud_watch_logs_log_group_arn is none - # - output.trail.cloud_watch_logs_role_arn is none - - #- name: 'Remove CloudWatch Log Group (no change)' - # amazon.aws.cloudtrail: - # state: present - # name: '{{ cloudtrail_name }}' - # cloudwatch_logs_log_group_arn: '' - # cloudwatch_logs_role_arn: '' - # register: output - #- assert: - # that: - # - output is not changed - # - output.trail.name == cloudtrail_name - # - output.trail.cloud_watch_logs_log_group_arn is none - # - output.trail.cloud_watch_logs_role_arn is none + # - name: 'Remove CloudWatch Log Group (CHECK MODE)' + # amazon.aws.cloudtrail: + # state: present + # name: '{{ cloudtrail_name }}' + # cloudwatch_logs_log_group_arn: '' + # cloudwatch_logs_role_arn: '' + # register: output + # check_mode: yes + # - assert: + # that: + # - output is changed + # - output.trail.name == cloudtrail_name + # - output.trail.cloud_watch_logs_log_group_arn is none + # - output.trail.cloud_watch_logs_role_arn is none + + # - name: 'Remove CloudWatch Log Group' + # amazon.aws.cloudtrail: + # state: present + # name: '{{ cloudtrail_name }}' + # cloudwatch_logs_log_group_arn: '' + # cloudwatch_logs_role_arn: '' + # register: output + # - assert: + # that: + # - output is changed + # - output.trail.name == cloudtrail_name + # - output.trail.cloud_watch_logs_log_group_arn is none + # - output.trail.cloud_watch_logs_role_arn is none + + # - name: 'Remove CloudWatch Log Group (no change)' + # amazon.aws.cloudtrail: + # state: present + # name: '{{ cloudtrail_name }}' + # cloudwatch_logs_log_group_arn: '' + # cloudwatch_logs_role_arn: '' + # register: output + # - assert: + # that: + # - output is not changed + # - output.trail.name == cloudtrail_name + # - output.trail.cloud_watch_logs_log_group_arn is none + # - output.trail.cloud_watch_logs_role_arn is none # ============================================================ @@ -1333,16 +1333,16 @@ role_arn: "{{ output_cloudwatch_no_kms_role.iam_role.arn }}" role_session_name: cloudtrailNoKms region: "{{ aws_region }}" - register: noKms_assumed_role + register: no_kms_assumed_role - name: Enable logging encryption w/ alias (no change, no kms permmissions, check mode) amazon.aws.cloudtrail: state: present name: "{{ cloudtrail_name }}" kms_key_id: alias/{{ kms_alias }} - access_key: "{{ noKms_assumed_role.sts_creds.access_key }}" - secret_key: "{{ noKms_assumed_role.sts_creds.secret_key }}" - session_token: "{{ noKms_assumed_role.sts_creds.session_token }}" + access_key: "{{ no_kms_assumed_role.sts_creds.access_key }}" + secret_key: "{{ no_kms_assumed_role.sts_creds.secret_key }}" + session_token: "{{ no_kms_assumed_role.sts_creds.session_token }}" check_mode: true register: output - ansible.builtin.assert: @@ -1445,7 +1445,7 @@ - ansible.builtin.assert: that: - output is changed - #- output.exists == True + # - output.exists == True - output.trail.name == cloudtrail_name - output.trail.home_region == aws_region - output.trail.include_global_service_events == True diff --git a/tests/integration/targets/cloudtrail/tasks/tagging.yml b/tests/integration/targets/cloudtrail/tasks/tagging.yml index 0d1503a5241..44d762577f5 100644 --- a/tests/integration/targets/cloudtrail/tasks/tagging.yml +++ b/tests/integration/targets/cloudtrail/tasks/tagging.yml @@ -37,45 +37,45 @@ block: ### - - name: test adding tags to cloudtrail (check mode) + - name: Test adding tags to cloudtrail (check mode) amazon.aws.cloudtrail: tags: "{{ first_tags }}" purge_tags: true register: update_result check_mode: true - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is changed - - name: test adding tags to cloudtrail + - name: Test adding tags to cloudtrail amazon.aws.cloudtrail: tags: "{{ first_tags }}" purge_tags: true register: update_result - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is changed - update_result.trail.tags == first_tags - - name: test adding tags to cloudtrail - idempotency (check mode) + - name: Test adding tags to cloudtrail - idempotency (check mode) amazon.aws.cloudtrail: tags: "{{ first_tags }}" purge_tags: true register: update_result check_mode: true - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is not changed - - name: test adding tags to cloudtrail - idempotency + - name: Test adding tags to cloudtrail - idempotency amazon.aws.cloudtrail: tags: "{{ first_tags }}" purge_tags: true register: update_result - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is not changed @@ -83,45 +83,45 @@ ### - - name: test updating tags with purge on cloudtrail (check mode) + - name: Test updating tags with purge on cloudtrail (check mode) amazon.aws.cloudtrail: tags: "{{ second_tags }}" purge_tags: true register: update_result check_mode: true - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is changed - - name: test updating tags with purge on cloudtrail + - name: Test updating tags with purge on cloudtrail amazon.aws.cloudtrail: tags: "{{ second_tags }}" purge_tags: true register: update_result - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is changed - update_result.trail.tags == second_tags - - name: test updating tags with purge on cloudtrail - idempotency (check mode) + - name: Test updating tags with purge on cloudtrail - idempotency (check mode) amazon.aws.cloudtrail: tags: "{{ second_tags }}" purge_tags: true register: update_result check_mode: true - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is not changed - - name: test updating tags with purge on cloudtrail - idempotency + - name: Test updating tags with purge on cloudtrail - idempotency amazon.aws.cloudtrail: tags: "{{ second_tags }}" purge_tags: true register: update_result - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is not changed @@ -129,45 +129,45 @@ ### - - name: test updating tags without purge on cloudtrail (check mode) + - name: Test updating tags without purge on cloudtrail (check mode) amazon.aws.cloudtrail: tags: "{{ third_tags }}" purge_tags: false register: update_result check_mode: true - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is changed - - name: test updating tags without purge on cloudtrail + - name: Test updating tags without purge on cloudtrail amazon.aws.cloudtrail: tags: "{{ third_tags }}" purge_tags: false register: update_result - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is changed - update_result.trail.tags == final_tags - - name: test updating tags without purge on cloudtrail - idempotency (check mode) + - name: Test updating tags without purge on cloudtrail - idempotency (check mode) amazon.aws.cloudtrail: tags: "{{ third_tags }}" purge_tags: false register: update_result check_mode: true - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is not changed - - name: test updating tags without purge on cloudtrail - idempotency + - name: Test updating tags without purge on cloudtrail - idempotency amazon.aws.cloudtrail: tags: "{{ third_tags }}" purge_tags: false register: update_result - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is not changed @@ -185,20 +185,20 @@ # # ### - - name: test no tags param cloudtrail (check mode) + - name: Test no tags param cloudtrail (check mode) amazon.aws.cloudtrail: {} register: update_result check_mode: true - - name: assert no change + - name: Assert no change ansible.builtin.assert: that: - update_result is not changed - update_result.trail.tags == final_tags - - name: test no tags param cloudtrail + - name: Test no tags param cloudtrail amazon.aws.cloudtrail: {} register: update_result - - name: assert no change + - name: Assert no change ansible.builtin.assert: that: - update_result is not changed @@ -206,45 +206,45 @@ ### - - name: test removing tags from cloudtrail (check mode) + - name: Test removing tags from cloudtrail (check mode) amazon.aws.cloudtrail: tags: {} purge_tags: true register: update_result check_mode: true - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is changed - - name: test removing tags from cloudtrail + - name: Test removing tags from cloudtrail amazon.aws.cloudtrail: tags: {} purge_tags: true register: update_result - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is changed - update_result.trail.tags == {} - - name: test removing tags from cloudtrail - idempotency (check mode) + - name: Test removing tags from cloudtrail - idempotency (check mode) amazon.aws.cloudtrail: tags: {} purge_tags: true register: update_result check_mode: true - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is not changed - - name: test removing tags from cloudtrail - idempotency + - name: Test removing tags from cloudtrail - idempotency amazon.aws.cloudtrail: tags: {} purge_tags: true register: update_result - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is not changed diff --git a/tests/integration/targets/cloudwatch_metric_alarm/tasks/env_cleanup.yml b/tests/integration/targets/cloudwatch_metric_alarm/tasks/env_cleanup.yml index 5f1d0db2d8b..eb2c044e778 100644 --- a/tests/integration/targets/cloudwatch_metric_alarm/tasks/env_cleanup.yml +++ b/tests/integration/targets/cloudwatch_metric_alarm/tasks/env_cleanup.yml @@ -1,5 +1,5 @@ --- -- name: remove any instances in the test VPC +- name: Remove any instances in the test VPC amazon.aws.ec2_instance: filters: vpc_id: "{{ testing_vpc.vpc.id }}" @@ -9,13 +9,13 @@ ignore_errors: true retries: 10 -- name: remove ENIs +- name: Remove ENIs amazon.aws.ec2_eni_info: filters: vpc-id: "{{ testing_vpc.vpc.id }}" register: enis -- name: delete all ENIs +- name: Delete all ENIs amazon.aws.ec2_eni: eni_id: "{{ item.id }}" state: absent @@ -24,7 +24,7 @@ ignore_errors: true retries: 10 -- name: remove the security group +- name: Remove the security group amazon.aws.ec2_security_group: name: "{{ resource_prefix }}-sg" description: a security group for ansible tests @@ -35,7 +35,7 @@ ignore_errors: true retries: 10 -- name: remove routing rules +- name: Remove routing rules amazon.aws.ec2_vpc_route_table: state: absent vpc_id: "{{ testing_vpc.vpc.id }}" @@ -52,7 +52,7 @@ ignore_errors: true retries: 10 -- name: remove internet gateway +- name: Remove internet gateway amazon.aws.ec2_vpc_igw: vpc_id: "{{ testing_vpc.vpc.id }}" state: absent @@ -61,7 +61,7 @@ ignore_errors: true retries: 10 -- name: remove subnet A +- name: Remove subnet A amazon.aws.ec2_vpc_subnet: state: absent vpc_id: "{{ testing_vpc.vpc.id }}" @@ -71,7 +71,7 @@ ignore_errors: true retries: 10 -- name: remove subnet B +- name: Remove subnet B amazon.aws.ec2_vpc_subnet: state: absent vpc_id: "{{ testing_vpc.vpc.id }}" @@ -81,7 +81,7 @@ ignore_errors: true retries: 10 -- name: remove the VPC +- name: Remove the VPC amazon.aws.ec2_vpc_net: name: "{{ resource_prefix }}-vpc" cidr_block: 10.22.32.0/23 diff --git a/tests/integration/targets/cloudwatch_metric_alarm/tasks/env_setup.yml b/tests/integration/targets/cloudwatch_metric_alarm/tasks/env_setup.yml index fe31e042594..eabc7572571 100644 --- a/tests/integration/targets/cloudwatch_metric_alarm/tasks/env_setup.yml +++ b/tests/integration/targets/cloudwatch_metric_alarm/tasks/env_setup.yml @@ -34,7 +34,7 @@ Name: "{{ resource_prefix }}-subnet-b" register: testing_subnet_b -- name: create routing rules +- name: Create routing rules amazon.aws.ec2_vpc_route_table: vpc_id: "{{ testing_vpc.vpc.id }}" tags: @@ -46,7 +46,7 @@ - "{{ testing_subnet_a.subnet.id }}" - "{{ testing_subnet_b.subnet.id }}" -- name: create a security group with the vpc +- name: Create a security group with the vpc amazon.aws.ec2_security_group: name: "{{ resource_prefix }}-sg" description: a security group for ansible tests diff --git a/tests/integration/targets/cloudwatch_metric_alarm/tasks/main.yml b/tests/integration/targets/cloudwatch_metric_alarm/tasks/main.yml index 1c5e15b411f..fafe7f1ed30 100644 --- a/tests/integration/targets/cloudwatch_metric_alarm/tasks/main.yml +++ b/tests/integration/targets/cloudwatch_metric_alarm/tasks/main.yml @@ -1,5 +1,5 @@ --- -- name: run cloudwatch_metric_alarm tests +- name: Run cloudwatch_metric_alarm tests module_defaults: group/aws: access_key: "{{ aws_access_key }}" @@ -10,9 +10,9 @@ - ansible.builtin.set_fact: alarm_full_name: "{{ alarm_prefix }}-{{ resource_prefix }}-cpu-low" - - name: set up environment for testing. + - name: Set up environment for testing. ansible.builtin.include_tasks: env_setup.yml - - name: get info on alarms + - name: Get info on alarms amazon.aws.cloudwatch_metric_alarm_info: alarm_names: - "{{ alarm_full_name }}" @@ -30,12 +30,12 @@ wait: true register: ec2_instance_results - - name: ensure alarm doesn't exist for a clean test + - name: Ensure alarm doesn't exist for a clean test amazon.aws.cloudwatch_metric_alarm: state: absent name: "{{ alarm_full_name }}" - - name: create ec2 metric alarm on ec2 instance (check mode) + - name: Create ec2 metric alarm on ec2 instance (check mode) amazon.aws.cloudwatch_metric_alarm: dimensions: InstanceId: "{{ ec2_instance_results.instances[0].instance_id }}" @@ -55,20 +55,20 @@ check_mode: true register: ec2_instance_metric_alarm_check - - name: get info on alarms + - name: Get info on alarms amazon.aws.cloudwatch_metric_alarm_info: alarm_names: - "{{ alarm_full_name }}" register: alarm_info_check - - name: verify that an alarm was not created in check mode + - name: Verify that an alarm was not created in check mode ansible.builtin.assert: that: - ec2_instance_metric_alarm_check.changed - not ec2_instance_metric_alarm_check.alarm_arn - alarm_info_check.metric_alarms | length == 0 - - name: create ec2 metric alarm on ec2 instance + - name: Create ec2 metric alarm on ec2 instance amazon.aws.cloudwatch_metric_alarm: dimensions: InstanceId: "{{ ec2_instance_results.instances[0].instance_id }}" @@ -87,13 +87,13 @@ description: This will alarm when an instance's cpu usage average is lower than 5% for 10 of 15 minutes register: ec2_instance_metric_alarm - - name: get info on alarms + - name: Get info on alarms amazon.aws.cloudwatch_metric_alarm_info: alarm_names: - "{{ alarm_full_name }}" register: alarm_info - - name: verify that an alarm was created + - name: Verify that an alarm was created ansible.builtin.assert: that: - ec2_instance_metric_alarm.changed @@ -111,7 +111,7 @@ - ec2_instance_metric_alarm.description == alarm_info.metric_alarms[0].alarm_description - ec2_instance_metric_alarm.treat_missing_data == alarm_info.metric_alarms[0].treat_missing_data - - name: create ec2 metric alarm on ec2 instance (idempotent) (check mode) + - name: Create ec2 metric alarm on ec2 instance (idempotent) (check mode) amazon.aws.cloudwatch_metric_alarm: dimensions: InstanceId: "{{ ec2_instance_results.instances[0].instance_id }}" @@ -131,7 +131,7 @@ check_mode: true register: ec2_instance_metric_alarm_idempotent_check - - name: get info on alarms + - name: Get info on alarms amazon.aws.cloudwatch_metric_alarm_info: alarm_names: - "{{ alarm_full_name }}" @@ -161,7 +161,7 @@ - alarm_description - treat_missing_data - - name: create ec2 metric alarm on ec2 instance (idempotent) + - name: Create ec2 metric alarm on ec2 instance (idempotent) amazon.aws.cloudwatch_metric_alarm: dimensions: InstanceId: "{{ ec2_instance_results.instances[0].instance_id }}" @@ -180,7 +180,7 @@ description: This will alarm when an instance's cpu usage average is lower than 5% for 10 of 15 minutes register: ec2_instance_metric_alarm_idempotent - - name: get info on alarms + - name: Get info on alarms amazon.aws.cloudwatch_metric_alarm_info: alarm_names: - "{{ alarm_full_name }}" @@ -210,7 +210,7 @@ - alarm_description - treat_missing_data - - name: update alarm (check mode) + - name: Update alarm (check mode) amazon.aws.cloudwatch_metric_alarm: dimensions: InstanceId: "{{ ec2_instance_results.instances[0].instance_id }}" @@ -230,12 +230,12 @@ check_mode: true register: ec2_instance_metric_alarm_update_check - - name: verify that alarm registers as updated in check mode + - name: Verify that alarm registers as updated in check mode ansible.builtin.assert: that: - ec2_instance_metric_alarm_check.changed - - name: verify that properties were not changed in check mode + - name: Verify that properties were not changed in check mode ansible.builtin.assert: that: - ec2_instance_metric_alarm_update_check.changed @@ -253,7 +253,7 @@ - ec2_instance_metric_alarm_update_check.evaluation_periods == alarm_info.metric_alarms[0].evaluation_periods - ec2_instance_metric_alarm_update_check.treat_missing_data == alarm_info.metric_alarms[0].treat_missing_data - - name: update alarm + - name: Update alarm amazon.aws.cloudwatch_metric_alarm: dimensions: InstanceId: "{{ ec2_instance_results.instances[0].instance_id }}" @@ -272,12 +272,12 @@ description: This will alarm when an instance's cpu usage percentage is greater than or equal to 50% for 3 minutes register: ec2_instance_metric_alarm_update - - name: verify that alarm registers as updated + - name: Verify that alarm registers as updated ansible.builtin.assert: that: - ec2_instance_metric_alarm.changed - - name: verify that properties were changed + - name: Verify that properties were changed ansible.builtin.assert: that: - ec2_instance_metric_alarm_update.changed @@ -295,7 +295,7 @@ - ec2_instance_metric_alarm_update.evaluation_periods == alarm_info.metric_alarms[0].evaluation_periods - ec2_instance_metric_alarm_update.treat_missing_data == alarm_info.metric_alarms[0].treat_missing_data - - name: try to remove the alarm (check mode) + - name: Try to remove the alarm (check mode) amazon.aws.cloudwatch_metric_alarm: state: absent name: "{{ alarm_full_name }}" @@ -307,7 +307,7 @@ that: - ec2_instance_metric_alarm_deletion_check.changed - - name: get info on alarms + - name: Get info on alarms amazon.aws.cloudwatch_metric_alarm_info: alarm_names: - "{{ alarm_full_name }}" @@ -318,7 +318,7 @@ that: - alarm_info.metric_alarms | length > 0 - - name: try to remove the alarm + - name: Try to remove the alarm amazon.aws.cloudwatch_metric_alarm: state: absent name: "{{ alarm_full_name }}" @@ -329,7 +329,7 @@ that: - ec2_instance_metric_alarm_deletion.changed - - name: get info on alarms + - name: Get info on alarms amazon.aws.cloudwatch_metric_alarm_info: alarm_names: - "{{ alarm_full_name }}" @@ -340,7 +340,7 @@ that: - alarm_info.metric_alarms | length == 0 - - name: create ec2 metric alarm with no unit on ec2 instance + - name: Create ec2 metric alarm with no unit on ec2 instance amazon.aws.cloudwatch_metric_alarm: dimensions: InstanceId: "{{ ec2_instance_results.instances[0].instance_id }}" @@ -358,13 +358,13 @@ description: This will alarm when an instance's cpu usage average is lower than 5% for 10 of 15 minutes register: ec2_instance_metric_alarm_no_unit - - name: get info on alarms + - name: Get info on alarms amazon.aws.cloudwatch_metric_alarm_info: alarm_names: - "{{ alarm_full_name }}" register: alarm_info_no_unit - - name: verify that an alarm was created + - name: Verify that an alarm was created ansible.builtin.assert: that: - ec2_instance_metric_alarm_no_unit.changed @@ -382,7 +382,7 @@ - ec2_instance_metric_alarm_no_unit.description == alarm_info_no_unit.metric_alarms[0].alarm_description - ec2_instance_metric_alarm_no_unit.treat_missing_data == alarm_info_no_unit.metric_alarms[0].treat_missing_data - - name: try to remove the alarm + - name: Try to remove the alarm amazon.aws.cloudwatch_metric_alarm: state: absent name: "{{ alarm_full_name }}" @@ -393,7 +393,7 @@ that: - ec2_instance_metric_alarm_deletion.changed - - name: get info on alarms + - name: Get info on alarms amazon.aws.cloudwatch_metric_alarm_info: alarm_names: - "{{ alarm_full_name }}" @@ -404,7 +404,7 @@ that: - alarm_info.metric_alarms | length == 0 - - name: create ec2 metric alarm with metrics + - name: Create ec2 metric alarm with metrics amazon.aws.cloudwatch_metric_alarm: state: present name: "{{ alarm_full_name }}" @@ -429,13 +429,13 @@ return_data: true register: ec2_instance_metric_alarm_metrics - - name: get info on alarms + - name: Get info on alarms amazon.aws.cloudwatch_metric_alarm_info: alarm_names: - "{{ alarm_full_name }}" register: alarm_info_metrics - - name: verify that an alarm was created + - name: Verify that an alarm was created ansible.builtin.assert: that: - ec2_instance_metric_alarm_metrics.changed @@ -450,7 +450,7 @@ - ec2_instance_metric_alarm_metrics.metrics[0].metric_stat.unit == alarm_info_metrics.metric_alarms[0].metrics[0].metric_stat.unit - ec2_instance_metric_alarm_metrics.metrics[0].return_data == alarm_info_metrics.metric_alarms[0].metrics[0].return_data - - name: try to remove the alarm + - name: Try to remove the alarm amazon.aws.cloudwatch_metric_alarm: state: absent name: "{{ alarm_full_name }}" @@ -461,7 +461,7 @@ that: - ec2_instance_metric_alarm_deletion_no_unit.changed - - name: get info on alarms + - name: Get info on alarms amazon.aws.cloudwatch_metric_alarm_info: alarm_names: - "{{ alarm_full_name }}" @@ -472,7 +472,7 @@ that: - alarm_info_no_unit.metric_alarms | length == 0 - - name: create ec2 metric alarm by providing mutually exclusive values + - name: Create ec2 metric alarm by providing mutually exclusive values amazon.aws.cloudwatch_metric_alarm: dimensions: InstanceId: "{{ ec2_instance_results.instances[0].instance_id }}" @@ -509,10 +509,10 @@ - ec2_instance_metric_mutually_exclusive.failed - '"parameters are mutually exclusive" in ec2_instance_metric_mutually_exclusive.msg' - - name: create alarm without dimensions + - name: Create alarm without dimensions amazon.aws.cloudwatch_metric_alarm: state: present - name: '{{ alarm_full_name }}' + name: "{{ alarm_full_name }}" metric: CPUUtilization namespace: AWS/EC2 treat_missing_data: missing @@ -522,26 +522,25 @@ period: 300 evaluation_periods: 3 unit: Percent - description: This will alarm when an instance's cpu usage average is lower than - 5% for 15 minutes + description: This will alarm when an instance's cpu usage average is lower than 5% for 15 minutes register: ec2_instance_metric_alarm_no_dimensions - - name: get info on alarm without dimensions + - name: Get info on alarm without dimensions amazon.aws.cloudwatch_metric_alarm_info: alarm_names: - "{{ alarm_full_name }}" register: alarm_info_metrics_alarm_no_dimensions - - name: verify that an alarm was created without dimensions + - name: Verify that an alarm was created without dimensions ansible.builtin.assert: that: - ec2_instance_metric_alarm_no_dimensions.changed - alarm_info_metrics_alarm_no_dimensions.metric_alarms[0].dimensions | length == 0 - - name: create alarm without dimensions (idempotent) + - name: Create alarm without dimensions (idempotent) amazon.aws.cloudwatch_metric_alarm: state: present - name: '{{ alarm_full_name }}' + name: "{{ alarm_full_name }}" metric: CPUUtilization namespace: AWS/EC2 treat_missing_data: missing @@ -551,23 +550,22 @@ period: 300 evaluation_periods: 3 unit: Percent - description: This will alarm when an instance's cpu usage average is lower than - 5% for 15 minutes + description: This will alarm when an instance's cpu usage average is lower than 5% for 15 minutes register: ec2_instance_metric_alarm_no_dimensions_idempotent - name: "Verify alarm without dimensions does not register as changed after update" - assert: + ansible.builtin.assert: that: - not ec2_instance_metric_alarm_no_dimensions_idempotent.changed always: - - name: try to delete the alarm + - name: Try to delete the alarm amazon.aws.cloudwatch_metric_alarm: state: absent name: "{{ alarm_full_name }}" ignore_errors: true - - name: try to stop the ec2 instance + - name: Try to stop the ec2 instance amazon.aws.ec2_instance: instance_ids: "{{ ec2_instance_results.instances[0].instance_id }}" state: terminated diff --git a/tests/integration/targets/cloudwatchevent_rule/tasks/main.yml b/tests/integration/targets/cloudwatchevent_rule/tasks/main.yml index 70183c14aad..36eb3e819cd 100644 --- a/tests/integration/targets/cloudwatchevent_rule/tasks/main.yml +++ b/tests/integration/targets/cloudwatchevent_rule/tasks/main.yml @@ -7,7 +7,6 @@ region: "{{ aws_region }}" block: - - name: Run tests for testing json input_template ansible.builtin.import_tasks: test_json_input_template.yml diff --git a/tests/integration/targets/cloudwatchevent_rule/tasks/test_json_input_template.yml b/tests/integration/targets/cloudwatchevent_rule/tasks/test_json_input_template.yml index d72fa3c8e6e..6b76721a3b5 100644 --- a/tests/integration/targets/cloudwatchevent_rule/tasks/test_json_input_template.yml +++ b/tests/integration/targets/cloudwatchevent_rule/tasks/test_json_input_template.yml @@ -1,7 +1,6 @@ --- - name: Run tests for json input_template block: - - name: Create SNS topic community.aws.sns_topic: name: TestSNSTopic-Json @@ -73,4 +72,4 @@ - name: Delete SNS topic community.aws.sns_topic: name: TestSNSTopic-Json - state: absent \ No newline at end of file + state: absent diff --git a/tests/integration/targets/cloudwatchlogs/tasks/cloudwatchlogs_tests.yml b/tests/integration/targets/cloudwatchlogs/tasks/cloudwatchlogs_tests.yml index e127b76a130..fe39567c2d9 100644 --- a/tests/integration/targets/cloudwatchlogs/tasks/cloudwatchlogs_tests.yml +++ b/tests/integration/targets/cloudwatchlogs/tasks/cloudwatchlogs_tests.yml @@ -1,14 +1,15 @@ --- # Tests for changes to the cloudwatchlogs_log_group and cloudwatchlogs_log_group_metric_filter -- block: - - name: create cloudwatch log group for integration test +- ignore_errors: true + block: + - name: Create cloudwatch log group for integration test amazon.aws.cloudwatchlogs_log_group: state: present log_group_name: "{{ log_group_name }}" retention: 1 - - name: check_mode set metric filter on '{{ log_group_name }}' + - name: Check_mode set metric filter on '{{ log_group_name }}' amazon.aws.cloudwatchlogs_log_group_metric_filter: log_group_name: "{{ log_group_name }}" filter_name: "{{ filter_name }}" @@ -21,13 +22,13 @@ check_mode: true register: out - - name: check_mode state must be changed + - name: Check_mode state must be changed ansible.builtin.assert: that: - out is changed - out.metric_filters | count == 1 - - name: set metric filter on '{{ log_group_name }}' + - name: Set metric filter on '{{ log_group_name }}' amazon.aws.cloudwatchlogs_log_group_metric_filter: log_group_name: "{{ log_group_name }}" filter_name: "{{ filter_name }}" @@ -39,13 +40,13 @@ metric_value: $.value register: out - - name: create metric filter + - name: Create metric filter ansible.builtin.assert: that: - out is changed - out.metric_filters | count == 1 - - name: re-set metric filter on '{{ log_group_name }}' + - name: Re-set metric filter on '{{ log_group_name }}' amazon.aws.cloudwatchlogs_log_group_metric_filter: log_group_name: "{{ log_group_name }}" filter_name: "{{ filter_name }}" @@ -57,12 +58,12 @@ metric_value: $.value register: out - - name: metric filter must not change + - name: Metric filter must not change ansible.builtin.assert: that: - out is not changed - - name: update metric transformation on '{{ log_group_name }}' + - name: Update metric transformation on '{{ log_group_name }}' amazon.aws.cloudwatchlogs_log_group_metric_filter: log_group_name: "{{ log_group_name }}" filter_name: "{{ filter_name }}" @@ -75,14 +76,14 @@ default_value: 3.1415 register: out - - name: update metric filter + - name: Update metric filter ansible.builtin.assert: that: - out is changed - out.metric_filters[0].metric_namespace == "made_with_ansible" - out.metric_filters[0].default_value == 3.1415 - - name: update filter_pattern on '{{ log_group_name }}' + - name: Update filter_pattern on '{{ log_group_name }}' amazon.aws.cloudwatchlogs_log_group_metric_filter: log_group_name: "{{ log_group_name }}" filter_name: "{{ filter_name }}" @@ -94,7 +95,7 @@ metric_value: $.value register: out - - name: update metric filter + - name: Update metric filter ansible.builtin.assert: that: - out is changed @@ -189,7 +190,7 @@ - out is failed - out.msg == "default_value and dimensions are mutually exclusive." - - name: checkmode delete metric filter on '{{ log_group_name }}' + - name: Checkmode delete metric filter on '{{ log_group_name }}' amazon.aws.cloudwatchlogs_log_group_metric_filter: log_group_name: "{{ log_group_name }}" filter_name: "{{ filter_name }}" @@ -197,44 +198,43 @@ check_mode: true register: out - - name: check_mode state must be changed + - name: Check_mode state must be changed ansible.builtin.assert: that: - out is changed - - name: delete metric filter on '{{ log_group_name }}' + - name: Delete metric filter on '{{ log_group_name }}' amazon.aws.cloudwatchlogs_log_group_metric_filter: log_group_name: "{{ log_group_name }}" filter_name: "{{ filter_name }}" state: absent register: out - - name: delete metric filter + - name: Delete metric filter ansible.builtin.assert: that: - out is changed - - name: delete metric filter on '{{ log_group_name }}' which does not exist + - name: Delete metric filter on group which doesn't exist any more amazon.aws.cloudwatchlogs_log_group_metric_filter: log_group_name: "{{ log_group_name }}" filter_name: "{{ filter_name }}" state: absent register: out - - name: delete metric filter + - name: Delete metric filter ansible.builtin.assert: that: - out is not changed always: - - name: delete metric filter + - name: Delete metric filter amazon.aws.cloudwatchlogs_log_group_metric_filter: log_group_name: "{{ log_group_name }}" filter_name: "{{ filter_name }}" state: absent - - name: delete cloudwatch log group for integration test + - name: Delete cloudwatch log group for integration test amazon.aws.cloudwatchlogs_log_group: state: absent log_group_name: "{{ log_group_name }}" - ignore_errors: true diff --git a/tests/integration/targets/cloudwatchlogs/tasks/create-delete-tags.yml b/tests/integration/targets/cloudwatchlogs/tasks/create-delete-tags.yml index 700cf4e806a..a71d6d20d8a 100644 --- a/tests/integration/targets/cloudwatchlogs/tasks/create-delete-tags.yml +++ b/tests/integration/targets/cloudwatchlogs/tasks/create-delete-tags.yml @@ -36,7 +36,7 @@ amazon.aws.cloudwatchlogs_log_group_info: log_group_name: "{{ log_group_name }}" block: - - name: create cloudwatch log group for integration test (check_mode) + - name: Create cloudwatch log group for integration test (check_mode) amazon.aws.cloudwatchlogs_log_group: state: present log_group_name: "{{ log_group_name }}" @@ -53,7 +53,7 @@ - '"log_groups" not in result' - '"logs:CreateLogGroup" not in result.resource_actions' - - name: create cloudwatch log group for integration test + - name: Create cloudwatch log group for integration test amazon.aws.cloudwatchlogs_log_group: state: present log_group_name: "{{ log_group_name }}" @@ -88,7 +88,7 @@ vars: log_group: "{{ result.log_groups[0] }}" - - name: create cloudwatch log group for integration test (check_mode - idempotent) + - name: Create cloudwatch log group for integration test (check_mode - idempotent) amazon.aws.cloudwatchlogs_log_group: state: present log_group_name: "{{ log_group_name }}" @@ -102,7 +102,7 @@ - '"log_groups" in result' - result.log_groups | length == 1 - - name: create cloudwatch log group for integration test (idempotent) + - name: Create cloudwatch log group for integration test (idempotent) amazon.aws.cloudwatchlogs_log_group: state: present log_group_name: "{{ log_group_name }}" @@ -117,7 +117,7 @@ vars: log_group: "{{ result.log_groups[0] }}" - - name: describe all log groups + - name: Describe all log groups amazon.aws.cloudwatchlogs_log_group_info: {} register: result @@ -126,7 +126,7 @@ - '"log_groups" in result' - result.log_groups | length >= 1 - - name: describe log group + - name: Describe log group amazon.aws.cloudwatchlogs_log_group_info: log_group_name: "{{ log_group_name }}" register: result @@ -145,51 +145,51 @@ - '"tags" in log_group' vars: log_group: "{{ result.log_groups[0] }}" - - name: test adding tags to cloudwatchlogs_log_group (check_mode) + - name: Test adding tags to cloudwatchlogs_log_group (check_mode) amazon.aws.cloudwatchlogs_log_group: tags: "{{ first_tags }}" purge_tags: true check_mode: true register: update_result - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is changed - '"logs:UntagLogGroup" not in update_result' - '"logs:TagLogGroup" not in update_result' - - name: test adding tags to cloudwatchlogs_log_group + - name: Test adding tags to cloudwatchlogs_log_group amazon.aws.cloudwatchlogs_log_group: tags: "{{ first_tags }}" purge_tags: true register: update_result - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is changed - update_result.log_groups[0].tags == first_tags - - name: test adding tags to cloudwatchlogs_log_group - idempotency (check mode) + - name: Test adding tags to cloudwatchlogs_log_group - idempotency (check mode) amazon.aws.cloudwatchlogs_log_group: tags: "{{ first_tags }}" purge_tags: true check_mode: true register: update_result - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is not changed - '"logs:UntagLogGroup" not in update_result' - '"logs:TagLogGroup" not in update_result' - - name: test adding tags to cloudwatchlogs_log_group - idempotency + - name: Test adding tags to cloudwatchlogs_log_group - idempotency amazon.aws.cloudwatchlogs_log_group: tags: "{{ first_tags }}" purge_tags: true register: update_result - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is not changed @@ -197,51 +197,51 @@ ### - - name: test updating tags with purge on cloudwatchlogs_log_group (check mode) + - name: Test updating tags with purge on cloudwatchlogs_log_group (check mode) amazon.aws.cloudwatchlogs_log_group: tags: "{{ second_tags }}" purge_tags: true check_mode: true register: update_result - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is changed - '"logs:UntagLogGroup" not in update_result' - '"logs:TagLogGroup" not in update_result' - - name: test updating tags with purge on cloudwatchlogs_log_group + - name: Test updating tags with purge on cloudwatchlogs_log_group amazon.aws.cloudwatchlogs_log_group: tags: "{{ second_tags }}" purge_tags: true register: update_result - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is changed - update_result.log_groups[0].tags == second_tags - - name: test updating tags with purge on cloudwatchlogs_log_group - idempotency (check mode) + - name: Test updating tags with purge on cloudwatchlogs_log_group - idempotency (check mode) amazon.aws.cloudwatchlogs_log_group: tags: "{{ second_tags }}" purge_tags: true check_mode: true register: update_result - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is not changed - '"logs:UntagLogGroup" not in update_result' - '"logs:TagLogGroup" not in update_result' - - name: test updating tags with purge on cloudwatchlogs_log_group - idempotency + - name: Test updating tags with purge on cloudwatchlogs_log_group - idempotency amazon.aws.cloudwatchlogs_log_group: tags: "{{ second_tags }}" purge_tags: true register: update_result - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is not changed @@ -249,51 +249,51 @@ ### - - name: test updating tags without purge on cloudwatchlogs_log_group (check mode) + - name: Test updating tags without purge on cloudwatchlogs_log_group (check mode) amazon.aws.cloudwatchlogs_log_group: tags: "{{ third_tags }}" purge_tags: false check_mode: true register: update_result - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is changed - '"logs:UntagLogGroup" not in update_result' - '"logs:TagLogGroup" not in update_result' - - name: test updating tags without purge on cloudwatchlogs_log_group + - name: Test updating tags without purge on cloudwatchlogs_log_group amazon.aws.cloudwatchlogs_log_group: tags: "{{ third_tags }}" purge_tags: false register: update_result - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is changed - update_result.log_groups[0].tags == final_tags - - name: test updating tags without purge on cloudwatchlogs_log_group - idempotency (check mode) + - name: Test updating tags without purge on cloudwatchlogs_log_group - idempotency (check mode) amazon.aws.cloudwatchlogs_log_group: tags: "{{ third_tags }}" purge_tags: false check_mode: true register: update_result - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is not changed - '"logs:UntagLogGroup" not in update_result' - '"logs:TagLogGroup" not in update_result' - - name: test updating tags without purge on cloudwatchlogs_log_group - idempotency + - name: Test updating tags without purge on cloudwatchlogs_log_group - idempotency amazon.aws.cloudwatchlogs_log_group: tags: "{{ third_tags }}" purge_tags: false register: update_result - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is not changed @@ -301,10 +301,10 @@ ### - - name: test that cloudwatchlogs_log_group_info returns the tags + - name: Test that cloudwatchlogs_log_group_info returns the tags amazon.aws.cloudwatchlogs_log_group_info: register: tag_info - - name: assert tags present + - name: Assert tags present ansible.builtin.assert: that: - tag_info.log_groups | length == 1 @@ -312,21 +312,21 @@ ### - - name: test no tags param cloudwatchlogs_log_group (check mode) + - name: Test no tags param cloudwatchlogs_log_group (check mode) amazon.aws.cloudwatchlogs_log_group: {} check_mode: true register: update_result - - name: assert no change + - name: Assert no change ansible.builtin.assert: that: - update_result is not changed - update_result.log_groups[0].tags == final_tags - - name: test no tags param cloudwatchlogs_log_group + - name: Test no tags param cloudwatchlogs_log_group amazon.aws.cloudwatchlogs_log_group: {} register: update_result - - name: assert no change + - name: Assert no change ansible.builtin.assert: that: - update_result is not changed @@ -334,52 +334,52 @@ ### - - name: test removing tags from cloudwatchlogs_log_group (check mode) + - name: Test removing tags from cloudwatchlogs_log_group (check mode) amazon.aws.cloudwatchlogs_log_group: tags: {} purge_tags: true check_mode: true register: update_result - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is changed - - name: test removing tags from cloudwatchlogs_log_group + - name: Test removing tags from cloudwatchlogs_log_group amazon.aws.cloudwatchlogs_log_group: tags: {} purge_tags: true register: update_result - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is changed - update_result.log_groups[0].tags == {} - - name: test removing tags from cloudwatchlogs_log_group - idempotency (check mode) + - name: Test removing tags from cloudwatchlogs_log_group - idempotency (check mode) amazon.aws.cloudwatchlogs_log_group: tags: {} purge_tags: true check_mode: true register: update_result - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is not changed - - name: test removing tags from cloudwatchlogs_log_group - idempotency + - name: Test removing tags from cloudwatchlogs_log_group - idempotency amazon.aws.cloudwatchlogs_log_group: tags: {} purge_tags: true register: update_result - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is not changed - update_result.log_groups[0].tags == {} - - name: delete cloudwatch log group for integration test (check_mode) + - name: Delete cloudwatch log group for integration test (check_mode) amazon.aws.cloudwatchlogs_log_group: state: absent log_group_name: "{{ log_group_name }}" @@ -391,7 +391,7 @@ - result is changed - '"logs:DeleteLogGroup" not in result.resource_actions' - - name: delete cloudwatch log group for integration test + - name: Delete cloudwatch log group for integration test amazon.aws.cloudwatchlogs_log_group: state: absent log_group_name: "{{ log_group_name }}" @@ -401,7 +401,7 @@ that: - result is changed - - name: delete cloudwatch log group for integration test (check_mode - idempotent) + - name: Delete cloudwatch log group for integration test (check_mode - idempotent) amazon.aws.cloudwatchlogs_log_group: state: absent log_group_name: "{{ log_group_name }}" @@ -413,7 +413,7 @@ - result is not changed - '"logs:DeleteLogGroup" not in result.resource_actions' - - name: delete cloudwatch log group for integration test (idempotent) + - name: Delete cloudwatch log group for integration test (idempotent) amazon.aws.cloudwatchlogs_log_group: state: absent log_group_name: "{{ log_group_name }}" @@ -423,7 +423,7 @@ that: - result is not changed - - name: describe missing log group + - name: Describe missing log group amazon.aws.cloudwatchlogs_log_group_info: log_group_name: "{{ log_group_name }}" register: result @@ -434,7 +434,7 @@ - result.log_groups | length == 0 always: - - name: delete cloudwatch log group for integration test + - name: Delete cloudwatch log group for integration test amazon.aws.cloudwatchlogs_log_group: state: absent log_group_name: "{{ log_group_name }}" diff --git a/tests/integration/targets/ec2_ami/defaults/main.yml b/tests/integration/targets/ec2_ami/defaults/main.yml index bbd4301501d..5f23ca54bfd 100644 --- a/tests/integration/targets/ec2_ami/defaults/main.yml +++ b/tests/integration/targets/ec2_ami/defaults/main.yml @@ -2,7 +2,7 @@ availability_zone: "{{ ec2_availability_zone_names[0] }}" # defaults file for test_ec2_ami -ec2_ami_name: "{{resource_prefix}}" +ec2_ami_name: "{{ resource_prefix }}" ec2_ami_description: Created by ansible integration tests ec2_ami_image: "{{ ec2_ami_id }}" diff --git a/tests/integration/targets/ec2_ami/tasks/main.yml b/tests/integration/targets/ec2_ami/tasks/main.yml index bfe926935f6..0ae52be02e5 100644 --- a/tests/integration/targets/ec2_ami/tasks/main.yml +++ b/tests/integration/targets/ec2_ami/tasks/main.yml @@ -10,7 +10,7 @@ # ============================================================ # SETUP: vpc, ec2 key pair, subnet, security group, ec2 instance, snapshot - - name: create a VPC to work in + - name: Create a VPC to work in amazon.aws.ec2_vpc_net: cidr_block: "{{ vpc_cidr }}" state: present @@ -19,13 +19,13 @@ Name: "{{ ec2_ami_name }}_setup" register: setup_vpc - - name: create a key pair to use for creating an ec2 instance + - name: Create a key pair to use for creating an ec2 instance amazon.aws.ec2_key: name: "{{ ec2_ami_name }}_setup" state: present register: setup_key - - name: create a subnet to use for creating an ec2 instance + - name: Create a subnet to use for creating an ec2 instance amazon.aws.ec2_vpc_subnet: az: "{{ availability_zone }}" tags: "{{ ec2_ami_name }}_setup" @@ -36,7 +36,7 @@ Name: "{{ ec2_ami_name }}_setup" register: setup_subnet - - name: create a security group to use for creating an ec2 instance + - name: Create a security group to use for creating an ec2 instance amazon.aws.ec2_security_group: name: "{{ ec2_ami_name }}_setup" description: created by Ansible integration tests @@ -44,7 +44,7 @@ vpc_id: "{{ setup_vpc.vpc.id }}" register: setup_sg - - name: provision ec2 instance to create an image + - name: Provision ec2 instance to create an image amazon.aws.ec2_instance: state: running key_name: "{{ setup_key.key.name }}" @@ -64,7 +64,7 @@ ansible.builtin.set_fact: ec2_instance_id: "{{ setup_instance.instances[0].instance_id }}" - - name: take a snapshot of the instance to create an image + - name: Take a snapshot of the instance to create an image amazon.aws.ec2_snapshot: instance_id: "{{ ec2_instance_id }}" device_name: "{{ ec2_ami_root_disk }}" @@ -88,7 +88,7 @@ # ============================================================ - - name: test clean failure if not providing image_id or name with state=present + - name: Test clean failure if not providing image_id or name with state=present amazon.aws.ec2_ami: instance_id: "{{ ec2_instance_id }}" state: present @@ -100,7 +100,7 @@ register: result ignore_errors: true - - name: assert error message is helpful + - name: Assert error message is helpful ansible.builtin.assert: that: - result.failed @@ -108,7 +108,7 @@ # ============================================================ - - name: create an image from the instance (check mode) + - name: Create an image from the instance (check mode) amazon.aws.ec2_ami: instance_id: "{{ ec2_instance_id }}" state: present @@ -121,12 +121,12 @@ check_mode: true register: check_mode_result - - name: assert that check_mode result is changed + - name: Assert that check_mode result is changed ansible.builtin.assert: that: - check_mode_result is changed - - name: create an image from the instance + - name: Create an image from the instance amazon.aws.ec2_ami: instance_id: "{{ ec2_instance_id }}" state: present @@ -138,24 +138,24 @@ root_device_name: "{{ ec2_ami_root_disk }}" register: result - - name: set image id fact for deletion later + - name: Set image id fact for deletion later ansible.builtin.set_fact: ec2_ami_image_id: "{{ result.image_id }}" - - name: assert that image has been created + - name: Assert that image has been created ansible.builtin.assert: that: - result.changed - result.image_id.startswith('ami-') - "'Name' in result.tags and result.tags.Name == ec2_ami_name + '_ami'" - - name: get related snapshot info and ensure the tags have been propagated + - name: Get related snapshot info and ensure the tags have been propagated amazon.aws.ec2_snapshot_info: snapshot_ids: - "{{ result.block_device_mapping[ec2_ami_root_disk].snapshot_id }}" register: snapshot_result - - name: ensure the tags have been propagated to the snapshot + - name: Ensure the tags have been propagated to the snapshot ansible.builtin.assert: that: - "'tags' in snapshot_result.snapshots[0]" @@ -163,7 +163,7 @@ # ============================================================ - - name: create an image from the instance with attached devices with no_device true (check mode) + - name: Create an image from the instance with attached devices with no_device true (check mode) amazon.aws.ec2_ami: name: "{{ ec2_ami_name }}_no_device_true_ami" instance_id: "{{ ec2_instance_id }}" @@ -180,12 +180,12 @@ check_mode: true register: check_mode_result - - name: assert that check_mode result is changed + - name: Assert that check_mode result is changed ansible.builtin.assert: that: - check_mode_result is changed - - name: create an image from the instance with attached devices with no_device true + - name: Create an image from the instance with attached devices with no_device true amazon.aws.ec2_ami: name: "{{ ec2_ami_name }}_no_device_true_ami" instance_id: "{{ ec2_instance_id }}" @@ -201,17 +201,17 @@ root_device_name: "{{ ec2_ami_root_disk }}" register: result_no_device_true - - name: set image id fact for deletion later + - name: Set image id fact for deletion later ansible.builtin.set_fact: ec2_ami_no_device_true_image_id: "{{ result_no_device_true.image_id }}" - - name: assert that image with no_device option yes has been created + - name: Assert that image with no_device option yes has been created ansible.builtin.assert: that: - result_no_device_true.changed - "'/dev/sdf' not in result_no_device_true.block_device_mapping" - - name: create an image from the instance with attached devices with no_device false + - name: Create an image from the instance with attached devices with no_device false amazon.aws.ec2_ami: name: "{{ ec2_ami_name }}_no_device_false_ami" instance_id: "{{ ec2_instance_id }}" @@ -226,11 +226,11 @@ root_device_name: "{{ ec2_ami_root_disk }}" register: result_no_device_false - - name: set image id fact for deletion later + - name: Set image id fact for deletion later ansible.builtin.set_fact: ec2_ami_no_device_false_image_id: "{{ result_no_device_false.image_id }}" - - name: assert that image with no_device option no has been created + - name: Assert that image with no_device option no has been created ansible.builtin.assert: that: - result_no_device_false.changed @@ -238,13 +238,13 @@ # ============================================================ - - name: gather facts about the image created + - name: Gather facts about the image created amazon.aws.ec2_ami_info: image_ids: "{{ ec2_ami_image_id }}" register: ami_facts_result ignore_errors: true - - name: assert that the right image was found + - name: Assert that the right image was found ansible.builtin.assert: that: - ami_facts_result.images[0].image_id == ec2_ami_image_id @@ -252,20 +252,20 @@ # some ec2_ami_info tests to test if the filtering is working fine. # ============================================================ - - name: gather info about the image + - name: Gather info about the image amazon.aws.ec2_ami_info: image_ids: "{{ ec2_region_images[ec2_region] }}" register: ami_info_result ignore_errors: true - - name: assert that the right image was found + - name: Assert that the right image was found ansible.builtin.assert: that: - ami_info_result.images[0].image_id == ec2_region_images[ec2_region] # ============================================================ - - name: gather info about the image using boolean filter + - name: Gather info about the image using boolean filter amazon.aws.ec2_ami_info: image_ids: "{{ ec2_region_images[ec2_region] }}" filters: @@ -273,14 +273,14 @@ register: ami_info_result ignore_errors: true - - name: assert that the right image was found + - name: Assert that the right image was found ansible.builtin.assert: that: - ami_info_result.images[0].image_id == ec2_region_images[ec2_region] # ============================================================ - - name: gather info about the image using integer filter + - name: Gather info about the image using integer filter amazon.aws.ec2_ami_info: image_ids: "{{ ec2_region_images[ec2_region] }}" filters: @@ -289,14 +289,14 @@ register: ami_info_result ignore_errors: true - - name: assert that the right image was found + - name: Assert that the right image was found ansible.builtin.assert: that: - ami_info_result.images[0].image_id == ec2_region_images[ec2_region] # ============================================================ - - name: gather info about the image using string filter + - name: Gather info about the image using string filter amazon.aws.ec2_ami_info: image_ids: "{{ ec2_region_images[ec2_region] }}" filters: @@ -304,7 +304,7 @@ register: ami_info_result ignore_errors: true - - name: assert that the right image was found + - name: Assert that the right image was found ansible.builtin.assert: that: - ami_info_result.images[0].image_id == ec2_region_images[ec2_region] @@ -312,7 +312,7 @@ # e2_ami_info filtering tests ends # ============================================================ - - name: delete the image (check mode) + - name: Delete the image (check mode) amazon.aws.ec2_ami: instance_id: "{{ ec2_instance_id }}" state: absent @@ -327,12 +327,12 @@ check_mode: true register: check_mode_result - - name: assert that check_mode result is changed + - name: Assert that check_mode result is changed ansible.builtin.assert: that: - check_mode_result is changed - - name: delete the image + - name: Delete the image amazon.aws.ec2_ami: instance_id: "{{ ec2_instance_id }}" state: absent @@ -346,7 +346,7 @@ ignore_errors: true register: result - - name: assert that the image has been deleted + - name: Assert that the image has been deleted ansible.builtin.assert: that: - result.changed @@ -355,13 +355,13 @@ # ============================================================== - - name: test removing an ami if no image ID is provided (expected failed=true) + - name: Test removing an ami if no image ID is provided (expected failed=true) amazon.aws.ec2_ami: state: absent register: result ignore_errors: true - - name: assert that an image ID is required + - name: Assert that an image ID is required ansible.builtin.assert: that: - result.failed @@ -369,7 +369,7 @@ # ============================================================ - - name: create an image from the snapshot + - name: Create an image from the snapshot amazon.aws.ec2_ami: name: "{{ ec2_ami_name }}_ami" description: "{{ ec2_ami_description }}" @@ -388,12 +388,12 @@ register: result ignore_errors: true - - name: set image id fact for deletion later + - name: Set image id fact for deletion later ansible.builtin.set_fact: ec2_ami_image_id: "{{ result.image_id }}" ec2_ami_snapshot: "{{ result.block_device_mapping[ec2_ami_root_disk].snapshot_id }}" - - name: assert a new ami has been created + - name: Assert a new ami has been created ansible.builtin.assert: that: - result.changed @@ -401,7 +401,7 @@ # ============================================================ - - name: test default launch permissions idempotence (check mode) + - name: Test default launch permissions idempotence (check mode) amazon.aws.ec2_ami: description: "{{ ec2_ami_description }}" state: present @@ -421,12 +421,12 @@ check_mode: true register: check_mode_result - - name: assert that check_mode result is not changed + - name: Assert that check_mode result is not changed ansible.builtin.assert: that: - check_mode_result is not changed - - name: test default launch permissions idempotence + - name: Test default launch permissions idempotence amazon.aws.ec2_ami: description: "{{ ec2_ami_description }}" state: present @@ -445,7 +445,7 @@ snapshot_id: "{{ setup_snapshot.snapshot_id }}" register: result - - name: assert a new ami has not been created + - name: Assert a new ami has not been created ansible.builtin.assert: that: - not result.changed @@ -453,7 +453,7 @@ # ============================================================ - - name: add a tag to the AMI + - name: Add a tag to the AMI amazon.aws.ec2_ami: state: present description: "{{ ec2_ami_description }}" @@ -464,13 +464,13 @@ purge_tags: false register: result - - name: assert a tag was added + - name: Assert a tag was added ansible.builtin.assert: that: - "'Name' in result.tags and result.tags.Name == ec2_ami_name + '_ami'" - "'New' in result.tags and result.tags.New == 'Tag'" - - name: use purge_tags to remove a tag from the AMI + - name: Use purge_tags to remove a tag from the AMI amazon.aws.ec2_ami: state: present description: "{{ ec2_ami_description }}" @@ -480,7 +480,7 @@ New: Tag register: result - - name: assert a tag was removed + - name: Assert a tag was removed ansible.builtin.assert: that: - "'Name' not in result.tags" @@ -488,7 +488,7 @@ # ============================================================ - - name: update AMI launch permissions (check mode) + - name: Update AMI launch permissions (check mode) amazon.aws.ec2_ami: state: present image_id: "{{ result.image_id }}" @@ -500,12 +500,12 @@ check_mode: true register: check_mode_result - - name: assert that check_mode result is changed + - name: Assert that check_mode result is changed ansible.builtin.assert: that: - check_mode_result is changed - - name: update AMI launch permissions + - name: Update AMI launch permissions amazon.aws.ec2_ami: state: present image_id: "{{ result.image_id }}" @@ -516,14 +516,14 @@ group_names: [all] register: result - - name: assert launch permissions were updated + - name: Assert launch permissions were updated ansible.builtin.assert: that: - result.changed # ============================================================ - - name: modify the AMI description (check mode) + - name: Modify the AMI description (check mode) amazon.aws.ec2_ami: state: present image_id: "{{ result.image_id }}" @@ -536,12 +536,12 @@ check_mode: true register: check_mode_result - - name: assert that check_mode result is changed + - name: Assert that check_mode result is changed ansible.builtin.assert: that: - check_mode_result is changed - - name: modify the AMI description + - name: Modify the AMI description amazon.aws.ec2_ami: state: present image_id: "{{ result.image_id }}" @@ -553,14 +553,14 @@ group_names: [all] register: result - - name: assert the description changed + - name: Assert the description changed ansible.builtin.assert: that: - result.changed # ============================================================ - - name: remove public launch permissions + - name: Remove public launch permissions amazon.aws.ec2_ami: state: present image_id: "{{ result.image_id }}" @@ -571,14 +571,14 @@ group_names: [] register: result - - name: assert launch permissions were updated + - name: Assert launch permissions were updated ansible.builtin.assert: that: - result.changed # ============================================================ - - name: delete ami without deleting the snapshot (default is not to delete) + - name: Delete ami without deleting the snapshot (default is not to delete) amazon.aws.ec2_ami: instance_id: "{{ ec2_instance_id }}" state: absent @@ -590,24 +590,24 @@ ignore_errors: true register: result - - name: assert that the image has been deleted + - name: Assert that the image has been deleted ansible.builtin.assert: that: - result.changed - "'image_id' not in result" - - name: ensure the snapshot still exists + - name: Ensure the snapshot still exists amazon.aws.ec2_snapshot_info: snapshot_ids: - "{{ ec2_ami_snapshot }}" register: snapshot_result - - name: assert the snapshot wasn't deleted + - name: Assert the snapshot wasn't deleted ansible.builtin.assert: that: - snapshot_result.snapshots[0].snapshot_id == ec2_ami_snapshot - - name: delete ami for a second time (check mode) + - name: Delete ami for a second time (check mode) amazon.aws.ec2_ami: instance_id: "{{ ec2_instance_id }}" state: absent @@ -619,12 +619,12 @@ check_mode: true register: check_mode_result - - name: assert that check_mode result is not changed + - name: Assert that check_mode result is not changed ansible.builtin.assert: that: - check_mode_result is not changed - - name: delete ami for a second time + - name: Delete ami for a second time amazon.aws.ec2_ami: instance_id: "{{ ec2_instance_id }}" state: absent @@ -635,7 +635,7 @@ wait: true register: result - - name: assert that image does not exist + - name: Assert that image does not exist ansible.builtin.assert: that: - not result.changed @@ -643,7 +643,7 @@ # ============================================================ - - name: create an image from the snapshot with boot_mode and tpm_support + - name: Create an image from the snapshot with boot_mode and tpm_support amazon.aws.ec2_ami: name: "{{ ec2_ami_name }}_ami-boot-tpm" description: "{{ ec2_ami_description }}" @@ -664,18 +664,18 @@ register: result ignore_errors: true - - name: set image id fact for deletion later + - name: Set image id fact for deletion later ansible.builtin.set_fact: ec2_ami_image_id_boot_tpm: "{{ result.image_id }}" ec2_ami_snapshot_boot_tpm: "{{ result.block_device_mapping[ec2_ami_root_disk].snapshot_id }}" - - name: gather facts about the image created + - name: Gather facts about the image created amazon.aws.ec2_ami_info: image_ids: "{{ ec2_ami_image_id_boot_tpm }}" register: ami_facts_result_boot_tpm ignore_errors: true - - name: assert that new ami has been created with desired options + - name: Assert that new ami has been created with desired options ansible.builtin.assert: that: - result.changed @@ -686,7 +686,7 @@ # === Test modify launch permissions org_arns and org_unit_arns========================= - - name: create an image from the instance + - name: Create an image from the instance amazon.aws.ec2_ami: instance_id: "{{ ec2_instance_id }}" state: present @@ -698,7 +698,7 @@ root_device_name: "{{ ec2_ami_root_disk }}" register: permissions_create_result - - name: modify the AMI launch permissions + - name: Modify the AMI launch permissions amazon.aws.ec2_ami: state: present image_id: "{{ permissions_create_result.image_id }}" @@ -716,7 +716,7 @@ describe_image_attributes: true register: permissions_info_result - - name: assert that launch permissions have changed + - name: Assert that launch permissions have changed ansible.builtin.assert: that: - permissions_update_result.changed @@ -735,14 +735,14 @@ ansible.builtin.debug: msg: "***** TESTING COMPLETE. COMMENCE TEARDOWN *****" - - name: delete ami + - name: Delete ami amazon.aws.ec2_ami: state: absent image_id: "{{ ec2_ami_image_id_boot_tpm }}" wait: true ignore_errors: true - - name: delete ami + - name: Delete ami amazon.aws.ec2_ami: state: absent image_id: "{{ ec2_ami_image_id }}" @@ -750,21 +750,21 @@ wait: true ignore_errors: true - - name: delete ami + - name: Delete ami amazon.aws.ec2_ami: state: absent image_id: "{{ ec2_ami_no_device_true_image_id }}" wait: true ignore_errors: true - - name: delete ami + - name: Delete ami amazon.aws.ec2_ami: state: absent image_id: "{{ ec2_ami_no_device_false_image_id }}" wait: true ignore_errors: true - - name: delete ami + - name: Delete ami amazon.aws.ec2_ami: state: absent image_id: "{{ ec2_ami_image_id }}" @@ -772,13 +772,13 @@ wait: true ignore_errors: true - - name: remove setup snapshot of ec2 instance + - name: Remove setup snapshot of ec2 instance amazon.aws.ec2_snapshot: state: absent snapshot_id: "{{ setup_snapshot.snapshot_id }}" ignore_errors: true - - name: remove setup ec2 instance + - name: Remove setup ec2 instance amazon.aws.ec2_instance: state: absent instance_ids: @@ -786,13 +786,13 @@ wait: true ignore_errors: true - - name: remove setup keypair + - name: Remove setup keypair amazon.aws.ec2_key: - name: "{{ec2_ami_name}}_setup" + name: "{{ ec2_ami_name }}_setup" state: absent ignore_errors: true - - name: remove setup security group + - name: Remove setup security group amazon.aws.ec2_security_group: name: "{{ ec2_ami_name }}_setup" description: created by Ansible integration tests @@ -800,10 +800,10 @@ vpc_id: "{{ setup_vpc.vpc.id }}" ignore_errors: true - - name: remove setup subnet + - name: Remove setup subnet amazon.aws.ec2_vpc_subnet: az: "{{ availability_zone }}" - tags: "{{ec2_ami_name}}_setup" + tags: "{{ ec2_ami_name }}_setup" vpc_id: "{{ setup_vpc.vpc.id }}" cidr: "{{ subnet_cidr }}" state: absent @@ -811,7 +811,7 @@ Name: "{{ ec2_ami_name }}_setup" ignore_errors: true - - name: remove setup VPC + - name: Remove setup VPC amazon.aws.ec2_vpc_net: cidr_block: "{{ vpc_cidr }}" state: absent diff --git a/tests/integration/targets/ec2_ami_instance/tasks/main.yml b/tests/integration/targets/ec2_ami_instance/tasks/main.yml index b830211168e..4c473446227 100644 --- a/tests/integration/targets/ec2_ami_instance/tasks/main.yml +++ b/tests/integration/targets/ec2_ami_instance/tasks/main.yml @@ -10,7 +10,7 @@ # ============================================================ # SETUP: vpc, ec2 key pair, subnet, security group, ec2 instance, snapshot - - name: create a VPC to work in + - name: Create a VPC to work in amazon.aws.ec2_vpc_net: cidr_block: "{{ vpc_cidr }}" state: present @@ -19,13 +19,13 @@ Name: "{{ ec2_ami_name }}_setup" register: setup_vpc - - name: create a key pair to use for creating an ec2 instance + - name: Create a key pair to use for creating an ec2 instance amazon.aws.ec2_key: name: "{{ ec2_ami_name }}_setup" state: present register: setup_key - - name: create a subnet to use for creating an ec2 instance + - name: Create a subnet to use for creating an ec2 instance amazon.aws.ec2_vpc_subnet: az: "{{ availability_zone }}" tags: "{{ ec2_ami_name }}_setup" @@ -36,7 +36,7 @@ Name: "{{ ec2_ami_name }}_setup" register: setup_subnet - - name: create a security group to use for creating an ec2 instance + - name: Create a security group to use for creating an ec2 instance amazon.aws.ec2_security_group: name: "{{ ec2_ami_name }}_setup" description: created by Ansible integration tests @@ -44,7 +44,7 @@ vpc_id: "{{ setup_vpc.vpc.id }}" register: setup_sg - - name: provision ec2 instance to create an image + - name: Provision ec2 instance to create an image amazon.aws.ec2_instance: state: running key_name: "{{ setup_key.key.name }}" @@ -66,7 +66,7 @@ # ============================================================ - - name: test clean failure if not providing image_id or name with state=present + - name: Test clean failure if not providing image_id or name with state=present amazon.aws.ec2_ami: instance_id: "{{ ec2_instance_id }}" state: present @@ -78,7 +78,7 @@ register: result ignore_errors: true - - name: assert error message is helpful + - name: Assert error message is helpful ansible.builtin.assert: that: - result.failed @@ -86,7 +86,7 @@ # ============================================================ - - name: create an image from the instance (check mode) + - name: Create an image from the instance (check mode) amazon.aws.ec2_ami: instance_id: "{{ ec2_instance_id }}" state: present @@ -99,12 +99,12 @@ check_mode: true register: check_mode_result - - name: assert that check_mode result is changed + - name: Assert that check_mode result is changed ansible.builtin.assert: that: - check_mode_result is changed - - name: create an image from the instance + - name: Create an image from the instance amazon.aws.ec2_ami: instance_id: "{{ ec2_instance_id }}" state: present @@ -116,24 +116,24 @@ root_device_name: "{{ ec2_ami_root_disk }}" register: result - - name: set image id fact for deletion later + - name: Set image id fact for deletion later ansible.builtin.set_fact: ec2_ami_image_id_simple: "{{ result.image_id }}" - - name: assert that image has been created + - name: Assert that image has been created ansible.builtin.assert: that: - result.changed - result.image_id.startswith('ami-') - "'Name' in result.tags and result.tags.Name == ec2_ami_name + '_ami'" - - name: get related snapshot info and ensure the tags have been propagated + - name: Get related snapshot info and ensure the tags have been propagated amazon.aws.ec2_snapshot_info: snapshot_ids: - "{{ result.block_device_mapping[ec2_ami_root_disk].snapshot_id }}" register: snapshot_result - - name: ensure the tags have been propagated to the snapshot + - name: Ensure the tags have been propagated to the snapshot ansible.builtin.assert: that: - "'tags' in snapshot_result.snapshots[0]" @@ -141,7 +141,7 @@ # ============================================================ - - name: create an image from the instance with attached devices with no_device true (check mode) + - name: Create an image from the instance with attached devices with no_device true (check mode) amazon.aws.ec2_ami: name: "{{ ec2_ami_name }}_no_device_true_ami" instance_id: "{{ ec2_instance_id }}" @@ -158,12 +158,12 @@ check_mode: true register: check_mode_result - - name: assert that check_mode result is changed + - name: Assert that check_mode result is changed ansible.builtin.assert: that: - check_mode_result is changed - - name: create an image from the instance with attached devices with no_device true + - name: Create an image from the instance with attached devices with no_device true amazon.aws.ec2_ami: name: "{{ ec2_ami_name }}_no_device_true_ami" instance_id: "{{ ec2_instance_id }}" @@ -179,17 +179,17 @@ root_device_name: "{{ ec2_ami_root_disk }}" register: result_no_device_true - - name: set image id fact for deletion later + - name: Set image id fact for deletion later ansible.builtin.set_fact: ec2_ami_no_device_true_image_id: "{{ result_no_device_true.image_id }}" - - name: assert that image with no_device option yes has been created + - name: Assert that image with no_device option yes has been created ansible.builtin.assert: that: - result_no_device_true.changed - "'/dev/sdf' not in result_no_device_true.block_device_mapping" - - name: create an image from the instance with attached devices with no_device false + - name: Create an image from the instance with attached devices with no_device false amazon.aws.ec2_ami: name: "{{ ec2_ami_name }}_no_device_false_ami" instance_id: "{{ ec2_instance_id }}" @@ -204,11 +204,11 @@ root_device_name: "{{ ec2_ami_root_disk }}" register: result_no_device_false - - name: set image id fact for deletion later + - name: Set image id fact for deletion later ansible.builtin.set_fact: ec2_ami_no_device_false_image_id: "{{ result_no_device_false.image_id }}" - - name: assert that image with no_device option no has been created + - name: Assert that image with no_device option no has been created ansible.builtin.assert: that: - result_no_device_false.changed @@ -216,13 +216,13 @@ # ============================================================ - - name: gather facts about the image created + - name: Gather facts about the image created amazon.aws.ec2_ami_info: image_ids: "{{ ec2_ami_image_id_simple }}" register: ami_facts_result ignore_errors: true - - name: assert that the right image was found + - name: Assert that the right image was found ansible.builtin.assert: that: - ami_facts_result.images[0].image_id == ec2_ami_image_id_simple @@ -230,20 +230,20 @@ # some ec2_ami_info tests to test if the filtering is working fine. # ============================================================ - - name: gather info about the image + - name: Gather info about the image amazon.aws.ec2_ami_info: image_ids: "{{ ec2_region_images[ec2_region] }}" register: ami_info_result ignore_errors: true - - name: assert that the right image was found + - name: Assert that the right image was found ansible.builtin.assert: that: - ami_info_result.images[0].image_id == ec2_region_images[ec2_region] # ============================================================ - - name: gather info about the image using boolean filter + - name: Gather info about the image using boolean filter amazon.aws.ec2_ami_info: image_ids: "{{ ec2_region_images[ec2_region] }}" filters: @@ -251,14 +251,14 @@ register: ami_info_result ignore_errors: true - - name: assert that the right image was found + - name: Assert that the right image was found ansible.builtin.assert: that: - ami_info_result.images[0].image_id == ec2_region_images[ec2_region] # ============================================================ - - name: gather info about the image using integer filter + - name: Gather info about the image using integer filter amazon.aws.ec2_ami_info: image_ids: "{{ ec2_region_images[ec2_region] }}" filters: @@ -267,14 +267,14 @@ register: ami_info_result ignore_errors: true - - name: assert that the right image was found + - name: Assert that the right image was found ansible.builtin.assert: that: - ami_info_result.images[0].image_id == ec2_region_images[ec2_region] # ============================================================ - - name: gather info about the image using string filter + - name: Gather info about the image using string filter amazon.aws.ec2_ami_info: image_ids: "{{ ec2_region_images[ec2_region] }}" filters: @@ -282,7 +282,7 @@ register: ami_info_result ignore_errors: true - - name: assert that the right image was found + - name: Assert that the right image was found ansible.builtin.assert: that: - ami_info_result.images[0].image_id == ec2_region_images[ec2_region] @@ -290,7 +290,7 @@ # ec2_ami_info filtering tests ends # ============================================================ - - name: delete the image (check mode) + - name: Delete the image (check mode) amazon.aws.ec2_ami: instance_id: "{{ ec2_instance_id }}" state: absent @@ -305,12 +305,12 @@ check_mode: true register: check_mode_result - - name: assert that check_mode result is changed + - name: Assert that check_mode result is changed ansible.builtin.assert: that: - check_mode_result is changed - - name: delete the image + - name: Delete the image amazon.aws.ec2_ami: instance_id: "{{ ec2_instance_id }}" state: absent @@ -324,7 +324,7 @@ ignore_errors: true register: result - - name: assert that the image has been deleted + - name: Assert that the image has been deleted ansible.builtin.assert: that: - result.changed @@ -333,13 +333,13 @@ # ============================================================== - - name: test removing an ami if no image ID is provided (expected failed=true) + - name: Test removing an ami if no image ID is provided (expected failed=true) amazon.aws.ec2_ami: state: absent register: result ignore_errors: true - - name: assert that an image ID is required + - name: Assert that an image ID is required ansible.builtin.assert: that: - result.failed @@ -353,7 +353,7 @@ ansible.builtin.debug: msg: "***** TESTING COMPLETE. COMMENCE TEARDOWN *****" - - name: remove setup ec2 instance + - name: Remove setup ec2 instance amazon.aws.ec2_instance: state: absent instance_ids: @@ -361,7 +361,7 @@ wait: true ignore_errors: true - - name: remove setup security group + - name: Remove setup security group amazon.aws.ec2_security_group: name: "{{ ec2_ami_name }}_setup" description: created by Ansible integration tests @@ -369,7 +369,7 @@ vpc_id: "{{ setup_vpc.vpc.id }}" ignore_errors: true - - name: delete ami + - name: Delete ami amazon.aws.ec2_ami: state: absent image_id: "{{ ec2_ami_image_id_simple }}" @@ -377,30 +377,30 @@ wait: true ignore_errors: true - - name: delete ami + - name: Delete ami amazon.aws.ec2_ami: state: absent image_id: "{{ ec2_ami_no_device_true_image_id }}" wait: true ignore_errors: true - - name: delete ami + - name: Delete ami amazon.aws.ec2_ami: state: absent image_id: "{{ ec2_ami_no_device_false_image_id }}" wait: true ignore_errors: true - - name: remove setup keypair + - name: Remove setup keypair amazon.aws.ec2_key: - name: "{{ec2_ami_name}}_setup" + name: "{{ ec2_ami_name }}_setup" state: absent ignore_errors: true - - name: remove setup subnet + - name: Remove setup subnet amazon.aws.ec2_vpc_subnet: az: "{{ availability_zone }}" - tags: "{{ec2_ami_name}}_setup" + tags: "{{ ec2_ami_name }}_setup" vpc_id: "{{ setup_vpc.vpc.id }}" cidr: "{{ subnet_cidr }}" state: absent @@ -408,7 +408,7 @@ Name: "{{ ec2_ami_name }}_setup" ignore_errors: true - - name: remove setup VPC + - name: Remove setup VPC amazon.aws.ec2_vpc_net: cidr_block: "{{ vpc_cidr }}" state: absent diff --git a/tests/integration/targets/ec2_ami_snapshot/tasks/main.yml b/tests/integration/targets/ec2_ami_snapshot/tasks/main.yml index 1b0252ef761..56a87e96ae7 100644 --- a/tests/integration/targets/ec2_ami_snapshot/tasks/main.yml +++ b/tests/integration/targets/ec2_ami_snapshot/tasks/main.yml @@ -10,7 +10,7 @@ # ============================================================ # SETUP: vpc, ec2 key pair, subnet, security group, ec2 instance, snapshot - - name: create a VPC to work in + - name: Create a VPC to work in amazon.aws.ec2_vpc_net: cidr_block: "{{ vpc_cidr }}" state: present @@ -19,13 +19,13 @@ Name: "{{ ec2_ami_name }}_setup" register: setup_vpc - - name: create a key pair to use for creating an ec2 instance + - name: Create a key pair to use for creating an ec2 instance amazon.aws.ec2_key: name: "{{ ec2_ami_name }}_setup" state: present register: setup_key - - name: create a subnet to use for creating an ec2 instance + - name: Create a subnet to use for creating an ec2 instance amazon.aws.ec2_vpc_subnet: az: "{{ availability_zone }}" tags: "{{ ec2_ami_name }}_setup" @@ -36,7 +36,7 @@ Name: "{{ ec2_ami_name }}_setup" register: setup_subnet - - name: create a security group to use for creating an ec2 instance + - name: Create a security group to use for creating an ec2 instance amazon.aws.ec2_security_group: name: "{{ ec2_ami_name }}_setup" description: created by Ansible integration tests @@ -44,7 +44,7 @@ vpc_id: "{{ setup_vpc.vpc.id }}" register: setup_sg - - name: provision ec2 instance to create an image + - name: Provision ec2 instance to create an image amazon.aws.ec2_instance: state: running key_name: "{{ setup_key.key.name }}" @@ -64,7 +64,7 @@ ansible.builtin.set_fact: ec2_instance_id: "{{ setup_instance.instances[0].instance_id }}" - - name: take a snapshot of the instance to create an image + - name: Take a snapshot of the instance to create an image amazon.aws.ec2_snapshot: instance_id: "{{ ec2_instance_id }}" device_name: "{{ ec2_ami_root_disk }}" @@ -73,7 +73,7 @@ # ============================================================ - - name: create an image from the snapshot + - name: Create an image from the snapshot amazon.aws.ec2_ami: name: "{{ ec2_ami_name }}_ami" description: "{{ ec2_ami_description }}" @@ -92,12 +92,12 @@ register: result ignore_errors: true - - name: set image id fact for deletion later + - name: Set image id fact for deletion later ansible.builtin.set_fact: ec2_ami_image_id: "{{ result.image_id }}" ec2_ami_snapshot: "{{ result.block_device_mapping[ec2_ami_root_disk].snapshot_id }}" - - name: assert a new ami has been created + - name: Assert a new ami has been created ansible.builtin.assert: that: - result.changed @@ -105,7 +105,7 @@ # ============================================================ - - name: test default launch permissions idempotence (check mode) + - name: Test default launch permissions idempotence (check mode) amazon.aws.ec2_ami: description: "{{ ec2_ami_description }}" state: present @@ -125,12 +125,12 @@ check_mode: true register: check_mode_result - - name: assert that check_mode result is not changed + - name: Assert that check_mode result is not changed ansible.builtin.assert: that: - check_mode_result is not changed - - name: test default launch permissions idempotence + - name: Test default launch permissions idempotence amazon.aws.ec2_ami: description: "{{ ec2_ami_description }}" state: present @@ -149,7 +149,7 @@ snapshot_id: "{{ setup_snapshot.snapshot_id }}" register: result - - name: assert a new ami has not been created + - name: Assert a new ami has not been created ansible.builtin.assert: that: - not result.changed @@ -157,7 +157,7 @@ # ============================================================ - - name: add a tag to the AMI + - name: Add a tag to the AMI amazon.aws.ec2_ami: state: present description: "{{ ec2_ami_description }}" @@ -168,13 +168,13 @@ purge_tags: false register: result - - name: assert a tag was added + - name: Assert a tag was added ansible.builtin.assert: that: - "'Name' in result.tags and result.tags.Name == ec2_ami_name + '_ami'" - "'New' in result.tags and result.tags.New == 'Tag'" - - name: use purge_tags to remove a tag from the AMI + - name: Use purge_tags to remove a tag from the AMI amazon.aws.ec2_ami: state: present description: "{{ ec2_ami_description }}" @@ -184,7 +184,7 @@ New: Tag register: result - - name: assert a tag was removed + - name: Assert a tag was removed ansible.builtin.assert: that: - "'Name' not in result.tags" @@ -192,7 +192,7 @@ # ============================================================ - - name: update AMI launch permissions (check mode) + - name: Update AMI launch permissions (check mode) amazon.aws.ec2_ami: state: present image_id: "{{ result.image_id }}" @@ -204,12 +204,12 @@ check_mode: true register: check_mode_result - - name: assert that check_mode result is changed + - name: Assert that check_mode result is changed ansible.builtin.assert: that: - check_mode_result is changed - - name: update AMI launch permissions + - name: Update AMI launch permissions amazon.aws.ec2_ami: state: present image_id: "{{ result.image_id }}" @@ -220,14 +220,14 @@ group_names: [all] register: result - - name: assert launch permissions were updated + - name: Assert launch permissions were updated ansible.builtin.assert: that: - result.changed # ============================================================ - - name: modify the AMI description (check mode) + - name: Modify the AMI description (check mode) amazon.aws.ec2_ami: state: present image_id: "{{ result.image_id }}" @@ -240,12 +240,12 @@ check_mode: true register: check_mode_result - - name: assert that check_mode result is changed + - name: Assert that check_mode result is changed ansible.builtin.assert: that: - check_mode_result is changed - - name: modify the AMI description + - name: Modify the AMI description amazon.aws.ec2_ami: state: present image_id: "{{ result.image_id }}" @@ -257,14 +257,14 @@ group_names: [all] register: result - - name: assert the description changed + - name: Assert the description changed ansible.builtin.assert: that: - result.changed # ============================================================ - - name: remove public launch permissions + - name: Remove public launch permissions amazon.aws.ec2_ami: state: present image_id: "{{ result.image_id }}" @@ -275,14 +275,14 @@ group_names: [] register: result - - name: assert launch permissions were updated + - name: Assert launch permissions were updated ansible.builtin.assert: that: - result.changed # ============================================================ - - name: delete ami without deleting the snapshot (default is not to delete) + - name: Delete ami without deleting the snapshot (default is not to delete) amazon.aws.ec2_ami: instance_id: "{{ ec2_instance_id }}" state: absent @@ -294,24 +294,24 @@ ignore_errors: true register: result - - name: assert that the image has been deleted + - name: Assert that the image has been deleted ansible.builtin.assert: that: - result.changed - "'image_id' not in result" - - name: ensure the snapshot still exists + - name: Ensure the snapshot still exists amazon.aws.ec2_snapshot_info: snapshot_ids: - "{{ ec2_ami_snapshot }}" register: snapshot_result - - name: assert the snapshot wasn't deleted + - name: Assert the snapshot wasn't deleted ansible.builtin.assert: that: - snapshot_result.snapshots[0].snapshot_id == ec2_ami_snapshot - - name: delete ami for a second time (check mode) + - name: Delete ami for a second time (check mode) amazon.aws.ec2_ami: instance_id: "{{ ec2_instance_id }}" state: absent @@ -323,12 +323,12 @@ check_mode: true register: check_mode_result - - name: assert that check_mode result is not changed + - name: Assert that check_mode result is not changed ansible.builtin.assert: that: - check_mode_result is not changed - - name: delete ami for a second time + - name: Delete ami for a second time amazon.aws.ec2_ami: instance_id: "{{ ec2_instance_id }}" state: absent @@ -339,7 +339,7 @@ wait: true register: result - - name: assert that image does not exist + - name: Assert that image does not exist ansible.builtin.assert: that: - not result.changed @@ -353,7 +353,7 @@ ansible.builtin.debug: msg: "***** TESTING COMPLETE. COMMENCE TEARDOWN *****" - - name: remove setup ec2 instance + - name: Remove setup ec2 instance amazon.aws.ec2_instance: state: absent instance_ids: @@ -361,7 +361,7 @@ wait: true ignore_errors: true - - name: delete ami + - name: Delete ami amazon.aws.ec2_ami: state: absent image_id: "{{ ec2_ami_image_id }}" @@ -369,19 +369,19 @@ wait: true ignore_errors: true - - name: remove setup snapshot of ec2 instance + - name: Remove setup snapshot of ec2 instance amazon.aws.ec2_snapshot: state: absent snapshot_id: "{{ setup_snapshot.snapshot_id }}" ignore_errors: true - - name: remove setup keypair + - name: Remove setup keypair amazon.aws.ec2_key: - name: "{{ec2_ami_name}}_setup" + name: "{{ ec2_ami_name }}_setup" state: absent ignore_errors: true - - name: remove setup security group + - name: Remove setup security group amazon.aws.ec2_security_group: name: "{{ ec2_ami_name }}_setup" description: created by Ansible integration tests @@ -389,10 +389,10 @@ vpc_id: "{{ setup_vpc.vpc.id }}" ignore_errors: true - - name: remove setup subnet + - name: Remove setup subnet amazon.aws.ec2_vpc_subnet: az: "{{ availability_zone }}" - tags: "{{ec2_ami_name}}_setup" + tags: "{{ ec2_ami_name }}_setup" vpc_id: "{{ setup_vpc.vpc.id }}" cidr: "{{ subnet_cidr }}" state: absent @@ -400,7 +400,7 @@ Name: "{{ ec2_ami_name }}_setup" ignore_errors: true - - name: remove setup VPC + - name: Remove setup VPC amazon.aws.ec2_vpc_net: cidr_block: "{{ vpc_cidr }}" state: absent diff --git a/tests/integration/targets/ec2_ami_tpm/defaults/main.yml b/tests/integration/targets/ec2_ami_tpm/defaults/main.yml index bbd4301501d..5f23ca54bfd 100644 --- a/tests/integration/targets/ec2_ami_tpm/defaults/main.yml +++ b/tests/integration/targets/ec2_ami_tpm/defaults/main.yml @@ -2,7 +2,7 @@ availability_zone: "{{ ec2_availability_zone_names[0] }}" # defaults file for test_ec2_ami -ec2_ami_name: "{{resource_prefix}}" +ec2_ami_name: "{{ resource_prefix }}" ec2_ami_description: Created by ansible integration tests ec2_ami_image: "{{ ec2_ami_id }}" diff --git a/tests/integration/targets/ec2_ami_tpm/tasks/main.yml b/tests/integration/targets/ec2_ami_tpm/tasks/main.yml index eb9a23c5c96..393ad6cfbdb 100644 --- a/tests/integration/targets/ec2_ami_tpm/tasks/main.yml +++ b/tests/integration/targets/ec2_ami_tpm/tasks/main.yml @@ -10,7 +10,7 @@ # ============================================================ # SETUP: vpc, ec2 key pair, subnet, security group, ec2 instance, snapshot - - name: create a VPC to work in + - name: Create a VPC to work in amazon.aws.ec2_vpc_net: cidr_block: "{{ vpc_cidr }}" state: present @@ -19,13 +19,13 @@ Name: "{{ ec2_ami_name }}_setup" register: setup_vpc - - name: create a key pair to use for creating an ec2 instance + - name: Create a key pair to use for creating an ec2 instance amazon.aws.ec2_key: name: "{{ ec2_ami_name }}_setup" state: present register: setup_key - - name: create a subnet to use for creating an ec2 instance + - name: Create a subnet to use for creating an ec2 instance amazon.aws.ec2_vpc_subnet: az: "{{ availability_zone }}" tags: "{{ ec2_ami_name }}_setup" @@ -36,7 +36,7 @@ Name: "{{ ec2_ami_name }}_setup" register: setup_subnet - - name: create a security group to use for creating an ec2 instance + - name: Create a security group to use for creating an ec2 instance amazon.aws.ec2_security_group: name: "{{ ec2_ami_name }}_setup" description: created by Ansible integration tests @@ -44,7 +44,7 @@ vpc_id: "{{ setup_vpc.vpc.id }}" register: setup_sg - - name: provision ec2 instance to create an image + - name: Provision ec2 instance to create an image amazon.aws.ec2_instance: state: running key_name: "{{ setup_key.key.name }}" @@ -64,7 +64,7 @@ ansible.builtin.set_fact: ec2_instance_id: "{{ setup_instance.instances[0].instance_id }}" - - name: take a snapshot of the instance to create an image + - name: Take a snapshot of the instance to create an image amazon.aws.ec2_snapshot: instance_id: "{{ ec2_instance_id }}" device_name: "{{ ec2_ami_root_disk }}" @@ -73,7 +73,7 @@ # ============================================================ - - name: create an image from the snapshot with boot_mode and tpm_support + - name: Create an image from the snapshot with boot_mode and tpm_support amazon.aws.ec2_ami: name: "{{ ec2_ami_name }}_ami-boot-tpm" description: "{{ ec2_ami_description }}" @@ -94,18 +94,18 @@ register: result ignore_errors: true - - name: set image id fact for deletion later + - name: Set image id fact for deletion later ansible.builtin.set_fact: ec2_ami_image_id_boot_tpm: "{{ result.image_id }}" ec2_ami_snapshot_boot_tpm: "{{ result.block_device_mapping[ec2_ami_root_disk].snapshot_id }}" - - name: gather facts about the image created + - name: Gather facts about the image created amazon.aws.ec2_ami_info: image_ids: "{{ ec2_ami_image_id_boot_tpm }}" register: ami_facts_result_boot_tpm ignore_errors: true - - name: assert that new ami has been created with desired options + - name: Assert that new ami has been created with desired options ansible.builtin.assert: that: - result.changed @@ -124,7 +124,7 @@ ansible.builtin.debug: msg: "***** TESTING COMPLETE. COMMENCE TEARDOWN *****" - - name: remove setup ec2 instance + - name: Remove setup ec2 instance amazon.aws.ec2_instance: state: absent instance_ids: @@ -132,26 +132,26 @@ wait: true ignore_errors: true - - name: delete ami + - name: Delete ami amazon.aws.ec2_ami: state: absent image_id: "{{ ec2_ami_image_id_boot_tpm }}" wait: true ignore_errors: true - - name: remove setup snapshot of ec2 instance + - name: Remove setup snapshot of ec2 instance amazon.aws.ec2_snapshot: state: absent snapshot_id: "{{ setup_snapshot.snapshot_id }}" ignore_errors: true - - name: remove setup keypair + - name: Remove setup keypair amazon.aws.ec2_key: - name: "{{ec2_ami_name}}_setup" + name: "{{ ec2_ami_name }}_setup" state: absent ignore_errors: true - - name: remove setup security group + - name: Remove setup security group amazon.aws.ec2_security_group: name: "{{ ec2_ami_name }}_setup" description: created by Ansible integration tests @@ -159,10 +159,10 @@ vpc_id: "{{ setup_vpc.vpc.id }}" ignore_errors: true - - name: remove setup subnet + - name: Remove setup subnet amazon.aws.ec2_vpc_subnet: az: "{{ availability_zone }}" - tags: "{{ec2_ami_name}}_setup" + tags: "{{ ec2_ami_name }}_setup" vpc_id: "{{ setup_vpc.vpc.id }}" cidr: "{{ subnet_cidr }}" state: absent @@ -170,7 +170,7 @@ Name: "{{ ec2_ami_name }}_setup" ignore_errors: true - - name: remove setup VPC + - name: Remove setup VPC amazon.aws.ec2_vpc_net: cidr_block: "{{ vpc_cidr }}" state: absent diff --git a/tests/integration/targets/ec2_eip/tasks/allocate.yml b/tests/integration/targets/ec2_eip/tasks/allocate.yml index c618681defa..e370a18d0e3 100644 --- a/tests/integration/targets/ec2_eip/tasks/allocate.yml +++ b/tests/integration/targets/ec2_eip/tasks/allocate.yml @@ -1,3 +1,4 @@ +--- - name: Test EIP allocation block: # ------------------------------------------------------------------------------------------ diff --git a/tests/integration/targets/ec2_eip/tasks/release.yml b/tests/integration/targets/ec2_eip/tasks/release.yml index 2303b42ebb8..c0e231f3dba 100644 --- a/tests/integration/targets/ec2_eip/tasks/release.yml +++ b/tests/integration/targets/ec2_eip/tasks/release.yml @@ -1,3 +1,4 @@ +--- - name: Test release EIP block: # ------------------------------------------------------------------------------------------ diff --git a/tests/integration/targets/ec2_eip/tasks/reuse_with_tag.yml b/tests/integration/targets/ec2_eip/tasks/reuse_with_tag.yml index 30b87d2dda3..9924d5f2951 100644 --- a/tests/integration/targets/ec2_eip/tasks/reuse_with_tag.yml +++ b/tests/integration/targets/ec2_eip/tasks/reuse_with_tag.yml @@ -4,7 +4,7 @@ # ------------------------------------------------------------------------------------------ # Reuse with tag - No match available # ------------------------------------------------------------------------------------------ - - name: attempt reusing an existing EIP with a tag (No match available) - check_mode + - name: Attempt reusing an existing EIP with a tag (No match available) - check_mode amazon.aws.ec2_eip: state: present reuse_existing_ip_allowed: true @@ -17,7 +17,7 @@ that: - no_tagged_eip is changed - - name: attempt reusing an existing EIP with a tag (No match available) + - name: Attempt reusing an existing EIP with a tag (No match available) amazon.aws.ec2_eip: state: present reuse_existing_ip_allowed: true diff --git a/tests/integration/targets/ec2_eip/tasks/setup.yml b/tests/integration/targets/ec2_eip/tasks/setup.yml index 44f3f50871f..1de785f5acb 100644 --- a/tests/integration/targets/ec2_eip/tasks/setup.yml +++ b/tests/integration/targets/ec2_eip/tasks/setup.yml @@ -1,3 +1,4 @@ +--- - name: Get the current caller identity facts amazon.aws.aws_caller_info: register: caller_info diff --git a/tests/integration/targets/ec2_eip/tasks/tagging.yml b/tests/integration/targets/ec2_eip/tasks/tagging.yml index 254cc785866..05d3d9f43cc 100644 --- a/tests/integration/targets/ec2_eip/tasks/tagging.yml +++ b/tests/integration/targets/ec2_eip/tasks/tagging.yml @@ -240,4 +240,4 @@ - name: Release EIPs ansible.builtin.include_tasks: tasks/common.yml vars: - delete_eips: true \ No newline at end of file + delete_eips: true diff --git a/tests/integration/targets/ec2_eip/tasks/update_reverse_dns_record.yml b/tests/integration/targets/ec2_eip/tasks/update_reverse_dns_record.yml index 4fc63b55ed9..0cc825e7255 100644 --- a/tests/integration/targets/ec2_eip/tasks/update_reverse_dns_record.yml +++ b/tests/integration/targets/ec2_eip/tasks/update_reverse_dns_record.yml @@ -1,3 +1,4 @@ +--- - name: Test EIP allocation and reverse DNS record operations block: # ------------------------------------------------------------------------------------------ @@ -38,12 +39,12 @@ record: "{{ test_domain }}" type: A ttl: 7200 - value: "{{ eip.public_ip}}" + value: "{{ eip.public_ip }}" identifier: "{{ resource_prefix }}" wait: true - name: Wait for reverse DNS record update to complete - pause: + ansible.builtin.pause: minutes: 3 - name: Assert that task result was as expected @@ -95,11 +96,10 @@ - eip.allocation_id is defined and eip.allocation_id.startswith("eipalloc-") - name: Wait for reverse DNS record update to complete - pause: + ansible.builtin.pause: minutes: 3 always: - - name: Delete EIP IP address an A record amazon.aws.route53: state: present @@ -107,7 +107,7 @@ record: "{{ test_domain }}" type: A ttl: 7200 - value: "{{ eip.public_ip}}" + value: "{{ eip.public_ip }}" identifier: "{{ resource_prefix }}" wait: true diff --git a/tests/integration/targets/ec2_eni/defaults/main.yml b/tests/integration/targets/ec2_eni/defaults/main.yml index 613a0142049..eccf40729a9 100644 --- a/tests/integration/targets/ec2_eni/defaults/main.yml +++ b/tests/integration/targets/ec2_eni/defaults/main.yml @@ -3,8 +3,8 @@ availability_zone: "{{ ec2_availability_zone_names[0] }}" vpc_seed_a: "{{ resource_prefix }}" vpc_seed_b: "{{ resource_prefix }}-ec2_eni" -vpc_prefix: 10.{{ 256 | random(seed=vpc_seed_a) }}.{{ 256 | random(seed=vpc_seed_b ) }} -vpc_cidr: "{{ vpc_prefix}}.128/26" +vpc_prefix: 10.{{ 256 | random(seed=vpc_seed_a) }}.{{ 256 | random(seed=vpc_seed_b) }} +vpc_cidr: "{{ vpc_prefix }}.128/26" ip_1: "{{ vpc_prefix }}.132" ip_2: "{{ vpc_prefix }}.133" ip_3: "{{ vpc_prefix }}.134" diff --git a/tests/integration/targets/ec2_eni/tasks/main.yaml b/tests/integration/targets/ec2_eni/tasks/main.yaml index cced1e15707..c59ec0210d3 100644 --- a/tests/integration/targets/ec2_eni/tasks/main.yaml +++ b/tests/integration/targets/ec2_eni/tasks/main.yaml @@ -8,7 +8,7 @@ block: # ============================================================ - - name: create a VPC + - name: Create a VPC amazon.aws.ec2_vpc_net: name: "{{ resource_prefix }}-vpc" state: present @@ -18,7 +18,7 @@ Description: Created by ansible-test register: vpc_result - - name: create a subnet + - name: Create a subnet amazon.aws.ec2_vpc_subnet: cidr: "{{ vpc_cidr }}" az: "{{ availability_zone }}" @@ -29,7 +29,7 @@ state: present register: vpc_subnet_result - - name: create a security group + - name: Create a security group amazon.aws.ec2_security_group: name: "{{ resource_prefix }}-sg" description: Created by {{ resource_prefix }} @@ -62,27 +62,27 @@ - 1 # We only need these instances to be running - - name: set variables for the instance IDs + - name: Set variables for the instance IDs ansible.builtin.set_fact: instance_id_1: "{{ ec2_instances.results[0].instance_ids[0] }}" instance_id_2: "{{ ec2_instances.results[1].instance_ids[0] }}" # ============================================================ - - name: test attaching and detaching network interfaces + - name: Test attaching and detaching network interfaces ansible.builtin.include_tasks: ./test_eni_basic_creation.yaml - - name: test attaching and detaching network interfaces + - name: Test attaching and detaching network interfaces ansible.builtin.include_tasks: ./test_ipaddress_assign.yaml - - name: test attaching and detaching network interfaces + - name: Test attaching and detaching network interfaces ansible.builtin.include_tasks: ./test_attachment.yaml - - name: test attaching and detaching multiple network interfaces + - name: Test attaching and detaching multiple network interfaces ansible.builtin.include_tasks: ./test_create_attached_multiple.yml - - name: test modifying source_dest_check + - name: Test modifying source_dest_check ansible.builtin.include_tasks: ./test_modifying_source_dest_check.yaml - - name: test modifying tags + - name: Test modifying tags ansible.builtin.include_tasks: ./test_modifying_tags.yaml - - name: test modifying delete_on_termination + - name: Test modifying delete_on_termination ansible.builtin.include_tasks: ./test_modifying_delete_on_termination.yaml - - name: test deleting ENIs + - name: Test deleting ENIs ansible.builtin.include_tasks: ./test_deletion.yaml always: # ============================================================ @@ -92,7 +92,7 @@ amazon.aws.ec2_eni_info: {} # ============================================================ - - name: remove the network interfaces + - name: Remove the network interfaces amazon.aws.ec2_eni: eni_id: "{{ item }}" force_detach: true @@ -104,7 +104,7 @@ - "{{ eni_id_2 | default(omit) }}" - "{{ eni_id_3 | default(omit) }}" - - name: terminate the instances + - name: Terminate the instances amazon.aws.ec2_instance: state: absent instance_ids: @@ -115,7 +115,7 @@ retries: 5 when: instance_id_1 is defined and instance_id_2 is defined - - name: remove the security group + - name: Remove the security group amazon.aws.ec2_security_group: name: "{{ resource_prefix }}-sg" description: "{{ resource_prefix }}" @@ -125,7 +125,7 @@ ignore_errors: true retries: 5 - - name: remove the subnet + - name: Remove the subnet amazon.aws.ec2_vpc_subnet: cidr: "{{ vpc_cidr }}" az: "{{ availability_zone }}" @@ -135,7 +135,7 @@ retries: 5 when: vpc_subnet_result is defined - - name: remove the VPC + - name: Remove the VPC amazon.aws.ec2_vpc_net: name: "{{ resource_prefix }}-vpc" cidr_block: "{{ vpc_cidr }}" diff --git a/tests/integration/targets/ec2_eni/tasks/test_attachment.yaml b/tests/integration/targets/ec2_eni/tasks/test_attachment.yaml index 53348e4e7c2..02da51094da 100644 --- a/tests/integration/targets/ec2_eni/tasks/test_attachment.yaml +++ b/tests/integration/targets/ec2_eni/tasks/test_attachment.yaml @@ -9,7 +9,7 @@ - "{{ instance_id_2 }}" wait: true -- name: attach the network interface to instance 1 (check mode) +- name: Attach the network interface to instance 1 (check mode) amazon.aws.ec2_eni: instance_id: "{{ instance_id_1 }}" device_index: 1 @@ -24,7 +24,7 @@ that: - result_check_mode.changed -- name: attach the network interface to instance 1 +- name: Attach the network interface to instance 1 amazon.aws.ec2_eni: instance_id: "{{ instance_id_1 }}" device_index: 1 @@ -62,7 +62,7 @@ vars: _interface_0: "{{ eni_info.network_interfaces[0] }}" -- name: verify the eni is attached +- name: Verify the eni is attached amazon.aws.ec2_eni: instance_id: "{{ instance_id_1 }}" device_index: 1 @@ -100,7 +100,7 @@ _interface_0: "{{ eni_info.network_interfaces[0] }}" # ============================================================ -- name: test attaching the network interface to a different instance (check mode) +- name: Test attaching the network interface to a different instance (check mode) amazon.aws.ec2_eni: instance_id: "{{ instance_id_2 }}" device_index: 1 @@ -115,7 +115,7 @@ that: - result_check_mode.changed -- name: test attaching the network interface to a different instance +- name: Test attaching the network interface to a different instance amazon.aws.ec2_eni: instance_id: "{{ instance_id_2 }}" device_index: 1 @@ -140,7 +140,7 @@ _interface_0: "{{ eni_info.network_interfaces[0] }}" # ============================================================ -- name: detach the network interface (check mode) +- name: Detach the network interface (check mode) amazon.aws.ec2_eni: instance_id: "{{ instance_id_2 }}" device_index: 1 @@ -155,7 +155,7 @@ that: - result_check_mode.changed -- name: detach the network interface +- name: Detach the network interface amazon.aws.ec2_eni: instance_id: "{{ instance_id_2 }}" device_index: 1 @@ -176,7 +176,7 @@ vars: _interface_0: "{{ eni_info.network_interfaces[0] }}" -- name: verify the network interface was detached +- name: Verify the network interface was detached amazon.aws.ec2_eni: instance_id: "{{ instance_id_2 }}" device_index: 1 @@ -192,7 +192,7 @@ - result.interface.attachment is undefined # ============================================================ -- name: reattach the network interface to test deleting it +- name: Reattach the network interface to test deleting it amazon.aws.ec2_eni: instance_id: "{{ instance_id_2 }}" device_index: 1 @@ -208,7 +208,7 @@ - result.interface.attachment is defined - result.interface.attachment.instance_id == instance_id_2 -- name: test that deleting the network interface while attached must be intentional +- name: Test that deleting the network interface while attached must be intentional amazon.aws.ec2_eni: eni_id: "{{ eni_id_1 }}" state: absent @@ -228,7 +228,7 @@ - "{{ instance_id_2 }}" wait: true -- name: delete an attached network interface with force_detach (check mode) +- name: Delete an attached network interface with force_detach (check mode) amazon.aws.ec2_eni: force_detach: true eni_id: "{{ eni_id_1 }}" @@ -241,7 +241,7 @@ that: - result_check_mode.changed -- name: delete an attached network interface with force_detach +- name: Delete an attached network interface with force_detach amazon.aws.ec2_eni: force_detach: true eni_id: "{{ eni_id_1 }}" @@ -254,7 +254,7 @@ - result.changed - result.interface.attachment is undefined -- name: test removing a network interface that does not exist +- name: Test removing a network interface that does not exist amazon.aws.ec2_eni: force_detach: true eni_id: "{{ eni_id_1 }}" @@ -267,7 +267,7 @@ - result.interface.attachment is undefined # ============================================================ -- name: recreate the network interface +- name: Recreate the network interface amazon.aws.ec2_eni: device_index: 1 private_ip_address: "{{ ip_1 }}" 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 4fadd3a07eb..52f96f8c6f6 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 @@ -9,11 +9,11 @@ wait: true register: ec2_instances -- name: set variable for the instance ID +- name: Set variable for the instance ID ansible.builtin.set_fact: instance_id_3: "{{ ec2_instances.instances[0].instance_id }}" -#================================================================= +# ================================================================= - name: Create and attach another interface to above instance - check_mode amazon.aws.ec2_eni: @@ -102,9 +102,9 @@ - "'ec2:CreateNetworkInterface' not in result.resource_actions" - "'ec2:ModifyNetworkInterfaceAttribute' not in result.resource_actions" -#================================================================= +# ================================================================= -- name: remove the network interface created in this test +- name: Remove the network interface created in this test amazon.aws.ec2_eni: eni_id: "{{ eni_id_attached_multiple }}" force_detach: true @@ -112,7 +112,7 @@ ignore_errors: true retries: 5 -- name: terminate the instance created in this test +- name: Terminate the instance created in this test amazon.aws.ec2_instance: state: absent instance_ids: diff --git a/tests/integration/targets/ec2_eni/tasks/test_deletion.yaml b/tests/integration/targets/ec2_eni/tasks/test_deletion.yaml index 778ad829a36..43252adb3c0 100644 --- a/tests/integration/targets/ec2_eni/tasks/test_deletion.yaml +++ b/tests/integration/targets/ec2_eni/tasks/test_deletion.yaml @@ -1,6 +1,6 @@ --- # ============================================================ -- name: test deleting the unattached network interface by using the ID (check mode) +- name: Test deleting the unattached network interface by using the ID (check mode) amazon.aws.ec2_eni: eni_id: "{{ eni_id_1 }}" name: "{{ resource_prefix }}" @@ -13,7 +13,7 @@ that: - result_check_mode.changed -- name: test deleting the unattached network interface by using the ID +- name: Test deleting the unattached network interface by using the ID amazon.aws.ec2_eni: eni_id: "{{ eni_id_1 }}" name: "{{ resource_prefix }}" @@ -31,7 +31,7 @@ - '"network_interfaces" in eni_info' - eni_id_1 not in ( eni_info.network_interfaces | selectattr('id') | map(attribute='id') | list ) -- name: test removing the network interface by ID is idempotent (check mode) +- name: Test removing the network interface by ID is idempotent (check mode) amazon.aws.ec2_eni: eni_id: "{{ eni_id_1 }}" name: "{{ resource_prefix }}" @@ -44,7 +44,7 @@ that: - not result_check_mode.changed -- name: test removing the network interface by ID is idempotent +- name: Test removing the network interface by ID is idempotent amazon.aws.ec2_eni: eni_id: "{{ eni_id_1 }}" name: "{{ resource_prefix }}" @@ -58,13 +58,13 @@ - result.interface is undefined # ============================================================ -- name: add a name tag to the other network interface before deleting it +- name: Add a name tag to the other network interface before deleting it amazon.aws.ec2_eni: eni_id: "{{ eni_id_2 }}" name: "{{ resource_prefix }}" state: present -- name: test deleting the unattached network interface by using the name +- name: Test deleting the unattached network interface by using the name amazon.aws.ec2_eni: name: "{{ resource_prefix }}" subnet_id: "{{ vpc_subnet_id }}" @@ -81,7 +81,7 @@ - '"network_interfaces" in eni_info' - eni_id_2 not in ( eni_info.network_interfaces | selectattr('id') | map(attribute='id') | list ) -- name: test removing the network interface by name is idempotent +- name: Test removing the network interface by name is idempotent amazon.aws.ec2_eni: name: "{{ resource_prefix }}" subnet_id: "{{ vpc_subnet_id }}" @@ -93,7 +93,7 @@ - not result.changed - result.interface is undefined -- name: verify that the network interface ID does not exist (retry-delete by ID) +- name: Verify that the network interface ID does not exist (retry-delete by ID) amazon.aws.ec2_eni: eni_id: "{{ eni_id_2 }}" state: absent diff --git a/tests/integration/targets/ec2_eni/tasks/test_eni_basic_creation.yaml b/tests/integration/targets/ec2_eni/tasks/test_eni_basic_creation.yaml index 28b428ec657..573e784d82d 100644 --- a/tests/integration/targets/ec2_eni/tasks/test_eni_basic_creation.yaml +++ b/tests/integration/targets/ec2_eni/tasks/test_eni_basic_creation.yaml @@ -1,6 +1,6 @@ --- # ============================================================ -- name: create a network interface (check mode) +- name: Create a network interface (check mode) amazon.aws.ec2_eni: device_index: 1 private_ip_address: "{{ ip_1 }}" @@ -13,7 +13,7 @@ that: - result_check_mode.changed -- name: create a network interface +- name: Create a network interface amazon.aws.ec2_eni: device_index: 1 private_ip_address: "{{ ip_1 }}" @@ -90,7 +90,7 @@ - '"vpc_id" in _interface_0' - _interface_0.vpc_id == vpc_id -- name: test idempotence by using the same private_ip_address (check mode) +- name: Test idempotence by using the same private_ip_address (check mode) amazon.aws.ec2_eni: device_index: 1 private_ip_address: "{{ ip_1 }}" @@ -103,7 +103,7 @@ that: - not result_check_mode.changed -- name: test idempotence by using the same private_ip_address +- name: Test idempotence by using the same private_ip_address amazon.aws.ec2_eni: device_index: 1 private_ip_address: "{{ ip_1 }}" @@ -119,7 +119,7 @@ # ============================================================ -- name: create a second network interface to test IP reassignment +- name: Create a second network interface to test IP reassignment amazon.aws.ec2_eni: device_index: 1 private_ip_address: "{{ ip_5 }}" @@ -132,7 +132,7 @@ - result.changed - result.interface.id != eni_id_1 -- name: save the second network interface ID for cleanup +- name: Save the second network interface ID for cleanup ansible.builtin.set_fact: eni_id_2: "{{ result.interface.id }}" @@ -246,7 +246,7 @@ # ========================================================= -- name: create another network interface without private_ip_address +- name: Create another network interface without private_ip_address amazon.aws.ec2_eni: device_index: 1 subnet_id: "{{ vpc_subnet_id }}" @@ -257,6 +257,6 @@ that: - result_no_private_ip.changed -- name: save the third network interface ID for cleanup +- name: Save the third network interface ID for cleanup ansible.builtin.set_fact: eni_id_3: "{{ result_no_private_ip.interface.id }}" diff --git a/tests/integration/targets/ec2_eni/tasks/test_ipaddress_assign.yaml b/tests/integration/targets/ec2_eni/tasks/test_ipaddress_assign.yaml index c86319e85f5..692ae3d8dd9 100644 --- a/tests/integration/targets/ec2_eni/tasks/test_ipaddress_assign.yaml +++ b/tests/integration/targets/ec2_eni/tasks/test_ipaddress_assign.yaml @@ -1,6 +1,6 @@ --- # ============================================================ -- name: add two implicit secondary IPs (check mode) +- name: Add two implicit secondary IPs (check mode) amazon.aws.ec2_eni: device_index: 1 private_ip_address: "{{ ip_1 }}" @@ -14,7 +14,7 @@ that: - result_check_mode.changed -- name: add two implicit secondary IPs +- name: Add two implicit secondary IPs amazon.aws.ec2_eni: device_index: 1 private_ip_address: "{{ ip_1 }}" @@ -36,7 +36,7 @@ vars: _interface_0: "{{ eni_info.network_interfaces[0] }}" -- name: test idempotence with two implicit secondary IPs (check mode) +- name: Test idempotence with two implicit secondary IPs (check mode) amazon.aws.ec2_eni: device_index: 1 private_ip_address: "{{ ip_1 }}" @@ -50,7 +50,7 @@ that: - not result_check_mode.changed -- name: test idempotence with two implicit secondary IPs +- name: Test idempotence with two implicit secondary IPs amazon.aws.ec2_eni: device_index: 1 private_ip_address: "{{ ip_1 }}" @@ -73,7 +73,7 @@ _interface_0: "{{ eni_info.network_interfaces[0] }}" # ============================================================ -- name: ensure secondary addresses are only removed if purge is set to true +- name: Ensure secondary addresses are only removed if purge is set to true amazon.aws.ec2_eni: purge_secondary_private_ip_addresses: false device_index: 1 @@ -101,15 +101,15 @@ # Using secondary_private_ip_address_count leads to unpredicable IP assignment # For the following test, first find an IP that has not been used yet -- name: save the list of private IPs in use +- name: Save the list of private IPs in use ansible.builtin.set_fact: current_private_ips: "{{ result.interface | json_query('private_ip_addresses[*].private_ip_address') | list }}" -- name: set new_secondary_ip to an IP that has not been used +- name: Set new_secondary_ip to an IP that has not been used ansible.builtin.set_fact: new_secondary_ip: "{{ [ip_2, ip_3, ip_4] | difference(current_private_ips) | first }}" -- name: add an explicit secondary address without purging the ones added implicitly +- name: Add an explicit secondary address without purging the ones added implicitly amazon.aws.ec2_eni: purge_secondary_private_ip_addresses: false device_index: 1 @@ -137,7 +137,7 @@ _private_ips: "{{ eni_info.network_interfaces | map(attribute='private_ip_addresses') | flatten | map(attribute='private_ip_address') | list }}" # ============================================================ -- name: remove secondary address (check mode) +- name: Remove secondary address (check mode) amazon.aws.ec2_eni: purge_secondary_private_ip_addresses: true device_index: 1 @@ -152,7 +152,7 @@ that: - result_check_mode.changed -- name: remove secondary address +- name: Remove secondary address amazon.aws.ec2_eni: purge_secondary_private_ip_addresses: true device_index: 1 @@ -175,7 +175,7 @@ vars: _interface_0: "{{ eni_info.network_interfaces[0] }}" -- name: test idempotent behavior purging secondary addresses (check mode) +- name: Test idempotent behavior purging secondary addresses (check mode) amazon.aws.ec2_eni: purge_secondary_private_ip_addresses: true device_index: 1 @@ -190,7 +190,7 @@ that: - not result_check_mode.changed -- name: test idempotent behavior purging secondary addresses +- name: Test idempotent behavior purging secondary addresses amazon.aws.ec2_eni: purge_secondary_private_ip_addresses: true device_index: 1 @@ -240,7 +240,7 @@ vars: _interface_0: "{{ eni_info.network_interfaces[0] }}" -- name: test that reassignment of an IP already in use fails when not explcitly allowed (default for allow_reassignment == False) +- name: Test that reassignment of an IP already in use fails when not explcitly allowed (default for allow_reassignment == False) amazon.aws.ec2_eni: device_index: 1 private_ip_address: "{{ ip_1 }}" @@ -259,7 +259,7 @@ - '"move is not allowed" in result.msg' # ============================================================ -- name: allow reassignment to add the list of secondary addresses +- name: Allow reassignment to add the list of secondary addresses amazon.aws.ec2_eni: allow_reassignment: true device_index: 1 @@ -278,7 +278,7 @@ - result.interface.id == eni_id_1 - result.interface.private_ip_addresses | length == 4 -- name: test reassigment is idempotent +- name: Test reassigment is idempotent amazon.aws.ec2_eni: allow_reassignment: true device_index: 1 @@ -298,7 +298,7 @@ # ============================================================ -- name: purge all the secondary addresses +- name: Purge all the secondary addresses amazon.aws.ec2_eni: purge_secondary_private_ip_addresses: true device_index: 1 diff --git a/tests/integration/targets/ec2_eni/tasks/test_modifying_delete_on_termination.yaml b/tests/integration/targets/ec2_eni/tasks/test_modifying_delete_on_termination.yaml index 8660a5394d1..486417754b0 100644 --- a/tests/integration/targets/ec2_eni/tasks/test_modifying_delete_on_termination.yaml +++ b/tests/integration/targets/ec2_eni/tasks/test_modifying_delete_on_termination.yaml @@ -1,7 +1,7 @@ --- # ============================================================ -- name: ensure delete_on_termination defaults to False +- name: Ensure delete_on_termination defaults to False amazon.aws.ec2_eni: instance_id: "{{ instance_id_2 }}" device_index: 1 @@ -24,7 +24,7 @@ # ============================================================ -- name: enable delete_on_termination (check mode) +- name: Enable delete_on_termination (check mode) amazon.aws.ec2_eni: instance_id: "{{ instance_id_2 }}" device_index: 1 @@ -40,7 +40,7 @@ that: - result_check_mode.changed -- name: enable delete_on_termination +- name: Enable delete_on_termination amazon.aws.ec2_eni: instance_id: "{{ instance_id_2 }}" device_index: 1 @@ -64,7 +64,7 @@ vars: _interface_0: "{{ eni_info.network_interfaces[0] }}" -- name: test idempotent behavior enabling delete_on_termination (check mode) +- name: Test idempotent behavior enabling delete_on_termination (check mode) amazon.aws.ec2_eni: instance_id: "{{ instance_id_2 }}" device_index: 1 @@ -80,7 +80,7 @@ that: - not result_check_mode.changed -- name: test idempotent behavior enabling delete_on_termination +- name: Test idempotent behavior enabling delete_on_termination amazon.aws.ec2_eni: instance_id: "{{ instance_id_2 }}" device_index: 1 @@ -98,7 +98,7 @@ # ============================================================ -- name: disable delete_on_termination (check mode) +- name: Disable delete_on_termination (check mode) amazon.aws.ec2_eni: instance_id: "{{ instance_id_2 }}" device_index: 1 @@ -114,7 +114,7 @@ that: - result_check_mode.changed -- name: disable delete_on_termination +- name: Disable delete_on_termination amazon.aws.ec2_eni: instance_id: "{{ instance_id_2 }}" device_index: 1 @@ -140,14 +140,14 @@ # ============================================================ -- name: terminate the instance to make sure the attached ENI remains +- name: Terminate the instance to make sure the attached ENI remains amazon.aws.ec2_instance: state: absent instance_ids: - "{{ instance_id_2 }}" wait: true -- name: verify the eni still exists +- name: Verify the eni still exists amazon.aws.ec2_eni: eni_id: "{{ eni_id_1 }}" state: present @@ -161,7 +161,7 @@ # ============================================================ -- name: ensure the network interface is attached +- name: Ensure the network interface is attached amazon.aws.ec2_eni: instance_id: "{{ instance_id_1 }}" device_index: 1 @@ -171,7 +171,7 @@ attached: true register: result -- name: ensure delete_on_termination is true +- name: Ensure delete_on_termination is true amazon.aws.ec2_eni: instance_id: "{{ instance_id_1 }}" device_index: 1 @@ -182,14 +182,14 @@ delete_on_termination: true register: result -- name: test terminating the instance after setting delete_on_termination to true +- name: Test terminating the instance after setting delete_on_termination to true amazon.aws.ec2_instance: state: absent instance_ids: - "{{ instance_id_1 }}" wait: true -- name: verify the eni was also removed +- name: Verify the eni was also removed amazon.aws.ec2_eni: eni_id: "{{ eni_id_1 }}" state: absent @@ -207,7 +207,7 @@ # ============================================================ -- name: recreate the network interface +- name: Recreate the network interface amazon.aws.ec2_eni: device_index: 1 private_ip_address: "{{ ip_1 }}" diff --git a/tests/integration/targets/ec2_eni/tasks/test_modifying_source_dest_check.yaml b/tests/integration/targets/ec2_eni/tasks/test_modifying_source_dest_check.yaml index d83b018bfc3..6422012f376 100644 --- a/tests/integration/targets/ec2_eni/tasks/test_modifying_source_dest_check.yaml +++ b/tests/integration/targets/ec2_eni/tasks/test_modifying_source_dest_check.yaml @@ -1,6 +1,6 @@ --- # ============================================================ -- name: test source_dest_check defaults to true (check mode) +- name: Test source_dest_check defaults to true (check mode) amazon.aws.ec2_eni: eni_id: "{{ eni_id_1 }}" source_dest_check: true @@ -12,7 +12,7 @@ that: - not result_check_mode.changed -- name: test source_dest_check defaults to true +- name: Test source_dest_check defaults to true amazon.aws.ec2_eni: eni_id: "{{ eni_id_1 }}" source_dest_check: true @@ -25,7 +25,7 @@ - result.interface.source_dest_check == true # ============================================================ -- name: disable source_dest_check +- name: Disable source_dest_check amazon.aws.ec2_eni: eni_id: "{{ eni_id_1 }}" source_dest_check: false @@ -49,7 +49,7 @@ vars: _interface_0: "{{ eni_info.network_interfaces[0] }}" -- name: test idempotence disabling source_dest_check (check mode) +- name: Test idempotence disabling source_dest_check (check mode) amazon.aws.ec2_eni: eni_id: "{{ eni_id_1 }}" source_dest_check: false @@ -61,7 +61,7 @@ that: - not result_check_mode.changed -- name: test idempotence disabling source_dest_check +- name: Test idempotence disabling source_dest_check amazon.aws.ec2_eni: eni_id: "{{ eni_id_1 }}" source_dest_check: false @@ -74,7 +74,7 @@ - result.interface.source_dest_check == false # ============================================================ -- name: enable source_dest_check +- name: Enable source_dest_check amazon.aws.ec2_eni: eni_id: "{{ eni_id_1 }}" source_dest_check: true diff --git a/tests/integration/targets/ec2_eni/tasks/test_modifying_tags.yaml b/tests/integration/targets/ec2_eni/tasks/test_modifying_tags.yaml index 0a7cca027c0..9a7b0673ac4 100644 --- a/tests/integration/targets/ec2_eni/tasks/test_modifying_tags.yaml +++ b/tests/integration/targets/ec2_eni/tasks/test_modifying_tags.yaml @@ -1,6 +1,6 @@ --- # ============================================================ -- name: verify there are no tags associated with the network interface +- name: Verify there are no tags associated with the network interface amazon.aws.ec2_eni: eni_id: "{{ eni_id_1 }}" state: present @@ -14,7 +14,7 @@ - result.interface.name is undefined # ============================================================ -- name: add tags to the network interface (check mode) +- name: Add tags to the network interface (check mode) amazon.aws.ec2_eni: eni_id: "{{ eni_id_1 }}" state: present @@ -28,7 +28,7 @@ that: - result_check_mode.changed -- name: add tags to the network interface +- name: Add tags to the network interface amazon.aws.ec2_eni: eni_id: "{{ eni_id_1 }}" state: present @@ -59,7 +59,7 @@ _interface_0: "{{ eni_info.network_interfaces[0] }}" # ============================================================ -- name: test idempotence by using the Name tag and the subnet (check mode) +- name: Test idempotence by using the Name tag and the subnet (check mode) amazon.aws.ec2_eni: name: "{{ resource_prefix }}" state: present @@ -71,7 +71,7 @@ that: - not result_check_mode.changed -- name: test idempotence by using the Name tag and the subnet +- name: Test idempotence by using the Name tag and the subnet amazon.aws.ec2_eni: name: "{{ resource_prefix }}" state: present @@ -84,7 +84,7 @@ - result.interface.id == eni_id_1 # ============================================================ -- name: test tags are not purged if tags are null even if name is provided (check mode) +- name: Test tags are not purged if tags are null even if name is provided (check mode) amazon.aws.ec2_eni: name: "{{ resource_prefix }}" state: present @@ -96,7 +96,7 @@ that: - not result_check_mode.changed -- name: test tags are not purged if tags are null even if name is provided +- name: Test tags are not purged if tags are null even if name is provided amazon.aws.ec2_eni: name: "{{ resource_prefix }}" state: present @@ -122,7 +122,7 @@ _interface_0: "{{ eni_info.network_interfaces[0] }}" # ============================================================ -- name: test setting purge tags to false +- name: Test setting purge tags to false amazon.aws.ec2_eni: eni_id: "{{ eni_id_1 }}" state: present @@ -148,7 +148,7 @@ _interface_0: "{{ eni_info.network_interfaces[0] }}" # ============================================================ -- name: test adding a new tag without removing any others +- name: Test adding a new tag without removing any others amazon.aws.ec2_eni: eni_id: "{{ eni_id_1 }}" state: present @@ -177,7 +177,7 @@ _interface_0: "{{ eni_info.network_interfaces[0] }}" # ============================================================ -- name: test purging tags and adding a new one +- name: Test purging tags and adding a new one amazon.aws.ec2_eni: name: "{{ resource_prefix }}" state: present @@ -204,7 +204,7 @@ vars: _interface_0: "{{ eni_info.network_interfaces[0] }}" -- name: test purging tags and adding a new one is idempotent +- name: Test purging tags and adding a new one is idempotent amazon.aws.ec2_eni: name: "{{ resource_prefix }}" state: present @@ -232,7 +232,7 @@ _interface_0: "{{ eni_info.network_interfaces[0] }}" # ============================================================ -- name: test purging all tags +- name: Test purging all tags amazon.aws.ec2_eni: eni_id: "{{ eni_id_1 }}" state: present diff --git a/tests/integration/targets/ec2_instance_block_devices/defaults/main.yml b/tests/integration/targets/ec2_instance_block_devices/defaults/main.yml index 251a9bcb35b..9e58058f1e3 100644 --- a/tests/integration/targets/ec2_instance_block_devices/defaults/main.yml +++ b/tests/integration/targets/ec2_instance_block_devices/defaults/main.yml @@ -1,4 +1,4 @@ --- # defaults file for ec2_instance_block_devices ec2_instance_type: t3.micro -ec2_instance_tag_TestId: "{{ resource_prefix }}-block-devices" +ec2_instance_tag_testid: "{{ resource_prefix }}-block-devices" 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 14ee2b6b977..5e1672920ff 100644 --- a/tests/integration/targets/ec2_instance_block_devices/tasks/main.yml +++ b/tests/integration/targets/ec2_instance_block_devices/tasks/main.yml @@ -20,7 +20,7 @@ delete_on_termination: true volume_type: standard tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" instance_type: "{{ ec2_instance_type }}" wait: true register: block_device_instances @@ -54,7 +54,7 @@ delete_on_termination: true volume_type: standard tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" instance_type: "{{ ec2_instance_type }}" check_mode: true @@ -99,7 +99,7 @@ volume_type: gp3 throughput: 500 tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" instance_type: "{{ ec2_instance_type }}" wait: true register: block_device_instances_gp3 diff --git a/tests/integration/targets/ec2_instance_checkmode_tests/defaults/main.yml b/tests/integration/targets/ec2_instance_checkmode_tests/defaults/main.yml index 7f684dcfe91..d44a8e0b280 100644 --- a/tests/integration/targets/ec2_instance_checkmode_tests/defaults/main.yml +++ b/tests/integration/targets/ec2_instance_checkmode_tests/defaults/main.yml @@ -1,4 +1,4 @@ --- # defaults file for ec2_instance_checkmode_tests ec2_instance_type: t3.micro -ec2_instance_tag_TestId: "{{ resource_prefix }}-instance-checkmode" +ec2_instance_tag_testid: "{{ resource_prefix }}-instance-checkmode" 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 07f48ff8afb..eb60a95c9df 100644 --- a/tests/integration/targets/ec2_instance_checkmode_tests/tasks/main.yml +++ b/tests/integration/targets/ec2_instance_checkmode_tests/tasks/main.yml @@ -16,7 +16,7 @@ vpc_subnet_id: "{{ testing_subnet_a.subnet.id }}" wait: false tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" TestTag: Some Value register: basic_instance @@ -29,17 +29,17 @@ instance_type: "{{ ec2_instance_type }}" vpc_subnet_id: "{{ testing_subnet_b.subnet.id }}" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" TestTag: Some Value check_mode: true - - name: fact presented ec2 instance + - name: Fact presented ec2 instance amazon.aws.ec2_instance_info: filters: tag:Name: "{{ resource_prefix }}-checkmode-comparison" register: presented_instance_fact - - name: fact checkmode ec2 instance + - name: Fact checkmode ec2 instance amazon.aws.ec2_instance_info: filters: tag:Name: "{{ resource_prefix }}-checkmode-comparison-checkmode" @@ -57,11 +57,11 @@ name: "{{ resource_prefix }}-checkmode-comparison" vpc_subnet_id: "{{ testing_subnet_a.subnet.id }}" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" TestTag: Some Value check_mode: true - - name: fact ec2 instance + - name: Fact ec2 instance amazon.aws.ec2_instance_info: filters: tag:Name: "{{ resource_prefix }}-checkmode-comparison" @@ -78,12 +78,12 @@ name: "{{ resource_prefix }}-checkmode-comparison" vpc_subnet_id: "{{ testing_subnet_a.subnet.id }}" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" TestTag: Some Value wait: true register: instance_stop - - name: fact stopped ec2 instance + - name: Fact stopped ec2 instance amazon.aws.ec2_instance_info: filters: tag:Name: "{{ resource_prefix }}-checkmode-comparison" @@ -100,11 +100,11 @@ name: "{{ resource_prefix }}-checkmode-comparison" vpc_subnet_id: "{{ testing_subnet_a.subnet.id }}" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" TestTag: Some Value check_mode: true - - name: fact ec2 instance + - name: Fact ec2 instance amazon.aws.ec2_instance_info: filters: tag:Name: "{{ resource_prefix }}-checkmode-comparison" @@ -121,10 +121,10 @@ name: "{{ resource_prefix }}-checkmode-comparison" vpc_subnet_id: "{{ testing_subnet_a.subnet.id }}" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" TestTag: Some Value - - name: fact ec2 instance. + - name: Fact ec2 instance. amazon.aws.ec2_instance_info: filters: tag:Name: "{{ resource_prefix }}-checkmode-comparison" @@ -141,11 +141,11 @@ name: "{{ resource_prefix }}-checkmode-comparison" vpc_subnet_id: "{{ testing_subnet_a.subnet.id }}" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" TestTag: Some Other Value check_mode: true - - name: fact ec2 instance. + - name: Fact ec2 instance. amazon.aws.ec2_instance_info: filters: tag:Name: "{{ resource_prefix }}-checkmode-comparison" @@ -162,12 +162,12 @@ name: "{{ resource_prefix }}-checkmode-comparison" vpc_subnet_id: "{{ testing_subnet_a.subnet.id }}" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" TestTag: Some Value wait: true check_mode: true - - name: fact ec2 instance + - name: Fact ec2 instance amazon.aws.ec2_instance_info: filters: tag:Name: "{{ resource_prefix }}-checkmode-comparison" @@ -184,11 +184,11 @@ name: "{{ resource_prefix }}-checkmode-comparison" vpc_subnet_id: "{{ testing_subnet_a.subnet.id }}" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" TestTag: Some Value wait: true - - name: fact ec2 instance + - name: Fact ec2 instance amazon.aws.ec2_instance_info: filters: tag:Name: "{{ resource_prefix }}-checkmode-comparison" @@ -204,6 +204,6 @@ amazon.aws.ec2_instance: state: absent filters: - tag:TestId: "{{ ec2_instance_tag_TestId }}" + tag:TestId: "{{ ec2_instance_tag_testid }}" wait: true ignore_errors: true diff --git a/tests/integration/targets/ec2_instance_cpu_options/defaults/main.yml b/tests/integration/targets/ec2_instance_cpu_options/defaults/main.yml index be83a4f46ae..19e14fd2ea3 100644 --- a/tests/integration/targets/ec2_instance_cpu_options/defaults/main.yml +++ b/tests/integration/targets/ec2_instance_cpu_options/defaults/main.yml @@ -1,4 +1,4 @@ --- # defaults file for ec2_instance_cpu_options ec2_instance_type: t3.micro -ec2_instance_tag_TestId: "{{ resource_prefix }}-cpu-options" +ec2_instance_tag_testid: "{{ resource_prefix }}-cpu-options" 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 cc6b30ef353..368ef0408e8 100644 --- a/tests/integration/targets/ec2_instance_cpu_options/tasks/main.yml +++ b/tests/integration/targets/ec2_instance_cpu_options/tasks/main.yml @@ -6,13 +6,13 @@ session_token: "{{ security_token | default(omit) }}" region: "{{ aws_region }}" block: - - name: create t3.nano instance with cpu_options + - name: Create t3.nano instance with cpu_options amazon.aws.ec2_instance: state: present name: "{{ resource_prefix }}-test-t3nano-1-threads-per-core" image_id: "{{ ec2_ami_id }}" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" vpc_subnet_id: "{{ testing_subnet_a.subnet.id }}" instance_type: t3.nano cpu_options: @@ -21,19 +21,19 @@ wait: true register: instance_creation - - name: instance with cpu_options created with the right options + - name: Instance with cpu_options created with the right options ansible.builtin.assert: that: - instance_creation is success - instance_creation is changed - - name: modify cpu_options on existing instance (warning displayed) + - name: Modify cpu_options on existing instance (warning displayed) amazon.aws.ec2_instance: state: present name: "{{ resource_prefix }}-test-t3nano-1-threads-per-core" image_id: "{{ ec2_ami_id }}" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" vpc_subnet_id: "{{ testing_subnet_a.subnet.id }}" instance_type: t3.nano cpu_options: @@ -43,13 +43,13 @@ register: cpu_options_update ignore_errors: true - - name: fact presented ec2 instance + - name: Fact presented ec2 instance amazon.aws.ec2_instance_info: filters: tag:Name: "{{ resource_prefix }}-test-t3nano-1-threads-per-core" register: presented_instance_fact - - name: modify cpu_options has no effect on existing instance + - name: Modify cpu_options has no effect on existing instance ansible.builtin.assert: that: - cpu_options_update is success @@ -59,13 +59,13 @@ - 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) + - name: Create t3.nano instance with cpu_options(check mode) amazon.aws.ec2_instance: state: running name: "{{ resource_prefix }}-test-t3nano-1-threads-per-core-checkmode" image_id: "{{ ec2_ami_id }}" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" vpc_subnet_id: "{{ testing_subnet_a.subnet.id }}" instance_type: t3.nano cpu_options: @@ -74,7 +74,7 @@ wait: true check_mode: true - - name: fact checkmode ec2 instance + - name: Fact checkmode ec2 instance amazon.aws.ec2_instance_info: filters: tag:Name: "{{ resource_prefix }}-test-t3nano-1-threads-per-core-checkmode" diff --git a/tests/integration/targets/ec2_instance_default_vpc_tests/defaults/main.yml b/tests/integration/targets/ec2_instance_default_vpc_tests/defaults/main.yml index 75dc25b6b3f..7b1c01d7a34 100644 --- a/tests/integration/targets/ec2_instance_default_vpc_tests/defaults/main.yml +++ b/tests/integration/targets/ec2_instance_default_vpc_tests/defaults/main.yml @@ -1,4 +1,4 @@ --- # defaults file for ec2_instance_default_vpc ec2_instance_type: t3.micro -ec2_instance_tag_TestId: "{{ resource_prefix }}-default-vpc" +ec2_instance_tag_testid: "{{ resource_prefix }}-default-vpc" 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 50839585efa..2e374361487 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 @@ -12,7 +12,7 @@ name: "{{ resource_prefix }}-test-default-vpc" image_id: "{{ ec2_ami_id }}" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" security_group: default instance_type: "{{ ec2_instance_type }}" wait: false @@ -24,18 +24,18 @@ name: "{{ resource_prefix }}-test-default-vpc-checkmode" image_id: "{{ ec2_ami_id }}" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" security_group: default instance_type: "{{ ec2_instance_type }}" check_mode: true - - name: fact presented ec2 instance + - name: Fact presented ec2 instance amazon.aws.ec2_instance_info: filters: tag:Name: "{{ resource_prefix }}-test-default-vpc" register: presented_instance_fact - - name: fact checkmode ec2 instance + - name: Fact checkmode ec2 instance amazon.aws.ec2_instance_info: filters: tag:Name: "{{ resource_prefix }}-test-default-vpc-checkmode" @@ -52,13 +52,13 @@ state: absent instance_ids: "{{ in_default_vpc.instance_ids }}" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" always: - name: Terminate vpc_tests instances amazon.aws.ec2_instance: state: absent filters: - tag:TestId: "{{ ec2_instance_tag_TestId }}" + tag:TestId: "{{ ec2_instance_tag_testid }}" wait: true ignore_errors: true diff --git a/tests/integration/targets/ec2_instance_ebs_optimized/defaults/main.yml b/tests/integration/targets/ec2_instance_ebs_optimized/defaults/main.yml index 131ec7197d6..67d2a2527df 100644 --- a/tests/integration/targets/ec2_instance_ebs_optimized/defaults/main.yml +++ b/tests/integration/targets/ec2_instance_ebs_optimized/defaults/main.yml @@ -1,4 +1,4 @@ --- # defaults file for ec2_instance_ebs_optimized ec2_instance_type: t3.micro -ec2_instance_tag_TestId: "{{ resource_prefix }}-ebs-optimized" +ec2_instance_tag_testid: "{{ resource_prefix }}-ebs-optimized" 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 35423690c0a..24d1431b2bc 100644 --- a/tests/integration/targets/ec2_instance_ebs_optimized/tasks/main.yml +++ b/tests/integration/targets/ec2_instance_ebs_optimized/tasks/main.yml @@ -12,7 +12,7 @@ name: "{{ resource_prefix }}-test-ebs-optimized-instance-in-vpc" image_id: "{{ ec2_ami_id }}" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" security_groups: "{{ sg.group_id }}" vpc_subnet_id: "{{ testing_subnet_b.subnet.id }}" ebs_optimized: true diff --git a/tests/integration/targets/ec2_instance_external_resource_attach/defaults/main.yml b/tests/integration/targets/ec2_instance_external_resource_attach/defaults/main.yml index bb2dee36792..e418d2f6c4a 100644 --- a/tests/integration/targets/ec2_instance_external_resource_attach/defaults/main.yml +++ b/tests/integration/targets/ec2_instance_external_resource_attach/defaults/main.yml @@ -1,4 +1,4 @@ --- # defaults file for ec2_instance_external_resource_attach ec2_instance_type: t3.micro -ec2_instance_tag_TestId: "{{ resource_prefix }}-external-attach" +ec2_instance_tag_testid: "{{ resource_prefix }}-external-attach" 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 24195e63f36..d7aad1d1c8b 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 @@ -44,12 +44,12 @@ image_id: "{{ ec2_ami_id }}" availability_zone: "{{ subnet_b_az }}" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" instance_type: "{{ ec2_instance_type }}" wait: false register: in_test_vpc - - name: Gather {{ resource_prefix }}-test-eni-vpc info + - name: Gather info about instance amazon.aws.ec2_instance_info: filters: tag:Name: "{{ resource_prefix }}-test-eni-vpc" @@ -69,7 +69,7 @@ - id: "{{ eni_b.interface.id }}" image_id: "{{ ec2_ami_id }}" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" instance_type: "{{ ec2_instance_type }}" wait: false register: add_interface_check_mode @@ -80,7 +80,7 @@ that: - add_interface_check_mode is changed - - name: Gather {{ resource_prefix }}-test-eni-vpc info + - name: Gather info about instance amazon.aws.ec2_instance_info: filters: tag:Name: "{{ resource_prefix }}-test-eni-vpc" @@ -101,7 +101,7 @@ - id: "{{ eni_b.interface.id }}" image_id: "{{ ec2_ami_id }}" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" instance_type: "{{ ec2_instance_type }}" wait: false register: add_interface @@ -110,8 +110,10 @@ retries: 10 - name: Validate that the instance has now 2 interfaces attached + when: add_interface is successful + block: - - name: Gather {{ resource_prefix }}-test-eni-vpc info + - name: Gather info about instance amazon.aws.ec2_instance_info: filters: tag:Name: "{{ resource_prefix }}-test-eni-vpc" @@ -123,8 +125,6 @@ - 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 - - name: Make instance in the testing subnet created in the test VPC(check mode) amazon.aws.ec2_instance: state: present @@ -135,17 +135,17 @@ image_id: "{{ ec2_ami_id }}" availability_zone: "{{ subnet_b_az }}" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" instance_type: "{{ ec2_instance_type }}" check_mode: true - - name: fact presented ec2 instance + - name: Fact presented ec2 instance amazon.aws.ec2_instance_info: filters: tag:Name: "{{ resource_prefix }}-test-eni-vpc" register: presented_instance_fact - - name: fact checkmode ec2 instance + - name: Fact checkmode ec2 instance amazon.aws.ec2_instance_info: filters: tag:Name: "{{ resource_prefix }}-test-eni-vpc-checkmode" diff --git a/tests/integration/targets/ec2_instance_hibernation_options/defaults/main.yml b/tests/integration/targets/ec2_instance_hibernation_options/defaults/main.yml index b58da2c6989..1bf2ec00591 100644 --- a/tests/integration/targets/ec2_instance_hibernation_options/defaults/main.yml +++ b/tests/integration/targets/ec2_instance_hibernation_options/defaults/main.yml @@ -1,4 +1,4 @@ --- # defaults file for ec2_instance_hibernation_options ec2_instance_type: t3.micro -ec2_instance_tag_TestId: "{{ resource_prefix }}-instance-hibernation-options" +ec2_instance_tag_testid: "{{ resource_prefix }}-instance-hibernation-options" diff --git a/tests/integration/targets/ec2_instance_iam_instance_role/defaults/main.yml b/tests/integration/targets/ec2_instance_iam_instance_role/defaults/main.yml index 72042a1c665..c3695fe7db0 100644 --- a/tests/integration/targets/ec2_instance_iam_instance_role/defaults/main.yml +++ b/tests/integration/targets/ec2_instance_iam_instance_role/defaults/main.yml @@ -1,7 +1,7 @@ --- # defaults file for ec2_instance_iam_instance_profile ec2_instance_type: t3.micro -ec2_instance_tag_TestId: "{{ resource_prefix }}-instance-profile" +ec2_instance_tag_testid: "{{ resource_prefix }}-instance-profile" first_iam_role: ansible-test-{{ tiny_prefix }}-instance_role second_iam_role: ansible-test-{{ tiny_prefix }}-instance_role-2 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 336ebdb0876..bfe4f825b1e 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 @@ -10,7 +10,7 @@ amazon.aws.iam_role: state: present name: "{{ first_iam_role }}" - assume_role_policy_document: "{{ lookup('file','assume-role-policy.json') }}" + assume_role_policy_document: "{{ lookup('file', 'assume-role-policy.json') }}" create_instance_profile: true managed_policy: - AmazonEC2ContainerServiceRole @@ -20,13 +20,13 @@ amazon.aws.iam_role: state: present name: "{{ second_iam_role }}" - assume_role_policy_document: "{{ lookup('file','assume-role-policy.json') }}" + assume_role_policy_document: "{{ lookup('file', 'assume-role-policy.json') }}" create_instance_profile: true managed_policy: - AmazonEC2ContainerServiceRole register: iam_role_2 - - name: wait 10 seconds for roles to become available + - name: Wait 10 seconds for roles to become available ansible.builtin.wait_for: timeout: 10 delegate_to: localhost @@ -41,7 +41,7 @@ instance_role: "{{ first_iam_role }}" vpc_subnet_id: "{{ testing_subnet_a.subnet.id }}" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" register: instance_with_role - ansible.builtin.assert: @@ -58,16 +58,16 @@ instance_role: "{{ iam_role.iam_role.arn.replace(':role/', ':instance-profile/') }}" vpc_subnet_id: "{{ testing_subnet_a.subnet.id }}" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" check_mode: true - - name: fact presented ec2 instance + - name: Fact presented ec2 instance amazon.aws.ec2_instance_info: filters: tag:Name: "{{ resource_prefix }}-test-instance-role" register: presented_instance_fact - - name: fact checkmode ec2 instance + - name: Fact checkmode ec2 instance amazon.aws.ec2_instance_info: filters: tag:Name: "{{ resource_prefix }}-test-instance-role-checkmode" @@ -89,15 +89,15 @@ instance_role: "{{ iam_role_2.iam_role.arn.replace(':role/', ':instance-profile/') }}" vpc_subnet_id: "{{ testing_subnet_a.subnet.id }}" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" register: instance_with_updated_role - - name: wait 10 seconds for role update to complete + - name: Wait 10 seconds for role update to complete ansible.builtin.wait_for: timeout: 10 delegate_to: localhost - - name: fact checkmode ec2 instance + - name: Fact checkmode ec2 instance amazon.aws.ec2_instance_info: filters: tag:Name: "{{ resource_prefix }}-test-instance-role" @@ -114,7 +114,7 @@ amazon.aws.ec2_instance: state: absent filters: - tag:TestId: "{{ ec2_instance_tag_TestId }}" + tag:TestId: "{{ ec2_instance_tag_testid }}" wait: true ignore_errors: true diff --git a/tests/integration/targets/ec2_instance_info/defaults/main.yml b/tests/integration/targets/ec2_instance_info/defaults/main.yml index 039bdfd48a9..ec5b8b39092 100644 --- a/tests/integration/targets/ec2_instance_info/defaults/main.yml +++ b/tests/integration/targets/ec2_instance_info/defaults/main.yml @@ -1,6 +1,6 @@ --- ec2_instance_type: t2.micro -ec2_instance_tag_TestId: "{{ resource_prefix }}-instance-info" +ec2_instance_tag_testid: "{{ resource_prefix }}-instance-info" ec2_instance_name: "{{ resource_prefix }}-test-instance-info" ec2_instance_user_data: | packages: diff --git a/tests/integration/targets/ec2_instance_info/tasks/main.yml b/tests/integration/targets/ec2_instance_info/tasks/main.yml index acdf6fc9999..b79627102cb 100644 --- a/tests/integration/targets/ec2_instance_info/tasks/main.yml +++ b/tests/integration/targets/ec2_instance_info/tasks/main.yml @@ -13,13 +13,13 @@ image_id: "{{ ec2_ami_id }}" availability_zone: "{{ subnet_b_az }}" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" user_data: "{{ ec2_instance_user_data }}" instance_type: "{{ ec2_instance_type }}" wait: false register: _instances - - name: Gather {{ ec2_instance_name }} info + - name: Gather info about instance {{ ec2_instance_name }} amazon.aws.ec2_instance_info: filters: tag:Name: "{{ ec2_instance_name }}" @@ -82,4 +82,4 @@ state: absent instance_ids: "{{ _instances.instance_ids }}" wait: false - ignore_errors: true \ No newline at end of file + ignore_errors: true diff --git a/tests/integration/targets/ec2_instance_instance_minimal/defaults/main.yml b/tests/integration/targets/ec2_instance_instance_minimal/defaults/main.yml index 98104ce70ac..f5c4d7ff9d3 100644 --- a/tests/integration/targets/ec2_instance_instance_minimal/defaults/main.yml +++ b/tests/integration/targets/ec2_instance_instance_minimal/defaults/main.yml @@ -1,4 +1,4 @@ --- # defaults file for ec2_instance_minimal ec2_instance_type: t3a.micro -ec2_instance_tag_TestId: "{{ resource_prefix }}-instance-minimal" +ec2_instance_tag_testid: "{{ resource_prefix }}-instance-minimal" diff --git a/tests/integration/targets/ec2_instance_instance_minimal/tasks/main.yml b/tests/integration/targets/ec2_instance_instance_minimal/tasks/main.yml index 1fdd2208b50..81b4fe02963 100644 --- a/tests/integration/targets/ec2_instance_instance_minimal/tasks/main.yml +++ b/tests/integration/targets/ec2_instance_instance_minimal/tasks/main.yml @@ -13,7 +13,7 @@ instance_type: "{{ ec2_instance_type }}" image_id: "{{ ec2_ami_id }}" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" wait: true register: create_instance check_mode: true @@ -32,7 +32,7 @@ instance_type: "{{ ec2_instance_type }}" image_id: "{{ ec2_ami_id }}" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" wait: true register: create_instance @@ -56,7 +56,7 @@ instance_type: "{{ ec2_instance_type }}" image_id: "{{ ec2_ami_id }}" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" wait: true register: create_instance check_mode: true @@ -77,7 +77,7 @@ instance_type: "{{ ec2_instance_type }}" image_id: "{{ ec2_ami_id }}" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" wait: true register: create_instance @@ -99,7 +99,7 @@ instance_type: "{{ ec2_instance_type }}" image_id: "{{ ec2_ami_id }}" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" wait: true register: create_instance_2 check_mode: true @@ -118,7 +118,7 @@ instance_type: "{{ ec2_instance_type }}" image_id: "{{ ec2_ami_id }}" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" wait: true register: create_instance_2 @@ -143,7 +143,7 @@ instance_type: "{{ ec2_instance_type }}" image_id: "{{ ec2_ami_id }}" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" wait: true register: create_instance_2 check_mode: true @@ -164,7 +164,7 @@ instance_type: "{{ ec2_instance_type }}" image_id: "{{ ec2_ami_id }}" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" wait: true register: create_instance_2 @@ -186,7 +186,7 @@ image_id: "{{ ec2_ami_id }}" tags: Name: "{{ resource_prefix }}-test-basic-tag" - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" wait: true register: create_instance_tag check_mode: true @@ -205,7 +205,7 @@ image_id: "{{ ec2_ami_id }}" tags: Name: "{{ resource_prefix }}-test-basic-tag" - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" wait: true register: create_instance_tag @@ -231,7 +231,7 @@ image_id: "{{ ec2_ami_id }}" tags: Name: "{{ resource_prefix }}-test-basic-tag" - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" wait: true register: create_instance_tag check_mode: true @@ -252,7 +252,7 @@ image_id: "{{ ec2_ami_id }}" tags: Name: "{{ resource_prefix }}-test-basic-tag" - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" wait: true register: create_instance_tag @@ -267,7 +267,7 @@ ############################################################### - - name: Create a new instance in AZ {{ aws_region }}a + - name: Create a new instance in AZ a amazon.aws.ec2_instance: state: present name: "{{ resource_prefix }}-test-basic-{{ aws_region }}a" @@ -276,7 +276,7 @@ region: "{{ aws_region }}" availability_zone: "{{ aws_region }}a" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" wait: true register: create_instance @@ -300,7 +300,7 @@ - create_instance.instance_ids[0].startswith("i-") - info_result.instances[0].placement.availability_zone == aws_region+"a" - - name: Create a new instance in AZ {{ aws_region }}b + - name: Create a new instance in AZ b amazon.aws.ec2_instance: state: present name: "{{ resource_prefix }}-test-basic-{{ aws_region }}b" @@ -309,7 +309,7 @@ region: "{{ aws_region }}" availability_zone: "{{ aws_region }}b" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" wait: true register: create_instance diff --git a/tests/integration/targets/ec2_instance_instance_multiple/defaults/main.yml b/tests/integration/targets/ec2_instance_instance_multiple/defaults/main.yml index 2c916eccc8f..e05bb9c72e3 100644 --- a/tests/integration/targets/ec2_instance_instance_multiple/defaults/main.yml +++ b/tests/integration/targets/ec2_instance_instance_multiple/defaults/main.yml @@ -1,4 +1,4 @@ --- # defaults file for ec2_instance_multiple ec2_instance_type: t3a.micro -ec2_instance_tag_TestId: "{{ resource_prefix }}-instance-multiple" +ec2_instance_tag_testid: "{{ resource_prefix }}-instance-multiple" diff --git a/tests/integration/targets/ec2_instance_instance_multiple/tasks/main.yml b/tests/integration/targets/ec2_instance_instance_multiple/tasks/main.yml index 898f45f3de4..ded0200857f 100644 --- a/tests/integration/targets/ec2_instance_instance_multiple/tasks/main.yml +++ b/tests/integration/targets/ec2_instance_instance_multiple/tasks/main.yml @@ -17,9 +17,9 @@ state: present purge_tags: false tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" filters: - tag:TestId: "{{ ec2_instance_tag_TestId }}" + tag:TestId: "{{ ec2_instance_tag_testid }}" register: create_multiple_instances check_mode: true @@ -38,10 +38,10 @@ image_id: "{{ ec2_ami_id }}" state: present tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" purge_tags: false filters: - tag:TestId: "{{ ec2_instance_tag_TestId }}" + tag:TestId: "{{ ec2_instance_tag_testid }}" wait: true register: create_multiple_instances @@ -125,7 +125,7 @@ image_id: "{{ ec2_ami_id }}" purge_tags: false tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" register: create_multiple_instances check_mode: true @@ -145,7 +145,7 @@ name: "{{ resource_prefix }}-test-enf_cnt" purge_tags: false tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" wait: true register: create_multiple_instances @@ -166,7 +166,7 @@ name: "{{ resource_prefix }}-test-enf_cnt" purge_tags: false tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" register: create_multiple_instances check_mode: true @@ -187,7 +187,7 @@ name: "{{ resource_prefix }}-test-enf_cnt" purge_tags: false tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" wait: true register: create_multiple_instances @@ -208,7 +208,7 @@ name: "{{ resource_prefix }}-test-enf_cnt" purge_tags: false tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" register: terminate_multiple_instances check_mode: true @@ -231,7 +231,7 @@ name: "{{ resource_prefix }}-test-enf_cnt" purge_tags: false tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" wait: true register: terminate_multiple_instances @@ -253,7 +253,7 @@ name: "{{ resource_prefix }}-test-enf_cnt" purge_tags: false tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" register: terminate_multiple_instances check_mode: true @@ -275,7 +275,7 @@ name: "{{ resource_prefix }}-test-enf_cnt" purge_tags: false tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" register: terminate_multiple_instances - ansible.builtin.assert: @@ -297,7 +297,7 @@ name: "{{ resource_prefix }}-test-enf_cnt" purge_tags: false tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" register: restart_multiple_instances check_mode: true @@ -312,7 +312,6 @@ - '"ec2:StopInstances" not in restart_multiple_instances.resource_actions' - '"ec2:StartInstances" not in restart_multiple_instances.resource_actions' - - name: Trigger restart of instances with exact_count amazon.aws.ec2_instance: state: restarted @@ -323,7 +322,7 @@ name: "{{ resource_prefix }}-test-enf_cnt" purge_tags: false tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" wait: true register: restart_multiple_instances @@ -349,7 +348,7 @@ name: "{{ resource_prefix }}-test-enf_cnt" purge_tags: false tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" wait: true check_mode: true register: create_multiple_instances @@ -373,12 +372,13 @@ name: "{{ resource_prefix }}-test-enf_cnt" purge_tags: false tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" wait: true register: create_multiple_instances - - name: debug is here - ansible.builtin.debug: msg="{{ create_multiple_instances.instance_ids }}" + - name: Debug is here + ansible.builtin.debug: + msg: "{{ create_multiple_instances.instance_ids }}" - ansible.builtin.assert: that: - create_multiple_instances is not failed @@ -397,7 +397,7 @@ name: "{{ resource_prefix }}-test-enf_cnt" purge_tags: false tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" wait: true check_mode: true register: create_multiple_instances @@ -420,7 +420,7 @@ name: "{{ resource_prefix }}-test-enf_cnt" purge_tags: false tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" wait: true register: create_multiple_instances @@ -441,13 +441,15 @@ instance-state-name: [running] register: test_instances - - name: set fact - ansible.builtin.set_fact: test_instances_ids="{{ test_instances.instances[item].instance_id }}" + - name: Set fact + ansible.builtin.set_fact: + test_instances_ids: "{{ test_instances.instances[item].instance_id }}" loop: "{{ range(0, test_instances.instances | length) | list }}" register: test_instances_list - name: Make a list of ids - ansible.builtin.set_fact: instances_to_terminate="{{ test_instances_list.results | map(attribute='ansible_facts.test_instances_ids') | list }}" + ansible.builtin.set_fact: + instances_to_terminate: "{{ test_instances_list.results | map(attribute='ansible_facts.test_instances_ids') | list }}" - name: Terminate instance based on id (check_mode) amazon.aws.ec2_instance: state: absent diff --git a/tests/integration/targets/ec2_instance_instance_no_wait/defaults/main.yml b/tests/integration/targets/ec2_instance_instance_no_wait/defaults/main.yml index 21e78d90675..7624c463c88 100644 --- a/tests/integration/targets/ec2_instance_instance_no_wait/defaults/main.yml +++ b/tests/integration/targets/ec2_instance_instance_no_wait/defaults/main.yml @@ -1,4 +1,4 @@ --- # defaults file for ec2_instance_no_wait ec2_instance_type: t3a.micro -ec2_instance_tag_TestId: "{{ resource_prefix }}-instance-no-wait" +ec2_instance_tag_testid: "{{ resource_prefix }}-instance-no-wait" 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 b34e36bba67..fa6fdd8a7c7 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 @@ -13,7 +13,7 @@ image_id: "{{ ec2_ami_id }}" vpc_subnet_id: "{{ testing_subnet_b.subnet.id }}" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" wait: false instance_type: "{{ ec2_instance_type }}" register: in_test_vpc @@ -33,7 +33,7 @@ image_id: "{{ ec2_ami_id }}" vpc_subnet_id: "{{ testing_subnet_b.subnet.id }}" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" wait: false instance_type: "{{ ec2_instance_type }}" check_mode: true diff --git a/tests/integration/targets/ec2_instance_launch_template/tasks/main.yml b/tests/integration/targets/ec2_instance_launch_template/tasks/main.yml index 8e90d08a86a..ae0c5dbf511 100644 --- a/tests/integration/targets/ec2_instance_launch_template/tasks/main.yml +++ b/tests/integration/targets/ec2_instance_launch_template/tasks/main.yml @@ -85,7 +85,7 @@ - name: Set instances to delete ansible.builtin.set_fact: - test_instance_ids: "{{ test_instance_ids + _instance_b.instance_ids | default([])}}" + test_instance_ids: "{{ test_instance_ids + _instance_b.instance_ids | default([]) }}" - name: Validate instance created as expected ansible.builtin.assert: diff --git a/tests/integration/targets/ec2_instance_license_specifications/defaults/main.yml b/tests/integration/targets/ec2_instance_license_specifications/defaults/main.yml index 8798ab5ffda..37fa8f24740 100644 --- a/tests/integration/targets/ec2_instance_license_specifications/defaults/main.yml +++ b/tests/integration/targets/ec2_instance_license_specifications/defaults/main.yml @@ -1,6 +1,6 @@ --- # defaults file for ec2_instance_block_devices ec2_instance_type: t3a.micro -ec2_instance_tag_TestId: "{{ resource_prefix }}-license-specifications" +ec2_instance_tag_testid: "{{ resource_prefix }}-license-specifications" ec2_host_resource_group_arn: arn:aws:resource-groups:{{ aws_region }}:123456789012:group/{{ resource_prefix }}-resource-group ec2_license_configuration_arn: arn:aws:license-manager:{{ aws_region }}:123456789012:license-configuration:lic-0123456789 diff --git a/tests/integration/targets/ec2_instance_license_specifications/tasks/main.yml b/tests/integration/targets/ec2_instance_license_specifications/tasks/main.yml index e9cb2b32080..8d251dc4139 100644 --- a/tests/integration/targets/ec2_instance_license_specifications/tasks/main.yml +++ b/tests/integration/targets/ec2_instance_license_specifications/tasks/main.yml @@ -17,7 +17,7 @@ license_specifications: - license_configuration_arn: "{{ ec2_license_configuration_arn }}" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" instance_type: "{{ ec2_instance_type }}" wait: true ignore_errors: true diff --git a/tests/integration/targets/ec2_instance_metadata_options/defaults/main.yml b/tests/integration/targets/ec2_instance_metadata_options/defaults/main.yml index 75a131696ff..921c850f199 100644 --- a/tests/integration/targets/ec2_instance_metadata_options/defaults/main.yml +++ b/tests/integration/targets/ec2_instance_metadata_options/defaults/main.yml @@ -1,4 +1,4 @@ --- # defaults file for ec2_instance_metadata_options ec2_instance_type: t3a.micro -ec2_instance_tag_TestId: "{{ resource_prefix }}-instance-metadata" +ec2_instance_tag_testid: "{{ resource_prefix }}-instance-metadata" 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 a4fe26fe9a1..9224c2c6578 100644 --- a/tests/integration/targets/ec2_instance_metadata_options/tasks/main.yml +++ b/tests/integration/targets/ec2_instance_metadata_options/tasks/main.yml @@ -1,5 +1,5 @@ --- -- name: test with boto3 version that supports instance_metadata_tags +- name: Test with boto3 version that supports instance_metadata_tags module_defaults: group/aws: access_key: "{{ aws_access_key }}" @@ -7,7 +7,6 @@ session_token: "{{ security_token | default(omit) }}" region: "{{ aws_region }}" block: - - name: Create a new instance amazon.aws.ec2_instance: state: running @@ -15,7 +14,7 @@ instance_type: "{{ ec2_instance_type }}" image_id: "{{ ec2_ami_id }}" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" metadata_options: http_endpoint: enabled http_tokens: required @@ -24,7 +23,7 @@ wait: true register: instance_creation - - name: instance with metadata_options created with the right options + - name: Instance with metadata_options created with the right options ansible.builtin.assert: that: - instance_creation is success @@ -34,13 +33,13 @@ - instance_creation.spec.MetadataOptions.InstanceMetadataTags == 'enabled' - instance_creation.spec.MetadataOptions.HttpPutResponseHopLimit == 2 - - name: modify metadata_options on existing instance + - name: Modify metadata_options on existing instance amazon.aws.ec2_instance: state: present name: "{{ resource_prefix }}-test-t3nano-enabled-required" image_id: "{{ ec2_ami_id }}" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" vpc_subnet_id: "{{ testing_subnet_a.subnet.id }}" instance_type: t3.nano metadata_options: @@ -50,7 +49,7 @@ wait: false register: metadata_options_update - - name: fact presented ec2 instance + - name: Fact presented ec2 instance amazon.aws.ec2_instance_info: filters: tag:Name: "{{ resource_prefix }}-test-t3nano-enabled-required" @@ -72,4 +71,4 @@ state: absent instance_ids: "{{ instance_creation.instance_ids }}" wait: false - ignore_errors: true \ No newline at end of file + ignore_errors: true diff --git a/tests/integration/targets/ec2_instance_network/tasks/enis.yml b/tests/integration/targets/ec2_instance_network/tasks/enis.yml index c09120e5229..33ca20cb583 100644 --- a/tests/integration/targets/ec2_instance_network/tasks/enis.yml +++ b/tests/integration/targets/ec2_instance_network/tasks/enis.yml @@ -34,12 +34,12 @@ ec2_instance_id: "{{ create_instance.instance_ids }}" - name: Get instance info - ec2_instance_info: + amazon.aws.ec2_instance_info: instance_ids: "{{ ec2_instance_id }}" register: _instances - name: Ensure instance has one ENI attached - assert: + ansible.builtin.assert: that: - _instances.instances.0.network_interfaces | map(attribute='network_interface_id') | list == [eni_a.interface.id] - _instances.instances.0.network_interfaces.0.attachment.device_index == 0 @@ -59,12 +59,12 @@ register: attach_eni - name: Get instance info - ec2_instance_info: + amazon.aws.ec2_instance_info: instance_ids: "{{ ec2_instance_id }}" register: _instances - name: Ensure instance has 2 ENIs attached - assert: + ansible.builtin.assert: that: - attach_eni is changed - _instances.instances.0.network_interfaces | length == 2 @@ -105,12 +105,12 @@ register: detach_eni - name: Get instance info - ec2_instance_info: + amazon.aws.ec2_instance_info: instance_ids: "{{ ec2_instance_id }}" register: _instances - name: Ensure instance has 2 ENIs attached - assert: + ansible.builtin.assert: that: - detach_eni is not changed - _instances.instances.0.network_interfaces | length == 2 diff --git a/tests/integration/targets/ec2_instance_network/tasks/failures.yml b/tests/integration/targets/ec2_instance_network/tasks/failures.yml index 0a2d23f27eb..ffb95dae593 100644 --- a/tests/integration/targets/ec2_instance_network/tasks/failures.yml +++ b/tests/integration/targets/ec2_instance_network/tasks/failures.yml @@ -22,7 +22,6 @@ - make_instance is failed - make_instance.msg == "The option 'assign_public_ip' cannot be set to true with multiple network interfaces." - # Network interface with mutiple primary private ip address - name: Make instance with network interfaces with mutiple primary private ip address amazon.aws.ec2_instance: @@ -112,4 +111,4 @@ ansible.builtin.assert: that: - make_instance is failed - - make_instance.msg == "The option 'ipv6_addresses' cannot be specified when launching more than one instance." \ No newline at end of file + - make_instance.msg == "The option 'ipv6_addresses' cannot be specified when launching more than one instance." diff --git a/tests/integration/targets/ec2_instance_network/tasks/main.yml b/tests/integration/targets/ec2_instance_network/tasks/main.yml index fcedd03fae7..2624ccd22bd 100644 --- a/tests/integration/targets/ec2_instance_network/tasks/main.yml +++ b/tests/integration/targets/ec2_instance_network/tasks/main.yml @@ -26,19 +26,20 @@ register: multiple_ips - name: Fact presented instance - ec2_instance_info: + amazon.aws.ec2_instance_info: instance_ids: "{{ multiple_ips.instance_ids }}" register: _instances - name: Ensure instance has ENI attached with 2 Private IP addresses - assert: + ansible.builtin.assert: that: - multiple_ips is changed - _instances.instances.0.network_interfaces | length == 1 - _instances.instances.0.network_interfaces.0.private_ip_addresses | length == 2 - - _instances.instances.0.network_interfaces.0.private_ip_addresses | selectattr('primary', 'equalto', true) | map(attribute='private_ip_address') | list | first == subnet_a_startswith+'120' - - _instances.instances.0.network_interfaces.0.private_ip_addresses | selectattr('primary', 'equalto', false) | map(attribute='private_ip_address') | list | first == subnet_a_startswith+'121' - + - _instances.instances.0.network_interfaces.0.private_ip_addresses | selectattr('primary', 'equalto', true) | map(attribute='private_ip_address') | list + | first == subnet_a_startswith+'120' + - _instances.instances.0.network_interfaces.0.private_ip_addresses | selectattr('primary', 'equalto', false) | map(attribute='private_ip_address') | list + | first == subnet_a_startswith+'121' - name: Make instance with single private ip addresses amazon.aws.ec2_instance: @@ -53,12 +54,12 @@ register: single_ip - name: Fact presented instance - ec2_instance_info: + amazon.aws.ec2_instance_info: instance_ids: "{{ single_ip.instance_ids }}" register: _instances - name: Ensure instance has one ENI attached to it - assert: + ansible.builtin.assert: that: - multiple_ips is changed - _instances.instances.0.network_interfaces | length == 1 @@ -84,12 +85,12 @@ register: ipv6_instance - name: Fact presented instance - ec2_instance_info: + amazon.aws.ec2_instance_info: instance_ids: "{{ ipv6_instance.instance_ids }}" register: _instances - name: Ensure instance has one ENI attached to it - assert: + ansible.builtin.assert: that: - ipv6_instance is changed - _instances.instances.0.network_interfaces | length == 1 @@ -114,12 +115,12 @@ created_instance_id: "{{ create_with_group.instance_ids }}" - name: Fact presented instance - ec2_instance_info: + amazon.aws.ec2_instance_info: instance_ids: "{{ created_instance_id }}" register: _instances - name: Ensure instance has been created with one security group - assert: + ansible.builtin.assert: that: - create_with_group is changed - _instances.instances.0.security_groups | map(attribute='group_name') | list == [security_group_name_1] @@ -140,12 +141,12 @@ check_mode: true - name: Fact presented instance - ec2_instance_info: + amazon.aws.ec2_instance_info: instance_ids: "{{ created_instance_id }}" register: _instances - name: Ensure instance has still one Security group - assert: + ansible.builtin.assert: that: - add_group_checkmode is changed - _instances.instances.0.security_groups | map(attribute='group_name') | list == [security_group_name_1] @@ -165,12 +166,12 @@ register: add_group - name: Fact presented instance - ec2_instance_info: + amazon.aws.ec2_instance_info: instance_ids: "{{ created_instance_id }}" register: _instances - name: Ensure instance has 1 additional Security group - assert: + ansible.builtin.assert: that: - add_group is changed - _instances.instances.0.security_groups | length == 2 @@ -192,7 +193,7 @@ register: add_group_idempotency - name: Ensure no change was made on the instance - assert: + ansible.builtin.assert: that: - add_group_idempotency is not changed @@ -208,12 +209,12 @@ check_mode: true - name: Fact presented instance - ec2_instance_info: + amazon.aws.ec2_instance_info: instance_ids: "{{ created_instance_id }}" register: _instances - name: Ensure instance has still 2 Security groups - assert: + ansible.builtin.assert: that: - remove_group_checkmode is changed - _instances.instances.0.security_groups | length == 2 @@ -231,12 +232,12 @@ register: remove_group - name: Fact presented instance - ec2_instance_info: + amazon.aws.ec2_instance_info: instance_ids: "{{ created_instance_id }}" register: _instances - name: Ensure instance has 1 less Security group - assert: + ansible.builtin.assert: that: - remove_group is changed - _instances.instances.0.security_groups | length == 1 @@ -253,6 +254,6 @@ register: remove_group_idempotency - name: Ensure module did not reported change - assert: + ansible.builtin.assert: that: - remove_group_idempotency is not changed diff --git a/tests/integration/targets/ec2_instance_placement_options/defaults/main.yml b/tests/integration/targets/ec2_instance_placement_options/defaults/main.yml index 970dba1980a..7722fbf37f5 100644 --- a/tests/integration/targets/ec2_instance_placement_options/defaults/main.yml +++ b/tests/integration/targets/ec2_instance_placement_options/defaults/main.yml @@ -1,6 +1,6 @@ --- # defaults file for ec2_instance_block_devices ec2_instance_type: t3.micro -ec2_instance_tag_TestId: "{{ resource_prefix }}-placement-group" +ec2_instance_tag_testid: "{{ resource_prefix }}-placement-group" ec2_tenancy: dedicated -ec2_placement_group_name: "{{ resource_prefix}}-placement-group" +ec2_placement_group_name: "{{ resource_prefix }}-placement-group" diff --git a/tests/integration/targets/ec2_instance_placement_options/tasks/main.yml b/tests/integration/targets/ec2_instance_placement_options/tasks/main.yml index 4c7f0ca6d69..160be87d485 100644 --- a/tests/integration/targets/ec2_instance_placement_options/tasks/main.yml +++ b/tests/integration/targets/ec2_instance_placement_options/tasks/main.yml @@ -22,7 +22,7 @@ group_name: "{{ ec2_placement_group_name }}" tags: Name: "{{ resource_prefix }}-test-placement-group-name" - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" security_group: default instance_type: "{{ ec2_instance_type }}" wait: true @@ -33,7 +33,7 @@ amazon.aws.ec2_instance_info: filters: tag:Name: "{{ resource_prefix }}-test-placement-group-name" - tag:TestId: "{{ ec2_instance_tag_TestId }}" + tag:TestId: "{{ ec2_instance_tag_testid }}" instance-state-name: running ignore_errors: true register: instance_facts @@ -55,7 +55,7 @@ placement: tenancy: "{{ ec2_tenancy }}" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" security_group: default instance_type: "{{ ec2_instance_type }}" availability_zone: "{{ ec2_availability_zone }}" @@ -67,7 +67,7 @@ amazon.aws.ec2_instance_info: filters: tag:Name: "{{ resource_prefix }}-test-dedicated-tenancy" - tag:TestId: "{{ ec2_instance_tag_TestId }}" + tag:TestId: "{{ ec2_instance_tag_testid }}" instance-state-name: running ignore_errors: true register: instance_facts diff --git a/tests/integration/targets/ec2_instance_placement_options/tasks/select_availability_zone.yml b/tests/integration/targets/ec2_instance_placement_options/tasks/select_availability_zone.yml index 0b48ebcb85c..96c935fc7bd 100644 --- a/tests/integration/targets/ec2_instance_placement_options/tasks/select_availability_zone.yml +++ b/tests/integration/targets/ec2_instance_placement_options/tasks/select_availability_zone.yml @@ -1,3 +1,4 @@ +--- # aws regions supporting 't3.micro' instance type - ansible.builtin.set_fact: av_zones: diff --git a/tests/integration/targets/ec2_instance_security_group/defaults/main.yml b/tests/integration/targets/ec2_instance_security_group/defaults/main.yml index 542106868ff..886365e3076 100644 --- a/tests/integration/targets/ec2_instance_security_group/defaults/main.yml +++ b/tests/integration/targets/ec2_instance_security_group/defaults/main.yml @@ -1,4 +1,4 @@ --- # defaults file for ec2_instance_security_group ec2_instance_type: t3a.micro -ec2_instance_tag_TestId: "{{ resource_prefix }}-instance-sg" +ec2_instance_tag_testid: "{{ resource_prefix }}-instance-sg" diff --git a/tests/integration/targets/ec2_instance_state_config_updates/defaults/main.yml b/tests/integration/targets/ec2_instance_state_config_updates/defaults/main.yml index 652b82b1ebf..ee532d27e03 100644 --- a/tests/integration/targets/ec2_instance_state_config_updates/defaults/main.yml +++ b/tests/integration/targets/ec2_instance_state_config_updates/defaults/main.yml @@ -1,4 +1,4 @@ --- # defaults file for ec2_instance_state_config_updates ec2_instance_type: t3a.micro -ec2_instance_tag_TestId: "{{ resource_prefix }}-state-config-updates" +ec2_instance_tag_testid: "{{ resource_prefix }}-state-config-updates" 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 bcb74d10759..c30e084747f 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 @@ -17,7 +17,7 @@ name: "{{ resource_prefix }}-test-state-param-changes" image_id: "{{ ec2_ami_id }}" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" security_groups: "{{ sg.group_id }}" vpc_subnet_id: "{{ testing_subnet_b.subnet.id }}" termination_protection: false @@ -42,7 +42,7 @@ name: "{{ resource_prefix }}-test-state-param-changes" image_id: "{{ ec2_ami_id }}" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" security_groups: "{{ sg2.group_id }}" vpc_subnet_id: "{{ testing_subnet_b.subnet.id }}" termination_protection: true @@ -74,7 +74,7 @@ name: "{{ resource_prefix }}-test-state-param-changes" image_id: "{{ ec2_ami_id }}" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" security_groups: "{{ sg.group_id }}" vpc_subnet_id: "{{ testing_subnet_b.subnet.id }}" termination_protection: false @@ -100,7 +100,7 @@ name: "{{ resource_prefix }}-test-state-param-changes" image_id: "{{ ec2_ami_id }}" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" security_groups: "{{ sg2.group_id }}" vpc_subnet_id: "{{ testing_subnet_b.subnet.id }}" termination_protection: true @@ -124,7 +124,7 @@ name: "{{ resource_prefix }}-test-state-param-changes" image_id: "{{ ec2_ami_id }}" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" security_groups: "{{ sg.group_id }}" vpc_subnet_id: "{{ testing_subnet_b.subnet.id }}" termination_protection: false diff --git a/tests/integration/targets/ec2_instance_tags_and_vpc_settings/defaults/main.yml b/tests/integration/targets/ec2_instance_tags_and_vpc_settings/defaults/main.yml index c8cf7e27fd5..48693b2f346 100644 --- a/tests/integration/targets/ec2_instance_tags_and_vpc_settings/defaults/main.yml +++ b/tests/integration/targets/ec2_instance_tags_and_vpc_settings/defaults/main.yml @@ -1,4 +1,4 @@ --- # defaults file for ec2_instance_tags_and_vpc_settings ec2_instance_type: t3a.micro -ec2_instance_tag_TestId: "{{ resource_prefix }}-instance-tags-vpc" +ec2_instance_tag_testid: "{{ resource_prefix }}-instance-tags-vpc" 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 3ede6475d3c..4dbef166a5c 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 @@ -16,7 +16,7 @@ package_upgrade: true package_update: true tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" Something: else security_groups: "{{ sg.group_id }}" network_interfaces: @@ -38,7 +38,7 @@ package_upgrade: true package_update: true tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" Something: else security_groups: "{{ sg.group_id }}" network_interfaces: @@ -59,7 +59,7 @@ package_upgrade: true package_update: true tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" Something: else security_groups: "{{ sg.group_id }}" vpc_subnet_id: "{{ testing_subnet_b.subnet.id }}" @@ -68,20 +68,20 @@ - name: Remaking the same instance resulted in no changes ansible.builtin.assert: that: not remake_in_test_vpc.changed - - name: check that instance IDs match anyway + - name: Check that instance IDs match anyway ansible.builtin.assert: that: remake_in_test_vpc.instance_ids[0] == in_test_vpc.instance_ids[0] - - name: check that source_dest_check was set to false + - name: Check that source_dest_check was set to false ansible.builtin.assert: that: not remake_in_test_vpc.instances[0].source_dest_check - - name: fact presented ec2 instance + - name: Fact presented ec2 instance amazon.aws.ec2_instance_info: filters: tag:Name: "{{ resource_prefix }}-test-basic-vpc-create" register: presented_instance_fact - - name: fact checkmode ec2 instance + - name: Fact checkmode ec2 instance amazon.aws.ec2_instance_info: filters: tag:Name: "{{ resource_prefix }}-test-basic-vpc-create-checkmode" @@ -99,7 +99,7 @@ name: "{{ resource_prefix }}-test-basic-vpc-create" image_id: "{{ ec2_ami_id }}" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" Another: thing purge_tags: false security_groups: "{{ sg.group_id }}" @@ -122,7 +122,7 @@ name: "{{ resource_prefix }}-test-basic-vpc-create" image_id: "{{ ec2_ami_id }}" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" Another: thing security_groups: "{{ sg.group_id }}" vpc_subnet_id: "{{ testing_subnet_b.subnet.id }}" @@ -137,13 +137,13 @@ that: - "'Something' not in check_tags.instances[0].tags" - - name: check that subnet-default public IP rule was followed + - name: Check that subnet-default public IP rule was followed ansible.builtin.assert: that: - check_tags.instances[0].public_dns_name == "" - check_tags.instances[0].private_ip_address.startswith(subnet_b_startswith) - check_tags.instances[0].subnet_id == testing_subnet_b.subnet.id - - name: check that tags were applied + - name: Check that tags were applied ansible.builtin.assert: that: - check_tags.instances[0].tags.Name.startswith(resource_prefix) @@ -189,7 +189,7 @@ name: "{{ resource_prefix }}-test-basic-vpc-create" image_id: "{{ ec2_ami_id }}" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" Something: else security_groups: "{{ sg.group_id }}" source_dest_check: true @@ -209,7 +209,7 @@ name: "{{ resource_prefix }}-test-basic-vpc-create" image_id: "{{ ec2_ami_id }}" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" Something: else security_groups: "{{ sg.group_id }}" source_dest_check: true @@ -217,7 +217,7 @@ instance_type: "{{ ec2_instance_type }}" register: update_source_dest_check - - name: fact presented ec2 instance + - name: Fact presented ec2 instance amazon.aws.ec2_instance_info: filters: tag:Name: "{{ resource_prefix }}-test-basic-vpc-create" @@ -235,7 +235,7 @@ name: "{{ resource_prefix }}-test-basic-vpc-create" image_id: "{{ ec2_ami_id }}" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" Something: else security_groups: "{{ sg.group_id }}" source_dest_check: true diff --git a/tests/integration/targets/ec2_instance_termination_protection/defaults/main.yml b/tests/integration/targets/ec2_instance_termination_protection/defaults/main.yml index f7ca95e8768..4b045f62c3a 100644 --- a/tests/integration/targets/ec2_instance_termination_protection/defaults/main.yml +++ b/tests/integration/targets/ec2_instance_termination_protection/defaults/main.yml @@ -1,4 +1,4 @@ --- # defaults file for ec2_instance_termination_protection ec2_instance_type: t3a.micro -ec2_instance_tag_TestId: "{{ resource_prefix }}-instance-temination" +ec2_instance_tag_testid: "{{ resource_prefix }}-instance-temination" 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 dfd50c910ee..ca38e3cd52d 100644 --- a/tests/integration/targets/ec2_instance_termination_protection/tasks/main.yml +++ b/tests/integration/targets/ec2_instance_termination_protection/tasks/main.yml @@ -59,8 +59,9 @@ AWS_SESSION_TOKEN: "{{ security_token | default('') }}" AWS_DEFAULT_REGION: "{{ aws_region }}" register: instance_termination_check + changed_when: false - - name: convert it to an object + - name: Convert it to an object ansible.builtin.set_fact: instance_termination_status: "{{ instance_termination_check.stdout | from_json }}" @@ -142,8 +143,9 @@ AWS_SESSION_TOKEN: "{{ security_token | default('') }}" AWS_DEFAULT_REGION: "{{ aws_region }}" register: instance_termination_check + changed_when: false - - name: convert it to an object + - name: Convert it to an object ansible.builtin.set_fact: instance_termination_status: "{{ instance_termination_check.stdout | from_json }}" @@ -175,8 +177,9 @@ AWS_SESSION_TOKEN: "{{ security_token | default('') }}" AWS_DEFAULT_REGION: "{{ aws_region }}" register: instance_termination_check + changed_when: false - - name: convert it to an object + - name: Convert it to an object ansible.builtin.set_fact: instance_termination_status: "{{ instance_termination_check.stdout | from_json }}" diff --git a/tests/integration/targets/ec2_instance_type/tasks/main.yml b/tests/integration/targets/ec2_instance_type/tasks/main.yml index 70b3d585065..c09c2fc37eb 100644 --- a/tests/integration/targets/ec2_instance_type/tasks/main.yml +++ b/tests/integration/targets/ec2_instance_type/tasks/main.yml @@ -6,7 +6,7 @@ session_token: "{{ security_token | default(omit) }}" region: "{{ aws_region }}" block: - - include_tasks: single_instance.yml + - ansible.builtin.include_tasks: single_instance.yml vars: ec2_instance_name: "{{ resource_prefix }}-test-instance-type-single" @@ -25,7 +25,7 @@ exact_count: 2 - name: Test upgrade instance type with various number of instances - include_tasks: update_instance_type.yml + ansible.builtin.include_tasks: update_instance_type.yml with_items: - new_instance_type: "{{ ec2_instance_type_updated }}" new_instance_count: 2 diff --git a/tests/integration/targets/ec2_instance_type/tasks/single_instance.yml b/tests/integration/targets/ec2_instance_type/tasks/single_instance.yml index 5b0a735aa89..9ba4190d3b8 100644 --- a/tests/integration/targets/ec2_instance_type/tasks/single_instance.yml +++ b/tests/integration/targets/ec2_instance_type/tasks/single_instance.yml @@ -74,4 +74,4 @@ instance_ids: "{{ ec2_instance_ids }}" wait: false ignore_errors: true - when: ec2_instance_ids is defined \ No newline at end of file + when: ec2_instance_ids is defined diff --git a/tests/integration/targets/ec2_instance_uptime/defaults/main.yml b/tests/integration/targets/ec2_instance_uptime/defaults/main.yml index f74164da1c4..84d584223a0 100644 --- a/tests/integration/targets/ec2_instance_uptime/defaults/main.yml +++ b/tests/integration/targets/ec2_instance_uptime/defaults/main.yml @@ -1,4 +1,4 @@ --- # defaults file for ec2_instance_uptime ec2_instance_type: t3a.micro -ec2_instance_tag_TestId: "{{ resource_prefix }}-instance-uptime" +ec2_instance_tag_testid: "{{ resource_prefix }}-instance-uptime" diff --git a/tests/integration/targets/ec2_instance_uptime/tasks/main.yml b/tests/integration/targets/ec2_instance_uptime/tasks/main.yml index 8b510da2fa7..7895b0ecc7c 100644 --- a/tests/integration/targets/ec2_instance_uptime/tasks/main.yml +++ b/tests/integration/targets/ec2_instance_uptime/tasks/main.yml @@ -6,19 +6,19 @@ session_token: "{{ security_token | default(omit) }}" region: "{{ aws_region }}" block: - - name: create t3.nano instance + - name: Create t3.nano instance amazon.aws.ec2_instance: state: running name: "{{ resource_prefix }}-test-uptime" region: "{{ aws_region }}" image_id: "{{ ec2_ami_id }}" tags: - TestId: "{{ ec2_instance_tag_TestId }}" + TestId: "{{ ec2_instance_tag_testid }}" vpc_subnet_id: "{{ testing_subnet_a.subnet.id }}" instance_type: t3.nano wait: true - - name: check ec2 instance + - name: Check ec2 instance amazon.aws.ec2_instance_info: filters: tag:Name: "{{ resource_prefix }}-test-uptime" @@ -30,7 +30,7 @@ that: - instance_facts.instances | length == 1 - - name: check using uptime 100 hours - should find nothing + - name: Check using uptime 100 hours - should find nothing amazon.aws.ec2_instance_info: region: "{{ aws_region }}" uptime: 6000 @@ -49,7 +49,7 @@ timeout: 61 delegate_to: localhost - - name: check using uptime 1 minute + - name: Check using uptime 1 minute amazon.aws.ec2_instance_info: region: "{{ aws_region }}" uptime: 1 diff --git a/tests/integration/targets/ec2_key/defaults/main.yml b/tests/integration/targets/ec2_key/defaults/main.yml index 1dbd820b1c7..761ab43dac0 100644 --- a/tests/integration/targets/ec2_key/defaults/main.yml +++ b/tests/integration/targets/ec2_key/defaults/main.yml @@ -1,4 +1,4 @@ --- # defaults file for test_ec2_key -ec2_key_name: "{{resource_prefix}}" -ec2_key_name_rsa: "{{resource_prefix}}-rsa" +ec2_key_name: "{{ resource_prefix }}" +ec2_key_name_rsa: "{{ resource_prefix }}-rsa" diff --git a/tests/integration/targets/ec2_key/tasks/main.yml b/tests/integration/targets/ec2_key/tasks/main.yml index 1abcf5908d2..506d3b918a8 100644 --- a/tests/integration/targets/ec2_key/tasks/main.yml +++ b/tests/integration/targets/ec2_key/tasks/main.yml @@ -2,7 +2,8 @@ # TODO - name: test 'validate_certs' parameter # ============================================================= -- module_defaults: +- name: Run ec2_key tests with credentials set + module_defaults: group/aws: region: "{{ aws_region }}" access_key: "{{ aws_access_key }}" @@ -20,37 +21,37 @@ priv_key_file_name: "{{ _tmpdir.path }}/aws_ssh_rsa" # ============================================================ - - name: test with no parameters + - name: Test with no parameters amazon.aws.ec2_key: register: result ignore_errors: true - - name: assert failure when called with no parameters + - name: Assert failure when called with no parameters ansible.builtin.assert: that: - result.failed - 'result.msg == "missing required arguments: name"' # ============================================================ - - name: test removing a non-existent key pair (check mode) + - name: Test removing a non-existent key pair (check mode) amazon.aws.ec2_key: name: "{{ ec2_key_name }}" state: absent register: result check_mode: true - - name: assert removing a non-existent key pair + - name: Assert removing a non-existent key pair ansible.builtin.assert: that: - not result.changed - - name: test removing a non-existent key pair + - name: Test removing a non-existent key pair amazon.aws.ec2_key: name: "{{ ec2_key_name }}" state: absent register: result - - name: assert removing a non-existent key pair + - name: Assert removing a non-existent key pair ansible.builtin.assert: that: - not result.changed @@ -58,7 +59,7 @@ # ============================================================ # Test: create new key by AWS (key_material not provided) # ============================================================ - - name: test creating a new key pair (check_mode) + - name: Test creating a new key pair (check_mode) amazon.aws.ec2_key: name: "{{ ec2_key_name }}" state: present @@ -69,19 +70,19 @@ register: result check_mode: true - - name: assert creating a new key pair + - name: Assert creating a new key pair ansible.builtin.assert: that: - result is changed - - name: assert that key pair was not created + - name: Assert that key pair was not created amazon.aws.ec2_key_info: names: - "{{ ec2_key_name }}" register: aws_keypair failed_when: aws_keypair.keypairs | length > 0 - - name: test creating a new key pair + - name: Test creating a new key pair amazon.aws.ec2_key: name: "{{ ec2_key_name }}" state: present @@ -91,7 +92,7 @@ spaced key: Spaced value register: result - - name: assert creating a new key pair + - name: Assert creating a new key pair ansible.builtin.assert: that: - result is changed @@ -110,7 +111,7 @@ - '"spaced key" in result.key.tags' - result.key.tags['spaced key'] == 'Spaced value' - - name: assert that key pair was created + - name: Assert that key pair was created amazon.aws.ec2_key_info: names: - "{{ ec2_key_name }}" @@ -122,7 +123,7 @@ names: "{{ ec2_key_name }}" register: key_info - - name: assert the gathered key info + - name: Assert the gathered key info ansible.builtin.assert: that: - key_info.keypairs[0].key_name == ec2_key_name @@ -137,7 +138,7 @@ - ansible.builtin.set_fact: key_id_1: "{{ result.key.id }}" - - name: test re-"creating" the same key (check_mode) + - name: Test re-"creating" the same key (check_mode) amazon.aws.ec2_key: name: "{{ ec2_key_name }}" state: present @@ -148,12 +149,12 @@ register: result check_mode: true - - name: assert re-creating the same key + - name: Assert re-creating the same key ansible.builtin.assert: that: - result is not changed - - name: test re-"creating" the same key + - name: Test re-"creating" the same key amazon.aws.ec2_key: name: "{{ ec2_key_name }}" state: present @@ -163,7 +164,7 @@ spaced key: Spaced value register: result - - name: assert re-creating the same key + - name: Assert re-creating the same key ansible.builtin.assert: that: - result is not changed @@ -177,7 +178,7 @@ state: absent path: "{{ priv_key_file_name }}" - - name: test creating a new key pair (check_mode) + - name: Test creating a new key pair (check_mode) amazon.aws.ec2_key: name: "{{ ec2_key_name_rsa }}" state: present @@ -190,25 +191,25 @@ check_mode: true no_log: true - - name: assert creating a new key pair + - name: Assert creating a new key pair ansible.builtin.assert: that: - result is changed - - name: assert that key pair was not created + - name: Assert that key pair was not created amazon.aws.ec2_key_info: names: - "{{ ec2_key_name_rsa }}" register: aws_keypair failed_when: aws_keypair.keypairs | length > 0 - - name: assert that private key was not saved + - name: Assert that private key was not saved ansible.builtin.stat: path: "{{ priv_key_file_name }}" register: result failed_when: result.stat.exists - - name: test creating a new key pair + - name: Test creating a new key pair amazon.aws.ec2_key: name: "{{ ec2_key_name_rsa }}" state: present @@ -219,7 +220,7 @@ spaced key: Spaced value register: result - - name: assert creating a new key pair + - name: Assert creating a new key pair ansible.builtin.assert: that: - result is changed @@ -238,20 +239,20 @@ - '"spaced key" in result.key.tags' - result.key.tags['spaced key'] == 'Spaced value' - - name: assert that key pair was created + - name: Assert that key pair was created amazon.aws.ec2_key_info: names: - "{{ ec2_key_name_rsa }}" register: aws_keypair failed_when: aws_keypair.keypairs | length == 0 - - name: assert that private key was saved into file + - name: Assert that private key was saved into file ansible.builtin.stat: path: "{{ priv_key_file_name }}" register: result failed_when: (not result.stat.exists) or (result.stat.size == 0) - - name: test re-"creating" the same key (check_mode) + - name: Test re-"creating" the same key (check_mode) amazon.aws.ec2_key: name: "{{ ec2_key_name_rsa }}" state: present @@ -263,12 +264,12 @@ register: result check_mode: true - - name: assert re-creating the same key + - name: Assert re-creating the same key ansible.builtin.assert: that: - result is not changed - - name: test re-"creating" the same key + - name: Test re-"creating" the same key amazon.aws.ec2_key: name: "{{ ec2_key_name_rsa }}" state: present @@ -279,13 +280,13 @@ spaced key: Spaced value register: result - - name: assert re-creating the same key + - name: Assert re-creating the same key ansible.builtin.assert: that: - result is not changed # ============================================================ - - name: test updating tags without purge (check mode) + - name: Test updating tags without purge (check mode) amazon.aws.ec2_key: name: "{{ ec2_key_name }}" state: present @@ -295,12 +296,12 @@ register: result check_mode: true - - name: assert updated tags + - name: Assert updated tags ansible.builtin.assert: that: - result is changed - - name: test updating tags without purge + - name: Test updating tags without purge amazon.aws.ec2_key: name: "{{ ec2_key_name }}" state: present @@ -309,7 +310,7 @@ purge_tags: false register: result - - name: assert updated tags + - name: Assert updated tags ansible.builtin.assert: that: - result is changed @@ -335,7 +336,7 @@ names: "{{ ec2_key_name }}" register: key_info - - name: assert the gathered key info + - name: Assert the gathered key info ansible.builtin.assert: that: - key_info.keypairs[0].key_name == ec2_key_name @@ -349,7 +350,7 @@ - '"newKey" in key_info.keypairs[0].tags' - key_info.keypairs[0].tags['newKey'] == 'Another value' - - name: test updating tags without purge - idempotency (check mode) + - name: Test updating tags without purge - idempotency (check mode) amazon.aws.ec2_key: name: "{{ ec2_key_name }}" state: present @@ -359,12 +360,12 @@ register: result check_mode: true - - name: assert updated tags + - name: Assert updated tags ansible.builtin.assert: that: - result is not changed - - name: test updating tags without purge - idempotency + - name: Test updating tags without purge - idempotency amazon.aws.ec2_key: name: "{{ ec2_key_name }}" state: present @@ -373,7 +374,7 @@ purge_tags: false register: result - - name: assert updated tags + - name: Assert updated tags ansible.builtin.assert: that: - result is not changed @@ -395,7 +396,7 @@ - result.key.tags['newKey'] == 'Another value' # ============================================================ - - name: test updating tags with purge (check mode) + - name: Test updating tags with purge (check mode) amazon.aws.ec2_key: name: "{{ ec2_key_name }}" state: present @@ -405,12 +406,12 @@ register: result check_mode: true - - name: assert updated tags + - name: Assert updated tags ansible.builtin.assert: that: - result is changed - - name: test updating tags with purge + - name: Test updating tags with purge amazon.aws.ec2_key: name: "{{ ec2_key_name }}" state: present @@ -419,7 +420,7 @@ purge_tags: true register: result - - name: assert updated tags + - name: Assert updated tags ansible.builtin.assert: that: - result is changed @@ -437,7 +438,7 @@ - '"newKey" in result.key.tags' - result.key.tags['newKey'] == 'Another value' - - name: test updating tags with purge - idempotency (check mode) + - name: Test updating tags with purge - idempotency (check mode) amazon.aws.ec2_key: name: "{{ ec2_key_name }}" state: present @@ -447,12 +448,12 @@ register: result check_mode: true - - name: assert updated tags + - name: Assert updated tags ansible.builtin.assert: that: - result is not changed - - name: test updating tags with purge - idempotency + - name: Test updating tags with purge - idempotency amazon.aws.ec2_key: name: "{{ ec2_key_name }}" state: present @@ -461,7 +462,7 @@ purge_tags: true register: result - - name: assert updated tags + - name: Assert updated tags ansible.builtin.assert: that: - result is not changed @@ -480,39 +481,39 @@ - result.key.tags['newKey'] == 'Another value' # ============================================================ - - name: test removing an existent key (check mode) + - name: Test removing an existent key (check mode) amazon.aws.ec2_key: name: "{{ ec2_key_name }}" state: absent register: result check_mode: true - - name: assert removing an existent key + - name: Assert removing an existent key ansible.builtin.assert: that: - result is changed - - name: assert using check_mode did not removed key pair + - name: Assert using check_mode did not removed key pair amazon.aws.ec2_key_info: names: - "{{ ec2_key_name }}" register: keys failed_when: keys.keypairs | length == 0 - - name: test removing an existent key + - name: Test removing an existent key amazon.aws.ec2_key: name: "{{ ec2_key_name }}" state: absent register: result - - name: assert removing an existent key + - name: Assert removing an existent key ansible.builtin.assert: that: - result is changed - '"key" in result' - result.key == None - - name: assert that key pair was removed + - name: Assert that key pair was removed amazon.aws.ec2_key_info: names: - "{{ ec2_key_name }}" @@ -520,14 +521,14 @@ failed_when: keys.keypairs | length > 0 # ============================================================ - - name: test state=present with key_material + - name: Test state=present with key_material amazon.aws.ec2_key: name: "{{ ec2_key_name }}" key_material: "{{ key_material }}" state: present register: result - - name: assert state=present with key_material + - name: Assert state=present with key_material ansible.builtin.assert: that: - result.changed == True @@ -546,7 +547,7 @@ fingerprint: "{{ fingerprint }}" register: key_info - - name: assert gathered key info + - name: Assert gathered key info ansible.builtin.assert: that: - '"key_fingerprint" in key_info.keypairs[0]' @@ -556,14 +557,14 @@ - key_info.keypairs[0].key_name == ec2_key_name - key_info.keypairs[0].key_fingerprint == fingerprint # ============================================================ - - name: test state=present with key_material (idempotency) + - name: Test state=present with key_material (idempotency) amazon.aws.ec2_key: name: "{{ ec2_key_name }}" key_material: "{{ key_material }}" state: present register: result - - name: assert state=present with key_material + - name: Assert state=present with key_material ansible.builtin.assert: that: - result is not changed @@ -579,14 +580,14 @@ # ============================================================ - - name: test force=no with another_key_material (expect changed=false) + - name: Test force=no with another_key_material (expect changed=false) amazon.aws.ec2_key: name: "{{ ec2_key_name }}" key_material: "{{ another_key_material }}" force: false register: result - - name: assert force=no with another_key_material (expect changed=false) + - name: Assert force=no with another_key_material (expect changed=false) ansible.builtin.assert: that: - not result.changed @@ -594,13 +595,13 @@ # ============================================================ - - name: test updating a key pair using another_key_material (expect changed=True) + - name: Test updating a key pair using another_key_material (expect changed=True) amazon.aws.ec2_key: name: "{{ ec2_key_name }}" key_material: "{{ another_key_material }}" register: result - - name: assert updating a key pair using another_key_material (expect changed=True) + - name: Assert updating a key pair using another_key_material (expect changed=True) ansible.builtin.assert: that: - result.changed @@ -608,13 +609,13 @@ - result.key.fingerprint == another_fingerprint # ============================================================ - - name: test state=absent (expect changed=true) + - name: Test state=absent (expect changed=true) amazon.aws.ec2_key: name: "{{ ec2_key_name }}" state: absent register: result - - name: assert state=absent with key_material (expect changed=true) + - name: Assert state=absent with key_material (expect changed=true) ansible.builtin.assert: that: - result.changed @@ -622,13 +623,13 @@ - result.key == None # ============================================================ - - name: test create ED25519 key pair type + - name: Test create ED25519 key pair type amazon.aws.ec2_key: name: "{{ ec2_key_name }}" key_type: ed25519 register: result - - name: assert that task succeed + - name: Assert that task succeed ansible.builtin.assert: that: - result.changed @@ -640,7 +641,7 @@ key_type: rsa register: result - - name: assert that task succeed + - name: Assert that task succeed ansible.builtin.assert: that: - result.changed diff --git a/tests/integration/targets/ec2_launch_template/meta/main.yml b/tests/integration/targets/ec2_launch_template/meta/main.yml index 1471b11f658..fcadd50dc68 100644 --- a/tests/integration/targets/ec2_launch_template/meta/main.yml +++ b/tests/integration/targets/ec2_launch_template/meta/main.yml @@ -1,2 +1,3 @@ +--- dependencies: - setup_ec2_facts diff --git a/tests/integration/targets/ec2_launch_template/tasks/deletion.yml b/tests/integration/targets/ec2_launch_template/tasks/deletion.yml index 31770e1e941..38ccb48a660 100644 --- a/tests/integration/targets/ec2_launch_template/tasks/deletion.yml +++ b/tests/integration/targets/ec2_launch_template/tasks/deletion.yml @@ -1,3 +1,4 @@ +--- - name: Test deletion of launch template vars: deletion_launch_template_name: "{{ resource_prefix }}-deletion" @@ -28,10 +29,10 @@ - _templates.launch_templates[0].versions | length == 5 - _templates.launch_templates[0].latest_version_number == 5 - _templates.launch_templates[0].default_version_number == 5 - - #==================================================================== + + # ==================================================================== # Validate deletion errors - #==================================================================== + # ==================================================================== - name: Delete a non-existent template amazon.aws.ec2_launch_template: name: "{{ resource_prefix }}-not-a-real-template" @@ -40,7 +41,7 @@ ignore_errors: true - name: Ensure module did not failed while trying to delete non-existent template - assert: + ansible.builtin.assert: that: - delete_fake_template is not failed @@ -91,9 +92,9 @@ vars: error_m: "The following versions [10] do not exist for launch template id" - #==================================================================== + # ==================================================================== # Delete default version and set latest version as new default - #==================================================================== + # ==================================================================== - name: Delete default version and set a new default version (check mode) amazon.aws.ec2_launch_template: name: "{{ deletion_launch_template_name }}" @@ -144,9 +145,9 @@ - _templates.launch_templates[0].latest_version_number == 4 - _templates.launch_templates[0].default_version_number == 4 - #==================================================================== + # ==================================================================== # Delete a single version and set a new default version different from the latest - #==================================================================== + # ==================================================================== - name: Delete a single version and set a new default version different from the latest (check mode) amazon.aws.ec2_launch_template: name: "{{ deletion_launch_template_name }}" @@ -199,9 +200,9 @@ - _templates.launch_templates[0].latest_version_number == 4 - _templates.launch_templates[0].default_version_number == 1 - #==================================================================== + # ==================================================================== # Delete multiple versions - #==================================================================== + # ==================================================================== - name: Delete multiple versions (check mode) amazon.aws.ec2_launch_template: name: "{{ deletion_launch_template_name }}" @@ -252,9 +253,9 @@ - _templates.launch_templates[0].latest_version_number == 4 - _templates.launch_templates[0].default_version_number == 4 - #==================================================================== + # ==================================================================== # Delete launch template - #==================================================================== + # ==================================================================== - name: Delete launch template (check mode) amazon.aws.ec2_launch_template: name: "{{ deletion_launch_template_name }}" @@ -312,9 +313,9 @@ - delete_template_idempotency.deleted_template == {} - delete_template_idempotency.deleted_versions == [] - #==================================================================== + # ==================================================================== # Delete launch template with multiple versions - #==================================================================== + # ==================================================================== - name: Create multiple versions of the launch template amazon.aws.ec2_launch_template: name: "{{ deletion_launch_template_name_2 }}" diff --git a/tests/integration/targets/ec2_launch_template/tasks/iam_instance_role.yml b/tests/integration/targets/ec2_launch_template/tasks/iam_instance_role.yml index 3bd38fbce3a..17ef38bb025 100644 --- a/tests/integration/targets/ec2_launch_template/tasks/iam_instance_role.yml +++ b/tests/integration/targets/ec2_launch_template/tasks/iam_instance_role.yml @@ -1,3 +1,4 @@ +--- - name: Test using IAM instance profile vars: test_launch_template_name: "{{ resource_prefix }}-test-instance-role" @@ -5,21 +6,21 @@ - name: Create IAM role for test amazon.aws.iam_role: name: "{{ test_role_name }}-1" - assume_role_policy_document: "{{ lookup('file','assume-role-policy.json') }}" + assume_role_policy_document: "{{ lookup('file', 'assume-role-policy.json') }}" state: present - create_instance_profile: yes + create_instance_profile: true managed_policy: - - AWSDenyAll + - AWSDenyAll register: iam_role - name: Create second IAM role for test amazon.aws.iam_role: name: "{{ test_role_name }}-2" - assume_role_policy_document: "{{ lookup('file','assume-role-policy.json') }}" + assume_role_policy_document: "{{ lookup('file', 'assume-role-policy.json') }}" state: present - create_instance_profile: yes + create_instance_profile: true managed_policy: - - AWSDenyAll + - AWSDenyAll register: iam_role_2 - name: Make instance with an instance_role @@ -64,7 +65,7 @@ ansible.builtin.assert: that: - 'template_with_role.default_template.launch_template_data.iam_instance_profile.arn == iam_role.iam_role.arn.replace(":role/", ":instance-profile/")' - - 'template_with_role is not changed' + - "template_with_role is not changed" - _template_info.launch_templates | length == 1 - _template_info.launch_templates[0].versions | length == 1 - _template_info.launch_templates[0].versions[0].launch_template_data.iam_instance_profile.arn == iam_role.iam_role.arn.replace(":role/", ":instance-profile/") @@ -90,9 +91,9 @@ that: - 'template_with_updated_role.default_template.launch_template_data.iam_instance_profile.arn == iam_role_2.iam_role.arn.replace(":role/", ":instance-profile/")' - 'template_with_updated_role.default_template.launch_template_data.iam_instance_profile.arn == iam_role_2.iam_role.arn.replace(":role/", ":instance-profile/")' - - 'template_with_role.default_template.version_number < template_with_updated_role.default_template.version_number' - - 'template_with_updated_role is changed' - - 'template_with_updated_role is not failed' + - "template_with_role.default_template.version_number < template_with_updated_role.default_template.version_number" + - "template_with_updated_role is changed" + - "template_with_updated_role is not failed" - _template_info.launch_templates | length == 1 - _template_info.launch_templates[0].versions | length == 2 - template_version.launch_template_data.iam_instance_profile.arn == iam_role_2.iam_role.arn.replace(":role/", ":instance-profile/") @@ -118,7 +119,7 @@ - name: Ensure that module did not reported change ansible.builtin.assert: that: - - 'template_with_updated_role is not changed' + - "template_with_updated_role is not changed" - 'template_with_updated_role.default_template.launch_template_data.iam_instance_profile.arn == iam_role_2.iam_role.arn.replace(":role/", ":instance-profile/")' - _template_info.launch_templates | length == 1 - _template_info.launch_templates[0].versions | length == 2 @@ -143,9 +144,9 @@ that: - 'template_with_updated_role.default_template.launch_template_data.iam_instance_profile.arn == iam_role.iam_role.arn.replace(":role/", ":instance-profile/")' - 'template_with_updated_role.default_template.launch_template_data.iam_instance_profile.arn == iam_role.iam_role.arn.replace(":role/", ":instance-profile/")' - - 'template_with_role.default_template.version_number < template_with_updated_role.default_template.version_number' - - 'template_with_updated_role is changed' - - 'template_with_updated_role is not failed' + - "template_with_role.default_template.version_number < template_with_updated_role.default_template.version_number" + - "template_with_updated_role is changed" + - "template_with_updated_role is not failed" - _template_info.launch_templates | length == 1 - _template_info.launch_templates[0].versions | length == 3 - template_version.launch_template_data.iam_instance_profile.arn == iam_role.iam_role.arn.replace(":role/", ":instance-profile/") @@ -171,7 +172,7 @@ - name: Assert that the template was not updated ansible.builtin.assert: that: - - 'template_with_updated_role is not changed' + - "template_with_updated_role is not changed" - 'template_with_updated_role.default_template.launch_template_data.iam_instance_profile.arn == iam_role.iam_role.arn.replace(":role/", ":instance-profile/")' - _template_info.launch_templates | length == 1 - _template_info.launch_templates[0].versions | length == 3 @@ -183,20 +184,20 @@ state: absent register: lt_removed ignore_errors: true - + - name: Delete IAM role for test amazon.aws.iam_role: name: "{{ test_role_name }}-1" - assume_role_policy_document: "{{ lookup('file','assume-role-policy.json') }}" + assume_role_policy_document: "{{ lookup('file', 'assume-role-policy.json') }}" state: absent delete_instance_profile: true register: iam_removed ignore_errors: true - name: Delete IAM role for test - iam_role: + amazon.aws.iam_role: name: "{{ test_role_name }}-2" - assume_role_policy_document: "{{ lookup('file','assume-role-policy.json') }}" + assume_role_policy_document: "{{ lookup('file', 'assume-role-policy.json') }}" state: absent delete_instance_profile: true register: iam_2_removed diff --git a/tests/integration/targets/ec2_launch_template/tasks/main.yml b/tests/integration/targets/ec2_launch_template/tasks/main.yml index c8ea5f055da..4fd372a69c5 100644 --- a/tests/integration/targets/ec2_launch_template/tasks/main.yml +++ b/tests/integration/targets/ec2_launch_template/tasks/main.yml @@ -6,8 +6,8 @@ session_token: "{{ security_token | default(omit) }}" region: "{{ aws_region }}" block: - - include_tasks: template_data.yml - - include_tasks: tagging.yml - - include_tasks: iam_instance_role.yml - - include_tasks: versions.yml - - include_tasks: deletion.yml + - ansible.builtin.include_tasks: template_data.yml + - ansible.builtin.include_tasks: tagging.yml + - ansible.builtin.include_tasks: iam_instance_role.yml + - ansible.builtin.include_tasks: versions.yml + - ansible.builtin.include_tasks: deletion.yml diff --git a/tests/integration/targets/ec2_launch_template/tasks/tagging.yml b/tests/integration/targets/ec2_launch_template/tasks/tagging.yml index 9c021904acf..be1e5f55ccb 100644 --- a/tests/integration/targets/ec2_launch_template/tasks/tagging.yml +++ b/tests/integration/targets/ec2_launch_template/tasks/tagging.yml @@ -40,7 +40,7 @@ filters: launch-template-name: "{{ test_launch_template_name }}" register: _templates - + - name: Ensure the launch template was created with tags ansible.builtin.assert: that: @@ -55,8 +55,10 @@ - instance_tags.tags == launch_template_instance_tags - network_interface_tags.tags == launch_template_network_tags vars: - instance_tags: "{{ _templates.launch_templates[0].versions[0].launch_template_data.tag_specifications | selectattr('resource_type', 'equalto', 'instance') | list | first }}" - network_interface_tags: "{{ _templates.launch_templates[0].versions[0].launch_template_data.tag_specifications | selectattr('resource_type', 'equalto', 'network-interface') | list | first }}" + instance_tags: "{{ _templates.launch_templates[0].versions[0].launch_template_data.tag_specifications | selectattr('resource_type', 'equalto', 'instance') + | list | first }}" + network_interface_tags: "{{ _templates.launch_templates[0].versions[0].launch_template_data.tag_specifications | selectattr('resource_type', 'equalto', 'network-interface') + | list | first }}" # Create launch template once again with same tags (expected no change) - name: Create launch template once again with same tags (expected no change) @@ -97,8 +99,10 @@ - instance_tags.tags == launch_template_instance_tags - network_interface_tags.tags == launch_template_network_tags vars: - instance_tags: "{{ _templates.launch_templates[0].versions[0].launch_template_data.tag_specifications | selectattr('resource_type', 'equalto', 'instance') | list | first }}" - network_interface_tags: "{{ _templates.launch_templates[0].versions[0].launch_template_data.tag_specifications | selectattr('resource_type', 'equalto', 'network-interface') | list | first }}" + instance_tags: "{{ _templates.launch_templates[0].versions[0].launch_template_data.tag_specifications | selectattr('resource_type', 'equalto', 'instance') + | list | first }}" + network_interface_tags: "{{ _templates.launch_templates[0].versions[0].launch_template_data.tag_specifications | selectattr('resource_type', 'equalto', 'network-interface') + | list | first }}" # Add new tag - name: Add new tag with purge_tags=false @@ -141,8 +145,10 @@ - instance_tags.tags == launch_template_instance_tags - network_interface_tags.tags == launch_template_network_tags vars: - instance_tags: "{{ _templates.launch_templates[0].versions[0].launch_template_data.tag_specifications | selectattr('resource_type', 'equalto', 'instance') | list | first }}" - network_interface_tags: "{{ _templates.launch_templates[0].versions[0].launch_template_data.tag_specifications | selectattr('resource_type', 'equalto', 'network-interface') | list | first }}" + instance_tags: "{{ _templates.launch_templates[0].versions[0].launch_template_data.tag_specifications | selectattr('resource_type', 'equalto', 'instance') + | list | first }}" + network_interface_tags: "{{ _templates.launch_templates[0].versions[0].launch_template_data.tag_specifications | selectattr('resource_type', 'equalto', 'network-interface') + | list | first }}" # Add new launch template version and update tags - name: Add new launch template version and update tags diff --git a/tests/integration/targets/ec2_launch_template/tasks/template_data.yml b/tests/integration/targets/ec2_launch_template/tasks/template_data.yml index da4eeb6aedc..cb5234e9bc4 100644 --- a/tests/integration/targets/ec2_launch_template/tasks/template_data.yml +++ b/tests/integration/targets/ec2_launch_template/tasks/template_data.yml @@ -1,3 +1,4 @@ +--- - name: Test launch template data vars: test_launch_template_name: "{{ resource_prefix }}-template-data" @@ -9,8 +10,8 @@ image_id: "{{ ec2_ami_id }}" instance_type: c4.large cpu_options: - core_count: 1 - threads_per_core: 1 + core_count: 1 + threads_per_core: 1 network_interfaces: - device_index: 0 associate_public_ip_address: false @@ -45,8 +46,8 @@ image_id: "{{ ec2_ami_id }}" instance_type: c4.large cpu_options: - core_count: 1 - threads_per_core: 3 + core_count: 1 + threads_per_core: 3 network_interfaces: - device_index: 0 associate_public_ip_address: false @@ -94,8 +95,8 @@ image_id: "{{ ec2_ami_id }}" instance_type: c4.large cpu_options: - core_count: 1 - threads_per_core: 3 + core_count: 1 + threads_per_core: 3 network_interfaces: - device_index: 0 associate_public_ip_address: false @@ -138,7 +139,7 @@ - _templates.launch_templates[0].versions[0].launch_template_data.network_interfaces[1].ipv6_address_count == 1 always: - - name: delete the template + - name: Delete the template amazon.aws.ec2_launch_template: name: "{{ test_launch_template_name }}" state: absent diff --git a/tests/integration/targets/ec2_launch_template/tasks/versions.yml b/tests/integration/targets/ec2_launch_template/tasks/versions.yml index df0869f80bf..197235abade 100644 --- a/tests/integration/targets/ec2_launch_template/tasks/versions.yml +++ b/tests/integration/targets/ec2_launch_template/tasks/versions.yml @@ -1,462 +1,463 @@ +--- - name: Test launch template versioning vars: test_launch_template_name: "{{ resource_prefix }}-versioning" block: - #===================================================================== - # Create the launch template - #===================================================================== - - name: Create a launch template (check mode) - amazon.aws.ec2_launch_template: - name: "{{ test_launch_template_name }}" - image_id: "{{ ec2_ami_id }}" - tags: - TestId: "{{ resource_prefix }}" - instance_type: c4.large - register: _create_check - check_mode: true - - - name: Read launch template information - amazon.aws.ec2_launch_template_info: - filters: - launch-template-name: "{{ test_launch_template_name }}" - register: _template_info - - - name: Ensure module reported changed while the template was not created - ansible.builtin.assert: - that: - - _create_check is changed - - '"default_version" not in _create_check' - - '"latest_version" not in _create_check' - - _template_info.launch_templates | length == 0 - - - name: Create a launch template - amazon.aws.ec2_launch_template: - name: "{{ test_launch_template_name }}" - image_id: "{{ ec2_ami_id }}" - tags: - TestId: "{{ resource_prefix }}" - instance_type: c4.large - register: _create - - - name: Read launch template information - amazon.aws.ec2_launch_template_info: - launch_template_ids: - - "{{ _create.template.launch_template_id }}" - register: _template_info - - - name: Ensure the launch template was created with the right version - ansible.builtin.assert: - that: - - _create is changed - - _create.default_version == 1 - - _create.latest_version == 1 - - _template_info.launch_templates | length == 1 - - _template_info.launch_templates[0].default_version_number == 1 - - _template_info.launch_templates[0].latest_version_number == 1 - - _template_info.launch_templates[0].versions | length == 1 - - _template_info.launch_templates[0].versions.0.launch_template_data.image_id == ec2_ami_id - - _template_info.launch_templates[0].versions.0.launch_template_data.instance_type == "c4.large" - - - name: Create the same launch template once again - amazon.aws.ec2_launch_template: - name: "{{ test_launch_template_name }}" - image_id: "{{ ec2_ami_id }}" - tags: - TestId: "{{ resource_prefix }}" - instance_type: c4.large - register: _create_idempotency - - - name: Read launch template information - amazon.aws.ec2_launch_template_info: - filters: - launch-template-name: "{{ test_launch_template_name }}" - register: _template_info - - - name: Ensure the module did not reported change (idempotency) - ansible.builtin.assert: - that: - - _create_idempotency is not changed - - _create.default_version == 1 - - _create.latest_version == 1 - - _template_info.launch_templates | length == 1 - - _template_info.launch_templates[0].default_version_number == 1 - - _template_info.launch_templates[0].latest_version_number == 1 - - _template_info.launch_templates[0].versions | length == 1 - - _template_info.launch_templates[0].versions.0.launch_template_data.image_id == ec2_ami_id - - _template_info.launch_templates[0].versions.0.launch_template_data.instance_type == "c4.large" - - #===================================================================== - # Create a new version of the launch template (set first version as default) - #===================================================================== - - name: Create a new version of the launch template (check mode) - amazon.aws.ec2_launch_template: - name: "{{ test_launch_template_name }}" - default_version: 1 - image_id: "{{ ec2_ami_id }}" - tags: - TestId: "{{ resource_prefix }}" - instance_type: m5.large - register: _update_check - check_mode: true - - - name: Read launch template information - amazon.aws.ec2_launch_template_info: - filters: - launch-template-name: "{{ test_launch_template_name }}" - register: _template_info - - - name: Ensure the module reported change in check mode - ansible.builtin.assert: - that: - - _update_check is changed - - _template_info.launch_templates | length == 1 - - _template_info.launch_templates[0].default_version_number == 1 - - _template_info.launch_templates[0].latest_version_number == 1 - - _template_info.launch_templates[0].versions | length == 1 - - - name: Create a new version of the launch template - amazon.aws.ec2_launch_template: - name: "{{ test_launch_template_name }}" - default_version: 1 - image_id: "{{ ec2_ami_id }}" - tags: - TestId: "{{ resource_prefix }}" - instance_type: m5.large - register: _update - - - name: Read launch template information - amazon.aws.ec2_launch_template_info: - filters: - launch-template-name: "{{ test_launch_template_name }}" - register: _template_info - - - name: Ensure the launch template latest version has changed - ansible.builtin.assert: - that: - - _update is changed - - _update.default_version == 1 - - _update.latest_version == 2 - - _template_info.launch_templates | length == 1 - - _template_info.launch_templates[0].default_version_number == 1 - - _template_info.launch_templates[0].latest_version_number == 2 - - _template_info.launch_templates[0].versions | length == 2 - - created_template.launch_template_data.image_id == ec2_ami_id - - created_template.launch_template_data.instance_type == "m5.large" - vars: - created_template: "{{ _template_info.launch_templates[0].versions | selectattr('version_number', 'equalto', 2) | first }}" - - - name: Create a new version of the launch template (idempotency) - amazon.aws.ec2_launch_template: - name: "{{ test_launch_template_name }}" - default_version: 1 - image_id: "{{ ec2_ami_id }}" - tags: - TestId: "{{ resource_prefix }}" - instance_type: m5.large - register: _update_idempotency - - - name: Read launch template information - amazon.aws.ec2_launch_template_info: - filters: - launch-template-name: "{{ test_launch_template_name }}" - register: _template_info - - - name: Ensure the module did not reported change (idempotency) - ansible.builtin.assert: - that: - - _update_idempotency is not changed - - _update_idempotency.default_version == 1 - - _update_idempotency.latest_version == 2 - - _template_info.launch_templates | length == 1 - - _template_info.launch_templates[0].default_version_number == 1 - - _template_info.launch_templates[0].latest_version_number == 2 - - _template_info.launch_templates[0].versions | length == 2 - - #===================================================================== - # Set the latest version of the launch template as default - #===================================================================== - - name: Set the latest version of the launch template as default (check mode) - amazon.aws.ec2_launch_template: - name: "{{ test_launch_template_name }}" - default_version: latest - image_id: "{{ ec2_ami_id }}" - tags: - TestId: "{{ resource_prefix }}" - instance_type: m5.large - register: _set_version_check - check_mode: true - - - name: Read launch template information - amazon.aws.ec2_launch_template_info: - filters: - launch-template-name: "{{ test_launch_template_name }}" - register: _template_info - - - name: Ensure the module reported change in check mode - ansible.builtin.assert: - that: - - _set_version_check is changed - - _template_info.launch_templates | length == 1 - - _template_info.launch_templates[0].default_version_number == 1 - - _template_info.launch_templates[0].latest_version_number == 2 - - _template_info.launch_templates[0].versions | length == 2 - - - name: Set the latest version of the launch template as default - amazon.aws.ec2_launch_template: - name: "{{ test_launch_template_name }}" - default_version: latest - image_id: "{{ ec2_ami_id }}" - tags: - TestId: "{{ resource_prefix }}" - instance_type: m5.large - register: _set_version - - - name: Read launch template information - amazon.aws.ec2_launch_template_info: - filters: - launch-template-name: "{{ test_launch_template_name }}" - register: _template_info - - - name: Ensure the launch template latest version has changed - ansible.builtin.assert: - that: - - _set_version is changed - - _set_version.default_version == 2 - - _set_version.latest_version == 2 - - _template_info.launch_templates | length == 1 - - _template_info.launch_templates[0].default_version_number == 2 - - _template_info.launch_templates[0].latest_version_number == 2 - - _template_info.launch_templates[0].versions | length == 2 - - created_template.launch_template_data.image_id == ec2_ami_id - - created_template.launch_template_data.instance_type == "m5.large" - vars: - created_template: "{{ _template_info.launch_templates[0].versions | selectattr('version_number', 'equalto', 2) | first }}" - - - name: Set the latest version of the launch template as default (idempotency) - amazon.aws.ec2_launch_template: - name: "{{ test_launch_template_name }}" - default_version: latest - image_id: "{{ ec2_ami_id }}" - tags: - TestId: "{{ resource_prefix }}" - instance_type: m5.large - register: _set_version_idempotency - - - name: Read launch template information - amazon.aws.ec2_launch_template_info: - filters: - launch-template-name: "{{ test_launch_template_name }}" - register: _template_info - - - name: Ensure the module did not reported change (idempotency) - ansible.builtin.assert: - that: - - _set_version_idempotency is not changed - - _set_version_idempotency.default_version == 2 - - _set_version_idempotency.latest_version == 2 - - _template_info.launch_templates[0].default_version_number == 2 - - _template_info.launch_templates[0].latest_version_number == 2 - - _template_info.launch_templates[0].versions | length == 2 - - #===================================================================== - # Create another version - #===================================================================== - - name: Create a new launch template version (check mode) - amazon.aws.ec2_launch_template: - name: "{{ test_launch_template_name }}" - image_id: "{{ ec2_ami_id }}" - tags: - TestId: "{{ resource_prefix }}" - instance_type: t3.medium - register: _another_version_check - check_mode: true - - - name: Read launch template information - amazon.aws.ec2_launch_template_info: - launch_template_ids: - - "{{ _create.template.launch_template_id }}" - register: _template_info - - - name: Ensure the module reported change in check_mode - ansible.builtin.assert: - that: - - _another_version_check is changed - - _template_info.launch_templates | length == 1 - - _template_info.launch_templates[0].default_version_number == 2 - - _template_info.launch_templates[0].latest_version_number == 2 - - _template_info.launch_templates[0].versions | length == 2 - - - name: Create a new launch template version - amazon.aws.ec2_launch_template: - name: "{{ test_launch_template_name }}" - image_id: "{{ ec2_ami_id }}" - tags: - TestId: "{{ resource_prefix }}" - instance_type: t3.medium - register: _another_version - - - name: Read launch template information - amazon.aws.ec2_launch_template_info: - launch_template_ids: - - "{{ _create.template.launch_template_id }}" - register: _template_info - - - name: Ensure the launch template latest version has changed - ansible.builtin.assert: - that: - - _another_version is changed - - _another_version.default_version == 3 - - _another_version.latest_version == 3 - - _template_info.launch_templates | length == 1 - - _template_info.launch_templates[0].default_version_number == 3 - - _template_info.launch_templates[0].latest_version_number == 3 - - _template_info.launch_templates[0].versions | length == 3 - - created_template.launch_template_data.image_id == ec2_ami_id - - created_template.launch_template_data.instance_type == "t3.medium" - vars: - created_template: "{{ _template_info.launch_templates[0].versions | selectattr('version_number', 'equalto', 3) | first }}" - - - name: Create a new launch template version (idempotency) - amazon.aws.ec2_launch_template: - name: "{{ test_launch_template_name }}" - image_id: "{{ ec2_ami_id }}" - tags: - TestId: "{{ resource_prefix }}" - instance_type: t3.medium - register: _another_version_idempotency - - - name: Read launch template information - amazon.aws.ec2_launch_template_info: - launch_template_ids: - - "{{ _create.template.launch_template_id }}" - register: _template_info - - - name: Ensure the module did not reported change (idempotency) - ansible.builtin.assert: - that: - - _another_version_idempotency is not changed - - _another_version_idempotency.default_version == 3 - - _another_version_idempotency.latest_version == 3 - - _template_info.launch_templates | length == 1 - - _template_info.launch_templates[0].default_version_number == 3 - - _template_info.launch_templates[0].latest_version_number == 3 - - _template_info.launch_templates[0].versions | length == 3 - - #===================================================================== - # Create another version based on an old version - #===================================================================== - - name: Create new template version based on an old version (check mode) - amazon.aws.ec2_launch_template: - name: "{{ test_launch_template_name }}" - cpu_options: + # ===================================================================== + # Create the launch template + # ===================================================================== + - name: Create a launch template (check mode) + amazon.aws.ec2_launch_template: + name: "{{ test_launch_template_name }}" + image_id: "{{ ec2_ami_id }}" + tags: + TestId: "{{ resource_prefix }}" + instance_type: c4.large + register: _create_check + check_mode: true + + - name: Read launch template information + amazon.aws.ec2_launch_template_info: + filters: + launch-template-name: "{{ test_launch_template_name }}" + register: _template_info + + - name: Ensure module reported changed while the template was not created + ansible.builtin.assert: + that: + - _create_check is changed + - '"default_version" not in _create_check' + - '"latest_version" not in _create_check' + - _template_info.launch_templates | length == 0 + + - name: Create a launch template + amazon.aws.ec2_launch_template: + name: "{{ test_launch_template_name }}" + image_id: "{{ ec2_ami_id }}" + tags: + TestId: "{{ resource_prefix }}" + instance_type: c4.large + register: _create + + - name: Read launch template information + amazon.aws.ec2_launch_template_info: + launch_template_ids: + - "{{ _create.template.launch_template_id }}" + register: _template_info + + - name: Ensure the launch template was created with the right version + ansible.builtin.assert: + that: + - _create is changed + - _create.default_version == 1 + - _create.latest_version == 1 + - _template_info.launch_templates | length == 1 + - _template_info.launch_templates[0].default_version_number == 1 + - _template_info.launch_templates[0].latest_version_number == 1 + - _template_info.launch_templates[0].versions | length == 1 + - _template_info.launch_templates[0].versions.0.launch_template_data.image_id == ec2_ami_id + - _template_info.launch_templates[0].versions.0.launch_template_data.instance_type == "c4.large" + + - name: Create the same launch template once again + amazon.aws.ec2_launch_template: + name: "{{ test_launch_template_name }}" + image_id: "{{ ec2_ami_id }}" + tags: + TestId: "{{ resource_prefix }}" + instance_type: c4.large + register: _create_idempotency + + - name: Read launch template information + amazon.aws.ec2_launch_template_info: + filters: + launch-template-name: "{{ test_launch_template_name }}" + register: _template_info + + - name: Ensure the module did not reported change (idempotency) + ansible.builtin.assert: + that: + - _create_idempotency is not changed + - _create.default_version == 1 + - _create.latest_version == 1 + - _template_info.launch_templates | length == 1 + - _template_info.launch_templates[0].default_version_number == 1 + - _template_info.launch_templates[0].latest_version_number == 1 + - _template_info.launch_templates[0].versions | length == 1 + - _template_info.launch_templates[0].versions.0.launch_template_data.image_id == ec2_ami_id + - _template_info.launch_templates[0].versions.0.launch_template_data.instance_type == "c4.large" + + # ===================================================================== + # Create a new version of the launch template (set first version as default) + # ===================================================================== + - name: Create a new version of the launch template (check mode) + amazon.aws.ec2_launch_template: + name: "{{ test_launch_template_name }}" + default_version: 1 + image_id: "{{ ec2_ami_id }}" + tags: + TestId: "{{ resource_prefix }}" + instance_type: m5.large + register: _update_check + check_mode: true + + - name: Read launch template information + amazon.aws.ec2_launch_template_info: + filters: + launch-template-name: "{{ test_launch_template_name }}" + register: _template_info + + - name: Ensure the module reported change in check mode + ansible.builtin.assert: + that: + - _update_check is changed + - _template_info.launch_templates | length == 1 + - _template_info.launch_templates[0].default_version_number == 1 + - _template_info.launch_templates[0].latest_version_number == 1 + - _template_info.launch_templates[0].versions | length == 1 + + - name: Create a new version of the launch template + amazon.aws.ec2_launch_template: + name: "{{ test_launch_template_name }}" + default_version: 1 + image_id: "{{ ec2_ami_id }}" + tags: + TestId: "{{ resource_prefix }}" + instance_type: m5.large + register: _update + + - name: Read launch template information + amazon.aws.ec2_launch_template_info: + filters: + launch-template-name: "{{ test_launch_template_name }}" + register: _template_info + + - name: Ensure the launch template latest version has changed + ansible.builtin.assert: + that: + - _update is changed + - _update.default_version == 1 + - _update.latest_version == 2 + - _template_info.launch_templates | length == 1 + - _template_info.launch_templates[0].default_version_number == 1 + - _template_info.launch_templates[0].latest_version_number == 2 + - _template_info.launch_templates[0].versions | length == 2 + - created_template.launch_template_data.image_id == ec2_ami_id + - created_template.launch_template_data.instance_type == "m5.large" + vars: + created_template: "{{ _template_info.launch_templates[0].versions | selectattr('version_number', 'equalto', 2) | first }}" + + - name: Create a new version of the launch template (idempotency) + amazon.aws.ec2_launch_template: + name: "{{ test_launch_template_name }}" + default_version: 1 + image_id: "{{ ec2_ami_id }}" + tags: + TestId: "{{ resource_prefix }}" + instance_type: m5.large + register: _update_idempotency + + - name: Read launch template information + amazon.aws.ec2_launch_template_info: + filters: + launch-template-name: "{{ test_launch_template_name }}" + register: _template_info + + - name: Ensure the module did not reported change (idempotency) + ansible.builtin.assert: + that: + - _update_idempotency is not changed + - _update_idempotency.default_version == 1 + - _update_idempotency.latest_version == 2 + - _template_info.launch_templates | length == 1 + - _template_info.launch_templates[0].default_version_number == 1 + - _template_info.launch_templates[0].latest_version_number == 2 + - _template_info.launch_templates[0].versions | length == 2 + + # ===================================================================== + # Set the latest version of the launch template as default + # ===================================================================== + - name: Set the latest version of the launch template as default (check mode) + amazon.aws.ec2_launch_template: + name: "{{ test_launch_template_name }}" + default_version: latest + image_id: "{{ ec2_ami_id }}" + tags: + TestId: "{{ resource_prefix }}" + instance_type: m5.large + register: _set_version_check + check_mode: true + + - name: Read launch template information + amazon.aws.ec2_launch_template_info: + filters: + launch-template-name: "{{ test_launch_template_name }}" + register: _template_info + + - name: Ensure the module reported change in check mode + ansible.builtin.assert: + that: + - _set_version_check is changed + - _template_info.launch_templates | length == 1 + - _template_info.launch_templates[0].default_version_number == 1 + - _template_info.launch_templates[0].latest_version_number == 2 + - _template_info.launch_templates[0].versions | length == 2 + + - name: Set the latest version of the launch template as default + amazon.aws.ec2_launch_template: + name: "{{ test_launch_template_name }}" + default_version: latest + image_id: "{{ ec2_ami_id }}" + tags: + TestId: "{{ resource_prefix }}" + instance_type: m5.large + register: _set_version + + - name: Read launch template information + amazon.aws.ec2_launch_template_info: + filters: + launch-template-name: "{{ test_launch_template_name }}" + register: _template_info + + - name: Ensure the launch template latest version has changed + ansible.builtin.assert: + that: + - _set_version is changed + - _set_version.default_version == 2 + - _set_version.latest_version == 2 + - _template_info.launch_templates | length == 1 + - _template_info.launch_templates[0].default_version_number == 2 + - _template_info.launch_templates[0].latest_version_number == 2 + - _template_info.launch_templates[0].versions | length == 2 + - created_template.launch_template_data.image_id == ec2_ami_id + - created_template.launch_template_data.instance_type == "m5.large" + vars: + created_template: "{{ _template_info.launch_templates[0].versions | selectattr('version_number', 'equalto', 2) | first }}" + + - name: Set the latest version of the launch template as default (idempotency) + amazon.aws.ec2_launch_template: + name: "{{ test_launch_template_name }}" + default_version: latest + image_id: "{{ ec2_ami_id }}" + tags: + TestId: "{{ resource_prefix }}" + instance_type: m5.large + register: _set_version_idempotency + + - name: Read launch template information + amazon.aws.ec2_launch_template_info: + filters: + launch-template-name: "{{ test_launch_template_name }}" + register: _template_info + + - name: Ensure the module did not reported change (idempotency) + ansible.builtin.assert: + that: + - _set_version_idempotency is not changed + - _set_version_idempotency.default_version == 2 + - _set_version_idempotency.latest_version == 2 + - _template_info.launch_templates[0].default_version_number == 2 + - _template_info.launch_templates[0].latest_version_number == 2 + - _template_info.launch_templates[0].versions | length == 2 + + # ===================================================================== + # Create another version + # ===================================================================== + - name: Create a new launch template version (check mode) + amazon.aws.ec2_launch_template: + name: "{{ test_launch_template_name }}" + image_id: "{{ ec2_ami_id }}" + tags: + TestId: "{{ resource_prefix }}" + instance_type: t3.medium + register: _another_version_check + check_mode: true + + - name: Read launch template information + amazon.aws.ec2_launch_template_info: + launch_template_ids: + - "{{ _create.template.launch_template_id }}" + register: _template_info + + - name: Ensure the module reported change in check_mode + ansible.builtin.assert: + that: + - _another_version_check is changed + - _template_info.launch_templates | length == 1 + - _template_info.launch_templates[0].default_version_number == 2 + - _template_info.launch_templates[0].latest_version_number == 2 + - _template_info.launch_templates[0].versions | length == 2 + + - name: Create a new launch template version + amazon.aws.ec2_launch_template: + name: "{{ test_launch_template_name }}" + image_id: "{{ ec2_ami_id }}" + tags: + TestId: "{{ resource_prefix }}" + instance_type: t3.medium + register: _another_version + + - name: Read launch template information + amazon.aws.ec2_launch_template_info: + launch_template_ids: + - "{{ _create.template.launch_template_id }}" + register: _template_info + + - name: Ensure the launch template latest version has changed + ansible.builtin.assert: + that: + - _another_version is changed + - _another_version.default_version == 3 + - _another_version.latest_version == 3 + - _template_info.launch_templates | length == 1 + - _template_info.launch_templates[0].default_version_number == 3 + - _template_info.launch_templates[0].latest_version_number == 3 + - _template_info.launch_templates[0].versions | length == 3 + - created_template.launch_template_data.image_id == ec2_ami_id + - created_template.launch_template_data.instance_type == "t3.medium" + vars: + created_template: "{{ _template_info.launch_templates[0].versions | selectattr('version_number', 'equalto', 3) | first }}" + + - name: Create a new launch template version (idempotency) + amazon.aws.ec2_launch_template: + name: "{{ test_launch_template_name }}" + image_id: "{{ ec2_ami_id }}" + tags: + TestId: "{{ resource_prefix }}" + instance_type: t3.medium + register: _another_version_idempotency + + - name: Read launch template information + amazon.aws.ec2_launch_template_info: + launch_template_ids: + - "{{ _create.template.launch_template_id }}" + register: _template_info + + - name: Ensure the module did not reported change (idempotency) + ansible.builtin.assert: + that: + - _another_version_idempotency is not changed + - _another_version_idempotency.default_version == 3 + - _another_version_idempotency.latest_version == 3 + - _template_info.launch_templates | length == 1 + - _template_info.launch_templates[0].default_version_number == 3 + - _template_info.launch_templates[0].latest_version_number == 3 + - _template_info.launch_templates[0].versions | length == 3 + + # ===================================================================== + # Create another version based on an old version + # ===================================================================== + - name: Create new template version based on an old version (check mode) + amazon.aws.ec2_launch_template: + name: "{{ test_launch_template_name }}" + cpu_options: core_count: 1 threads_per_core: 1 - source_version: 1 - register: _version_based_on_old_version_check - check_mode: true - - - name: Read launch template information - amazon.aws.ec2_launch_template_info: - launch_template_ids: - - "{{ _create.template.launch_template_id }}" - register: _template_info - - - name: Ensure module reported change in check mode - ansible.builtin.assert: - that: - - _version_based_on_old_version_check is changed - - _template_info.launch_templates | length == 1 - - _template_info.launch_templates[0].default_version_number == 3 - - _template_info.launch_templates[0].latest_version_number == 3 - - _template_info.launch_templates[0].versions | length == 3 - - - name: Create new template version based on an old version - amazon.aws.ec2_launch_template: - name: "{{ test_launch_template_name }}" - cpu_options: + source_version: 1 + register: _version_based_on_old_version_check + check_mode: true + + - name: Read launch template information + amazon.aws.ec2_launch_template_info: + launch_template_ids: + - "{{ _create.template.launch_template_id }}" + register: _template_info + + - name: Ensure module reported change in check mode + ansible.builtin.assert: + that: + - _version_based_on_old_version_check is changed + - _template_info.launch_templates | length == 1 + - _template_info.launch_templates[0].default_version_number == 3 + - _template_info.launch_templates[0].latest_version_number == 3 + - _template_info.launch_templates[0].versions | length == 3 + + - name: Create new template version based on an old version + amazon.aws.ec2_launch_template: + name: "{{ test_launch_template_name }}" + cpu_options: core_count: 1 threads_per_core: 1 - source_version: 1 - register: _version_based_on_old_version - - - name: Read launch template information - amazon.aws.ec2_launch_template_info: - launch_template_ids: - - "{{ _create.template.launch_template_id }}" - register: _template_info - - - name: Ensure the new launch template has been created with the right options - ansible.builtin.assert: - that: - - _version_based_on_old_version is changed - - _version_based_on_old_version.default_version == 4 - - _version_based_on_old_version.latest_version == 4 - - _version_based_on_old_version.latest_template.launch_template_data.instance_type == "c4.large" - - _template_info.launch_templates | length == 1 - - _template_info.launch_templates[0].default_version_number == 4 - - _template_info.launch_templates[0].latest_version_number == 4 - - _template_info.launch_templates[0].versions | length == 4 - - created_template.launch_template_data.image_id == ec2_ami_id - - created_template.launch_template_data.cpu_options.core_count == 1 - - created_template.launch_template_data.cpu_options.threads_per_core == 1 - vars: - created_template: "{{ _template_info.launch_templates[0].versions | selectattr('version_number', 'equalto', 4) | first }}" - - #===================================================================== - # Create another version with updated description - #===================================================================== - - name: Create a launch template version with another description (check mode) - amazon.aws.ec2_launch_template: - name: "{{ test_launch_template_name }}" - version_description: "Fix something." - register: _version_description_check - check_mode: true - - - name: Read launch template information - amazon.aws.ec2_launch_template_info: - launch_template_ids: - - "{{ _create.template.launch_template_id }}" - register: _template_info - - - name: Ensure module reported change in check mode - ansible.builtin.assert: - that: - - _version_description_check is changed - - _template_info.launch_templates | length == 1 - - _template_info.launch_templates[0].default_version_number == 4 - - _template_info.launch_templates[0].latest_version_number == 4 - - _template_info.launch_templates[0].versions | length == 4 - - - name: Create a launch template version with another description - amazon.aws.ec2_launch_template: - name: "{{ test_launch_template_name }}" - version_description: "Fix something." - register: _version_description - - - name: Read launch template information - amazon.aws.ec2_launch_template_info: - launch_template_ids: - - "{{ _create.template.launch_template_id }}" - register: _template_info - - - name: Ensure module reported change - ansible.builtin.assert: - that: - - _version_description is changed - - _version_description.default_version == 5 - - _version_description.latest_version == 5 - - _version_description.latest_template.version_description == "Fix something." - - _template_info.launch_templates | length == 1 - - _template_info.launch_templates[0].default_version_number == 5 - - _template_info.launch_templates[0].latest_version_number == 5 - - _template_info.launch_templates[0].versions | length == 5 - - created_template.version_description == "Fix something." - vars: - created_template: "{{ _template_info.launch_templates[0].versions | selectattr('version_number', 'equalto', 5) | first }}" + source_version: 1 + register: _version_based_on_old_version + + - name: Read launch template information + amazon.aws.ec2_launch_template_info: + launch_template_ids: + - "{{ _create.template.launch_template_id }}" + register: _template_info + + - name: Ensure the new launch template has been created with the right options + ansible.builtin.assert: + that: + - _version_based_on_old_version is changed + - _version_based_on_old_version.default_version == 4 + - _version_based_on_old_version.latest_version == 4 + - _version_based_on_old_version.latest_template.launch_template_data.instance_type == "c4.large" + - _template_info.launch_templates | length == 1 + - _template_info.launch_templates[0].default_version_number == 4 + - _template_info.launch_templates[0].latest_version_number == 4 + - _template_info.launch_templates[0].versions | length == 4 + - created_template.launch_template_data.image_id == ec2_ami_id + - created_template.launch_template_data.cpu_options.core_count == 1 + - created_template.launch_template_data.cpu_options.threads_per_core == 1 + vars: + created_template: "{{ _template_info.launch_templates[0].versions | selectattr('version_number', 'equalto', 4) | first }}" + + # ===================================================================== + # Create another version with updated description + # ===================================================================== + - name: Create a launch template version with another description (check mode) + amazon.aws.ec2_launch_template: + name: "{{ test_launch_template_name }}" + version_description: "Fix something." + register: _version_description_check + check_mode: true + + - name: Read launch template information + amazon.aws.ec2_launch_template_info: + launch_template_ids: + - "{{ _create.template.launch_template_id }}" + register: _template_info + + - name: Ensure module reported change in check mode + ansible.builtin.assert: + that: + - _version_description_check is changed + - _template_info.launch_templates | length == 1 + - _template_info.launch_templates[0].default_version_number == 4 + - _template_info.launch_templates[0].latest_version_number == 4 + - _template_info.launch_templates[0].versions | length == 4 + + - name: Create a launch template version with another description + amazon.aws.ec2_launch_template: + name: "{{ test_launch_template_name }}" + version_description: "Fix something." + register: _version_description + + - name: Read launch template information + amazon.aws.ec2_launch_template_info: + launch_template_ids: + - "{{ _create.template.launch_template_id }}" + register: _template_info + + - name: Ensure module reported change + ansible.builtin.assert: + that: + - _version_description is changed + - _version_description.default_version == 5 + - _version_description.latest_version == 5 + - _version_description.latest_template.version_description == "Fix something." + - _template_info.launch_templates | length == 1 + - _template_info.launch_templates[0].default_version_number == 5 + - _template_info.launch_templates[0].latest_version_number == 5 + - _template_info.launch_templates[0].versions | length == 5 + - created_template.version_description == "Fix something." + vars: + created_template: "{{ _template_info.launch_templates[0].versions | selectattr('version_number', 'equalto', 5) | first }}" always: - - name: Delete the template - amazon.aws.ec2_launch_template: - name: "{{ test_launch_template_name }}" - state: absent - ignore_errors: true + - name: Delete the template + amazon.aws.ec2_launch_template: + name: "{{ test_launch_template_name }}" + state: absent + ignore_errors: true diff --git a/tests/integration/targets/ec2_metadata_facts/playbooks/setup.yml b/tests/integration/targets/ec2_metadata_facts/playbooks/setup.yml index f3c9344eef0..0428187f086 100644 --- a/tests/integration/targets/ec2_metadata_facts/playbooks/setup.yml +++ b/tests/integration/targets/ec2_metadata_facts/playbooks/setup.yml @@ -1,5 +1,6 @@ --- -- module_defaults: +- name: Prepare environment for the ec2_metadata_facts tests + module_defaults: group/aws: access_key: "{{ aws_access_key }}" secret_key: "{{ aws_secret_key }}" @@ -24,16 +25,16 @@ session_token: "{{ security_token | default(omit) }}" - ansible.builtin.include_role: - name: ../setup_sshkey + name: setup_sshkey - ansible.builtin.include_role: - name: ../setup_ec2_facts + name: setup_ec2_facts - ansible.builtin.set_fact: availability_zone: "{{ ec2_availability_zone_names[0] }}" # ============================================================ - - name: create a VPC + - name: Create a VPC amazon.aws.ec2_vpc_net: name: "{{ resource_prefix }}-vpc" state: present @@ -46,7 +47,7 @@ - ansible.builtin.set_fact: vpc_id: "{{ vpc_result.vpc.id }}" - - name: create an internet gateway + - name: Create an internet gateway amazon.aws.ec2_vpc_igw: vpc_id: "{{ vpc_id }}" state: present @@ -54,7 +55,7 @@ Name: "{{ resource_prefix }}" register: igw_result - - name: create a subnet + - name: Create a subnet amazon.aws.ec2_vpc_subnet: cidr: "{{ vpc_cidr }}" az: "{{ availability_zone }}" @@ -65,7 +66,7 @@ state: present register: vpc_subnet_result - - name: create a public route table + - name: Create a public route table amazon.aws.ec2_vpc_route_table: vpc_id: "{{ vpc_id }}" tags: @@ -77,7 +78,7 @@ gateway_id: "{{ igw_result.gateway_id }}" register: public_route_table - - name: create a security group + - name: Create a security group amazon.aws.ec2_security_group: name: "{{ resource_prefix }}-sg" description: Created by {{ resource_prefix }} @@ -166,8 +167,9 @@ - name: Create inventory file ansible.builtin.template: - src: ../templates/inventory.j2 + src: inventory.j2 dest: ../inventory + mode: "0644" - ansible.builtin.wait_for: port: 22 diff --git a/tests/integration/targets/ec2_metadata_facts/playbooks/teardown.yml b/tests/integration/targets/ec2_metadata_facts/playbooks/teardown.yml index 70bd00aea20..5383a0ff49f 100644 --- a/tests/integration/targets/ec2_metadata_facts/playbooks/teardown.yml +++ b/tests/integration/targets/ec2_metadata_facts/playbooks/teardown.yml @@ -1,5 +1,6 @@ --- -- module_defaults: +- name: Cleanup after ec2_metadata_facts tests + module_defaults: group/aws: access_key: "{{ aws_access_key }}" secret_key: "{{ aws_secret_key }}" @@ -11,7 +12,7 @@ tasks: # ============================================================ - - name: terminate the instance + - name: Terminate the instance amazon.aws.ec2_instance: state: absent instance_ids: @@ -23,13 +24,13 @@ register: remove until: remove is successful - - name: remove ssh key + - name: Remove ssh key amazon.aws.ec2_key: name: "{{ ec2_key_name }}" state: absent ignore_errors: true - - name: remove the public route table + - name: Remove the public route table amazon.aws.ec2_vpc_route_table: vpc_id: "{{ vpc_id }}" route_table_id: "{{ vpc_route_table_id }}" @@ -40,7 +41,7 @@ register: remove until: remove is successful - - name: remove the internet gateway + - name: Remove the internet gateway amazon.aws.ec2_vpc_igw: vpc_id: "{{ vpc_id }}" state: absent @@ -49,7 +50,7 @@ register: remove until: remove is successful - - name: remove the security group + - name: Remove the security group amazon.aws.ec2_security_group: group_id: "{{ vpc_sg_id }}" state: absent @@ -58,7 +59,7 @@ register: remove until: remove is successful - - name: remove the subnet + - name: Remove the subnet amazon.aws.ec2_vpc_subnet: cidr: "{{ vpc_cidr }}" az: "{{ availability_zone }}" @@ -69,7 +70,7 @@ register: remove until: remove is successful - - name: remove the VPC + - name: Remove the VPC amazon.aws.ec2_vpc_net: name: "{{ resource_prefix }}-vpc" cidr_block: "{{ vpc_cidr }}" 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 a75a11832c8..20eed28656e 100644 --- a/tests/integration/targets/ec2_metadata_facts/playbooks/test_metadata.yml +++ b/tests/integration/targets/ec2_metadata_facts/playbooks/test_metadata.yml @@ -1,5 +1,6 @@ --- -- hosts: testhost +- name: Run ec2_metadata_facts tests + hosts: testhost tasks: - name: Wait for EC2 to be available ansible.builtin.wait_for_connection: diff --git a/tests/integration/targets/ec2_metadata_facts/runme.sh b/tests/integration/targets/ec2_metadata_facts/runme.sh index 6f2bc466032..da8cde3a8bc 100755 --- a/tests/integration/targets/ec2_metadata_facts/runme.sh +++ b/tests/integration/targets/ec2_metadata_facts/runme.sh @@ -6,6 +6,9 @@ export ANSIBLE_SSH_ARGS='-o UserKnownHostsFile=/dev/null' CMD_ARGS=("$@") +ln -s "$(pwd)/../" playbooks/roles +ln -s ../templates playbooks/templates + # Destroy Environment cleanup() { ansible-playbook playbooks/teardown.yml -i inventory -c local "${CMD_ARGS[@]}" diff --git a/tests/integration/targets/ec2_placement_group/tasks/env_cleanup.yml b/tests/integration/targets/ec2_placement_group/tasks/env_cleanup.yml index 994bbc78be4..d1e5addac42 100644 --- a/tests/integration/targets/ec2_placement_group/tasks/env_cleanup.yml +++ b/tests/integration/targets/ec2_placement_group/tasks/env_cleanup.yml @@ -1,88 +1,89 @@ +--- - name: Remove any instances in the test VPC amazon.aws.ec2_instance: filters: - vpc_id: '{{ testing_vpc.vpc.id }}' + vpc_id: "{{ testing_vpc.vpc.id }}" state: absent register: removed until: removed is not failed - ignore_errors: yes + ignore_errors: true retries: 10 - name: Get ENIs amazon.aws.ec2_eni_info: filters: - vpc-id: '{{ testing_vpc.vpc.id }}' + vpc-id: "{{ testing_vpc.vpc.id }}" register: enis - name: Delete all ENIs amazon.aws.ec2_eni: - eni_id: '{{ item.id }}' + eni_id: "{{ item.id }}" state: absent until: removed is not failed - with_items: '{{ enis.network_interfaces }}' - ignore_errors: yes + with_items: "{{ enis.network_interfaces }}" + ignore_errors: true retries: 10 - name: Remove the security group amazon.aws.ec2_security_group: - name: '{{ resource_prefix }}-sg' + name: "{{ resource_prefix }}-sg" description: a security group for ansible tests - vpc_id: '{{ testing_vpc.vpc.id }}' + vpc_id: "{{ testing_vpc.vpc.id }}" state: absent register: removed until: removed is not failed - ignore_errors: yes + ignore_errors: true retries: 10 - name: Remove routing rules amazon.aws.ec2_vpc_route_table: state: absent - vpc_id: '{{ testing_vpc.vpc.id }}' + vpc_id: "{{ testing_vpc.vpc.id }}" tags: - created: '{{ resource_prefix }}-route' + created: "{{ resource_prefix }}-route" routes: - - dest: 0.0.0.0/0 - gateway_id: '{{ igw.gateway_id }}' + - dest: 0.0.0.0/0 + gateway_id: "{{ igw.gateway_id }}" subnets: - - '{{ testing_subnet_a.subnet.id }}' - - '{{ testing_subnet_b.subnet.id }}' + - "{{ testing_subnet_a.subnet.id }}" + - "{{ testing_subnet_b.subnet.id }}" register: removed until: removed is not failed - ignore_errors: yes + ignore_errors: true retries: 10 - name: Remove internet gateway amazon.aws.ec2_vpc_igw: - vpc_id: '{{ testing_vpc.vpc.id }}' + vpc_id: "{{ testing_vpc.vpc.id }}" state: absent register: removed until: removed is not failed - ignore_errors: yes + ignore_errors: true retries: 10 - name: Remove subnet A amazon.aws.ec2_vpc_subnet: state: absent - vpc_id: '{{ testing_vpc.vpc.id }}' + vpc_id: "{{ testing_vpc.vpc.id }}" cidr: 10.22.32.0/24 register: removed until: removed is not failed - ignore_errors: yes + ignore_errors: true retries: 10 - name: Remove subnet B amazon.aws.ec2_vpc_subnet: state: absent - vpc_id: '{{ testing_vpc.vpc.id }}' + vpc_id: "{{ testing_vpc.vpc.id }}" cidr: 10.22.33.0/24 register: removed until: removed is not failed - ignore_errors: yes + ignore_errors: true retries: 10 - name: Remove the VPC amazon.aws.ec2_vpc_net: - name: '{{ resource_prefix }}-vpc' + name: "{{ resource_prefix }}-vpc" cidr_block: 10.22.32.0/23 state: absent tags: @@ -90,5 +91,5 @@ tenancy: default register: removed until: removed is not failed - ignore_errors: yes + ignore_errors: true retries: 10 diff --git a/tests/integration/targets/ec2_placement_group/tasks/env_setup.yml b/tests/integration/targets/ec2_placement_group/tasks/env_setup.yml index 77fee9d57b3..76d3512098b 100644 --- a/tests/integration/targets/ec2_placement_group/tasks/env_setup.yml +++ b/tests/integration/targets/ec2_placement_group/tasks/env_setup.yml @@ -1,6 +1,7 @@ +--- - name: Create VPC for use in testing amazon.aws.ec2_vpc_net: - name: '{{ resource_prefix }}-vpc' + name: "{{ resource_prefix }}-vpc" cidr_block: 10.22.32.0/23 tags: Name: Ansible ec2_lc Testing VPC @@ -9,7 +10,7 @@ - name: Create internet gateway for use in testing amazon.aws.ec2_vpc_igw: - vpc_id: '{{ testing_vpc.vpc.id }}' + vpc_id: "{{ testing_vpc.vpc.id }}" state: present tags: Name: Ansible ec2_lc Testing gateway @@ -18,47 +19,47 @@ - name: Create default subnet in zone A amazon.aws.ec2_vpc_subnet: state: present - vpc_id: '{{ testing_vpc.vpc.id }}' + vpc_id: "{{ testing_vpc.vpc.id }}" cidr: 10.22.32.0/24 - az: '{{ aws_region }}a' + az: "{{ aws_region }}a" resource_tags: - Name: '{{ resource_prefix }}-subnet-a' + Name: "{{ resource_prefix }}-subnet-a" register: testing_subnet_a - name: Create secondary subnet in zone B amazon.aws.ec2_vpc_subnet: state: present - vpc_id: '{{ testing_vpc.vpc.id }}' + vpc_id: "{{ testing_vpc.vpc.id }}" cidr: 10.22.33.0/24 - az: '{{ aws_region }}b' + az: "{{ aws_region }}b" resource_tags: - Name: '{{ resource_prefix }}-subnet-b' + Name: "{{ resource_prefix }}-subnet-b" register: testing_subnet_b - name: Create routing rules amazon.aws.ec2_vpc_route_table: - vpc_id: '{{ testing_vpc.vpc.id }}' + vpc_id: "{{ testing_vpc.vpc.id }}" tags: - created: '{{ resource_prefix }}-route' + created: "{{ resource_prefix }}-route" routes: - - dest: 0.0.0.0/0 - gateway_id: '{{ igw.gateway_id }}' + - dest: 0.0.0.0/0 + gateway_id: "{{ igw.gateway_id }}" subnets: - - '{{ testing_subnet_a.subnet.id }}' - - '{{ testing_subnet_b.subnet.id }}' + - "{{ testing_subnet_a.subnet.id }}" + - "{{ testing_subnet_b.subnet.id }}" - name: Create a security group with the vpc amazon.aws.ec2_security_group: - name: '{{ resource_prefix }}-sg' + name: "{{ resource_prefix }}-sg" description: a security group for ansible tests - vpc_id: '{{ testing_vpc.vpc.id }}' + vpc_id: "{{ testing_vpc.vpc.id }}" rules: - - proto: tcp - from_port: 22 - to_port: 22 - cidr_ip: 0.0.0.0/0 - - proto: tcp - from_port: 80 - to_port: 80 - cidr_ip: 0.0.0.0/0 + - proto: tcp + from_port: 22 + to_port: 22 + cidr_ip: 0.0.0.0/0 + - proto: tcp + from_port: 80 + to_port: 80 + cidr_ip: 0.0.0.0/0 register: sg diff --git a/tests/integration/targets/ec2_placement_group/tasks/main.yml b/tests/integration/targets/ec2_placement_group/tasks/main.yml index 2f2a3a713b5..81fddb0784b 100644 --- a/tests/integration/targets/ec2_placement_group/tasks/main.yml +++ b/tests/integration/targets/ec2_placement_group/tasks/main.yml @@ -1,568 +1,559 @@ -- name: run ec2_placement_group tests +--- +- name: Run ec2_placement_group 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 }}" vars: placement_group_names: [] - block: - - - name: Set up environment for testing. - include_tasks: env_setup.yml - - - name: Create a placement group 1 - check_mode - amazon.aws.ec2_placement_group: - name: '{{ resource_prefix }}-pg1' - state: present - check_mode: true - register: pg_1_create_check_mode - - - name: Assert that placement group data is returned (check mode) - ansible.builtin.assert: - that: - - pg_1_create_check_mode is changed - - pg_1_create_check_mode.placement_group.name == resource_prefix ~ '-pg1' - - - name: Create a placement group 1 - amazon.aws.ec2_placement_group: - name: '{{ resource_prefix }}-pg1' - state: present - register: pg_1_create - - - ansible.builtin.set_fact: - placement_group_names: '{{ placement_group_names + [pg_1_create.placement_group.name] - }}' - - - name: Assert that placement group is created - ansible.builtin.assert: - that: - - pg_1_create is changed - - pg_1_create.placement_group.name == resource_prefix ~ '-pg1' - - pg_1_create.placement_group.state == "available" - - '"ec2:CreatePlacementGroup" in pg_1_create.resource_actions' - - - name: Gather information about placement group 1 - amazon.aws.ec2_placement_group_info: - names: - - '{{ resource_prefix }}-pg1' - register: pg_1_info_result - - - name: Assert that placement group is created - ansible.builtin.assert: - that: - - pg_1_info_result is not changed - - pg_1_info_result.placement_groups[0].name == resource_prefix ~ '-pg1' - - pg_1_info_result.placement_groups[0].state == "available" - - pg_1_info_result.placement_groups[0].strategy == "cluster" - - '"ec2:DescribePlacementGroups" in pg_1_info_result.resource_actions' - - - name: Create a placement group 1 - Idempotency - amazon.aws.ec2_placement_group: - name: '{{ resource_prefix }}-pg1' - state: present - register: pg_1_create - - - name: Assert that placement group is not created (idempotent) - ansible.builtin.assert: - that: - - pg_1_create is not changed - - pg_1_create.placement_group.name == resource_prefix ~ '-pg1' - - pg_1_create.placement_group.state == "available" - - '"ec2:CreatePlacementGroup" not in pg_1_create.resource_actions' - - - name: Create a placement group 1 - check_mode Idempotency - amazon.aws.ec2_placement_group: - name: '{{ resource_prefix }}-pg1' - state: present - check_mode: true - register: pg_1_create_check_mode_idem - - - name: Assert that placement group is not created (idempotent - check_mode) - ansible.builtin.assert: - that: - - pg_1_create_check_mode_idem is not changed - - pg_1_create_check_mode_idem.placement_group.name == resource_prefix ~ '-pg1' - - pg_1_create_check_mode_idem.placement_group.state == "available" - - - name: Create a placement group 2 - check_mode - amazon.aws.ec2_placement_group: - name: '{{ resource_prefix }}-pg2' - state: present - strategy: spread - check_mode: true - register: pg_2_create_check_mode - - - name: Assert that placement group is created - ansible.builtin.assert: - that: - - pg_2_create_check_mode is changed - - pg_2_create_check_mode.placement_group.name == resource_prefix ~ '-pg2' - - - name: Create a placement group 2 with spread strategy - amazon.aws.ec2_placement_group: - name: '{{ resource_prefix }}-pg2' - state: present - strategy: spread - register: pg_2_create - - - name: Assert that placement group is created - ansible.builtin.assert: - that: - - pg_2_create is changed - - pg_2_create.placement_group.name == resource_prefix ~ '-pg2' - - pg_2_create.placement_group.state == "available" - - '"ec2:CreatePlacementGroup" in pg_2_create.resource_actions' - - - ansible.builtin.set_fact: - placement_group_names: '{{ placement_group_names + [pg_2_create.placement_group.name] - }}' - - - name: Gather information about placement group 2 - amazon.aws.ec2_placement_group_info: - names: - - '{{ resource_prefix }}-pg2' - register: pg_2_info_result - - - name: Assert that placement group is created - ansible.builtin.assert: - that: - - pg_2_info_result is not changed - - pg_2_info_result.placement_groups[0].name == resource_prefix ~ '-pg2' - - pg_2_info_result.placement_groups[0].state == "available" - - pg_2_info_result.placement_groups[0].strategy == "spread" - - '"ec2:DescribePlacementGroups" in pg_2_info_result.resource_actions' - - - name: Create a placement group 2 with spread strategy - Idempotency - amazon.aws.ec2_placement_group: - name: '{{ resource_prefix }}-pg2' - state: present - strategy: spread - register: pg_2_create - - - name: Assert that placement group exists (idempotent) - ansible.builtin.assert: - that: - - pg_2_create is not changed - - pg_2_create.placement_group.name == resource_prefix ~ '-pg2' - - pg_2_create.placement_group.state == "available" - - '"ec2:CreatePlacementGroup" not in pg_2_create.resource_actions' - - - name: Create a placement group 2 - check_mode Idempotency - amazon.aws.ec2_placement_group: - name: '{{ resource_prefix }}-pg2' - state: present - strategy: spread - check_mode: true - register: pg_2_create_check_mode_idem - - - name: Assert that placement group exists (idempotent - check_mode) - ansible.builtin.assert: - that: - - pg_2_create_check_mode_idem is not changed - - pg_2_create_check_mode_idem.placement_group.name == resource_prefix ~ '-pg2' - - pg_2_create_check_mode_idem.placement_group.state == "available" - - - name: Create a placement group 3 - check_mode - amazon.aws.ec2_placement_group: - name: '{{ resource_prefix }}-pg3' - state: present - strategy: partition - partition_count: 4 - check_mode: true - register: pg_3_create_check_mode - - - name: Assert that placement group exists - ansible.builtin.assert: - that: - - pg_3_create_check_mode is changed - - pg_3_create_check_mode.placement_group.name == resource_prefix ~ '-pg3' - - - name: Create a placement group 3 with Partition strategy - amazon.aws.ec2_placement_group: - name: '{{ resource_prefix }}-pg3' - state: present - strategy: partition - partition_count: 4 - register: pg_3_create - - - name: Assert that placement group exists - ansible.builtin.assert: - that: - - pg_3_create is changed - - pg_3_create.placement_group.name == resource_prefix ~ '-pg3' - - pg_3_create.placement_group.state == "available" - - '"ec2:CreatePlacementGroup" in pg_3_create.resource_actions' - - - ansible.builtin.set_fact: - placement_group_names: '{{ placement_group_names + [pg_3_create.placement_group.name] - }}' - - - - name: Gather information about placement group 3 - amazon.aws.ec2_placement_group_info: - names: - - '{{ resource_prefix }}-pg3' - register: pg_3_info_result - - - name: Assert that placement group exists - ansible.builtin.assert: - that: - - pg_3_info_result is not changed - - pg_3_info_result.placement_groups[0].name == resource_prefix ~ '-pg3' - - pg_3_info_result.placement_groups[0].state == "available" - - pg_3_info_result.placement_groups[0].strategy == "partition" - - '"ec2:DescribePlacementGroups" in pg_3_info_result.resource_actions' - - - name: Create a placement group 3 with Partition strategy - Idempotency - amazon.aws.ec2_placement_group: - name: '{{ resource_prefix }}-pg3' - state: present - strategy: partition - partition_count: 4 - register: pg_3_create - - - name: Assert that placement group exists (idempotent) - ansible.builtin.assert: - that: - - pg_3_create is not changed - - pg_3_create.placement_group.name == resource_prefix ~ '-pg3' - - pg_3_create.placement_group.state == "available" - - '"ec2:CreatePlacementGroup" not in pg_3_create.resource_actions' - - - name: Create a placement group 3 - check_mode Idempotency - amazon.aws.ec2_placement_group: - name: '{{ resource_prefix }}-pg3' - state: present - strategy: partition - partition_count: 4 - check_mode: true - register: pg_3_create_check_mode_idem - - - name: Assert that placement group exists (idempotent - check_mode) - ansible.builtin.assert: - that: - - pg_3_create_check_mode_idem is not changed - - pg_3_create_check_mode_idem.placement_group.name == resource_prefix ~ '-pg3' - - pg_3_create_check_mode_idem.placement_group.state == "available" - - - name: Create a placement group 4 with tags - check_mode - amazon.aws.ec2_placement_group: - name: '{{ resource_prefix }}-pg4' - state: present - strategy: cluster - tags: - foo: test1 - bar: test2 - check_mode: true - register: pg_4_create_check_mode - - - name: Assert that placement group exists (check-mode) - ansible.builtin.assert: - that: - - pg_4_create_check_mode is changed - - pg_4_create_check_mode.placement_group.name == resource_prefix ~ '-pg4' - - pg_4_create_check_mode.placement_group.tags.foo == "test1" - - pg_4_create_check_mode.placement_group.tags.bar == "test2" - - - name: Create a placement group 4 with tags - amazon.aws.ec2_placement_group: - name: '{{ resource_prefix }}-pg4' - state: present - strategy: cluster - tags: - foo: test1 - bar: test2 - register: pg_4_create - - - name: Assert that placement group exists - ansible.builtin.assert: - that: - - pg_4_create is changed - - pg_4_create.placement_group.name == resource_prefix ~ '-pg4' - - pg_4_create.placement_group.state == "available" - - pg_4_create.placement_group.tags.foo == "test1" - - pg_4_create.placement_group.tags.bar == "test2" - - '"ec2:CreatePlacementGroup" in pg_4_create.resource_actions' - - - ansible.builtin.set_fact: - placement_group_names: '{{ placement_group_names + [pg_4_create.placement_group.name] - }}' - - - name: Gather information about placement group 4 - amazon.aws.ec2_placement_group_info: - names: - - '{{ resource_prefix }}-pg4' - register: pg_4_info_result - - - name: Assert that placement group exists - ansible.builtin.assert: - that: - - pg_4_info_result is not changed - - pg_4_info_result.placement_groups[0].name == resource_prefix ~ '-pg4' - - pg_4_info_result.placement_groups[0].state == "available" - - pg_4_info_result.placement_groups[0].strategy == "cluster" - - pg_4_info_result.placement_groups[0].tags.foo == "test1" - - pg_4_info_result.placement_groups[0].tags.bar == "test2" - - '"ec2:DescribePlacementGroups" in pg_4_info_result.resource_actions' - - - name: Create a placement group 4 with tags - Idempotency - amazon.aws.ec2_placement_group: - name: '{{ resource_prefix }}-pg4' - state: present - strategy: cluster - tags: - foo: test1 - bar: test2 - register: pg_4_create - - - name: Assert that placement group exists (idempotent) - ansible.builtin.assert: - that: - - pg_4_create is not changed - - pg_4_create.placement_group.name == resource_prefix ~ '-pg4' - - pg_4_create.placement_group.state == "available" - - pg_4_create.placement_group.strategy == "cluster" - - pg_4_create.placement_group.tags.foo == "test1" - - pg_4_create.placement_group.tags.bar == "test2" - - '"ec2:CreatePlacementGroup" not in pg_4_create.resource_actions' - - - name: Create a placement group 4 with tags - check_mode Idempotency - amazon.aws.ec2_placement_group: - name: '{{ resource_prefix }}-pg4' - state: present - strategy: cluster - tags: - foo: test1 - bar: test2 - check_mode: true - register: pg_4_create_check_mode_idem - - - name: Assert that placement group exists (idempotent - check-mode) - ansible.builtin.assert: - that: - - pg_4_create_check_mode_idem is not changed - - pg_4_create_check_mode_idem.placement_group.name == resource_prefix ~ '-pg4' - - pg_4_create_check_mode_idem.placement_group.state == "available" - - pg_4_create_check_mode_idem.placement_group.strategy == "cluster" - - pg_4_create_check_mode_idem.placement_group.tags.foo == "test1" - - pg_4_create_check_mode_idem.placement_group.tags.bar == "test2" - - - name: List all placement groups. - amazon.aws.ec2_placement_group_info: - register: all_ec2_placement_groups + - name: Set up environment for testing. + ansible.builtin.include_tasks: env_setup.yml + - name: Create a placement group 1 - check_mode + amazon.aws.ec2_placement_group: + name: "{{ resource_prefix }}-pg1" + state: present + check_mode: true + register: pg_1_create_check_mode + + - name: Assert that placement group data is returned (check mode) + ansible.builtin.assert: + that: + - pg_1_create_check_mode is changed + - pg_1_create_check_mode.placement_group.name == resource_prefix ~ '-pg1' + + - name: Create a placement group 1 + amazon.aws.ec2_placement_group: + name: "{{ resource_prefix }}-pg1" + state: present + register: pg_1_create + + - ansible.builtin.set_fact: + placement_group_names: "{{ placement_group_names + [pg_1_create.placement_group.name] }}" + + - name: Assert that placement group is created + ansible.builtin.assert: + that: + - pg_1_create is changed + - pg_1_create.placement_group.name == resource_prefix ~ '-pg1' + - pg_1_create.placement_group.state == "available" + - '"ec2:CreatePlacementGroup" in pg_1_create.resource_actions' + + - name: Gather information about placement group 1 + amazon.aws.ec2_placement_group_info: + names: + - "{{ resource_prefix }}-pg1" + register: pg_1_info_result + + - name: Assert that placement group is created + ansible.builtin.assert: + that: + - pg_1_info_result is not changed + - pg_1_info_result.placement_groups[0].name == resource_prefix ~ '-pg1' + - pg_1_info_result.placement_groups[0].state == "available" + - pg_1_info_result.placement_groups[0].strategy == "cluster" + - '"ec2:DescribePlacementGroups" in pg_1_info_result.resource_actions' + + - name: Create a placement group 1 - Idempotency + amazon.aws.ec2_placement_group: + name: "{{ resource_prefix }}-pg1" + state: present + register: pg_1_create + + - name: Assert that placement group is not created (idempotent) + ansible.builtin.assert: + that: + - pg_1_create is not changed + - pg_1_create.placement_group.name == resource_prefix ~ '-pg1' + - pg_1_create.placement_group.state == "available" + - '"ec2:CreatePlacementGroup" not in pg_1_create.resource_actions' + + - name: Create a placement group 1 - check_mode Idempotency + amazon.aws.ec2_placement_group: + name: "{{ resource_prefix }}-pg1" + state: present + check_mode: true + register: pg_1_create_check_mode_idem + + - name: Assert that placement group is not created (idempotent - check_mode) + ansible.builtin.assert: + that: + - pg_1_create_check_mode_idem is not changed + - pg_1_create_check_mode_idem.placement_group.name == resource_prefix ~ '-pg1' + - pg_1_create_check_mode_idem.placement_group.state == "available" + + - name: Create a placement group 2 - check_mode + amazon.aws.ec2_placement_group: + name: "{{ resource_prefix }}-pg2" + state: present + strategy: spread + check_mode: true + register: pg_2_create_check_mode + + - name: Assert that placement group is created + ansible.builtin.assert: + that: + - pg_2_create_check_mode is changed + - pg_2_create_check_mode.placement_group.name == resource_prefix ~ '-pg2' + + - name: Create a placement group 2 with spread strategy + amazon.aws.ec2_placement_group: + name: "{{ resource_prefix }}-pg2" + state: present + strategy: spread + register: pg_2_create + + - name: Assert that placement group is created + ansible.builtin.assert: + that: + - pg_2_create is changed + - pg_2_create.placement_group.name == resource_prefix ~ '-pg2' + - pg_2_create.placement_group.state == "available" + - '"ec2:CreatePlacementGroup" in pg_2_create.resource_actions' + + - ansible.builtin.set_fact: + placement_group_names: "{{ placement_group_names + [pg_2_create.placement_group.name] }}" + + - name: Gather information about placement group 2 + amazon.aws.ec2_placement_group_info: + names: + - "{{ resource_prefix }}-pg2" + register: pg_2_info_result + + - name: Assert that placement group is created + ansible.builtin.assert: + that: + - pg_2_info_result is not changed + - pg_2_info_result.placement_groups[0].name == resource_prefix ~ '-pg2' + - pg_2_info_result.placement_groups[0].state == "available" + - pg_2_info_result.placement_groups[0].strategy == "spread" + - '"ec2:DescribePlacementGroups" in pg_2_info_result.resource_actions' + + - name: Create a placement group 2 with spread strategy - Idempotency + amazon.aws.ec2_placement_group: + name: "{{ resource_prefix }}-pg2" + state: present + strategy: spread + register: pg_2_create + + - name: Assert that placement group exists (idempotent) + ansible.builtin.assert: + that: + - pg_2_create is not changed + - pg_2_create.placement_group.name == resource_prefix ~ '-pg2' + - pg_2_create.placement_group.state == "available" + - '"ec2:CreatePlacementGroup" not in pg_2_create.resource_actions' + + - name: Create a placement group 2 - check_mode Idempotency + amazon.aws.ec2_placement_group: + name: "{{ resource_prefix }}-pg2" + state: present + strategy: spread + check_mode: true + register: pg_2_create_check_mode_idem + + - name: Assert that placement group exists (idempotent - check_mode) + ansible.builtin.assert: + that: + - pg_2_create_check_mode_idem is not changed + - pg_2_create_check_mode_idem.placement_group.name == resource_prefix ~ '-pg2' + - pg_2_create_check_mode_idem.placement_group.state == "available" + + - name: Create a placement group 3 - check_mode + amazon.aws.ec2_placement_group: + name: "{{ resource_prefix }}-pg3" + state: present + strategy: partition + partition_count: 4 + check_mode: true + register: pg_3_create_check_mode + + - name: Assert that placement group exists + ansible.builtin.assert: + that: + - pg_3_create_check_mode is changed + - pg_3_create_check_mode.placement_group.name == resource_prefix ~ '-pg3' + + - name: Create a placement group 3 with Partition strategy + amazon.aws.ec2_placement_group: + name: "{{ resource_prefix }}-pg3" + state: present + strategy: partition + partition_count: 4 + register: pg_3_create + + - name: Assert that placement group exists + ansible.builtin.assert: + that: + - pg_3_create is changed + - pg_3_create.placement_group.name == resource_prefix ~ '-pg3' + - pg_3_create.placement_group.state == "available" + - '"ec2:CreatePlacementGroup" in pg_3_create.resource_actions' + + - ansible.builtin.set_fact: + placement_group_names: "{{ placement_group_names + [pg_3_create.placement_group.name] }}" + + - name: Gather information about placement group 3 + amazon.aws.ec2_placement_group_info: + names: + - "{{ resource_prefix }}-pg3" + register: pg_3_info_result + + - name: Assert that placement group exists + ansible.builtin.assert: + that: + - pg_3_info_result is not changed + - pg_3_info_result.placement_groups[0].name == resource_prefix ~ '-pg3' + - pg_3_info_result.placement_groups[0].state == "available" + - pg_3_info_result.placement_groups[0].strategy == "partition" + - '"ec2:DescribePlacementGroups" in pg_3_info_result.resource_actions' + + - name: Create a placement group 3 with Partition strategy - Idempotency + amazon.aws.ec2_placement_group: + name: "{{ resource_prefix }}-pg3" + state: present + strategy: partition + partition_count: 4 + register: pg_3_create + + - name: Assert that placement group exists (idempotent) + ansible.builtin.assert: + that: + - pg_3_create is not changed + - pg_3_create.placement_group.name == resource_prefix ~ '-pg3' + - pg_3_create.placement_group.state == "available" + - '"ec2:CreatePlacementGroup" not in pg_3_create.resource_actions' + + - name: Create a placement group 3 - check_mode Idempotency + amazon.aws.ec2_placement_group: + name: "{{ resource_prefix }}-pg3" + state: present + strategy: partition + partition_count: 4 + check_mode: true + register: pg_3_create_check_mode_idem + + - name: Assert that placement group exists (idempotent - check_mode) + ansible.builtin.assert: + that: + - pg_3_create_check_mode_idem is not changed + - pg_3_create_check_mode_idem.placement_group.name == resource_prefix ~ '-pg3' + - pg_3_create_check_mode_idem.placement_group.state == "available" + + - name: Create a placement group 4 with tags - check_mode + amazon.aws.ec2_placement_group: + name: "{{ resource_prefix }}-pg4" + state: present + strategy: cluster + tags: + foo: test1 + bar: test2 + check_mode: true + register: pg_4_create_check_mode + + - name: Assert that placement group exists (check-mode) + ansible.builtin.assert: + that: + - pg_4_create_check_mode is changed + - pg_4_create_check_mode.placement_group.name == resource_prefix ~ '-pg4' + - pg_4_create_check_mode.placement_group.tags.foo == "test1" + - pg_4_create_check_mode.placement_group.tags.bar == "test2" + + - name: Create a placement group 4 with tags + amazon.aws.ec2_placement_group: + name: "{{ resource_prefix }}-pg4" + state: present + strategy: cluster + tags: + foo: test1 + bar: test2 + register: pg_4_create + + - name: Assert that placement group exists + ansible.builtin.assert: + that: + - pg_4_create is changed + - pg_4_create.placement_group.name == resource_prefix ~ '-pg4' + - pg_4_create.placement_group.state == "available" + - pg_4_create.placement_group.tags.foo == "test1" + - pg_4_create.placement_group.tags.bar == "test2" + - '"ec2:CreatePlacementGroup" in pg_4_create.resource_actions' + + - ansible.builtin.set_fact: + placement_group_names: "{{ placement_group_names + [pg_4_create.placement_group.name] }}" + + - name: Gather information about placement group 4 + amazon.aws.ec2_placement_group_info: + names: + - "{{ resource_prefix }}-pg4" + register: pg_4_info_result + + - name: Assert that placement group exists + ansible.builtin.assert: + that: + - pg_4_info_result is not changed + - pg_4_info_result.placement_groups[0].name == resource_prefix ~ '-pg4' + - pg_4_info_result.placement_groups[0].state == "available" + - pg_4_info_result.placement_groups[0].strategy == "cluster" + - pg_4_info_result.placement_groups[0].tags.foo == "test1" + - pg_4_info_result.placement_groups[0].tags.bar == "test2" + - '"ec2:DescribePlacementGroups" in pg_4_info_result.resource_actions' + + - name: Create a placement group 4 with tags - Idempotency + amazon.aws.ec2_placement_group: + name: "{{ resource_prefix }}-pg4" + state: present + strategy: cluster + tags: + foo: test1 + bar: test2 + register: pg_4_create + + - name: Assert that placement group exists (idempotent) + ansible.builtin.assert: + that: + - pg_4_create is not changed + - pg_4_create.placement_group.name == resource_prefix ~ '-pg4' + - pg_4_create.placement_group.state == "available" + - pg_4_create.placement_group.strategy == "cluster" + - pg_4_create.placement_group.tags.foo == "test1" + - pg_4_create.placement_group.tags.bar == "test2" + - '"ec2:CreatePlacementGroup" not in pg_4_create.resource_actions' + + - name: Create a placement group 4 with tags - check_mode Idempotency + amazon.aws.ec2_placement_group: + name: "{{ resource_prefix }}-pg4" + state: present + strategy: cluster + tags: + foo: test1 + bar: test2 + check_mode: true + register: pg_4_create_check_mode_idem + + - name: Assert that placement group exists (idempotent - check-mode) + ansible.builtin.assert: + that: + - pg_4_create_check_mode_idem is not changed + - pg_4_create_check_mode_idem.placement_group.name == resource_prefix ~ '-pg4' + - pg_4_create_check_mode_idem.placement_group.state == "available" + - pg_4_create_check_mode_idem.placement_group.strategy == "cluster" + - pg_4_create_check_mode_idem.placement_group.tags.foo == "test1" + - pg_4_create_check_mode_idem.placement_group.tags.bar == "test2" + + - name: List all placement groups. + amazon.aws.ec2_placement_group_info: + register: all_ec2_placement_groups # Delete Placement Group ========================================== - - name: Delete a placement group 1 - check_mode - amazon.aws.ec2_placement_group: - name: '{{ resource_prefix }}-pg1' - state: absent - check_mode: true - register: pg_1_delete_check_mode - ignore_errors: true - - - name: Assert check mode (check mode) - ansible.builtin.assert: - that: - - pg_1_delete_check_mode is changed - - - name: Delete a placement group 1 - amazon.aws.ec2_placement_group: - name: '{{ resource_prefix }}-pg1' - state: absent - register: pg_1_delete - - - name: Assert that deletion is successful - ansible.builtin.assert: - that: - - pg_1_delete is changed - - '"ec2:DeletePlacementGroup" in pg_1_delete.resource_actions' - - - name: Delete a placement group 1 - Idempotency - amazon.aws.ec2_placement_group: - name: '{{ resource_prefix }}-pg1' - state: absent - register: pg_1_delete - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - pg_1_delete is not changed - - '"ec2:DeletePlacementGroup" not in pg_1_delete.resource_actions' - - - name: Delete a placement group 1 - check_mode Idempotency - amazon.aws.ec2_placement_group: - name: '{{ resource_prefix }}-pg1' - state: absent - check_mode: true - register: pg_1_delete_check_mode_idem - ignore_errors: true - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - pg_1_delete_check_mode_idem is not changed - - - name: Delete a placement group 2 - check_mode - amazon.aws.ec2_placement_group: - name: '{{ resource_prefix }}-pg2' - state: absent - check_mode: true - register: pg_2_delete_check_mode - ignore_errors: true - - - name: Assert that check mode is successful - ansible.builtin.assert: - that: - - pg_2_delete_check_mode is changed - - - name: Delete a placement group 2 - amazon.aws.ec2_placement_group: - name: '{{ resource_prefix }}-pg2' - state: absent - register: pg_2_delete - - - name: Assert that there is change - ansible.builtin.assert: - that: - - pg_2_delete is changed - - '"ec2:DeletePlacementGroup" in pg_2_delete.resource_actions' - - - name: Delete a placement group 2 - Idempotency - amazon.aws.ec2_placement_group: - name: '{{ resource_prefix }}-pg2' - state: absent - register: pg_2_delete - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - pg_2_delete is not changed - - '"ec2:DeletePlacementGroup" not in pg_2_delete.resource_actions' - - - name: Delete a placement group 2 - check_mode Idempotency - amazon.aws.ec2_placement_group: - name: '{{ resource_prefix }}-pg2' - state: absent - check_mode: true - register: pg_2_delete_check_mode_idem - ignore_errors: true - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - pg_2_delete_check_mode_idem is not changed - - - name: Delete a placement group 3 - check_mode - amazon.aws.ec2_placement_group: - name: '{{ resource_prefix }}-pg3' - state: absent - check_mode: true - register: pg_3_delete_check_mode - ignore_errors: true - - - name: Assert that there is change - check mode - ansible.builtin.assert: - that: - - pg_3_delete_check_mode is changed - - - name: Delete a placement group 3 - amazon.aws.ec2_placement_group: - name: '{{ resource_prefix }}-pg3' - state: absent - register: pg_3_delete - - - name: Assert that there is change - ansible.builtin.assert: - that: - - pg_3_delete is changed - - '"ec2:DeletePlacementGroup" in pg_3_delete.resource_actions' - - - name: Delete a placement group 3 - Idempotency - amazon.aws.ec2_placement_group: - name: '{{ resource_prefix }}-pg3' - state: absent - register: pg_3_delete - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - pg_3_delete is not changed - - '"ec2:DeletePlacementGroup" not in pg_3_delete.resource_actions' - - - name: Delete a placement group 3 - check_mode Idempotency - amazon.aws.ec2_placement_group: - name: '{{ resource_prefix }}-pg3' - state: absent - check_mode: true - register: pg_3_delete_check_mode_idem - ignore_errors: true - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - pg_3_delete_check_mode_idem is not changed - - - name: Delete a placement group 4 - check_mode - amazon.aws.ec2_placement_group: - name: '{{ resource_prefix }}-pg4' - state: absent - check_mode: true - register: pg_4_delete_check_mode - ignore_errors: true - - - name: Assert that there is change check mode - ansible.builtin.assert: - that: - - pg_4_delete_check_mode is changed - - - - name: Delete a placement group 4 - amazon.aws.ec2_placement_group: - name: '{{ resource_prefix }}-pg4' - state: absent - register: pg_4_delete - - - name: Assert that there is change - ansible.builtin.assert: - that: - - pg_4_delete is changed - - '"ec2:DeletePlacementGroup" in pg_4_delete.resource_actions' - - - name: Delete a placement group 4 - Idempotency - amazon.aws.ec2_placement_group: - name: '{{ resource_prefix }}-pg4' - state: absent - register: pg_4_delete - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - pg_4_delete is not changed - - '"ec2:DeletePlacementGroup" not in pg_4_delete.resource_actions' - - - name: Delete a placement group 4 - check_mode Idempotency - amazon.aws.ec2_placement_group: - name: '{{ resource_prefix }}-pg4' - state: absent - check_mode: true - register: pg_4_delete_check_mode_idem - ignore_errors: true - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - pg_4_delete_check_mode_idem is not changed + - name: Delete a placement group 1 - check_mode + amazon.aws.ec2_placement_group: + name: "{{ resource_prefix }}-pg1" + state: absent + check_mode: true + register: pg_1_delete_check_mode + ignore_errors: true + + - name: Assert check mode (check mode) + ansible.builtin.assert: + that: + - pg_1_delete_check_mode is changed + + - name: Delete a placement group 1 + amazon.aws.ec2_placement_group: + name: "{{ resource_prefix }}-pg1" + state: absent + register: pg_1_delete + + - name: Assert that deletion is successful + ansible.builtin.assert: + that: + - pg_1_delete is changed + - '"ec2:DeletePlacementGroup" in pg_1_delete.resource_actions' + + - name: Delete a placement group 1 - Idempotency + amazon.aws.ec2_placement_group: + name: "{{ resource_prefix }}-pg1" + state: absent + register: pg_1_delete + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - pg_1_delete is not changed + - '"ec2:DeletePlacementGroup" not in pg_1_delete.resource_actions' + + - name: Delete a placement group 1 - check_mode Idempotency + amazon.aws.ec2_placement_group: + name: "{{ resource_prefix }}-pg1" + state: absent + check_mode: true + register: pg_1_delete_check_mode_idem + ignore_errors: true + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - pg_1_delete_check_mode_idem is not changed + + - name: Delete a placement group 2 - check_mode + amazon.aws.ec2_placement_group: + name: "{{ resource_prefix }}-pg2" + state: absent + check_mode: true + register: pg_2_delete_check_mode + ignore_errors: true + + - name: Assert that check mode is successful + ansible.builtin.assert: + that: + - pg_2_delete_check_mode is changed + + - name: Delete a placement group 2 + amazon.aws.ec2_placement_group: + name: "{{ resource_prefix }}-pg2" + state: absent + register: pg_2_delete + + - name: Assert that there is change + ansible.builtin.assert: + that: + - pg_2_delete is changed + - '"ec2:DeletePlacementGroup" in pg_2_delete.resource_actions' + + - name: Delete a placement group 2 - Idempotency + amazon.aws.ec2_placement_group: + name: "{{ resource_prefix }}-pg2" + state: absent + register: pg_2_delete + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - pg_2_delete is not changed + - '"ec2:DeletePlacementGroup" not in pg_2_delete.resource_actions' + + - name: Delete a placement group 2 - check_mode Idempotency + amazon.aws.ec2_placement_group: + name: "{{ resource_prefix }}-pg2" + state: absent + check_mode: true + register: pg_2_delete_check_mode_idem + ignore_errors: true + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - pg_2_delete_check_mode_idem is not changed + + - name: Delete a placement group 3 - check_mode + amazon.aws.ec2_placement_group: + name: "{{ resource_prefix }}-pg3" + state: absent + check_mode: true + register: pg_3_delete_check_mode + ignore_errors: true + + - name: Assert that there is change - check mode + ansible.builtin.assert: + that: + - pg_3_delete_check_mode is changed + + - name: Delete a placement group 3 + amazon.aws.ec2_placement_group: + name: "{{ resource_prefix }}-pg3" + state: absent + register: pg_3_delete + + - name: Assert that there is change + ansible.builtin.assert: + that: + - pg_3_delete is changed + - '"ec2:DeletePlacementGroup" in pg_3_delete.resource_actions' + + - name: Delete a placement group 3 - Idempotency + amazon.aws.ec2_placement_group: + name: "{{ resource_prefix }}-pg3" + state: absent + register: pg_3_delete + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - pg_3_delete is not changed + - '"ec2:DeletePlacementGroup" not in pg_3_delete.resource_actions' + + - name: Delete a placement group 3 - check_mode Idempotency + amazon.aws.ec2_placement_group: + name: "{{ resource_prefix }}-pg3" + state: absent + check_mode: true + register: pg_3_delete_check_mode_idem + ignore_errors: true + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - pg_3_delete_check_mode_idem is not changed + + - name: Delete a placement group 4 - check_mode + amazon.aws.ec2_placement_group: + name: "{{ resource_prefix }}-pg4" + state: absent + check_mode: true + register: pg_4_delete_check_mode + ignore_errors: true + + - name: Assert that there is change check mode + ansible.builtin.assert: + that: + - pg_4_delete_check_mode is changed + + - name: Delete a placement group 4 + amazon.aws.ec2_placement_group: + name: "{{ resource_prefix }}-pg4" + state: absent + register: pg_4_delete + + - name: Assert that there is change + ansible.builtin.assert: + that: + - pg_4_delete is changed + - '"ec2:DeletePlacementGroup" in pg_4_delete.resource_actions' + + - name: Delete a placement group 4 - Idempotency + amazon.aws.ec2_placement_group: + name: "{{ resource_prefix }}-pg4" + state: absent + register: pg_4_delete + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - pg_4_delete is not changed + - '"ec2:DeletePlacementGroup" not in pg_4_delete.resource_actions' + + - name: Delete a placement group 4 - check_mode Idempotency + amazon.aws.ec2_placement_group: + name: "{{ resource_prefix }}-pg4" + state: absent + check_mode: true + register: pg_4_delete_check_mode_idem + ignore_errors: true + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - pg_4_delete_check_mode_idem is not changed always: + - name: Make sure placement groups created during test are deleted + amazon.aws.ec2_placement_group: + name: "{{ item }}" + state: absent + with_items: "{{ placement_group_names }}" - - name: Make sure placement groups created during test are deleted - amazon.aws.ec2_placement_group: - name: '{{ item }}' - state: absent - with_items: '{{ placement_group_names }}' - - - include_tasks: env_cleanup.yml + - ansible.builtin.include_tasks: env_cleanup.yml diff --git a/tests/integration/targets/ec2_security_group/defaults/main.yml b/tests/integration/targets/ec2_security_group/defaults/main.yml index 72afe4f8e30..842e4ae91fa 100644 --- a/tests/integration/targets/ec2_security_group/defaults/main.yml +++ b/tests/integration/targets/ec2_security_group/defaults/main.yml @@ -1,6 +1,6 @@ --- # defaults file for test_ec2_group -ec2_group_name: "{{resource_prefix}}" +ec2_group_name: "{{ resource_prefix }}" ec2_group_description: Created by ansible integration tests vpc_cidr: 10.{{ 256 | random(seed=resource_prefix) }}.0.0/16 diff --git a/tests/integration/targets/ec2_security_group/tasks/data_validation.yml b/tests/integration/targets/ec2_security_group/tasks/data_validation.yml index 7cd9f3fb468..43d56355ef9 100644 --- a/tests/integration/targets/ec2_security_group/tasks/data_validation.yml +++ b/tests/integration/targets/ec2_security_group/tasks/data_validation.yml @@ -2,14 +2,14 @@ - block: - name: Create a group with only the default rule amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}-input-tests" + name: "{{ ec2_group_name }}-input-tests" vpc_id: "{{ vpc_result.vpc.id }}" - description: "{{ec2_group_description}}" + description: "{{ ec2_group_description }}" - name: Run through some common weird port specs amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}-input-tests" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}-input-tests" + description: "{{ ec2_group_description }}" rules: - "{{ item }}" with_items: @@ -25,9 +25,9 @@ - 9002-9005 cidr_ip: 10.2.3.0/24 always: - - name: tidy up input testing group + - name: Tidy up input testing group amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}-input-tests" + name: "{{ ec2_group_name }}-input-tests" vpc_id: "{{ vpc_result.vpc.id }}" state: absent ignore_errors: true diff --git a/tests/integration/targets/ec2_security_group/tasks/diff_mode.yml b/tests/integration/targets/ec2_security_group/tasks/diff_mode.yml index 134cb823991..8897b404136 100644 --- a/tests/integration/targets/ec2_security_group/tasks/diff_mode.yml +++ b/tests/integration/targets/ec2_security_group/tasks/diff_mode.yml @@ -1,7 +1,7 @@ --- # ============================================================ -- name: create a group with a rule (CHECK MODE + DIFF) +- name: Create a group with a rule (CHECK MODE + DIFF) amazon.aws.ec2_security_group: name: "{{ ec2_group_name }}" description: "{{ ec2_group_description }}" @@ -22,7 +22,7 @@ that: - check_mode_result.changed -- name: create a group with a rule (DIFF) +- name: Create a group with a rule (DIFF) amazon.aws.ec2_security_group: name: "{{ ec2_group_name }}" description: "{{ ec2_group_description }}" @@ -44,7 +44,7 @@ - result.diff.0.after.ip_permissions == check_mode_result.diff.0.after.ip_permissions - result.diff.0.after.ip_permissions_egress == check_mode_result.diff.0.after.ip_permissions_egress -- name: add rules to make sorting occur (CHECK MODE + DIFF) +- name: Add rules to make sorting occur (CHECK MODE + DIFF) amazon.aws.ec2_security_group: name: "{{ ec2_group_name }}" description: "{{ ec2_group_description }}" @@ -73,7 +73,7 @@ that: - check_mode_result.changed -- name: add rules in a different order to test sorting consistency (DIFF) +- name: Add rules in a different order to test sorting consistency (DIFF) amazon.aws.ec2_security_group: name: "{{ ec2_group_name }}" description: "{{ ec2_group_description }}" @@ -103,7 +103,7 @@ - result.diff.0.after.ip_permissions == check_mode_result.diff.0.after.ip_permissions - result.diff.0.after.ip_permissions_egress == check_mode_result.diff.0.after.ip_permissions_egress -- name: purge rules (CHECK MODE + DIFF) +- name: Purge rules (CHECK MODE + DIFF) amazon.aws.ec2_security_group: name: "{{ ec2_group_name }}" description: "{{ ec2_group_description }}" @@ -122,7 +122,7 @@ that: - check_mode_result.changed -- name: purge rules (DIFF) +- name: Purge rules (DIFF) amazon.aws.ec2_security_group: name: "{{ ec2_group_name }}" description: "{{ ec2_group_description }}" @@ -142,7 +142,7 @@ - result.diff.0.after.ip_permissions == check_mode_result.diff.0.after.ip_permissions - result.diff.0.after.ip_permissions_egress == check_mode_result.diff.0.after.ip_permissions_egress -- name: delete the security group (CHECK MODE + DIFF) +- name: Delete the security group (CHECK MODE + DIFF) amazon.aws.ec2_security_group: name: "{{ ec2_group_name }}" state: absent @@ -154,7 +154,7 @@ that: - check_mode_result.changed -- name: delete the security group (DIFF) +- name: Delete the security group (DIFF) amazon.aws.ec2_security_group: name: "{{ ec2_group_name }}" state: absent diff --git a/tests/integration/targets/ec2_security_group/tasks/egress_tests.yml b/tests/integration/targets/ec2_security_group/tasks/egress_tests.yml index cdc42fbb5b7..6cdc0f4798f 100644 --- a/tests/integration/targets/ec2_security_group/tasks/egress_tests.yml +++ b/tests/integration/targets/ec2_security_group/tasks/egress_tests.yml @@ -2,13 +2,13 @@ - block: - name: Create a group with only the default rule amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}-egress-tests" + name: "{{ ec2_group_name }}-egress-tests" vpc_id: "{{ vpc_result.vpc.id }}" - description: "{{ec2_group_description}}" + description: "{{ ec2_group_description }}" state: present register: result - - name: assert default rule is in place (expected changed=true) + - name: Assert default rule is in place (expected changed=true) ansible.builtin.assert: that: - result is changed @@ -18,14 +18,14 @@ - name: Create a group with only the default rule amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}-egress-tests" + name: "{{ ec2_group_name }}-egress-tests" vpc_id: "{{ vpc_result.vpc.id }}" - description: "{{ec2_group_description}}" + description: "{{ ec2_group_description }}" purge_rules_egress: false state: present register: result - - name: assert default rule is not purged (expected changed=false) + - name: Assert default rule is not purged (expected changed=false) ansible.builtin.assert: that: - result is not changed @@ -35,15 +35,15 @@ - name: Pass empty egress rules without purging, should leave default rule in place amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}-egress-tests" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}-egress-tests" + description: "{{ ec2_group_description }}" vpc_id: "{{ vpc_result.vpc.id }}" purge_rules_egress: false rules_egress: [] state: present register: result - - name: assert default rule is not purged (expected changed=false) + - name: Assert default rule is not purged (expected changed=false) ansible.builtin.assert: that: - result is not changed @@ -53,15 +53,15 @@ - name: Purge rules, including the default amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}-egress-tests" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}-egress-tests" + description: "{{ ec2_group_description }}" vpc_id: "{{ vpc_result.vpc.id }}" purge_rules_egress: true rules_egress: [] state: present register: result - - name: assert default rule is not purged (expected changed=false) + - name: Assert default rule is not purged (expected changed=false) ansible.builtin.assert: that: - result is changed @@ -70,8 +70,8 @@ - name: Add a custom egress rule amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}-egress-tests" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}-egress-tests" + description: "{{ ec2_group_description }}" vpc_id: "{{ vpc_result.vpc.id }}" rules_egress: - proto: tcp @@ -81,15 +81,15 @@ state: present register: result - - name: assert first rule is here + - name: Assert first rule is here ansible.builtin.assert: that: - result.ip_permissions_egress|length == 1 - name: Add a second custom egress rule amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}-egress-tests" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}-egress-tests" + description: "{{ ec2_group_description }}" purge_rules_egress: false vpc_id: "{{ vpc_result.vpc.id }}" rules_egress: @@ -100,15 +100,15 @@ state: present register: result - - name: assert the first rule is not purged + - name: Assert the first rule is not purged ansible.builtin.assert: that: - result.ip_permissions_egress|length == 2 - name: Purge the second rule (CHECK MODE) (DIFF MODE) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}-egress-tests" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}-egress-tests" + description: "{{ ec2_group_description }}" vpc_id: "{{ vpc_result.vpc.id }}" rules_egress: - proto: tcp @@ -120,7 +120,7 @@ check_mode: true diff: true - - name: assert first rule will be left + - name: Assert first rule will be left ansible.builtin.assert: that: - result.changed @@ -129,8 +129,8 @@ - name: Purge the second rule amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}-egress-tests" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}-egress-tests" + description: "{{ ec2_group_description }}" vpc_id: "{{ vpc_result.vpc.id }}" rules_egress: - proto: tcp @@ -140,16 +140,16 @@ state: present register: result - - name: assert first rule is here + - name: Assert first rule is here ansible.builtin.assert: that: - result.ip_permissions_egress|length == 1 - result.ip_permissions_egress[0].ip_ranges[0].cidr_ip == '10.2.1.2/32' - - name: add a rule for all TCP ports + - name: Add a rule for all TCP ports amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}-egress-tests" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}-egress-tests" + description: "{{ ec2_group_description }}" rules_egress: - proto: tcp ports: "0-65535" @@ -160,8 +160,8 @@ - name: Re-add the default rule amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}-egress-tests" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}-egress-tests" + description: "{{ ec2_group_description }}" rules_egress: - proto: -1 cidr_ip: "0.0.0.0/0" @@ -169,9 +169,9 @@ vpc_id: "{{ vpc_result.vpc.id }}" register: result always: - - name: tidy up egress rule test security group + - name: Tidy up egress rule test security group amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}-egress-tests" + name: "{{ ec2_group_name }}-egress-tests" state: absent vpc_id: "{{ vpc_result.vpc.id }}" ignore_errors: true 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 4355a4f6365..339c3f51720 100644 --- a/tests/integration/targets/ec2_security_group/tasks/group_info.yml +++ b/tests/integration/targets/ec2_security_group/tasks/group_info.yml @@ -91,13 +91,13 @@ always: # ========================= Cleanup ================================= - - name: tidy up test security group 1 + - name: Tidy up test security group 1 amazon.aws.ec2_security_group: name: "{{ ec2_group_name }}-info-1" state: absent ignore_errors: true - - name: tidy up test security group 2 + - name: Tidy up test security group 2 amazon.aws.ec2_security_group: name: "{{ ec2_group_name }}-info-2" state: absent diff --git a/tests/integration/targets/ec2_security_group/tasks/icmp_verbs.yml b/tests/integration/targets/ec2_security_group/tasks/icmp_verbs.yml index b827f10a5ee..d823218ea0a 100644 --- a/tests/integration/targets/ec2_security_group/tasks/icmp_verbs.yml +++ b/tests/integration/targets/ec2_security_group/tasks/icmp_verbs.yml @@ -3,9 +3,9 @@ # ============================================================ - name: Create simple rule using icmp verbs amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}-icmp-1" + name: "{{ ec2_group_name }}-icmp-1" vpc_id: "{{ vpc_result.vpc.id }}" - description: "{{ec2_group_description}}" + description: "{{ ec2_group_description }}" rules: - proto: icmp icmp_type: 3 @@ -31,9 +31,9 @@ - name: Create ipv6 rule using icmp verbs amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}-icmp-2" + name: "{{ ec2_group_name }}-icmp-2" vpc_id: "{{ vpc_result.vpc.id }}" - description: "{{ec2_group_description}}" + description: "{{ ec2_group_description }}" rules: - proto: icmpv6 icmp_type: 1 @@ -57,14 +57,14 @@ - name: Create rule using security group referencing amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}-icmp-3" + name: "{{ ec2_group_name }}-icmp-3" vpc_id: "{{ vpc_result.vpc.id }}" - description: "{{ec2_group_description}}" + description: "{{ ec2_group_description }}" rules: - proto: icmp icmp_type: 5 icmp_code: 1 - group_name: "{{ec2_group_name}}-auto-create-2" + group_name: "{{ ec2_group_name }}-auto-create-2" group_desc: sg-group-referencing state: present register: result @@ -82,9 +82,9 @@ - name: Create list rule using 0 as icmp_type amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}-icmp-4" + name: "{{ ec2_group_name }}-icmp-4" vpc_id: "{{ vpc_result.vpc.id }}" - description: "{{ec2_group_description}}" + description: "{{ ec2_group_description }}" rules: - proto: icmp icmp_type: 0 @@ -114,9 +114,9 @@ # ============================================================ - name: Create a group with non-ICMP protocol amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}-icmp-4" + name: "{{ ec2_group_name }}-icmp-4" vpc_id: "{{ vpc_result.vpc.id }}" - description: "{{ec2_group_description}}" + description: "{{ ec2_group_description }}" rules: - proto: tcp icmp_type: 0 @@ -128,16 +128,16 @@ register: result ignore_errors: true - - name: assert that group creation fails when proto != icmp with icmp parameters + - name: Assert that group creation fails when proto != icmp with icmp parameters ansible.builtin.assert: that: - result is failed - name: Create a group with conflicting parameters amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}-icmp-4" + name: "{{ ec2_group_name }}-icmp-4" vpc_id: "{{ vpc_result.vpc.id }}" - description: "{{ec2_group_description}}" + description: "{{ ec2_group_description }}" rules: - proto: icmp from_port: 5 @@ -151,16 +151,16 @@ register: result ignore_errors: true - - name: assert that group creation fails when using conflicting parameters + - name: Assert that group creation fails when using conflicting parameters ansible.builtin.assert: that: - result is failed - name: Create a group with missing icmp parameters amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}-icmp-4" + name: "{{ ec2_group_name }}-icmp-4" vpc_id: "{{ vpc_result.vpc.id }}" - description: "{{ec2_group_description}}" + description: "{{ ec2_group_description }}" rules: - proto: tcp icmp_type: 0 @@ -171,25 +171,25 @@ register: result ignore_errors: true - - name: assert that group creation fails when missing icmp parameters + - name: Assert that group creation fails when missing icmp parameters ansible.builtin.assert: that: - result is failed always: - - name: tidy up egress rule test security group rules + - name: Tidy up egress rule test security group rules amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}-auto-create-2" + name: "{{ ec2_group_name }}-auto-create-2" description: sg-group-referencing vpc_id: "{{ vpc_result.vpc.id }}" rules: [] rules_egress: [] ignore_errors: true - - name: tidy up egress rule test security group rules + - name: Tidy up egress rule test security group rules amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}-icmp-{{ item }}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}-icmp-{{ item }}" + description: "{{ ec2_group_description }}" vpc_id: "{{ vpc_result.vpc.id }}" rules: [] rules_egress: [] @@ -200,16 +200,16 @@ - 3 - 4 - - name: tidy up egress rule test security group rules + - name: Tidy up egress rule test security group rules amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}-auto-create-2" + name: "{{ ec2_group_name }}-auto-create-2" state: absent vpc_id: "{{ vpc_result.vpc.id }}" ignore_errors: true - - name: tidy up egress rule test security group + - name: Tidy up egress rule test security group amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}-icmp-{{ item }}" + name: "{{ ec2_group_name }}-icmp-{{ item }}" state: absent vpc_id: "{{ vpc_result.vpc.id }}" ignore_errors: true diff --git a/tests/integration/targets/ec2_security_group/tasks/ipv6_default_tests.yml b/tests/integration/targets/ec2_security_group/tasks/ipv6_default_tests.yml index a1a46119c29..95251187076 100644 --- a/tests/integration/targets/ec2_security_group/tasks/ipv6_default_tests.yml +++ b/tests/integration/targets/ec2_security_group/tasks/ipv6_default_tests.yml @@ -1,9 +1,9 @@ --- # ============================================================ -- name: test state=present for ipv6 (expected changed=true) (CHECK MODE) +- name: Test state=present for ipv6 (expected changed=true) (CHECK MODE) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}" state: present rules: - proto: tcp @@ -13,16 +13,16 @@ check_mode: true register: result -- name: assert state=present (expected changed=true) +- name: Assert state=present (expected changed=true) ansible.builtin.assert: that: - result.changed # ============================================================ -- name: test state=present for ipv6 (expected changed=true) +- name: Test state=present for ipv6 (expected changed=true) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}" state: present rules: - proto: tcp @@ -31,17 +31,17 @@ cidr_ipv6: 64:ff9b::/96 register: result -- name: assert state=present (expected changed=true) +- name: Assert state=present (expected changed=true) ansible.builtin.assert: that: - result.changed - result.group_id.startswith("sg-") # ============================================================ -- name: test rules_egress state=present for ipv6 (expected changed=true) (CHECK MODE) +- name: Test rules_egress state=present for ipv6 (expected changed=true) (CHECK MODE) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}" state: present rules: - proto: tcp @@ -56,16 +56,16 @@ check_mode: true register: result -- name: assert state=present (expected changed=true) +- name: Assert state=present (expected changed=true) ansible.builtin.assert: that: - result.changed # ============================================================ -- name: test rules_egress state=present for ipv6 (expected changed=true) +- name: Test rules_egress state=present for ipv6 (expected changed=true) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}" state: present rules: - proto: tcp @@ -79,12 +79,12 @@ cidr_ipv6: 64:ff9b::/96 register: result -- name: assert state=present (expected changed=true) +- name: Assert state=present (expected changed=true) ansible.builtin.assert: that: - result.changed - result.group_id.startswith("sg-") -- name: delete it +- name: Delete it amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" + name: "{{ ec2_group_name }}" state: absent diff --git a/tests/integration/targets/ec2_security_group/tasks/main.yml b/tests/integration/targets/ec2_security_group/tasks/main.yml index e551f19a65e..949c55992f7 100644 --- a/tests/integration/targets/ec2_security_group/tasks/main.yml +++ b/tests/integration/targets/ec2_security_group/tasks/main.yml @@ -14,15 +14,15 @@ group/aws: access_key: "{{ aws_access_key }}" secret_key: "{{ aws_secret_key }}" - session_token: "{{ security_token | default(omit)}}" + session_token: "{{ security_token | default(omit) }}" region: "{{ aws_region }}" block: - - name: determine if there is a default VPC + - name: Determine if there is a default VPC ansible.builtin.set_fact: defaultvpc: "{{ lookup('amazon.aws.aws_account_attribute', attribute='default-vpc', **connection_args) }}" register: default_vpc - - name: create a VPC + - name: Create a VPC amazon.aws.ec2_vpc_net: name: "{{ resource_prefix }}-vpc" state: present @@ -31,8 +31,8 @@ Name: "{{ resource_prefix }}-vpc" Description: Created by ansible-test register: vpc_result - #TODO(ryansb): Update CI for VPC peering permissions - #- include_tasks: ./multi_account.yml + ## TODO(ryansb): Update CI for VPC peering permissions + # - include_tasks: ./multi_account.yml - ansible.builtin.include_tasks: ./diff_mode.yml - ansible.builtin.include_tasks: ./numeric_protos.yml - ansible.builtin.include_tasks: ./rule_group_create.yml @@ -41,107 +41,107 @@ - ansible.builtin.include_tasks: ./data_validation.yml - ansible.builtin.include_tasks: ./multi_nested_target.yml - ansible.builtin.include_tasks: ./group_info.yml - - name: test state=absent (CHECK MODE) + - name: Test state=absent (CHECK MODE) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}" state: absent check_mode: true register: result - - name: assert no changes would be made + - name: Assert no changes would be made ansible.builtin.assert: that: - not result.changed # =========================================================== - - name: test state=absent + - name: Test state=absent amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}" state: absent register: result # ============================================================ - - name: test state=present (expected changed=true) (CHECK MODE) + - name: Test state=present (expected changed=true) (CHECK MODE) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}" state: present check_mode: true register: result - - name: assert state=present (expected changed=true) + - name: Assert state=present (expected changed=true) ansible.builtin.assert: that: - result.changed # ============================================================ - - name: test state=present (expected changed=true) + - name: Test state=present (expected changed=true) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}" state: present register: result - - name: assert state=present (expected changed=true) + - name: Assert state=present (expected changed=true) ansible.builtin.assert: that: - result.changed - result.group_id.startswith("sg-") # ============================================================ - - name: test state=present different description (expected changed=false) (CHECK MODE) + - name: Test state=present different description (expected changed=false) (CHECK MODE) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}CHANGED" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}CHANGED" state: present check_mode: true register: result - - name: assert state=present (expected changed=false) + - name: Assert state=present (expected changed=false) ansible.builtin.assert: that: - not result.changed # ============================================================ - - name: test state=present different description (expected changed=false) + - name: Test state=present different description (expected changed=false) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}CHANGED" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}CHANGED" state: present ignore_errors: true register: result - - name: assert state=present (expected changed=false) + - name: Assert state=present (expected changed=false) ansible.builtin.assert: that: - not result.changed - result.group_id.startswith("sg-") # ============================================================ - - name: test state=present (expected changed=false) + - name: Test state=present (expected changed=false) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}" state: present register: result - - name: assert state=present (expected changed=false) + - name: Assert state=present (expected changed=false) ansible.builtin.assert: that: - not result.changed - result.group_id.startswith("sg-") # ============================================================ - - name: tests IPv6 with the default VPC + - name: Tests IPv6 with the default VPC ansible.builtin.include_tasks: ./ipv6_default_tests.yml when: default_vpc - - name: test IPv6 with a specified VPC + - name: Test IPv6 with a specified VPC block: # ============================================================ - - name: test state=present (expected changed=true) (CHECK MODE) + - name: Test state=present (expected changed=true) (CHECK MODE) amazon.aws.ec2_security_group: name: "{{ ec2_group_name }}-2" description: "{{ ec2_group_description }}-2" @@ -150,13 +150,13 @@ check_mode: true register: result - - name: assert state=present (expected changed=true) + - name: Assert state=present (expected changed=true) ansible.builtin.assert: that: - result.changed # ============================================================ - - name: test state=present (expected changed=true) + - name: Test state=present (expected changed=true) amazon.aws.ec2_security_group: name: "{{ ec2_group_name }}-2" description: "{{ ec2_group_description }}-2" @@ -164,14 +164,14 @@ vpc_id: "{{ vpc_result.vpc.id }}" register: result - - name: assert state=present (expected changed=true) + - name: Assert state=present (expected changed=true) ansible.builtin.assert: that: - result.changed - result.group_id.startswith("sg-") # ============================================================ - - name: test state=present for ipv6 (expected changed=true) (CHECK MODE) + - name: Test state=present for ipv6 (expected changed=true) (CHECK MODE) amazon.aws.ec2_security_group: name: "{{ ec2_group_name }}-2" description: "{{ ec2_group_description }}-2" @@ -185,13 +185,13 @@ check_mode: true register: result - - name: assert state=present (expected changed=true) + - name: Assert state=present (expected changed=true) ansible.builtin.assert: that: - result.changed # ============================================================ - - name: test state=present for ipv6 (expected changed=true) + - name: Test state=present for ipv6 (expected changed=true) amazon.aws.ec2_security_group: name: "{{ ec2_group_name }}-2" description: "{{ ec2_group_description }}-2" @@ -204,14 +204,14 @@ cidr_ipv6: 64:ff9b::/96 register: result - - name: assert state=present (expected changed=true) + - name: Assert state=present (expected changed=true) ansible.builtin.assert: that: - result.changed - result.group_id.startswith("sg-") # ============================================================ - - name: test state=present for ipv6 (expected changed=false) (CHECK MODE) + - name: Test state=present for ipv6 (expected changed=false) (CHECK MODE) amazon.aws.ec2_security_group: name: "{{ ec2_group_name }}-2" description: "{{ ec2_group_description }}-2" @@ -225,13 +225,13 @@ check_mode: true register: result - - name: assert nothing changed + - name: Assert nothing changed ansible.builtin.assert: that: - not result.changed # ============================================================ - - name: test state=present for ipv6 (expected changed=false) + - name: Test state=present for ipv6 (expected changed=false) amazon.aws.ec2_security_group: name: "{{ ec2_group_name }}-2" description: "{{ ec2_group_description }}-2" @@ -244,13 +244,13 @@ cidr_ipv6: 64:ff9b::/96 register: result - - name: assert nothing changed + - name: Assert nothing changed ansible.builtin.assert: that: - not result.changed # ============================================================ - - name: test rules_egress state=present for ipv6 (expected changed=true) (CHECK MODE) + - name: Test rules_egress state=present for ipv6 (expected changed=true) (CHECK MODE) amazon.aws.ec2_security_group: name: "{{ ec2_group_name }}-2" description: "{{ ec2_group_description }}-2" @@ -270,7 +270,7 @@ diff: true register: result - - name: assert state=present (expected changed=true) + - name: Assert state=present (expected changed=true) ansible.builtin.assert: that: - result.changed @@ -278,7 +278,7 @@ - result.diff.0.before.ip_permissions_egress != result.diff.0.after.ip_permissions_egress # ============================================================ - - name: test rules_egress state=present for ipv6 (expected changed=true) + - name: Test rules_egress state=present for ipv6 (expected changed=true) amazon.aws.ec2_security_group: name: "{{ ec2_group_name }}-2" description: "{{ ec2_group_description }}-2" @@ -296,14 +296,14 @@ cidr_ipv6: 64:ff9b::/96 register: result - - name: assert state=present (expected changed=true) + - name: Assert state=present (expected changed=true) ansible.builtin.assert: that: - result.changed - result.group_id.startswith("sg-") # ============================================================ - - name: test state=absent (expected changed=true) (CHECK MODE) + - name: Test state=absent (expected changed=true) (CHECK MODE) amazon.aws.ec2_security_group: name: "{{ ec2_group_name }}-2" description: "{{ ec2_group_description }}-2" @@ -313,14 +313,14 @@ diff: true register: result - - name: assert group was removed + - name: Assert group was removed ansible.builtin.assert: that: - result.changed - not result.diff.0.after # ============================================================ - - name: test state=absent (expected changed=true) + - name: Test state=absent (expected changed=true) amazon.aws.ec2_security_group: name: "{{ ec2_group_name }}-2" description: "{{ ec2_group_description }}-2" @@ -328,16 +328,16 @@ vpc_id: "{{ vpc_result.vpc.id }}" register: result - - name: assert group was removed + - name: Assert group was removed ansible.builtin.assert: that: - result.changed # ============================================================ - - name: test state=present for ipv4 (expected changed=true) (CHECK MODE) + - name: Test state=present for ipv4 (expected changed=true) (CHECK MODE) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}" rules: - proto: tcp from_port: 8182 @@ -346,16 +346,16 @@ check_mode: true register: result - - name: assert state=present (expected changed=true) + - name: Assert state=present (expected changed=true) ansible.builtin.assert: that: - result.changed # ============================================================ - - name: test state=present for ipv4 (expected changed=true) + - name: Test state=present for ipv4 (expected changed=true) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}" rules: - proto: tcp from_port: 8182 @@ -363,7 +363,7 @@ cidr_ip: 10.1.1.1/32 register: result - - name: assert state=present (expected changed=true) + - name: Assert state=present (expected changed=true) ansible.builtin.assert: that: - result.changed @@ -372,10 +372,10 @@ - result.ip_permissions_egress|length == 1 # ============================================================ - - name: add same rule to the existing group (expected changed=false) (CHECK MODE) + - name: Add same rule to the existing group (expected changed=false) (CHECK MODE) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}" state: present rules: - proto: tcp @@ -392,10 +392,10 @@ - check_result.diff.0.before.ip_permissions.0 == check_result.diff.0.after.ip_permissions.0 # ============================================================ - - name: add same rule to the existing group (expected changed=false) + - name: Add same rule to the existing group (expected changed=false) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}" state: present rules: - proto: tcp @@ -404,22 +404,22 @@ cidr_ip: 10.1.1.1/32 register: result - - name: assert state=present (expected changed=false) + - name: Assert state=present (expected changed=false) ansible.builtin.assert: that: - not result.changed - result.group_id.startswith("sg-") - - name: assert state=present (expected changed=false) + - name: Assert state=present (expected changed=false) ansible.builtin.assert: that: - not check_result.changed # ============================================================ - - name: add a rule that auto creates another security group (CHECK MODE) + - name: Add a rule that auto creates another security group (CHECK MODE) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}" state: present purge_rules: false rules: @@ -430,16 +430,16 @@ check_mode: true register: result - - name: check that there are now two rules + - name: Check that there are now two rules ansible.builtin.assert: that: - result.changed # ============================================================ - - name: add a rule that auto creates another security group + - name: Add a rule that auto creates another security group amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}" state: present purge_rules: false rules: @@ -449,7 +449,7 @@ ports: 7171 register: result - - name: check that there are now two rules + - name: Check that there are now two rules ansible.builtin.assert: that: - result.changed @@ -459,10 +459,10 @@ - result.ip_permissions_egress[0].ip_protocol == "-1" # ============================================================ - - name: test ip rules convert port numbers from string to int (expected changed=true) (CHECK MODE) + - name: Test ip rules convert port numbers from string to int (expected changed=true) (CHECK MODE) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}" state: present rules: - proto: tcp @@ -477,16 +477,16 @@ check_mode: true register: result - - name: assert state=present (expected changed=true) + - name: Assert state=present (expected changed=true) ansible.builtin.assert: that: - result.changed # ============================================================ - - name: test ip rules convert port numbers from string to int (expected changed=true) + - name: Test ip rules convert port numbers from string to int (expected changed=true) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}" state: present rules: - proto: tcp @@ -500,7 +500,7 @@ cidr_ip: 10.1.1.1/32 register: result - - name: assert state=present (expected changed=true) + - name: Assert state=present (expected changed=true) ansible.builtin.assert: that: - result.changed @@ -509,48 +509,48 @@ - result.ip_permissions_egress[0].ip_protocol == "tcp" # ============================================================ - - name: test group rules convert port numbers from string to int (expected changed=true) (CHECK MODE) + - name: Test group rules convert port numbers from string to int (expected changed=true) (CHECK MODE) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}" state: present rules: - proto: tcp from_port: "8185" to_port: "8185" - group_id: "{{result.group_id}}" + group_id: "{{ result.group_id }}" rules_egress: - proto: tcp from_port: "8186" to_port: "8186" - group_id: "{{result.group_id}}" + group_id: "{{ result.group_id }}" check_mode: true register: result - - name: assert state=present (expected changed=true) + - name: Assert state=present (expected changed=true) ansible.builtin.assert: that: - result.changed # ============================================================ - - name: test group rules convert port numbers from string to int (expected changed=true) + - name: Test group rules convert port numbers from string to int (expected changed=true) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}" state: present rules: - proto: tcp from_port: "8185" to_port: "8185" - group_id: "{{result.group_id}}" + group_id: "{{ result.group_id }}" rules_egress: - proto: tcp from_port: "8186" to_port: "8186" - group_id: "{{result.group_id}}" + group_id: "{{ result.group_id }}" register: result - - name: assert state=present (expected changed=true) + - name: Assert state=present (expected changed=true) ansible.builtin.assert: that: - result.changed @@ -558,10 +558,10 @@ - result.warning is not defined # ============================================================ - - name: test adding a range of ports and ports given as strings (expected changed=true) (CHECK MODE) + - name: Test adding a range of ports and ports given as strings (expected changed=true) (CHECK MODE) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}" state: present # set purge_rules to false so we don't get a false positive from previously added rules purge_rules: false @@ -574,16 +574,16 @@ check_mode: true register: result - - name: assert state=present (expected changed=true) + - name: Assert state=present (expected changed=true) ansible.builtin.assert: that: - result.changed # ============================================================ - - name: test adding a range of ports and ports given as strings (expected changed=true) + - name: Test adding a range of ports and ports given as strings (expected changed=true) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}" state: present # set purge_rules to false so we don't get a false positive from previously added rules purge_rules: false @@ -595,17 +595,17 @@ cidr_ip: 10.1.1.1/32 register: result - - name: assert state=present (expected changed=true) + - name: Assert state=present (expected changed=true) ansible.builtin.assert: that: - result.changed - result.group_id.startswith("sg-") # ============================================================ - - name: test adding a rule with a IPv4 CIDR with host bits set (expected changed=true) (CHECK MODE) + - name: Test adding a rule with a IPv4 CIDR with host bits set (expected changed=true) (CHECK MODE) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}" state: present # set purge_rules to false so we don't get a false positive from previously added rules purge_rules: false @@ -617,16 +617,16 @@ check_mode: true register: result - - name: assert state=present (expected changed=true) + - name: Assert state=present (expected changed=true) ansible.builtin.assert: that: - result.changed # ============================================================ - - name: test adding a rule with a IPv4 CIDR with host bits set (expected changed=true) + - name: Test adding a rule with a IPv4 CIDR with host bits set (expected changed=true) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}" state: present # set purge_rules to false so we don't get a false positive from previously added rules purge_rules: false @@ -637,17 +637,17 @@ cidr_ip: 10.0.0.1/8 register: result - - name: assert state=present (expected changed=true) + - name: Assert state=present (expected changed=true) ansible.builtin.assert: that: - result.changed - result.group_id.startswith("sg-") # ============================================================ - - name: test adding the same rule with a IPv4 CIDR with host bits set (expected changed=false) (CHECK MODE) + - name: Test adding the same rule with a IPv4 CIDR with host bits set (expected changed=false) (CHECK MODE) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}" state: present # set purge_rules to false so we don't get a false positive from previously added rules purge_rules: false @@ -660,10 +660,10 @@ register: check_result # ============================================================ - - name: test adding the same rule with a IPv4 CIDR with host bits set (expected changed=false and a warning) + - name: Test adding the same rule with a IPv4 CIDR with host bits set (expected changed=false and a warning) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}" state: present # set purge_rules to false so we don't get a false positive from previously added rules purge_rules: false @@ -674,12 +674,12 @@ cidr_ip: 10.0.0.1/8 register: result - - name: assert state=present (expected changed=false and a warning) + - name: Assert state=present (expected changed=false and a warning) ansible.builtin.assert: that: - not check_result.changed - - name: assert state=present (expected changed=false and a warning) + - name: Assert state=present (expected changed=false and a warning) ansible.builtin.assert: that: # No way to assert for warnings? @@ -687,12 +687,15 @@ - result.group_id.startswith("sg-") # ============================================================ - - name: test using the default VPC + - name: Test using the default VPC + when: default_vpc + + # ============================================================ block: - - name: test adding a rule with a IPv6 CIDR with host bits set (expected changed=true) (CHECK MODE) + - name: Test adding a rule with a IPv6 CIDR with host bits set (expected changed=true) (CHECK MODE) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}" state: present # set purge_rules to false so we don't get a false positive from previously added rules purge_rules: false @@ -704,16 +707,16 @@ check_mode: true register: result - - name: assert state=present (expected changed=true) + - name: Assert state=present (expected changed=true) ansible.builtin.assert: that: - result.changed # ============================================================ - - name: test adding a rule with a IPv6 CIDR with host bits set (expected changed=true) + - name: Test adding a rule with a IPv6 CIDR with host bits set (expected changed=true) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}" state: present # set purge_rules to false so we don't get a false positive from previously added rules purge_rules: false @@ -724,7 +727,7 @@ cidr_ipv6: 2001:db00::1/24 register: result - - name: assert state=present (expected changed=true) + - name: Assert state=present (expected changed=true) ansible.builtin.assert: that: - result.changed @@ -732,10 +735,10 @@ # ============================================================ - - name: test adding a rule again with a IPv6 CIDR with host bits set (expected changed=false and a warning) + - name: Test adding a rule again with a IPv6 CIDR with host bits set (expected changed=false and a warning) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}" state: present # set purge_rules to false so we don't get a false positive from previously added rules purge_rules: false @@ -746,46 +749,43 @@ cidr_ipv6: 2001:db00::1/24 register: result - - name: assert state=present (expected changed=false and a warning) + - name: Assert state=present (expected changed=false and a warning) ansible.builtin.assert: that: # No way to assert for warnings? - not result.changed - result.group_id.startswith("sg-") - when: default_vpc - - # ============================================================ - - name: test state=absent (expected changed=true) (CHECK MODE) + - name: Test state=absent (expected changed=true) (CHECK MODE) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" + name: "{{ ec2_group_name }}" state: absent check_mode: true register: result - - name: assert state=absent (expected changed=true) + - name: Assert state=absent (expected changed=true) ansible.builtin.assert: that: - result.changed # ============================================================ - - name: test state=absent (expected changed=true) + - name: Test state=absent (expected changed=true) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" + name: "{{ ec2_group_name }}" state: absent register: result - - name: assert state=absent (expected changed=true) + - name: Assert state=absent (expected changed=true) ansible.builtin.assert: that: - result.changed - not result.group_id # ============================================================ - - name: create security group in the VPC (CHECK MODE) + - name: Create security group in the VPC (CHECK MODE) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}" vpc_id: "{{ vpc_result.vpc.id }}" state: present rules: @@ -796,16 +796,16 @@ check_mode: true register: result - - name: assert state=present (expected changed=true) + - name: Assert state=present (expected changed=true) ansible.builtin.assert: that: - result.changed # ============================================================ - - name: create security group in the VPC + - name: Create security group in the VPC amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}" vpc_id: "{{ vpc_result.vpc.id }}" state: present rules: @@ -815,7 +815,7 @@ cidr_ip: 10.1.1.1/32 register: result - - name: assert state=present (expected changed=true) + - name: Assert state=present (expected changed=true) ansible.builtin.assert: that: - result.changed @@ -823,10 +823,10 @@ - result.group_id.startswith("sg-") # ============================================================ - - name: test adding tags (expected changed=true) (CHECK MODE) + - name: Test adding tags (expected changed=true) (CHECK MODE) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}" vpc_id: "{{ vpc_result.vpc.id }}" state: present rules: @@ -841,7 +841,7 @@ diff: true register: result - - name: assert that tags were added (expected changed=true) + - name: Assert that tags were added (expected changed=true) ansible.builtin.assert: that: - result.changed @@ -850,10 +850,10 @@ - result.diff.0.after.tags.tag2 == "test2" # ============================================================ - - name: test adding tags (expected changed=true) + - name: Test adding tags (expected changed=true) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}" vpc_id: "{{ vpc_result.vpc.id }}" state: present rules: @@ -866,17 +866,17 @@ tag2: test2 register: result - - name: assert that tags were added (expected changed=true) + - name: Assert that tags were added (expected changed=true) ansible.builtin.assert: that: - result.changed - 'result.tags == {"tag1": "test1", "tag2": "test2"}' # ============================================================ - - name: test that tags are present (expected changed=False) (CHECK MODE) + - name: Test that tags are present (expected changed=False) (CHECK MODE) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}" vpc_id: "{{ vpc_result.vpc.id }}" state: present purge_rules_egress: false @@ -891,16 +891,16 @@ check_mode: true register: result - - name: assert that tags were not changed (expected changed=False) + - name: Assert that tags were not changed (expected changed=False) ansible.builtin.assert: that: - not result.changed # ============================================================ - - name: test that tags are present (expected changed=False) + - name: Test that tags are present (expected changed=False) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}" vpc_id: "{{ vpc_result.vpc.id }}" state: present purge_rules_egress: false @@ -914,17 +914,17 @@ tag2: test2 register: result - - name: assert that tags were not changed (expected changed=False) + - name: Assert that tags were not changed (expected changed=False) ansible.builtin.assert: that: - not result.changed - 'result.tags == {"tag1": "test1", "tag2": "test2"}' # ============================================================ - - name: test purging tags (expected changed=True) (CHECK MODE) + - name: Test purging tags (expected changed=True) (CHECK MODE) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}" vpc_id: "{{ vpc_result.vpc.id }}" state: present rules: @@ -937,16 +937,16 @@ check_mode: true register: result - - name: assert that tag2 was removed (expected changed=true) + - name: Assert that tag2 was removed (expected changed=true) ansible.builtin.assert: that: - result.changed # ============================================================ - - name: test purging tags (expected changed=True) + - name: Test purging tags (expected changed=True) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}" vpc_id: "{{ vpc_result.vpc.id }}" state: present rules: @@ -958,7 +958,7 @@ tag1: test1 register: result - - name: assert that tag2 was removed (expected changed=true) + - name: Assert that tag2 was removed (expected changed=true) ansible.builtin.assert: that: - result.changed @@ -966,10 +966,10 @@ # ============================================================ - - name: assert that tags are left as-is if not specified (expected changed=False) + - name: Assert that tags are left as-is if not specified (expected changed=False) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}" vpc_id: "{{ vpc_result.vpc.id }}" state: present rules: @@ -979,7 +979,7 @@ cidr_ip: 10.1.1.1/32 register: result - - name: assert that the tags stayed the same (expected changed=false) + - name: Assert that the tags stayed the same (expected changed=false) ansible.builtin.assert: that: - not result.changed @@ -987,10 +987,10 @@ # ============================================================ - - name: test purging all tags (expected changed=True) + - name: Test purging all tags (expected changed=True) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}" vpc_id: "{{ vpc_result.vpc.id }}" state: present rules: @@ -1001,17 +1001,17 @@ tags: {} register: result - - name: assert that tag1 was removed (expected changed=true) + - name: Assert that tag1 was removed (expected changed=true) ansible.builtin.assert: that: - result.changed - not result.tags # ============================================================ - - name: test adding a rule and egress rule descriptions (expected changed=true) (CHECK MODE) + - name: Test adding a rule and egress rule descriptions (expected changed=true) (CHECK MODE) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}" vpc_id: "{{ vpc_result.vpc.id }}" # purge the other rules so assertions work for the subsequent tests for rule descriptions purge_rules_egress: true @@ -1032,16 +1032,16 @@ check_mode: true register: result - - name: assert that rule descriptions are created (expected changed=true) + - name: Assert that rule descriptions are created (expected changed=true) ansible.builtin.assert: that: - result.changed # ========================================================================================= - - name: add rules without descriptions ready for adding descriptions to existing rules + - name: Add rules without descriptions ready for adding descriptions to existing rules amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}" vpc_id: "{{ vpc_result.vpc.id }}" # purge the other rules so assertions work for the subsequent tests for rule descriptions purge_rules_egress: true @@ -1060,10 +1060,10 @@ register: result # ============================================================ - - name: test adding a rule and egress rule descriptions (expected changed=true) + - name: Test adding a rule and egress rule descriptions (expected changed=true) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}" vpc_id: "{{ vpc_result.vpc.id }}" # purge the other rules so assertions work for the subsequent tests for rule descriptions purge_rules_egress: true @@ -1083,7 +1083,7 @@ rule_desc: egress rule desc 1 register: result - - name: assert that rule descriptions are created (expected changed=true) + - name: Assert that rule descriptions are created (expected changed=true) ansible.builtin.assert: that: - result.changed @@ -1091,10 +1091,10 @@ - result.ip_permissions_egress[0].ip_ranges[0].description == "egress rule desc 1" # ============================================================ - - name: test modifying rule and egress rule descriptions (expected changed=true) (CHECK MODE) + - name: Test modifying rule and egress rule descriptions (expected changed=true) (CHECK MODE) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}" vpc_id: "{{ vpc_result.vpc.id }}" purge_rules_egress: false purge_rules: false @@ -1114,17 +1114,17 @@ check_mode: true register: result - - name: assert that rule descriptions were modified (expected changed=true) + - name: Assert that rule descriptions were modified (expected changed=true) ansible.builtin.assert: that: - result.ip_permissions | length > 0 - result.changed # ============================================================ - - name: test modifying rule and egress rule descriptions (expected changed=true) + - name: Test modifying rule and egress rule descriptions (expected changed=true) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}" vpc_id: "{{ vpc_result.vpc.id }}" purge_rules_egress: false purge_rules: false @@ -1143,7 +1143,7 @@ rule_desc: egress rule desc 2 register: result - - name: assert that rule descriptions were modified (expected changed=true) + - name: Assert that rule descriptions were modified (expected changed=true) ansible.builtin.assert: that: - result.changed @@ -1152,10 +1152,10 @@ # ============================================================ - - name: test creating rule in default vpc with egress rule (expected changed=true) + - name: Test creating rule in default vpc with egress rule (expected changed=true) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}-default-vpc" - description: "{{ec2_group_description}} default VPC" + name: "{{ ec2_group_name }}-default-vpc" + description: "{{ ec2_group_description }} default VPC" purge_rules_egress: true state: present rules: @@ -1172,17 +1172,17 @@ rule_desc: egress rule desc 2 register: result - - name: assert that rule descriptions were modified (expected changed=true) + - name: Assert that rule descriptions were modified (expected changed=true) ansible.builtin.assert: that: - result.changed - result.ip_permissions_egress|length == 1 # ============================================================ - - name: test that keeping the same rule descriptions (expected changed=false) (CHECK MODE) + - name: Test that keeping the same rule descriptions (expected changed=false) (CHECK MODE) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}" vpc_id: "{{ vpc_result.vpc.id }}" purge_rules_egress: false purge_rules: false @@ -1202,16 +1202,16 @@ check_mode: true register: result - - name: assert that rule descriptions stayed the same (expected changed=false) + - name: Assert that rule descriptions stayed the same (expected changed=false) ansible.builtin.assert: that: - not result.changed # ============================================================ - - name: test that keeping the same rule descriptions (expected changed=false) + - name: Test that keeping the same rule descriptions (expected changed=false) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}" vpc_id: "{{ vpc_result.vpc.id }}" purge_rules_egress: false purge_rules: false @@ -1230,7 +1230,7 @@ rule_desc: egress rule desc 2 register: result - - name: assert that rule descriptions stayed the same (expected changed=false) + - name: Assert that rule descriptions stayed the same (expected changed=false) ansible.builtin.assert: that: - not result.changed @@ -1238,10 +1238,10 @@ - result.ip_permissions_egress[0].ip_ranges[0].description == "egress rule desc 2" # ============================================================ - - name: test removing rule descriptions (expected changed=true) (CHECK MODE) + - name: Test removing rule descriptions (expected changed=true) (CHECK MODE) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}" vpc_id: "{{ vpc_result.vpc.id }}" purge_rules_egress: false purge_rules: false @@ -1261,16 +1261,16 @@ check_mode: true register: result - - name: assert that rule descriptions were removed (expected changed=true) + - name: Assert that rule descriptions were removed (expected changed=true) ansible.builtin.assert: that: - result.changed # ============================================================ - - name: test removing rule descriptions (expected changed=true) + - name: Test removing rule descriptions (expected changed=true) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}" + description: "{{ ec2_group_description }}" vpc_id: "{{ vpc_result.vpc.id }}" purge_rules_egress: false purge_rules: false @@ -1290,7 +1290,7 @@ register: result ignore_errors: true - - name: assert that rule descriptions were removed + - name: Assert that rule descriptions were removed ansible.builtin.assert: that: - result.ip_permissions[0].ipv6_ranges[0].description is undefined @@ -1298,13 +1298,13 @@ # ============================================================ - - name: test state=absent (expected changed=true) + - name: Test state=absent (expected changed=true) amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}" + name: "{{ ec2_group_name }}" state: absent register: result - - name: assert state=absent (expected changed=true) + - name: Assert state=absent (expected changed=true) ansible.builtin.assert: that: - result.changed @@ -1355,7 +1355,7 @@ # ============================================================ - - name: tidy up VPC + - name: Tidy up VPC amazon.aws.ec2_vpc_net: name: "{{ resource_prefix }}-vpc" state: absent diff --git a/tests/integration/targets/ec2_security_group/tasks/multi_account.yml b/tests/integration/targets/ec2_security_group/tasks/multi_account.yml index 64819304f5e..f10f5a1b892 100644 --- a/tests/integration/targets/ec2_security_group/tasks/multi_account.yml +++ b/tests/integration/targets/ec2_security_group/tasks/multi_account.yml @@ -2,7 +2,7 @@ - block: - amazon.aws.aws_caller_info: register: caller_facts - - name: create a VPC + - name: Create a VPC amazon.aws.ec2_vpc_net: name: "{{ resource_prefix }}-vpc-2" state: present @@ -81,7 +81,8 @@ that: - out is failed always: - - ansible.builtin.pause: seconds=5 + - ansible.builtin.pause: + seconds: "5" - name: Delete secondary-VPC side of peer amazon.aws.ec2_vpc_peering: vpc_id: "{{ vpc_result_2.vpc.id }}" @@ -114,7 +115,7 @@ state: absent vpc_id: "{{ vpc_result.vpc.id }}" ignore_errors: true - - name: tidy up VPC + - name: Tidy up VPC amazon.aws.ec2_vpc_net: name: "{{ resource_prefix }}-vpc-2" state: absent diff --git a/tests/integration/targets/ec2_security_group/tasks/multi_nested_target.yml b/tests/integration/targets/ec2_security_group/tasks/multi_nested_target.yml index 02057003a8b..3909a61d893 100644 --- a/tests/integration/targets/ec2_security_group/tasks/multi_nested_target.yml +++ b/tests/integration/targets/ec2_security_group/tasks/multi_nested_target.yml @@ -1,7 +1,7 @@ --- # ============================================================ -- name: test state=present for multiple ipv6 and ipv4 targets (expected changed=true) (CHECK MODE) +- name: Test state=present for multiple ipv6 and ipv4 targets (expected changed=true) (CHECK MODE) amazon.aws.ec2_security_group: name: "{{ ec2_group_name }}" description: "{{ ec2_group_description }}" @@ -22,12 +22,12 @@ check_mode: true register: result -- name: assert state=present (expected changed=true) +- name: Assert state=present (expected changed=true) ansible.builtin.assert: that: - result.changed -- name: test state=present for multiple ipv6 and ipv4 targets (expected changed=true) +- name: Test state=present for multiple ipv6 and ipv4 targets (expected changed=true) amazon.aws.ec2_security_group: name: "{{ ec2_group_name }}" description: "{{ ec2_group_description }}" @@ -47,7 +47,7 @@ - [10.0.0.0/24, 10.20.0.0/24] register: result -- name: assert state=present (expected changed=true) +- name: Assert state=present (expected changed=true) ansible.builtin.assert: that: - result.changed @@ -55,7 +55,7 @@ - result.ip_permissions[0].ip_ranges | length == 4 or result.ip_permissions[1].ip_ranges | length == 4 - result.ip_permissions[0].ipv6_ranges | length == 2 or result.ip_permissions[1].ipv6_ranges | length == 2 -- name: test state=present for multiple ipv6 and ipv4 targets (expected changed=false) (CHECK MODE) +- name: Test state=present for multiple ipv6 and ipv4 targets (expected changed=false) (CHECK MODE) amazon.aws.ec2_security_group: name: "{{ ec2_group_name }}" description: "{{ ec2_group_description }}" @@ -76,12 +76,12 @@ check_mode: true register: result -- name: assert state=present (expected changed=true) +- name: Assert state=present (expected changed=true) ansible.builtin.assert: that: - not result.changed -- name: test state=present for multiple ipv6 and ipv4 targets (expected changed=false) +- name: Test state=present for multiple ipv6 and ipv4 targets (expected changed=false) amazon.aws.ec2_security_group: name: "{{ ec2_group_name }}" description: "{{ ec2_group_description }}" @@ -101,12 +101,12 @@ - [10.0.0.0/24, 10.20.0.0/24] register: result -- name: assert state=present (expected changed=true) +- name: Assert state=present (expected changed=true) ansible.builtin.assert: that: - not result.changed -- name: test state=present purging a nested ipv4 target (expected changed=true) (CHECK MODE) +- name: Test state=present purging a nested ipv4 target (expected changed=true) (CHECK MODE) amazon.aws.ec2_security_group: name: "{{ ec2_group_name }}" description: "{{ ec2_group_description }}" @@ -131,7 +131,7 @@ that: - result.changed -- name: test state=present purging a nested ipv4 target (expected changed=true) +- name: Test state=present purging a nested ipv4 target (expected changed=true) amazon.aws.ec2_security_group: name: "{{ ec2_group_name }}" description: "{{ ec2_group_description }}" @@ -157,7 +157,7 @@ - result.ip_permissions[0].ip_ranges | length == 3 or result.ip_permissions[1].ip_ranges | length == 3 - result.ip_permissions[0].ipv6_ranges | length == 2 or result.ip_permissions[1].ipv6_ranges | length == 2 -- name: test state=present with both associated ipv6 targets nested (expected changed=false) +- name: Test state=present with both associated ipv6 targets nested (expected changed=false) amazon.aws.ec2_security_group: name: "{{ ec2_group_name }}" description: "{{ ec2_group_description }}" @@ -180,7 +180,7 @@ that: - not result.changed -- name: test state=present add another nested ipv6 target (expected changed=true) +- name: Test state=present add another nested ipv6 target (expected changed=true) amazon.aws.ec2_security_group: name: "{{ ec2_group_name }}" description: "{{ ec2_group_description }}" @@ -207,7 +207,7 @@ - result.ip_permissions[0].ip_ranges | length == 3 or result.ip_permissions[1].ip_ranges | length == 3 - result.ip_permissions[0].ipv6_ranges | length == 3 or result.ip_permissions[1].ipv6_ranges | length == 3 -- name: delete it +- name: Delete it amazon.aws.ec2_security_group: name: "{{ ec2_group_name }}" state: absent diff --git a/tests/integration/targets/ec2_security_group/tasks/numeric_protos.yml b/tests/integration/targets/ec2_security_group/tasks/numeric_protos.yml index dc1762e531d..c7b7b41e6d0 100644 --- a/tests/integration/targets/ec2_security_group/tasks/numeric_protos.yml +++ b/tests/integration/targets/ec2_security_group/tasks/numeric_protos.yml @@ -1,8 +1,8 @@ --- - block: - - name: set up temporary group name for tests + - name: Set up temporary group name for tests ansible.builtin.set_fact: - group_tmp_name: "{{ec2_group_name}}-numbered-protos" + group_tmp_name: "{{ ec2_group_name }}-numbered-protos" - name: Create a group with numbered protocol (GRE) amazon.aws.ec2_security_group: @@ -58,9 +58,9 @@ - result is not changed always: - - name: tidy up egress rule test security group + - name: Tidy up egress rule test security group amazon.aws.ec2_security_group: - name: "{{group_tmp_name}}" + name: "{{ group_tmp_name }}" state: absent vpc_id: "{{ vpc_result.vpc.id }}" ignore_errors: true diff --git a/tests/integration/targets/ec2_security_group/tasks/rule_group_create.yml b/tests/integration/targets/ec2_security_group/tasks/rule_group_create.yml index 1563ad5413e..d1c3be3eecc 100644 --- a/tests/integration/targets/ec2_security_group/tasks/rule_group_create.yml +++ b/tests/integration/targets/ec2_security_group/tasks/rule_group_create.yml @@ -2,35 +2,35 @@ - block: - name: Create a group with self-referring rule amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}-auto-create-1" + name: "{{ ec2_group_name }}-auto-create-1" vpc_id: "{{ vpc_result.vpc.id }}" - description: "{{ec2_group_description}}" + description: "{{ ec2_group_description }}" rules: - proto: tcp from_port: 8000 to_port: 8100 - group_name: "{{ec2_group_name}}-auto-create-1" + group_name: "{{ ec2_group_name }}-auto-create-1" state: present register: result - name: Create a second group rule amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}-auto-create-2" + name: "{{ ec2_group_name }}-auto-create-2" vpc_id: "{{ vpc_result.vpc.id }}" - description: "{{ec2_group_description}}" + description: "{{ ec2_group_description }}" state: present - name: Create a series of rules with a recently created group as target amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}-auto-create-1" + name: "{{ ec2_group_name }}-auto-create-1" vpc_id: "{{ vpc_result.vpc.id }}" - description: "{{ec2_group_description}}" + description: "{{ ec2_group_description }}" purge_rules: false rules: - proto: tcp from_port: "{{ item }}" to_port: "{{ item }}" - group_name: "{{ec2_group_name}}-auto-create-2" + group_name: "{{ ec2_group_name }}-auto-create-2" state: present register: result with_items: @@ -45,19 +45,19 @@ - name: Create a group with only the default rule amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}-auto-create-1" + name: "{{ ec2_group_name }}-auto-create-1" vpc_id: "{{ vpc_result.vpc.id }}" - description: "{{ec2_group_description}}" + description: "{{ ec2_group_description }}" rules: - proto: tcp from_port: 8182 to_port: 8182 - group_name: "{{ec2_group_name}}-auto-create-3" + group_name: "{{ ec2_group_name }}-auto-create-3" state: present register: result ignore_errors: true - - name: assert you can't create a new group from a rule target with no description + - name: Assert you can't create a new group from a rule target with no description ansible.builtin.assert: that: - result is failed @@ -65,16 +65,16 @@ - name: Create a group with a target of a separate group amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}-auto-create-1" + name: "{{ ec2_group_name }}-auto-create-1" vpc_id: "{{ vpc_result.vpc.id }}" - description: "{{ec2_group_description}}" + description: "{{ ec2_group_description }}" rules: - proto: tcp ports: - 22 - 80 - group_name: "{{ec2_group_name}}-auto-create-3" - group_desc: "{{ec2_group_description}}" + group_name: "{{ ec2_group_name }}-auto-create-3" + group_desc: "{{ ec2_group_description }}" state: present register: result @@ -84,9 +84,9 @@ - name: Create a 4th group amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}-auto-create-4" + name: "{{ ec2_group_name }}-auto-create-4" vpc_id: "{{ vpc_result.vpc.id }}" - description: "{{ec2_group_description}}" + description: "{{ ec2_group_description }}" state: present rules: - proto: tcp @@ -94,16 +94,16 @@ - 22 cidr_ip: "0.0.0.0/0" - - name: use recently created group in a rule + - name: Use recently created group in a rule amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}-auto-create-5" + name: "{{ ec2_group_name }}-auto-create-5" vpc_id: "{{ vpc_result.vpc.id }}" - description: "{{ec2_group_description}}" + description: "{{ ec2_group_description }}" rules: - proto: tcp ports: - 443 - group_name: "{{ec2_group_name}}-auto-create-4" + group_name: "{{ ec2_group_name }}-auto-create-4" state: present - ansible.builtin.assert: @@ -111,17 +111,17 @@ - result.warning is not defined always: - - name: tidy up egress rule test security group rules + - name: Tidy up egress rule test security group rules amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}-auto-create-{{ item }}" - description: "{{ec2_group_description}}" + name: "{{ ec2_group_name }}-auto-create-{{ item }}" + description: "{{ ec2_group_description }}" rules: [] rules_egress: [] ignore_errors: true with_items: [5, 4, 3, 2, 1] - - name: tidy up egress rule test security group + - name: Tidy up egress rule test security group amazon.aws.ec2_security_group: - name: "{{ec2_group_name}}-auto-create-{{ item }}" + name: "{{ ec2_group_name }}-auto-create-{{ item }}" state: absent vpc_id: "{{ vpc_result.vpc.id }}" ignore_errors: true diff --git a/tests/integration/targets/ec2_snapshot/tasks/main.yml b/tests/integration/targets/ec2_snapshot/tasks/main.yml index bc33df658ba..1d8de730d14 100644 --- a/tests/integration/targets/ec2_snapshot/tasks/main.yml +++ b/tests/integration/targets/ec2_snapshot/tasks/main.yml @@ -284,7 +284,7 @@ ignore_errors: true register: info_result - - name: assert that operation failed + - name: Assert that operation failed ansible.builtin.assert: that: - info_result is failed @@ -298,7 +298,7 @@ ignore_errors: true register: info_result - - name: assert that operation failed + - name: Assert that operation failed ansible.builtin.assert: that: - info_result is failed @@ -386,7 +386,7 @@ - name: Delete detached and untagged volume amazon.aws.ec2_vol: - id: "{{ volume_detached.volume_id}}" + id: "{{ volume_detached.volume_id }}" state: absent ignore_errors: true diff --git a/tests/integration/targets/ec2_snapshot/tasks/test_modify_create_volume_permissions.yml b/tests/integration/targets/ec2_snapshot/tasks/test_modify_create_volume_permissions.yml index 17106cdf405..f771609dac5 100644 --- a/tests/integration/targets/ec2_snapshot/tasks/test_modify_create_volume_permissions.yml +++ b/tests/integration/targets/ec2_snapshot/tasks/test_modify_create_volume_permissions.yml @@ -29,7 +29,7 @@ - "{{ snapshot_id }}" register: info_result - - name: assert that createVolumePermission are "Private" + - name: Assert that createVolumePermission are "Private" ansible.builtin.assert: that: - info_result.snapshots[0].create_volume_permissions | length == 0 diff --git a/tests/integration/targets/ec2_spot_instance/defaults/main.yml b/tests/integration/targets/ec2_spot_instance/defaults/main.yml index ba4cd5896c6..56b84a7aa4b 100644 --- a/tests/integration/targets/ec2_spot_instance/defaults/main.yml +++ b/tests/integration/targets/ec2_spot_instance/defaults/main.yml @@ -1,8 +1,8 @@ --- vpc_seed_a: "{{ resource_prefix }}" vpc_seed_b: "{{ resource_prefix }}-ec2_eni" -vpc_prefix: 10.{{ 256 | random(seed=vpc_seed_a) }}.{{ 256 | random(seed=vpc_seed_b ) }} -vpc_cidr: "{{ vpc_prefix}}.128/26" +vpc_prefix: 10.{{ 256 | random(seed=vpc_seed_a) }}.{{ 256 | random(seed=vpc_seed_b) }} +vpc_cidr: "{{ vpc_prefix }}.128/26" ip_1: "{{ vpc_prefix }}.132" ip_2: "{{ vpc_prefix }}.133" ip_3: "{{ vpc_prefix }}.134" diff --git a/tests/integration/targets/ec2_spot_instance/tasks/main.yaml b/tests/integration/targets/ec2_spot_instance/tasks/main.yaml index ddd63c70dda..d973c1383c1 100644 --- a/tests/integration/targets/ec2_spot_instance/tasks/main.yaml +++ b/tests/integration/targets/ec2_spot_instance/tasks/main.yaml @@ -18,7 +18,7 @@ availability_zone: "{{ az_info['availability_zones'][0]['zone_name'] }}" # ============================================================ - - name: create a VPC + - name: Create a VPC amazon.aws.ec2_vpc_net: name: "{{ resource_prefix }}-vpc" state: present @@ -28,7 +28,7 @@ Description: Created by ansible-test register: vpc_result - - name: create a subnet + - name: Create a subnet amazon.aws.ec2_vpc_subnet: cidr: "{{ vpc_cidr }}" az: "{{ availability_zone }}" @@ -39,7 +39,7 @@ state: present register: vpc_subnet_result - - name: create a security group + - name: Create a security group amazon.aws.ec2_security_group: name: "{{ resource_prefix }}-sg" description: Created by {{ resource_prefix }} @@ -48,7 +48,7 @@ vpc_id: "{{ vpc_result.vpc.id }}" register: vpc_sg_result - - name: create a new ec2 key pair + - name: Create a new ec2 key pair amazon.aws.ec2_key: name: "{{ resource_prefix }}-keypair" @@ -113,7 +113,7 @@ availability_zone: "{{ availability_zone }}" monitoring: enabled: false - spot_price: !!float "0.002" + spot_price: 0.002 tags: camelCase: helloWorld PascalCase: HelloWorld @@ -258,13 +258,13 @@ filters: vpc-id: "{{ vpc_result.vpc.id }}" - - name: get all spot requests created during test + - name: Get all spot requests created during test amazon.aws.ec2_spot_instance_info: filters: tag:ansible-test: "{{ resource_prefix }}" register: spot_request_list - - name: remove spot instance requests + - name: Remove spot instance requests amazon.aws.ec2_spot_instance: spot_instance_request_ids: - "{{ item.spot_instance_request_id }}" @@ -273,7 +273,7 @@ retries: 5 with_items: "{{ spot_request_list.spot_request }}" - - name: remove the security group + - name: Remove the security group amazon.aws.ec2_security_group: name: "{{ resource_prefix }}-sg" description: "{{ resource_prefix }}" @@ -283,7 +283,7 @@ ignore_errors: true retries: 5 - - name: remove the subnet + - name: Remove the subnet amazon.aws.ec2_vpc_subnet: cidr: "{{ vpc_cidr }}" az: "{{ availability_zone }}" @@ -293,7 +293,7 @@ retries: 5 when: vpc_subnet_result is defined - - name: remove the VPC + - name: Remove the VPC amazon.aws.ec2_vpc_net: name: "{{ resource_prefix }}-vpc" cidr_block: "{{ vpc_cidr }}" @@ -301,7 +301,7 @@ ignore_errors: true retries: 5 - - name: remove key pair by name + - name: Remove key pair by name amazon.aws.ec2_key: name: "{{ resource_prefix }}-keypair" state: absent diff --git a/tests/integration/targets/ec2_spot_instance/tasks/terminate_associated_instances.yml b/tests/integration/targets/ec2_spot_instance/tasks/terminate_associated_instances.yml index 7ff2ef97a63..c1971849648 100644 --- a/tests/integration/targets/ec2_spot_instance/tasks/terminate_associated_instances.yml +++ b/tests/integration/targets/ec2_spot_instance/tasks/terminate_associated_instances.yml @@ -49,7 +49,7 @@ state: absent check_mode: true register: idem_check - + - ansible.builtin.assert: that: - idem_check is not changed @@ -63,7 +63,7 @@ - ansible.builtin.assert: that: instance_info_result.instances[0].state.name == 'running' - #========================================================================== + # ========================================================================== # Spot instance request creation - name: Simple Spot Request Creation @@ -107,7 +107,7 @@ state: absent terminate_instances: true - - name: wait for instance to terminate + - name: Wait for instance to terminate ansible.builtin.pause: seconds: 60 diff --git a/tests/integration/targets/ec2_transit_gateway/meta/main.yml b/tests/integration/targets/ec2_transit_gateway/meta/main.yml index 32cf5dda7ed..23d65c7ef45 100644 --- a/tests/integration/targets/ec2_transit_gateway/meta/main.yml +++ b/tests/integration/targets/ec2_transit_gateway/meta/main.yml @@ -1 +1,2 @@ +--- dependencies: [] diff --git a/tests/integration/targets/ec2_transit_gateway/tasks/main.yml b/tests/integration/targets/ec2_transit_gateway/tasks/main.yml index eacbdd3d9b1..edf5785fa9c 100644 --- a/tests/integration/targets/ec2_transit_gateway/tasks/main.yml +++ b/tests/integration/targets/ec2_transit_gateway/tasks/main.yml @@ -1,297 +1,297 @@ +--- - name: Run 'ec2_transit_gateway 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: Generate unique value for testing - ansible.builtin.set_fact: - tgw_description: '{{ resource_prefix }}-tgw' - - - name: Test create transit gateway without tags - check_mode - amazon.aws.ec2_transit_gateway: - description: '{{ tgw_description }}' - register: create_result - check_mode: true - - - name: Assert changed is True - check_mode - ansible.builtin.assert: - that: - - create_result.changed == True - - '"ec2:CreateTransitGateway" not in create_result.resource_actions' - - - name: Test create transit gateway without tags - amazon.aws.ec2_transit_gateway: - description: '{{ tgw_description }}' - register: create_result - - - name: Assert changed is True - ansible.builtin.assert: - that: - - create_result.changed == True - - - name: Test create transit gateway without tags - idempotency - amazon.aws.ec2_transit_gateway: - description: '{{ tgw_description }}' - register: create_result - - - name: Assert changed is True - ansible.builtin.assert: - that: - - create_result.changed == False - - '"ec2:CreateTransitGateway" not in create_result.resource_actions' - - - name: Test update transit gateway with tags by description - check_mode - amazon.aws.ec2_transit_gateway: - description: '{{ tgw_description }}' - tags: - Name: Ansible Test TGW - register: result - check_mode: true - - - name: Assert changed is True - check_mode - ansible.builtin.assert: - that: - - result.changed == True - - '"ec2:CreateTags" not in result.resource_actions' - - - name: Test update transit gateway with tags by description - amazon.aws.ec2_transit_gateway: - description: '{{ tgw_description }}' - tags: - Name: Ansible Test TGW - register: result - - - name: Assert changed is True - ansible.builtin.assert: - that: - - result.changed == True - - result.transit_gateway.tags | length == 1 - - "'Name' in result.transit_gateway.tags" - - - name: Test update transit gateway with tags by description - idempotency - amazon.aws.ec2_transit_gateway: - description: '{{ tgw_description }}' - tags: - Name: Ansible Test TGW - register: result - - - name: Assert changed is False - idempotency - ansible.builtin.assert: - that: - - result.changed == False - - result.transit_gateway.tags | length == 1 - - "'Name' in result.transit_gateway.tags" - - - name: Test update transit gateway with new tag and purge_tags false - check_mode - amazon.aws.ec2_transit_gateway: - transit_gateway_id: '{{ create_result.transit_gateway.transit_gateway_id }}' - purge_tags: false - tags: - status: ok to delete - register: result - check_mode: true - - - name: Assert changed is True and have 2 tags - check_mode - ansible.builtin.assert: - that: - - result.changed == True - - result.transit_gateway.tags | length != 2 - - "'Name' in result.transit_gateway.tags" - - '"ec2:CreateTags" not in result.resource_actions' - - - name: Test update transit gateway with new tag and purge_tags false - amazon.aws.ec2_transit_gateway: - transit_gateway_id: '{{ create_result.transit_gateway.transit_gateway_id }}' - purge_tags: false - tags: - status: ok to delete - register: result - - - name: Assert changed is True and have 2 tags - ansible.builtin.assert: - that: - - result.changed == True - - result.transit_gateway.tags | length == 2 - - "'Name' in result.transit_gateway.tags" - - - name: Test update transit gateway with new tag and purge_tags false - idempotency - amazon.aws.ec2_transit_gateway: - transit_gateway_id: '{{ create_result.transit_gateway.transit_gateway_id }}' - purge_tags: false - tags: - status: ok to delete - register: result - - - name: Assert changed is True and have 2 tags - idempotency - ansible.builtin.assert: - that: - - result.changed == False - - result.transit_gateway.tags | length == 2 - - "'Name' in result.transit_gateway.tags" - - - name: Test update transit gateway with purge_tags true - check_mode - amazon.aws.ec2_transit_gateway: - transit_gateway_id: '{{ create_result.transit_gateway.transit_gateway_id }}' - purge_tags: true - tags: - status: ok to delete - register: result - check_mode: true - - - name: Assert changed is True and TGW tag is absent - check_mode - ansible.builtin.assert: - that: - - result.changed == True - - result.transit_gateway.tags | length == 2 - - '"ec2:DeleteTags" not in result.resource_actions' - - - name: Test update transit gateway with purge_tags true - amazon.aws.ec2_transit_gateway: - transit_gateway_id: '{{ create_result.transit_gateway.transit_gateway_id }}' - purge_tags: true - tags: - status: ok to delete - register: result - - - name: Assert changed is True and TGW tag is absent - ansible.builtin.assert: - that: - - result.changed == True - - result.transit_gateway.tags | length == 1 - - "'Name' not in result.transit_gateway.tags" - - - name: Test idempotence - amazon.aws.ec2_transit_gateway: - description: '{{ tgw_description }}' - purge_tags: true - tags: - status: ok to delete - register: result - - - name: Assert changed is False - ansible.builtin.assert: - that: - - result.changed == False - - - name: Generate unique value for testing - ansible.builtin.set_fact: - tgw_description_multicast: '{{ resource_prefix }}-tgw-multicast' - - - name: Test create transit gateway with multicast enabled - check_mode - amazon.aws.ec2_transit_gateway: - description: '{{ tgw_description_multicast }}' - multicast_support: true - register: create_result - check_mode: true - - - name: Assert changed is True - check_mode - ansible.builtin.assert: - that: - - create_result.changed == True - - '"ec2:CreateTransitGateway" not in create_result.resource_actions' - - - name: Test create transit gateway with multicast enabled - amazon.aws.ec2_transit_gateway: - description: '{{ tgw_description_multicast }}' - multicast_support: true - register: create_result - - - name: Assert changed is True - ansible.builtin.assert: - that: - - create_result.changed == True - - - name: Test create transit gateway with multicast enabled - idempotency - amazon.aws.ec2_transit_gateway: - description: '{{ tgw_description_multicast }}' - multicast_support: true - register: create_result - - - name: Assert changed is True - idempotency - ansible.builtin.assert: - that: - - create_result.changed == False - - - name: Test success with filter - amazon.aws.ec2_transit_gateway_info: - filters: - options.multicast-support: enable - register: result - - - name: Assert success with multicast-support filter - ansible.builtin.assert: - that: - - result.transit_gateways != [] - - # ==== Combine ec2_transit_gateway_info ====================== - - name: Test success with no parameters - amazon.aws.ec2_transit_gateway_info: - register: result - - name: Assert success with no parameters - ansible.builtin.assert: - that: - - result.changed == false - - result.transit_gateways != [] - - - name: Test success with single filter - amazon.aws.ec2_transit_gateway_info: - filters: - transit-gateway-id: '{{ create_result.transit_gateway.transit_gateway_id }}' - register: result - - - name: Assert success with transit_gateway_id filter - ansible.builtin.assert: - that: - - result.changed == false - - result.transit_gateways != [] - - - name: Test empty result set for non-existent tgw id via filter - amazon.aws.ec2_transit_gateway_info: - filters: - transit-gateway-id: tgw-00000011111111122 - register: result - - - name: Assert success with transit_gateway_id filter - ansible.builtin.assert: - that: - - result.changed == false - - result.transit_gateways == [] - - - name: Test NotFound exception caught and returned empty result set - amazon.aws.ec2_transit_gateway_info: - transit_gateway_id: tgw-00000011111111122 - register: result - - - name: Assert success with transit_gateway_id filter - ansible.builtin.assert: - that: - - result.changed == false - - result.transit_gateways == [] - - - name: Test success with multiple filters - amazon.aws.ec2_transit_gateway_info: - filters: - options.dns-support: enable - options.vpn-ecmp-support: enable - register: result - - - name: Assert success with transit_gateway_id filter - ansible.builtin.assert: - that: - - result.changed == false - - result.transit_gateways != [] + - name: Generate unique value for testing + ansible.builtin.set_fact: + tgw_description: "{{ resource_prefix }}-tgw" + + - name: Test create transit gateway without tags - check_mode + amazon.aws.ec2_transit_gateway: + description: "{{ tgw_description }}" + register: create_result + check_mode: true + + - name: Assert changed is True - check_mode + ansible.builtin.assert: + that: + - create_result.changed == True + - '"ec2:CreateTransitGateway" not in create_result.resource_actions' + + - name: Test create transit gateway without tags + amazon.aws.ec2_transit_gateway: + description: "{{ tgw_description }}" + register: create_result + + - name: Assert changed is True + ansible.builtin.assert: + that: + - create_result.changed == True + + - name: Test create transit gateway without tags - idempotency + amazon.aws.ec2_transit_gateway: + description: "{{ tgw_description }}" + register: create_result + + - name: Assert changed is True + ansible.builtin.assert: + that: + - create_result.changed == False + - '"ec2:CreateTransitGateway" not in create_result.resource_actions' + + - name: Test update transit gateway with tags by description - check_mode + amazon.aws.ec2_transit_gateway: + description: "{{ tgw_description }}" + tags: + Name: Ansible Test TGW + register: result + check_mode: true + + - name: Assert changed is True - check_mode + ansible.builtin.assert: + that: + - result.changed == True + - '"ec2:CreateTags" not in result.resource_actions' + + - name: Test update transit gateway with tags by description + amazon.aws.ec2_transit_gateway: + description: "{{ tgw_description }}" + tags: + Name: Ansible Test TGW + register: result + + - name: Assert changed is True + ansible.builtin.assert: + that: + - result.changed == True + - result.transit_gateway.tags | length == 1 + - "'Name' in result.transit_gateway.tags" + + - name: Test update transit gateway with tags by description - idempotency + amazon.aws.ec2_transit_gateway: + description: "{{ tgw_description }}" + tags: + Name: Ansible Test TGW + register: result + + - name: Assert changed is False - idempotency + ansible.builtin.assert: + that: + - result.changed == False + - result.transit_gateway.tags | length == 1 + - "'Name' in result.transit_gateway.tags" + + - name: Test update transit gateway with new tag and purge_tags false - check_mode + amazon.aws.ec2_transit_gateway: + transit_gateway_id: "{{ create_result.transit_gateway.transit_gateway_id }}" + purge_tags: false + tags: + status: ok to delete + register: result + check_mode: true + + - name: Assert changed is True and have 2 tags - check_mode + ansible.builtin.assert: + that: + - result.changed == True + - result.transit_gateway.tags | length != 2 + - "'Name' in result.transit_gateway.tags" + - '"ec2:CreateTags" not in result.resource_actions' + + - name: Test update transit gateway with new tag and purge_tags false + amazon.aws.ec2_transit_gateway: + transit_gateway_id: "{{ create_result.transit_gateway.transit_gateway_id }}" + purge_tags: false + tags: + status: ok to delete + register: result + + - name: Assert changed is True and have 2 tags + ansible.builtin.assert: + that: + - result.changed == True + - result.transit_gateway.tags | length == 2 + - "'Name' in result.transit_gateway.tags" + + - name: Test update transit gateway with new tag and purge_tags false - idempotency + amazon.aws.ec2_transit_gateway: + transit_gateway_id: "{{ create_result.transit_gateway.transit_gateway_id }}" + purge_tags: false + tags: + status: ok to delete + register: result + + - name: Assert changed is True and have 2 tags - idempotency + ansible.builtin.assert: + that: + - result.changed == False + - result.transit_gateway.tags | length == 2 + - "'Name' in result.transit_gateway.tags" + + - name: Test update transit gateway with purge_tags true - check_mode + amazon.aws.ec2_transit_gateway: + transit_gateway_id: "{{ create_result.transit_gateway.transit_gateway_id }}" + purge_tags: true + tags: + status: ok to delete + register: result + check_mode: true + + - name: Assert changed is True and TGW tag is absent - check_mode + ansible.builtin.assert: + that: + - result.changed == True + - result.transit_gateway.tags | length == 2 + - '"ec2:DeleteTags" not in result.resource_actions' + + - name: Test update transit gateway with purge_tags true + amazon.aws.ec2_transit_gateway: + transit_gateway_id: "{{ create_result.transit_gateway.transit_gateway_id }}" + purge_tags: true + tags: + status: ok to delete + register: result + + - name: Assert changed is True and TGW tag is absent + ansible.builtin.assert: + that: + - result.changed == True + - result.transit_gateway.tags | length == 1 + - "'Name' not in result.transit_gateway.tags" + + - name: Test idempotence + amazon.aws.ec2_transit_gateway: + description: "{{ tgw_description }}" + purge_tags: true + tags: + status: ok to delete + register: result + + - name: Assert changed is False + ansible.builtin.assert: + that: + - result.changed == False + + - name: Generate unique value for testing + ansible.builtin.set_fact: + tgw_description_multicast: "{{ resource_prefix }}-tgw-multicast" + + - name: Test create transit gateway with multicast enabled - check_mode + amazon.aws.ec2_transit_gateway: + description: "{{ tgw_description_multicast }}" + multicast_support: true + register: create_result + check_mode: true + + - name: Assert changed is True - check_mode + ansible.builtin.assert: + that: + - create_result.changed == True + - '"ec2:CreateTransitGateway" not in create_result.resource_actions' + + - name: Test create transit gateway with multicast enabled + amazon.aws.ec2_transit_gateway: + description: "{{ tgw_description_multicast }}" + multicast_support: true + register: create_result + + - name: Assert changed is True + ansible.builtin.assert: + that: + - create_result.changed == True + + - name: Test create transit gateway with multicast enabled - idempotency + amazon.aws.ec2_transit_gateway: + description: "{{ tgw_description_multicast }}" + multicast_support: true + register: create_result + + - name: Assert changed is True - idempotency + ansible.builtin.assert: + that: + - create_result.changed == False + + - name: Test success with filter + amazon.aws.ec2_transit_gateway_info: + filters: + options.multicast-support: enable + register: result + + - name: Assert success with multicast-support filter + ansible.builtin.assert: + that: + - result.transit_gateways != [] + + # ==== Combine ec2_transit_gateway_info ====================== + - name: Test success with no parameters + amazon.aws.ec2_transit_gateway_info: + register: result + - name: Assert success with no parameters + ansible.builtin.assert: + that: + - result.changed == false + - result.transit_gateways != [] + + - name: Test success with single filter + amazon.aws.ec2_transit_gateway_info: + filters: + transit-gateway-id: "{{ create_result.transit_gateway.transit_gateway_id }}" + register: result + + - name: Assert success with transit_gateway_id filter + ansible.builtin.assert: + that: + - result.changed == false + - result.transit_gateways != [] + + - name: Test empty result set for non-existent tgw id via filter + amazon.aws.ec2_transit_gateway_info: + filters: + transit-gateway-id: tgw-00000011111111122 + register: result + + - name: Assert success with transit_gateway_id filter + ansible.builtin.assert: + that: + - result.changed == false + - result.transit_gateways == [] + + - name: Test NotFound exception caught and returned empty result set + amazon.aws.ec2_transit_gateway_info: + transit_gateway_id: tgw-00000011111111122 + register: result + + - name: Assert success with transit_gateway_id filter + ansible.builtin.assert: + that: + - result.changed == false + - result.transit_gateways == [] + + - name: Test success with multiple filters + amazon.aws.ec2_transit_gateway_info: + filters: + options.dns-support: enable + options.vpn-ecmp-support: enable + register: result + + - name: Assert success with transit_gateway_id filter + ansible.builtin.assert: + that: + - result.changed == false + - result.transit_gateways != [] always: ###### TEARDOWN STARTS HERE ###### - - name: Delete transit gateway - amazon.aws.ec2_transit_gateway: - description: '{{ item }}' - state: absent - ignore_errors: true - loop: - - '{{ tgw_description }}' - - '{{ tgw_description_multicast }}' + - name: Delete transit gateway + amazon.aws.ec2_transit_gateway: + description: "{{ item }}" + state: absent + ignore_errors: true + loop: + - "{{ tgw_description }}" + - "{{ tgw_description_multicast }}" diff --git a/tests/integration/targets/ec2_transit_gateway_vpc_attachment/defaults/main.yml b/tests/integration/targets/ec2_transit_gateway_vpc_attachment/defaults/main.yml index ded63478d39..7b8984ccf67 100644 --- a/tests/integration/targets/ec2_transit_gateway_vpc_attachment/defaults/main.yml +++ b/tests/integration/targets/ec2_transit_gateway_vpc_attachment/defaults/main.yml @@ -1,26 +1,27 @@ +--- _resource_prefix: AnsibleTest -#_resource_prefix: 'AnsibleTest-{{ tiny_prefix }}-TGW-Attach' +# _resource_prefix: 'AnsibleTest-{{ tiny_prefix }}-TGW-Attach' cidr_prefix: 10.{{ 255 | random(seed=_resource_prefix) }} -tgw_name: '{{ _resource_prefix }}' -tgw_name_2: '{{ _resource_prefix }}-2' -vpc_name_a: '{{ _resource_prefix }}-1' -vpc_name_b: '{{ _resource_prefix }}-2' -vpc_cidr_a: '{{ cidr_prefix }}.1.0/24' -vpc_cidr_b: '{{ cidr_prefix }}.2.0/24' +tgw_name: "{{ _resource_prefix }}" +tgw_name_2: "{{ _resource_prefix }}-2" +vpc_name_a: "{{ _resource_prefix }}-1" +vpc_name_b: "{{ _resource_prefix }}-2" +vpc_cidr_a: "{{ cidr_prefix }}.1.0/24" +vpc_cidr_b: "{{ cidr_prefix }}.2.0/24" -subnet_cidr_a_1: '{{ cidr_prefix }}.1.0/26' -subnet_cidr_a_2: '{{ cidr_prefix }}.1.64/26' -subnet_cidr_a_3: '{{ cidr_prefix }}.1.128/26' -subnet_cidr_a_1a: '{{ cidr_prefix }}.1.192/26' -subnet_cidr_b_1: '{{ cidr_prefix }}.2.0/26' -subnet_cidr_b_2: '{{ cidr_prefix }}.2.64/26' +subnet_cidr_a_1: "{{ cidr_prefix }}.1.0/26" +subnet_cidr_a_2: "{{ cidr_prefix }}.1.64/26" +subnet_cidr_a_3: "{{ cidr_prefix }}.1.128/26" +subnet_cidr_a_1a: "{{ cidr_prefix }}.1.192/26" +subnet_cidr_b_1: "{{ cidr_prefix }}.2.0/26" +subnet_cidr_b_2: "{{ cidr_prefix }}.2.64/26" -subnet_name_a_1: '{{ _resource_prefix }}-a-1' -subnet_name_a_1a: '{{ _resource_prefix }}-a-1a' -subnet_name_a_2: '{{ _resource_prefix }}-a-2' -subnet_name_a_3: '{{ _resource_prefix }}-a-3' -subnet_name_b_1: '{{ _resource_prefix }}-b-1' -subnet_name_b_2: '{{ _resource_prefix }}-b-2' +subnet_name_a_1: "{{ _resource_prefix }}-a-1" +subnet_name_a_1a: "{{ _resource_prefix }}-a-1a" +subnet_name_a_2: "{{ _resource_prefix }}-a-2" +subnet_name_a_3: "{{ _resource_prefix }}-a-3" +subnet_name_b_1: "{{ _resource_prefix }}-b-1" +subnet_name_b_2: "{{ _resource_prefix }}-b-2" -attachment_name: '{{ _resource_prefix }}' -attachment_name_complex: '{{ _resource_prefix }}-complex' +attachment_name: "{{ _resource_prefix }}" +attachment_name_complex: "{{ _resource_prefix }}-complex" diff --git a/tests/integration/targets/ec2_transit_gateway_vpc_attachment/meta/main.yml b/tests/integration/targets/ec2_transit_gateway_vpc_attachment/meta/main.yml index 2bff8543af2..38772e94708 100644 --- a/tests/integration/targets/ec2_transit_gateway_vpc_attachment/meta/main.yml +++ b/tests/integration/targets/ec2_transit_gateway_vpc_attachment/meta/main.yml @@ -1,2 +1,3 @@ +--- dependencies: -- role: setup_ec2_facts + - role: setup_ec2_facts diff --git a/tests/integration/targets/ec2_transit_gateway_vpc_attachment/tasks/cleanup.yml b/tests/integration/targets/ec2_transit_gateway_vpc_attachment/tasks/cleanup.yml index 81aae1079a9..b1ad223a996 100644 --- a/tests/integration/targets/ec2_transit_gateway_vpc_attachment/tasks/cleanup.yml +++ b/tests/integration/targets/ec2_transit_gateway_vpc_attachment/tasks/cleanup.yml @@ -1,69 +1,70 @@ +--- - name: Describe all attachments on our VPC amazon.aws.ec2_transit_gateway_vpc_attachment_info: filters: - transit-gateway-id: '{{ tgw_id }}' + transit-gateway-id: "{{ tgw_id }}" register: info ignore_errors: true - name: Start deletion of all attachments amazon.aws.ec2_transit_gateway_vpc_attachment: state: absent - id: '{{ item.transit_gateway_attachment_id }}' + id: "{{ item.transit_gateway_attachment_id }}" wait: false - loop: '{{ info.attachments }}' + loop: "{{ info.attachments }}" ignore_errors: true - name: Wait for deletion of all attachments amazon.aws.ec2_transit_gateway_vpc_attachment: state: absent - id: '{{ item.transit_gateway_attachment_id }}' + id: "{{ item.transit_gateway_attachment_id }}" wait: true - loop: '{{ info.attachments }}' + loop: "{{ info.attachments }}" ignore_errors: true - name: Delete subnets amazon.aws.ec2_vpc_subnet: state: absent - cidr: '{{ item.cidr }}' - vpc_id: '{{ item.vpc_id }}' + cidr: "{{ item.cidr }}" + vpc_id: "{{ item.vpc_id }}" loop: - - cidr: '{{ subnet_cidr_a_1 }}' - vpc_id: '{{ vpc_id_a }}' - - cidr: '{{ subnet_cidr_a_2 }}' - vpc_id: '{{ vpc_id_a }}' - - cidr: '{{ subnet_cidr_a_3 }}' - vpc_id: '{{ vpc_id_a }}' - - cidr: '{{ subnet_cidr_b_1 }}' - vpc_id: '{{ vpc_id_b }}' - - cidr: '{{ subnet_cidr_b_2 }}' - vpc_id: '{{ vpc_id_b }}' - - cidr: '{{ subnet_cidr_a_1a }}' - vpc_id: '{{ vpc_id_a }}' + - cidr: "{{ subnet_cidr_a_1 }}" + vpc_id: "{{ vpc_id_a }}" + - cidr: "{{ subnet_cidr_a_2 }}" + vpc_id: "{{ vpc_id_a }}" + - cidr: "{{ subnet_cidr_a_3 }}" + vpc_id: "{{ vpc_id_a }}" + - cidr: "{{ subnet_cidr_b_1 }}" + vpc_id: "{{ vpc_id_b }}" + - cidr: "{{ subnet_cidr_b_2 }}" + vpc_id: "{{ vpc_id_b }}" + - cidr: "{{ subnet_cidr_a_1a }}" + vpc_id: "{{ vpc_id_a }}" ignore_errors: true - name: Delete VPCs to attach to TGW amazon.aws.ec2_vpc_net: state: absent - cidr_block: '{{ item.cidr }}' - name: '{{ item.name }}' + cidr_block: "{{ item.cidr }}" + name: "{{ item.name }}" loop: - - cidr: '{{ vpc_cidr_a }}' - name: '{{ vpc_name_a }}' - - cidr: '{{ vpc_cidr_b }}' - name: '{{ vpc_name_b }}' + - cidr: "{{ vpc_cidr_a }}" + name: "{{ vpc_name_a }}" + - cidr: "{{ vpc_cidr_b }}" + name: "{{ vpc_name_b }}" ignore_errors: true - name: Gather info about all transit gateways amazon.aws.ec2_transit_gateway_info: transit_gateway_ids: - - '{{ tgw_id }}' - - '{{ tgw_id_2 }}' + - "{{ tgw_id }}" + - "{{ tgw_id_2 }}" - name: Delete Transit Gateways amazon.aws.ec2_transit_gateway: state: absent - transit_gateway_id: '{{ item.tgw_id }}' + transit_gateway_id: "{{ item.tgw_id }}" loop: - - tgw_id: '{{ tgw_id }}' - - tgw_id: '{{ tgw_id_2 }}' + - tgw_id: "{{ tgw_id }}" + - tgw_id: "{{ tgw_id_2 }}" ignore_errors: true diff --git a/tests/integration/targets/ec2_transit_gateway_vpc_attachment/tasks/complex.yml b/tests/integration/targets/ec2_transit_gateway_vpc_attachment/tasks/complex.yml index 4fdd0ba6eb6..65477233931 100644 --- a/tests/integration/targets/ec2_transit_gateway_vpc_attachment/tasks/complex.yml +++ b/tests/integration/targets/ec2_transit_gateway_vpc_attachment/tasks/complex.yml @@ -1,3 +1,4 @@ +--- # Tests the setting of most parameters at the same time # # Note: Does not delete the attachment, so that there's a second VPC attached to @@ -7,450 +8,450 @@ # Creation - block: - - name: (CHECK_MODE) Create an attachment - complex parameters - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - name: '{{ attachment_name_complex }}' - transit_gateway: '{{ tgw_id }}' - subnets: - - '{{ subnet_id_b_1 }}' - - '{{ subnet_id_b_2 }}' - tags: - tagA: example Value - Tag_B: second value - appliance_mode_support: true - ipv6_support: true - register: complex_attach + - name: (CHECK_MODE) Create an attachment - complex parameters + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + name: "{{ attachment_name_complex }}" + transit_gateway: "{{ tgw_id }}" + subnets: + - "{{ subnet_id_b_1 }}" + - "{{ subnet_id_b_2 }}" + tags: + tagA: example Value + Tag_B: second value + appliance_mode_support: true + ipv6_support: true + register: complex_attach - - name: Assert that the test is successful - ansible.builtin.assert: - that: - - complex_attach is changed - - '"attachments" in complex_attach' - - complex_attach.attachments | length == 1 - - '"options" in attachment' - - '"subnet_ids" in attachment' - - '"tags" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == "enable" - - attachment.options.ipv6_support == "enable" - - attachment.subnet_ids | length == 2 - - subnet_id_b_1 in attachment.subnet_ids - - subnet_id_b_2 in attachment.subnet_ids - - attachment.tags | length == 3 - - '"Name" in attachment.tags' - - '"tagA" in attachment.tags' - - '"Tag_B" in attachment.tags' - - attachment.tags.Name == attachment_name_complex - - attachment.tags.tagA == "example Value" - - attachment.tags.Tag_B == "second value" - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_b - vars: - attachment: '{{ complex_attach.attachments[0] }}' + - name: Assert that the test is successful + ansible.builtin.assert: + that: + - complex_attach is changed + - '"attachments" in complex_attach' + - complex_attach.attachments | length == 1 + - '"options" in attachment' + - '"subnet_ids" in attachment' + - '"tags" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == "enable" + - attachment.options.ipv6_support == "enable" + - attachment.subnet_ids | length == 2 + - subnet_id_b_1 in attachment.subnet_ids + - subnet_id_b_2 in attachment.subnet_ids + - attachment.tags | length == 3 + - '"Name" in attachment.tags' + - '"tagA" in attachment.tags' + - '"Tag_B" in attachment.tags' + - attachment.tags.Name == attachment_name_complex + - attachment.tags.tagA == "example Value" + - attachment.tags.Tag_B == "second value" + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_b + vars: + attachment: "{{ complex_attach.attachments[0] }}" - - name: Create an attachment - complex parameters - amazon.aws.ec2_transit_gateway_vpc_attachment: - name: '{{ attachment_name_complex }}' - transit_gateway: '{{ tgw_id }}' - subnets: - - '{{ subnet_id_b_1 }}' - - '{{ subnet_id_b_2 }}' - tags: - tagA: example Value - Tag_B: second value - appliance_mode_support: true - ipv6_support: true - register: complex_attach + - name: Create an attachment - complex parameters + amazon.aws.ec2_transit_gateway_vpc_attachment: + name: "{{ attachment_name_complex }}" + transit_gateway: "{{ tgw_id }}" + subnets: + - "{{ subnet_id_b_1 }}" + - "{{ subnet_id_b_2 }}" + tags: + tagA: example Value + Tag_B: second value + appliance_mode_support: true + ipv6_support: true + register: complex_attach - - name: Assert that the test is successful - ansible.builtin.assert: - that: - - complex_attach is changed - - '"attachments" in complex_attach' - - complex_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 2 - - subnet_id_b_1 in attachment.subnet_ids - - subnet_id_b_2 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_b - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'enable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'enable' - - attachment.transit_gateway_attachment_id.startswith('tgw-attach-') - - attachment.state == 'available' - - attachment.tags | length == 3 - - '"Name" in attachment.tags' - - '"tagA" in attachment.tags' - - '"Tag_B" in attachment.tags' - - attachment.tags.Name == attachment_name_complex - - attachment.tags.tagA == "example Value" - - attachment.tags.Tag_B == "second value" - - attachment.vpc_owner_id == vpc_owner_b - vars: - attachment: '{{ complex_attach.attachments[0] }}' + - name: Assert that the test is successful + ansible.builtin.assert: + that: + - complex_attach is changed + - '"attachments" in complex_attach' + - complex_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 2 + - subnet_id_b_1 in attachment.subnet_ids + - subnet_id_b_2 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_b + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'enable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'enable' + - attachment.transit_gateway_attachment_id.startswith('tgw-attach-') + - attachment.state == 'available' + - attachment.tags | length == 3 + - '"Name" in attachment.tags' + - '"tagA" in attachment.tags' + - '"Tag_B" in attachment.tags' + - attachment.tags.Name == attachment_name_complex + - attachment.tags.tagA == "example Value" + - attachment.tags.Tag_B == "second value" + - attachment.vpc_owner_id == vpc_owner_b + vars: + attachment: "{{ complex_attach.attachments[0] }}" - - name: Save Attachment ID - set_fact: - complex_attachment_id: '{{ complex_attach.attachments[0].transit_gateway_attachment_id }}' + - name: Save Attachment ID + ansible.builtin.set_fact: + complex_attachment_id: "{{ complex_attach.attachments[0].transit_gateway_attachment_id }}" - - name: Gather information about the attachment - amazon.aws.ec2_transit_gateway_vpc_attachment_info: - filters: - transit-gateway-id: '{{ tgw_id }}' - register: info + - name: Gather information about the attachment + amazon.aws.ec2_transit_gateway_vpc_attachment_info: + filters: + transit-gateway-id: "{{ tgw_id }}" + register: info - - name: (CHECK_MODE) Create an attachment - complex parameters -- IDEMPOTENCY - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - name: '{{ attachment_name_complex }}' - transit_gateway: '{{ tgw_id }}' - subnets: - - '{{ subnet_id_b_1 }}' - - '{{ subnet_id_b_2 }}' - tags: - tagA: example Value - Tag_B: second value - appliance_mode_support: true - ipv6_support: true - register: complex_attach + - name: (CHECK_MODE) Create an attachment - complex parameters -- IDEMPOTENCY + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + name: "{{ attachment_name_complex }}" + transit_gateway: "{{ tgw_id }}" + subnets: + - "{{ subnet_id_b_1 }}" + - "{{ subnet_id_b_2 }}" + tags: + tagA: example Value + Tag_B: second value + appliance_mode_support: true + ipv6_support: true + register: complex_attach - - name: Assert that there is no change - ansible.builtin.assert: - that: - - complex_attach is not changed - - '"attachments" in complex_attach' - - complex_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 2 - - subnet_id_b_1 in attachment.subnet_ids - - subnet_id_b_2 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_b - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'enable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'enable' - - attachment.transit_gateway_attachment_id == complex_attachment_id - - attachment.state == 'available' - - attachment.tags | length == 3 - - '"Name" in attachment.tags' - - '"tagA" in attachment.tags' - - '"Tag_B" in attachment.tags' - - attachment.tags.Name == attachment_name_complex - - attachment.tags.tagA == "example Value" - - attachment.tags.Tag_B == "second value" - - attachment.vpc_owner_id == vpc_owner_b - vars: - attachment: '{{ complex_attach.attachments[0] }}' + - name: Assert that there is no change + ansible.builtin.assert: + that: + - complex_attach is not changed + - '"attachments" in complex_attach' + - complex_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 2 + - subnet_id_b_1 in attachment.subnet_ids + - subnet_id_b_2 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_b + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'enable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'enable' + - attachment.transit_gateway_attachment_id == complex_attachment_id + - attachment.state == 'available' + - attachment.tags | length == 3 + - '"Name" in attachment.tags' + - '"tagA" in attachment.tags' + - '"Tag_B" in attachment.tags' + - attachment.tags.Name == attachment_name_complex + - attachment.tags.tagA == "example Value" + - attachment.tags.Tag_B == "second value" + - attachment.vpc_owner_id == vpc_owner_b + vars: + attachment: "{{ complex_attach.attachments[0] }}" - - name: Create an attachment - complex parameters -- IDEMPOTENCY - amazon.aws.ec2_transit_gateway_vpc_attachment: - name: '{{ attachment_name_complex }}' - transit_gateway: '{{ tgw_id }}' - subnets: - - '{{ subnet_id_b_1 }}' - - '{{ subnet_id_b_2 }}' - tags: - tagA: example Value - Tag_B: second value - appliance_mode_support: true - ipv6_support: true - register: complex_attach + - name: Create an attachment - complex parameters -- IDEMPOTENCY + amazon.aws.ec2_transit_gateway_vpc_attachment: + name: "{{ attachment_name_complex }}" + transit_gateway: "{{ tgw_id }}" + subnets: + - "{{ subnet_id_b_1 }}" + - "{{ subnet_id_b_2 }}" + tags: + tagA: example Value + Tag_B: second value + appliance_mode_support: true + ipv6_support: true + register: complex_attach - - name: Assert that there is no change - ansible.builtin.assert: - that: - - complex_attach is not changed - - '"attachments" in complex_attach' - - complex_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 2 - - subnet_id_b_1 in attachment.subnet_ids - - subnet_id_b_2 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_b - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'enable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'enable' - - attachment.transit_gateway_attachment_id == complex_attachment_id - - attachment.state == 'available' - - attachment.tags | length == 3 - - '"Name" in attachment.tags' - - '"tagA" in attachment.tags' - - '"Tag_B" in attachment.tags' - - attachment.tags.Name == attachment_name_complex - - attachment.tags.tagA == "example Value" - - attachment.tags.Tag_B == "second value" - - attachment.vpc_owner_id == vpc_owner_b - vars: - attachment: '{{ complex_attach.attachments[0] }}' + - name: Assert that there is no change + ansible.builtin.assert: + that: + - complex_attach is not changed + - '"attachments" in complex_attach' + - complex_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 2 + - subnet_id_b_1 in attachment.subnet_ids + - subnet_id_b_2 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_b + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'enable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'enable' + - attachment.transit_gateway_attachment_id == complex_attachment_id + - attachment.state == 'available' + - attachment.tags | length == 3 + - '"Name" in attachment.tags' + - '"tagA" in attachment.tags' + - '"Tag_B" in attachment.tags' + - attachment.tags.Name == attachment_name_complex + - attachment.tags.tagA == "example Value" + - attachment.tags.Tag_B == "second value" + - attachment.vpc_owner_id == vpc_owner_b + vars: + attachment: "{{ complex_attach.attachments[0] }}" # ============================================================================= # Update - - name: (CHECK_MODE) Update an attachment - complex parameters - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - name: '{{ attachment_name_complex }}' - transit_gateway: '{{ tgw_id }}' - subnets: - - '{{ subnet_id_b_1 }}' - purge_subnets: true - tags: - tagC: '3' - Tag_D: Hello again dear world - purge_tags: false - dns_support: false - ipv6_support: false - register: complex_attach + - name: (CHECK_MODE) Update an attachment - complex parameters + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + name: "{{ attachment_name_complex }}" + transit_gateway: "{{ tgw_id }}" + subnets: + - "{{ subnet_id_b_1 }}" + purge_subnets: true + tags: + tagC: "3" + Tag_D: Hello again dear world + purge_tags: false + dns_support: false + ipv6_support: false + register: complex_attach - - name: Assert that the test is successful - ansible.builtin.assert: - that: - - complex_attach is changed - - '"attachments" in complex_attach' - - complex_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_b_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_b - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'enable' - - attachment.options.dns_support == 'disable' - - attachment.options.ipv6_support == 'disable' - - attachment.transit_gateway_attachment_id == complex_attachment_id - - attachment.state == 'available' - - attachment.tags | length == 5 - - '"Name" in attachment.tags' - - '"tagA" in attachment.tags' - - '"Tag_B" in attachment.tags' - - '"tagC" in attachment.tags' - - '"Tag_D" in attachment.tags' - - attachment.tags.Name == attachment_name_complex - - attachment.tags.tagA == "example Value" - - attachment.tags.Tag_B == "second value" - - attachment.tags.tagC == "3" - - attachment.tags.Tag_D == "Hello again dear world" - - attachment.vpc_owner_id == vpc_owner_b - vars: - attachment: '{{ complex_attach.attachments[0] }}' + - name: Assert that the test is successful + ansible.builtin.assert: + that: + - complex_attach is changed + - '"attachments" in complex_attach' + - complex_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_b_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_b + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'enable' + - attachment.options.dns_support == 'disable' + - attachment.options.ipv6_support == 'disable' + - attachment.transit_gateway_attachment_id == complex_attachment_id + - attachment.state == 'available' + - attachment.tags | length == 5 + - '"Name" in attachment.tags' + - '"tagA" in attachment.tags' + - '"Tag_B" in attachment.tags' + - '"tagC" in attachment.tags' + - '"Tag_D" in attachment.tags' + - attachment.tags.Name == attachment_name_complex + - attachment.tags.tagA == "example Value" + - attachment.tags.Tag_B == "second value" + - attachment.tags.tagC == "3" + - attachment.tags.Tag_D == "Hello again dear world" + - attachment.vpc_owner_id == vpc_owner_b + vars: + attachment: "{{ complex_attach.attachments[0] }}" - - name: Update an attachment - complex parameters - amazon.aws.ec2_transit_gateway_vpc_attachment: - name: '{{ attachment_name_complex }}' - transit_gateway: '{{ tgw_id }}' - subnets: - - '{{ subnet_id_b_1 }}' - purge_subnets: true - tags: - tagC: '3' - Tag_D: Hello again dear world - purge_tags: false - dns_support: false - ipv6_support: false - register: complex_attach + - name: Update an attachment - complex parameters + amazon.aws.ec2_transit_gateway_vpc_attachment: + name: "{{ attachment_name_complex }}" + transit_gateway: "{{ tgw_id }}" + subnets: + - "{{ subnet_id_b_1 }}" + purge_subnets: true + tags: + tagC: "3" + Tag_D: Hello again dear world + purge_tags: false + dns_support: false + ipv6_support: false + register: complex_attach - - name: Assert that the test is successful - ansible.builtin.assert: - that: - - complex_attach is changed - - '"attachments" in complex_attach' - - complex_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_b_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_b - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'enable' - - attachment.options.dns_support == 'disable' - - attachment.options.ipv6_support == 'disable' - - attachment.transit_gateway_attachment_id == complex_attachment_id - - attachment.state == 'available' - - attachment.tags | length == 5 - - '"Name" in attachment.tags' - - '"tagA" in attachment.tags' - - '"Tag_B" in attachment.tags' - - '"tagC" in attachment.tags' - - '"Tag_D" in attachment.tags' - - attachment.tags.Name == attachment_name_complex - - attachment.tags.tagA == "example Value" - - attachment.tags.Tag_B == "second value" - - attachment.tags.tagC == "3" - - attachment.tags.Tag_D == "Hello again dear world" - - attachment.vpc_owner_id == vpc_owner_b - vars: - attachment: '{{ complex_attach.attachments[0] }}' + - name: Assert that the test is successful + ansible.builtin.assert: + that: + - complex_attach is changed + - '"attachments" in complex_attach' + - complex_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_b_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_b + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'enable' + - attachment.options.dns_support == 'disable' + - attachment.options.ipv6_support == 'disable' + - attachment.transit_gateway_attachment_id == complex_attachment_id + - attachment.state == 'available' + - attachment.tags | length == 5 + - '"Name" in attachment.tags' + - '"tagA" in attachment.tags' + - '"Tag_B" in attachment.tags' + - '"tagC" in attachment.tags' + - '"Tag_D" in attachment.tags' + - attachment.tags.Name == attachment_name_complex + - attachment.tags.tagA == "example Value" + - attachment.tags.Tag_B == "second value" + - attachment.tags.tagC == "3" + - attachment.tags.Tag_D == "Hello again dear world" + - attachment.vpc_owner_id == vpc_owner_b + vars: + attachment: "{{ complex_attach.attachments[0] }}" - - name: (CHECK_MODE) Update an attachment - complex parameters -- IDEMPOTENCY - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - name: '{{ attachment_name_complex }}' - transit_gateway: '{{ tgw_id }}' - subnets: - - '{{ subnet_id_b_1 }}' - purge_subnets: true - tags: - tagC: '3' - Tag_D: Hello again dear world - purge_tags: false - dns_support: false - ipv6_support: false - register: complex_attach + - name: (CHECK_MODE) Update an attachment - complex parameters -- IDEMPOTENCY + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + name: "{{ attachment_name_complex }}" + transit_gateway: "{{ tgw_id }}" + subnets: + - "{{ subnet_id_b_1 }}" + purge_subnets: true + tags: + tagC: "3" + Tag_D: Hello again dear world + purge_tags: false + dns_support: false + ipv6_support: false + register: complex_attach - - name: Assert that there is no change - ansible.builtin.assert: - that: - - complex_attach is not changed - - '"attachments" in complex_attach' - - complex_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_b_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_b - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'enable' - - attachment.options.dns_support == 'disable' - - attachment.options.ipv6_support == 'disable' - - attachment.transit_gateway_attachment_id == complex_attachment_id - - attachment.state == 'available' - - attachment.tags | length == 5 - - '"Name" in attachment.tags' - - '"tagA" in attachment.tags' - - '"Tag_B" in attachment.tags' - - '"tagC" in attachment.tags' - - '"Tag_D" in attachment.tags' - - attachment.tags.Name == attachment_name_complex - - attachment.tags.tagA == "example Value" - - attachment.tags.Tag_B == "second value" - - attachment.tags.tagC == "3" - - attachment.tags.Tag_D == "Hello again dear world" - - attachment.vpc_owner_id == vpc_owner_b - vars: - attachment: '{{ complex_attach.attachments[0] }}' + - name: Assert that there is no change + ansible.builtin.assert: + that: + - complex_attach is not changed + - '"attachments" in complex_attach' + - complex_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_b_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_b + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'enable' + - attachment.options.dns_support == 'disable' + - attachment.options.ipv6_support == 'disable' + - attachment.transit_gateway_attachment_id == complex_attachment_id + - attachment.state == 'available' + - attachment.tags | length == 5 + - '"Name" in attachment.tags' + - '"tagA" in attachment.tags' + - '"Tag_B" in attachment.tags' + - '"tagC" in attachment.tags' + - '"Tag_D" in attachment.tags' + - attachment.tags.Name == attachment_name_complex + - attachment.tags.tagA == "example Value" + - attachment.tags.Tag_B == "second value" + - attachment.tags.tagC == "3" + - attachment.tags.Tag_D == "Hello again dear world" + - attachment.vpc_owner_id == vpc_owner_b + vars: + attachment: "{{ complex_attach.attachments[0] }}" - - name: Update an attachment - complex parameters -- IDEMPOTENCY - amazon.aws.ec2_transit_gateway_vpc_attachment: - name: '{{ attachment_name_complex }}' - transit_gateway: '{{ tgw_id }}' - subnets: - - '{{ subnet_id_b_1 }}' - purge_subnets: true - tags: - tagC: '3' - Tag_D: Hello again dear world - purge_tags: false - dns_support: false - ipv6_support: false - register: complex_attach + - name: Update an attachment - complex parameters -- IDEMPOTENCY + amazon.aws.ec2_transit_gateway_vpc_attachment: + name: "{{ attachment_name_complex }}" + transit_gateway: "{{ tgw_id }}" + subnets: + - "{{ subnet_id_b_1 }}" + purge_subnets: true + tags: + tagC: "3" + Tag_D: Hello again dear world + purge_tags: false + dns_support: false + ipv6_support: false + register: complex_attach - - name: Assert that there is no change - ansible.builtin.assert: - that: - - complex_attach is not changed - - '"attachments" in complex_attach' - - complex_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_b_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_b - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'enable' - - attachment.options.dns_support == 'disable' - - attachment.options.ipv6_support == 'disable' - - attachment.transit_gateway_attachment_id == complex_attachment_id - - attachment.state == 'available' - - attachment.tags | length == 5 - - '"Name" in attachment.tags' - - '"tagA" in attachment.tags' - - '"Tag_B" in attachment.tags' - - '"tagC" in attachment.tags' - - '"Tag_D" in attachment.tags' - - attachment.tags.Name == attachment_name_complex - - attachment.tags.tagA == "example Value" - - attachment.tags.Tag_B == "second value" - - attachment.tags.tagC == "3" - - attachment.tags.Tag_D == "Hello again dear world" - - attachment.vpc_owner_id == vpc_owner_b - vars: - attachment: '{{ complex_attach.attachments[0] }}' + - name: Assert that there is no change + ansible.builtin.assert: + that: + - complex_attach is not changed + - '"attachments" in complex_attach' + - complex_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_b_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_b + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'enable' + - attachment.options.dns_support == 'disable' + - attachment.options.ipv6_support == 'disable' + - attachment.transit_gateway_attachment_id == complex_attachment_id + - attachment.state == 'available' + - attachment.tags | length == 5 + - '"Name" in attachment.tags' + - '"tagA" in attachment.tags' + - '"Tag_B" in attachment.tags' + - '"tagC" in attachment.tags' + - '"Tag_D" in attachment.tags' + - attachment.tags.Name == attachment_name_complex + - attachment.tags.tagA == "example Value" + - attachment.tags.Tag_B == "second value" + - attachment.tags.tagC == "3" + - attachment.tags.Tag_D == "Hello again dear world" + - attachment.vpc_owner_id == vpc_owner_b + vars: + attachment: "{{ complex_attach.attachments[0] }}" diff --git a/tests/integration/targets/ec2_transit_gateway_vpc_attachment/tasks/main.yml b/tests/integration/targets/ec2_transit_gateway_vpc_attachment/tasks/main.yml index ecec94bff5a..64654214786 100644 --- a/tests/integration/targets/ec2_transit_gateway_vpc_attachment/tasks/main.yml +++ b/tests/integration/targets/ec2_transit_gateway_vpc_attachment/tasks/main.yml @@ -1,21 +1,17 @@ -- name: ec2_transit_gateway_vpc_attachment integration tests +--- +- name: Ec2_transit_gateway_vpc_attachment 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: # Prepares various resources - - include_tasks: setup.yml - - # Tests create / update on parameters simulatniously - - include_tasks: complex.yml - - # Tests create / update / delete on individual parameters - - include_tasks: simple.yml - + - ansible.builtin.include_tasks: setup.yml + - ansible.builtin.include_tasks: complex.yml + - ansible.builtin.include_tasks: simple.yml always: # Cleanup after ourselves - - include_tasks: cleanup.yml + - ansible.builtin.include_tasks: cleanup.yml diff --git a/tests/integration/targets/ec2_transit_gateway_vpc_attachment/tasks/setup.yml b/tests/integration/targets/ec2_transit_gateway_vpc_attachment/tasks/setup.yml index d52875f1537..3bef366dfff 100644 --- a/tests/integration/targets/ec2_transit_gateway_vpc_attachment/tasks/setup.yml +++ b/tests/integration/targets/ec2_transit_gateway_vpc_attachment/tasks/setup.yml @@ -1,100 +1,101 @@ +--- - name: Pick 2 AZs available for use - set_fact: - subnet_az_a_1: '{{ ec2_availability_zone_names[0] }}' - subnet_az_a_1a: '{{ ec2_availability_zone_names[0] }}' - subnet_az_a_2: '{{ ec2_availability_zone_names[1] }}' - subnet_az_a_3: '{{ ec2_availability_zone_names[2] }}' - subnet_az_b_1: '{{ ec2_availability_zone_names[0] }}' - subnet_az_b_2: '{{ ec2_availability_zone_names[1] }}' + ansible.builtin.set_fact: + subnet_az_a_1: "{{ ec2_availability_zone_names[0] }}" + subnet_az_a_1a: "{{ ec2_availability_zone_names[0] }}" + subnet_az_a_2: "{{ ec2_availability_zone_names[1] }}" + subnet_az_a_3: "{{ ec2_availability_zone_names[2] }}" + subnet_az_b_1: "{{ ec2_availability_zone_names[0] }}" + subnet_az_b_2: "{{ ec2_availability_zone_names[1] }}" - name: Create Transit Gateways amazon.aws.ec2_transit_gateway: - description: '{{ item.description }}' + description: "{{ item.description }}" tags: - Name: '{{ item.name }}' + Name: "{{ item.name }}" loop: - - description: Transit Gateway for testing ec2_transit_gateway_attachment - name: '{{ tgw_name }}' - - description: Second Transit Gateway for testing ec2_transit_gateway_attachment - name: '{{ tgw_name_2 }}' + - description: Transit Gateway for testing ec2_transit_gateway_attachment + name: "{{ tgw_name }}" + - description: Second Transit Gateway for testing ec2_transit_gateway_attachment + name: "{{ tgw_name_2 }}" register: create_tgws - name: Create VPCs to attach to TGW amazon.aws.ec2_vpc_net: - cidr_block: '{{ item.cidr }}' - name: '{{ item.name }}' + cidr_block: "{{ item.cidr }}" + name: "{{ item.name }}" ipv6_cidr: true loop: - - cidr: '{{ vpc_cidr_a }}' - name: '{{ vpc_name_a }}' - - cidr: '{{ vpc_cidr_b }}' - name: '{{ vpc_name_b }}' + - cidr: "{{ vpc_cidr_a }}" + name: "{{ vpc_name_a }}" + - cidr: "{{ vpc_cidr_b }}" + name: "{{ vpc_name_b }}" register: create_vpcs -- set_fact: - tgw_id: '{{ create_tgws.results[0].transit_gateway.transit_gateway_id }}' - tgw_id_2: '{{ create_tgws.results[1].transit_gateway.transit_gateway_id }}' - vpc_id_a: '{{ vpc_a.id }}' - vpc_id_b: '{{ vpc_b.id }}' - vpc_owner_a: '{{ vpc_a.owner_id }}' - vpc_owner_b: '{{ vpc_b.owner_id }}' - subnet_ipv6_a_1: '{{ vpc_ipv6_a | replace("0::/56","0::/64") }}' - subnet_ipv6_a_2: '{{ vpc_ipv6_a | replace("0::/56","1::/64") }}' - subnet_ipv6_a_3: '{{ vpc_ipv6_a | replace("0::/56","2::/64") }}' - subnet_ipv6_a_1a: '{{ vpc_ipv6_a | replace("0::/56","3::/64") }}' - subnet_ipv6_b_1: '{{ vpc_ipv6_b | replace("0::/56","0::/64") }}' - subnet_ipv6_b_2: '{{ vpc_ipv6_b | replace("0::/56","1::/64") }}' +- ansible.builtin.set_fact: + tgw_id: "{{ create_tgws.results[0].transit_gateway.transit_gateway_id }}" + tgw_id_2: "{{ create_tgws.results[1].transit_gateway.transit_gateway_id }}" + vpc_id_a: "{{ vpc_a.id }}" + vpc_id_b: "{{ vpc_b.id }}" + vpc_owner_a: "{{ vpc_a.owner_id }}" + vpc_owner_b: "{{ vpc_b.owner_id }}" + subnet_ipv6_a_1: '{{ vpc_ipv6_a | replace("0::/56", "0::/64") }}' + subnet_ipv6_a_2: '{{ vpc_ipv6_a | replace("0::/56", "1::/64") }}' + subnet_ipv6_a_3: '{{ vpc_ipv6_a | replace("0::/56", "2::/64") }}' + subnet_ipv6_a_1a: '{{ vpc_ipv6_a | replace("0::/56", "3::/64") }}' + subnet_ipv6_b_1: '{{ vpc_ipv6_b | replace("0::/56", "0::/64") }}' + subnet_ipv6_b_2: '{{ vpc_ipv6_b | replace("0::/56", "1::/64") }}' vars: - vpc_a: '{{ create_vpcs.results[0].vpc }}' - vpc_b: '{{ create_vpcs.results[1].vpc }}' - vpc_ipv6_a: '{{ vpc_a.ipv6_cidr_block_association_set[0].ipv6_cidr_block }}' - vpc_ipv6_b: '{{ vpc_b.ipv6_cidr_block_association_set[0].ipv6_cidr_block }}' + vpc_a: "{{ create_vpcs.results[0].vpc }}" + vpc_b: "{{ create_vpcs.results[1].vpc }}" + vpc_ipv6_a: "{{ vpc_a.ipv6_cidr_block_association_set[0].ipv6_cidr_block }}" + vpc_ipv6_b: "{{ vpc_b.ipv6_cidr_block_association_set[0].ipv6_cidr_block }}" - name: Create subnets amazon.aws.ec2_vpc_subnet: - az: '{{ item.az }}' - cidr: '{{ item.cidr }}' - ipv6_cidr: '{{ item.ipv6_cidr }}' + az: "{{ item.az }}" + cidr: "{{ item.cidr }}" + ipv6_cidr: "{{ item.ipv6_cidr }}" tags: - Name: '{{ item.name }}' - vpc_id: '{{ item.vpc_id }}' + Name: "{{ item.name }}" + vpc_id: "{{ item.vpc_id }}" loop: - - az: '{{ subnet_az_a_1 }}' - cidr: '{{ subnet_cidr_a_1 }}' - ipv6_cidr: '{{ subnet_ipv6_a_1 }}' - vpc_id: '{{ vpc_id_a }}' - name: '{{ subnet_name_a_1 }}' - - az: '{{ subnet_az_a_2 }}' - cidr: '{{ subnet_cidr_a_2 }}' - ipv6_cidr: '{{ subnet_ipv6_a_2 }}' - vpc_id: '{{ vpc_id_a }}' - name: '{{ subnet_name_a_2 }}' - - az: '{{ subnet_az_a_3 }}' - cidr: '{{ subnet_cidr_a_3 }}' - ipv6_cidr: '{{ subnet_ipv6_a_3 }}' - vpc_id: '{{ vpc_id_a }}' - name: '{{ subnet_name_a_3 }}' - - az: '{{ subnet_az_b_1 }}' - cidr: '{{ subnet_cidr_b_1 }}' - ipv6_cidr: '{{ subnet_ipv6_b_1 }}' - vpc_id: '{{ vpc_id_b }}' - name: '{{ subnet_name_b_1 }}' - - az: '{{ subnet_az_b_2 }}' - cidr: '{{ subnet_cidr_b_2 }}' - ipv6_cidr: '{{ subnet_ipv6_b_2 }}' - vpc_id: '{{ vpc_id_b }}' - name: '{{ subnet_name_b_2 }}' - - az: '{{ subnet_az_a_1a }}' - cidr: '{{ subnet_cidr_a_1a }}' - ipv6_cidr: '{{ subnet_ipv6_a_1a }}' - vpc_id: '{{ vpc_id_a }}' - name: '{{ subnet_name_a_1a }}' + - az: "{{ subnet_az_a_1 }}" + cidr: "{{ subnet_cidr_a_1 }}" + ipv6_cidr: "{{ subnet_ipv6_a_1 }}" + vpc_id: "{{ vpc_id_a }}" + name: "{{ subnet_name_a_1 }}" + - az: "{{ subnet_az_a_2 }}" + cidr: "{{ subnet_cidr_a_2 }}" + ipv6_cidr: "{{ subnet_ipv6_a_2 }}" + vpc_id: "{{ vpc_id_a }}" + name: "{{ subnet_name_a_2 }}" + - az: "{{ subnet_az_a_3 }}" + cidr: "{{ subnet_cidr_a_3 }}" + ipv6_cidr: "{{ subnet_ipv6_a_3 }}" + vpc_id: "{{ vpc_id_a }}" + name: "{{ subnet_name_a_3 }}" + - az: "{{ subnet_az_b_1 }}" + cidr: "{{ subnet_cidr_b_1 }}" + ipv6_cidr: "{{ subnet_ipv6_b_1 }}" + vpc_id: "{{ vpc_id_b }}" + name: "{{ subnet_name_b_1 }}" + - az: "{{ subnet_az_b_2 }}" + cidr: "{{ subnet_cidr_b_2 }}" + ipv6_cidr: "{{ subnet_ipv6_b_2 }}" + vpc_id: "{{ vpc_id_b }}" + name: "{{ subnet_name_b_2 }}" + - az: "{{ subnet_az_a_1a }}" + cidr: "{{ subnet_cidr_a_1a }}" + ipv6_cidr: "{{ subnet_ipv6_a_1a }}" + vpc_id: "{{ vpc_id_a }}" + name: "{{ subnet_name_a_1a }}" register: create_subnets -- set_fact: - subnet_id_a_1: '{{ create_subnets.results[0].subnet.id }}' - subnet_id_a_2: '{{ create_subnets.results[1].subnet.id }}' - subnet_id_a_3: '{{ create_subnets.results[2].subnet.id }}' - subnet_id_b_1: '{{ create_subnets.results[3].subnet.id }}' - subnet_id_b_2: '{{ create_subnets.results[4].subnet.id }}' - subnet_id_a_1a: '{{ create_subnets.results[5].subnet.id }}' +- ansible.builtin.set_fact: + subnet_id_a_1: "{{ create_subnets.results[0].subnet.id }}" + subnet_id_a_2: "{{ create_subnets.results[1].subnet.id }}" + subnet_id_a_3: "{{ create_subnets.results[2].subnet.id }}" + subnet_id_b_1: "{{ create_subnets.results[3].subnet.id }}" + subnet_id_b_2: "{{ create_subnets.results[4].subnet.id }}" + subnet_id_a_1a: "{{ create_subnets.results[5].subnet.id }}" diff --git a/tests/integration/targets/ec2_transit_gateway_vpc_attachment/tasks/simple.yml b/tests/integration/targets/ec2_transit_gateway_vpc_attachment/tasks/simple.yml index 9a2ff5aa211..06bbd2d202d 100644 --- a/tests/integration/targets/ec2_transit_gateway_vpc_attachment/tasks/simple.yml +++ b/tests/integration/targets/ec2_transit_gateway_vpc_attachment/tasks/simple.yml @@ -1,3706 +1,3706 @@ +--- # ============================================================================= # Creation - block: - - name: (CHECK_MODE) Create an attachment - minimal parameters - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - transit_gateway: '{{ tgw_id }}' - subnets: - - '{{ subnet_id_a_1 }}' - register: simple_attach - - - name: Assert that attachment parameters are returned in CHECK_MODE - ansible.builtin.assert: - that: - - simple_attach is changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: Create an attachment - minimal parameters - amazon.aws.ec2_transit_gateway_vpc_attachment: - transit_gateway: '{{ tgw_id }}' - subnets: - - '{{ subnet_id_a_1 }}' - register: simple_attach - - - name: Assert that the create attachment is successful - ansible.builtin.assert: - that: - - simple_attach is changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.transit_gateway_attachment_id.startswith('tgw-attach-') - - attachment.state == 'available' - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: Save Attachment ID - ansible.builtin.set_fact: - simple_attachment_id: '{{ simple_attach.attachments[0].transit_gateway_attachment_id - }}' - - - name: (CHECK_MODE) Create an attachment - minimal parameters -- IDEMPOTENCY - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - transit_gateway: '{{ tgw_id }}' - subnets: - - '{{ subnet_id_a_1 }}' - register: simple_attach - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - simple_attach is not changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: Create an attachment - minimal parameters -- IDEMPOTENCY - amazon.aws.ec2_transit_gateway_vpc_attachment: - transit_gateway: '{{ tgw_id }}' - subnets: - - '{{ subnet_id_a_1 }}' - register: simple_attach - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - simple_attach is not changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' + - name: (CHECK_MODE) Create an attachment - minimal parameters + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + transit_gateway: "{{ tgw_id }}" + subnets: + - "{{ subnet_id_a_1 }}" + register: simple_attach + + - name: Assert that attachment parameters are returned in CHECK_MODE + ansible.builtin.assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: Create an attachment - minimal parameters + amazon.aws.ec2_transit_gateway_vpc_attachment: + transit_gateway: "{{ tgw_id }}" + subnets: + - "{{ subnet_id_a_1 }}" + register: simple_attach + + - name: Assert that the create attachment is successful + ansible.builtin.assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.transit_gateway_attachment_id.startswith('tgw-attach-') + - attachment.state == 'available' + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: Save Attachment ID + ansible.builtin.set_fact: + simple_attachment_id: "{{ simple_attach.attachments[0].transit_gateway_attachment_id }}" + + - name: (CHECK_MODE) Create an attachment - minimal parameters -- IDEMPOTENCY + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + transit_gateway: "{{ tgw_id }}" + subnets: + - "{{ subnet_id_a_1 }}" + register: simple_attach + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: Create an attachment - minimal parameters -- IDEMPOTENCY + amazon.aws.ec2_transit_gateway_vpc_attachment: + transit_gateway: "{{ tgw_id }}" + subnets: + - "{{ subnet_id_a_1 }}" + register: simple_attach + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" # ===== - - name: (CHECK_MODE) By Id - minimal parameters -- IDEMPOTENCY - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - subnets: - - '{{ subnet_id_a_1 }}' - register: simple_attach - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - simple_attach is not changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: By Id - minimal parameters -- IDEMPOTENCY - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - subnets: - - '{{ subnet_id_a_1 }}' - register: simple_attach - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - simple_attach is not changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' + - name: (CHECK_MODE) By Id - minimal parameters -- IDEMPOTENCY + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + subnets: + - "{{ subnet_id_a_1 }}" + register: simple_attach + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: By Id - minimal parameters -- IDEMPOTENCY + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + subnets: + - "{{ subnet_id_a_1 }}" + register: simple_attach + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" # ============================================================================= # Set a name - - name: (CHECK_MODE) Set name - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - name: '{{ attachment_name }}' - register: simple_attach - - - name: Assert that the attachment parameters are returned in CHECK_MODE - ansible.builtin.assert: - that: - - simple_attach is changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 1 - - '"Name" in attachment.tags' - - attachment.tags.Name == attachment_name - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: Set name - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - name: '{{ attachment_name }}' - register: simple_attach - - - name: Assert that 'Set name' is successful - ansible.builtin.assert: - that: - - simple_attach is changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 1 - - '"Name" in attachment.tags' - - attachment.tags.Name == attachment_name - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: (CHECK_MODE) Set name -- IDEMPOTENCY - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - name: '{{ attachment_name }}' - register: simple_attach - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - simple_attach is not changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 1 - - '"Name" in attachment.tags' - - attachment.tags.Name == attachment_name - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: Set name -- IDEMPOTENCY - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - name: '{{ attachment_name }}' - register: simple_attach - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - simple_attach is not changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 1 - - '"Name" in attachment.tags' - - attachment.tags.Name == attachment_name - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' + - name: (CHECK_MODE) Set name + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + name: "{{ attachment_name }}" + register: simple_attach + + - name: Assert that the attachment parameters are returned in CHECK_MODE + ansible.builtin.assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 1 + - '"Name" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: Set name + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + name: "{{ attachment_name }}" + register: simple_attach + + - name: Assert that 'Set name' is successful + ansible.builtin.assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 1 + - '"Name" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: (CHECK_MODE) Set name -- IDEMPOTENCY + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + name: "{{ attachment_name }}" + register: simple_attach + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 1 + - '"Name" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: Set name -- IDEMPOTENCY + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + name: "{{ attachment_name }}" + register: simple_attach + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 1 + - '"Name" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" # ===== - - name: (CHECK_MODE) By Name - minimal parameters -- IDEMPOTENCY - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - name: '{{ attachment_name }}' - subnets: - - '{{ subnet_id_a_1 }}' - register: simple_attach - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - simple_attach is not changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 1 - - '"Name" in attachment.tags' - - attachment.tags.Name == attachment_name - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: By Name - minimal parameters -- IDEMPOTENCY - amazon.aws.ec2_transit_gateway_vpc_attachment: - name: '{{ attachment_name }}' - subnets: - - '{{ subnet_id_a_1 }}' - register: simple_attach - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - simple_attach is not changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 1 - - '"Name" in attachment.tags' - - attachment.tags.Name == attachment_name - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' + - name: (CHECK_MODE) By Name - minimal parameters -- IDEMPOTENCY + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + name: "{{ attachment_name }}" + subnets: + - "{{ subnet_id_a_1 }}" + register: simple_attach + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 1 + - '"Name" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: By Name - minimal parameters -- IDEMPOTENCY + amazon.aws.ec2_transit_gateway_vpc_attachment: + name: "{{ attachment_name }}" + subnets: + - "{{ subnet_id_a_1 }}" + register: simple_attach + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 1 + - '"Name" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" # ============================================================================= # Describe - - name: Describe all attachments - amazon.aws.ec2_transit_gateway_vpc_attachment_info: - register: info - - - name: Assert that the transit_gateway_vpc_attachment_info is returned sucessfully - ansible.builtin.assert: - that: - - info is not changed - - '"attachments" in info' - - info.attachments | length >= 2 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length >= 1 - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - '"Name" in attachment.tags' - vars: - attachment: '{{ info.attachments[0] }}' - - - name: Describe attachments on a specific VPC - amazon.aws.ec2_transit_gateway_vpc_attachment_info: - filters: - transit-gateway-id: '{{ tgw_id }}' - register: info - - - name: Assert that the returned info is correct - ansible.builtin.assert: - that: - - info is not changed - - '"attachments" in info' - - info.attachments | length == 2 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length >= 1 - - attachment.transit_gateway_id == tgw_id - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - '"Name" in attachment.tags' - vars: - attachment: '{{ info.attachments[0] }}' - - - name: Describe attachment with a specific name - amazon.aws.ec2_transit_gateway_vpc_attachment_info: - name: '{{ attachment_name }}' - register: info - - - name: Assert that the returned info is correct - ansible.builtin.assert: - that: - - info is not changed - - '"attachments" in info' - - info.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 1 - - '"Name" in attachment.tags' - - attachment.tags.Name == attachment_name - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ info.attachments[0] }}' - - - name: Describe attachment by ID - amazon.aws.ec2_transit_gateway_vpc_attachment_info: - id: '{{ simple_attachment_id }}' - register: info - - - name: Assert that the returned info is correct - ansible.builtin.assert: - that: - - info is not changed - - '"attachments" in info' - - info.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 1 - - '"Name" in attachment.tags' - - attachment.tags.Name == attachment_name - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ info.attachments[0] }}' + - name: Describe all attachments + amazon.aws.ec2_transit_gateway_vpc_attachment_info: + register: info + + - name: Assert that the transit_gateway_vpc_attachment_info is returned sucessfully + ansible.builtin.assert: + that: + - info is not changed + - '"attachments" in info' + - info.attachments | length >= 2 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length >= 1 + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - '"Name" in attachment.tags' + vars: + attachment: "{{ info.attachments[0] }}" + + - name: Describe attachments on a specific VPC + amazon.aws.ec2_transit_gateway_vpc_attachment_info: + filters: + transit-gateway-id: "{{ tgw_id }}" + register: info + + - name: Assert that the returned info is correct + ansible.builtin.assert: + that: + - info is not changed + - '"attachments" in info' + - info.attachments | length == 2 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length >= 1 + - attachment.transit_gateway_id == tgw_id + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - '"Name" in attachment.tags' + vars: + attachment: "{{ info.attachments[0] }}" + + - name: Describe attachment with a specific name + amazon.aws.ec2_transit_gateway_vpc_attachment_info: + name: "{{ attachment_name }}" + register: info + + - name: Assert that the returned info is correct + ansible.builtin.assert: + that: + - info is not changed + - '"attachments" in info' + - info.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 1 + - '"Name" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ info.attachments[0] }}" + + - name: Describe attachment by ID + amazon.aws.ec2_transit_gateway_vpc_attachment_info: + id: "{{ simple_attachment_id }}" + register: info + + - name: Assert that the returned info is correct + ansible.builtin.assert: + that: + - info is not changed + - '"attachments" in info' + - info.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 1 + - '"Name" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ info.attachments[0] }}" # ============================================================================= # Tag attachment - - name: (CHECK_MODE) Set tags - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - name: '{{ attachment_name }}' - tags: - CamelCase: CamelCaseValue - pascalCase: pascalCaseValue - snake_case: snake_case_value - Tag with Space: value with space - register: simple_attach - - - name: Assert that 'Set tags' is successful - ansible.builtin.assert: - that: - - simple_attach is changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 5 - - '"Name" in attachment.tags' - - '"CamelCase" in attachment.tags' - - '"pascalCase" in attachment.tags' - - '"snake_case" in attachment.tags' - - '"Tag with Space" in attachment.tags' - - attachment.tags.Name == attachment_name - - attachment.tags.CamelCase == 'CamelCaseValue' - - attachment.tags.pascalCase == 'pascalCaseValue' - - attachment.tags.snake_case == 'snake_case_value' - - attachment.tags['Tag with Space'] == 'value with space' - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: Set tags - amazon.aws.ec2_transit_gateway_vpc_attachment: - name: '{{ attachment_name }}' - tags: - CamelCase: CamelCaseValue - pascalCase: pascalCaseValue - snake_case: snake_case_value - Tag with Space: value with space - register: simple_attach - - - name: Assert that 'Set tags' is successful - ansible.builtin.assert: - that: - - simple_attach is changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 5 - - '"Name" in attachment.tags' - - '"CamelCase" in attachment.tags' - - '"pascalCase" in attachment.tags' - - '"snake_case" in attachment.tags' - - '"Tag with Space" in attachment.tags' - - attachment.tags.Name == attachment_name - - attachment.tags.CamelCase == 'CamelCaseValue' - - attachment.tags.pascalCase == 'pascalCaseValue' - - attachment.tags.snake_case == 'snake_case_value' - - attachment.tags['Tag with Space'] == 'value with space' - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: (CHECK_MODE) Set tags -- IDEMPOTENCY - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - name: '{{ attachment_name }}' - tags: - CamelCase: CamelCaseValue - pascalCase: pascalCaseValue - snake_case: snake_case_value - Tag with Space: value with space - register: simple_attach - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - simple_attach is not changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 5 - - '"Name" in attachment.tags' - - '"CamelCase" in attachment.tags' - - '"pascalCase" in attachment.tags' - - '"snake_case" in attachment.tags' - - '"Tag with Space" in attachment.tags' - - attachment.tags.Name == attachment_name - - attachment.tags.CamelCase == 'CamelCaseValue' - - attachment.tags.pascalCase == 'pascalCaseValue' - - attachment.tags.snake_case == 'snake_case_value' - - attachment.tags['Tag with Space'] == 'value with space' - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: Set tags -- IDEMPOTENCY - amazon.aws.ec2_transit_gateway_vpc_attachment: - name: '{{ attachment_name }}' - tags: - CamelCase: CamelCaseValue - pascalCase: pascalCaseValue - snake_case: snake_case_value - Tag with Space: value with space - register: simple_attach - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - simple_attach is not changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 5 - - '"Name" in attachment.tags' - - '"CamelCase" in attachment.tags' - - '"pascalCase" in attachment.tags' - - '"snake_case" in attachment.tags' - - '"Tag with Space" in attachment.tags' - - attachment.tags.Name == attachment_name - - attachment.tags.CamelCase == 'CamelCaseValue' - - attachment.tags.pascalCase == 'pascalCaseValue' - - attachment.tags.snake_case == 'snake_case_value' - - attachment.tags['Tag with Space'] == 'value with space' - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: Describe attachment with tags set - amazon.aws.ec2_transit_gateway_vpc_attachment_info: - id: '{{ simple_attachment_id }}' - register: info - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - info is not changed - - '"attachments" in info' - - info.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 5 - - '"Name" in attachment.tags' - - '"CamelCase" in attachment.tags' - - '"pascalCase" in attachment.tags' - - '"snake_case" in attachment.tags' - - '"Tag with Space" in attachment.tags' - - attachment.tags.Name == attachment_name - - attachment.tags.CamelCase == 'CamelCaseValue' - - attachment.tags.pascalCase == 'pascalCaseValue' - - attachment.tags.snake_case == 'snake_case_value' - - attachment.tags['Tag with Space'] == 'value with space' - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ info.attachments[0] }}' + - name: (CHECK_MODE) Set tags + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + name: "{{ attachment_name }}" + tags: + CamelCase: CamelCaseValue + pascalCase: pascalCaseValue + snake_case: snake_case_value + Tag with Space: value with space + register: simple_attach + + - name: Assert that 'Set tags' is successful + ansible.builtin.assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 5 + - '"Name" in attachment.tags' + - '"CamelCase" in attachment.tags' + - '"pascalCase" in attachment.tags' + - '"snake_case" in attachment.tags' + - '"Tag with Space" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.tags.CamelCase == 'CamelCaseValue' + - attachment.tags.pascalCase == 'pascalCaseValue' + - attachment.tags.snake_case == 'snake_case_value' + - attachment.tags['Tag with Space'] == 'value with space' + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: Set tags + amazon.aws.ec2_transit_gateway_vpc_attachment: + name: "{{ attachment_name }}" + tags: + CamelCase: CamelCaseValue + pascalCase: pascalCaseValue + snake_case: snake_case_value + Tag with Space: value with space + register: simple_attach + + - name: Assert that 'Set tags' is successful + ansible.builtin.assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 5 + - '"Name" in attachment.tags' + - '"CamelCase" in attachment.tags' + - '"pascalCase" in attachment.tags' + - '"snake_case" in attachment.tags' + - '"Tag with Space" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.tags.CamelCase == 'CamelCaseValue' + - attachment.tags.pascalCase == 'pascalCaseValue' + - attachment.tags.snake_case == 'snake_case_value' + - attachment.tags['Tag with Space'] == 'value with space' + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: (CHECK_MODE) Set tags -- IDEMPOTENCY + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + name: "{{ attachment_name }}" + tags: + CamelCase: CamelCaseValue + pascalCase: pascalCaseValue + snake_case: snake_case_value + Tag with Space: value with space + register: simple_attach + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 5 + - '"Name" in attachment.tags' + - '"CamelCase" in attachment.tags' + - '"pascalCase" in attachment.tags' + - '"snake_case" in attachment.tags' + - '"Tag with Space" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.tags.CamelCase == 'CamelCaseValue' + - attachment.tags.pascalCase == 'pascalCaseValue' + - attachment.tags.snake_case == 'snake_case_value' + - attachment.tags['Tag with Space'] == 'value with space' + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: Set tags -- IDEMPOTENCY + amazon.aws.ec2_transit_gateway_vpc_attachment: + name: "{{ attachment_name }}" + tags: + CamelCase: CamelCaseValue + pascalCase: pascalCaseValue + snake_case: snake_case_value + Tag with Space: value with space + register: simple_attach + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 5 + - '"Name" in attachment.tags' + - '"CamelCase" in attachment.tags' + - '"pascalCase" in attachment.tags' + - '"snake_case" in attachment.tags' + - '"Tag with Space" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.tags.CamelCase == 'CamelCaseValue' + - attachment.tags.pascalCase == 'pascalCaseValue' + - attachment.tags.snake_case == 'snake_case_value' + - attachment.tags['Tag with Space'] == 'value with space' + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: Describe attachment with tags set + amazon.aws.ec2_transit_gateway_vpc_attachment_info: + id: "{{ simple_attachment_id }}" + register: info + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - info is not changed + - '"attachments" in info' + - info.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 5 + - '"Name" in attachment.tags' + - '"CamelCase" in attachment.tags' + - '"pascalCase" in attachment.tags' + - '"snake_case" in attachment.tags' + - '"Tag with Space" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.tags.CamelCase == 'CamelCaseValue' + - attachment.tags.pascalCase == 'pascalCaseValue' + - attachment.tags.snake_case == 'snake_case_value' + - attachment.tags['Tag with Space'] == 'value with space' + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ info.attachments[0] }}" # ===== - - name: (CHECK_MODE) No change to tags with name set -- IDEMPOTENCY - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - name: '{{ attachment_name }}' - register: simple_attach - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - simple_attach is not changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 5 - - '"Name" in attachment.tags' - - '"CamelCase" in attachment.tags' - - '"pascalCase" in attachment.tags' - - '"snake_case" in attachment.tags' - - '"Tag with Space" in attachment.tags' - - attachment.tags.Name == attachment_name - - attachment.tags.CamelCase == 'CamelCaseValue' - - attachment.tags.pascalCase == 'pascalCaseValue' - - attachment.tags.snake_case == 'snake_case_value' - - attachment.tags['Tag with Space'] == 'value with space' - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: No change to tags with name set -- IDEMPOTENCY - amazon.aws.ec2_transit_gateway_vpc_attachment: - name: '{{ attachment_name }}' - register: simple_attach - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - simple_attach is not changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 5 - - '"Name" in attachment.tags' - - '"CamelCase" in attachment.tags' - - '"pascalCase" in attachment.tags' - - '"snake_case" in attachment.tags' - - '"Tag with Space" in attachment.tags' - - attachment.tags.Name == attachment_name - - attachment.tags.CamelCase == 'CamelCaseValue' - - attachment.tags.pascalCase == 'pascalCaseValue' - - attachment.tags.snake_case == 'snake_case_value' - - attachment.tags['Tag with Space'] == 'value with space' - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' + - name: (CHECK_MODE) No change to tags with name set -- IDEMPOTENCY + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + name: "{{ attachment_name }}" + register: simple_attach + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 5 + - '"Name" in attachment.tags' + - '"CamelCase" in attachment.tags' + - '"pascalCase" in attachment.tags' + - '"snake_case" in attachment.tags' + - '"Tag with Space" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.tags.CamelCase == 'CamelCaseValue' + - attachment.tags.pascalCase == 'pascalCaseValue' + - attachment.tags.snake_case == 'snake_case_value' + - attachment.tags['Tag with Space'] == 'value with space' + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: No change to tags with name set -- IDEMPOTENCY + amazon.aws.ec2_transit_gateway_vpc_attachment: + name: "{{ attachment_name }}" + register: simple_attach + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 5 + - '"Name" in attachment.tags' + - '"CamelCase" in attachment.tags' + - '"pascalCase" in attachment.tags' + - '"snake_case" in attachment.tags' + - '"Tag with Space" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.tags.CamelCase == 'CamelCaseValue' + - attachment.tags.pascalCase == 'pascalCaseValue' + - attachment.tags.snake_case == 'snake_case_value' + - attachment.tags['Tag with Space'] == 'value with space' + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" # ===== - - name: (CHECK_MODE) Update tags - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - name: '{{ attachment_name }}' - purge_tags: false - tags: - snake_case: snake_case_value 2 - Tag with Space: value with space 2 - register: simple_attach - - - name: Assert that the test is successful - ansible.builtin.assert: - that: - - simple_attach is changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 5 - - '"Name" in attachment.tags' - - '"CamelCase" in attachment.tags' - - '"pascalCase" in attachment.tags' - - '"snake_case" in attachment.tags' - - '"Tag with Space" in attachment.tags' - - attachment.tags.Name == attachment_name - - attachment.tags.CamelCase == 'CamelCaseValue' - - attachment.tags.pascalCase == 'pascalCaseValue' - - attachment.tags.snake_case == 'snake_case_value 2' - - attachment.tags['Tag with Space'] == 'value with space 2' - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: Update tags - amazon.aws.ec2_transit_gateway_vpc_attachment: - name: '{{ attachment_name }}' - purge_tags: false - tags: - snake_case: snake_case_value 2 - Tag with Space: value with space 2 - register: simple_attach - - - name: Assert that the test is successful - ansible.builtin.assert: - that: - - simple_attach is changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 5 - - '"Name" in attachment.tags' - - '"CamelCase" in attachment.tags' - - '"pascalCase" in attachment.tags' - - '"snake_case" in attachment.tags' - - '"Tag with Space" in attachment.tags' - - attachment.tags.Name == attachment_name - - attachment.tags.CamelCase == 'CamelCaseValue' - - attachment.tags.pascalCase == 'pascalCaseValue' - - attachment.tags.snake_case == 'snake_case_value 2' - - attachment.tags['Tag with Space'] == 'value with space 2' - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: (CHECK_MODE) Update tags -- IDEMPOTENCY - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - name: '{{ attachment_name }}' - purge_tags: false - tags: - snake_case: snake_case_value 2 - Tag with Space: value with space 2 - register: simple_attach - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - simple_attach is not changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 5 - - '"Name" in attachment.tags' - - '"CamelCase" in attachment.tags' - - '"pascalCase" in attachment.tags' - - '"snake_case" in attachment.tags' - - '"Tag with Space" in attachment.tags' - - attachment.tags.Name == attachment_name - - attachment.tags.CamelCase == 'CamelCaseValue' - - attachment.tags.pascalCase == 'pascalCaseValue' - - attachment.tags.snake_case == 'snake_case_value 2' - - attachment.tags['Tag with Space'] == 'value with space 2' - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: Update tags -- IDEMPOTENCY - amazon.aws.ec2_transit_gateway_vpc_attachment: - name: '{{ attachment_name }}' - purge_tags: false - tags: - snake_case: snake_case_value 2 - Tag with Space: value with space 2 - register: simple_attach - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - simple_attach is not changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 5 - - '"Name" in attachment.tags' - - '"CamelCase" in attachment.tags' - - '"pascalCase" in attachment.tags' - - '"snake_case" in attachment.tags' - - '"Tag with Space" in attachment.tags' - - attachment.tags.Name == attachment_name - - attachment.tags.CamelCase == 'CamelCaseValue' - - attachment.tags.pascalCase == 'pascalCaseValue' - - attachment.tags.snake_case == 'snake_case_value 2' - - attachment.tags['Tag with Space'] == 'value with space 2' - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' + - name: (CHECK_MODE) Update tags + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + name: "{{ attachment_name }}" + purge_tags: false + tags: + snake_case: snake_case_value 2 + Tag with Space: value with space 2 + register: simple_attach + + - name: Assert that the test is successful + ansible.builtin.assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 5 + - '"Name" in attachment.tags' + - '"CamelCase" in attachment.tags' + - '"pascalCase" in attachment.tags' + - '"snake_case" in attachment.tags' + - '"Tag with Space" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.tags.CamelCase == 'CamelCaseValue' + - attachment.tags.pascalCase == 'pascalCaseValue' + - attachment.tags.snake_case == 'snake_case_value 2' + - attachment.tags['Tag with Space'] == 'value with space 2' + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: Update tags + amazon.aws.ec2_transit_gateway_vpc_attachment: + name: "{{ attachment_name }}" + purge_tags: false + tags: + snake_case: snake_case_value 2 + Tag with Space: value with space 2 + register: simple_attach + + - name: Assert that the test is successful + ansible.builtin.assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 5 + - '"Name" in attachment.tags' + - '"CamelCase" in attachment.tags' + - '"pascalCase" in attachment.tags' + - '"snake_case" in attachment.tags' + - '"Tag with Space" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.tags.CamelCase == 'CamelCaseValue' + - attachment.tags.pascalCase == 'pascalCaseValue' + - attachment.tags.snake_case == 'snake_case_value 2' + - attachment.tags['Tag with Space'] == 'value with space 2' + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: (CHECK_MODE) Update tags -- IDEMPOTENCY + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + name: "{{ attachment_name }}" + purge_tags: false + tags: + snake_case: snake_case_value 2 + Tag with Space: value with space 2 + register: simple_attach + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 5 + - '"Name" in attachment.tags' + - '"CamelCase" in attachment.tags' + - '"pascalCase" in attachment.tags' + - '"snake_case" in attachment.tags' + - '"Tag with Space" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.tags.CamelCase == 'CamelCaseValue' + - attachment.tags.pascalCase == 'pascalCaseValue' + - attachment.tags.snake_case == 'snake_case_value 2' + - attachment.tags['Tag with Space'] == 'value with space 2' + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: Update tags -- IDEMPOTENCY + amazon.aws.ec2_transit_gateway_vpc_attachment: + name: "{{ attachment_name }}" + purge_tags: false + tags: + snake_case: snake_case_value 2 + Tag with Space: value with space 2 + register: simple_attach + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 5 + - '"Name" in attachment.tags' + - '"CamelCase" in attachment.tags' + - '"pascalCase" in attachment.tags' + - '"snake_case" in attachment.tags' + - '"Tag with Space" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.tags.CamelCase == 'CamelCaseValue' + - attachment.tags.pascalCase == 'pascalCaseValue' + - attachment.tags.snake_case == 'snake_case_value 2' + - attachment.tags['Tag with Space'] == 'value with space 2' + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" # ===== - - name: (CHECK_MODE) Remove tags - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - name: '{{ attachment_name }}' - tags: - CamelCase: CamelCaseValue - pascalCase: pascalCaseValue - register: simple_attach - - - name: Assert that the test is successful - ansible.builtin.assert: - that: - - simple_attach is changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 3 - - '"Name" in attachment.tags' - - '"CamelCase" in attachment.tags' - - '"pascalCase" in attachment.tags' - - attachment.tags.Name == attachment_name - - attachment.tags.CamelCase == 'CamelCaseValue' - - attachment.tags.pascalCase == 'pascalCaseValue' - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: Remove tags - amazon.aws.ec2_transit_gateway_vpc_attachment: - name: '{{ attachment_name }}' - tags: - CamelCase: CamelCaseValue - pascalCase: pascalCaseValue - register: simple_attach - - - name: Assert that the test is successful - ansible.builtin.assert: - that: - - simple_attach is changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 3 - - '"Name" in attachment.tags' - - '"CamelCase" in attachment.tags' - - '"pascalCase" in attachment.tags' - - attachment.tags.Name == attachment_name - - attachment.tags.CamelCase == 'CamelCaseValue' - - attachment.tags.pascalCase == 'pascalCaseValue' - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: (CHECK_MODE) Remove tags -- IDEMPOTENCY - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - name: '{{ attachment_name }}' - tags: - CamelCase: CamelCaseValue - pascalCase: pascalCaseValue - register: simple_attach - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - simple_attach is not changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 3 - - '"Name" in attachment.tags' - - '"CamelCase" in attachment.tags' - - '"pascalCase" in attachment.tags' - - attachment.tags.Name == attachment_name - - attachment.tags.CamelCase == 'CamelCaseValue' - - attachment.tags.pascalCase == 'pascalCaseValue' - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: Remove tags -- IDEMPOTENCY - amazon.aws.ec2_transit_gateway_vpc_attachment: - name: '{{ attachment_name }}' - tags: - CamelCase: CamelCaseValue - pascalCase: pascalCaseValue - register: simple_attach - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - simple_attach is not changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 3 - - '"Name" in attachment.tags' - - '"CamelCase" in attachment.tags' - - '"pascalCase" in attachment.tags' - - attachment.tags.Name == attachment_name - - attachment.tags.CamelCase == 'CamelCaseValue' - - attachment.tags.pascalCase == 'pascalCaseValue' - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' + - name: (CHECK_MODE) Remove tags + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + name: "{{ attachment_name }}" + tags: + CamelCase: CamelCaseValue + pascalCase: pascalCaseValue + register: simple_attach + + - name: Assert that the test is successful + ansible.builtin.assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 3 + - '"Name" in attachment.tags' + - '"CamelCase" in attachment.tags' + - '"pascalCase" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.tags.CamelCase == 'CamelCaseValue' + - attachment.tags.pascalCase == 'pascalCaseValue' + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: Remove tags + amazon.aws.ec2_transit_gateway_vpc_attachment: + name: "{{ attachment_name }}" + tags: + CamelCase: CamelCaseValue + pascalCase: pascalCaseValue + register: simple_attach + + - name: Assert that the test is successful + ansible.builtin.assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 3 + - '"Name" in attachment.tags' + - '"CamelCase" in attachment.tags' + - '"pascalCase" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.tags.CamelCase == 'CamelCaseValue' + - attachment.tags.pascalCase == 'pascalCaseValue' + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: (CHECK_MODE) Remove tags -- IDEMPOTENCY + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + name: "{{ attachment_name }}" + tags: + CamelCase: CamelCaseValue + pascalCase: pascalCaseValue + register: simple_attach + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 3 + - '"Name" in attachment.tags' + - '"CamelCase" in attachment.tags' + - '"pascalCase" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.tags.CamelCase == 'CamelCaseValue' + - attachment.tags.pascalCase == 'pascalCaseValue' + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: Remove tags -- IDEMPOTENCY + amazon.aws.ec2_transit_gateway_vpc_attachment: + name: "{{ attachment_name }}" + tags: + CamelCase: CamelCaseValue + pascalCase: pascalCaseValue + register: simple_attach + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 3 + - '"Name" in attachment.tags' + - '"CamelCase" in attachment.tags' + - '"pascalCase" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.tags.CamelCase == 'CamelCaseValue' + - attachment.tags.pascalCase == 'pascalCaseValue' + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" # ===== - - name: (CHECK_MODE) Add tags with no purge - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - name: '{{ attachment_name }}' - purge_tags: false - tags: - AnotherTag: Another Value - register: simple_attach - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - simple_attach is changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 4 - - '"Name" in attachment.tags' - - '"CamelCase" in attachment.tags' - - '"pascalCase" in attachment.tags' - - '"AnotherTag" in attachment.tags' - - attachment.tags.Name == attachment_name - - attachment.tags.CamelCase == 'CamelCaseValue' - - attachment.tags.pascalCase == 'pascalCaseValue' - - attachment.tags.AnotherTag == 'Another Value' - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: Add tags with no purge - amazon.aws.ec2_transit_gateway_vpc_attachment: - name: '{{ attachment_name }}' - purge_tags: false - tags: - AnotherTag: Another Value - register: simple_attach - - - name: Assert that the test is successful - ansible.builtin.assert: - that: - - simple_attach is changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 4 - - '"Name" in attachment.tags' - - '"CamelCase" in attachment.tags' - - '"pascalCase" in attachment.tags' - - '"AnotherTag" in attachment.tags' - - attachment.tags.Name == attachment_name - - attachment.tags.CamelCase == 'CamelCaseValue' - - attachment.tags.pascalCase == 'pascalCaseValue' - - attachment.tags.AnotherTag == 'Another Value' - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: (CHECK_MODE) Add tags with no purge -- IDEMPOTENCY - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - name: '{{ attachment_name }}' - purge_tags: false - tags: - AnotherTag: Another Value - register: simple_attach - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - simple_attach is not changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 4 - - '"Name" in attachment.tags' - - '"CamelCase" in attachment.tags' - - '"pascalCase" in attachment.tags' - - '"AnotherTag" in attachment.tags' - - attachment.tags.Name == attachment_name - - attachment.tags.CamelCase == 'CamelCaseValue' - - attachment.tags.pascalCase == 'pascalCaseValue' - - attachment.tags.AnotherTag == 'Another Value' - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: Add tags with no purge -- IDEMPOTENCY - amazon.aws.ec2_transit_gateway_vpc_attachment: - name: '{{ attachment_name }}' - purge_tags: false - tags: - AnotherTag: Another Value - register: simple_attach - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - simple_attach is not changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 4 - - '"Name" in attachment.tags' - - '"CamelCase" in attachment.tags' - - '"pascalCase" in attachment.tags' - - '"AnotherTag" in attachment.tags' - - attachment.tags.Name == attachment_name - - attachment.tags.CamelCase == 'CamelCaseValue' - - attachment.tags.pascalCase == 'pascalCaseValue' - - attachment.tags.AnotherTag == 'Another Value' - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' + - name: (CHECK_MODE) Add tags with no purge + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + name: "{{ attachment_name }}" + purge_tags: false + tags: + AnotherTag: Another Value + register: simple_attach + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 4 + - '"Name" in attachment.tags' + - '"CamelCase" in attachment.tags' + - '"pascalCase" in attachment.tags' + - '"AnotherTag" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.tags.CamelCase == 'CamelCaseValue' + - attachment.tags.pascalCase == 'pascalCaseValue' + - attachment.tags.AnotherTag == 'Another Value' + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: Add tags with no purge + amazon.aws.ec2_transit_gateway_vpc_attachment: + name: "{{ attachment_name }}" + purge_tags: false + tags: + AnotherTag: Another Value + register: simple_attach + + - name: Assert that the test is successful + ansible.builtin.assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 4 + - '"Name" in attachment.tags' + - '"CamelCase" in attachment.tags' + - '"pascalCase" in attachment.tags' + - '"AnotherTag" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.tags.CamelCase == 'CamelCaseValue' + - attachment.tags.pascalCase == 'pascalCaseValue' + - attachment.tags.AnotherTag == 'Another Value' + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: (CHECK_MODE) Add tags with no purge -- IDEMPOTENCY + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + name: "{{ attachment_name }}" + purge_tags: false + tags: + AnotherTag: Another Value + register: simple_attach + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 4 + - '"Name" in attachment.tags' + - '"CamelCase" in attachment.tags' + - '"pascalCase" in attachment.tags' + - '"AnotherTag" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.tags.CamelCase == 'CamelCaseValue' + - attachment.tags.pascalCase == 'pascalCaseValue' + - attachment.tags.AnotherTag == 'Another Value' + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: Add tags with no purge -- IDEMPOTENCY + amazon.aws.ec2_transit_gateway_vpc_attachment: + name: "{{ attachment_name }}" + purge_tags: false + tags: + AnotherTag: Another Value + register: simple_attach + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 4 + - '"Name" in attachment.tags' + - '"CamelCase" in attachment.tags' + - '"pascalCase" in attachment.tags' + - '"AnotherTag" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.tags.CamelCase == 'CamelCaseValue' + - attachment.tags.pascalCase == 'pascalCaseValue' + - attachment.tags.AnotherTag == 'Another Value' + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" # ===== - - name: (CHECK_MODE) Remove all tags with name set - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - name: '{{ attachment_name }}' - tags: {} - register: simple_attach - - - name: Assert that the test is successful - ansible.builtin.assert: - that: - - simple_attach is changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 1 - - '"Name" in attachment.tags' - - attachment.tags.Name == attachment_name - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: Remove all tags with name set - amazon.aws.ec2_transit_gateway_vpc_attachment: - name: '{{ attachment_name }}' - tags: {} - register: simple_attach - - - name: Assert that the test is successful - ansible.builtin.assert: - that: - - simple_attach is changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 1 - - '"Name" in attachment.tags' - - attachment.tags.Name == attachment_name - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: (CHECK_MODE) Remove all tags with name set -- IDEMPOTENCY - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - name: '{{ attachment_name }}' - tags: {} - register: simple_attach - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - simple_attach is not changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 1 - - '"Name" in attachment.tags' - - attachment.tags.Name == attachment_name - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: Remove all tags with name set -- IDEMPOTENCY - amazon.aws.ec2_transit_gateway_vpc_attachment: - name: '{{ attachment_name }}' - tags: {} - register: simple_attach - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - simple_attach is not changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 1 - - '"Name" in attachment.tags' - - attachment.tags.Name == attachment_name - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' + - name: (CHECK_MODE) Remove all tags with name set + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + name: "{{ attachment_name }}" + tags: {} + register: simple_attach + + - name: Assert that the test is successful + ansible.builtin.assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 1 + - '"Name" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: Remove all tags with name set + amazon.aws.ec2_transit_gateway_vpc_attachment: + name: "{{ attachment_name }}" + tags: {} + register: simple_attach + + - name: Assert that the test is successful + ansible.builtin.assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 1 + - '"Name" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: (CHECK_MODE) Remove all tags with name set -- IDEMPOTENCY + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + name: "{{ attachment_name }}" + tags: {} + register: simple_attach + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 1 + - '"Name" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: Remove all tags with name set -- IDEMPOTENCY + amazon.aws.ec2_transit_gateway_vpc_attachment: + name: "{{ attachment_name }}" + tags: {} + register: simple_attach + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 1 + - '"Name" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" # ===== - - name: (CHECK_MODE) Remove all tags including name - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - tags: {} - register: simple_attach - - - name: Assert that the test is successful - ansible.builtin.assert: - that: - - simple_attach is changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: Remove all tags including name - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - tags: {} - register: simple_attach - - - name: Assert that the test is successful - ansible.builtin.assert: - that: - - simple_attach is changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: (CHECK_MODE) Remove all tags including name -- IDEMPOTENCY - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - tags: {} - register: simple_attach - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - simple_attach is not changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: Remove all tags including name -- IDEMPOTENCY - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - tags: {} - register: simple_attach - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - simple_attach is not changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' + - name: (CHECK_MODE) Remove all tags including name + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + tags: {} + register: simple_attach + + - name: Assert that the test is successful + ansible.builtin.assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: Remove all tags including name + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + tags: {} + register: simple_attach + + - name: Assert that the test is successful + ansible.builtin.assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: (CHECK_MODE) Remove all tags including name -- IDEMPOTENCY + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + tags: {} + register: simple_attach + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: Remove all tags including name -- IDEMPOTENCY + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + tags: {} + register: simple_attach + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" # ============================================================================= # Options - - name: (CHECK_MODE) Set IPv6 support - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - ipv6_support: true - register: simple_attach - - - name: Assert that the test is successful - ansible.builtin.assert: - that: - - simple_attach is changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'enable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: Set IPv6 support - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - ipv6_support: true - register: simple_attach - - - name: Assert that the test is successful - ansible.builtin.assert: - that: - - simple_attach is changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'enable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: (CHECK_MODE) Set IPv6 support -- IDEMPOTENCY - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - ipv6_support: true - register: simple_attach - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - simple_attach is not changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'enable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: Set IPv6 support -- IDEMPOTENCY - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - ipv6_support: true - register: simple_attach - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - simple_attach is not changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'enable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' + - name: (CHECK_MODE) Set IPv6 support + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + ipv6_support: true + register: simple_attach + + - name: Assert that the test is successful + ansible.builtin.assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'enable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: Set IPv6 support + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + ipv6_support: true + register: simple_attach + + - name: Assert that the test is successful + ansible.builtin.assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'enable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: (CHECK_MODE) Set IPv6 support -- IDEMPOTENCY + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + ipv6_support: true + register: simple_attach + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'enable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: Set IPv6 support -- IDEMPOTENCY + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + ipv6_support: true + register: simple_attach + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'enable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" # ===== - - name: (CHECK_MODE) Set DNS support - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - dns_support: false - register: simple_attach - - - name: Assert that the test is successful - ansible.builtin.assert: - that: - - simple_attach is changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'disable' - - attachment.options.ipv6_support == 'enable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: Set DNS support - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - dns_support: false - register: simple_attach - - - name: Assert that the test is successful - ansible.builtin.assert: - that: - - simple_attach is changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'disable' - - attachment.options.ipv6_support == 'enable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: (CHECK_MODE) Set DNS support -- IDEMPOTENCY - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - dns_support: false - register: simple_attach - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - simple_attach is not changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'disable' - - attachment.options.ipv6_support == 'enable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: Set DNS support -- IDEMPOTENCY - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - dns_support: false - register: simple_attach - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - simple_attach is not changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'disable' - - attachment.options.ipv6_support == 'enable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' + - name: (CHECK_MODE) Set DNS support + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + dns_support: false + register: simple_attach + + - name: Assert that the test is successful + ansible.builtin.assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'disable' + - attachment.options.ipv6_support == 'enable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: Set DNS support + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + dns_support: false + register: simple_attach + + - name: Assert that the test is successful + ansible.builtin.assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'disable' + - attachment.options.ipv6_support == 'enable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: (CHECK_MODE) Set DNS support -- IDEMPOTENCY + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + dns_support: false + register: simple_attach + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'disable' + - attachment.options.ipv6_support == 'enable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: Set DNS support -- IDEMPOTENCY + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + dns_support: false + register: simple_attach + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'disable' + - attachment.options.ipv6_support == 'enable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" # ===== - - name: (CHECK_MODE) Set Appliance Mode support - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - appliance_mode_support: true - register: simple_attach - - - name: Assert that the test is successful - ansible.builtin.assert: - that: - - simple_attach is changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'enable' - - attachment.options.dns_support == 'disable' - - attachment.options.ipv6_support == 'enable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: Set Appliance Mode support - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - appliance_mode_support: true - register: simple_attach - - - name: Assert that the test is successful - ansible.builtin.assert: - that: - - simple_attach is changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'enable' - - attachment.options.dns_support == 'disable' - - attachment.options.ipv6_support == 'enable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: (CHECK_MODE) Set Appliance Mode support -- IDEMPOTENCY - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - appliance_mode_support: true - register: simple_attach - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - simple_attach is not changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'enable' - - attachment.options.dns_support == 'disable' - - attachment.options.ipv6_support == 'enable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: Set Appliance Mode support -- IDEMPOTENCY - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - appliance_mode_support: true - register: simple_attach - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - simple_attach is not changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'enable' - - attachment.options.dns_support == 'disable' - - attachment.options.ipv6_support == 'enable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' + - name: (CHECK_MODE) Set Appliance Mode support + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + appliance_mode_support: true + register: simple_attach + + - name: Assert that the test is successful + ansible.builtin.assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'enable' + - attachment.options.dns_support == 'disable' + - attachment.options.ipv6_support == 'enable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: Set Appliance Mode support + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + appliance_mode_support: true + register: simple_attach + + - name: Assert that the test is successful + ansible.builtin.assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'enable' + - attachment.options.dns_support == 'disable' + - attachment.options.ipv6_support == 'enable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: (CHECK_MODE) Set Appliance Mode support -- IDEMPOTENCY + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + appliance_mode_support: true + register: simple_attach + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'enable' + - attachment.options.dns_support == 'disable' + - attachment.options.ipv6_support == 'enable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: Set Appliance Mode support -- IDEMPOTENCY + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + appliance_mode_support: true + register: simple_attach + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'enable' + - attachment.options.dns_support == 'disable' + - attachment.options.ipv6_support == 'enable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" # ===== - - name: (CHECK_MODE) Update IPv6 support - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - ipv6_support: false - register: simple_attach - - - name: Assert that the test is successful - ansible.builtin.assert: - that: - - simple_attach is changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'enable' - - attachment.options.dns_support == 'disable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: Update IPv6 support - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - ipv6_support: false - register: simple_attach - - - name: Assert that the test is successful - ansible.builtin.assert: - that: - - simple_attach is changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'enable' - - attachment.options.dns_support == 'disable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: (CHECK_MODE) Update IPv6 support -- IDEMPOTENCY - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - ipv6_support: false - register: simple_attach - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - simple_attach is not changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'enable' - - attachment.options.dns_support == 'disable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: Update IPv6 support -- IDEMPOTENCY - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - ipv6_support: false - register: simple_attach - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - simple_attach is not changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'enable' - - attachment.options.dns_support == 'disable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' + - name: (CHECK_MODE) Update IPv6 support + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + ipv6_support: false + register: simple_attach + + - name: Assert that the test is successful + ansible.builtin.assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'enable' + - attachment.options.dns_support == 'disable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: Update IPv6 support + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + ipv6_support: false + register: simple_attach + + - name: Assert that the test is successful + ansible.builtin.assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'enable' + - attachment.options.dns_support == 'disable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: (CHECK_MODE) Update IPv6 support -- IDEMPOTENCY + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + ipv6_support: false + register: simple_attach + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'enable' + - attachment.options.dns_support == 'disable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: Update IPv6 support -- IDEMPOTENCY + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + ipv6_support: false + register: simple_attach + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'enable' + - attachment.options.dns_support == 'disable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" # ===== - - name: (CHECK_MODE) Update DNS support - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - dns_support: true - register: simple_attach - - - name: Assert that the test is successful - ansible.builtin.assert: - that: - - simple_attach is changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'enable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: Update DNS support - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - dns_support: true - register: simple_attach - - - name: Assert that the test is successful - ansible.builtin.assert: - that: - - simple_attach is changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'enable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: (CHECK_MODE) Update DNS support -- IDEMPOTENCY - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - dns_support: true - register: simple_attach - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - simple_attach is not changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'enable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: Update DNS support -- IDEMPOTENCY - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - dns_support: true - register: simple_attach - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - simple_attach is not changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'enable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' + - name: (CHECK_MODE) Update DNS support + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + dns_support: true + register: simple_attach + + - name: Assert that the test is successful + ansible.builtin.assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'enable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: Update DNS support + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + dns_support: true + register: simple_attach + + - name: Assert that the test is successful + ansible.builtin.assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'enable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: (CHECK_MODE) Update DNS support -- IDEMPOTENCY + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + dns_support: true + register: simple_attach + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'enable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: Update DNS support -- IDEMPOTENCY + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + dns_support: true + register: simple_attach + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'enable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" # ===== - - name: (CHECK_MODE) Update Appliance Mode support - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - appliance_mode_support: false - register: simple_attach - - - name: Assert that the test is successful - ansible.builtin.assert: - that: - - simple_attach is changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: Update Appliance Mode support - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - appliance_mode_support: false - register: simple_attach - - - name: Assert that the test is successful - ansible.builtin.assert: - that: - - simple_attach is changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: (CHECK_MODE) Update Appliance Mode support -- IDEMPOTENCY - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - appliance_mode_support: false - register: simple_attach - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - simple_attach is not changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: Update Appliance Mode support -- IDEMPOTENCY - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - appliance_mode_support: false - register: simple_attach - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - simple_attach is not changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 1 - - subnet_id_a_1 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' + - name: (CHECK_MODE) Update Appliance Mode support + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + appliance_mode_support: false + register: simple_attach + + - name: Assert that the test is successful + ansible.builtin.assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: Update Appliance Mode support + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + appliance_mode_support: false + register: simple_attach + + - name: Assert that the test is successful + ansible.builtin.assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: (CHECK_MODE) Update Appliance Mode support -- IDEMPOTENCY + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + appliance_mode_support: false + register: simple_attach + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: Update Appliance Mode support -- IDEMPOTENCY + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + appliance_mode_support: false + register: simple_attach + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" # ============================================================================= # Subnet Management - - name: (CHECK_MODE) Try to add subnet from a different VPC - no purge - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - subnets: - - '{{ subnet_id_b_2 }}' - purge_subnets: false - register: simple_attach - ignore_errors: true - - - name: Assert that the test failed - ansible.builtin.assert: - that: - - simple_attach is failed - - - name: Try to add subnet from a different VPC - no purge - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - subnets: - - '{{ subnet_id_b_2 }}' - purge_subnets: false - register: simple_attach - ignore_errors: true - - - name: Assert that the test failed - ansible.builtin.assert: - that: - - simple_attach is failed + - name: (CHECK_MODE) Try to add subnet from a different VPC - no purge + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + subnets: + - "{{ subnet_id_b_2 }}" + purge_subnets: false + register: simple_attach + ignore_errors: true + + - name: Assert that the test failed + ansible.builtin.assert: + that: + - simple_attach is failed + + - name: Try to add subnet from a different VPC - no purge + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + subnets: + - "{{ subnet_id_b_2 }}" + purge_subnets: false + register: simple_attach + ignore_errors: true + + - name: Assert that the test failed + ansible.builtin.assert: + that: + - simple_attach is failed # ===== - - name: (CHECK_MODE) Try to add subnet from a different VPC - with purge - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - subnets: - - '{{ subnet_id_a_1 }}' - - '{{ subnet_id_b_2 }}' - purge_subnets: true - register: simple_attach - ignore_errors: true - - - name: Assert that the test failed - ansible.builtin.assert: - that: - - simple_attach is failed - - - name: Try to add subnet from a different VPC - with purge - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - subnets: - - '{{ subnet_id_a_1 }}' - - '{{ subnet_id_b_2 }}' - purge_subnets: true - register: simple_attach - ignore_errors: true - - - name: Assert that the test failed - ansible.builtin.assert: - that: - - simple_attach is failed + - name: (CHECK_MODE) Try to add subnet from a different VPC - with purge + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + subnets: + - "{{ subnet_id_a_1 }}" + - "{{ subnet_id_b_2 }}" + purge_subnets: true + register: simple_attach + ignore_errors: true + + - name: Assert that the test failed + ansible.builtin.assert: + that: + - simple_attach is failed + + - name: Try to add subnet from a different VPC - with purge + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + subnets: + - "{{ subnet_id_a_1 }}" + - "{{ subnet_id_b_2 }}" + purge_subnets: true + register: simple_attach + ignore_errors: true + + - name: Assert that the test failed + ansible.builtin.assert: + that: + - simple_attach is failed # ===== - - name: (CHECK_MODE) Try to add subnet in the same AZ - no purge - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - subnets: - - '{{ subnet_id_b_1a }}' - purge_subnets: false - register: simple_attach - ignore_errors: true - - - name: Assert that the test failed - ansible.builtin.assert: - that: - - simple_attach is failed - - - name: Try to add subnet in the same AZ - no purge - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - subnets: - - '{{ subnet_id_a_1a }}' - purge_subnets: false - register: simple_attach - ignore_errors: true - - - name: Assert that the test failed - ansible.builtin.assert: - that: - - simple_attach is failed + - name: (CHECK_MODE) Try to add subnet in the same AZ - no purge + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + subnets: + - "{{ subnet_id_b_1a }}" + purge_subnets: false + register: simple_attach + ignore_errors: true + + - name: Assert that the test failed + ansible.builtin.assert: + that: + - simple_attach is failed + + - name: Try to add subnet in the same AZ - no purge + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + subnets: + - "{{ subnet_id_a_1a }}" + purge_subnets: false + register: simple_attach + ignore_errors: true + + - name: Assert that the test failed + ansible.builtin.assert: + that: + - simple_attach is failed # ===== - - name: (CHECK_MODE) Try to add subnet in the same AZ - with purge - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - subnets: - - '{{ subnet_id_a_1 }}' - - '{{ subnet_id_a_1a }}' - purge_subnets: true - register: simple_attach - ignore_errors: true - - - name: Assert that the test failed - ansible.builtin.assert: - that: - - simple_attach is failed - - - name: Try to add subnet in the same AZ - with purge - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - subnets: - - '{{ subnet_id_a_1 }}' - - '{{ subnet_id_a_1a }}' - purge_subnets: true - register: simple_attach - ignore_errors: true - - - name: Assert that the test failed - ansible.builtin.assert: - that: - - simple_attach is failed + - name: (CHECK_MODE) Try to add subnet in the same AZ - with purge + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + subnets: + - "{{ subnet_id_a_1 }}" + - "{{ subnet_id_a_1a }}" + purge_subnets: true + register: simple_attach + ignore_errors: true + + - name: Assert that the test failed + ansible.builtin.assert: + that: + - simple_attach is failed + + - name: Try to add subnet in the same AZ - with purge + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + subnets: + - "{{ subnet_id_a_1 }}" + - "{{ subnet_id_a_1a }}" + purge_subnets: true + register: simple_attach + ignore_errors: true + + - name: Assert that the test failed + ansible.builtin.assert: + that: + - simple_attach is failed # ===== - - name: (CHECK_MODE) Add subnet - without purge - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - subnets: - - '{{ subnet_id_a_2 }}' - purge_subnets: false - register: simple_attach - - - name: Assert that the test is successful - ansible.builtin.assert: - that: - - simple_attach is changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 2 - - subnet_id_a_1 in attachment.subnet_ids - - subnet_id_a_2 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: Add subnet - without purge - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - subnets: - - '{{ subnet_id_a_2 }}' - purge_subnets: false - register: simple_attach - - - name: Assert that the test is successful - ansible.builtin.assert: - that: - - simple_attach is changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 2 - - subnet_id_a_1 in attachment.subnet_ids - - subnet_id_a_2 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: (CHECK_MODE) Add subnet - without purge -- IDEMPOTENCY - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - subnets: - - '{{ subnet_id_a_2 }}' - purge_subnets: false - register: simple_attach - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - simple_attach is not changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 2 - - subnet_id_a_1 in attachment.subnet_ids - - subnet_id_a_2 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: Add subnet - without purge -- IDEMPOTENCY - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - subnets: - - '{{ subnet_id_a_2 }}' - purge_subnets: false - register: simple_attach - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - simple_attach is not changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 2 - - subnet_id_a_1 in attachment.subnet_ids - - subnet_id_a_2 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' + - name: (CHECK_MODE) Add subnet - without purge + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + subnets: + - "{{ subnet_id_a_2 }}" + purge_subnets: false + register: simple_attach + + - name: Assert that the test is successful + ansible.builtin.assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 2 + - subnet_id_a_1 in attachment.subnet_ids + - subnet_id_a_2 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: Add subnet - without purge + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + subnets: + - "{{ subnet_id_a_2 }}" + purge_subnets: false + register: simple_attach + + - name: Assert that the test is successful + ansible.builtin.assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 2 + - subnet_id_a_1 in attachment.subnet_ids + - subnet_id_a_2 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: (CHECK_MODE) Add subnet - without purge -- IDEMPOTENCY + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + subnets: + - "{{ subnet_id_a_2 }}" + purge_subnets: false + register: simple_attach + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 2 + - subnet_id_a_1 in attachment.subnet_ids + - subnet_id_a_2 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: Add subnet - without purge -- IDEMPOTENCY + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + subnets: + - "{{ subnet_id_a_2 }}" + purge_subnets: false + register: simple_attach + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 2 + - subnet_id_a_1 in attachment.subnet_ids + - subnet_id_a_2 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" # ===== - - name: (CHECK_MODE) Add subnet - with purge - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - subnets: - - '{{ subnet_id_a_1 }}' - - '{{ subnet_id_a_2 }}' - - '{{ subnet_id_a_3 }}' - purge_subnets: true - register: simple_attach - - - name: Assert that the test is successful - ansible.builtin.assert: - that: - - simple_attach is changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 3 - - subnet_id_a_1 in attachment.subnet_ids - - subnet_id_a_2 in attachment.subnet_ids - - subnet_id_a_3 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: Add subnet - with purge - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - subnets: - - '{{ subnet_id_a_1 }}' - - '{{ subnet_id_a_2 }}' - - '{{ subnet_id_a_3 }}' - purge_subnets: true - register: simple_attach - - - name: Assert that the test is successful - ansible.builtin.assert: - that: - - simple_attach is changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 3 - - subnet_id_a_1 in attachment.subnet_ids - - subnet_id_a_2 in attachment.subnet_ids - - subnet_id_a_3 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: (CHECK_MODE) Add subnet - with purge -- IDEMPOTENCY - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - subnets: - - '{{ subnet_id_a_1 }}' - - '{{ subnet_id_a_2 }}' - - '{{ subnet_id_a_3 }}' - purge_subnets: true - register: simple_attach - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - simple_attach is not changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 3 - - subnet_id_a_1 in attachment.subnet_ids - - subnet_id_a_2 in attachment.subnet_ids - - subnet_id_a_3 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: Add subnet - with purge -- IDEMPOTENCY - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - subnets: - - '{{ subnet_id_a_1 }}' - - '{{ subnet_id_a_2 }}' - - '{{ subnet_id_a_3 }}' - purge_subnets: true - register: simple_attach - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - simple_attach is not changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 3 - - subnet_id_a_1 in attachment.subnet_ids - - subnet_id_a_2 in attachment.subnet_ids - - subnet_id_a_3 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' + - name: (CHECK_MODE) Add subnet - with purge + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + subnets: + - "{{ subnet_id_a_1 }}" + - "{{ subnet_id_a_2 }}" + - "{{ subnet_id_a_3 }}" + purge_subnets: true + register: simple_attach + + - name: Assert that the test is successful + ansible.builtin.assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 3 + - subnet_id_a_1 in attachment.subnet_ids + - subnet_id_a_2 in attachment.subnet_ids + - subnet_id_a_3 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: Add subnet - with purge + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + subnets: + - "{{ subnet_id_a_1 }}" + - "{{ subnet_id_a_2 }}" + - "{{ subnet_id_a_3 }}" + purge_subnets: true + register: simple_attach + + - name: Assert that the test is successful + ansible.builtin.assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 3 + - subnet_id_a_1 in attachment.subnet_ids + - subnet_id_a_2 in attachment.subnet_ids + - subnet_id_a_3 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: (CHECK_MODE) Add subnet - with purge -- IDEMPOTENCY + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + subnets: + - "{{ subnet_id_a_1 }}" + - "{{ subnet_id_a_2 }}" + - "{{ subnet_id_a_3 }}" + purge_subnets: true + register: simple_attach + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 3 + - subnet_id_a_1 in attachment.subnet_ids + - subnet_id_a_2 in attachment.subnet_ids + - subnet_id_a_3 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: Add subnet - with purge -- IDEMPOTENCY + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + subnets: + - "{{ subnet_id_a_1 }}" + - "{{ subnet_id_a_2 }}" + - "{{ subnet_id_a_3 }}" + purge_subnets: true + register: simple_attach + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 3 + - subnet_id_a_1 in attachment.subnet_ids + - subnet_id_a_2 in attachment.subnet_ids + - subnet_id_a_3 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" # ===== - - name: (CHECK_MODE) Remove subnet - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - subnets: - - '{{ subnet_id_a_2 }}' - - '{{ subnet_id_a_3 }}' - purge_subnets: true - register: simple_attach - - - name: Assert that the test is successful - ansible.builtin.assert: - that: - - simple_attach is changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 2 - - subnet_id_a_2 in attachment.subnet_ids - - subnet_id_a_3 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: Remove subnet - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - subnets: - - '{{ subnet_id_a_2 }}' - - '{{ subnet_id_a_3 }}' - purge_subnets: true - register: simple_attach - - - name: Assert that the test is successful - ansible.builtin.assert: - that: - - simple_attach is changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 2 - - subnet_id_a_2 in attachment.subnet_ids - - subnet_id_a_3 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: (CHECK_MODE) Remove subnet -- IDEMPOTENCY - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - subnets: - - '{{ subnet_id_a_2 }}' - - '{{ subnet_id_a_3 }}' - purge_subnets: true - register: simple_attach - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - simple_attach is not changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 2 - - subnet_id_a_2 in attachment.subnet_ids - - subnet_id_a_3 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: Remove subnet -- IDEMPOTENCY - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - subnets: - - '{{ subnet_id_a_2 }}' - - '{{ subnet_id_a_3 }}' - purge_subnets: true - register: simple_attach - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - simple_attach is not changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 2 - - subnet_id_a_2 in attachment.subnet_ids - - subnet_id_a_3 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' + - name: (CHECK_MODE) Remove subnet + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + subnets: + - "{{ subnet_id_a_2 }}" + - "{{ subnet_id_a_3 }}" + purge_subnets: true + register: simple_attach + + - name: Assert that the test is successful + ansible.builtin.assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 2 + - subnet_id_a_2 in attachment.subnet_ids + - subnet_id_a_3 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: Remove subnet + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + subnets: + - "{{ subnet_id_a_2 }}" + - "{{ subnet_id_a_3 }}" + purge_subnets: true + register: simple_attach + + - name: Assert that the test is successful + ansible.builtin.assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 2 + - subnet_id_a_2 in attachment.subnet_ids + - subnet_id_a_3 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: (CHECK_MODE) Remove subnet -- IDEMPOTENCY + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + subnets: + - "{{ subnet_id_a_2 }}" + - "{{ subnet_id_a_3 }}" + purge_subnets: true + register: simple_attach + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 2 + - subnet_id_a_2 in attachment.subnet_ids + - subnet_id_a_3 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: Remove subnet -- IDEMPOTENCY + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + subnets: + - "{{ subnet_id_a_2 }}" + - "{{ subnet_id_a_3 }}" + purge_subnets: true + register: simple_attach + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 2 + - subnet_id_a_2 in attachment.subnet_ids + - subnet_id_a_3 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" # ===== - - name: (CHECK_MODE) Remove and add subnet - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - subnets: - - '{{ subnet_id_a_1 }}' - - '{{ subnet_id_a_2 }}' - purge_subnets: true - register: simple_attach - - - name: Assert that the test is successful - ansible.builtin.assert: - that: - - simple_attach is changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 2 - - subnet_id_a_1 in attachment.subnet_ids - - subnet_id_a_2 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: Remove and add subnet - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - subnets: - - '{{ subnet_id_a_1 }}' - - '{{ subnet_id_a_2 }}' - purge_subnets: true - register: simple_attach - - - name: Assert that the test is successful - ansible.builtin.assert: - that: - - simple_attach is changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 2 - - subnet_id_a_1 in attachment.subnet_ids - - subnet_id_a_2 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: (CHECK_MODE) Remove and add subnet -- IDEMPOTENCY - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - subnets: - - '{{ subnet_id_a_1 }}' - - '{{ subnet_id_a_2 }}' - purge_subnets: true - register: simple_attach - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - simple_attach is not changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 2 - - subnet_id_a_1 in attachment.subnet_ids - - subnet_id_a_2 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' - - - name: Remove and add subnet -- IDEMPOTENCY - amazon.aws.ec2_transit_gateway_vpc_attachment: - id: '{{ simple_attachment_id }}' - subnets: - - '{{ subnet_id_a_1 }}' - - '{{ subnet_id_a_2 }}' - purge_subnets: true - register: simple_attach - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - simple_attach is not changed - - '"attachments" in simple_attach' - - simple_attach.attachments | length == 1 - - '"subnet_ids" in attachment' - - '"transit_gateway_id" in attachment' - - '"vpc_id" in attachment' - - attachment.subnet_ids | length == 2 - - subnet_id_a_1 in attachment.subnet_ids - - subnet_id_a_2 in attachment.subnet_ids - - attachment.transit_gateway_id == tgw_id - - attachment.vpc_id == vpc_id_a - - '"creation_time" in attachment' - - '"options" in attachment' - - '"state" in attachment' - - '"tags" in attachment' - - '"transit_gateway_attachment_id" in attachment' - - '"vpc_owner_id" in attachment' - - '"appliance_mode_support" in attachment.options' - - '"dns_support" in attachment.options' - - '"ipv6_support" in attachment.options' - - attachment.options.appliance_mode_support == 'disable' - - attachment.options.dns_support == 'enable' - - attachment.options.ipv6_support == 'disable' - - attachment.state == 'available' - - attachment.transit_gateway_attachment_id == simple_attachment_id - - attachment.tags | length == 0 - - attachment.vpc_owner_id == vpc_owner_a - vars: - attachment: '{{ simple_attach.attachments[0] }}' + - name: (CHECK_MODE) Remove and add subnet + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + subnets: + - "{{ subnet_id_a_1 }}" + - "{{ subnet_id_a_2 }}" + purge_subnets: true + register: simple_attach + + - name: Assert that the test is successful + ansible.builtin.assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 2 + - subnet_id_a_1 in attachment.subnet_ids + - subnet_id_a_2 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: Remove and add subnet + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + subnets: + - "{{ subnet_id_a_1 }}" + - "{{ subnet_id_a_2 }}" + purge_subnets: true + register: simple_attach + + - name: Assert that the test is successful + ansible.builtin.assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 2 + - subnet_id_a_1 in attachment.subnet_ids + - subnet_id_a_2 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: (CHECK_MODE) Remove and add subnet -- IDEMPOTENCY + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + subnets: + - "{{ subnet_id_a_1 }}" + - "{{ subnet_id_a_2 }}" + purge_subnets: true + register: simple_attach + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 2 + - subnet_id_a_1 in attachment.subnet_ids + - subnet_id_a_2 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" + + - name: Remove and add subnet -- IDEMPOTENCY + amazon.aws.ec2_transit_gateway_vpc_attachment: + id: "{{ simple_attachment_id }}" + subnets: + - "{{ subnet_id_a_1 }}" + - "{{ subnet_id_a_2 }}" + purge_subnets: true + register: simple_attach + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 2 + - subnet_id_a_1 in attachment.subnet_ids + - subnet_id_a_2 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: "{{ simple_attach.attachments[0] }}" # ============================================================================= # Deletion - - name: (CHECK_MODE) Delete an attachment - minimal parameters - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - state: absent - id: '{{ simple_attachment_id }}' - wait: false - register: simple_attach - - - name: Assert that the test is successful - ansible.builtin.assert: - that: - - simple_attach is changed - - - name: Delete an attachment - minimal parameters - amazon.aws.ec2_transit_gateway_vpc_attachment: - state: absent - id: '{{ simple_attachment_id }}' - wait: false - register: simple_attach - - - name: Assert that the test is successful - ansible.builtin.assert: - that: - - simple_attach is changed - - - name: (CHECK_MODE) Delete an attachment - minimal parameters -- IDEMPOTENCY - check_mode: true - amazon.aws.ec2_transit_gateway_vpc_attachment: - state: absent - id: '{{ simple_attachment_id }}' - wait: false - register: simple_attach - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - simple_attach is not changed - - - name: Delete an attachment - minimal parameters -- IDEMPOTENCY - amazon.aws.ec2_transit_gateway_vpc_attachment: - state: absent - id: '{{ simple_attachment_id }}' - wait: false - register: simple_attach - - - name: Assert that there is no change - ansible.builtin.assert: - that: - - simple_attach is not changed + - name: (CHECK_MODE) Delete an attachment - minimal parameters + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + state: absent + id: "{{ simple_attachment_id }}" + wait: false + register: simple_attach + + - name: Assert that the test is successful + ansible.builtin.assert: + that: + - simple_attach is changed + + - name: Delete an attachment - minimal parameters + amazon.aws.ec2_transit_gateway_vpc_attachment: + state: absent + id: "{{ simple_attachment_id }}" + wait: false + register: simple_attach + + - name: Assert that the test is successful + ansible.builtin.assert: + that: + - simple_attach is changed + + - name: (CHECK_MODE) Delete an attachment - minimal parameters -- IDEMPOTENCY + check_mode: true + amazon.aws.ec2_transit_gateway_vpc_attachment: + state: absent + id: "{{ simple_attachment_id }}" + wait: false + register: simple_attach + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - simple_attach is not changed + + - name: Delete an attachment - minimal parameters -- IDEMPOTENCY + amazon.aws.ec2_transit_gateway_vpc_attachment: + state: absent + id: "{{ simple_attachment_id }}" + wait: false + register: simple_attach + + - name: Assert that there is no change + ansible.builtin.assert: + that: + - simple_attach is not changed always: - - name: Delete attachment - amazon.aws.ec2_transit_gateway_vpc_attachment: - state: absent - id: '{{ simple_attachment_id }}' - wait: false - ignore_errors: true + - name: Delete attachment + amazon.aws.ec2_transit_gateway_vpc_attachment: + state: absent + id: "{{ simple_attachment_id }}" + wait: false + ignore_errors: true diff --git a/tests/integration/targets/ec2_vol/tasks/main.yml b/tests/integration/targets/ec2_vol/tasks/main.yml index c929372e301..75580b6fe5e 100644 --- a/tests/integration/targets/ec2_vol/tasks/main.yml +++ b/tests/integration/targets/ec2_vol/tasks/main.yml @@ -26,7 +26,7 @@ az: "{{ availability_zone }}" register: testing_subnet - - name: create an ec2 instance + - name: Create an ec2 instance amazon.aws.ec2_instance: name: "{{ instance_name }}" vpc_subnet_id: "{{ testing_subnet.subnet.id }}" @@ -36,12 +36,12 @@ ResourcePrefix: "{{ resource_prefix }}" register: test_instance - - name: check task return attributes + - name: Check task return attributes ansible.builtin.assert: that: - test_instance.changed - - name: create another ec2 instance + - name: Create another ec2 instance amazon.aws.ec2_instance: name: "{{ instance_name }}-2" vpc_subnet_id: "{{ testing_subnet.subnet.id }}" @@ -51,12 +51,12 @@ ResourcePrefix: "{{ resource_prefix }}" register: test_instance_2 - - name: check task return attributes + - name: Check task return attributes ansible.builtin.assert: that: - test_instance_2.changed - - name: create another ec2 instance + - name: Create another ec2 instance amazon.aws.ec2_instance: name: "{{ instance_name }}-3" vpc_subnet_id: "{{ testing_subnet.subnet.id }}" @@ -66,14 +66,14 @@ ResourcePrefix: "{{ resource_prefix }}" register: test_instance_3 - - name: check task return attributes + - name: Check task return attributes ansible.builtin.assert: that: - test_instance_3.changed # # ==== ec2_vol tests =============================================== - - name: create a volume (validate module defaults - check_mode) + - name: Create a volume (validate module defaults - check_mode) amazon.aws.ec2_vol: volume_size: 1 zone: "{{ availability_zone }}" @@ -86,7 +86,7 @@ that: - volume1_check_mode is changed - - name: create a volume (validate module defaults) + - name: Create a volume (validate module defaults) amazon.aws.ec2_vol: volume_size: 1 zone: "{{ availability_zone }}" @@ -94,7 +94,7 @@ ResourcePrefix: "{{ resource_prefix }}" register: volume1 - - name: check task return attributes + - name: Check task return attributes ansible.builtin.assert: that: - volume1.changed @@ -112,7 +112,7 @@ # no idempotency check needed here - - name: create another volume (override module defaults) + - name: Create another volume (override module defaults) amazon.aws.ec2_vol: encrypted: true volume_size: 4 @@ -124,7 +124,7 @@ zone: "{{ availability_zone }}" register: volume2 - - name: check task return attributes + - name: Check task return attributes ansible.builtin.assert: that: - volume2.changed @@ -140,7 +140,7 @@ - volume2.volume.encrypted - volume2.volume.tags.ResourcePrefix == resource_prefix - - name: create another volume (override module defaults) (idempotent) + - name: Create another volume (override module defaults) (idempotent) amazon.aws.ec2_vol: encrypted: true volume_size: 4 @@ -152,12 +152,12 @@ zone: "{{ availability_zone }}" register: volume2_idem - - name: check task return attributes + - name: Check task return attributes ansible.builtin.assert: that: - not volume2_idem.changed - - name: create snapshot from volume + - name: Create snapshot from volume amazon.aws.ec2_snapshot: volume_id: "{{ volume1.volume_id }}" description: Resource Prefix - {{ resource_prefix }} @@ -165,12 +165,12 @@ ResourcePrefix: "{{ resource_prefix }}" register: vol1_snapshot - - name: check task return attributes + - name: Check task return attributes ansible.builtin.assert: that: - vol1_snapshot.changed - - name: create a volume from a snapshot (check_mode) + - name: Create a volume from a snapshot (check_mode) amazon.aws.ec2_vol: snapshot: "{{ vol1_snapshot.snapshot_id }}" encrypted: true @@ -182,12 +182,12 @@ check_mode: true register: volume3_check_mode - - name: check task return attributes + - name: Check task return attributes ansible.builtin.assert: that: - volume3_check_mode.changed - - name: create a volume from a snapshot + - name: Create a volume from a snapshot amazon.aws.ec2_vol: snapshot: "{{ vol1_snapshot.snapshot_id }}" encrypted: true @@ -198,7 +198,7 @@ ResourcePrefix: "{{ resource_prefix }}" register: volume3 - - name: check task return attributes + - name: Check task return attributes ansible.builtin.assert: that: - volume3.changed @@ -210,7 +210,7 @@ instance_ids: "{{ test_instance.instance_ids }}" wait: true - - name: attach existing volume to an instance (check_mode) + - name: Attach existing volume to an instance (check_mode) amazon.aws.ec2_vol: id: "{{ volume1.volume_id }}" instance: "{{ test_instance.instance_ids[0] }}" @@ -223,7 +223,7 @@ that: - vol_attach_result_check_mode is changed - - name: attach existing volume to an instance + - name: Attach existing volume to an instance amazon.aws.ec2_vol: id: "{{ volume1.volume_id }}" instance: "{{ test_instance.instance_ids[0] }}" @@ -231,7 +231,7 @@ delete_on_termination: false register: vol_attach_result - - name: check task return attributes + - name: Check task return attributes ansible.builtin.assert: that: - vol_attach_result.changed @@ -240,7 +240,7 @@ # There's a delay between the volume being "In Use", and the attachment being reported. This # can result in a race condition on the results. (There's no clean waiter to use either) - - name: wait for volume to report attached/attaching + - name: Wait for volume to report attached/attaching amazon.aws.ec2_vol_info: filters: volume-id: "{{ volume1.volume_id }}" @@ -257,7 +257,7 @@ - vol_attach_info.volumes[0].attachment_set[0].device == '/dev/sdg' - not vol_attach_info.volumes[0].attachment_set[0].delete_on_termination - - name: attach existing volume to an instance (idempotent - check_mode) + - name: Attach existing volume to an instance (idempotent - check_mode) amazon.aws.ec2_vol: id: "{{ volume1.volume_id }}" instance: "{{ test_instance.instance_ids[0] }}" @@ -270,7 +270,7 @@ that: - vol_attach_result_check_mode is not changed - - name: attach existing volume to an instance (idempotent) + - name: Attach existing volume to an instance (idempotent) amazon.aws.ec2_vol: id: "{{ volume1.volume_id }}" instance: "{{ test_instance.instance_ids[0] }}" @@ -278,13 +278,13 @@ delete_on_termination: false register: vol_attach_result - - name: check task return attributes + - name: Check task return attributes ansible.builtin.assert: that: - not vol_attach_result.changed - vol_attach_result.volume.attachment_set[0].status in ['attached', 'attaching'] - - name: attach a new volume to an instance (check_mode) + - name: Attach a new volume to an instance (check_mode) amazon.aws.ec2_vol: instance: "{{ test_instance.instance_ids[0] }}" device_name: /dev/sdh @@ -304,7 +304,7 @@ that: - new_vol_attach_result_check_mode is changed - - name: attach a new volume to an instance + - name: Attach a new volume to an instance amazon.aws.ec2_vol: instance: "{{ test_instance.instance_ids[0] }}" device_name: /dev/sdh @@ -319,7 +319,7 @@ ResourcePrefix: "{{ resource_prefix }}" register: new_vol_attach_result - - name: check task return attributes + - name: Check task return attributes ansible.builtin.assert: that: - new_vol_attach_result.changed @@ -334,7 +334,7 @@ - new_vol_attach_result.volume.tags["snake_case"] == 'simple_snake_case' - new_vol_attach_result.volume.tags["Name"] == resource_prefix +' - sdh' - - name: attach a new volume to an instance (idempotent - check_mode) + - name: Attach a new volume to an instance (idempotent - check_mode) amazon.aws.ec2_vol: instance: "{{ test_instance.instance_ids[0] }}" device_name: /dev/sdh @@ -350,7 +350,7 @@ that: - new_vol_attach_result_idem_check_mode is not changed - - name: attach a new volume to an instance (idempotent) + - name: Attach a new volume to an instance (idempotent) amazon.aws.ec2_vol: instance: "{{ test_instance.instance_ids[0] }}" device_name: /dev/sdh @@ -361,13 +361,13 @@ register: new_vol_attach_result_idem ignore_errors: true - - name: check task return attributes + - name: Check task return attributes ansible.builtin.assert: that: - not new_vol_attach_result_idem.changed - "'Volume mapping for /dev/sdh already exists' in new_vol_attach_result_idem.msg" - - name: change some tag values + - name: Change some tag values amazon.aws.ec2_vol: instance: "{{ test_instance.instance_ids[0] }}" id: "{{ new_vol_attach_result.volume.id }}" @@ -382,7 +382,7 @@ purge_tags: false register: new_vol_attach_result - - name: check task return attributes + - name: Check task return attributes ansible.builtin.assert: that: - new_vol_attach_result.changed @@ -404,7 +404,7 @@ - new_vol_attach_result.volume.tags["ResourcePrefix"] == resource_prefix - new_vol_attach_result.volume.tags["Name"] == resource_prefix +' - sdh' - - name: change some tag values + - name: Change some tag values amazon.aws.ec2_vol: instance: "{{ test_instance.instance_ids[0] }}" id: "{{ new_vol_attach_result.volume.id }}" @@ -419,7 +419,7 @@ purge_tags: true register: new_vol_attach_result - - name: check task return attributes + - name: Check task return attributes ansible.builtin.assert: that: - new_vol_attach_result.changed @@ -439,7 +439,7 @@ - new_vol_attach_result.volume.tags["snake_case"] == 'simple_snake_case ❤️' - new_vol_attach_result.volume.tags["ResourcePrefix"] == resource_prefix - - name: create a volume from a snapshot and attach to the instance (check_mode) + - name: Create a volume from a snapshot and attach to the instance (check_mode) amazon.aws.ec2_vol: instance: "{{ test_instance.instance_ids[0] }}" device_name: /dev/sdi @@ -453,7 +453,7 @@ that: - attach_new_vol_from_snapshot_result_check_mode is changed - - name: create a volume from a snapshot and attach to the instance + - name: Create a volume from a snapshot and attach to the instance amazon.aws.ec2_vol: instance: "{{ test_instance.instance_ids[0] }}" device_name: /dev/sdi @@ -462,7 +462,7 @@ ResourcePrefix: "{{ resource_prefix }}" register: attach_new_vol_from_snapshot_result - - name: check task return attributes + - name: Check task return attributes ansible.builtin.assert: that: - attach_new_vol_from_snapshot_result.changed @@ -471,39 +471,39 @@ - attach_new_vol_from_snapshot_result.volume.attachment_set[0].status in ['attached', 'attaching'] - attach_new_vol_from_snapshot_result.volume.attachment_set[0].instance_id == test_instance.instance_ids[0] - - name: get info on ebs volumes + - name: Get info on ebs volumes amazon.aws.ec2_vol_info: register: ec2_vol_info - - name: check task return attributes + - name: Check task return attributes ansible.builtin.assert: that: - not ec2_vol_info.failed - - name: get info on ebs volumes + - name: Get info on ebs volumes amazon.aws.ec2_vol_info: filters: attachment.instance-id: "{{ test_instance.instance_ids[0] }}" register: ec2_vol_info - - name: check task return attributes + - name: Check task return attributes ansible.builtin.assert: that: - ec2_vol_info.volumes | length == 4 - - name: must not change because of missing parameter modify_volume + - name: Must not change because of missing parameter modify_volume amazon.aws.ec2_vol: id: "{{ new_vol_attach_result.volume_id }}" zone: "{{ availability_zone }}" volume_type: gp3 register: changed_gp3_volume - - name: volume must not changed + - name: Volume must not changed ansible.builtin.assert: that: - not changed_gp3_volume.changed - - name: change existing volume to gp3 (check_mode) + - name: Change existing volume to gp3 (check_mode) amazon.aws.ec2_vol: id: "{{ new_vol_attach_result.volume_id }}" zone: "{{ availability_zone }}" @@ -516,7 +516,7 @@ that: - changed_gp3_volume_check_mode is changed - - name: change existing volume to gp3 + - name: Change existing volume to gp3 amazon.aws.ec2_vol: id: "{{ new_vol_attach_result.volume_id }}" zone: "{{ availability_zone }}" @@ -524,7 +524,7 @@ modify_volume: true register: changed_gp3_volume - - name: check that volume_type has changed + - name: Check that volume_type has changed ansible.builtin.assert: that: - changed_gp3_volume.changed @@ -546,7 +546,7 @@ - new_vol_attach_result.volume.tags["snake_case"] == 'simple_snake_case ❤️' - new_vol_attach_result.volume.tags["ResourcePrefix"] == resource_prefix - - name: volume must be from type gp3 (idempotent) + - name: Volume must be from type gp3 (idempotent) amazon.aws.ec2_vol: id: "{{ new_vol_attach_result.volume_id }}" zone: "{{ availability_zone }}" @@ -558,7 +558,7 @@ until: not changed_gp3_volume.failed # retry because ebs change is to slow - - name: must not changed (idempotent) + - name: Must not changed (idempotent) ansible.builtin.assert: that: - not changed_gp3_volume.changed @@ -580,20 +580,20 @@ - new_vol_attach_result.volume.tags["snake_case"] == 'simple_snake_case ❤️' - new_vol_attach_result.volume.tags["ResourcePrefix"] == resource_prefix - - name: re-read volume information to validate new volume_type + - name: Re-read volume information to validate new volume_type amazon.aws.ec2_vol_info: filters: volume-id: "{{ changed_gp3_volume.volume_id }}" register: verify_gp3_change - - name: volume type must be gp3 + - name: Volume type must be gp3 ansible.builtin.assert: that: - v.type == 'gp3' vars: v: "{{ verify_gp3_change.volumes[0] }}" - - name: detach volume from the instance (check_mode) + - name: Detach volume from the instance (check_mode) amazon.aws.ec2_vol: id: "{{ new_vol_attach_result.volume_id }}" instance: "" @@ -604,41 +604,41 @@ that: - new_vol_attach_result_check_mode is changed - - name: detach volume from the instance + - name: Detach volume from the instance amazon.aws.ec2_vol: id: "{{ new_vol_attach_result.volume_id }}" instance: "" register: new_vol_attach_result - - name: check task return attributes + - name: Check task return attributes ansible.builtin.assert: that: - new_vol_attach_result.changed - new_vol_attach_result.volume.status == 'available' - - name: detach volume from the instance (idempotent - check_mode) + - name: Detach volume from the instance (idempotent - check_mode) amazon.aws.ec2_vol: id: "{{ new_vol_attach_result.volume_id }}" instance: "" register: new_vol_attach_result_idem_check_mode - - name: check task return attributes + - name: Check task return attributes ansible.builtin.assert: that: - not new_vol_attach_result_idem_check_mode.changed - - name: detach volume from the instance (idempotent) + - name: Detach volume from the instance (idempotent) amazon.aws.ec2_vol: id: "{{ new_vol_attach_result.volume_id }}" instance: "" register: new_vol_attach_result_idem - - name: check task return attributes + - name: Check task return attributes ansible.builtin.assert: that: - not new_vol_attach_result_idem.changed - - name: delete volume (check_mode) + - name: Delete volume (check_mode) amazon.aws.ec2_vol: id: "{{ volume2.volume_id }}" state: absent @@ -649,18 +649,18 @@ that: - delete_volume_result_check_mode is changed - - name: delete volume + - name: Delete volume amazon.aws.ec2_vol: id: "{{ volume2.volume_id }}" state: absent register: delete_volume_result - - name: check task return attributes + - name: Check task return attributes ansible.builtin.assert: that: - delete_volume_result.changed - - name: delete volume (idempotent - check_mode) + - name: Delete volume (idempotent - check_mode) amazon.aws.ec2_vol: id: "{{ volume2.volume_id }}" state: absent @@ -671,13 +671,13 @@ that: - delete_volume_result_check_mode is not changed - - name: delete volume (idempotent) + - name: Delete volume (idempotent) amazon.aws.ec2_vol: id: "{{ volume2.volume_id }}" state: absent register: delete_volume_result_idem - - name: check task return attributes + - name: Check task return attributes ansible.builtin.assert: that: - not delete_volume_result_idem.changed @@ -697,7 +697,7 @@ delete_on_termination: true register: dot_volume - - name: check task return attributes + - name: Check task return attributes ansible.builtin.assert: that: - dot_volume.changed @@ -764,7 +764,7 @@ v: "{{ volume_info.volumes[0] }}" when: ansible_version.full is version('2.7', '>=') - - name: test create a new gp3 volume + - name: Test create a new gp3 volume amazon.aws.ec2_vol: volume_size: 70 zone: "{{ availability_zone }}" @@ -776,7 +776,7 @@ ResourcePrefix: "{{ resource_prefix }}" register: gp3_volume - - name: check that volume_type is gp3 + - name: Check that volume_type is gp3 ansible.builtin.assert: that: - gp3_volume.changed @@ -801,14 +801,14 @@ volume-id: "{{ gp3_volume.volume_id }}" register: verify_throughput - - name: throughput must be equal to 130 + - name: Throughput must be equal to 130 ansible.builtin.assert: that: - v.throughput == 130 vars: v: "{{ verify_throughput.volumes[0] }}" - - name: print out facts + - name: Print out facts ansible.builtin.debug: var: vol_facts @@ -818,18 +818,18 @@ volume-id: "{{ gp3_volume.volume_id }}" register: verify_throughput - - name: throughput must be equal to 130 + - name: Throughput must be equal to 130 ansible.builtin.assert: that: - v.throughput == 130 vars: v: "{{ verify_throughput.volumes[0] }}" - - name: print out facts + - name: Print out facts ansible.builtin.debug: var: vol_facts - - name: increase throughput + - name: Increase throughput amazon.aws.ec2_vol: volume_size: 70 zone: "{{ availability_zone }}" @@ -841,7 +841,7 @@ ResourcePrefix: "{{ resource_prefix }}" register: gp3_volume - - name: check that throughput has changed + - name: Check that throughput has changed ansible.builtin.assert: that: - gp3_volume.changed @@ -857,7 +857,7 @@ - gp3_volume.volume.throughput == 131 # Multi-Attach disk - - name: create disk with multi-attach enabled + - name: Create disk with multi-attach enabled amazon.aws.ec2_vol: volume_size: 4 volume_type: io1 @@ -868,14 +868,14 @@ ResourcePrefix: "{{ resource_prefix }}" register: multi_attach_disk - - name: check volume creation + - name: Check volume creation ansible.builtin.assert: that: - multi_attach_disk.changed - "'volume' in multi_attach_disk" - multi_attach_disk.volume.multi_attach_enabled - - name: attach existing volume to an instance + - name: Attach existing volume to an instance amazon.aws.ec2_vol: id: "{{ multi_attach_disk.volume_id }}" instance: "{{ test_instance.instance_ids[0] }}" @@ -889,7 +889,7 @@ instance_ids: "{{ test_instance_2.instance_ids }}" wait: true - - name: attach existing volume to second instance + - name: Attach existing volume to second instance amazon.aws.ec2_vol: id: "{{ multi_attach_disk.volume_id }}" instance: "{{ test_instance_2.instance_ids[0] }}" @@ -897,7 +897,7 @@ delete_on_termination: false register: vol_attach_result - - name: check task return attributes + - name: Check task return attributes ansible.builtin.assert: that: - vol_attach_result.changed @@ -906,7 +906,7 @@ - test_instance.instance_ids[0] in vol_attach_result.volume.attachment_set | map(attribute="instance_id") | list - test_instance_2.instance_ids[0] in vol_attach_result.volume.attachment_set | map(attribute="instance_id") | list - - name: create a volume without tags + - name: Create a volume without tags amazon.aws.ec2_vol: volume_size: 5 zone: "{{ availability_zone }}" @@ -918,7 +918,7 @@ - volume_without_tag.changed # idempotency check without tags - - name: create a volume without tags (idempotency check) + - name: Create a volume without tags (idempotency check) amazon.aws.ec2_vol: volume_size: 5 zone: "{{ availability_zone }}" @@ -945,7 +945,7 @@ - ansible.builtin.debug: var: pre_delete - - name: delete test instance + - name: Delete test instance amazon.aws.ec2_instance: instance_ids: - "{{ item }}" @@ -957,7 +957,7 @@ - "{{ test_instance_3.instance_ids[0] }}" ignore_errors: true - - name: delete volumes + - name: Delete volumes amazon.aws.ec2_vol: id: "{{ item.volume_id }}" state: absent @@ -973,20 +973,20 @@ - "{{ multi_attach_disk }}" - "{{ volume_without_tag }}" - - name: delete snapshot + - name: Delete snapshot amazon.aws.ec2_snapshot: snapshot_id: "{{ vol1_snapshot.snapshot_id }}" state: absent ignore_errors: true - - name: delete test subnet + - name: Delete test subnet amazon.aws.ec2_vpc_subnet: vpc_id: "{{ testing_vpc.vpc.id }}" cidr: "{{ subnet_cidr }}" state: absent ignore_errors: true - - name: delete test VPC + - name: Delete test VPC amazon.aws.ec2_vpc_net: name: "{{ vpc_name }}" cidr_block: "{{ vpc_cidr }}" diff --git a/tests/integration/targets/ec2_vpc_dhcp_option/tasks/main.yml b/tests/integration/targets/ec2_vpc_dhcp_option/tasks/main.yml index e3e59e2c6d1..dbd5147e834 100644 --- a/tests/integration/targets/ec2_vpc_dhcp_option/tasks/main.yml +++ b/tests/integration/targets/ec2_vpc_dhcp_option/tasks/main.yml @@ -16,21 +16,21 @@ block: # DHCP option set can be attached to multiple VPCs, we don't want to use any that # don't belong to this test run - - name: find all DHCP option sets that already exist before running tests + - name: Find all DHCP option sets that already exist before running tests amazon.aws.ec2_vpc_dhcp_option_info: register: result - ansible.builtin.set_fact: preexisting_option_sets: "{{ result.dhcp_options | map(attribute='dhcp_options_id') | list }}" - - name: create a VPC with a default DHCP option set to test inheritance and delete_old + - name: Create a VPC with a default DHCP option set to test inheritance and delete_old amazon.aws.ec2_vpc_net: name: "{{ resource_prefix }}" cidr_block: "{{ vpc_cidr }}" state: present register: vpc - - name: ensure a DHCP option set is attached to the VPC + - name: Ensure a DHCP option set is attached to the VPC ansible.builtin.assert: that: - vpc.vpc.dhcp_options_id is defined @@ -66,7 +66,7 @@ dhcp_options_id: "{{ new_dhcp_options.dhcp_options_id }}" ## ============================================ - - name: find the VPC's associated option set + - name: Find the VPC's associated option set amazon.aws.ec2_vpc_net_info: vpc_ids: "{{ vpc_id }}" register: vpc_info @@ -74,7 +74,7 @@ - ansible.builtin.set_fact: original_dhcp_options_id: "{{ vpc_info.vpcs[0].dhcp_options_id }}" - - name: get information about the DHCP option + - name: Get information about the DHCP option amazon.aws.ec2_vpc_dhcp_option_info: dhcp_options_ids: ["{{ original_dhcp_options_id }}"] register: original_dhcp_options_info @@ -94,7 +94,7 @@ # FIXME: always reassociated to lowest alphanum dhcp_options_id when vpc_id is provided without options, # This task will return an unpredictable dhcp_option_id so we can't assert anything about the option's values - - name: test a DHCP option exists (check mode) + - name: Test a DHCP option exists (check mode) amazon.aws.ec2_vpc_dhcp_option: state: present vpc_id: "{{ vpc_id }}" @@ -111,7 +111,7 @@ - not found_dhcp_options.changed # FIXME: always reassociated when vpc_id is provided without options, so here we provide the default options - - name: test a DHCP option exists + - name: Test a DHCP option exists amazon.aws.ec2_vpc_dhcp_option: state: present vpc_id: "{{ vpc_id }}" @@ -129,7 +129,7 @@ - original_dhcp_options_id == found_dhcp_options.dhcp_options_id # Create a DHCP option set that inherits from the default set and does not delete the old set - - name: create a DHCP option set that inherits from the default set (check mode) + - name: Create a DHCP option set that inherits from the default set (check mode) amazon.aws.ec2_vpc_dhcp_option: state: present vpc_id: "{{ vpc_id }}" @@ -149,7 +149,7 @@ that: - dhcp_options.changed - - name: create a DHCP option set that inherits from the default set + - name: Create a DHCP option set that inherits from the default set amazon.aws.ec2_vpc_dhcp_option: state: present vpc_id: "{{ vpc_id }}" @@ -188,7 +188,7 @@ - ansible.builtin.set_fact: new_dhcp_options_id: "{{ dhcp_options.dhcp_options_id }}" - - name: get information about the new DHCP option + - name: Get information about the new DHCP option amazon.aws.ec2_vpc_dhcp_option_info: dhcp_options_ids: ["{{ new_dhcp_options_id }}"] register: new_dhcp_options @@ -225,14 +225,14 @@ - result is success - result.dhcp_options_id == default_options_id - - name: delete it for the next test + - name: Delete it for the next test amazon.aws.ec2_vpc_dhcp_option: dhcp_options_id: "{{ new_dhcp_options_id }}" state: absent # Create a DHCP option set that does not inherit from the old set and doesn't delete the old set - - name: create a DHCP option set that does not inherit from the default set (check mode) + - name: Create a DHCP option set that does not inherit from the default set (check mode) amazon.aws.ec2_vpc_dhcp_option: state: present vpc_id: "{{ vpc_id }}" @@ -252,7 +252,7 @@ that: - dhcp_options.changed - - name: create a DHCP option set that does not inherit from the default set + - name: Create a DHCP option set that does not inherit from the default set amazon.aws.ec2_vpc_dhcp_option: state: present vpc_id: "{{ vpc_id }}" @@ -287,7 +287,7 @@ - ansible.builtin.set_fact: new_dhcp_options_id: "{{ dhcp_options.dhcp_options_id }}" - - name: get information about the new DHCP option + - name: Get information about the new DHCP option amazon.aws.ec2_vpc_dhcp_option_info: dhcp_options_ids: ["{{ new_dhcp_options_id }}"] register: new_dhcp_options @@ -302,19 +302,19 @@ - new_config['netbios-name-servers'] | map(attribute='value') | list | sort == ['10.0.0.1', '10.0.1.1'] - new_config['netbios-node-type'][0]['value'] == '2' - - name: disassociate the new DHCP option set so it can be deleted + - name: Disassociate the new DHCP option set so it can be deleted amazon.aws.ec2_vpc_dhcp_option: dhcp_options_id: "{{ original_dhcp_options_id }}" vpc_id: "{{ vpc_id }}" state: present - - name: delete it for the next test + - name: Delete it for the next test amazon.aws.ec2_vpc_dhcp_option: dhcp_options_id: "{{ new_dhcp_options_id }}" state: absent # Create a DHCP option set that inherits from the default set overwrites a default and deletes the old set - - name: create a DHCP option set that inherits from the default set and deletes the original set (check mode) + - name: Create a DHCP option set that inherits from the default set and deletes the original set (check mode) amazon.aws.ec2_vpc_dhcp_option: state: present vpc_id: "{{ vpc_id }}" @@ -335,7 +335,7 @@ that: - dhcp_options.changed - - name: create a DHCP option set that inherits from the default set and deletes the original set + - name: Create a DHCP option set that inherits from the default set and deletes the original set amazon.aws.ec2_vpc_dhcp_option: state: present vpc_id: "{{ vpc_id }}" @@ -365,7 +365,7 @@ - ansible.builtin.set_fact: new_dhcp_options_id: "{{ dhcp_options.dhcp_options_id }}" - - name: get information about the new DHCP option + - name: Get information about the new DHCP option amazon.aws.ec2_vpc_dhcp_option_info: dhcp_options_ids: ["{{ new_dhcp_options_id }}"] register: new_dhcp_options @@ -381,7 +381,7 @@ - new_config['netbios-name-servers'] | map(attribute='value') | list | sort == ['10.0.0.1', '10.0.1.1'] - new_config['netbios-node-type'][0]['value'] == '1' - - name: verify the original set was deleted + - name: Verify the original set was deleted amazon.aws.ec2_vpc_dhcp_option_info: dhcp_options_ids: ["{{ original_dhcp_options_id }}"] register: dhcp_options @@ -400,7 +400,7 @@ # Create a DHCP option set that does not inherit from the old set and deletes the old set - - name: create a DHCP option set that does not inherit from the default set and deletes the original set (check mode) + - name: Create a DHCP option set that does not inherit from the default set and deletes the original set (check mode) amazon.aws.ec2_vpc_dhcp_option: state: present vpc_id: "{{ vpc_id }}" @@ -416,7 +416,7 @@ that: - dhcp_options.changed - - name: create a DHCP option set that does not inherit from the default set and deletes the original set + - name: Create a DHCP option set that does not inherit from the default set and deletes the original set amazon.aws.ec2_vpc_dhcp_option: state: present vpc_id: "{{ vpc_id }}" @@ -438,7 +438,7 @@ - ansible.builtin.set_fact: new_dhcp_options_id: "{{ dhcp_options.dhcp_options_id }}" - - name: get information about the new DHCP option + - name: Get information about the new DHCP option amazon.aws.ec2_vpc_dhcp_option_info: dhcp_options_ids: ["{{ new_dhcp_options_id }}"] register: new_dhcp_options @@ -452,7 +452,7 @@ - new_config['domain-name'][0]['value'] == aws_domain_name - new_config['domain-name-servers'][0]['value'] == 'AmazonProvidedDNS' - - name: verify the original set was deleted + - name: Verify the original set was deleted amazon.aws.ec2_vpc_dhcp_option_info: dhcp_options_ids: ["{{ original_dhcp_options_id }}"] register: dhcp_options @@ -468,7 +468,7 @@ # Create a DHCP option set with tags - - name: create a DHCP option set with tags (check mode) + - name: Create a DHCP option set with tags (check mode) amazon.aws.ec2_vpc_dhcp_option: state: present vpc_id: "{{ vpc_id }}" @@ -491,7 +491,7 @@ that: - dhcp_options.changed - - name: create a DHCP option set with tags + - name: Create a DHCP option set with tags amazon.aws.ec2_vpc_dhcp_option: state: present vpc_id: "{{ vpc_id }}" @@ -528,7 +528,7 @@ - ansible.builtin.set_fact: new_dhcp_options_id: "{{ dhcp_options.dhcp_options_id }}" - - name: check if the expected tags are associated + - name: Check if the expected tags are associated amazon.aws.ec2_vpc_dhcp_option_info: dhcp_options_ids: ["{{ new_dhcp_options_id }}"] register: dhcp_options_info @@ -540,7 +540,7 @@ - dhcp_options_info.dhcp_options[0].tags['Collection'] == 'amazon.aws' - dhcp_options_info.dhcp_options[0].tags['CreatedBy'] == 'ansible-test' - - name: test no changes with the same tags (check mode) + - name: Test no changes with the same tags (check mode) amazon.aws.ec2_vpc_dhcp_option: state: present vpc_id: "{{ vpc_id }}" @@ -565,7 +565,7 @@ - dhcp_options.dhcp_config['netbios-name-servers'] | sort == ['10.0.0.1', '10.0.1.1'] - dhcp_options.dhcp_config['ntp-servers'] | sort == ['10.0.0.2', '10.0.1.2'] - - name: test no changes with the same tags + - name: Test no changes with the same tags amazon.aws.ec2_vpc_dhcp_option: state: present vpc_id: "{{ vpc_id }}" @@ -582,7 +582,7 @@ Collection: amazon.aws register: dhcp_options - - name: check if the expected tags are associated + - name: Check if the expected tags are associated amazon.aws.ec2_vpc_dhcp_option_info: dhcp_options_ids: ["{{ dhcp_options.dhcp_options_id }}"] register: dhcp_options_info @@ -602,7 +602,7 @@ - dhcp_options_info.dhcp_options[0].tags['Collection'] == 'amazon.aws' - dhcp_options_info.dhcp_options[0].tags['CreatedBy'] == 'ansible-test' - - name: test no changes without specifying tags (check mode) + - name: Test no changes without specifying tags (check mode) amazon.aws.ec2_vpc_dhcp_option: state: present vpc_id: "{{ vpc_id }}" @@ -625,7 +625,7 @@ - dhcp_options.dhcp_config['netbios-name-servers'] | sort == ['10.0.0.1', '10.0.1.1'] - dhcp_options.dhcp_config['ntp-servers'] | sort == ['10.0.0.2', '10.0.1.2'] - - name: test no changes without specifying tags + - name: Test no changes without specifying tags amazon.aws.ec2_vpc_dhcp_option: state: present vpc_id: "{{ vpc_id }}" @@ -640,7 +640,7 @@ purge_tags: false register: dhcp_options - - name: check if the expected tags are associated + - name: Check if the expected tags are associated amazon.aws.ec2_vpc_dhcp_option_info: dhcp_options_ids: ["{{ dhcp_options.dhcp_options_id }}"] register: dhcp_options_info @@ -657,7 +657,7 @@ - dhcp_options_info.dhcp_options[0].tags['Collection'] == 'amazon.aws' - dhcp_options_info.dhcp_options[0].tags['CreatedBy'] == 'ansible-test' - - name: add a tag without using dhcp_options_id + - name: Add a tag without using dhcp_options_id amazon.aws.ec2_vpc_dhcp_option: state: present vpc_id: "{{ vpc_id }}" @@ -675,7 +675,7 @@ another: tag register: dhcp_options - - name: check if the expected tags are associated + - name: Check if the expected tags are associated amazon.aws.ec2_vpc_dhcp_option_info: dhcp_options_ids: ["{{ dhcp_options.dhcp_options_id }}"] register: dhcp_options_info @@ -697,7 +697,7 @@ - dhcp_options_info.dhcp_options[0].tags['Collection'] == 'amazon.aws' - dhcp_options_info.dhcp_options[0].tags['CreatedBy'] == 'ansible-test' - - name: add and removing tags (check mode) + - name: Add and removing tags (check mode) amazon.aws.ec2_vpc_dhcp_option: dhcp_options_id: "{{ dhcp_options.dhcp_options_id }}" state: present @@ -720,7 +720,7 @@ that: - dhcp_options.changed - - name: add and remove tags + - name: Add and remove tags amazon.aws.ec2_vpc_dhcp_option: dhcp_options_id: "{{ dhcp_options.dhcp_options_id }}" state: present @@ -738,7 +738,7 @@ Collection: amazon.aws register: dhcp_options - - name: check if the expected tags are associated + - name: Check if the expected tags are associated amazon.aws.ec2_vpc_dhcp_option_info: dhcp_options_ids: ["{{ dhcp_options.dhcp_options_id }}"] register: dhcp_options_info @@ -755,7 +755,7 @@ - dhcp_options_info.dhcp_options[0].tags['Collection'] == 'amazon.aws' - dhcp_options_info.dhcp_options[0].tags['AnsibleTest'] == 'integration' - - name: add tags with different cases + - name: Add tags with different cases amazon.aws.ec2_vpc_dhcp_option: dhcp_options_id: "{{ dhcp_options.dhcp_options_id }}" state: present @@ -775,7 +775,7 @@ snake_case: simple_snake_case register: dhcp_options - - name: check if the expected tags are associated + - name: Check if the expected tags are associated amazon.aws.ec2_vpc_dhcp_option_info: dhcp_options_ids: ["{{ dhcp_options.dhcp_options_id }}"] register: dhcp_options_info @@ -796,7 +796,7 @@ - dhcp_options_info.dhcp_options[0].tags['CamelCase'] == 'SimpleCamelCase' - dhcp_options_info.dhcp_options[0].tags['snake_case'] == 'simple_snake_case' - - name: test purging all tags + - name: Test purging all tags amazon.aws.ec2_vpc_dhcp_option: dhcp_options_id: "{{ dhcp_options.dhcp_options_id }}" state: present @@ -812,7 +812,7 @@ tags: {} register: dhcp_options - - name: check if the expected tags are associated + - name: Check if the expected tags are associated amazon.aws.ec2_vpc_dhcp_option_info: dhcp_options_ids: ["{{ dhcp_options.dhcp_options_id }}"] register: dhcp_options_info @@ -823,7 +823,7 @@ - new_dhcp_options_id == dhcp_options.dhcp_options_id - not dhcp_options_info.dhcp_options[0].tags - - name: test removing all tags + - name: Test removing all tags amazon.aws.ec2_vpc_dhcp_option: dhcp_options_id: "{{ dhcp_options.dhcp_options_id }}" state: present @@ -839,7 +839,7 @@ tags: {} register: dhcp_options - - name: check if the expected tags are associated + - name: Check if the expected tags are associated amazon.aws.ec2_vpc_dhcp_option_info: dhcp_options_ids: ["{{ dhcp_options.dhcp_options_id }}"] register: dhcp_options_info @@ -850,7 +850,7 @@ - new_dhcp_options_id == dhcp_options.dhcp_options_id - not dhcp_options_info.dhcp_options[0].tags - - name: remove the DHCP option set (check mode) + - name: Remove the DHCP option set (check mode) amazon.aws.ec2_vpc_dhcp_option: state: absent vpc_id: "{{ vpc_id }}" @@ -863,7 +863,7 @@ # - dhcp_options.changed # FIXME: does nothing - the module should associate "default" with the VPC provided but currently does not - - name: removing the DHCP option set + - name: Removing the DHCP option set amazon.aws.ec2_vpc_dhcp_option: state: absent vpc_id: "{{ vpc_id }}" @@ -874,7 +874,7 @@ # that: # - dhcp_options.changed - - name: remove the DHCP option set again (check mode) + - name: Remove the DHCP option set again (check mode) amazon.aws.ec2_vpc_dhcp_option: state: absent vpc_id: "{{ vpc_id }}" @@ -886,7 +886,7 @@ that: - not dhcp_options.changed - - name: remove the DHCP option set again + - name: Remove the DHCP option set again amazon.aws.ec2_vpc_dhcp_option: state: absent vpc_id: "{{ vpc_id }}" @@ -913,7 +913,7 @@ tag:Name: "*'{{ resource_prefix }}*" register: option_sets - - name: clean up DHCP option sets + - name: Clean up DHCP option sets amazon.aws.ec2_vpc_dhcp_option: state: absent dhcp_options_id: "{{ original_dhcp_options_id }}" @@ -921,7 +921,7 @@ when: original_dhcp_options_id is defined ignore_errors: true - - name: clean up DHCP option sets + - name: Clean up DHCP option sets amazon.aws.ec2_vpc_dhcp_option: state: absent dhcp_options_id: "{{ new_dhcp_options_id }}" diff --git a/tests/integration/targets/ec2_vpc_egress_igw/tasks/main.yml b/tests/integration/targets/ec2_vpc_egress_igw/tasks/main.yml index db58384a65c..43fa19e50b9 100644 --- a/tests/integration/targets/ec2_vpc_egress_igw/tasks/main.yml +++ b/tests/integration/targets/ec2_vpc_egress_igw/tasks/main.yml @@ -2,224 +2,223 @@ - name: Run ec2_vpc_egress_igw 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: Test failure with no parameters - amazon.aws.ec2_vpc_egress_igw: - register: result - ignore_errors: true + - name: Test failure with no parameters + amazon.aws.ec2_vpc_egress_igw: + register: result + ignore_errors: true - - name: Assert failure with no parameters - assert: - that: - - result is failed - - 'result.msg == "missing required arguments: vpc_id"' + - name: Assert failure with no parameters + ansible.builtin.assert: + that: + - result is failed + - 'result.msg == "missing required arguments: vpc_id"' - # ============================================================ - - name: Test failure with non-existent VPC ID - amazon.aws.ec2_vpc_egress_igw: - state: present - vpc_id: vpc-02394e50abc1807e8 - register: result - ignore_errors: true - - - name: Assert failure with non-existent VPC ID - assert: - that: - - result is failed - - e_msg in result.exception - vars: - e_msg: "The vpc ID 'vpc-02394e50abc1807e8' does not exist" + # ============================================================ + - name: Test failure with non-existent VPC ID + amazon.aws.ec2_vpc_egress_igw: + state: present + vpc_id: vpc-02394e50abc1807e8 + register: result + ignore_errors: true - # ============================================================ - - name: Create a VPC - amazon.aws.ec2_vpc_net: - name: "{{ resource_prefix }}-vpc" - state: present - cidr_block: "10.232.232.128/26" - tags: - Name: "{{ resource_prefix }}-vpc" - Description: "Created by ansible-test" - register: vpc_result + - name: Assert failure with non-existent VPC ID + ansible.builtin.assert: + that: + - result is failed + - e_msg in result.exception + vars: + e_msg: "The vpc ID 'vpc-02394e50abc1807e8' does not exist" - # ============================================================ - - name: Create egress-only internet gateway using check_mode=true - amazon.aws.ec2_vpc_egress_igw: - state: present - vpc_id: "{{ vpc_result.vpc.id }}" - register: vpc_eigw_create_check_mode - check_mode: true - - - name: List all Egress only internet gateway - amazon.aws.ec2_vpc_egress_igw_info: - register: egress_only_igws - - - name: Assert module returned changed and the Egress IGW was not created - assert: - that: + # ============================================================ + - name: Create a VPC + amazon.aws.ec2_vpc_net: + name: "{{ resource_prefix }}-vpc" + state: present + cidr_block: "10.232.232.128/26" + tags: + Name: "{{ resource_prefix }}-vpc" + Description: "Created by ansible-test" + register: vpc_result + + # ============================================================ + - name: Create egress-only internet gateway using check_mode=true + amazon.aws.ec2_vpc_egress_igw: + state: present + vpc_id: "{{ vpc_result.vpc.id }}" + register: vpc_eigw_create_check_mode + check_mode: true + + - name: List all Egress only internet gateway + amazon.aws.ec2_vpc_egress_igw_info: + register: egress_only_igws + + - name: Assert module returned changed and the Egress IGW was not created + ansible.builtin.assert: + that: - vpc_eigw_create_check_mode is changed - egress_only_igws.egress_only_internet_gateways | selectattr('attachments.0.vpc_id', 'equalto', vpc_result.vpc.id) | list == [] - # # ============================================================ - - name: Create egress-only internet gateway (expected changed=true) - amazon.aws.ec2_vpc_egress_igw: - state: present - vpc_id: "{{ vpc_result.vpc.id }}" - register: vpc_eigw_create + # # ============================================================ + - name: Create egress-only internet gateway (expected changed=true) + amazon.aws.ec2_vpc_egress_igw: + state: present + vpc_id: "{{ vpc_result.vpc.id }}" + register: vpc_eigw_create - - name: List all Egress only internet gateway - amazon.aws.ec2_vpc_egress_igw_info: - register: egress_only_igws + - name: List all Egress only internet gateway + amazon.aws.ec2_vpc_egress_igw_info: + register: egress_only_igws - - name: Assert module returned changed and the Egress IGW was not created - ansible.builtin.assert: - that: + - name: Assert module returned changed and the Egress IGW was not created + ansible.builtin.assert: + that: - vpc_eigw_create is changed - egress_only_igws.egress_only_internet_gateways | selectattr('attachments.0.vpc_id', 'equalto', vpc_result.vpc.id) | list | length == 1 - # # ============================================================ - - name: Create egress-only internet gateway once again (idempotency) - amazon.aws.ec2_vpc_egress_igw: - state: present - vpc_id: "{{ vpc_result.vpc.id }}" - register: vpc_eigw_create_idempotency + # # ============================================================ + - name: Create egress-only internet gateway once again (idempotency) + amazon.aws.ec2_vpc_egress_igw: + state: present + vpc_id: "{{ vpc_result.vpc.id }}" + register: vpc_eigw_create_idempotency - - name: List all Egress only internet gateway - amazon.aws.ec2_vpc_egress_igw_info: - register: egress_only_igws + - name: List all Egress only internet gateway + amazon.aws.ec2_vpc_egress_igw_info: + register: egress_only_igws - - name: Assert module returned changed and the Egress IGW was not created - ansible.builtin.assert: - that: + - name: Assert module returned changed and the Egress IGW was not created + ansible.builtin.assert: + that: - vpc_eigw_create_idempotency is not changed - vpc_eigw_create_idempotency.gateway_id == vpc_eigw_create.gateway_id - egress_only_igws.egress_only_internet_gateways | selectattr('attachments.0.vpc_id', 'equalto', vpc_result.vpc.id) | list | length == 1 - # # ============================================================ - - name: Delete egress-only internet gateway (check_mode) - amazon.aws.ec2_vpc_egress_igw: - state: absent - vpc_id: "{{ vpc_result.vpc.id }}" - register: vpc_eigw_delete_check_mode - check_mode: true - - - name: List all Egress only internet gateway - amazon.aws.ec2_vpc_egress_igw_info: - register: egress_only_igws - - - name: Assert module returned changed and the Egress IGW was not created - ansible.builtin.assert: - that: + # # ============================================================ + - name: Delete egress-only internet gateway (check_mode) + amazon.aws.ec2_vpc_egress_igw: + state: absent + vpc_id: "{{ vpc_result.vpc.id }}" + register: vpc_eigw_delete_check_mode + check_mode: true + + - name: List all Egress only internet gateway + amazon.aws.ec2_vpc_egress_igw_info: + register: egress_only_igws + + - name: Assert module returned changed and the Egress IGW was not created + ansible.builtin.assert: + that: - vpc_eigw_delete_check_mode is changed - vpc_eigw_create_idempotency.gateway_id == vpc_eigw_delete_check_mode.gateway_id - egress_only_igws.egress_only_internet_gateways | selectattr('attachments.0.vpc_id', 'equalto', vpc_result.vpc.id) | list | length == 1 - # # ============================================================ - - name: Delete egress-only internet gateway once again (idempotency) - amazon.aws.ec2_vpc_egress_igw: - state: absent - vpc_id: "{{ vpc_result.vpc.id }}" - register: vpc_eigw_delete - - - name: List all Egress only internet gateway - amazon.aws.ec2_vpc_egress_igw_info: - register: egress_only_igws - - - name: Assert module returned changed and the Egress IGW was not created - ansible.builtin.assert: - that: - - vpc_eigw_delete is changed - - vpc_eigw_create_idempotency.gateway_id == vpc_eigw_delete.gateway_id - - egress_only_igws.egress_only_internet_gateways | selectattr('attachments.0.vpc_id', 'equalto', vpc_result.vpc.id) | list == [] - - # # ============================================================ - - name: Delete egress-only internet gateway - amazon.aws.ec2_vpc_egress_igw: - state: absent - vpc_id: "{{ vpc_result.vpc.id }}" - register: vpc_eigw_delete_idempotency - - - name: Assert module returned changed and the Egress IGW was not created - ansible.builtin.assert: - that: - - vpc_eigw_delete_idempotency is not changed - - ## ============================================================ - ## Tagging - - name: Create Egress only internet gateway with tags - amazon.aws.ec2_vpc_egress_igw: - vpc_id: "{{ vpc_result.vpc.id }}" - tags: - ResourcePrefix: "{{ resource_prefix }}" - VpcId: "{{ vpc_result.vpc.id }}" - register: create_with_tags - - - name: List all Egress only internet gateway - amazon.aws.ec2_vpc_egress_igw_info: - register: egress_only_igws - - - name: Assert that the Egress IGW was created with tags - ansible.builtin.assert: - that: - - create_with_tags is changed - - egress_info.tags == resource_tags - vars: - egress_info: "{{ egress_only_igws.egress_only_internet_gateways | selectattr('attachments.0.vpc_id', 'equalto', vpc_result.vpc.id) | list | first }}" - resource_tags: - ResourcePrefix: "{{ resource_prefix }}" - VpcId: "{{ vpc_result.vpc.id }}" - - - name: Trying to update tags (no change) - amazon.aws.ec2_vpc_egress_igw: - vpc_id: "{{ vpc_result.vpc.id }}" - tags: - ResourcePrefix: "{{ resource_prefix }}" - VpcId: "{{ vpc_result.vpc.id }}" - register: update_tags - - - name: List all Egress only internet gateway - amazon.aws.ec2_vpc_egress_igw_info: - register: egress_only_igws - - - name: Assert that the Egress IGW was not updated - ansible.builtin.assert: - that: - - update_tags is not changed - - egress_info.tags == resource_tags - vars: - egress_info: "{{ egress_only_igws.egress_only_internet_gateways | selectattr('attachments.0.vpc_id', 'equalto', vpc_result.vpc.id) | list | first }}" - resource_tags: - ResourcePrefix: "{{ resource_prefix }}" - VpcId: "{{ vpc_result.vpc.id }}" - - - name: Add tag to existing tags - amazon.aws.ec2_vpc_egress_igw: - vpc_id: "{{ vpc_result.vpc.id }}" - tags: - Phase: integration - purge_tags: false - register: add_tag - - - name: List all Egress only internet gateway - amazon.aws.ec2_vpc_egress_igw_info: - register: egress_only_igws - - - name: Assert that the Egress IGW was created with tags - ansible.builtin.assert: - that: - - add_tag is changed - - egress_info.tags == resource_tags - vars: - egress_info: "{{ egress_only_igws.egress_only_internet_gateways | selectattr('attachments.0.vpc_id', 'equalto', vpc_result.vpc.id) | list | first }}" - resource_tags: - ResourcePrefix: "{{ resource_prefix }}" - VpcId: "{{ vpc_result.vpc.id }}" - Phase: integration + # # ============================================================ + - name: Delete egress-only internet gateway once again (idempotency) + amazon.aws.ec2_vpc_egress_igw: + state: absent + vpc_id: "{{ vpc_result.vpc.id }}" + register: vpc_eigw_delete + + - name: List all Egress only internet gateway + amazon.aws.ec2_vpc_egress_igw_info: + register: egress_only_igws + + - name: Assert module returned changed and the Egress IGW was not created + ansible.builtin.assert: + that: + - vpc_eigw_delete is changed + - vpc_eigw_create_idempotency.gateway_id == vpc_eigw_delete.gateway_id + - egress_only_igws.egress_only_internet_gateways | selectattr('attachments.0.vpc_id', 'equalto', vpc_result.vpc.id) | list == [] + + # # ============================================================ + - name: Delete egress-only internet gateway + amazon.aws.ec2_vpc_egress_igw: + state: absent + vpc_id: "{{ vpc_result.vpc.id }}" + register: vpc_eigw_delete_idempotency + + - name: Assert module returned changed and the Egress IGW was not created + ansible.builtin.assert: + that: + - vpc_eigw_delete_idempotency is not changed + + ## ============================================================ + ## Tagging + - name: Create Egress only internet gateway with tags + amazon.aws.ec2_vpc_egress_igw: + vpc_id: "{{ vpc_result.vpc.id }}" + tags: + ResourcePrefix: "{{ resource_prefix }}" + VpcId: "{{ vpc_result.vpc.id }}" + register: create_with_tags + + - name: List all Egress only internet gateway + amazon.aws.ec2_vpc_egress_igw_info: + register: egress_only_igws + + - name: Assert that the Egress IGW was created with tags + ansible.builtin.assert: + that: + - create_with_tags is changed + - egress_info.tags == resource_tags + vars: + egress_info: "{{ egress_only_igws.egress_only_internet_gateways | selectattr('attachments.0.vpc_id', 'equalto', vpc_result.vpc.id) | list | first }}" + resource_tags: + ResourcePrefix: "{{ resource_prefix }}" + VpcId: "{{ vpc_result.vpc.id }}" + + - name: Trying to update tags (no change) + amazon.aws.ec2_vpc_egress_igw: + vpc_id: "{{ vpc_result.vpc.id }}" + tags: + ResourcePrefix: "{{ resource_prefix }}" + VpcId: "{{ vpc_result.vpc.id }}" + register: update_tags + + - name: List all Egress only internet gateway + amazon.aws.ec2_vpc_egress_igw_info: + register: egress_only_igws + + - name: Assert that the Egress IGW was not updated + ansible.builtin.assert: + that: + - update_tags is not changed + - egress_info.tags == resource_tags + vars: + egress_info: "{{ egress_only_igws.egress_only_internet_gateways | selectattr('attachments.0.vpc_id', 'equalto', vpc_result.vpc.id) | list | first }}" + resource_tags: + ResourcePrefix: "{{ resource_prefix }}" + VpcId: "{{ vpc_result.vpc.id }}" + + - name: Add tag to existing tags + amazon.aws.ec2_vpc_egress_igw: + vpc_id: "{{ vpc_result.vpc.id }}" + tags: + Phase: integration + purge_tags: false + register: add_tag + + - name: List all Egress only internet gateway + amazon.aws.ec2_vpc_egress_igw_info: + register: egress_only_igws + + - name: Assert that the Egress IGW was created with tags + ansible.builtin.assert: + that: + - add_tag is changed + - egress_info.tags == resource_tags + vars: + egress_info: "{{ egress_only_igws.egress_only_internet_gateways | selectattr('attachments.0.vpc_id', 'equalto', vpc_result.vpc.id) | list | first }}" + resource_tags: + ResourcePrefix: "{{ resource_prefix }}" + VpcId: "{{ vpc_result.vpc.id }}" + Phase: integration always: # ============================================================ diff --git a/tests/integration/targets/ec2_vpc_endpoint/tasks/main.yml b/tests/integration/targets/ec2_vpc_endpoint/tasks/main.yml index aa29d6e7425..15ddd13db17 100644 --- a/tests/integration/targets/ec2_vpc_endpoint/tasks/main.yml +++ b/tests/integration/targets/ec2_vpc_endpoint/tasks/main.yml @@ -1,5 +1,5 @@ --- -- name: ec2_vpc_endpoint tests +- name: Ec2_vpc_endpoint tests module_defaults: group/aws: access_key: "{{ aws_access_key }}" @@ -9,7 +9,7 @@ block: # ============================================================ # BEGIN PRE-TEST SETUP - - name: create a VPC + - name: Create a VPC amazon.aws.ec2_vpc_net: state: present name: "{{ vpc_name }}" @@ -716,7 +716,7 @@ amazon.aws.ec2_vpc_subnet: state: present vpc_id: "{{ vpc_id }}" - az: "{{ aws_region}}a" + az: "{{ aws_region }}a" cidr: "{{ vpc_cidr }}" register: interface_endpoint_create_subnet_check @@ -787,4 +787,4 @@ name: setup_ec2_vpc tasks_from: cleanup.yml vars: - vpc_id: "{{ vpc_creation.vpc.id }}" + setup_ec2_vpc_id: "{{ vpc_creation.vpc.id }}" diff --git a/tests/integration/targets/ec2_vpc_igw/tasks/main.yml b/tests/integration/targets/ec2_vpc_igw/tasks/main.yml index cad21c5712d..588fa10f2e8 100644 --- a/tests/integration/targets/ec2_vpc_igw/tasks/main.yml +++ b/tests/integration/targets/ec2_vpc_igw/tasks/main.yml @@ -1,5 +1,5 @@ --- -- name: ec2_vpc_igw tests +- name: Ec2_vpc_igw tests module_defaults: group/aws: access_key: "{{ aws_access_key }}" @@ -384,7 +384,7 @@ snake_case: simple_snake_case register: vpc_igw_update - - name: assert tags are updated (expected changed=true) + - name: Assert tags are updated (expected changed=true) ansible.builtin.assert: that: - vpc_igw_update is changed @@ -764,7 +764,7 @@ - name: Test state=absent when supplying a gateway id and wrong vpc id (expected failure) amazon.aws.ec2_vpc_igw: state: absent - internet_gateway_id: "{{ detached_igw_result.gateway_id}}" + internet_gateway_id: "{{ detached_igw_result.gateway_id }}" vpc_id: vpc-xxxxxxxxx register: vpc_igw_delete ignore_errors: true diff --git a/tests/integration/targets/ec2_vpc_nacl/defaults/main.yml b/tests/integration/targets/ec2_vpc_nacl/defaults/main.yml index 5ac931209fb..1c547cbf5f3 100644 --- a/tests/integration/targets/ec2_vpc_nacl/defaults/main.yml +++ b/tests/integration/targets/ec2_vpc_nacl/defaults/main.yml @@ -1,12 +1,12 @@ --- -vpc_name: '{{ resource_prefix }}-ec2-vpc-nacl' -nacl_name: '{{ resource_prefix }}-ec2-vpc-nacl' -subnet_name: '{{ resource_prefix }}-ec2-vpc-nacl' -vpc_cidr: '10.{{ 256 | random(seed=resource_prefix) }}.0.0/16' -subnet_1: '10.{{ 256 | random(seed=resource_prefix) }}.1.0/24' -subnet_2: '10.{{ 256 | random(seed=resource_prefix) }}.2.0/24' -subnet_3: '10.{{ 256 | random(seed=resource_prefix) }}.3.0/24' -subnet_4: '10.{{ 256 | random(seed=resource_prefix) }}.4.0/24' +vpc_name: "{{ resource_prefix }}-ec2-vpc-nacl" +nacl_name: "{{ resource_prefix }}-ec2-vpc-nacl" +subnet_name: "{{ resource_prefix }}-ec2-vpc-nacl" +vpc_cidr: "10.{{ 256 | random(seed=resource_prefix) }}.0.0/16" +subnet_1: "10.{{ 256 | random(seed=resource_prefix) }}.1.0/24" +subnet_2: "10.{{ 256 | random(seed=resource_prefix) }}.2.0/24" +subnet_3: "10.{{ 256 | random(seed=resource_prefix) }}.3.0/24" +subnet_4: "10.{{ 256 | random(seed=resource_prefix) }}.4.0/24" -vpc_ipv6_cidr: '10.{{ 256 | random(seed=resource_prefix) }}.5.0/25' -vpc_ipv6_name: '{{ vpc_name }}-ipv6' +vpc_ipv6_cidr: "10.{{ 256 | random(seed=resource_prefix) }}.5.0/25" +vpc_ipv6_name: "{{ vpc_name }}-ipv6" diff --git a/tests/integration/targets/ec2_vpc_nacl/meta/main.yml b/tests/integration/targets/ec2_vpc_nacl/meta/main.yml index 32cf5dda7ed..23d65c7ef45 100644 --- a/tests/integration/targets/ec2_vpc_nacl/meta/main.yml +++ b/tests/integration/targets/ec2_vpc_nacl/meta/main.yml @@ -1 +1,2 @@ +--- dependencies: [] diff --git a/tests/integration/targets/ec2_vpc_nacl/tasks/ingress_and_egress.yml b/tests/integration/targets/ec2_vpc_nacl/tasks/ingress_and_egress.yml index 584a9bcec0f..3d7aaa9c284 100644 --- a/tests/integration/targets/ec2_vpc_nacl/tasks/ingress_and_egress.yml +++ b/tests/integration/targets/ec2_vpc_nacl/tasks/ingress_and_egress.yml @@ -1,159 +1,160 @@ +--- # ============================================================ - name: Test Ingress and Egress rules block: - - name: Create ingress and egress rules using subnet IDs - amazon.aws.ec2_vpc_nacl: - vpc_id: "{{ vpc_id }}" - name: "{{ nacl_name }}" - subnets: "{{ subnet_ids }}" - tags: - Created_by: "Ansible test {{ resource_prefix }}" - ingress: - - [100, 'tcp', 'allow', '0.0.0.0/0', null, null, 22, 22] - - [200, 'tcp', 'allow', '0.0.0.0/0', null, null, 80, 80] - - [300, 'icmp', 'allow', '0.0.0.0/0', 0, 8] - egress: - - [100, 'all', 'allow', '0.0.0.0/0', null, null, null, null] - state: 'present' - register: nacl - - - name: Assert the network acl was created - ansible.builtin.assert: - that: - - nacl.changed - - nacl.nacl_id.startswith('acl-') - - - name: Get network ACL facts - amazon.aws.ec2_vpc_nacl_info: - nacl_ids: - - "{{ nacl.nacl_id }}" - register: nacl_facts - - - name: Assert the nacl has the correct attributes - ansible.builtin.assert: - that: - - nacl_facts.nacls | length == 1 - - nacl_facts.nacls[0].ingress | length == 3 - - nacl_facts.nacls[0].egress | length == 1 + - name: Create ingress and egress rules using subnet IDs + amazon.aws.ec2_vpc_nacl: + vpc_id: "{{ vpc_id }}" + name: "{{ nacl_name }}" + subnets: "{{ subnet_ids }}" + tags: + Created_by: "Ansible test {{ resource_prefix }}" + ingress: + - [100, "tcp", "allow", "0.0.0.0/0", !!null "", !!null "", 22, 22] + - [200, "tcp", "allow", "0.0.0.0/0", !!null "", !!null "", 80, 80] + - [300, "icmp", "allow", "0.0.0.0/0", 0, 8] + egress: + - [100, "all", "allow", "0.0.0.0/0", !!null "", !!null "", !!null "", !!null ""] + state: "present" + register: nacl + + - name: Assert the network acl was created + ansible.builtin.assert: + that: + - nacl.changed + - nacl.nacl_id.startswith('acl-') + + - name: Get network ACL facts + amazon.aws.ec2_vpc_nacl_info: + nacl_ids: + - "{{ nacl.nacl_id }}" + register: nacl_facts + + - name: Assert the nacl has the correct attributes + ansible.builtin.assert: + that: + - nacl_facts.nacls | length == 1 + - nacl_facts.nacls[0].ingress | length == 3 + - nacl_facts.nacls[0].egress | length == 1 # ============================================================ - - name: Remove an ingress rule - amazon.aws.ec2_vpc_nacl: - vpc_id: "{{ vpc_id }}" - name: "{{ nacl_name }}" - subnets: "{{ subnet_ids }}" - tags: - Created_by: "Ansible test {{ resource_prefix }}" - ingress: - - [100, 'tcp', 'allow', '0.0.0.0/0', null, null, 22, 22] - - [200, 'tcp', 'allow', '0.0.0.0/0', null, null, 80, 80] - egress: - - [100, 'all', 'allow', '0.0.0.0/0', null, null, null, null] - state: 'present' - register: nacl - - - name: Assert the network acl changed - ansible.builtin.assert: - that: - - nacl.changed - - nacl.nacl_id.startswith('acl-') - - - name: Get network ACL facts - amazon.aws.ec2_vpc_nacl_info: - nacl_ids: - - "{{ nacl.nacl_id }}" - register: nacl_facts - - - name: Assert the nacl has the correct attributes - ansible.builtin.assert: - that: - - nacl_facts.nacls | length == 1 - - nacl_facts.nacls[0].ingress | length == 2 - - nacl_facts.nacls[0].egress | length == 1 + - name: Remove an ingress rule + amazon.aws.ec2_vpc_nacl: + vpc_id: "{{ vpc_id }}" + name: "{{ nacl_name }}" + subnets: "{{ subnet_ids }}" + tags: + Created_by: "Ansible test {{ resource_prefix }}" + ingress: + - [100, "tcp", "allow", "0.0.0.0/0", !!null "", !!null "", 22, 22] + - [200, "tcp", "allow", "0.0.0.0/0", !!null "", !!null "", 80, 80] + egress: + - [100, "all", "allow", "0.0.0.0/0", !!null "", !!null "", !!null "", !!null ""] + state: "present" + register: nacl + + - name: Assert the network acl changed + ansible.builtin.assert: + that: + - nacl.changed + - nacl.nacl_id.startswith('acl-') + + - name: Get network ACL facts + amazon.aws.ec2_vpc_nacl_info: + nacl_ids: + - "{{ nacl.nacl_id }}" + register: nacl_facts + + - name: Assert the nacl has the correct attributes + ansible.builtin.assert: + that: + - nacl_facts.nacls | length == 1 + - nacl_facts.nacls[0].ingress | length == 2 + - nacl_facts.nacls[0].egress | length == 1 # ============================================================ - - name: Remove the egress rule - amazon.aws.ec2_vpc_nacl: - vpc_id: "{{ vpc_id }}" - name: "{{ nacl_name }}" - subnets: "{{ subnet_ids }}" - tags: - Created_by: "Ansible test {{ resource_prefix }}" - ingress: - - [100, 'tcp', 'allow', '0.0.0.0/0', null, null, 22, 22] - - [200, 'tcp', 'allow', '0.0.0.0/0', null, null, 80, 80] - egress: [] - state: 'present' - register: nacl - - - name: Assert the network acl changed - ansible.builtin.assert: - that: - - nacl.changed - - nacl.nacl_id.startswith('acl-') - - - name: Get network ACL facts - amazon.aws.ec2_vpc_nacl_info: - nacl_ids: - - "{{ nacl.nacl_id }}" - register: nacl_facts - - - name: Assert the nacl has the correct attributes - ansible.builtin.assert: - that: - - nacl_facts.nacls | length == 1 - - nacl_facts.nacls[0].ingress | length == 2 - - nacl_facts.nacls[0].egress | length == 0 + - name: Remove the egress rule + amazon.aws.ec2_vpc_nacl: + vpc_id: "{{ vpc_id }}" + name: "{{ nacl_name }}" + subnets: "{{ subnet_ids }}" + tags: + Created_by: "Ansible test {{ resource_prefix }}" + ingress: + - [100, "tcp", "allow", "0.0.0.0/0", !!null "", !!null "", 22, 22] + - [200, "tcp", "allow", "0.0.0.0/0", !!null "", !!null "", 80, 80] + egress: [] + state: "present" + register: nacl + + - name: Assert the network acl changed + ansible.builtin.assert: + that: + - nacl.changed + - nacl.nacl_id.startswith('acl-') + + - name: Get network ACL facts + amazon.aws.ec2_vpc_nacl_info: + nacl_ids: + - "{{ nacl.nacl_id }}" + register: nacl_facts + + - name: Assert the nacl has the correct attributes + ansible.builtin.assert: + that: + - nacl_facts.nacls | length == 1 + - nacl_facts.nacls[0].ingress | length == 2 + - nacl_facts.nacls[0].egress | length == 0 # ============================================================ - - name: Add egress rules - amazon.aws.ec2_vpc_nacl: - vpc_id: "{{ vpc_id }}" - name: "{{ nacl_name }}" - subnets: "{{ subnet_ids }}" - tags: - Created_by: "Ansible test {{ resource_prefix }}" - ingress: - - [100, 'tcp', 'allow', '0.0.0.0/0', null, null, 22, 22] - - [200, 'tcp', 'allow', '0.0.0.0/0', null, null, 80, 80] - egress: - - [100, 'tcp', 'allow', '10.0.0.0/24', null, null, 22, 22] - - [200, 'udp', 'allow', '10.0.0.0/24', null, null, 22, 22] - state: 'present' - register: nacl - - - name: Assert the network acl changed - ansible.builtin.assert: - that: - - nacl.changed - - nacl.nacl_id.startswith('acl-') - - - name: Get network ACL facts - amazon.aws.ec2_vpc_nacl_info: - nacl_ids: - - "{{ nacl.nacl_id }}" - register: nacl_facts - - - name: Assert the nacl has the correct attributes - ansible.builtin.assert: - that: - - nacl_facts.nacls | length == 1 - - nacl_facts.nacls[0].ingress | length == 2 - - nacl_facts.nacls[0].egress | length == 2 + - name: Add egress rules + amazon.aws.ec2_vpc_nacl: + vpc_id: "{{ vpc_id }}" + name: "{{ nacl_name }}" + subnets: "{{ subnet_ids }}" + tags: + Created_by: "Ansible test {{ resource_prefix }}" + ingress: + - [100, "tcp", "allow", "0.0.0.0/0", !!null "", !!null "", 22, 22] + - [200, "tcp", "allow", "0.0.0.0/0", !!null "", !!null "", 80, 80] + egress: + - [100, "tcp", "allow", "10.0.0.0/24", !!null "", !!null "", 22, 22] + - [200, "udp", "allow", "10.0.0.0/24", !!null "", !!null "", 22, 22] + state: "present" + register: nacl + + - name: Assert the network acl changed + ansible.builtin.assert: + that: + - nacl.changed + - nacl.nacl_id.startswith('acl-') + + - name: Get network ACL facts + amazon.aws.ec2_vpc_nacl_info: + nacl_ids: + - "{{ nacl.nacl_id }}" + register: nacl_facts + + - name: Assert the nacl has the correct attributes + ansible.builtin.assert: + that: + - nacl_facts.nacls | length == 1 + - nacl_facts.nacls[0].ingress | length == 2 + - nacl_facts.nacls[0].egress | length == 2 # ============================================================ - - name: Remove the network ACL - amazon.aws.ec2_vpc_nacl: - vpc_id: "{{ vpc_id }}" - name: "{{ nacl_name }}" - state: absent - register: nacl - - - name: Assert nacl was removed - ansible.builtin.assert: - that: - - nacl.changed + - name: Remove the network ACL + amazon.aws.ec2_vpc_nacl: + vpc_id: "{{ vpc_id }}" + name: "{{ nacl_name }}" + state: absent + register: nacl + + - name: Assert nacl was removed + ansible.builtin.assert: + that: + - nacl.changed diff --git a/tests/integration/targets/ec2_vpc_nacl/tasks/ipv6.yml b/tests/integration/targets/ec2_vpc_nacl/tasks/ipv6.yml index 5ac3819723e..c0425e6621d 100644 --- a/tests/integration/targets/ec2_vpc_nacl/tasks/ipv6.yml +++ b/tests/integration/targets/ec2_vpc_nacl/tasks/ipv6.yml @@ -1,6 +1,6 @@ +--- - name: Test using IPv6 block: - # ============================================================ - name: Create ingress and egress rules using subnet names @@ -12,12 +12,12 @@ tags: Created_by: "Ansible test {{ resource_prefix }}" ingress: - - [100, 'tcp', 'allow', '0.0.0.0/0', null, null, 22, 22] - - [200, 'tcp', 'allow', '0.0.0.0/0', null, null, 80, 80] - - [300, 'icmp', 'allow', '0.0.0.0/0', 0, 8] + - [100, "tcp", "allow", "0.0.0.0/0", !!null "", !!null "", 22, 22] + - [200, "tcp", "allow", "0.0.0.0/0", !!null "", !!null "", 80, 80] + - [300, "icmp", "allow", "0.0.0.0/0", 0, 8] egress: - - [100, 'all', 'allow', '0.0.0.0/0', null, null, null, null] - state: 'present' + - [100, "all", "allow", "0.0.0.0/0", !!null "", !!null "", !!null "", !!null ""] + state: "present" register: nacl - name: Assert that module returned the Network ACL id @@ -38,22 +38,22 @@ tags: Created_by: "Ansible test {{ resource_prefix }}" ingress: - - [100, 'tcp', 'allow', '0.0.0.0/0', null, null, 22, 22] - - [200, 'tcp', 'allow', '0.0.0.0/0', null, null, 80, 80] - - [205, 'tcp', 'allow', '::/0', null, null, 80, 80] - - [300, 'icmp', 'allow', '0.0.0.0/0', 0, 8] - - [305, 'ipv6-icmp', 'allow', '::/0', 0, 8] + - [100, "tcp", "allow", "0.0.0.0/0", !!null "", !!null "", 22, 22] + - [200, "tcp", "allow", "0.0.0.0/0", !!null "", !!null "", 80, 80] + - [205, "tcp", "allow", "::/0", !!null "", !!null "", 80, 80] + - [300, "icmp", "allow", "0.0.0.0/0", 0, 8] + - [305, "ipv6-icmp", "allow", "::/0", 0, 8] egress: - - [100, 'all', 'allow', '0.0.0.0/0', null, null, null, null] - - [105, 'all', 'allow', '::/0', null, null, null, null] - state: 'present' + - [100, "all", "allow", "0.0.0.0/0", !!null "", !!null "", !!null "", !!null ""] + - [105, "all", "allow", "::/0", !!null "", !!null "", !!null "", !!null ""] + state: "present" register: nacl - name: Assert that module reported change while the Network ACL remained unchanged ansible.builtin.assert: - that: - - nacl.changed - - nacl.nacl_id == nacl_id + that: + - nacl.changed + - nacl.nacl_id == nacl_id - name: Get network ACL facts (test that it works with ipv6 entries) amazon.aws.ec2_vpc_nacl_info: @@ -78,16 +78,16 @@ Created_by: "Ansible test {{ resource_prefix }}" ingress: [] egress: - - [100, 'all', 'allow', '0.0.0.0/0', null, null, null, null] - - [105, 'all', 'allow', '::/0', null, null, null, null] - state: 'present' + - [100, "all", "allow", "0.0.0.0/0", !!null "", !!null "", !!null "", !!null ""] + - [105, "all", "allow", "::/0", !!null "", !!null "", !!null "", !!null ""] + state: "present" register: nacl - name: Assert that module reported change while the Network ACL remained unchanged ansible.builtin.assert: - that: - - nacl.changed - - nacl.nacl_id == nacl_id + that: + - nacl.changed + - nacl.nacl_id == nacl_id - name: Purge egress entries amazon.aws.ec2_vpc_nacl: @@ -99,7 +99,7 @@ Created_by: "Ansible test {{ resource_prefix }}" ingress: [] egress: [] - state: 'present' + state: "present" register: nacl - name: Assert that module reported change @@ -121,7 +121,6 @@ - nacl_facts.nacls[0].egress | length == 0 always: - - name: Remove network ACL amazon.aws.ec2_vpc_nacl: vpc_id: "{{ vpc_ipv6_id }}" diff --git a/tests/integration/targets/ec2_vpc_nacl/tasks/main.yml b/tests/integration/targets/ec2_vpc_nacl/tasks/main.yml index 0225056152b..0c159ddcde9 100644 --- a/tests/integration/targets/ec2_vpc_nacl/tasks/main.yml +++ b/tests/integration/targets/ec2_vpc_nacl/tasks/main.yml @@ -7,7 +7,6 @@ region: "{{ aws_region }}" block: - # ============================================================ - name: Test without any parameters @@ -26,19 +25,19 @@ register: nacl_facts - name: Assert we don't error - assert: + ansible.builtin.assert: that: - nacl_facts is succeeded - name: Get network ACL info with invalid ID amazon.aws.ec2_vpc_nacl_info: nacl_ids: - - 'acl-000000000000' + - "acl-000000000000" register: nacl_facts ignore_errors: true - name: Assert message mentions missing ACLs - assert: + ansible.builtin.assert: that: - nacl_facts is failed - '"does not exist" in nacl_facts.msg' @@ -55,8 +54,8 @@ - name: Pick AZs ansible.builtin.set_fact: - az_one: '{{ az_info.availability_zones[0].zone_name }}' - az_two: '{{ az_info.availability_zones[1].zone_name }}' + az_one: "{{ az_info.availability_zones[0].zone_name }}" + az_two: "{{ az_info.availability_zones[1].zone_name }}" # ============================================================ @@ -137,7 +136,6 @@ # ============================================================ always: - - name: Remove network ACL amazon.aws.ec2_vpc_nacl: vpc_id: "{{ vpc_id }}" @@ -168,7 +166,7 @@ ignore_errors: true register: removed_vpc with_items: - - '{{ vpc_id }}' - - '{{ vpc_ipv6_id }}' + - "{{ vpc_id }}" + - "{{ vpc_ipv6_id }}" # ============================================================ diff --git a/tests/integration/targets/ec2_vpc_nacl/tasks/subnet_ids.yml b/tests/integration/targets/ec2_vpc_nacl/tasks/subnet_ids.yml index 5aaed181bef..ba8b8015e44 100644 --- a/tests/integration/targets/ec2_vpc_nacl/tasks/subnet_ids.yml +++ b/tests/integration/targets/ec2_vpc_nacl/tasks/subnet_ids.yml @@ -1,3 +1,4 @@ +--- # ============================================================ - name: Create ingress and egress rules using subnet IDs @@ -8,12 +9,12 @@ tags: Created_by: "Ansible test {{ resource_prefix }}" ingress: - - [100, 'tcp', 'allow', '0.0.0.0/0', null, null, 22, 22] - - [200, 'tcp', 'allow', '0.0.0.0/0', null, null, 80, 80] - - [300, 'icmp', 'allow', '0.0.0.0/0', 0, 8] + - [100, "tcp", "allow", "0.0.0.0/0", !!null "", !!null "", 22, 22] + - [200, "tcp", "allow", "0.0.0.0/0", !!null "", !!null "", 80, 80] + - [300, "icmp", "allow", "0.0.0.0/0", 0, 8] egress: - - [100, 'all', 'allow', '0.0.0.0/0', null, null, null, null] - state: 'present' + - [100, "all", "allow", "0.0.0.0/0", !!null "", !!null "", !!null "", !!null ""] + state: "present" register: nacl - name: Set helpful fact for Network ACL ID @@ -53,12 +54,12 @@ tags: Created_by: "Ansible test {{ resource_prefix }}" ingress: - - [100, 'tcp', 'allow', '0.0.0.0/0', null, null, 22, 22] - - [200, 'tcp', 'allow', '0.0.0.0/0', null, null, 80, 80] - - [300, 'icmp', 'allow', '0.0.0.0/0', 0, 8] + - [100, "tcp", "allow", "0.0.0.0/0", !!null "", !!null "", 22, 22] + - [200, "tcp", "allow", "0.0.0.0/0", !!null "", !!null "", 80, 80] + - [300, "icmp", "allow", "0.0.0.0/0", 0, 8] egress: - - [100, 'all', 'allow', '0.0.0.0/0', null, null, null, null] - state: 'present' + - [100, "all", "allow", "0.0.0.0/0", !!null "", !!null "", !!null "", !!null ""] + state: "present" register: nacl - name: Assert the network acl already existed @@ -92,12 +93,12 @@ tags: Created_by: "Ansible test {{ resource_prefix }}" ingress: - - [100, 'tcp', 'allow', '0.0.0.0/0', null, null, 22, 22] - - [200, 'tcp', 'allow', '0.0.0.0/0', null, null, 80, 80] - - [300, 'icmp', 'allow', '0.0.0.0/0', 0, 8] + - [100, "tcp", "allow", "0.0.0.0/0", !!null "", !!null "", 22, 22] + - [200, "tcp", "allow", "0.0.0.0/0", !!null "", !!null "", 80, 80] + - [300, "icmp", "allow", "0.0.0.0/0", 0, 8] egress: - - [100, 'all', 'allow', '0.0.0.0/0', null, null, null, null] - state: 'present' + - [100, "all", "allow", "0.0.0.0/0", !!null "", !!null "", !!null "", !!null ""] + state: "present" register: nacl - name: Assert the network ACL changed diff --git a/tests/integration/targets/ec2_vpc_nacl/tasks/subnet_names.yml b/tests/integration/targets/ec2_vpc_nacl/tasks/subnet_names.yml index 78831afface..93d5ad7a956 100644 --- a/tests/integration/targets/ec2_vpc_nacl/tasks/subnet_names.yml +++ b/tests/integration/targets/ec2_vpc_nacl/tasks/subnet_names.yml @@ -1,3 +1,4 @@ +--- # ============================================================ - name: Create ingress and egress rules using subnet names @@ -8,12 +9,12 @@ tags: Created_by: "Ansible test {{ resource_prefix }}" ingress: - - [100, 'tcp', 'allow', '0.0.0.0/0', null, null, 22, 22] - - [200, 'tcp', 'allow', '0.0.0.0/0', null, null, 80, 80] - - [300, 'icmp', 'allow', '0.0.0.0/0', 0, 8] + - [100, "tcp", "allow", "0.0.0.0/0", !!null "", !!null "", 22, 22] + - [200, "tcp", "allow", "0.0.0.0/0", !!null "", !!null "", 80, 80] + - [300, "icmp", "allow", "0.0.0.0/0", 0, 8] egress: - - [100, 'all', 'allow', '0.0.0.0/0', null, null, null, null] - state: 'present' + - [100, "all", "allow", "0.0.0.0/0", !!null "", !!null "", !!null "", !!null ""] + state: "present" register: nacl - name: Set helpful fact for Network ACL ID @@ -52,12 +53,12 @@ tags: Created_by: "Ansible test {{ resource_prefix }}" ingress: - - [100, 'tcp', 'allow', '0.0.0.0/0', null, null, 22, 22] - - [200, 'tcp', 'allow', '0.0.0.0/0', null, null, 80, 80] - - [300, 'icmp', 'allow', '0.0.0.0/0', 0, 8] + - [100, "tcp", "allow", "0.0.0.0/0", !!null "", !!null "", 22, 22] + - [200, "tcp", "allow", "0.0.0.0/0", !!null "", !!null "", 80, 80] + - [300, "icmp", "allow", "0.0.0.0/0", 0, 8] egress: - - [100, 'all', 'allow', '0.0.0.0/0', null, null, null, null] - state: 'present' + - [100, "all", "allow", "0.0.0.0/0", !!null "", !!null "", !!null "", !!null ""] + state: "present" register: nacl - name: Assert the network acl already existed @@ -91,12 +92,12 @@ tags: Created_by: "Ansible test {{ resource_prefix }}" ingress: - - [100, 'tcp', 'allow', '0.0.0.0/0', null, null, 22, 22] - - [200, 'tcp', 'allow', '0.0.0.0/0', null, null, 80, 80] - - [300, 'icmp', 'allow', '0.0.0.0/0', 0, 8] + - [100, "tcp", "allow", "0.0.0.0/0", !!null "", !!null "", 22, 22] + - [200, "tcp", "allow", "0.0.0.0/0", !!null "", !!null "", 80, 80] + - [300, "icmp", "allow", "0.0.0.0/0", 0, 8] egress: - - [100, 'all', 'allow', '0.0.0.0/0', null, null, null, null] - state: 'present' + - [100, "all", "allow", "0.0.0.0/0", !!null "", !!null "", !!null "", !!null ""] + state: "present" register: nacl - name: Assert the network ACL changed diff --git a/tests/integration/targets/ec2_vpc_nacl/tasks/tags.yml b/tests/integration/targets/ec2_vpc_nacl/tasks/tags.yml index 556ab45494a..22e62138de6 100644 --- a/tests/integration/targets/ec2_vpc_nacl/tasks/tags.yml +++ b/tests/integration/targets/ec2_vpc_nacl/tasks/tags.yml @@ -1,455 +1,455 @@ +--- - name: Run test from tags.yml vars: first_tags: - 'Key with Spaces': Value with spaces + "Key with Spaces": Value with spaces CamelCaseKey: CamelCaseValue pascalCaseKey: pascalCaseValue snake_case_key: snake_case_value second_tags: - 'New Key with Spaces': Value with spaces + "New Key with Spaces": Value with spaces NewCamelCaseKey: CamelCaseValue newPascalCaseKey: pascalCaseValue new_snake_case_key: snake_case_value third_tags: - 'Key with Spaces': Value with spaces + "Key with Spaces": Value with spaces CamelCaseKey: CamelCaseValue pascalCaseKey: pascalCaseValue snake_case_key: snake_case_value - 'New Key with Spaces': Updated Value with spaces + "New Key with Spaces": Updated Value with spaces final_tags: - 'Key with Spaces': Value with spaces + "Key with Spaces": Value with spaces CamelCaseKey: CamelCaseValue pascalCaseKey: pascalCaseValue snake_case_key: snake_case_value - 'New Key with Spaces': Updated Value with spaces + "New Key with Spaces": Updated Value with spaces NewCamelCaseKey: CamelCaseValue newPascalCaseKey: pascalCaseValue new_snake_case_key: snake_case_value name_tags: - Name: '{{ nacl_name }}' + Name: "{{ nacl_name }}" block: - # ============================================================ - - name: Create a network ACL using subnet IDs - amazon.aws.ec2_vpc_nacl: - vpc_id: "{{ vpc_id }}" - name: "{{ nacl_name }}" - subnets: "{{ subnet_ids }}" - state: 'present' - register: nacl - - - name: Assert the network acl was created - ansible.builtin.assert: - that: - - nacl.changed - - nacl.nacl_id.startswith('acl-') - - - name: Store NACL ID - ansible.builtin.set_fact: - nacl_id: '{{ nacl.nacl_id }}' - - - name: Get network ACL facts - amazon.aws.ec2_vpc_nacl_info: - nacl_ids: - - "{{ nacl_id }}" - register: nacl_info - - - name: Assert the nacl has the correct attributes - ansible.builtin.assert: - that: - - nacl_info.nacls[0].nacl_id == nacl_id - - nacl_info.nacls[0].tags == name_tags + - name: Create a network ACL using subnet IDs + amazon.aws.ec2_vpc_nacl: + vpc_id: "{{ vpc_id }}" + name: "{{ nacl_name }}" + subnets: "{{ subnet_ids }}" + state: "present" + register: nacl + + - name: Assert the network acl was created + ansible.builtin.assert: + that: + - nacl.changed + - nacl.nacl_id.startswith('acl-') + + - name: Store NACL ID + ansible.builtin.set_fact: + nacl_id: "{{ nacl.nacl_id }}" + + - name: Get network ACL facts + amazon.aws.ec2_vpc_nacl_info: + nacl_ids: + - "{{ nacl_id }}" + register: nacl_info + + - name: Assert the nacl has the correct attributes + ansible.builtin.assert: + that: + - nacl_info.nacls[0].nacl_id == nacl_id + - nacl_info.nacls[0].tags == name_tags # ============================================================ - - name: Add tags (check mode) - amazon.aws.ec2_vpc_nacl: - vpc_id: "{{ vpc_id }}" - name: "{{ nacl_name }}" - subnets: "{{ subnet_ids }}" - tags: "{{ first_tags }}" - state: 'present' - register: nacl - check_mode: True - - - name: Assert would change - ansible.builtin.assert: - that: - - nacl is changed - - nacl.nacl_id == nacl_id - - - name: Add tags - amazon.aws.ec2_vpc_nacl: - vpc_id: "{{ vpc_id }}" - name: "{{ nacl_name }}" - subnets: "{{ subnet_ids }}" - tags: "{{ first_tags }}" - state: 'present' - register: nacl - - - name: Get network ACL facts - amazon.aws.ec2_vpc_nacl_info: - nacl_ids: - - "{{ nacl.nacl_id }}" - register: nacl_info - - - name: Verify the tags were added - ansible.builtin.assert: - that: - - nacl is changed - - nacl.nacl_id == nacl_id - - nacl_info.nacls[0].nacl_id == nacl_id - - nacl_info.nacls[0].tags == ( first_tags | combine(name_tags) ) - - - name: Add tags - IDEMPOTENCY (check mode) - amazon.aws.ec2_vpc_nacl: - vpc_id: "{{ vpc_id }}" - name: "{{ nacl_name }}" - subnets: "{{ subnet_ids }}" - tags: "{{ first_tags }}" - state: 'present' - register: nacl - check_mode: True - - - name: Assert would not change - ansible.builtin.assert: - that: - - nacl is not changed - - nacl.nacl_id == nacl_id - - - name: Add tags - IDEMPOTENCY - amazon.aws.ec2_vpc_nacl: - vpc_id: "{{ vpc_id }}" - name: "{{ nacl_name }}" - subnets: "{{ subnet_ids }}" - tags: "{{ first_tags }}" - state: 'present' - register: nacl - - - name: Get network ACL facts - amazon.aws.ec2_vpc_nacl_info: - nacl_ids: - - "{{ nacl.nacl_id }}" - register: nacl_info - - - name: Verify no change - ansible.builtin.assert: - that: - - nacl is not changed - - nacl.nacl_id == nacl_id - - nacl_info.nacls[0].nacl_id == nacl_id - - nacl_info.nacls[0].tags == ( first_tags | combine(name_tags) ) + - name: Add tags (check mode) + amazon.aws.ec2_vpc_nacl: + vpc_id: "{{ vpc_id }}" + name: "{{ nacl_name }}" + subnets: "{{ subnet_ids }}" + tags: "{{ first_tags }}" + state: "present" + register: nacl + check_mode: true + + - name: Assert would change + ansible.builtin.assert: + that: + - nacl is changed + - nacl.nacl_id == nacl_id + + - name: Add tags + amazon.aws.ec2_vpc_nacl: + vpc_id: "{{ vpc_id }}" + name: "{{ nacl_name }}" + subnets: "{{ subnet_ids }}" + tags: "{{ first_tags }}" + state: "present" + register: nacl + + - name: Get network ACL facts + amazon.aws.ec2_vpc_nacl_info: + nacl_ids: + - "{{ nacl.nacl_id }}" + register: nacl_info + + - name: Verify the tags were added + ansible.builtin.assert: + that: + - nacl is changed + - nacl.nacl_id == nacl_id + - nacl_info.nacls[0].nacl_id == nacl_id + - nacl_info.nacls[0].tags == ( first_tags | combine(name_tags) ) + + - name: Add tags - IDEMPOTENCY (check mode) + amazon.aws.ec2_vpc_nacl: + vpc_id: "{{ vpc_id }}" + name: "{{ nacl_name }}" + subnets: "{{ subnet_ids }}" + tags: "{{ first_tags }}" + state: "present" + register: nacl + check_mode: true + + - name: Assert would not change + ansible.builtin.assert: + that: + - nacl is not changed + - nacl.nacl_id == nacl_id + + - name: Add tags - IDEMPOTENCY + amazon.aws.ec2_vpc_nacl: + vpc_id: "{{ vpc_id }}" + name: "{{ nacl_name }}" + subnets: "{{ subnet_ids }}" + tags: "{{ first_tags }}" + state: "present" + register: nacl + + - name: Get network ACL facts + amazon.aws.ec2_vpc_nacl_info: + nacl_ids: + - "{{ nacl.nacl_id }}" + register: nacl_info + + - name: Verify no change + ansible.builtin.assert: + that: + - nacl is not changed + - nacl.nacl_id == nacl_id + - nacl_info.nacls[0].nacl_id == nacl_id + - nacl_info.nacls[0].tags == ( first_tags | combine(name_tags) ) # ============================================================ - - name: Get network ACL facts by filter - amazon.aws.ec2_vpc_nacl_info: - filters: - "tag:Name": "{{ nacl_name }}" - register: nacl_info + - name: Get network ACL facts by filter + amazon.aws.ec2_vpc_nacl_info: + filters: + "tag:Name": "{{ nacl_name }}" + register: nacl_info - - name: Assert the facts are the same as before - ansible.builtin.assert: - that: - - nacl_info.nacls | length == 1 - - nacl.nacl_id == nacl_id - - nacl_info.nacls[0].nacl_id == nacl_id + - name: Assert the facts are the same as before + ansible.builtin.assert: + that: + - nacl_info.nacls | length == 1 + - nacl.nacl_id == nacl_id + - nacl_info.nacls[0].nacl_id == nacl_id # ============================================================ - - name: Modify tags with purge (check mode) - amazon.aws.ec2_vpc_nacl: - vpc_id: "{{ vpc_id }}" - name: "{{ nacl_name }}" - subnets: "{{ subnet_ids }}" - tags: "{{ second_tags }}" - state: 'present' - register: nacl - check_mode: True - - - name: Assert would change - ansible.builtin.assert: - that: - - nacl is changed - - nacl.nacl_id == nacl_id - - - name: Modify tags with purge - amazon.aws.ec2_vpc_nacl: - vpc_id: "{{ vpc_id }}" - name: "{{ nacl_name }}" - subnets: "{{ subnet_ids }}" - tags: "{{ second_tags }}" - state: 'present' - register: nacl - - - name: Get network ACL facts - amazon.aws.ec2_vpc_nacl_info: - nacl_ids: - - "{{ nacl.nacl_id }}" - register: nacl_info - - - name: Verify the tags were added - ansible.builtin.assert: - that: - - nacl is changed - - nacl.nacl_id == nacl_id - - nacl_info.nacls[0].nacl_id == nacl_id - - nacl_info.nacls[0].tags == ( second_tags | combine(name_tags) ) - - - name: Modify tags with purge - IDEMPOTENCY (check mode) - amazon.aws.ec2_vpc_nacl: - vpc_id: "{{ vpc_id }}" - name: "{{ nacl_name }}" - subnets: "{{ subnet_ids }}" - tags: "{{ second_tags }}" - state: 'present' - register: nacl - check_mode: True - - - name: Assert would not change - ansible.builtin.assert: - that: - - nacl is not changed - - nacl.nacl_id == nacl_id - - - name: Modify tags with purge - IDEMPOTENCY - amazon.aws.ec2_vpc_nacl: - vpc_id: "{{ vpc_id }}" - name: "{{ nacl_name }}" - subnets: "{{ subnet_ids }}" - tags: "{{ second_tags }}" - state: 'present' - register: nacl - - - name: Get network ACL facts - amazon.aws.ec2_vpc_nacl_info: - nacl_ids: - - "{{ nacl.nacl_id }}" - register: nacl_info - - - name: Verify no change - ansible.builtin.assert: - that: - - nacl is not changed - - nacl.nacl_id == nacl_id - - nacl_info.nacls[0].nacl_id == nacl_id - - nacl_info.nacls[0].tags == ( second_tags | combine(name_tags) ) + - name: Modify tags with purge (check mode) + amazon.aws.ec2_vpc_nacl: + vpc_id: "{{ vpc_id }}" + name: "{{ nacl_name }}" + subnets: "{{ subnet_ids }}" + tags: "{{ second_tags }}" + state: "present" + register: nacl + check_mode: true + + - name: Assert would change + ansible.builtin.assert: + that: + - nacl is changed + - nacl.nacl_id == nacl_id + + - name: Modify tags with purge + amazon.aws.ec2_vpc_nacl: + vpc_id: "{{ vpc_id }}" + name: "{{ nacl_name }}" + subnets: "{{ subnet_ids }}" + tags: "{{ second_tags }}" + state: "present" + register: nacl + + - name: Get network ACL facts + amazon.aws.ec2_vpc_nacl_info: + nacl_ids: + - "{{ nacl.nacl_id }}" + register: nacl_info + + - name: Verify the tags were added + ansible.builtin.assert: + that: + - nacl is changed + - nacl.nacl_id == nacl_id + - nacl_info.nacls[0].nacl_id == nacl_id + - nacl_info.nacls[0].tags == ( second_tags | combine(name_tags) ) + + - name: Modify tags with purge - IDEMPOTENCY (check mode) + amazon.aws.ec2_vpc_nacl: + vpc_id: "{{ vpc_id }}" + name: "{{ nacl_name }}" + subnets: "{{ subnet_ids }}" + tags: "{{ second_tags }}" + state: "present" + register: nacl + check_mode: true + + - name: Assert would not change + ansible.builtin.assert: + that: + - nacl is not changed + - nacl.nacl_id == nacl_id + + - name: Modify tags with purge - IDEMPOTENCY + amazon.aws.ec2_vpc_nacl: + vpc_id: "{{ vpc_id }}" + name: "{{ nacl_name }}" + subnets: "{{ subnet_ids }}" + tags: "{{ second_tags }}" + state: "present" + register: nacl + + - name: Get network ACL facts + amazon.aws.ec2_vpc_nacl_info: + nacl_ids: + - "{{ nacl.nacl_id }}" + register: nacl_info + + - name: Verify no change + ansible.builtin.assert: + that: + - nacl is not changed + - nacl.nacl_id == nacl_id + - nacl_info.nacls[0].nacl_id == nacl_id + - nacl_info.nacls[0].tags == ( second_tags | combine(name_tags) ) # ============================================================ - - name: Modify tags without purge (check mode) - amazon.aws.ec2_vpc_nacl: - vpc_id: "{{ vpc_id }}" - name: "{{ nacl_name }}" - subnets: "{{ subnet_ids }}" - tags: "{{ third_tags }}" - state: 'present' - purge_tags: False - register: nacl - check_mode: True - - - name: Assert would change - ansible.builtin.assert: - that: - - nacl is changed - - nacl.nacl_id == nacl_id - - - name: Modify tags without purge - amazon.aws.ec2_vpc_nacl: - vpc_id: "{{ vpc_id }}" - name: "{{ nacl_name }}" - subnets: "{{ subnet_ids }}" - tags: "{{ third_tags }}" - state: 'present' - purge_tags: False - register: nacl - - - name: Get network ACL facts - amazon.aws.ec2_vpc_nacl_info: - nacl_ids: - - "{{ nacl.nacl_id }}" - register: nacl_info - - - name: Verify the tags were added - ansible.builtin.assert: - that: - - nacl is changed - - nacl.nacl_id == nacl_id - - nacl_info.nacls[0].nacl_id == nacl_id - - nacl_info.nacls[0].tags == ( final_tags | combine(name_tags) ) - - - name: Modify tags without purge - IDEMPOTENCY (check mode) - amazon.aws.ec2_vpc_nacl: - vpc_id: "{{ vpc_id }}" - name: "{{ nacl_name }}" - subnets: "{{ subnet_ids }}" - tags: "{{ third_tags }}" - state: 'present' - purge_tags: False - register: nacl - check_mode: True - - - name: Assert would not change - ansible.builtin.assert: - that: - - nacl is not changed - - nacl.nacl_id == nacl_id - - - name: Modify tags without purge - IDEMPOTENCY - amazon.aws.ec2_vpc_nacl: - vpc_id: "{{ vpc_id }}" - name: "{{ nacl_name }}" - subnets: "{{ subnet_ids }}" - tags: "{{ third_tags }}" - state: 'present' - purge_tags: False - register: nacl - - - name: Get network ACL facts - amazon.aws.ec2_vpc_nacl_info: - nacl_ids: - - "{{ nacl.nacl_id }}" - register: nacl_info - - - name: Verify no change - ansible.builtin.assert: - that: - - nacl is not changed - - nacl.nacl_id == nacl_id - - nacl_info.nacls[0].nacl_id == nacl_id - - nacl_info.nacls[0].tags == ( final_tags | combine(name_tags) ) + - name: Modify tags without purge (check mode) + amazon.aws.ec2_vpc_nacl: + vpc_id: "{{ vpc_id }}" + name: "{{ nacl_name }}" + subnets: "{{ subnet_ids }}" + tags: "{{ third_tags }}" + state: "present" + purge_tags: false + register: nacl + check_mode: true + + - name: Assert would change + ansible.builtin.assert: + that: + - nacl is changed + - nacl.nacl_id == nacl_id + + - name: Modify tags without purge + amazon.aws.ec2_vpc_nacl: + vpc_id: "{{ vpc_id }}" + name: "{{ nacl_name }}" + subnets: "{{ subnet_ids }}" + tags: "{{ third_tags }}" + state: "present" + purge_tags: false + register: nacl + + - name: Get network ACL facts + amazon.aws.ec2_vpc_nacl_info: + nacl_ids: + - "{{ nacl.nacl_id }}" + register: nacl_info + + - name: Verify the tags were added + ansible.builtin.assert: + that: + - nacl is changed + - nacl.nacl_id == nacl_id + - nacl_info.nacls[0].nacl_id == nacl_id + - nacl_info.nacls[0].tags == ( final_tags | combine(name_tags) ) + + - name: Modify tags without purge - IDEMPOTENCY (check mode) + amazon.aws.ec2_vpc_nacl: + vpc_id: "{{ vpc_id }}" + name: "{{ nacl_name }}" + subnets: "{{ subnet_ids }}" + tags: "{{ third_tags }}" + state: "present" + purge_tags: false + register: nacl + check_mode: true + + - name: Assert would not change + ansible.builtin.assert: + that: + - nacl is not changed + - nacl.nacl_id == nacl_id + + - name: Modify tags without purge - IDEMPOTENCY + amazon.aws.ec2_vpc_nacl: + vpc_id: "{{ vpc_id }}" + name: "{{ nacl_name }}" + subnets: "{{ subnet_ids }}" + tags: "{{ third_tags }}" + state: "present" + purge_tags: false + register: nacl + + - name: Get network ACL facts + amazon.aws.ec2_vpc_nacl_info: + nacl_ids: + - "{{ nacl.nacl_id }}" + register: nacl_info + + - name: Verify no change + ansible.builtin.assert: + that: + - nacl is not changed + - nacl.nacl_id == nacl_id + - nacl_info.nacls[0].nacl_id == nacl_id + - nacl_info.nacls[0].tags == ( final_tags | combine(name_tags) ) # ============================================================ - - name: No change to tags without setting tags (check mode) - amazon.aws.ec2_vpc_nacl: - vpc_id: "{{ vpc_id }}" - name: "{{ nacl_name }}" - subnets: "{{ subnet_ids }}" - state: 'present' - register: nacl - check_mode: True - - - name: Assert would change - ansible.builtin.assert: - that: - - nacl is not changed - - nacl.nacl_id == nacl_id - - - name: No change to tags without setting tags - amazon.aws.ec2_vpc_nacl: - vpc_id: "{{ vpc_id }}" - name: "{{ nacl_name }}" - subnets: "{{ subnet_ids }}" - state: 'present' - register: nacl - - - name: Get network ACL facts - amazon.aws.ec2_vpc_nacl_info: - nacl_ids: - - "{{ nacl.nacl_id }}" - register: nacl_info - - - name: Verify the tags were added - ansible.builtin.assert: - that: - - nacl is not changed - - nacl.nacl_id == nacl_id - - nacl_info.nacls[0].nacl_id == nacl_id - - nacl_info.nacls[0].tags == ( final_tags | combine(name_tags) ) + - name: No change to tags without setting tags (check mode) + amazon.aws.ec2_vpc_nacl: + vpc_id: "{{ vpc_id }}" + name: "{{ nacl_name }}" + subnets: "{{ subnet_ids }}" + state: "present" + register: nacl + check_mode: true + + - name: Assert would change + ansible.builtin.assert: + that: + - nacl is not changed + - nacl.nacl_id == nacl_id + + - name: No change to tags without setting tags + amazon.aws.ec2_vpc_nacl: + vpc_id: "{{ vpc_id }}" + name: "{{ nacl_name }}" + subnets: "{{ subnet_ids }}" + state: "present" + register: nacl + + - name: Get network ACL facts + amazon.aws.ec2_vpc_nacl_info: + nacl_ids: + - "{{ nacl.nacl_id }}" + register: nacl_info + + - name: Verify the tags were added + ansible.builtin.assert: + that: + - nacl is not changed + - nacl.nacl_id == nacl_id + - nacl_info.nacls[0].nacl_id == nacl_id + - nacl_info.nacls[0].tags == ( final_tags | combine(name_tags) ) # ============================================================ - - name: Remove non name tags (check mode) - amazon.aws.ec2_vpc_nacl: - vpc_id: "{{ vpc_id }}" - name: "{{ nacl_name }}" - subnets: "{{ subnet_ids }}" - tags: {} - state: 'present' - register: nacl - check_mode: True - - - name: Assert would change - ansible.builtin.assert: - that: - - nacl is changed - - nacl.nacl_id == nacl_id - - - name: Remove non name tags - amazon.aws.ec2_vpc_nacl: - vpc_id: "{{ vpc_id }}" - name: "{{ nacl_name }}" - subnets: "{{ subnet_ids }}" - tags: {} - state: 'present' - register: nacl - - - name: Get network ACL facts - amazon.aws.ec2_vpc_nacl_info: - nacl_ids: - - "{{ nacl.nacl_id }}" - register: nacl_info - - - name: Verify the tags were added - ansible.builtin.assert: - that: - - nacl is changed - - nacl.nacl_id == nacl_id - - nacl_info.nacls[0].nacl_id == nacl_id - - nacl_info.nacls[0].tags == name_tags - - - name: Remove non name tags - IDEMPOTENCY (check mode) - amazon.aws.ec2_vpc_nacl: - vpc_id: "{{ vpc_id }}" - name: "{{ nacl_name }}" - subnets: "{{ subnet_ids }}" - tags: {} - state: 'present' - register: nacl - check_mode: True - - - name: Assert would not change - ansible.builtin.assert: - that: - - nacl is not changed - - nacl.nacl_id == nacl_id - - - name: Remove non name tags - IDEMPOTENCY - amazon.aws.ec2_vpc_nacl: - vpc_id: "{{ vpc_id }}" - name: "{{ nacl_name }}" - subnets: "{{ subnet_ids }}" - tags: {} - state: 'present' - register: nacl - - - name: Get network ACL facts - amazon.aws.ec2_vpc_nacl_info: - nacl_ids: - - "{{ nacl.nacl_id }}" - register: nacl_info - - - name: Verify no change - ansible.builtin.assert: - that: - - nacl is not changed - - nacl.nacl_id == nacl_id - - nacl_info.nacls[0].nacl_id == nacl_id - - nacl_info.nacls[0].tags == name_tags + - name: Remove non name tags (check mode) + amazon.aws.ec2_vpc_nacl: + vpc_id: "{{ vpc_id }}" + name: "{{ nacl_name }}" + subnets: "{{ subnet_ids }}" + tags: {} + state: "present" + register: nacl + check_mode: true + + - name: Assert would change + ansible.builtin.assert: + that: + - nacl is changed + - nacl.nacl_id == nacl_id + + - name: Remove non name tags + amazon.aws.ec2_vpc_nacl: + vpc_id: "{{ vpc_id }}" + name: "{{ nacl_name }}" + subnets: "{{ subnet_ids }}" + tags: {} + state: "present" + register: nacl + + - name: Get network ACL facts + amazon.aws.ec2_vpc_nacl_info: + nacl_ids: + - "{{ nacl.nacl_id }}" + register: nacl_info + + - name: Verify the tags were added + ansible.builtin.assert: + that: + - nacl is changed + - nacl.nacl_id == nacl_id + - nacl_info.nacls[0].nacl_id == nacl_id + - nacl_info.nacls[0].tags == name_tags + + - name: Remove non name tags - IDEMPOTENCY (check mode) + amazon.aws.ec2_vpc_nacl: + vpc_id: "{{ vpc_id }}" + name: "{{ nacl_name }}" + subnets: "{{ subnet_ids }}" + tags: {} + state: "present" + register: nacl + check_mode: true + + - name: Assert would not change + ansible.builtin.assert: + that: + - nacl is not changed + - nacl.nacl_id == nacl_id + + - name: Remove non name tags - IDEMPOTENCY + amazon.aws.ec2_vpc_nacl: + vpc_id: "{{ vpc_id }}" + name: "{{ nacl_name }}" + subnets: "{{ subnet_ids }}" + tags: {} + state: "present" + register: nacl + + - name: Get network ACL facts + amazon.aws.ec2_vpc_nacl_info: + nacl_ids: + - "{{ nacl.nacl_id }}" + register: nacl_info + + - name: Verify no change + ansible.builtin.assert: + that: + - nacl is not changed + - nacl.nacl_id == nacl_id + - nacl_info.nacls[0].nacl_id == nacl_id + - nacl_info.nacls[0].tags == name_tags # ============================================================ always: - - name: Remove the network ACL - amazon.aws.ec2_vpc_nacl: - vpc_id: "{{ vpc_id }}" - name: "{{ nacl_name }}" - state: absent - register: nacl - - - name: Assert nacl was removed - ansible.builtin.assert: - that: - - nacl.changed + - name: Remove the network ACL + amazon.aws.ec2_vpc_nacl: + vpc_id: "{{ vpc_id }}" + name: "{{ nacl_name }}" + state: absent + register: nacl + + - name: Assert nacl was removed + ansible.builtin.assert: + that: + - nacl.changed diff --git a/tests/integration/targets/ec2_vpc_nat_gateway/tasks/main.yml b/tests/integration/targets/ec2_vpc_nat_gateway/tasks/main.yml index 7cc3ea1b880..3c96f3fb2e2 100644 --- a/tests/integration/targets/ec2_vpc_nat_gateway/tasks/main.yml +++ b/tests/integration/targets/ec2_vpc_nat_gateway/tasks/main.yml @@ -1,5 +1,5 @@ --- -- name: ec2_vpc_nat_gateway tests +- name: Run ec2_vpc_nat_gateway tests module_defaults: group/aws: access_key: "{{ aws_access_key }}" @@ -7,7 +7,7 @@ session_token: "{{ security_token | default(omit) }}" region: "{{ aws_region }}" block: - # ============================================================ + # ============================================================ - name: Create a VPC amazon.aws.ec2_vpc_net: name: "{{ vpc_name }}" @@ -48,7 +48,7 @@ - eip_result.allocation_id.startswith("eipalloc-") - '"public_ip" in eip_result' - - name: "set fact: EIP allocation ID and EIP public IP" + - name: "Set fact: EIP allocation ID and EIP public IP" ansible.builtin.set_fact: eip_address: "{{ eip_result.public_ip }}" allocation_id: "{{ eip_result.allocation_id }}" @@ -75,7 +75,7 @@ - '"tags" in subnet_result.subnet' - subnet_result.subnet.vpc_id == vpc_id - - name: "set fact: VPC subnet ID" + - name: "Set fact: VPC subnet ID" ansible.builtin.set_fact: subnet_id: "{{ subnet_result.subnet.id }}" @@ -159,7 +159,7 @@ - '"vpc_id" in create_ngw' - create_ngw.vpc_id == vpc_id - - name: "set facts: NAT gateway ID" + - name: "Set facts: NAT gateway ID" ansible.builtin.set_fact: nat_gateway_id: "{{ create_ngw.nat_gateway_id }}" network_interface_id: "{{ create_ngw.nat_gateway_addresses[0].network_interface_id }}" @@ -410,7 +410,7 @@ default_create: true register: _nat_gateway - - name: + - name: Assert changes ansible.builtin.assert: that: - _nat_gateway.changed @@ -807,7 +807,7 @@ register: delete_tags_ngw check_mode: true - - name: assert tags would be removed - CHECK_MODE + - name: Assert tags would be removed - CHECK_MODE ansible.builtin.assert: that: - delete_tags_ngw.changed @@ -938,7 +938,7 @@ - '"create_time" in create_ngw' - '"allocation_id" not in create_ngw.nat_gateway_addresses[0]' - - name: "set facts: NAT gateway ID" + - name: "Set facts: NAT gateway ID" ansible.builtin.set_fact: nat_gateway_id: "{{ create_ngw.nat_gateway_id }}" network_interface_id: "{{ create_ngw.nat_gateway_addresses[0].network_interface_id }}" diff --git a/tests/integration/targets/ec2_vpc_net/tasks/main.yml b/tests/integration/targets/ec2_vpc_net/tasks/main.yml index c469f6c7ba1..89c4acc7844 100644 --- a/tests/integration/targets/ec2_vpc_net/tasks/main.yml +++ b/tests/integration/targets/ec2_vpc_net/tasks/main.yml @@ -50,7 +50,7 @@ ansible.builtin.assert: that: - result is failed - #- result.msg.startswith("missing required arguments") + # - result.msg.startswith("missing required arguments") - result.msg.startswith("one of") # ============================================================ @@ -181,10 +181,10 @@ state: present cidr_block: "{{ vpc_cidr }}" name: "{{ vpc_name }}" - # Intentionaly commenting out 'ipv6_cidr' - # When the 'ipv6_cidr' property is missing, the VPC should retain its configuration. - # That should not cause the module to set default value 'false' and disassociate the IPv6 block. - #ipv6_cidr: True + ## Intentionaly commenting out 'ipv6_cidr' + ## When the 'ipv6_cidr' property is missing, the VPC should retain its configuration. + ## That should not cause the module to set default value 'false' and disassociate the IPv6 block. + # ipv6_cidr: True register: result - name: Assert configuration did not change @@ -1582,7 +1582,6 @@ - result.vpc.ipv6_cidr_block_association_set[0].ipv6_cidr_block | ansible.utils.ipv6 - result.vpc.ipv6_cidr_block_association_set[0].ipv6_cidr_block_state.state in ["disassociated"] - - name: Retry to remove IPv6 CIDR association from VPC amazon.aws.ec2_vpc_net: state: present diff --git a/tests/integration/targets/ec2_vpc_peering/defaults/main.yml b/tests/integration/targets/ec2_vpc_peering/defaults/main.yml index 99698043b5e..7541c2971df 100644 --- a/tests/integration/targets/ec2_vpc_peering/defaults/main.yml +++ b/tests/integration/targets/ec2_vpc_peering/defaults/main.yml @@ -1,5 +1,6 @@ -vpc_seed: '{{ resource_prefix }}' -vpc_1_name: '{{ resource_prefix }}-vpc-1' +--- +vpc_seed: "{{ resource_prefix }}" +vpc_1_name: "{{ resource_prefix }}-vpc-1" vpc_1_cidr: 10.{{ 256 | random(seed=vpc_seed) }}.0.0/23 -vpc_2_name: '{{ resource_prefix }}-vpc-1' +vpc_2_name: "{{ resource_prefix }}-vpc-1" vpc_2_cidr: 10.{{ 256 | random(seed=vpc_seed) }}.2.0/23 diff --git a/tests/integration/targets/ec2_vpc_peering/meta/main.yml b/tests/integration/targets/ec2_vpc_peering/meta/main.yml index 32cf5dda7ed..23d65c7ef45 100644 --- a/tests/integration/targets/ec2_vpc_peering/meta/main.yml +++ b/tests/integration/targets/ec2_vpc_peering/meta/main.yml @@ -1 +1,2 @@ +--- dependencies: [] diff --git a/tests/integration/targets/ec2_vpc_peering/tasks/main.yml b/tests/integration/targets/ec2_vpc_peering/tasks/main.yml index 15cf6cb57bd..52cb1228a0c 100644 --- a/tests/integration/targets/ec2_vpc_peering/tasks/main.yml +++ b/tests/integration/targets/ec2_vpc_peering/tasks/main.yml @@ -1,657 +1,652 @@ +--- - name: EC2 VPC Peering Connection 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: Get ARN of calling user - amazon.aws.aws_caller_info: - register: aws_caller_info - - - name: Store Account ID for later use - ansible.builtin.set_fact: - account_id: '{{ aws_caller_info.account }}' - - # ============================================================ - - name: Fetch EC2 VPC Peering Connections in check_mode - amazon.aws.ec2_vpc_peering_info: - register: peers_info - check_mode: true - - - name: Assert success - ansible.builtin.assert: - that: - - peers_info is successful - - '"result" in peers_info' - - # ============================================================ - - name: Create VPC 1 - amazon.aws.ec2_vpc_net: - name: '{{ vpc_1_name }}' - state: present - cidr_block: '{{ vpc_1_cidr }}' - tags: - Name: '{{ vpc_1_name }}' - TestPrefex: '{{ resource_prefix }}' - register: vpc_1_result - - - name: Assert success - ansible.builtin.assert: - that: - - vpc_1_result is successful - - - name: Create VPC 2 - amazon.aws.ec2_vpc_net: - name: '{{ vpc_2_name }}' - state: present - cidr_block: '{{ vpc_2_cidr }}' - tags: - Name: '{{ vpc_2_name }}' - TestPrefex: '{{ resource_prefix }}' - register: vpc_2_result - - - name: Assert success - ansible.builtin.assert: - that: - - vpc_2_result is successful - - - name: Store VPC IDs - set_fact: - vpc_1: '{{ vpc_1_result.vpc.id }}' - vpc_2: '{{ vpc_2_result.vpc.id }}' - - - name: Set a name to use with the connections - ansible.builtin.set_fact: - connection_name: Peering connection for VPC {{ vpc_1 }} to VPC {{ vpc_2 }} - - - name: Create local account EC2 VPC Peering Connection request (check_mode) - amazon.aws.ec2_vpc_peering: - vpc_id: '{{ vpc_1 }}' - peer_vpc_id: '{{ vpc_2 }}' - state: present - tags: - Name: '{{ connection_name }}' - check_mode: true - register: vpc_peer - - - name: Assert success - ansible.builtin.assert: - that: - - vpc_peer is changed - - - name: Create local account EC2 VPC Peering Connection request - amazon.aws.ec2_vpc_peering: - vpc_id: '{{ vpc_1 }}' - peer_vpc_id: '{{ vpc_2 }}' - state: present - tags: - Name: '{{ connection_name }}' - register: vpc_peer - - - name: Assert success - ansible.builtin.assert: - that: - - vpc_peer is changed - - vpc_peer is successful - - "'peering_id' in vpc_peer" - - vpc_peer.vpc_peering_connection.requester_vpc_info.cidr_block == vpc_1_cidr - - vpc_peer.peering_id.startswith('pcx-') - - - name: Store Connection ID - ansible.builtin.set_fact: - peer_id_1: '{{ vpc_peer.peering_id }}' - - - name: Re-create local account EC2 VPC Peering Connection request (idempotency - check_mode) - amazon.aws.ec2_vpc_peering: - vpc_id: '{{ vpc_1 }}' - peer_vpc_id: '{{ vpc_2 }}' - state: present - tags: - Name: '{{ connection_name }}' - check_mode: true - register: vpc_peer - - - name: Assert success - ansible.builtin.assert: - that: - - vpc_peer is not changed - - - name: Re-create local account EC2 VPC Peering Connection request (idempotency) - amazon.aws.ec2_vpc_peering: - vpc_id: '{{ vpc_1 }}' - peer_vpc_id: '{{ vpc_2 }}' - state: present - tags: - Name: '{{ connection_name }}' - register: vpc_peer - - - name: Assert success - ansible.builtin.assert: - that: - - vpc_peer is not changed - - vpc_peer is successful - - vpc_peer.peering_id == peer_id_1 - - - name: Create local account EC2 VPC Peering Connection request with accepter/requester - reversed (idempotency check_mode) - amazon.aws.ec2_vpc_peering: - vpc_id: '{{ vpc_2 }}' - peer_vpc_id: '{{ vpc_1 }}' - state: present - tags: - Name: '{{ connection_name }}' - check_mode: true - register: vpc_peer - - - name: Assert success - ansible.builtin.assert: - that: - - vpc_peer is not changed - - - name: Create local account EC2 VPC Peering Connection request with accepter/requester - reversed (idempotency) - amazon.aws.ec2_vpc_peering: - vpc_id: '{{ vpc_2 }}' - peer_vpc_id: '{{ vpc_1 }}' - state: present - tags: - Name: '{{ connection_name }}' - register: vpc_peer - - - name: Assert success - ansible.builtin.assert: - that: - - vpc_peer is not changed - - vpc_peer is successful - - vpc_peer.peering_id == peer_id_1 - - - name: Get details on specific EC2 VPC Peering Connection - amazon.aws.ec2_vpc_peering_info: - peer_connection_ids: - - '{{ peer_id_1 }}' - register: peer_info - - - name: Assert expected values - ansible.builtin.assert: - that: - - peer_info is successful - - "'vpc_peering_connections' in peer_info" - - "'result' in peer_info" - - "'accepter_vpc_info' in peer_details" - - "'requester_vpc_info' in peer_details" - - "'status' in peer_details" - - "'code' in peer_details.status" - - peer_details.status.code == "pending-acceptance" - - "'message' in peer_details.status" - - "'tags' in peer_details" - - "'Name' in peer_details.tags" - - peer_details.tags.Name == connection_name - - "'vpc_peering_connection_id' in peer_details" - - peer_details.vpc_peering_connection_id == peer_id_1 - # Acceptor info isn't available until the connection has been accepted - - "'cidr_block' not in acceptor_details" - - "'cidr_block_set' not in acceptor_details" - - "'peering_options' not in acceptor_details" - - "'owner_id' in acceptor_details" - - acceptor_details.owner_id == account_id - - "'region' in acceptor_details" - - acceptor_details.region == aws_region - - "'vpc_id' in acceptor_details" - - acceptor_details.vpc_id == vpc_2 - # Information about the 'requesting' VPC - - "'cidr_block' in requester_details" - - requester_details.cidr_block == vpc_1_cidr - - "'cidr_block_set' in requester_details" - - requester_details.cidr_block_set | length == 1 - - "'cidr_block' in requester_details.cidr_block_set[0]" - - requester_details.cidr_block_set[0].cidr_block == vpc_1_cidr - - "'peering_options' in requester_details" - - "'owner_id' in requester_details" - - requester_details.owner_id == account_id - - "'region' in requester_details" - - requester_details.region == aws_region - - "'vpc_id' in requester_details" - - requester_details.vpc_id == vpc_1 - vars: - peer_details: '{{ peer_info.vpc_peering_connections[0] }}' - acceptor_details: '{{ peer_details["accepter_vpc_info"] }}' - requester_details: '{{ peer_details["requester_vpc_info"] }}' - - - name: Get all EC2 VPC Peering Connections with specific filters - amazon.aws.ec2_vpc_peering_info: - filters: - status-code: [pending-acceptance] - register: pending_vpc_peers - - - name: Assert expected values - ansible.builtin.assert: - that: + - name: Get ARN of calling user + amazon.aws.aws_caller_info: + register: aws_caller_info + + - name: Store Account ID for later use + ansible.builtin.set_fact: + account_id: "{{ aws_caller_info.account }}" + + # ============================================================ + - name: Fetch EC2 VPC Peering Connections in check_mode + amazon.aws.ec2_vpc_peering_info: + register: peers_info + check_mode: true + + - name: Assert success + ansible.builtin.assert: + that: + - peers_info is successful + - '"result" in peers_info' + + # ============================================================ + - name: Create VPC 1 + amazon.aws.ec2_vpc_net: + name: "{{ vpc_1_name }}" + state: present + cidr_block: "{{ vpc_1_cidr }}" + tags: + Name: "{{ vpc_1_name }}" + TestPrefex: "{{ resource_prefix }}" + register: vpc_1_result + + - name: Assert success + ansible.builtin.assert: + that: + - vpc_1_result is successful + + - name: Create VPC 2 + amazon.aws.ec2_vpc_net: + name: "{{ vpc_2_name }}" + state: present + cidr_block: "{{ vpc_2_cidr }}" + tags: + Name: "{{ vpc_2_name }}" + TestPrefex: "{{ resource_prefix }}" + register: vpc_2_result + + - name: Assert success + ansible.builtin.assert: + that: + - vpc_2_result is successful + + - name: Store VPC IDs + ansible.builtin.set_fact: + vpc_1: "{{ vpc_1_result.vpc.id }}" + vpc_2: "{{ vpc_2_result.vpc.id }}" + + - name: Set a name to use with the connections + ansible.builtin.set_fact: + connection_name: Peering connection for VPC {{ vpc_1 }} to VPC {{ vpc_2 }} + + - name: Create local account EC2 VPC Peering Connection request (check_mode) + amazon.aws.ec2_vpc_peering: + vpc_id: "{{ vpc_1 }}" + peer_vpc_id: "{{ vpc_2 }}" + state: present + tags: + Name: "{{ connection_name }}" + check_mode: true + register: vpc_peer + + - name: Assert success + ansible.builtin.assert: + that: + - vpc_peer is changed + + - name: Create local account EC2 VPC Peering Connection request + amazon.aws.ec2_vpc_peering: + vpc_id: "{{ vpc_1 }}" + peer_vpc_id: "{{ vpc_2 }}" + state: present + tags: + Name: "{{ connection_name }}" + register: vpc_peer + + - name: Assert success + ansible.builtin.assert: + that: + - vpc_peer is changed + - vpc_peer is successful + - "'peering_id' in vpc_peer" + - vpc_peer.vpc_peering_connection.requester_vpc_info.cidr_block == vpc_1_cidr + - vpc_peer.peering_id.startswith('pcx-') + + - name: Store Connection ID + ansible.builtin.set_fact: + peer_id_1: "{{ vpc_peer.peering_id }}" + + - name: Re-create local account EC2 VPC Peering Connection request (idempotency check_mode) + amazon.aws.ec2_vpc_peering: + vpc_id: "{{ vpc_1 }}" + peer_vpc_id: "{{ vpc_2 }}" + state: present + tags: + Name: "{{ connection_name }}" + check_mode: true + register: vpc_peer + + - name: Assert success + ansible.builtin.assert: + that: + - vpc_peer is not changed + + - name: Re-create local account EC2 VPC Peering Connection request (idempotency) + amazon.aws.ec2_vpc_peering: + vpc_id: "{{ vpc_1 }}" + peer_vpc_id: "{{ vpc_2 }}" + state: present + tags: + Name: "{{ connection_name }}" + register: vpc_peer + + - name: Assert success + ansible.builtin.assert: + that: + - vpc_peer is not changed + - vpc_peer is successful + - vpc_peer.peering_id == peer_id_1 + + - name: Create local account EC2 VPC Peering Connection request with accepter/requester reversed (idempotency check_mode) + amazon.aws.ec2_vpc_peering: + vpc_id: "{{ vpc_2 }}" + peer_vpc_id: "{{ vpc_1 }}" + state: present + tags: + Name: "{{ connection_name }}" + check_mode: true + register: vpc_peer + + - name: Assert success + ansible.builtin.assert: + that: + - vpc_peer is not changed + + - name: Create local account EC2 VPC Peering Connection request with accepter/requester reversed (idempotency) + amazon.aws.ec2_vpc_peering: + vpc_id: "{{ vpc_2 }}" + peer_vpc_id: "{{ vpc_1 }}" + state: present + tags: + Name: "{{ connection_name }}" + register: vpc_peer + + - name: Assert success + ansible.builtin.assert: + that: + - vpc_peer is not changed + - vpc_peer is successful + - vpc_peer.peering_id == peer_id_1 + + - name: Get details on specific EC2 VPC Peering Connection + amazon.aws.ec2_vpc_peering_info: + peer_connection_ids: + - "{{ peer_id_1 }}" + register: peer_info + + - name: Assert expected values + ansible.builtin.assert: + that: + - peer_info is successful + - "'vpc_peering_connections' in peer_info" + - "'result' in peer_info" + - "'accepter_vpc_info' in peer_details" + - "'requester_vpc_info' in peer_details" + - "'status' in peer_details" + - "'code' in peer_details.status" + - peer_details.status.code == "pending-acceptance" + - "'message' in peer_details.status" + - "'tags' in peer_details" + - "'Name' in peer_details.tags" + - peer_details.tags.Name == connection_name + - "'vpc_peering_connection_id' in peer_details" + - peer_details.vpc_peering_connection_id == peer_id_1 + # Acceptor info isn't available until the connection has been accepted + - "'cidr_block' not in acceptor_details" + - "'cidr_block_set' not in acceptor_details" + - "'peering_options' not in acceptor_details" + - "'owner_id' in acceptor_details" + - acceptor_details.owner_id == account_id + - "'region' in acceptor_details" + - acceptor_details.region == aws_region + - "'vpc_id' in acceptor_details" + - acceptor_details.vpc_id == vpc_2 + # Information about the 'requesting' VPC + - "'cidr_block' in requester_details" + - requester_details.cidr_block == vpc_1_cidr + - "'cidr_block_set' in requester_details" + - requester_details.cidr_block_set | length == 1 + - "'cidr_block' in requester_details.cidr_block_set[0]" + - requester_details.cidr_block_set[0].cidr_block == vpc_1_cidr + - "'peering_options' in requester_details" + - "'owner_id' in requester_details" + - requester_details.owner_id == account_id + - "'region' in requester_details" + - requester_details.region == aws_region + - "'vpc_id' in requester_details" + - requester_details.vpc_id == vpc_1 + vars: + peer_details: "{{ peer_info.vpc_peering_connections[0] }}" + acceptor_details: '{{ peer_details["accepter_vpc_info"] }}' + requester_details: '{{ peer_details["requester_vpc_info"] }}' + + - name: Get all EC2 VPC Peering Connections with specific filters + amazon.aws.ec2_vpc_peering_info: + filters: + status-code: [pending-acceptance] + register: pending_vpc_peers + + - name: Assert expected values + ansible.builtin.assert: + that: # Not guaranteed to just be us, only assert the shape - - pending_vpc_peers is successful - - "'vpc_peering_connections' in peer_info" - - "'result' in peer_info" - - "'accepter_vpc_info' in peer_details" - - "'requester_vpc_info' in peer_details" - - "'status' in peer_details" - - "'code' in peer_details.status" - - peer_details.status.code == "pending-acceptance" - - "'message' in peer_details.status" - - "'tags' in peer_details" - - "'vpc_peering_connection_id' in peer_details" - # Acceptor info isn't available until the connection has been accepted - - "'cidr_block' not in acceptor_details" - - "'cidr_block_set' not in acceptor_details" - - "'peering_options' not in acceptor_details" - - "'owner_id' in acceptor_details" - - "'region' in acceptor_details" - - "'vpc_id' in acceptor_details" - # Information about the 'requesting' VPC - - "'cidr_block' in requester_details" - - "'cidr_block_set' in requester_details" - - "'cidr_block' in requester_details.cidr_block_set[0]" - - "'peering_options' in requester_details" - - "'owner_id' in requester_details" - - "'region' in requester_details" - - "'vpc_id' in requester_details" - vars: - peer_details: '{{ pending_vpc_peers.vpc_peering_connections[0] }}' - acceptor_details: '{{ peer_details["accepter_vpc_info"] }}' - requester_details: '{{ peer_details["requester_vpc_info"] }}' - - - name: Update tags on the EC2 VPC Peering Connection (check_mode) - amazon.aws.ec2_vpc_peering: - vpc_id: '{{ vpc_1 }}' - peer_vpc_id: '{{ vpc_2 }}' - state: present - tags: - Name: '{{ connection_name }}' - testPrefix: '{{ resource_prefix }}' - check_mode: true - register: tag_peer - - - name: Assert success - ansible.builtin.assert: - that: - - tag_peer is changed - - - name: Update tags on the EC2 VPC Peering Connection - amazon.aws.ec2_vpc_peering: - vpc_id: '{{ vpc_1 }}' - peer_vpc_id: '{{ vpc_2 }}' - state: present - tags: - Name: '{{ connection_name }}' - testPrefix: '{{ resource_prefix }}' - register: tag_peer - - - name: Assert success - ansible.builtin.assert: - that: - - tag_peer is changed - - tag_peer is successful - - tag_peer.peering_id == peer_id_1 - - - name: Update tags on the EC2 VPC Peering Connection (idempotency check_mode) - amazon.aws.ec2_vpc_peering: - vpc_id: '{{ vpc_1 }}' - peer_vpc_id: '{{ vpc_2 }}' - state: present - tags: - Name: '{{ connection_name }}' - testPrefix: '{{ resource_prefix }}' - check_mode: true - register: tag_peer - - - name: Assert success - ansible.builtin.assert: - that: - - tag_peer is not changed - - - name: Update tags on the EC2 VPC Peering Connection (idempotency) - amazon.aws.ec2_vpc_peering: - vpc_id: '{{ vpc_1 }}' - peer_vpc_id: '{{ vpc_2 }}' - state: present - tags: - Name: '{{ connection_name }}' - testPrefix: '{{ resource_prefix }}' - register: tag_peer - - - name: Assert success - ansible.builtin.assert: - that: - - tag_peer is not changed - - tag_peer is successful - - tag_peer.peering_id == peer_id_1 - - - name: Get details on specific EC2 VPC Peering Connection - amazon.aws.ec2_vpc_peering_info: - peer_connection_ids: - - '{{ peer_id_1 }}' - register: peer_info - - - name: Assert expected tags - ansible.builtin.assert: - that: - - peer_info is successful - - "'tags' in peer_details" - - "'Name' in peer_details.tags" - - "'testPrefix' in peer_details.tags" - - peer_details.tags.Name == connection_name - - peer_details.tags.testPrefix == resource_prefix - vars: - peer_details: '{{ peer_info.vpc_peering_connections[0] }}' - - - name: Accept local EC2 VPC Peering request (check_mode) - amazon.aws.ec2_vpc_peering: - peering_id: '{{ vpc_peer.peering_id }}' - state: accept - wait: true - check_mode: true - register: action_peer - - - name: Assert success - ansible.builtin.assert: - that: - - action_peer is changed - - - name: Accept local EC2 VPC Peering request - amazon.aws.ec2_vpc_peering: - peering_id: '{{ vpc_peer.peering_id }}' - state: accept - wait: true - register: action_peer - - - name: Assert success - ansible.builtin.assert: - that: - - action_peer is changed - - action_peer is successful - - action_peer.peering_id == peer_id_1 - - action_peer.vpc_peering_connection.accepter_vpc_info.cidr_block == vpc_2_cidr - - action_peer.vpc_peering_connection.vpc_peering_connection_id == peer_id_1 - - - name: Get details on specific EC2 VPC Peering Connection - amazon.aws.ec2_vpc_peering_info: - peer_connection_ids: - - '{{ peer_id_1 }}' - register: peer_info - - - name: Assert expected values - ansible.builtin.assert: - that: - - peer_info is successful - - "'vpc_peering_connections' in peer_info" - - "'result' in peer_info" - - "'accepter_vpc_info' in peer_details" - - "'requester_vpc_info' in peer_details" - - "'status' in peer_details" - - "'code' in peer_details.status" - - peer_details.status.code == "active" - - "'message' in peer_details.status" - - "'tags' in peer_details" - - "'Name' in peer_details.tags" - - peer_details.tags.Name == connection_name - - "'testPrefix' in peer_details.tags" - - peer_details.tags.testPrefix == resource_prefix - - "'vpc_peering_connection_id' in peer_details" - - peer_details.vpc_peering_connection_id == peer_id_1 - # Information about the 'accepting' VPC should be available now - - "'cidr_block' in acceptor_details" - - acceptor_details.cidr_block == vpc_2_cidr - - "'cidr_block_set' in acceptor_details" - - acceptor_details.cidr_block_set | length == 1 - - "'cidr_block' in acceptor_details.cidr_block_set[0]" - - acceptor_details.cidr_block_set[0].cidr_block == vpc_2_cidr - - "'peering_options' in acceptor_details" - - "'owner_id' in acceptor_details" - - acceptor_details.owner_id == account_id - - "'region' in acceptor_details" - - acceptor_details.region == aws_region - - "'vpc_id' in acceptor_details" - - acceptor_details.vpc_id == vpc_2 - # Information about the 'requesting' VPC - - "'cidr_block' in requester_details" - - requester_details.cidr_block == vpc_1_cidr - - "'cidr_block_set' in requester_details" - - requester_details.cidr_block_set | length == 1 - - "'cidr_block' in requester_details.cidr_block_set[0]" - - requester_details.cidr_block_set[0].cidr_block == vpc_1_cidr - - "'peering_options' in requester_details" - - "'owner_id' in requester_details" - - requester_details.owner_id == account_id - - "'region' in requester_details" - - requester_details.region == aws_region - - "'vpc_id' in requester_details" - - requester_details.vpc_id == vpc_1 - vars: - peer_details: '{{ peer_info.vpc_peering_connections[0] }}' - acceptor_details: '{{ peer_details["accepter_vpc_info"] }}' - requester_details: '{{ peer_details["requester_vpc_info"] }}' - - - name: Accept local EC2 VPC Peering request (idempotency check_mode) - amazon.aws.ec2_vpc_peering: - peering_id: '{{ vpc_peer.peering_id }}' - state: accept - check_mode: true - register: action_peer - - - name: Assert success - ansible.builtin.assert: - that: - - action_peer is not changed - - - name: Accept local EC2 VPC Peering request (idempotency) - amazon.aws.ec2_vpc_peer: - peering_id: '{{ vpc_peer.peering_id }}' - state: accept - register: action_peer - - - name: Assert success - ansible.builtin.assert: - that: - - action_peer is not changed - - action_peer is successful - - action_peer.peering_id == peer_id_1 - - action_peer.vpc_peering_connection.vpc_peering_connection_id == peer_id_1 - - - name: Delete a local EC2 VPC Peering Connection (check_mode) - amazon.aws.ec2_vpc_peering: - peering_id: '{{ vpc_peer.peering_id }}' - state: absent - check_mode: true - register: delete_peer - - - name: Assert success - ansible.builtin.assert: - that: - - delete_peer is changed - - - name: Delete a local EC2 VPC Peering Connection - amazon.aws.ec2_vpc_peering: - peering_id: '{{ vpc_peer.peering_id }}' - state: absent - register: delete_peer - - - name: Assert success - ansible.builtin.assert: - that: - - delete_peer is changed - - delete_peer is successful - - "'peering_id' in delete_peer" - - - name: Get details on specific EC2 VPC Peering Connection - amazon.aws.ec2_vpc_peering_info: - peer_connection_ids: - - '{{ peer_id_1}}' - register: peer_info - - - name: Assert expected values - ansible.builtin.assert: - that: - - peer_info is successful - - "'vpc_peering_connections' in peer_info" - - "'result' in peer_info" - - "'accepter_vpc_info' in peer_details" - - "'requester_vpc_info' in peer_details" - - "'status' in peer_details" - - "'code' in peer_details.status" - - peer_details.status.code == "deleted" - - "'message' in peer_details.status" - - "'tags' in peer_details" - - "'Name' in peer_details.tags" - - peer_details.tags.Name == connection_name - - "'testPrefix' in peer_details.tags" - - peer_details.tags.testPrefix == resource_prefix - - "'vpc_peering_connection_id' in peer_details" - - peer_details.vpc_peering_connection_id == peer_id_1 - # Information about the 'accepting' VPC is reduced again - - "'cidr_block' not in acceptor_details" - - "'cidr_block_set' not in acceptor_details" - - "'peering_options' not in acceptor_details" - - "'owner_id' in acceptor_details" - - acceptor_details.owner_id == account_id - - "'region' in acceptor_details" - - acceptor_details.region == aws_region - - "'vpc_id' in acceptor_details" - - acceptor_details.vpc_id == vpc_2 - # Information about the 'requesting' VPC is reduced once the VPC's deleted - - "'cidr_block' not in requester_details" - - "'cidr_block_set' not in requester_details" - - "'peering_options' not in requester_details" - - "'owner_id' in requester_details" - - requester_details.owner_id == account_id - - "'region' in requester_details" - - requester_details.region == aws_region - - "'vpc_id' in requester_details" - - requester_details.vpc_id == vpc_1 - vars: - peer_details: '{{ peer_info.vpc_peering_connections[0] }}' - acceptor_details: '{{ peer_details["accepter_vpc_info"] }}' - requester_details: '{{ peer_details["requester_vpc_info"] }}' - - - name: Delete a local EC2 VPC Peering Connection (idempotency check_mode) - amazon.aws.ec2_vpc_peering: - peering_id: '{{ vpc_peer.peering_id }}' - state: absent - check_mode: true - register: delete_peer - - - name: Assert success - ansible.builtin.assert: - that: - - delete_peer is not changed - - - name: Delete a local EC2 VPC Peering Connection (idempotency) - amazon.aws.ec2_vpc_peering: - peering_id: '{{ vpc_peer.peering_id }}' - state: absent - register: delete_peer - - - name: Assert success - ansible.builtin.assert: - that: - - delete_peer is not changed - - delete_peer is successful - - - name: Create local account EC2 VPC Peering Connection - amazon.aws.ec2_vpc_peering: - vpc_id: '{{ vpc_1 }}' - peer_vpc_id: '{{ vpc_2 }}' - state: present - tags: - Name: Peering connection for VPC {{ vpc_1 }} to VPC {{ vpc_2 }} - register: vpc_peer2 - - - name: Assert success - ansible.builtin.assert: - that: - - vpc_peer2 is changed - - vpc_peer2 is successful - - "'peering_id' in vpc_peer2" - - vpc_peer2.peering_id.startswith('pcx-') - - - name: Store Connection ID - ansible.builtin.set_fact: - peer_id_2: '{{ vpc_peer2.peering_id }}' - - - name: Reject a local EC2 VPC Peering Connection - amazon.aws.ec2_vpc_peering: - peering_id: '{{ vpc_peer2.peering_id }}' - state: reject - wait: true - register: reject_peer - - - name: Assert success - ansible.builtin.assert: - that: - - reject_peer is changed - - reject_peer is successful - - reject_peer.peering_id == peer_id_2 - - - name: Reject a local EC2 VPC Peering Connection (idempotency) - amazon.aws.ec2_vpc_peering: - peering_id: '{{ vpc_peer2.peering_id }}' - state: reject - register: reject_peer - - - name: Assert success - ansible.builtin.assert: - that: - - reject_peer is not changed - - reject_peer is successful - - reject_peer.peering_id == peer_id_2 - - reject_peer.vpc_peering_connection.vpc_peering_connection_id == peer_id_2 - - - name: Delete a local EC2 VPC Peering Connections - amazon.aws.ec2_vpc_peering: - peering_id: '{{ vpc_peer2.peering_id }}' - state: absent - register: delete_peer - - - name: Assert success - ansible.builtin.assert: - that: - - delete_peer is not changed - - delete_peer is successful + - pending_vpc_peers is successful + - "'vpc_peering_connections' in peer_info" + - "'result' in peer_info" + - "'accepter_vpc_info' in peer_details" + - "'requester_vpc_info' in peer_details" + - "'status' in peer_details" + - "'code' in peer_details.status" + - peer_details.status.code == "pending-acceptance" + - "'message' in peer_details.status" + - "'tags' in peer_details" + - "'vpc_peering_connection_id' in peer_details" + # Acceptor info isn't available until the connection has been accepted + - "'cidr_block' not in acceptor_details" + - "'cidr_block_set' not in acceptor_details" + - "'peering_options' not in acceptor_details" + - "'owner_id' in acceptor_details" + - "'region' in acceptor_details" + - "'vpc_id' in acceptor_details" + # Information about the 'requesting' VPC + - "'cidr_block' in requester_details" + - "'cidr_block_set' in requester_details" + - "'cidr_block' in requester_details.cidr_block_set[0]" + - "'peering_options' in requester_details" + - "'owner_id' in requester_details" + - "'region' in requester_details" + - "'vpc_id' in requester_details" + vars: + peer_details: "{{ pending_vpc_peers.vpc_peering_connections[0] }}" + acceptor_details: '{{ peer_details["accepter_vpc_info"] }}' + requester_details: '{{ peer_details["requester_vpc_info"] }}' + + - name: Update tags on the EC2 VPC Peering Connection (check_mode) + amazon.aws.ec2_vpc_peering: + vpc_id: "{{ vpc_1 }}" + peer_vpc_id: "{{ vpc_2 }}" + state: present + tags: + Name: "{{ connection_name }}" + testPrefix: "{{ resource_prefix }}" + check_mode: true + register: tag_peer + + - name: Assert success + ansible.builtin.assert: + that: + - tag_peer is changed + + - name: Update tags on the EC2 VPC Peering Connection + amazon.aws.ec2_vpc_peering: + vpc_id: "{{ vpc_1 }}" + peer_vpc_id: "{{ vpc_2 }}" + state: present + tags: + Name: "{{ connection_name }}" + testPrefix: "{{ resource_prefix }}" + register: tag_peer + + - name: Assert success + ansible.builtin.assert: + that: + - tag_peer is changed + - tag_peer is successful + - tag_peer.peering_id == peer_id_1 + + - name: Update tags on the EC2 VPC Peering Connection (idempotency check_mode) + amazon.aws.ec2_vpc_peering: + vpc_id: "{{ vpc_1 }}" + peer_vpc_id: "{{ vpc_2 }}" + state: present + tags: + Name: "{{ connection_name }}" + testPrefix: "{{ resource_prefix }}" + check_mode: true + register: tag_peer + + - name: Assert success + ansible.builtin.assert: + that: + - tag_peer is not changed + + - name: Update tags on the EC2 VPC Peering Connection (idempotency) + amazon.aws.ec2_vpc_peering: + vpc_id: "{{ vpc_1 }}" + peer_vpc_id: "{{ vpc_2 }}" + state: present + tags: + Name: "{{ connection_name }}" + testPrefix: "{{ resource_prefix }}" + register: tag_peer + + - name: Assert success + ansible.builtin.assert: + that: + - tag_peer is not changed + - tag_peer is successful + - tag_peer.peering_id == peer_id_1 + + - name: Get details on specific EC2 VPC Peering Connection + amazon.aws.ec2_vpc_peering_info: + peer_connection_ids: + - "{{ peer_id_1 }}" + register: peer_info + + - name: Assert expected tags + ansible.builtin.assert: + that: + - peer_info is successful + - "'tags' in peer_details" + - "'Name' in peer_details.tags" + - "'testPrefix' in peer_details.tags" + - peer_details.tags.Name == connection_name + - peer_details.tags.testPrefix == resource_prefix + vars: + peer_details: "{{ peer_info.vpc_peering_connections[0] }}" + + - name: Accept local EC2 VPC Peering request (check_mode) + amazon.aws.ec2_vpc_peering: + peering_id: "{{ vpc_peer.peering_id }}" + state: accept + wait: true + check_mode: true + register: action_peer + + - name: Assert success + ansible.builtin.assert: + that: + - action_peer is changed + + - name: Accept local EC2 VPC Peering request + amazon.aws.ec2_vpc_peering: + peering_id: "{{ vpc_peer.peering_id }}" + state: accept + wait: true + register: action_peer + + - name: Assert success + ansible.builtin.assert: + that: + - action_peer is changed + - action_peer is successful + - action_peer.peering_id == peer_id_1 + - action_peer.vpc_peering_connection.accepter_vpc_info.cidr_block == vpc_2_cidr + - action_peer.vpc_peering_connection.vpc_peering_connection_id == peer_id_1 + + - name: Get details on specific EC2 VPC Peering Connection + amazon.aws.ec2_vpc_peering_info: + peer_connection_ids: + - "{{ peer_id_1 }}" + register: peer_info + + - name: Assert expected values + ansible.builtin.assert: + that: + - peer_info is successful + - "'vpc_peering_connections' in peer_info" + - "'result' in peer_info" + - "'accepter_vpc_info' in peer_details" + - "'requester_vpc_info' in peer_details" + - "'status' in peer_details" + - "'code' in peer_details.status" + - peer_details.status.code == "active" + - "'message' in peer_details.status" + - "'tags' in peer_details" + - "'Name' in peer_details.tags" + - peer_details.tags.Name == connection_name + - "'testPrefix' in peer_details.tags" + - peer_details.tags.testPrefix == resource_prefix + - "'vpc_peering_connection_id' in peer_details" + - peer_details.vpc_peering_connection_id == peer_id_1 + # Information about the 'accepting' VPC should be available now + - "'cidr_block' in acceptor_details" + - acceptor_details.cidr_block == vpc_2_cidr + - "'cidr_block_set' in acceptor_details" + - acceptor_details.cidr_block_set | length == 1 + - "'cidr_block' in acceptor_details.cidr_block_set[0]" + - acceptor_details.cidr_block_set[0].cidr_block == vpc_2_cidr + - "'peering_options' in acceptor_details" + - "'owner_id' in acceptor_details" + - acceptor_details.owner_id == account_id + - "'region' in acceptor_details" + - acceptor_details.region == aws_region + - "'vpc_id' in acceptor_details" + - acceptor_details.vpc_id == vpc_2 + # Information about the 'requesting' VPC + - "'cidr_block' in requester_details" + - requester_details.cidr_block == vpc_1_cidr + - "'cidr_block_set' in requester_details" + - requester_details.cidr_block_set | length == 1 + - "'cidr_block' in requester_details.cidr_block_set[0]" + - requester_details.cidr_block_set[0].cidr_block == vpc_1_cidr + - "'peering_options' in requester_details" + - "'owner_id' in requester_details" + - requester_details.owner_id == account_id + - "'region' in requester_details" + - requester_details.region == aws_region + - "'vpc_id' in requester_details" + - requester_details.vpc_id == vpc_1 + vars: + peer_details: "{{ peer_info.vpc_peering_connections[0] }}" + acceptor_details: '{{ peer_details["accepter_vpc_info"] }}' + requester_details: '{{ peer_details["requester_vpc_info"] }}' + + - name: Accept local EC2 VPC Peering request (idempotency check_mode) + amazon.aws.ec2_vpc_peering: + peering_id: "{{ vpc_peer.peering_id }}" + state: accept + check_mode: true + register: action_peer + + - name: Assert success + ansible.builtin.assert: + that: + - action_peer is not changed + + - name: Accept local EC2 VPC Peering request (idempotency) + amazon.aws.ec2_vpc_peering: + peering_id: "{{ vpc_peer.peering_id }}" + state: accept + register: action_peer + + - name: Assert success + ansible.builtin.assert: + that: + - action_peer is not changed + - action_peer is successful + - action_peer.peering_id == peer_id_1 + - action_peer.vpc_peering_connection.vpc_peering_connection_id == peer_id_1 + + - name: Delete a local EC2 VPC Peering Connection (check_mode) + amazon.aws.ec2_vpc_peering: + peering_id: "{{ vpc_peer.peering_id }}" + state: absent + check_mode: true + register: delete_peer + + - name: Assert success + ansible.builtin.assert: + that: + - delete_peer is changed + + - name: Delete a local EC2 VPC Peering Connection + amazon.aws.ec2_vpc_peering: + peering_id: "{{ vpc_peer.peering_id }}" + state: absent + register: delete_peer + + - name: Assert success + ansible.builtin.assert: + that: + - delete_peer is changed + - delete_peer is successful + - "'peering_id' in delete_peer" + + - name: Get details on specific EC2 VPC Peering Connection + amazon.aws.ec2_vpc_peering_info: + peer_connection_ids: + - "{{ peer_id_1 }}" + register: peer_info + + - name: Assert expected values + ansible.builtin.assert: + that: + - peer_info is successful + - "'vpc_peering_connections' in peer_info" + - "'result' in peer_info" + - "'accepter_vpc_info' in peer_details" + - "'requester_vpc_info' in peer_details" + - "'status' in peer_details" + - "'code' in peer_details.status" + - peer_details.status.code == "deleted" + - "'message' in peer_details.status" + - "'tags' in peer_details" + - "'Name' in peer_details.tags" + - peer_details.tags.Name == connection_name + - "'testPrefix' in peer_details.tags" + - peer_details.tags.testPrefix == resource_prefix + - "'vpc_peering_connection_id' in peer_details" + - peer_details.vpc_peering_connection_id == peer_id_1 + # Information about the 'accepting' VPC is reduced again + - "'cidr_block' not in acceptor_details" + - "'cidr_block_set' not in acceptor_details" + - "'peering_options' not in acceptor_details" + - "'owner_id' in acceptor_details" + - acceptor_details.owner_id == account_id + - "'region' in acceptor_details" + - acceptor_details.region == aws_region + - "'vpc_id' in acceptor_details" + - acceptor_details.vpc_id == vpc_2 + # Information about the 'requesting' VPC is reduced once the VPC's deleted + - "'cidr_block' not in requester_details" + - "'cidr_block_set' not in requester_details" + - "'peering_options' not in requester_details" + - "'owner_id' in requester_details" + - requester_details.owner_id == account_id + - "'region' in requester_details" + - requester_details.region == aws_region + - "'vpc_id' in requester_details" + - requester_details.vpc_id == vpc_1 + vars: + peer_details: "{{ peer_info.vpc_peering_connections[0] }}" + acceptor_details: '{{ peer_details["accepter_vpc_info"] }}' + requester_details: '{{ peer_details["requester_vpc_info"] }}' + + - name: Delete a local EC2 VPC Peering Connection (idempotency check_mode) + amazon.aws.ec2_vpc_peering: + peering_id: "{{ vpc_peer.peering_id }}" + state: absent + check_mode: true + register: delete_peer + + - name: Assert success + ansible.builtin.assert: + that: + - delete_peer is not changed + + - name: Delete a local EC2 VPC Peering Connection (idempotency) + amazon.aws.ec2_vpc_peering: + peering_id: "{{ vpc_peer.peering_id }}" + state: absent + register: delete_peer + + - name: Assert success + ansible.builtin.assert: + that: + - delete_peer is not changed + - delete_peer is successful + + - name: Create local account EC2 VPC Peering Connection + amazon.aws.ec2_vpc_peering: + vpc_id: "{{ vpc_1 }}" + peer_vpc_id: "{{ vpc_2 }}" + state: present + tags: + Name: Peering connection for VPC {{ vpc_1 }} to VPC {{ vpc_2 }} + register: vpc_peer2 + + - name: Assert success + ansible.builtin.assert: + that: + - vpc_peer2 is changed + - vpc_peer2 is successful + - "'peering_id' in vpc_peer2" + - vpc_peer2.peering_id.startswith('pcx-') + + - name: Store Connection ID + ansible.builtin.set_fact: + peer_id_2: "{{ vpc_peer2.peering_id }}" + + - name: Reject a local EC2 VPC Peering Connection + amazon.aws.ec2_vpc_peering: + peering_id: "{{ vpc_peer2.peering_id }}" + state: reject + wait: true + register: reject_peer + + - name: Assert success + ansible.builtin.assert: + that: + - reject_peer is changed + - reject_peer is successful + - reject_peer.peering_id == peer_id_2 + + - name: Reject a local EC2 VPC Peering Connection (idempotency) + amazon.aws.ec2_vpc_peering: + peering_id: "{{ vpc_peer2.peering_id }}" + state: reject + register: reject_peer + + - name: Assert success + ansible.builtin.assert: + that: + - reject_peer is not changed + - reject_peer is successful + - reject_peer.peering_id == peer_id_2 + - reject_peer.vpc_peering_connection.vpc_peering_connection_id == peer_id_2 + + - name: Delete a local EC2 VPC Peering Connections + amazon.aws.ec2_vpc_peering: + peering_id: "{{ vpc_peer2.peering_id }}" + state: absent + register: delete_peer + + - name: Assert success + ansible.builtin.assert: + that: + - delete_peer is not changed + - delete_peer is successful always: - - - name: Find all EC2 VPC Peering Connections for our VPCs - amazon.aws.ec2_vpc_peering_info: - filters: - accepter-vpc-info.vpc-id: '{{ item }}' - register: peering_info - loop: - - '{{ vpc_1 }}' - - '{{ vpc_2 }}' - - - ansible.builtin.set_fact: - vpc_peering_connection_ids: '{{ _vpc_peering_connections | map(attribute="vpc_peering_connection_id") - | list }}' - vars: - _vpc_peering_connections: '{{ peering_info.results | map(attribute="vpc_peering_connections") - | flatten }}' - ignore_errors: true + - name: Find all EC2 VPC Peering Connections for our VPCs + amazon.aws.ec2_vpc_peering_info: + filters: + accepter-vpc-info.vpc-id: "{{ item }}" + register: peering_info + loop: + - "{{ vpc_1 }}" + - "{{ vpc_2 }}" + + - ansible.builtin.set_fact: + vpc_peering_connection_ids: '{{ _vpc_peering_connections | map(attribute="vpc_peering_connection_id") | list }}' + vars: + _vpc_peering_connections: '{{ peering_info.results | map(attribute="vpc_peering_connections") | flatten }}' + ignore_errors: true # ============================================================ - - name: Delete remaining EC2 VPC Peering Connections - amazon.aws.ec2_vpc_peering: - peering_id: '{{ item }}' - state: absent - ignore_errors: true - loop: '{{ vpc_peering_connection_ids }}' - - - name: Tidy up VPCs - amazon.aws.ec2_vpc_net: - name: '{{ item.name }}' - state: absent - cidr_block: '{{ item.cidr }}' - ignore_errors: true - loop: - - {name: '{{ vpc_2_name }}', cidr: '{{ vpc_2_cidr }}'} - - {name: '{{ vpc_1_name }}', cidr: '{{ vpc_1_cidr }}'} + - name: Delete remaining EC2 VPC Peering Connections + amazon.aws.ec2_vpc_peering: + peering_id: "{{ item }}" + state: absent + ignore_errors: true + loop: "{{ vpc_peering_connection_ids }}" + + - name: Tidy up VPCs + amazon.aws.ec2_vpc_net: + name: "{{ item.name }}" + state: absent + cidr_block: "{{ item.cidr }}" + ignore_errors: true + loop: + - { name: "{{ vpc_2_name }}", cidr: "{{ vpc_2_cidr }}" } + - { name: "{{ vpc_1_name }}", cidr: "{{ vpc_1_cidr }}" } 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 84cf91fd11c..7b356b4f1b7 100644 --- a/tests/integration/targets/ec2_vpc_route_table/tasks/main.yml +++ b/tests/integration/targets/ec2_vpc_route_table/tasks/main.yml @@ -1,5 +1,5 @@ --- -- name: ec2_vpc_route_table integration tests +- name: Ec2_vpc_route_table integration tests module_defaults: group/aws: access_key: "{{ aws_access_key }}" @@ -71,7 +71,7 @@ cidr: "{{ item.cidr }}" az: "{{ item.zone }}" assign_instances_ipv6: "{{ item.assign_instances_ipv6 }}" - ipv6_cidr: "{{ item.ipv6_cidr }}" + ipv6_cidr: "{{ item.ipv6_cidr }}" vpc_id: "{{ vpc.vpc.id }}" state: present tags: @@ -147,7 +147,7 @@ asn: 4200000000 wait: true tags: - "team": "cloud" + "team": "cloud" register: transit_gateway - name: Create VPC attachment @@ -159,7 +159,7 @@ tags: "team": "cloud" wait: true - purge_subnets: False + purge_subnets: false register: vpc_attachment - name: CHECK MODE - route table should be created @@ -373,7 +373,7 @@ that: - not check_mode_results.changed - - name: rerun with purge_routes set to false + - name: Rerun with purge_routes set to false amazon.aws.ec2_vpc_route_table: vpc_id: "{{ vpc.vpc.id }}" tags: @@ -390,7 +390,7 @@ - no_purge_routes.route_table.routes | length == 4 - no_purge_routes.route_table.associations | length == 3 - - name: rerun with purge_subnets set to false + - name: Rerun with purge_subnets set to false amazon.aws.ec2_vpc_route_table: vpc_id: "{{ vpc.vpc.id }}" tags: @@ -409,7 +409,7 @@ - no_purge_subnets.route_table.routes | length == 4 - no_purge_subnets.route_table.associations | length == 3 - - name: rerun with purge_tags not set (implicitly false) + - name: Rerun with purge_tags not set (implicitly false) amazon.aws.ec2_vpc_route_table: vpc_id: "{{ vpc.vpc.id }}" routes: @@ -475,7 +475,7 @@ that: - check_mode_results.changed - - name: add subnets by cidr to public route table + - name: Add subnets by cidr to public route table amazon.aws.ec2_vpc_route_table: vpc_id: "{{ vpc.vpc.id }}" routes: @@ -507,7 +507,7 @@ - purge_subnets_cidr.changed - purge_subnets_cidr.route_table.associations | length == 0 - - name: add subnets by name to public route table + - name: Add subnets by name to public route table amazon.aws.ec2_vpc_route_table: vpc_id: "{{ vpc.vpc.id }}" routes: @@ -570,7 +570,7 @@ that: - check_mode_results.changed - - name: update tags + - name: Update tags amazon.aws.ec2_vpc_route_table: vpc_id: "{{ vpc.vpc.id }}" route_table_id: "{{ create_public_table.route_table.id }}" @@ -648,11 +648,11 @@ tags: Updated: new_tag Name: Public route table - register: Destroy_table + register: destroy_table - name: Assert Destroy table worked ansible.builtin.assert: that: - - Destroy_table.changed + - destroy_table.changed - name: CHECK MODE - redestroy public route table amazon.aws.ec2_vpc_route_table: @@ -666,7 +666,7 @@ that: - not check_mode_results.changed - - name: redestroy public route table + - name: Redestroy public route table amazon.aws.ec2_vpc_route_table: route_table_id: "{{ create_public_table.route_table.id }}" lookup: id @@ -686,7 +686,7 @@ subnet_id: "{{ subnets.results[0].subnet.id }}" nat_gateway_id: "{{ nat_gateway.nat_gateway_id }}" register: nat_gateway - - name: show route table info, get table using route-table-id + - name: Show route table info, get table using route-table-id amazon.aws.ec2_vpc_route_table_info: filters: route-table-id: "{{ create_private_table.route_table.id }}" @@ -704,7 +704,7 @@ - route_table_info.route_tables[0].id == create_private_table.route_table.id - '"propagating_vgws" in route_table_info.route_tables[0]' - - name: show route table info, get table using tags + - name: Show route table info, get table using tags amazon.aws.ec2_vpc_route_table_info: filters: tag:Public: "false" @@ -1426,7 +1426,7 @@ gateway_id: "{{ vgw.vgw.id }}" purge_routes: false register: create_gateway_table - + - name: Assert that there is no change ansible.builtin.assert: that: @@ -1575,7 +1575,7 @@ - name: Delete transit gateway amazon.aws.ec2_transit_gateway: state: absent - transit_gateway_id: '{{ transit_gateway.transit_gateway.transit_gateway_id }}' + transit_gateway_id: "{{ transit_gateway.transit_gateway.transit_gateway_id }}" wait: true ignore_errors: true - name: Destroy ENI diff --git a/tests/integration/targets/ec2_vpc_subnet/defaults/main.yml b/tests/integration/targets/ec2_vpc_subnet/defaults/main.yml index df946f8f315..64d3215ecbf 100644 --- a/tests/integration/targets/ec2_vpc_subnet/defaults/main.yml +++ b/tests/integration/targets/ec2_vpc_subnet/defaults/main.yml @@ -2,7 +2,7 @@ availability_zone: "{{ ec2_availability_zone_names[0] }}" # defaults file for ec2_vpc_subnet -ec2_vpc_subnet_name: "{{resource_prefix}}" +ec2_vpc_subnet_name: "{{ resource_prefix }}" ec2_vpc_subnet_description: Created by ansible integration tests vpc_cidr: 10.{{ 256 | random(seed=resource_prefix) }}.0.0/16 subnet_cidr: 10.{{ 256 | random(seed=resource_prefix) }}.1.0/24 diff --git a/tests/integration/targets/ec2_vpc_subnet/tasks/main.yml b/tests/integration/targets/ec2_vpc_subnet/tasks/main.yml index 998b4638b65..9c40c3478e0 100644 --- a/tests/integration/targets/ec2_vpc_subnet/tasks/main.yml +++ b/tests/integration/targets/ec2_vpc_subnet/tasks/main.yml @@ -7,7 +7,7 @@ region: "{{ aws_region }}" block: # ============================================================ - - name: create a VPC + - name: Create a VPC amazon.aws.ec2_vpc_net: name: "{{ resource_prefix }}-vpc" state: present @@ -25,10 +25,10 @@ subnet_ipv6_cidr: "{{ vpc_ipv6_cidr | regex_replace('::/.*', '::/64') }}" # ============================================================ - - name: check subnet does not exist + - name: Check subnet does not exist amazon.aws.ec2_vpc_subnet_info: filters: - tag:Name: "{{ec2_vpc_subnet_name}}" + tag:Name: "{{ ec2_vpc_subnet_name }}" register: vpc_subnet_info - name: Assert info result is zero @@ -36,35 +36,35 @@ that: - (vpc_subnet_info.subnets|length) == 0 - - name: create subnet (expected changed=true) (CHECK MODE) + - name: Create subnet (expected changed=true) (CHECK MODE) amazon.aws.ec2_vpc_subnet: cidr: "{{ subnet_cidr }}" az: "{{ availability_zone }}" vpc_id: "{{ vpc_result.vpc.id }}" tags: - Name: "{{ec2_vpc_subnet_name}}" - Description: "{{ec2_vpc_subnet_description}}" + Name: "{{ ec2_vpc_subnet_name }}" + Description: "{{ ec2_vpc_subnet_description }}" state: present check_mode: true register: vpc_subnet_create - - name: assert creation would happen + - name: Assert creation would happen ansible.builtin.assert: that: - vpc_subnet_create is changed - - name: create subnet (expected changed=true) + - name: Create subnet (expected changed=true) amazon.aws.ec2_vpc_subnet: cidr: "{{ subnet_cidr }}" az: "{{ availability_zone }}" vpc_id: "{{ vpc_result.vpc.id }}" tags: - Name: "{{ec2_vpc_subnet_name}}" - Description: "{{ec2_vpc_subnet_description}}" + Name: "{{ ec2_vpc_subnet_name }}" + Description: "{{ ec2_vpc_subnet_description }}" state: present register: vpc_subnet_create - - name: assert creation happened (expected changed=true) + - name: Assert creation happened (expected changed=true) ansible.builtin.assert: that: - vpc_subnet_create @@ -74,7 +74,7 @@ - '"Name" in vpc_subnet_create.subnet.tags and vpc_subnet_create.subnet.tags["Name"] == ec2_vpc_subnet_name' - '"Description" in vpc_subnet_create.subnet.tags and vpc_subnet_create.subnet.tags["Description"] == ec2_vpc_subnet_description' - - name: get info about the subnet + - name: Get info about the subnet amazon.aws.ec2_vpc_subnet_info: subnet_ids: "{{ vpc_subnet_create.subnet.id }}" register: vpc_subnet_info @@ -107,129 +107,129 @@ subnet_info: "{{ vpc_subnet_info.subnets[0] }}" # ============================================================ - - name: recreate subnet (expected changed=false) (CHECK MODE) + - name: Recreate subnet (expected changed=false) (CHECK MODE) amazon.aws.ec2_vpc_subnet: cidr: "{{ subnet_cidr }}" az: "{{ availability_zone }}" vpc_id: "{{ vpc_result.vpc.id }}" tags: - Name: "{{ec2_vpc_subnet_name}}" - Description: "{{ec2_vpc_subnet_description}}" + Name: "{{ ec2_vpc_subnet_name }}" + Description: "{{ ec2_vpc_subnet_description }}" state: present check_mode: true register: vpc_subnet_recreate - - name: assert recreation changed nothing (expected changed=false) + - name: Assert recreation changed nothing (expected changed=false) ansible.builtin.assert: that: - vpc_subnet_recreate is not changed - - name: recreate subnet (expected changed=false) + - name: Recreate subnet (expected changed=false) amazon.aws.ec2_vpc_subnet: cidr: "{{ subnet_cidr }}" az: "{{ availability_zone }}" vpc_id: "{{ vpc_result.vpc.id }}" tags: - Name: "{{ec2_vpc_subnet_name}}" - Description: "{{ec2_vpc_subnet_description}}" + Name: "{{ ec2_vpc_subnet_name }}" + Description: "{{ ec2_vpc_subnet_description }}" state: present register: vpc_subnet_recreate - - name: assert recreation changed nothing (expected changed=false) + - name: Assert recreation changed nothing (expected changed=false) ansible.builtin.assert: that: - vpc_subnet_recreate is not changed - vpc_subnet_recreate.subnet == vpc_subnet_create.subnet # ============================================================ - - name: update subnet so instances launched in it are assigned an IP (CHECK MODE) + - name: Update subnet so instances launched in it are assigned an IP (CHECK MODE) amazon.aws.ec2_vpc_subnet: cidr: "{{ subnet_cidr }}" az: "{{ availability_zone }}" vpc_id: "{{ vpc_result.vpc.id }}" tags: - Name: "{{ec2_vpc_subnet_name}}" - Description: "{{ec2_vpc_subnet_description}}" + Name: "{{ ec2_vpc_subnet_name }}" + Description: "{{ ec2_vpc_subnet_description }}" state: present map_public: true check_mode: true register: vpc_subnet_modify - - name: assert subnet changed + - name: Assert subnet changed ansible.builtin.assert: that: - vpc_subnet_modify is changed - - name: update subnet so instances launched in it are assigned an IP + - name: Update subnet so instances launched in it are assigned an IP amazon.aws.ec2_vpc_subnet: cidr: "{{ subnet_cidr }}" az: "{{ availability_zone }}" vpc_id: "{{ vpc_result.vpc.id }}" tags: - Name: "{{ec2_vpc_subnet_name}}" - Description: "{{ec2_vpc_subnet_description}}" + Name: "{{ ec2_vpc_subnet_name }}" + Description: "{{ ec2_vpc_subnet_description }}" state: present map_public: true register: vpc_subnet_modify - - name: assert subnet changed + - name: Assert subnet changed ansible.builtin.assert: that: - vpc_subnet_modify is changed - vpc_subnet_modify.subnet.map_public_ip_on_launch # ============================================================ - - name: add invalid ipv6 block to subnet (expected failed) + - name: Add invalid ipv6 block to subnet (expected failed) amazon.aws.ec2_vpc_subnet: cidr: "{{ subnet_cidr }}" az: "{{ availability_zone }}" vpc_id: "{{ vpc_result.vpc.id }}" ipv6_cidr: 2001:db8::/64 tags: - Name: "{{ec2_vpc_subnet_name}}" - Description: "{{ec2_vpc_subnet_description}}" + Name: "{{ ec2_vpc_subnet_name }}" + Description: "{{ ec2_vpc_subnet_description }}" state: present register: vpc_subnet_ipv6_failed ignore_errors: true - - name: assert failure happened (expected failed) + - name: Assert failure happened (expected failed) ansible.builtin.assert: that: - vpc_subnet_ipv6_failed is failed - "'Couldn\\'t associate ipv6 cidr' in vpc_subnet_ipv6_failed.msg" # ============================================================ - - name: add a tag (expected changed=true) (CHECK MODE) + - name: Add a tag (expected changed=true) (CHECK MODE) amazon.aws.ec2_vpc_subnet: cidr: "{{ subnet_cidr }}" az: "{{ availability_zone }}" vpc_id: "{{ vpc_result.vpc.id }}" tags: - Name: "{{ec2_vpc_subnet_name}}" - Description: "{{ec2_vpc_subnet_description}}" + Name: "{{ ec2_vpc_subnet_name }}" + Description: "{{ ec2_vpc_subnet_description }}" AnotherTag: SomeValue state: present check_mode: true register: vpc_subnet_add_a_tag - - name: assert tag addition happened (expected changed=true) + - name: Assert tag addition happened (expected changed=true) ansible.builtin.assert: that: - vpc_subnet_add_a_tag is changed - - name: add a tag (expected changed=true) + - name: Add a tag (expected changed=true) amazon.aws.ec2_vpc_subnet: cidr: "{{ subnet_cidr }}" az: "{{ availability_zone }}" vpc_id: "{{ vpc_result.vpc.id }}" tags: - Name: "{{ec2_vpc_subnet_name}}" - Description: "{{ec2_vpc_subnet_description}}" + Name: "{{ ec2_vpc_subnet_name }}" + Description: "{{ ec2_vpc_subnet_description }}" AnotherTag: SomeValue state: present register: vpc_subnet_add_a_tag - - name: assert tag addition happened (expected changed=true) + - name: Assert tag addition happened (expected changed=true) ansible.builtin.assert: that: - vpc_subnet_add_a_tag is changed @@ -240,10 +240,10 @@ - name: Get info by tag amazon.aws.ec2_vpc_subnet_info: filters: - tag:Name: "{{ec2_vpc_subnet_name}}" + tag:Name: "{{ ec2_vpc_subnet_name }}" register: vpc_subnet_info_by_tag - - name: assert info matches expected output + - name: Assert info matches expected output ansible.builtin.assert: that: - vpc_subnet_info_by_tag.subnets[0].id == vpc_subnet_add_a_tag.subnet.id @@ -252,7 +252,7 @@ - '"AnotherTag" in vpc_subnet_info_by_tag.subnets[0].tags and vpc_subnet_info_by_tag.subnets[0].tags["AnotherTag"] == "SomeValue"' # ============================================================ - - name: remove tags with default purge_tags=true (expected changed=true) (CHECK MODE) + - name: Remove tags with default purge_tags=true (expected changed=true) (CHECK MODE) amazon.aws.ec2_vpc_subnet: cidr: "{{ subnet_cidr }}" az: "{{ availability_zone }}" @@ -263,12 +263,12 @@ check_mode: true register: vpc_subnet_remove_tags - - name: assert tag removal happened (expected changed=true) + - name: Assert tag removal happened (expected changed=true) ansible.builtin.assert: that: - vpc_subnet_remove_tags is changed - - name: remove tags with default purge_tags=true (expected changed=true) + - name: Remove tags with default purge_tags=true (expected changed=true) amazon.aws.ec2_vpc_subnet: cidr: "{{ subnet_cidr }}" az: "{{ availability_zone }}" @@ -278,7 +278,7 @@ state: present register: vpc_subnet_remove_tags - - name: assert tag removal happened (expected changed=true) + - name: Assert tag removal happened (expected changed=true) ansible.builtin.assert: that: - vpc_subnet_remove_tags is changed @@ -291,7 +291,7 @@ subnet_id: "{{ vpc_subnet_remove_tags.subnet.id }}" register: vpc_subnet_info_removed_tags - - name: assert info matches expected output + - name: Assert info matches expected output ansible.builtin.assert: that: - '"Name" not in vpc_subnet_info_removed_tags.subnets[0].tags' @@ -299,37 +299,37 @@ - '"AnotherTag" in vpc_subnet_info_removed_tags.subnets[0].tags and vpc_subnet_info_removed_tags.subnets[0].tags["AnotherTag"] == "SomeValue"' # ============================================================ - - name: change tags with purge_tags=false (expected changed=true) (CHECK MODE) + - name: Change tags with purge_tags=false (expected changed=true) (CHECK MODE) amazon.aws.ec2_vpc_subnet: cidr: "{{ subnet_cidr }}" az: "{{ availability_zone }}" vpc_id: "{{ vpc_result.vpc.id }}" tags: - Name: "{{ec2_vpc_subnet_name}}" - Description: "{{ec2_vpc_subnet_description}}" + Name: "{{ ec2_vpc_subnet_name }}" + Description: "{{ ec2_vpc_subnet_description }}" state: present purge_tags: false check_mode: true register: vpc_subnet_change_tags - - name: assert tag addition happened (expected changed=true) + - name: Assert tag addition happened (expected changed=true) ansible.builtin.assert: that: - vpc_subnet_change_tags is changed - - name: change tags with purge_tags=false (expected changed=true) + - name: Change tags with purge_tags=false (expected changed=true) amazon.aws.ec2_vpc_subnet: cidr: "{{ subnet_cidr }}" az: "{{ availability_zone }}" vpc_id: "{{ vpc_result.vpc.id }}" tags: - Name: "{{ec2_vpc_subnet_name}}" - Description: "{{ec2_vpc_subnet_description}}" + Name: "{{ ec2_vpc_subnet_name }}" + Description: "{{ ec2_vpc_subnet_description }}" state: present purge_tags: false register: vpc_subnet_change_tags - - name: assert tag addition happened (expected changed=true) + - name: Assert tag addition happened (expected changed=true) ansible.builtin.assert: that: - vpc_subnet_change_tags is changed @@ -338,7 +338,7 @@ - '"AnotherTag" in vpc_subnet_change_tags.subnet.tags and vpc_subnet_change_tags.subnet.tags["AnotherTag"] == "SomeValue"' # ============================================================ - - name: test state=absent (expected changed=true) (CHECK MODE) + - name: Test state=absent (expected changed=true) (CHECK MODE) amazon.aws.ec2_vpc_subnet: cidr: "{{ subnet_cidr }}" vpc_id: "{{ vpc_result.vpc.id }}" @@ -346,25 +346,25 @@ check_mode: true register: result - - name: assert state=absent (expected changed=true) + - name: Assert state=absent (expected changed=true) ansible.builtin.assert: that: - result is changed - - name: test state=absent (expected changed=true) + - name: Test state=absent (expected changed=true) amazon.aws.ec2_vpc_subnet: cidr: "{{ subnet_cidr }}" vpc_id: "{{ vpc_result.vpc.id }}" state: absent register: result - - name: assert state=absent (expected changed=true) + - name: Assert state=absent (expected changed=true) ansible.builtin.assert: that: - result is changed # ============================================================ - - name: test state=absent (expected changed=false) (CHECK MODE) + - name: Test state=absent (expected changed=false) (CHECK MODE) amazon.aws.ec2_vpc_subnet: cidr: "{{ subnet_cidr }}" vpc_id: "{{ vpc_result.vpc.id }}" @@ -372,25 +372,25 @@ check_mode: true register: result - - name: assert state=absent (expected changed=false) + - name: Assert state=absent (expected changed=false) ansible.builtin.assert: that: - result is not changed - - name: test state=absent (expected changed=false) + - name: Test state=absent (expected changed=false) amazon.aws.ec2_vpc_subnet: cidr: "{{ subnet_cidr }}" vpc_id: "{{ vpc_result.vpc.id }}" state: absent register: result - - name: assert state=absent (expected changed=false) + - name: Assert state=absent (expected changed=false) ansible.builtin.assert: that: - result is not changed # ============================================================ - - name: create subnet without AZ (CHECK MODE) + - name: Create subnet without AZ (CHECK MODE) amazon.aws.ec2_vpc_subnet: cidr: "{{ subnet_cidr }}" vpc_id: "{{ vpc_result.vpc.id }}" @@ -398,25 +398,25 @@ check_mode: true register: subnet_without_az - - name: check that subnet without AZ works fine + - name: Check that subnet without AZ works fine ansible.builtin.assert: that: - subnet_without_az is changed - - name: create subnet without AZ + - name: Create subnet without AZ amazon.aws.ec2_vpc_subnet: cidr: "{{ subnet_cidr }}" vpc_id: "{{ vpc_result.vpc.id }}" state: present register: subnet_without_az - - name: check that subnet without AZ works fine + - name: Check that subnet without AZ works fine ansible.builtin.assert: that: - subnet_without_az is changed # ============================================================ - - name: remove subnet without AZ (CHECK MODE) + - name: Remove subnet without AZ (CHECK MODE) amazon.aws.ec2_vpc_subnet: cidr: "{{ subnet_cidr }}" vpc_id: "{{ vpc_result.vpc.id }}" @@ -424,25 +424,25 @@ check_mode: true register: result - - name: assert state=absent (expected changed=true) + - name: Assert state=absent (expected changed=true) ansible.builtin.assert: that: - result is changed - - name: remove subnet without AZ + - name: Remove subnet without AZ amazon.aws.ec2_vpc_subnet: cidr: "{{ subnet_cidr }}" vpc_id: "{{ vpc_result.vpc.id }}" state: absent register: result - - name: assert state=absent (expected changed=true) + - name: Assert state=absent (expected changed=true) ansible.builtin.assert: that: - result is changed # ============================================================ - - name: create subnet with IPv6 (expected changed=true) (CHECK MODE) + - name: Create subnet with IPv6 (expected changed=true) (CHECK MODE) amazon.aws.ec2_vpc_subnet: cidr: "{{ subnet_cidr }}" vpc_id: "{{ vpc_result.vpc.id }}" @@ -450,17 +450,17 @@ assign_instances_ipv6: true state: present tags: - Name: "{{ec2_vpc_subnet_name}}" - Description: "{{ec2_vpc_subnet_description}}" + Name: "{{ ec2_vpc_subnet_name }}" + Description: "{{ ec2_vpc_subnet_description }}" check_mode: true register: vpc_subnet_ipv6_create - - name: assert creation with IPv6 happened (expected changed=true) + - name: Assert creation with IPv6 happened (expected changed=true) ansible.builtin.assert: that: - vpc_subnet_ipv6_create is changed - - name: create subnet with IPv6 (expected changed=true) + - name: Create subnet with IPv6 (expected changed=true) amazon.aws.ec2_vpc_subnet: cidr: "{{ subnet_cidr }}" vpc_id: "{{ vpc_result.vpc.id }}" @@ -468,11 +468,11 @@ assign_instances_ipv6: true state: present tags: - Name: "{{ec2_vpc_subnet_name}}" - Description: "{{ec2_vpc_subnet_description}}" + Name: "{{ ec2_vpc_subnet_name }}" + Description: "{{ ec2_vpc_subnet_description }}" register: vpc_subnet_ipv6_create - - name: assert creation with IPv6 happened (expected changed=true) + - name: Assert creation with IPv6 happened (expected changed=true) ansible.builtin.assert: that: - vpc_subnet_ipv6_create is changed @@ -483,7 +483,7 @@ - vpc_subnet_ipv6_create.subnet.assign_ipv6_address_on_creation # ============================================================ - - name: recreate subnet (expected changed=false) (CHECK MODE) + - name: Recreate subnet (expected changed=false) (CHECK MODE) amazon.aws.ec2_vpc_subnet: cidr: "{{ subnet_cidr }}" vpc_id: "{{ vpc_result.vpc.id }}" @@ -491,17 +491,17 @@ assign_instances_ipv6: true state: present tags: - Name: "{{ec2_vpc_subnet_name}}" - Description: "{{ec2_vpc_subnet_description}}" + Name: "{{ ec2_vpc_subnet_name }}" + Description: "{{ ec2_vpc_subnet_description }}" check_mode: true register: vpc_subnet_ipv6_recreate - - name: assert recreation changed nothing (expected changed=false) + - name: Assert recreation changed nothing (expected changed=false) ansible.builtin.assert: that: - vpc_subnet_ipv6_recreate is not changed - - name: recreate subnet (expected changed=false) + - name: Recreate subnet (expected changed=false) amazon.aws.ec2_vpc_subnet: cidr: "{{ subnet_cidr }}" vpc_id: "{{ vpc_result.vpc.id }}" @@ -509,18 +509,18 @@ assign_instances_ipv6: true state: present tags: - Name: "{{ec2_vpc_subnet_name}}" - Description: "{{ec2_vpc_subnet_description}}" + Name: "{{ ec2_vpc_subnet_name }}" + Description: "{{ ec2_vpc_subnet_description }}" register: vpc_subnet_ipv6_recreate - - name: assert recreation changed nothing (expected changed=false) + - name: Assert recreation changed nothing (expected changed=false) ansible.builtin.assert: that: - vpc_subnet_ipv6_recreate is not changed - vpc_subnet_ipv6_recreate.subnet == vpc_subnet_ipv6_create.subnet # ============================================================ - - name: change subnet assign_instances_ipv6 attribute (expected changed=true) (CHECK MODE) + - name: Change subnet assign_instances_ipv6 attribute (expected changed=true) (CHECK MODE) amazon.aws.ec2_vpc_subnet: cidr: "{{ subnet_cidr }}" vpc_id: "{{ vpc_result.vpc.id }}" @@ -531,12 +531,12 @@ check_mode: true register: vpc_change_attribute - - name: assert assign_instances_ipv6 attribute changed (expected changed=true) + - name: Assert assign_instances_ipv6 attribute changed (expected changed=true) ansible.builtin.assert: that: - vpc_change_attribute is changed - - name: change subnet assign_instances_ipv6 attribute (expected changed=true) + - name: Change subnet assign_instances_ipv6 attribute (expected changed=true) amazon.aws.ec2_vpc_subnet: cidr: "{{ subnet_cidr }}" vpc_id: "{{ vpc_result.vpc.id }}" @@ -546,14 +546,14 @@ purge_tags: false register: vpc_change_attribute - - name: assert assign_instances_ipv6 attribute changed (expected changed=true) + - name: Assert assign_instances_ipv6 attribute changed (expected changed=true) ansible.builtin.assert: that: - vpc_change_attribute is changed - not vpc_change_attribute.subnet.assign_ipv6_address_on_creation # ============================================================ - - name: add second subnet with duplicate ipv6 cidr (expected failure) + - name: Add second subnet with duplicate ipv6 cidr (expected failure) amazon.aws.ec2_vpc_subnet: cidr: "{{ subnet_cidr_b }}" vpc_id: "{{ vpc_result.vpc.id }}" @@ -563,16 +563,16 @@ register: vpc_add_duplicate_ipv6 ignore_errors: true - - name: assert graceful failure (expected failed) + - name: Assert graceful failure (expected failed) ansible.builtin.assert: that: - vpc_add_duplicate_ipv6 is failed - - '"The IPv6 CIDR "+testChar+subnet_ipv6_cidr+testChar+" conflicts with another subnet" in vpc_add_duplicate_ipv6.msg' + - '"The IPv6 CIDR "+test_char+subnet_ipv6_cidr+test_char+" conflicts with another subnet" in vpc_add_duplicate_ipv6.msg' vars: - testChar: "'" + test_char: "'" # ============================================================ - - name: remove subnet ipv6 cidr (expected changed=true) (CHECK MODE) + - name: Remove subnet ipv6 cidr (expected changed=true) (CHECK MODE) amazon.aws.ec2_vpc_subnet: cidr: "{{ subnet_cidr }}" vpc_id: "{{ vpc_result.vpc.id }}" @@ -581,12 +581,12 @@ check_mode: true register: vpc_remove_ipv6_cidr - - name: assert subnet ipv6 cidr removed (expected changed=true) + - name: Assert subnet ipv6 cidr removed (expected changed=true) ansible.builtin.assert: that: - vpc_remove_ipv6_cidr is changed - - name: remove subnet ipv6 cidr (expected changed=true) + - name: Remove subnet ipv6 cidr (expected changed=true) amazon.aws.ec2_vpc_subnet: cidr: "{{ subnet_cidr }}" vpc_id: "{{ vpc_result.vpc.id }}" @@ -594,7 +594,7 @@ purge_tags: false register: vpc_remove_ipv6_cidr - - name: assert subnet ipv6 cidr removed (expected changed=true) + - name: Assert subnet ipv6 cidr removed (expected changed=true) ansible.builtin.assert: that: - vpc_remove_ipv6_cidr is changed @@ -602,7 +602,7 @@ - not vpc_remove_ipv6_cidr.subnet.assign_ipv6_address_on_creation # ============================================================ - - name: test adding a tag that looks like a boolean to the subnet (CHECK MODE) + - name: Test adding a tag that looks like a boolean to the subnet (CHECK MODE) amazon.aws.ec2_vpc_subnet: cidr: "{{ subnet_cidr }}" vpc_id: "{{ vpc_result.vpc.id }}" @@ -613,12 +613,12 @@ check_mode: true register: vpc_subnet_info - - name: assert a tag was added + - name: Assert a tag was added ansible.builtin.assert: that: - vpc_subnet_info is changed - - name: test adding a tag that looks like a boolean to the subnet + - name: Test adding a tag that looks like a boolean to the subnet amazon.aws.ec2_vpc_subnet: cidr: "{{ subnet_cidr }}" vpc_id: "{{ vpc_result.vpc.id }}" @@ -628,14 +628,14 @@ looks_like_boolean: true register: vpc_subnet_info - - name: assert a tag was added + - name: Assert a tag was added ansible.builtin.assert: that: - vpc_subnet_info is changed - vpc_subnet_info.subnet.tags.looks_like_boolean == "True" # ============================================================ - - name: test idempotence adding a tag that looks like a boolean (CHECK MODE) + - name: Test idempotence adding a tag that looks like a boolean (CHECK MODE) amazon.aws.ec2_vpc_subnet: cidr: "{{ subnet_cidr }}" vpc_id: "{{ vpc_result.vpc.id }}" @@ -646,12 +646,12 @@ check_mode: true register: vpc_subnet_info - - name: assert tags haven't changed + - name: Assert tags haven't changed ansible.builtin.assert: that: - vpc_subnet_info is not changed - - name: test idempotence adding a tag that looks like a boolean + - name: Test idempotence adding a tag that looks like a boolean amazon.aws.ec2_vpc_subnet: cidr: "{{ subnet_cidr }}" vpc_id: "{{ vpc_result.vpc.id }}" @@ -661,7 +661,7 @@ looks_like_boolean: true register: vpc_subnet_info - - name: assert tags haven't changed + - name: Assert tags haven't changed ansible.builtin.assert: that: - vpc_subnet_info is not changed @@ -671,13 +671,13 @@ # TEARDOWN STARTS HERE ################################################ - - name: tidy up subnet + - name: Tidy up subnet amazon.aws.ec2_vpc_subnet: cidr: "{{ subnet_cidr }}" vpc_id: "{{ vpc_result.vpc.id }}" state: absent - - name: tidy up VPC + - name: Tidy up VPC amazon.aws.ec2_vpc_net: name: "{{ resource_prefix }}-vpc" state: absent diff --git a/tests/integration/targets/ec2_vpc_vgw/defaults/main.yml b/tests/integration/targets/ec2_vpc_vgw/defaults/main.yml index 76bb479bbdf..6eab419630e 100644 --- a/tests/integration/targets/ec2_vpc_vgw/defaults/main.yml +++ b/tests/integration/targets/ec2_vpc_vgw/defaults/main.yml @@ -1,6 +1,7 @@ -vpc_name: '{{ resource_prefix }}-ec2-vpc-vgw' -vgw_name: '{{ resource_prefix }}-ec2-vpc-vgw' -subnet_name: '{{ resource_prefix }}-ec2-vpc-vgw' +--- +vpc_name: "{{ resource_prefix }}-ec2-vpc-vgw" +vgw_name: "{{ resource_prefix }}-ec2-vpc-vgw" +subnet_name: "{{ resource_prefix }}-ec2-vpc-vgw" vpc_cidr: 10.{{ 256 | random(seed=resource_prefix) }}.0.0/16 subnet_1: 10.{{ 256 | random(seed=resource_prefix) }}.1.0/24 subnet_2: 10.{{ 256 | random(seed=resource_prefix) }}.2.0/24 @@ -8,4 +9,4 @@ subnet_3: 10.{{ 256 | random(seed=resource_prefix) }}.3.0/24 subnet_4: 10.{{ 256 | random(seed=resource_prefix) }}.4.0/24 vpc_ipv6_cidr: 10.{{ 256 | random(seed=resource_prefix) }}.5.0/25 -vpc_ipv6_name: '{{ vpc_name }}-ipv6' +vpc_ipv6_name: "{{ vpc_name }}-ipv6" diff --git a/tests/integration/targets/ec2_vpc_vgw/meta/main.yml b/tests/integration/targets/ec2_vpc_vgw/meta/main.yml index 32cf5dda7ed..23d65c7ef45 100644 --- a/tests/integration/targets/ec2_vpc_vgw/meta/main.yml +++ b/tests/integration/targets/ec2_vpc_vgw/meta/main.yml @@ -1 +1,2 @@ +--- dependencies: [] diff --git a/tests/integration/targets/ec2_vpc_vgw/tasks/main.yml b/tests/integration/targets/ec2_vpc_vgw/tasks/main.yml index e9930d4a431..8447b64135e 100644 --- a/tests/integration/targets/ec2_vpc_vgw/tasks/main.yml +++ b/tests/integration/targets/ec2_vpc_vgw/tasks/main.yml @@ -1,304 +1,298 @@ -- name: ec2_vpc_vgw integration tests +--- +- name: Ec2_vpc_vgw 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 VPC - amazon.aws.ec2_vpc_net: - name: '{{ vpc_name }}-{{ item }}' - state: present - cidr_block: '{{ vpc_cidr }}' - tags: - Description: Created by ansible-test for IGW tests - register: vpc_result - loop: [1, 2] - - - name: Use set fact for vpc ids - ansible.builtin.set_fact: - vpc_id_1: '{{ vpc_result.results.0.vpc.id }}' - vpc_id_2: '{{ vpc_result.results.1.vpc.id }}' + - name: Create a VPC + amazon.aws.ec2_vpc_net: + name: "{{ vpc_name }}-{{ item }}" + state: present + cidr_block: "{{ vpc_cidr }}" + tags: + Description: Created by ansible-test for IGW tests + register: vpc_result + loop: [1, 2] + + - name: Use set fact for vpc ids + ansible.builtin.set_fact: + vpc_id_1: "{{ vpc_result.results.0.vpc.id }}" + vpc_id_2: "{{ vpc_result.results.1.vpc.id }}" # ============================================================ - - name: Create vpn gateway and attach it to vpc - check_mode - amazon.aws.ec2_vpc_vgw: - state: present - vpc_id: '{{ vpc_id_1 }}' - name: '{{ vgw_name }}' - register: vgw_check_mode - check_mode: true - - - name: Assert check_mode result - no vgw creation - ansible.builtin.assert: - that: - - vgw_check_mode.changed - - not vgw_check_mode.failed - - "'ec2:CreateVpnGateway' not in vgw_check_mode.resource_actions" - - "'ec2:AttachVpnGateway' not in vgw_check_mode.resource_actions" - - - name: Create vpn gateway and attach it to vpc - amazon.aws.ec2_vpc_vgw: - state: present - vpc_id: '{{ vpc_id_1 }}' - name: '{{ vgw_name }}' - register: vgw - - - name: Use set fact for vgw ids - ansible.builtin.set_fact: - vgw_id: '{{ vgw.vgw.id }}' - - - name: Assert result - vgw creation - ansible.builtin.assert: - that: - - vgw.changed - - vgw.vgw.vpc_id == vpc_id_1 - - vgw.vgw.tags.Name == vgw_name - - - name: Test idempotence - amazon.aws.ec2_vpc_vgw: - state: present - vpc_id: '{{ vpc_id_1 }}' - name: '{{ vgw_name }}' - register: vgw - - - name: Assert idempotence result - no change - ansible.builtin.assert: - that: - - not vgw.changed - - vgw.vgw.id == vgw_id + - name: Create vpn gateway and attach it to vpc - check_mode + amazon.aws.ec2_vpc_vgw: + state: present + vpc_id: "{{ vpc_id_1 }}" + name: "{{ vgw_name }}" + register: vgw_check_mode + check_mode: true + + - name: Assert check_mode result - no vgw creation + ansible.builtin.assert: + that: + - vgw_check_mode.changed + - not vgw_check_mode.failed + - "'ec2:CreateVpnGateway' not in vgw_check_mode.resource_actions" + - "'ec2:AttachVpnGateway' not in vgw_check_mode.resource_actions" + + - name: Create vpn gateway and attach it to vpc + amazon.aws.ec2_vpc_vgw: + state: present + vpc_id: "{{ vpc_id_1 }}" + name: "{{ vgw_name }}" + register: vgw + + - name: Use set fact for vgw ids + ansible.builtin.set_fact: + vgw_id: "{{ vgw.vgw.id }}" + + - name: Assert result - vgw creation + ansible.builtin.assert: + that: + - vgw.changed + - vgw.vgw.vpc_id == vpc_id_1 + - vgw.vgw.tags.Name == vgw_name + + - name: Test idempotence + amazon.aws.ec2_vpc_vgw: + state: present + vpc_id: "{{ vpc_id_1 }}" + name: "{{ vgw_name }}" + register: vgw + + - name: Assert idempotence result - no change + ansible.builtin.assert: + that: + - not vgw.changed + - vgw.vgw.id == vgw_id # ============================================================ - - name: Attach vpn gateway to the other VPC - check_mode - amazon.aws.ec2_vpc_vgw: - state: present - vpc_id: '{{ vpc_id_2 }}' - name: '{{ vgw_name }}' - register: vgw_check_mode - check_mode: true - - - name: Assert check_mode result - no create/attach/detach - ansible.builtin.assert: - that: - - vgw_check_mode.changed - - not vgw_check_mode.failed - - "'ec2:CreateVpnGateway' not in vgw_check_mode.resource_actions" - - "'ec2:AttachVpnGateway' not in vgw_check_mode.resource_actions" - - "'ec2:DetachVpnGateway' not in vgw_check_mode.resource_actions" - - - name: Attach vpn gateway to the other VPC - amazon.aws.ec2_vpc_vgw: - state: present - vpc_id: '{{ vpc_id_2 }}' - name: '{{ vgw_name }}' - register: vgw - - - name: Assert attach result - ansible.builtin.assert: - that: - - vgw.changed - - vgw.vgw.id == vgw_id - - vgw.vgw.vpc_id == vpc_id_2 - - - name: Attach vpn gateway to the other VPC - idempotency - amazon.aws.ec2_vpc_vgw: - state: present - vpc_id: '{{ vpc_id_2 }}' - name: '{{ vgw_name }}' - register: vgw - - - name: Assert idempotency result - no change - ansible.builtin.assert: - that: - - not vgw.changed - - not vgw.failed - - "'ec2:CreateVpnGateway' not in vgw_check_mode.resource_actions" - - "'ec2:AttachVpnGateway' not in vgw_check_mode.resource_actions" - - "'ec2:DetachVpnGateway' not in vgw_check_mode.resource_actions" + - name: Attach vpn gateway to the other VPC - check_mode + amazon.aws.ec2_vpc_vgw: + state: present + vpc_id: "{{ vpc_id_2 }}" + name: "{{ vgw_name }}" + register: vgw_check_mode + check_mode: true + + - name: Assert check_mode result - no create/attach/detach + ansible.builtin.assert: + that: + - vgw_check_mode.changed + - not vgw_check_mode.failed + - "'ec2:CreateVpnGateway' not in vgw_check_mode.resource_actions" + - "'ec2:AttachVpnGateway' not in vgw_check_mode.resource_actions" + - "'ec2:DetachVpnGateway' not in vgw_check_mode.resource_actions" + + - name: Attach vpn gateway to the other VPC + amazon.aws.ec2_vpc_vgw: + state: present + vpc_id: "{{ vpc_id_2 }}" + name: "{{ vgw_name }}" + register: vgw + + - name: Assert attach result + ansible.builtin.assert: + that: + - vgw.changed + - vgw.vgw.id == vgw_id + - vgw.vgw.vpc_id == vpc_id_2 + + - name: Attach vpn gateway to the other VPC - idempotency + amazon.aws.ec2_vpc_vgw: + state: present + vpc_id: "{{ vpc_id_2 }}" + name: "{{ vgw_name }}" + register: vgw + + - name: Assert idempotency result - no change + ansible.builtin.assert: + that: + - not vgw.changed + - not vgw.failed + - "'ec2:CreateVpnGateway' not in vgw_check_mode.resource_actions" + - "'ec2:AttachVpnGateway' not in vgw_check_mode.resource_actions" + - "'ec2:DetachVpnGateway' not in vgw_check_mode.resource_actions" # ============================================================ - - name: Get VPC VGW facts by ID (CHECK) - amazon.aws.ec2_vpc_vgw_info: - vpn_gateway_ids: ['{{ vgw_id }}'] - register: vgw_info - check_mode: true - - - name: Verify expected facts - vars: - vgw_details: '{{ vgw_info.virtual_gateways[0] }}' - attach_1_description: - state: detached - vpc_id: '{{ vpc_id_1 }}' - attach_2_description: - state: attached - vpc_id: '{{ vpc_id_2 }}' - ansible.builtin.assert: - that: - - vgw_info.virtual_gateways | length == 1 - - '"resource_tags" in vgw_details' - - '"state" in vgw_details' - - '"tags" in vgw_details' - - '"type" in vgw_details' - - '"vpc_attachments" in vgw_details' - - '"vpn_gateway_id" in vgw_details' - - vgw_details.vpn_gateway_id == vgw_id - - vgw_details.type == 'ipsec.1' - - vgw_details.state == 'available' - - '"Name" in vgw_details.resource_tags' - - vgw_details.resource_tags.Name == vgw_name - - ( attach_1_description in vgw_details.vpc_attachments and vgw_details.vpc_attachments - | length == 2 ) or ( vgw_details.vpc_attachments | length == 1 ) - - attach_2_description in vgw_details.vpc_attachments - - - name: Get VPC VGW facts by Tag - amazon.aws.ec2_vpc_vgw_info: - filters: - tag:Name: '{{ vgw_name }}' - register: vgw_info - - - name: Verify expected facts - vars: - vgw_details: '{{ vgw_info.virtual_gateways[0] }}' - attach_1_description: - state: detached - vpc_id: '{{ vpc_id_1 }}' - attach_2_description: - state: attached - vpc_id: '{{ vpc_id_2 }}' - ansible.builtin.assert: - that: - - vgw_info.virtual_gateways | length == 1 - - '"resource_tags" in vgw_details' - - '"state" in vgw_details' - - '"tags" in vgw_details' - - '"type" in vgw_details' - - '"vpc_attachments" in vgw_details' - - '"vpn_gateway_id" in vgw_details' - - vgw_details.vpn_gateway_id == vgw_id - - vgw_details.type == 'ipsec.1' - - vgw_details.state == 'available' - - '"Name" in vgw_details.resource_tags' - - vgw_details.resource_tags.Name == vgw_name - - ( attach_1_description in vgw_details.vpc_attachments and vgw_details.vpc_attachments - | length == 2 ) or ( vgw_details.vpc_attachments | length == 1 ) - - attach_2_description in vgw_details.vpc_attachments + - name: Get VPC VGW facts by ID (CHECK) + amazon.aws.ec2_vpc_vgw_info: + vpn_gateway_ids: ["{{ vgw_id }}"] + register: vgw_info + check_mode: true + + - name: Verify expected facts + vars: + vgw_details: "{{ vgw_info.virtual_gateways[0] }}" + attach_1_description: + state: detached + vpc_id: "{{ vpc_id_1 }}" + attach_2_description: + state: attached + vpc_id: "{{ vpc_id_2 }}" + ansible.builtin.assert: + that: + - vgw_info.virtual_gateways | length == 1 + - '"resource_tags" in vgw_details' + - '"state" in vgw_details' + - '"tags" in vgw_details' + - '"type" in vgw_details' + - '"vpc_attachments" in vgw_details' + - '"vpn_gateway_id" in vgw_details' + - vgw_details.vpn_gateway_id == vgw_id + - vgw_details.type == 'ipsec.1' + - vgw_details.state == 'available' + - '"Name" in vgw_details.resource_tags' + - vgw_details.resource_tags.Name == vgw_name + - ( attach_1_description in vgw_details.vpc_attachments and vgw_details.vpc_attachments | length == 2 ) or ( vgw_details.vpc_attachments | length == 1 ) + - attach_2_description in vgw_details.vpc_attachments + + - name: Get VPC VGW facts by Tag + amazon.aws.ec2_vpc_vgw_info: + filters: + tag:Name: "{{ vgw_name }}" + register: vgw_info + + - name: Verify expected facts + vars: + vgw_details: "{{ vgw_info.virtual_gateways[0] }}" + attach_1_description: + state: detached + vpc_id: "{{ vpc_id_1 }}" + attach_2_description: + state: attached + vpc_id: "{{ vpc_id_2 }}" + ansible.builtin.assert: + that: + - vgw_info.virtual_gateways | length == 1 + - '"resource_tags" in vgw_details' + - '"state" in vgw_details' + - '"tags" in vgw_details' + - '"type" in vgw_details' + - '"vpc_attachments" in vgw_details' + - '"vpn_gateway_id" in vgw_details' + - vgw_details.vpn_gateway_id == vgw_id + - vgw_details.type == 'ipsec.1' + - vgw_details.state == 'available' + - '"Name" in vgw_details.resource_tags' + - vgw_details.resource_tags.Name == vgw_name + - ( attach_1_description in vgw_details.vpc_attachments and vgw_details.vpc_attachments | length == 2 ) or ( vgw_details.vpc_attachments | length == 1 ) + - attach_2_description in vgw_details.vpc_attachments # ============================================================ - - name: Get all VGWs - amazon.aws.ec2_vpc_vgw_info: - register: vgw_info + - name: Get all VGWs + amazon.aws.ec2_vpc_vgw_info: + register: vgw_info - - name: Verify test VGW is in the results - vars: - vgw_id_list: '{{ vgw_info.virtual_gateways | map(attribute="vpn_gateway_id") - | list }}' - ansible.builtin.assert: - that: - - vgw_id in vgw_id_list + - name: Verify test VGW is in the results + vars: + vgw_id_list: '{{ vgw_info.virtual_gateways | map(attribute="vpn_gateway_id") | list }}' + ansible.builtin.assert: + that: + - vgw_id in vgw_id_list # ============================================================ - - name: Detach vpn gateway - check_mode - amazon.aws.ec2_vpc_vgw: - state: present - name: '{{ vgw_name }}' - register: vgw_check_mode - check_mode: true - - - name: Assert check_mode results - no detach action - ansible.builtin.assert: - that: - - vgw_check_mode.changed - - not vgw_check_mode.failed - - "'ec2:DetachVpcGateway' not in vgw_check_mode.resource_actions" - - - name: Detach vpn gateway - amazon.aws.ec2_vpc_vgw: - state: present - name: '{{ vgw_name }}' - register: vgw - - - name: Assert results - ansible.builtin.assert: - that: - - vgw.changed - - not vgw.vgw.vpc_id - - - name: Test idempotence - amazon.aws.ec2_vpc_vgw: - state: present - name: '{{ vgw_name }}' - register: vgw - - - name: Assert idempotency result - no change - ansible.builtin.assert: - that: - - not vgw.changed + - name: Detach vpn gateway - check_mode + amazon.aws.ec2_vpc_vgw: + state: present + name: "{{ vgw_name }}" + register: vgw_check_mode + check_mode: true + + - name: Assert check_mode results - no detach action + ansible.builtin.assert: + that: + - vgw_check_mode.changed + - not vgw_check_mode.failed + - "'ec2:DetachVpcGateway' not in vgw_check_mode.resource_actions" + + - name: Detach vpn gateway + amazon.aws.ec2_vpc_vgw: + state: present + name: "{{ vgw_name }}" + register: vgw + + - name: Assert results + ansible.builtin.assert: + that: + - vgw.changed + - not vgw.vgw.vpc_id + + - name: Test idempotence + amazon.aws.ec2_vpc_vgw: + state: present + name: "{{ vgw_name }}" + register: vgw + + - name: Assert idempotency result - no change + ansible.builtin.assert: + that: + - not vgw.changed # ============================================================ - - include_tasks: tags.yml - - # ============================================================ - - - name: Delete vpn gateway - check_mode - amazon.aws.ec2_vpc_vgw: - state: absent - name: '{{ vgw_name }}' - register: vgw_check_mode - check_mode: true - - - name: Assert check_mode result - no delete action - ansible.builtin.assert: - that: - - vgw_check_mode.changed - - not vgw_check_mode.failed - - "'ec2:DeleteVpnGateway' not in vgw_check_mode.resource_actions" - - - name: Delete vpn gateway - amazon.aws.ec2_vpc_vgw: - state: absent - name: '{{ vgw_name }}' - register: vgw - - - name: Assert result - ansible.builtin.assert: - that: - - vgw.changed - - - name: Test idempotence - amazon.aws.ec2_vpc_vgw: - state: absent - name: '{{ vgw_name }}' - register: vgw - - - name: Assert idempotency result - no change - ansible.builtin.assert: - that: - - not vgw.changed + - ansible.builtin.include_tasks: tags.yml + - name: Delete vpn gateway - check_mode + amazon.aws.ec2_vpc_vgw: + state: absent + name: "{{ vgw_name }}" + register: vgw_check_mode + check_mode: true + + - name: Assert check_mode result - no delete action + ansible.builtin.assert: + that: + - vgw_check_mode.changed + - not vgw_check_mode.failed + - "'ec2:DeleteVpnGateway' not in vgw_check_mode.resource_actions" + + - name: Delete vpn gateway + amazon.aws.ec2_vpc_vgw: + state: absent + name: "{{ vgw_name }}" + register: vgw + + - name: Assert result + ansible.builtin.assert: + that: + - vgw.changed + + - name: Test idempotence + amazon.aws.ec2_vpc_vgw: + state: absent + name: "{{ vgw_name }}" + register: vgw + + - name: Assert idempotency result - no change + ansible.builtin.assert: + that: + - not vgw.changed always: - - - ansible.builtin.debug: msg="Removing test dependencies" - - - name: Delete vpn gateway - amazon.aws.ec2_vpc_vgw: - state: absent - vpn_gateway_id: '{{ vgw.vgw.id | default(vgw_id) }}' - ignore_errors: true - - - name: Delete vpc - amazon.aws.ec2_vpc_net: - name: '{{ vpc_name }}-{{ item }}' - state: absent - cidr_block: '{{ vpc_cidr }}' - loop: [1, 2] - register: result - retries: 10 - delay: 5 - until: result is not failed - ignore_errors: true + - ansible.builtin.debug: + + msg: "Removing test dependencies" + - name: Delete vpn gateway + amazon.aws.ec2_vpc_vgw: + state: absent + vpn_gateway_id: "{{ vgw.vgw.id | default(vgw_id) }}" + ignore_errors: true + + - name: Delete vpc + amazon.aws.ec2_vpc_net: + name: "{{ vpc_name }}-{{ item }}" + state: absent + cidr_block: "{{ vpc_cidr }}" + loop: [1, 2] + register: result + retries: 10 + delay: 5 + until: result is not failed + ignore_errors: true diff --git a/tests/integration/targets/ec2_vpc_vgw/tasks/tags.yml b/tests/integration/targets/ec2_vpc_vgw/tasks/tags.yml index bf6a0784b1d..c10555e1893 100644 --- a/tests/integration/targets/ec2_vpc_vgw/tasks/tags.yml +++ b/tests/integration/targets/ec2_vpc_vgw/tasks/tags.yml @@ -1,3 +1,4 @@ +--- - vars: first_tags: Key with Spaces: Value with spaces @@ -25,319 +26,311 @@ newPascalCaseKey: pascalCaseValue new_snake_case_key: snake_case_value name_tags: - Name: '{{ vgw_name }}' + Name: "{{ vgw_name }}" module_defaults: amazon.aws.ec2_vpc_vgw: - name: '{{ vgw_name }}' + name: "{{ vgw_name }}" amazon.aws.ec2_vpc_vgw_info: - vpn_gateway_ids: ['{{ vgw_id }}'] + vpn_gateway_ids: ["{{ vgw_id }}"] block: - - # ============================================================ - - - name: Add tags - check_mode - amazon.aws.ec2_vpc_vgw: - tags: '{{ first_tags }}' - state: present - register: tag_vgw - check_mode: true - - - name: Assert would change - ansible.builtin.assert: - that: - - tag_vgw is changed - - tag_vgw is not failed - - "'ec2:CreateTags' not in tag_vgw.resource_actions" - - - name: Add tags - amazon.aws.ec2_vpc_vgw: - tags: '{{ first_tags }}' - state: present - register: tag_vgw - - - name: Get VPC VGW facts - amazon.aws.ec2_vpc_vgw_info: {} - register: tag_vgw_info - - - name: Verify the tags were added - ansible.builtin.assert: - that: - - tag_vgw is changed - - tag_vgw.vgw.id == vgw_id - - tag_vgw_info.virtual_gateways[0].vpn_gateway_id == vgw_id - - tag_vgw_info.virtual_gateways[0].resource_tags == ( first_tags | combine(name_tags) - ) - - - name: Add tags - IDEMPOTENCY - check_mode - amazon.aws.ec2_vpc_vgw: - tags: '{{ first_tags }}' - state: present - register: tag_vgw - check_mode: true - - - name: Assert would not change - ansible.builtin.assert: - that: - - tag_vgw is not changed - - tag_vgw.vgw.id == vgw_id - - - name: Add tags - IDEMPOTENCY - amazon.aws.ec2_vpc_vgw: - tags: '{{ first_tags }}' - state: present - register: tag_vgw - - name: Get VPC VGW facts - ec2_vpc_vgw_info: {} - register: tag_vgw_info - - - name: Verify no change - ansible.builtin.assert: - that: - - tag_vgw is not changed - - tag_vgw.vgw.id == vgw_id - - tag_vgw_info.virtual_gateways[0].vpn_gateway_id == vgw_id - - tag_vgw_info.virtual_gateways[0].resource_tags == ( first_tags | combine(name_tags) - ) - # ============================================================ - - name: Get VPC VGW facts by filter - amazon.aws.ec2_vpc_vgw_info: - filters: - tag:Name: '{{ vgw_name }}' - vpn_gateway_ids: '{{ omit }}' - register: tag_vgw_info - - - name: Assert the facts are the same as before - ansible.builtin.assert: - that: - - tag_vgw_info.virtual_gateways | length == 1 - - tag_vgw.vgw.id == vgw_id - - tag_vgw_info.virtual_gateways[0].vpn_gateway_id == vgw_id + - name: Add tags - check_mode + amazon.aws.ec2_vpc_vgw: + tags: "{{ first_tags }}" + state: present + register: tag_vgw + check_mode: true + + - name: Assert would change + ansible.builtin.assert: + that: + - tag_vgw is changed + - tag_vgw is not failed + - "'ec2:CreateTags' not in tag_vgw.resource_actions" + + - name: Add tags + amazon.aws.ec2_vpc_vgw: + tags: "{{ first_tags }}" + state: present + register: tag_vgw + + - name: Get VPC VGW facts + amazon.aws.ec2_vpc_vgw_info: {} + register: tag_vgw_info + + - name: Verify the tags were added + ansible.builtin.assert: + that: + - tag_vgw is changed + - tag_vgw.vgw.id == vgw_id + - tag_vgw_info.virtual_gateways[0].vpn_gateway_id == vgw_id + - tag_vgw_info.virtual_gateways[0].resource_tags == ( first_tags | combine(name_tags) ) + + - name: Add tags - IDEMPOTENCY - check_mode + amazon.aws.ec2_vpc_vgw: + tags: "{{ first_tags }}" + state: present + register: tag_vgw + check_mode: true + + - name: Assert would not change + ansible.builtin.assert: + that: + - tag_vgw is not changed + - tag_vgw.vgw.id == vgw_id + + - name: Add tags - IDEMPOTENCY + amazon.aws.ec2_vpc_vgw: + tags: "{{ first_tags }}" + state: present + register: tag_vgw + - name: Get VPC VGW facts + amazon.aws.ec2_vpc_vgw_info: {} + register: tag_vgw_info + + - name: Verify no change + ansible.builtin.assert: + that: + - tag_vgw is not changed + - tag_vgw.vgw.id == vgw_id + - tag_vgw_info.virtual_gateways[0].vpn_gateway_id == vgw_id + - tag_vgw_info.virtual_gateways[0].resource_tags == ( first_tags | combine(name_tags) ) # ============================================================ - - name: Modify tags with purge - check_mode - amazon.aws.ec2_vpc_vgw: - tags: '{{ second_tags }}' - state: present - register: tag_vgw - check_mode: true - - - name: Assert would change - ansible.builtin.assert: - that: - - tag_vgw is changed - - tag_vgw.vgw.id == vgw_id - - - name: Modify tags with purge - amazon.aws.ec2_vpc_vgw: - tags: '{{ second_tags }}' - state: present - register: tag_vgw + - name: Get VPC VGW facts by filter + amazon.aws.ec2_vpc_vgw_info: + filters: + tag:Name: "{{ vgw_name }}" + vpn_gateway_ids: "{{ omit }}" + register: tag_vgw_info - - name: Get VPC VGW facts - amazon.aws.ec2_vpc_vgw_info: - register: tag_vgw_info - - - name: Verify the tags were added - ansible.builtin.assert: - that: - - tag_vgw is changed - - tag_vgw.vgw.id == vgw_id - - tag_vgw_info.virtual_gateways[0].vpn_gateway_id == vgw_id - - tag_vgw_info.virtual_gateways[0].resource_tags == ( second_tags | combine(name_tags) - ) - - - name: Modify tags with purge - IDEMPOTENCY - check_mode - amazon.aws.ec2_vpc_vgw: - tags: '{{ second_tags }}' - state: present - register: tag_vgw - check_mode: true - - - name: Assert would not change - ansible.builtin.assert: - that: - - tag_vgw is not changed - - tag_vgw.vgw.id == vgw_id - - - name: Modify tags with purge - IDEMPOTENCY - amazon.aws.ec2_vpc_vgw: - tags: '{{ second_tags }}' - state: present - register: tag_vgw - - name: Get VPC VGW facts - ec2_vpc_vgw_info: - register: tag_vgw_info - - - name: Verify no change - ansible.builtin.assert: - that: - - tag_vgw is not changed - - tag_vgw.vgw.id == vgw_id - - tag_vgw_info.virtual_gateways[0].vpn_gateway_id == vgw_id - - tag_vgw_info.virtual_gateways[0].resource_tags == ( second_tags | combine(name_tags) - ) + - name: Assert the facts are the same as before + ansible.builtin.assert: + that: + - tag_vgw_info.virtual_gateways | length == 1 + - tag_vgw.vgw.id == vgw_id + - tag_vgw_info.virtual_gateways[0].vpn_gateway_id == vgw_id # ============================================================ - - name: Modify tags without purge - check_mode - amazon.aws.ec2_vpc_vgw: - tags: '{{ third_tags }}' - state: present - purge_tags: false - register: tag_vgw - check_mode: true - - - name: Assert would change - ansible.builtin.assert: - that: - - tag_vgw is changed - - tag_vgw.vgw.id == vgw_id - - - name: Modify tags without purge - amazon.aws.ec2_vpc_vgw: - tags: '{{ third_tags }}' - state: present - purge_tags: false - register: tag_vgw - - - name: Get VPC VGW facts - amazon.aws.ec2_vpc_vgw_info: - register: tag_vgw_info - - - name: Verify the tags were added - ansible.builtin.assert: - that: - - tag_vgw is changed - - tag_vgw.vgw.id == vgw_id - - tag_vgw_info.virtual_gateways[0].vpn_gateway_id == vgw_id - - tag_vgw_info.virtual_gateways[0].resource_tags == ( final_tags | combine(name_tags) - ) - - - name: Modify tags without purge - IDEMPOTENCY - check_mode - amazon.aws.ec2_vpc_vgw: - tags: '{{ third_tags }}' - state: present - purge_tags: false - register: tag_vgw - check_mode: true - - - name: Assert would not change - ansible.builtin.assert: - that: - - tag_vgw is not changed - - tag_vgw.vgw.id == vgw_id - - - name: Modify tags without purge - IDEMPOTENCY - amazon.aws.ec2_vpc_vgw: - tags: '{{ third_tags }}' - state: present - purge_tags: false - register: tag_vgw - - name: Get VPC VGW facts - ec2_vpc_vgw_info: - register: tag_vgw_info - - - name: Verify no change - ansible.builtin.assert: - that: - - tag_vgw is not changed - - tag_vgw.vgw.id == vgw_id - - tag_vgw_info.virtual_gateways[0].vpn_gateway_id == vgw_id - - tag_vgw_info.virtual_gateways[0].resource_tags == ( final_tags | combine(name_tags) - ) + - name: Modify tags with purge - check_mode + amazon.aws.ec2_vpc_vgw: + tags: "{{ second_tags }}" + state: present + register: tag_vgw + check_mode: true + + - name: Assert would change + ansible.builtin.assert: + that: + - tag_vgw is changed + - tag_vgw.vgw.id == vgw_id + + - name: Modify tags with purge + amazon.aws.ec2_vpc_vgw: + tags: "{{ second_tags }}" + state: present + register: tag_vgw + + - name: Get VPC VGW facts + amazon.aws.ec2_vpc_vgw_info: + register: tag_vgw_info + + - name: Verify the tags were added + ansible.builtin.assert: + that: + - tag_vgw is changed + - tag_vgw.vgw.id == vgw_id + - tag_vgw_info.virtual_gateways[0].vpn_gateway_id == vgw_id + - tag_vgw_info.virtual_gateways[0].resource_tags == ( second_tags | combine(name_tags) ) + + - name: Modify tags with purge - IDEMPOTENCY - check_mode + amazon.aws.ec2_vpc_vgw: + tags: "{{ second_tags }}" + state: present + register: tag_vgw + check_mode: true + + - name: Assert would not change + ansible.builtin.assert: + that: + - tag_vgw is not changed + - tag_vgw.vgw.id == vgw_id + + - name: Modify tags with purge - IDEMPOTENCY + amazon.aws.ec2_vpc_vgw: + tags: "{{ second_tags }}" + state: present + register: tag_vgw + - name: Get VPC VGW facts + amazon.aws.ec2_vpc_vgw_info: + register: tag_vgw_info + + - name: Verify no change + ansible.builtin.assert: + that: + - tag_vgw is not changed + - tag_vgw.vgw.id == vgw_id + - tag_vgw_info.virtual_gateways[0].vpn_gateway_id == vgw_id + - tag_vgw_info.virtual_gateways[0].resource_tags == ( second_tags | combine(name_tags) ) # ============================================================ - - name: No change to tags without setting tags - check_mode - amazon.aws.ec2_vpc_vgw: - state: present - register: tag_vgw - check_mode: true + - name: Modify tags without purge - check_mode + amazon.aws.ec2_vpc_vgw: + tags: "{{ third_tags }}" + state: present + purge_tags: false + register: tag_vgw + check_mode: true + + - name: Assert would change + ansible.builtin.assert: + that: + - tag_vgw is changed + - tag_vgw.vgw.id == vgw_id + + - name: Modify tags without purge + amazon.aws.ec2_vpc_vgw: + tags: "{{ third_tags }}" + state: present + purge_tags: false + register: tag_vgw + + - name: Get VPC VGW facts + amazon.aws.ec2_vpc_vgw_info: + register: tag_vgw_info + + - name: Verify the tags were added + ansible.builtin.assert: + that: + - tag_vgw is changed + - tag_vgw.vgw.id == vgw_id + - tag_vgw_info.virtual_gateways[0].vpn_gateway_id == vgw_id + - tag_vgw_info.virtual_gateways[0].resource_tags == ( final_tags | combine(name_tags) ) + + - name: Modify tags without purge - IDEMPOTENCY - check_mode + amazon.aws.ec2_vpc_vgw: + tags: "{{ third_tags }}" + state: present + purge_tags: false + register: tag_vgw + check_mode: true + + - name: Assert would not change + ansible.builtin.assert: + that: + - tag_vgw is not changed + - tag_vgw.vgw.id == vgw_id + + - name: Modify tags without purge - IDEMPOTENCY + amazon.aws.ec2_vpc_vgw: + tags: "{{ third_tags }}" + state: present + purge_tags: false + register: tag_vgw + - name: Get VPC VGW facts + amazon.aws.ec2_vpc_vgw_info: + register: tag_vgw_info + + - name: Verify no change + ansible.builtin.assert: + that: + - tag_vgw is not changed + - tag_vgw.vgw.id == vgw_id + - tag_vgw_info.virtual_gateways[0].vpn_gateway_id == vgw_id + - tag_vgw_info.virtual_gateways[0].resource_tags == ( final_tags | combine(name_tags) ) - - name: Assert would change - ansible.builtin.assert: - that: - - tag_vgw is not changed - - tag_vgw.vgw.id == vgw_id + # ============================================================ - - name: No change to tags without setting tags - amazon.aws.ec2_vpc_vgw: - state: present - register: tag_vgw - - name: Get VPC VGW facts - ec2_vpc_vgw_info: - register: tag_vgw_info - - - name: Verify the tags were added - ansible.builtin.assert: - that: - - tag_vgw is not changed - - tag_vgw.vgw.id == vgw_id - - tag_vgw_info.virtual_gateways[0].vpn_gateway_id == vgw_id - - tag_vgw_info.virtual_gateways[0].resource_tags == ( final_tags | combine(name_tags) - ) + - name: No change to tags without setting tags - check_mode + amazon.aws.ec2_vpc_vgw: + state: present + register: tag_vgw + check_mode: true + + - name: Assert would change + ansible.builtin.assert: + that: + - tag_vgw is not changed + - tag_vgw.vgw.id == vgw_id + + - name: No change to tags without setting tags + amazon.aws.ec2_vpc_vgw: + state: present + register: tag_vgw + - name: Get VPC VGW facts + amazon.aws.ec2_vpc_vgw_info: + register: tag_vgw_info + + - name: Verify the tags were added + ansible.builtin.assert: + that: + - tag_vgw is not changed + - tag_vgw.vgw.id == vgw_id + - tag_vgw_info.virtual_gateways[0].vpn_gateway_id == vgw_id + - tag_vgw_info.virtual_gateways[0].resource_tags == ( final_tags | combine(name_tags) ) # ============================================================ - - name: Remove non name tags - check_mode - amazon.aws.ec2_vpc_vgw: - tags: {} - state: present - register: tag_vgw - check_mode: true - - - name: Assert would change - ansible.builtin.assert: - that: - - tag_vgw is changed - - tag_vgw.vgw.id == vgw_id - - - name: Remove non name tags - amazon.aws.ec2_vpc_vgw: - tags: {} - state: present - register: tag_vgw - - name: Get VPC VGW facts - ec2_vpc_vgw_info: - register: tag_vgw_info - - - name: Verify the tags were added - ansible.builtin.assert: - that: - - tag_vgw is changed - - tag_vgw.vgw.id == vgw_id - - tag_vgw_info.virtual_gateways[0].vpn_gateway_id == vgw_id - - tag_vgw_info.virtual_gateways[0].resource_tags == name_tags - - - name: Remove non name tags - IDEMPOTENCY - check_mode - amazon.aws.ec2_vpc_vgw: - tags: {} - state: present - register: tag_vgw - check_mode: true - - - name: Assert would not change - ansible.builtin.assert: - that: - - tag_vgw is not changed - - tag_vgw.vgw.id == vgw_id - - - name: Remove non name tags - IDEMPOTENCY - amazon.aws.ec2_vpc_vgw: - tags: {} - state: present - register: tag_vgw - - name: Get VPC VGW facts - ec2_vpc_vgw_info: - register: tag_vgw_info - - - name: Verify no change - ansible.builtin.assert: - that: - - tag_vgw is not changed - - tag_vgw.vgw.id == vgw_id - - tag_vgw_info.virtual_gateways[0].vpn_gateway_id == vgw_id - - tag_vgw_info.virtual_gateways[0].resource_tags == name_tags + - name: Remove non name tags - check_mode + amazon.aws.ec2_vpc_vgw: + tags: {} + state: present + register: tag_vgw + check_mode: true + + - name: Assert would change + ansible.builtin.assert: + that: + - tag_vgw is changed + - tag_vgw.vgw.id == vgw_id + + - name: Remove non name tags + amazon.aws.ec2_vpc_vgw: + tags: {} + state: present + register: tag_vgw + - name: Get VPC VGW facts + amazon.aws.ec2_vpc_vgw_info: + register: tag_vgw_info + + - name: Verify the tags were added + ansible.builtin.assert: + that: + - tag_vgw is changed + - tag_vgw.vgw.id == vgw_id + - tag_vgw_info.virtual_gateways[0].vpn_gateway_id == vgw_id + - tag_vgw_info.virtual_gateways[0].resource_tags == name_tags + + - name: Remove non name tags - IDEMPOTENCY - check_mode + amazon.aws.ec2_vpc_vgw: + tags: {} + state: present + register: tag_vgw + check_mode: true + + - name: Assert would not change + ansible.builtin.assert: + that: + - tag_vgw is not changed + - tag_vgw.vgw.id == vgw_id + + - name: Remove non name tags - IDEMPOTENCY + amazon.aws.ec2_vpc_vgw: + tags: {} + state: present + register: tag_vgw + - name: Get VPC VGW facts + amazon.aws.ec2_vpc_vgw_info: + register: tag_vgw_info + + - name: Verify no change + ansible.builtin.assert: + that: + - tag_vgw is not changed + - tag_vgw.vgw.id == vgw_id + - tag_vgw_info.virtual_gateways[0].vpn_gateway_id == vgw_id + - tag_vgw_info.virtual_gateways[0].resource_tags == name_tags diff --git a/tests/integration/targets/ec2_vpc_vpn/meta/main.yml b/tests/integration/targets/ec2_vpc_vpn/meta/main.yml index 32cf5dda7ed..23d65c7ef45 100644 --- a/tests/integration/targets/ec2_vpc_vpn/meta/main.yml +++ b/tests/integration/targets/ec2_vpc_vpn/meta/main.yml @@ -1 +1,2 @@ +--- dependencies: [] diff --git a/tests/integration/targets/ec2_vpc_vpn/tasks/main.yml b/tests/integration/targets/ec2_vpc_vpn/tasks/main.yml index 3543acc9c26..571e274dd34 100644 --- a/tests/integration/targets/ec2_vpc_vpn/tasks/main.yml +++ b/tests/integration/targets/ec2_vpc_vpn/tasks/main.yml @@ -1,232 +1,226 @@ +--- - name: EC2 VPN Connection 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 VPC - amazon.aws.ec2_vpc_net: - name: '{{ resource_prefix }}-vpc' - state: present - cidr_block: 10.0.0.0/26 - tags: - Name: '{{ resource_prefix }}-vpc' - Description: Created by ansible-test - register: vpc_result - - - name: Create an EC2 VPC gateway and attach it to VPC - amazon.aws.ec2_vpc_vgw: - state: present - vpc_id: '{{ vpc_result.vpc.id }}' - name: '{{ resource_prefix }}-vgw' - register: vgw - - - name: Create customer gateway - community.aws.ec2_customer_gateway: - bgp_asn: 12345 - ip_address: 1.2.3.4 - name: testcgw - register: cgw - - - name: Create transit gateway - amazon.aws.ec2_transit_gateway: - description: Transit Gateway for vpn attachment - wait: true - register: tgw - - - name: Create an EC2 VPN Connection, with customer gateway, vpn_gateway_id and - transit_gateway - amazon.aws.ec2_vpc_vpn: - customer_gateway_id: '{{ cgw.gateway.customer_gateway.customer_gateway_id }}' - vpn_gateway_id: '{{ vgw.vgw.id }}' - transit_gateway_id: '{{ tgw.transit_gateway.transit_gateway_id }}' - state: present - register: result - ignore_errors: true - - - name: Assert creation of vpn failed - ansible.builtin.assert: - that: - - result is failed - - result.msg == "parameters are mutually exclusive: vpn_gateway_id|transit_gateway_id" - - - name: Create EC2 VPN Connection, with customer gateway and transit_gateway - amazon.aws.ec2_vpc_vpn: - customer_gateway_id: '{{ cgw.gateway.customer_gateway.customer_gateway_id }}' - transit_gateway_id: '{{ tgw.transit_gateway.transit_gateway_id }}' - state: present - wait_timeout: 1000 - register: tgw_vpn - - - name: Store ID of VPN - ansible.builtin.set_fact: - vpn_id: '{{ tgw_vpn.vpn_connection_id }}' - # ============================================================ - - name: Test success with no parameters - amazon.aws.ec2_vpc_vpn_info: - register: result - - - name: Assert success with no parameters - ansible.builtin.assert: - that: - - result.changed == false - - result.vpn_connections != [] + - name: Create a VPC + amazon.aws.ec2_vpc_net: + name: "{{ resource_prefix }}-vpc" + state: present + cidr_block: 10.0.0.0/26 + tags: + Name: "{{ resource_prefix }}-vpc" + Description: Created by ansible-test + register: vpc_result + + - name: Create an EC2 VPC gateway and attach it to VPC + amazon.aws.ec2_vpc_vgw: + state: present + vpc_id: "{{ vpc_result.vpc.id }}" + name: "{{ resource_prefix }}-vgw" + register: vgw + + - name: Create customer gateway + community.aws.ec2_customer_gateway: + bgp_asn: 12345 + ip_address: 1.2.3.4 + name: testcgw + register: cgw + + - name: Create transit gateway + amazon.aws.ec2_transit_gateway: + description: Transit Gateway for vpn attachment + wait: true + register: tgw + + - name: Create an EC2 VPN Connection, with customer gateway, vpn_gateway_id and transit_gateway + amazon.aws.ec2_vpc_vpn: + customer_gateway_id: "{{ cgw.gateway.customer_gateway.customer_gateway_id }}" + vpn_gateway_id: "{{ vgw.vgw.id }}" + transit_gateway_id: "{{ tgw.transit_gateway.transit_gateway_id }}" + state: present + register: result + ignore_errors: true + + - name: Assert creation of vpn failed + ansible.builtin.assert: + that: + - result is failed + - result.msg == "parameters are mutually exclusive: vpn_gateway_id|transit_gateway_id" + + - name: Create EC2 VPN Connection, with customer gateway and transit_gateway + amazon.aws.ec2_vpc_vpn: + customer_gateway_id: "{{ cgw.gateway.customer_gateway.customer_gateway_id }}" + transit_gateway_id: "{{ tgw.transit_gateway.transit_gateway_id }}" + state: present + wait_timeout: 1000 + register: tgw_vpn + + - name: Store ID of VPN + ansible.builtin.set_fact: + vpn_id: "{{ tgw_vpn.vpn_connection_id }}" + + # ============================================================ + - name: Test success with no parameters + amazon.aws.ec2_vpc_vpn_info: + register: result + + - name: Assert success with no parameters + ansible.builtin.assert: + that: + - result.changed == false + - result.vpn_connections != [] # ============================================================ - - name: Delete EC2 VPN Connection created with transit gateway - amazon.aws.ec2_vpc_vpn: - state: absent - vpn_connection_id: '{{ vpn_id }}' - register: result - retries: 10 - delay: 3 - until: result is not failed - ignore_errors: true + - name: Delete EC2 VPN Connection created with transit gateway + amazon.aws.ec2_vpc_vpn: + state: absent + vpn_connection_id: "{{ vpn_id }}" + register: result + retries: 10 + delay: 3 + until: result is not failed + ignore_errors: true # ============================================================ - - name: Create EC2 VPN Connection, with customer gateway and vpn gateway - amazon.aws.ec2_vpc_vpn: - customer_gateway_id: '{{ cgw.gateway.customer_gateway.customer_gateway_id }}' - vpn_gateway_id: '{{ vgw.vgw.id }}' - state: present - register: vpn + - name: Create EC2 VPN Connection, with customer gateway and vpn gateway + amazon.aws.ec2_vpc_vpn: + customer_gateway_id: "{{ cgw.gateway.customer_gateway.customer_gateway_id }}" + vpn_gateway_id: "{{ vgw.vgw.id }}" + state: present + register: vpn - - name: Store ID of the EC2 VPN Connection - ansible.builtin.set_fact: - vpn_id: '{{ vpn.vpn_connection_id }}' + - name: Store ID of the EC2 VPN Connection + ansible.builtin.set_fact: + vpn_id: "{{ vpn.vpn_connection_id }}" # ============================================================ - - name: Test success with no parameters - amazon.aws.ec2_vpc_vpn_info: - register: result - - - name: Assert success with no parameters - ansible.builtin.assert: - that: - - result.changed == false - - result.vpn_connections != [] - - - name: Test success with customer gateway id as a filter - amazon.aws.ec2_vpc_vpn_info: - filters: - customer-gateway-id: '{{ cgw.gateway.customer_gateway.customer_gateway_id - }}' - vpn-connection-id: '{{ vpn.vpn_connection_id }}' - register: result - - - name: Assert success with customer gateway id as filter - ansible.builtin.assert: - that: - - result.changed == false - - result.vpn_connections != [] + - name: Test success with no parameters + amazon.aws.ec2_vpc_vpn_info: + register: result + + - name: Assert success with no parameters + ansible.builtin.assert: + that: + - result.changed == false + - result.vpn_connections != [] + + - name: Test success with customer gateway id as a filter + amazon.aws.ec2_vpc_vpn_info: + filters: + customer-gateway-id: "{{ cgw.gateway.customer_gateway.customer_gateway_id }}" + vpn-connection-id: "{{ vpn.vpn_connection_id }}" + register: result + + - name: Assert success with customer gateway id as filter + ansible.builtin.assert: + that: + - result.changed == false + - result.vpn_connections != [] # ============================================================ - - include_tasks: tags.yml - - # ============================================================ - - - name: Delete EC2 VPN Connection (check_mode) - amazon.aws.ec2_vpc_vpn: - state: absent - vpn_connection_id: '{{ vpn_id }}' - register: result - check_mode: true - - - name: Assert EC2 VPN Connection is deleted (check_mode) - ansible.builtin.assert: - that: - - result is changed - - - name: Delete EC2 VPN Connection - amazon.aws.ec2_vpc_vpn: - state: absent - vpn_connection_id: '{{ vpn_id }}' - register: result - - - name: Assert EC2 VPN Connection is deleted - ansible.builtin.assert: - that: - - result is changed - - - name: Delete EC2 VPN Connection - idempotency (check) - amazon.aws.ec2_vpc_vpn: - state: absent - vpn_connection_id: '{{ vpn_id }}' - register: result - check_mode: true - - - name: Assert result has not changed (idempotency check_mode) - ansible.builtin.assert: - that: - - result is not changed - - - name: Delete EC2 VPN Connection - idempotency - amazon.aws.ec2_vpc_vpn: - state: absent - vpn_connection_id: '{{ vpn_id }}' - register: result - - - name: Assert result has not changed (idempotency) - ansible.builtin.assert: - that: - - result is not changed + - ansible.builtin.include_tasks: tags.yml + - name: Delete EC2 VPN Connection (check_mode) + amazon.aws.ec2_vpc_vpn: + state: absent + vpn_connection_id: "{{ vpn_id }}" + register: result + check_mode: true + + - name: Assert EC2 VPN Connection is deleted (check_mode) + ansible.builtin.assert: + that: + - result is changed + + - name: Delete EC2 VPN Connection + amazon.aws.ec2_vpc_vpn: + state: absent + vpn_connection_id: "{{ vpn_id }}" + register: result + + - name: Assert EC2 VPN Connection is deleted + ansible.builtin.assert: + that: + - result is changed + + - name: Delete EC2 VPN Connection - idempotency (check) + amazon.aws.ec2_vpc_vpn: + state: absent + vpn_connection_id: "{{ vpn_id }}" + register: result + check_mode: true + + - name: Assert result has not changed (idempotency check_mode) + ansible.builtin.assert: + that: + - result is not changed + + - name: Delete EC2 VPN Connection - idempotency + amazon.aws.ec2_vpc_vpn: + state: absent + vpn_connection_id: "{{ vpn_id }}" + register: result + + - name: Assert result has not changed (idempotency) + ansible.builtin.assert: + that: + - result is not changed # ============================================================ always: - - - name: Delete EC2 VPN Connection - amazon.aws.ec2_vpc_vpn: - state: absent - vpn_connection_id: '{{ vpn.vpn_connection_id }}' - register: result - retries: 10 - delay: 3 - until: result is not failed - ignore_errors: true - - - name: Delete customer gateway - community.aws.ec2_customer_gateway: - state: absent - ip_address: 1.2.3.4 - name: testcgw - bgp_asn: 12345 - register: result - retries: 10 - delay: 3 - until: result is not failed - ignore_errors: true - - - name: Delete VPN gateway - amazon.aws.ec2_vpc_vgw: - state: absent - vpn_gateway_id: '{{ vgw.vgw.id }}' - register: result - retries: 10 - delay: 3 - until: result is not failed - ignore_errors: true - - - name: Delete VPC - amazon.aws.ec2_vpc_net: - name: '{{ resource_prefix }}-vpc' - state: absent - cidr_block: 10.0.0.0/26 - register: result - retries: 10 - delay: 3 - until: result is not failed - ignore_errors: true - - - name: Delete transit gateway - amazon.aws.ec2_transit_gateway: - transit_gateway_id: '{{ tgw.transit_gateway.transit_gateway_id }}' - state: absent - ignore_errors: true + - name: Delete EC2 VPN Connection + amazon.aws.ec2_vpc_vpn: + state: absent + vpn_connection_id: "{{ vpn.vpn_connection_id }}" + register: result + retries: 10 + delay: 3 + until: result is not failed + ignore_errors: true + + - name: Delete customer gateway + community.aws.ec2_customer_gateway: + state: absent + ip_address: 1.2.3.4 + name: testcgw + bgp_asn: 12345 + register: result + retries: 10 + delay: 3 + until: result is not failed + ignore_errors: true + + - name: Delete VPN gateway + amazon.aws.ec2_vpc_vgw: + state: absent + vpn_gateway_id: "{{ vgw.vgw.id }}" + register: result + retries: 10 + delay: 3 + until: result is not failed + ignore_errors: true + + - name: Delete VPC + amazon.aws.ec2_vpc_net: + name: "{{ resource_prefix }}-vpc" + state: absent + cidr_block: 10.0.0.0/26 + register: result + retries: 10 + delay: 3 + until: result is not failed + ignore_errors: true + + - name: Delete transit gateway + amazon.aws.ec2_transit_gateway: + transit_gateway_id: "{{ tgw.transit_gateway.transit_gateway_id }}" + state: absent + ignore_errors: true diff --git a/tests/integration/targets/ec2_vpc_vpn/tasks/tags.yml b/tests/integration/targets/ec2_vpc_vpn/tasks/tags.yml index 00f6c9a6dff..f374e79faf4 100644 --- a/tests/integration/targets/ec2_vpc_vpn/tasks/tags.yml +++ b/tests/integration/targets/ec2_vpc_vpn/tasks/tags.yml @@ -1,3 +1,4 @@ +--- - vars: first_tags: Key with Spaces: Value with spaces @@ -26,323 +27,322 @@ new_snake_case_key: snake_case_value module_defaults: ec2_vpc_vpn: - vpn_connection_id: '{{ vpn_id }}' + vpn_connection_id: "{{ vpn_id }}" ec2_vpc_vpn_info: filters: - vpn-connection-id: '{{ vpn_id }}' + vpn-connection-id: "{{ vpn_id }}" block: - # ============================================================ - - name: Add tags (check_mode) - amazon.aws.ec2_vpc_vpn: - tags: '{{ first_tags }}' - state: present - register: tag_vpn - check_mode: true - - - name: Assert would change - ansible.builtin.assert: - that: - - tag_vpn is changed - - tag_vpn.vpn_connection_id == vpn_id - - - name: Add tags - amazon.aws.ec2_vpc_vpn: - tags: '{{ first_tags }}' - state: present - register: tag_vpn - - - name: Get EC2 VPC VPN facts - amazon.aws.ec2_vpc_vpn_info: - filters: - vpn-connection-id: '{{ vpn.vpn_connection_id }}' - register: tag_vpn_info - - - name: Verify the tags were added - ansible.builtin.assert: - that: - - tag_vpn is changed - - tag_vpn.vpn_connection_id == vpn_id - - tag_vpn_info.vpn_connections[0].vpn_connection_id == vpn_id - - tag_vpn_info.vpn_connections[0].tags == first_tags - - - name: Add tags - IDEMPOTENCY (check_mode) - amazon.aws.ec2_vpc_vpn: - tags: '{{ first_tags }}' - state: present - register: tag_vpn - check_mode: true - - - name: Assert would not change - ansible.builtin.assert: - that: - - tag_vpn is not changed - - tag_vpn.vpn_connection_id == vpn_id - - - name: Add tags - IDEMPOTENCY - amazon.aws.ec2_vpc_vpn: - tags: '{{ first_tags }}' - state: present - register: tag_vpn - - - name: Get EC2 VPC VPN facts - amazon.aws.ec2_vpc_vpn_info: - filters: - vpn-connection-id: '{{ vpn.vpn_connection_id }}' - register: tag_vpn_info - - - name: Verify no change - ansible.builtin.assert: - that: - - tag_vpn is not changed - - tag_vpn.vpn_connection_id == vpn_id - - tag_vpn_info.vpn_connections[0].vpn_connection_id == vpn_id - - tag_vpn_info.vpn_connections[0].tags == first_tags + - name: Add tags (check_mode) + amazon.aws.ec2_vpc_vpn: + tags: "{{ first_tags }}" + state: present + register: tag_vpn + check_mode: true + + - name: Assert would change + ansible.builtin.assert: + that: + - tag_vpn is changed + - tag_vpn.vpn_connection_id == vpn_id + + - name: Add tags + amazon.aws.ec2_vpc_vpn: + tags: "{{ first_tags }}" + state: present + register: tag_vpn + + - name: Get EC2 VPC VPN facts + amazon.aws.ec2_vpc_vpn_info: + filters: + vpn-connection-id: "{{ vpn.vpn_connection_id }}" + register: tag_vpn_info + + - name: Verify the tags were added + ansible.builtin.assert: + that: + - tag_vpn is changed + - tag_vpn.vpn_connection_id == vpn_id + - tag_vpn_info.vpn_connections[0].vpn_connection_id == vpn_id + - tag_vpn_info.vpn_connections[0].tags == first_tags + + - name: Add tags - IDEMPOTENCY (check_mode) + amazon.aws.ec2_vpc_vpn: + tags: "{{ first_tags }}" + state: present + register: tag_vpn + check_mode: true + + - name: Assert would not change + ansible.builtin.assert: + that: + - tag_vpn is not changed + - tag_vpn.vpn_connection_id == vpn_id + + - name: Add tags - IDEMPOTENCY + amazon.aws.ec2_vpc_vpn: + tags: "{{ first_tags }}" + state: present + register: tag_vpn + + - name: Get EC2 VPC VPN facts + amazon.aws.ec2_vpc_vpn_info: + filters: + vpn-connection-id: "{{ vpn.vpn_connection_id }}" + register: tag_vpn_info + + - name: Verify no change + ansible.builtin.assert: + that: + - tag_vpn is not changed + - tag_vpn.vpn_connection_id == vpn_id + - tag_vpn_info.vpn_connections[0].vpn_connection_id == vpn_id + - tag_vpn_info.vpn_connections[0].tags == first_tags # ============================================================ - - name: Modify tags with purge (check_mode) - amazon.aws.ec2_vpc_vpn: - tags: '{{ second_tags }}' - state: present - purge_tags: true - register: tag_vpn - check_mode: true - - - name: Assert would change - ansible.builtin.assert: - that: - - tag_vpn is changed - - tag_vpn.vpn_connection_id == vpn_id - - - name: Modify tags with purge - amazon.aws.ec2_vpc_vpn: - tags: '{{ second_tags }}' - state: present - purge_tags: true - register: tag_vpn - - - name: Get EC2 VPC VPN facts - amazon.aws.ec2_vpc_vpn_info: - filters: - vpn-connection-id: '{{ vpn.vpn_connection_id }}' - register: tag_vpn_info - - - name: Verify the tags were added - ansible.builtin.assert: - that: - - tag_vpn is changed - - tag_vpn.vpn_connection_id == vpn_id - - tag_vpn_info.vpn_connections[0].vpn_connection_id == vpn_id - - tag_vpn_info.vpn_connections[0].tags == second_tags - - - name: Modify tags with purge - IDEMPOTENCY (check_mode) - amazon.aws.ec2_vpc_vpn: - tags: '{{ second_tags }}' - state: present - purge_tags: true - register: tag_vpn - check_mode: true - - - name: Assert would not change - ansible.builtin.assert: - that: - - tag_vpn is not changed - - tag_vpn.vpn_connection_id == vpn_id - - - name: Modify tags with purge - IDEMPOTENCY - amazon.aws.ec2_vpc_vpn: - tags: '{{ second_tags }}' - state: present - purge_tags: true - register: tag_vpn - - - name: Get EC2 VPC VPN facts - amazon.aws.ec2_vpc_vpn_info: - filters: - vpn-connection-id: '{{ vpn.vpn_connection_id }}' - register: tag_vpn_info - - - name: Verify no change - ansible.builtin.assert: - that: - - tag_vpn is not changed - - tag_vpn.vpn_connection_id == vpn_id - - tag_vpn_info.vpn_connections[0].vpn_connection_id == vpn_id - - tag_vpn_info.vpn_connections[0].tags == second_tags + - name: Modify tags with purge (check_mode) + amazon.aws.ec2_vpc_vpn: + tags: "{{ second_tags }}" + state: present + purge_tags: true + register: tag_vpn + check_mode: true + + - name: Assert would change + ansible.builtin.assert: + that: + - tag_vpn is changed + - tag_vpn.vpn_connection_id == vpn_id + + - name: Modify tags with purge + amazon.aws.ec2_vpc_vpn: + tags: "{{ second_tags }}" + state: present + purge_tags: true + register: tag_vpn + + - name: Get EC2 VPC VPN facts + amazon.aws.ec2_vpc_vpn_info: + filters: + vpn-connection-id: "{{ vpn.vpn_connection_id }}" + register: tag_vpn_info + + - name: Verify the tags were added + ansible.builtin.assert: + that: + - tag_vpn is changed + - tag_vpn.vpn_connection_id == vpn_id + - tag_vpn_info.vpn_connections[0].vpn_connection_id == vpn_id + - tag_vpn_info.vpn_connections[0].tags == second_tags + + - name: Modify tags with purge - IDEMPOTENCY (check_mode) + amazon.aws.ec2_vpc_vpn: + tags: "{{ second_tags }}" + state: present + purge_tags: true + register: tag_vpn + check_mode: true + + - name: Assert would not change + ansible.builtin.assert: + that: + - tag_vpn is not changed + - tag_vpn.vpn_connection_id == vpn_id + + - name: Modify tags with purge - IDEMPOTENCY + amazon.aws.ec2_vpc_vpn: + tags: "{{ second_tags }}" + state: present + purge_tags: true + register: tag_vpn + + - name: Get EC2 VPC VPN facts + amazon.aws.ec2_vpc_vpn_info: + filters: + vpn-connection-id: "{{ vpn.vpn_connection_id }}" + register: tag_vpn_info + + - name: Verify no change + ansible.builtin.assert: + that: + - tag_vpn is not changed + - tag_vpn.vpn_connection_id == vpn_id + - tag_vpn_info.vpn_connections[0].vpn_connection_id == vpn_id + - tag_vpn_info.vpn_connections[0].tags == second_tags # ============================================================ - - name: Modify tags without purge (check_mode) - amazon.aws.ec2_vpc_vpn: - tags: '{{ third_tags }}' - state: present - purge_tags: false - register: tag_vpn - check_mode: true - - - name: Assert would change - ansible.builtin.assert: - that: - - tag_vpn is changed - - tag_vpn.vpn_connection_id == vpn_id - - - name: Modify tags without purge - amazon.aws.ec2_vpc_vpn: - tags: '{{ third_tags }}' - state: present - purge_tags: false - register: tag_vpn - - - name: Get EC2 VPC VPN facts - amazon.aws.ec2_vpc_vpn_info: - filters: - vpn-connection-id: '{{ vpn.vpn_connection_id }}' - register: tag_vpn_info - - - name: verify the tags were added - ansible.builtin.assert: - that: - - tag_vpn is changed - - tag_vpn.vpn_connection_id == vpn_id - - tag_vpn_info.vpn_connections[0].vpn_connection_id == vpn_id - - tag_vpn_info.vpn_connections[0].tags == final_tags - - - name: Modify tags without purge - IDEMPOTENCY (check_mode) - amazon.aws.ec2_vpc_vpn: - tags: '{{ third_tags }}' - state: present - purge_tags: false - register: tag_vpn - check_mode: true - - - name: Assert would not change - ansible.builtin.assert: - that: - - tag_vpn is not changed - - tag_vpn.vpn_connection_id == vpn_id - - - name: Modify tags without purge - IDEMPOTENCY - amazon.aws.ec2_vpc_vpn: - tags: '{{ third_tags }}' - state: present - purge_tags: false - register: tag_vpn - - - name: Get EC2 VPC VPN facts - amazon.aws.ec2_vpc_vpn_info: - filters: - vpn-connection-id: '{{ vpn.vpn_connection_id }}' - register: tag_vpn_info - - - name: Verify no change - ansible.builtin.assert: - that: - - tag_vpn is not changed - - tag_vpn.vpn_connection_id == vpn_id - - tag_vpn_info.vpn_connections[0].vpn_connection_id == vpn_id - - tag_vpn_info.vpn_connections[0].tags == final_tags + - name: Modify tags without purge (check_mode) + amazon.aws.ec2_vpc_vpn: + tags: "{{ third_tags }}" + state: present + purge_tags: false + register: tag_vpn + check_mode: true + + - name: Assert would change + ansible.builtin.assert: + that: + - tag_vpn is changed + - tag_vpn.vpn_connection_id == vpn_id + + - name: Modify tags without purge + amazon.aws.ec2_vpc_vpn: + tags: "{{ third_tags }}" + state: present + purge_tags: false + register: tag_vpn + + - name: Get EC2 VPC VPN facts + amazon.aws.ec2_vpc_vpn_info: + filters: + vpn-connection-id: "{{ vpn.vpn_connection_id }}" + register: tag_vpn_info + + - name: Verify the tags were added + ansible.builtin.assert: + that: + - tag_vpn is changed + - tag_vpn.vpn_connection_id == vpn_id + - tag_vpn_info.vpn_connections[0].vpn_connection_id == vpn_id + - tag_vpn_info.vpn_connections[0].tags == final_tags + + - name: Modify tags without purge - IDEMPOTENCY (check_mode) + amazon.aws.ec2_vpc_vpn: + tags: "{{ third_tags }}" + state: present + purge_tags: false + register: tag_vpn + check_mode: true + + - name: Assert would not change + ansible.builtin.assert: + that: + - tag_vpn is not changed + - tag_vpn.vpn_connection_id == vpn_id + + - name: Modify tags without purge - IDEMPOTENCY + amazon.aws.ec2_vpc_vpn: + tags: "{{ third_tags }}" + state: present + purge_tags: false + register: tag_vpn + + - name: Get EC2 VPC VPN facts + amazon.aws.ec2_vpc_vpn_info: + filters: + vpn-connection-id: "{{ vpn.vpn_connection_id }}" + register: tag_vpn_info + + - name: Verify no change + ansible.builtin.assert: + that: + - tag_vpn is not changed + - tag_vpn.vpn_connection_id == vpn_id + - tag_vpn_info.vpn_connections[0].vpn_connection_id == vpn_id + - tag_vpn_info.vpn_connections[0].tags == final_tags # ============================================================ - - name: No change to tags without setting tag (check_mode) - amazon.aws.ec2_vpc_vpn: - state: present - register: tag_vpn - check_mode: true - - - name: Assert would change - ansible.builtin.assert: - that: - - tag_vpn is not changed - - tag_vpn.vpn_connection_id == vpn_id - - - name: No change to tags without setting tags - amazon.aws.ec2_vpc_vpn: - state: present - register: tag_vpn - - - name: Get CE2 VPC VPN facts - amazon.aws.ec2_vpc_vpn_info: - filters: - vpn-connection-id: '{{ vpn.vpn_connection_id }}' - register: tag_vpn_info - - - name: Verify no tags were added - ansible.builtin.assert: - that: - - tag_vpn is not changed - - tag_vpn.vpn_connection_id == vpn_id - - tag_vpn_info.vpn_connections[0].vpn_connection_id == vpn_id - - tag_vpn_info.vpn_connections[0].tags == final_tags + - name: No change to tags without setting tag (check_mode) + amazon.aws.ec2_vpc_vpn: + state: present + register: tag_vpn + check_mode: true + + - name: Assert would change + ansible.builtin.assert: + that: + - tag_vpn is not changed + - tag_vpn.vpn_connection_id == vpn_id + + - name: No change to tags without setting tags + amazon.aws.ec2_vpc_vpn: + state: present + register: tag_vpn + + - name: Get CE2 VPC VPN facts + amazon.aws.ec2_vpc_vpn_info: + filters: + vpn-connection-id: "{{ vpn.vpn_connection_id }}" + register: tag_vpn_info + + - name: Verify no tags were added + ansible.builtin.assert: + that: + - tag_vpn is not changed + - tag_vpn.vpn_connection_id == vpn_id + - tag_vpn_info.vpn_connections[0].vpn_connection_id == vpn_id + - tag_vpn_info.vpn_connections[0].tags == final_tags # ============================================================ - - name: Remove tags (check_mode) - amazon.aws.ec2_vpc_vpn: - tags: {} - state: present - purge_tags: true - register: tag_vpn - check_mode: true - - - name: Assert would change - ansible.builtin.assert: - that: - - tag_vpn is changed - - tag_vpn.vpn_connection_id == vpn_id - - - name: Remove tags - amazon.aws.ec2_vpc_vpn: - tags: {} - state: present - purge_tags: true - register: tag_vpn - - - name: Get EC2 VPC VPN facts - amazon.aws.ec2_vpc_vpn_info: - filters: - vpn-connection-id: '{{ vpn.vpn_connection_id }}' - register: tag_vpn_info - - - name: Verify the tags were removed - ansible.builtin.assert: - that: - - tag_vpn is changed - - tag_vpn.vpn_connection_id == vpn_id - - tag_vpn_info.vpn_connections[0].vpn_connection_id == vpn_id - - - name: Remove tags - IDEMPOTENCY (check_mode) - amazon.aws.ec2_vpc_vpn: - tags: {} - state: present - purge_tags: true - register: tag_vpn - check_mode: true - - - name: Assert would not change - ansible.builtin.assert: - that: - - tag_vpn is not changed - - tag_vpn.vpn_connection_id == vpn_id - - - name: Remove tags - IDEMPOTENCY - amazon.aws.ec2_vpc_vpn: - tags: {} - state: present - purge_tags: true - register: tag_vpn - - - name: Get VPC VPN facts - amazon.aws.ec2_vpc_vpn_info: - filters: - vpn-connection-id: '{{ vpn.vpn_connection_id }}' - register: tag_vpn_info - - - name: Verify no change - ansible.builtin.assert: - that: - - tag_vpn is not changed - - tag_vpn.vpn_connection_id == vpn_id - - tag_vpn_info.vpn_connections[0].vpn_connection_id == vpn_id + - name: Remove tags (check_mode) + amazon.aws.ec2_vpc_vpn: + tags: {} + state: present + purge_tags: true + register: tag_vpn + check_mode: true + + - name: Assert would change + ansible.builtin.assert: + that: + - tag_vpn is changed + - tag_vpn.vpn_connection_id == vpn_id + + - name: Remove tags + amazon.aws.ec2_vpc_vpn: + tags: {} + state: present + purge_tags: true + register: tag_vpn + + - name: Get EC2 VPC VPN facts + amazon.aws.ec2_vpc_vpn_info: + filters: + vpn-connection-id: "{{ vpn.vpn_connection_id }}" + register: tag_vpn_info + + - name: Verify the tags were removed + ansible.builtin.assert: + that: + - tag_vpn is changed + - tag_vpn.vpn_connection_id == vpn_id + - tag_vpn_info.vpn_connections[0].vpn_connection_id == vpn_id + + - name: Remove tags - IDEMPOTENCY (check_mode) + amazon.aws.ec2_vpc_vpn: + tags: {} + state: present + purge_tags: true + register: tag_vpn + check_mode: true + + - name: Assert would not change + ansible.builtin.assert: + that: + - tag_vpn is not changed + - tag_vpn.vpn_connection_id == vpn_id + + - name: Remove tags - IDEMPOTENCY + amazon.aws.ec2_vpc_vpn: + tags: {} + state: present + purge_tags: true + register: tag_vpn + + - name: Get VPC VPN facts + amazon.aws.ec2_vpc_vpn_info: + filters: + vpn-connection-id: "{{ vpn.vpn_connection_id }}" + register: tag_vpn_info + + - name: Verify no change + ansible.builtin.assert: + that: + - tag_vpn is not changed + - tag_vpn.vpn_connection_id == vpn_id + - tag_vpn_info.vpn_connections[0].vpn_connection_id == vpn_id diff --git a/tests/integration/targets/elb_application_lb/tasks/alb_with_multiple_listener_certs.yml b/tests/integration/targets/elb_application_lb/tasks/alb_with_multiple_listener_certs.yml index af55c29bfe9..92d457ff085 100644 --- a/tests/integration/targets/elb_application_lb/tasks/alb_with_multiple_listener_certs.yml +++ b/tests/integration/targets/elb_application_lb/tasks/alb_with_multiple_listener_certs.yml @@ -1,3 +1,4 @@ +--- - name: Run tests block: - name: Generate private key for local certs @@ -24,11 +25,11 @@ register: cert_create_result with_items: "{{ local_certs }}" - - name: upload certificates + - name: Upload certificates community.aws.acm_certificate: name_tag: "{{ item.name }}" - certificate: "{{ lookup('file', item.cert ) }}" - private_key: "{{ lookup('file', item.priv_key ) }}" + certificate: "{{ lookup('file', item.cert) }}" + private_key: "{{ lookup('file', item.priv_key) }}" state: present tags: Application: search @@ -58,7 +59,7 @@ subnets: "{{ public_subnets }}" security_groups: "{{ sec_group.group_id }}" state: present - purge_listeners: False + purge_listeners: false listeners: - Protocol: HTTPS Port: 446 @@ -71,20 +72,20 @@ TargetGroupName: "{{ tg_name }}" register: alb - - name: Gather information about a particular ALB given its ARN #returns only default cert + - name: Gather information about a particular ALB given its ARN # returns only default cert amazon.aws.elb_application_lb_info: load_balancer_arns: - "{{ alb.load_balancer_arn }}" register: alb_info - - name: obtain information about a certificate 1 + - name: Obtain information about a certificate 1 community.aws.acm_certificate_info: - certificate_arn: "{{ cert_1_arn }}" + certificate_arn: "{{ cert_1_arn }}" register: cert_1_info - - name: obtain information about a certificate 2 + - name: Obtain information about a certificate 2 community.aws.acm_certificate_info: - certificate_arn: "{{ cert_2_arn }}" + certificate_arn: "{{ cert_2_arn }}" register: cert_2_info - name: Assert that both certificiates are in use by test load balancer @@ -100,7 +101,7 @@ subnets: "{{ public_subnets }}" security_groups: "{{ sec_group.group_id }}" state: absent - purge_listeners: False + purge_listeners: false listeners: - Protocol: HTTPS Port: 446 @@ -113,7 +114,7 @@ TargetGroupName: "{{ tg_name }}" ignore_errors: true - - name: delete a certificate with a particular ARN + - name: Delete a certificate with a particular ARN community.aws.acm_certificate: certificate_arn: "{{ item }}" state: absent diff --git a/tests/integration/targets/elb_application_lb/tasks/main.yml b/tests/integration/targets/elb_application_lb/tasks/main.yml index f1b89a6b185..f0afe8f489f 100644 --- a/tests/integration/targets/elb_application_lb/tasks/main.yml +++ b/tests/integration/targets/elb_application_lb/tasks/main.yml @@ -133,7 +133,6 @@ encryption: aws:kms policy: "{{ lookup('template', 'policy.json') }}" - - name: Run tests for creating ALB with listener having multiple certificates ansible.builtin.import_tasks: alb_with_multiple_listener_certs.yml 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 e5e043eaad1..8ec30c14444 100644 --- a/tests/integration/targets/elb_classic_lb/tasks/basic_internal.yml +++ b/tests/integration/targets/elb_classic_lb/tasks/basic_internal.yml @@ -222,7 +222,7 @@ # ============================================================ - - name: remove the test load balancer completely (check_mode) + - name: Remove the test load balancer completely (check_mode) amazon.aws.elb_classic_lb: name: "{{ elb_name }}" state: absent @@ -230,28 +230,28 @@ register: result check_mode: true - - name: assert the load balancer would be removed + - name: Assert the load balancer would be removed ansible.builtin.assert: that: - result is changed - result.elb.name == elb_name - result.elb.status == "deleted" - - name: remove the test load balancer completely + - name: Remove the test load balancer completely amazon.aws.elb_classic_lb: name: "{{ elb_name }}" state: absent wait: true register: result - - name: assert the load balancer was removed + - name: Assert the load balancer was removed ansible.builtin.assert: that: - result is changed - result.elb.name == elb_name - result.elb.status == "deleted" - - name: remove the test load balancer completely (idempotency) (check_mode) + - name: Remove the test load balancer completely (idempotency) (check_mode) amazon.aws.elb_classic_lb: name: "{{ elb_name }}" state: absent @@ -259,21 +259,21 @@ register: result check_mode: true - - name: assert the load balancer is gone + - name: Assert the load balancer is gone ansible.builtin.assert: that: - result is not changed - result.elb.name == elb_name - result.elb.status == "gone" - - name: remove the test load balancer completely (idempotency) + - name: Remove the test load balancer completely (idempotency) amazon.aws.elb_classic_lb: name: "{{ elb_name }}" state: absent wait: true register: result - - name: assert the load balancer is gone + - name: Assert the load balancer is gone ansible.builtin.assert: that: - result is not changed @@ -282,7 +282,7 @@ always: # ============================================================ - - name: remove the test load balancer + - name: Remove the test load balancer amazon.aws.elb_classic_lb: name: "{{ elb_name }}" state: absent 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 ab5b0b88a60..1cb7f3c3895 100644 --- a/tests/integration/targets/elb_classic_lb/tasks/basic_public.yml +++ b/tests/integration/targets/elb_classic_lb/tasks/basic_public.yml @@ -203,7 +203,7 @@ # ============================================================ - - name: remove the test load balancer completely (check_mode) + - name: Remove the test load balancer completely (check_mode) amazon.aws.elb_classic_lb: name: "{{ elb_name }}" state: absent @@ -211,28 +211,28 @@ register: result check_mode: true - - name: assert the load balancer would be removed + - name: Assert the load balancer would be removed ansible.builtin.assert: that: - result is changed - result.elb.name == elb_name - result.elb.status == "deleted" - - name: remove the test load balancer completely + - name: Remove the test load balancer completely amazon.aws.elb_classic_lb: name: "{{ elb_name }}" state: absent wait: true register: result - - name: assert the load balancer was removed + - name: Assert the load balancer was removed ansible.builtin.assert: that: - result is changed - result.elb.name == elb_name - result.elb.status == "deleted" - - name: remove the test load balancer completely (idempotency) (check_mode) + - name: Remove the test load balancer completely (idempotency) (check_mode) amazon.aws.elb_classic_lb: name: "{{ elb_name }}" state: absent @@ -240,21 +240,21 @@ register: result check_mode: true - - name: assert the load balancer is gone + - name: Assert the load balancer is gone ansible.builtin.assert: that: - result is not changed - result.elb.name == elb_name - result.elb.status == "gone" - - name: remove the test load balancer completely (idempotency) + - name: Remove the test load balancer completely (idempotency) amazon.aws.elb_classic_lb: name: "{{ elb_name }}" state: absent wait: true register: result - - name: assert the load balancer is gone + - name: Assert the load balancer is gone ansible.builtin.assert: that: - result is not changed @@ -263,7 +263,7 @@ always: # ============================================================ - - name: remove the test load balancer + - name: Remove the test load balancer amazon.aws.elb_classic_lb: name: "{{ elb_name }}" state: absent diff --git a/tests/integration/targets/elb_classic_lb/tasks/cleanup_vpc.yml b/tests/integration/targets/elb_classic_lb/tasks/cleanup_vpc.yml index 675fc576705..7f47311518b 100644 --- a/tests/integration/targets/elb_classic_lb/tasks/cleanup_vpc.yml +++ b/tests/integration/targets/elb_classic_lb/tasks/cleanup_vpc.yml @@ -1,5 +1,5 @@ --- -- name: delete security groups +- name: Delete security groups amazon.aws.ec2_security_group: name: "{{ item }}" state: absent @@ -9,7 +9,7 @@ - "{{ resource_prefix }}-b" - "{{ resource_prefix }}-c" -- name: delete subnets +- name: Delete subnets amazon.aws.ec2_vpc_subnet: vpc_id: "{{ setup_vpc.vpc.id }}" cidr: "{{ item }}" @@ -21,7 +21,7 @@ - "{{ subnet_cidr_3 }}" - "{{ subnet_cidr_4 }}" -- name: delete VPC +- name: Delete VPC amazon.aws.ec2_vpc_net: cidr_block: "{{ vpc_cidr }}" state: absent diff --git a/tests/integration/targets/elb_classic_lb/tasks/complex_changes.yml b/tests/integration/targets/elb_classic_lb/tasks/complex_changes.yml index 3108ae36937..d0dfb74bb5b 100644 --- a/tests/integration/targets/elb_classic_lb/tasks/complex_changes.yml +++ b/tests/integration/targets/elb_classic_lb/tasks/complex_changes.yml @@ -320,7 +320,7 @@ always: # ============================================================ - - name: remove the test load balancer + - name: Remove the test load balancer amazon.aws.elb_classic_lb: name: "{{ elb_name }}" state: absent diff --git a/tests/integration/targets/elb_classic_lb/tasks/describe_region.yml b/tests/integration/targets/elb_classic_lb/tasks/describe_region.yml index 2da62829106..fa8e6fc281e 100644 --- a/tests/integration/targets/elb_classic_lb/tasks/describe_region.yml +++ b/tests/integration/targets/elb_classic_lb/tasks/describe_region.yml @@ -1,9 +1,9 @@ --- -- name: list available AZs +- name: List available AZs amazon.aws.aws_az_info: register: region_azs -- name: pick AZs for testing +- name: Pick AZs for testing ansible.builtin.set_fact: availability_zone_a: "{{ region_azs.availability_zones[0].zone_name }}" availability_zone_b: "{{ region_azs.availability_zones[1].zone_name }}" 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 c1ec412c295..df1dae858a1 100644 --- a/tests/integration/targets/elb_classic_lb/tasks/https_listeners.yml +++ b/tests/integration/targets/elb_classic_lb/tasks/https_listeners.yml @@ -25,11 +25,11 @@ selfsigned_digest: sha256 register: cert_create_result -- name: upload certificates first time +- name: Upload certificates first time community.aws.acm_certificate: name_tag: "{{ item.name }}" - certificate: "{{ lookup('file', item.cert ) }}" - private_key: "{{ lookup('file', item.priv_key ) }}" + certificate: "{{ lookup('file', item.cert) }}" + private_key: "{{ lookup('file', item.priv_key) }}" state: present tags: Application: search diff --git a/tests/integration/targets/elb_classic_lb/tasks/main.yml b/tests/integration/targets/elb_classic_lb/tasks/main.yml index 53412374274..6ebffb8eece 100644 --- a/tests/integration/targets/elb_classic_lb/tasks/main.yml +++ b/tests/integration/targets/elb_classic_lb/tasks/main.yml @@ -34,7 +34,7 @@ always: # ============================================================ # ELB should already be gone, but double-check - - name: remove the test load balancer + - name: Remove the test load balancer amazon.aws.elb_classic_lb: name: "{{ elb_name }}" state: absent diff --git a/tests/integration/targets/elb_classic_lb/tasks/missing_params.yml b/tests/integration/targets/elb_classic_lb/tasks/missing_params.yml index 7f6c4bc3169..17f6343f36e 100644 --- a/tests/integration/targets/elb_classic_lb/tasks/missing_params.yml +++ b/tests/integration/targets/elb_classic_lb/tasks/missing_params.yml @@ -3,26 +3,26 @@ - block: # ============================================================ - - name: test with no name + - name: Test with no name amazon.aws.elb_classic_lb: state: present register: result ignore_errors: true - - name: assert failure when called with no parameters + - name: Assert failure when called with no parameters ansible.builtin.assert: that: - result.failed - '"missing required arguments" in result.msg' - '"name" in result.msg' - - name: test with only name (state missing) + - name: Test with only name (state missing) amazon.aws.elb_classic_lb: name: "{{ elb_name }}" register: result ignore_errors: true - - name: assert failure when called with only name + - name: Assert failure when called with only name ansible.builtin.assert: that: - result.failed @@ -40,7 +40,7 @@ register: result ignore_errors: true - - name: assert failure when neither subnets nor AZs are provided on creation + - name: Assert failure when neither subnets nor AZs are provided on creation ansible.builtin.assert: that: - result.failed @@ -55,7 +55,7 @@ register: result ignore_errors: true - - name: assert failure when listeners not provided on creation + - name: Assert failure when listeners not provided on creation ansible.builtin.assert: that: - result.failed @@ -73,7 +73,7 @@ register: result ignore_errors: true - - name: assert failure when listeners contains invalid protocol + - name: Assert failure when listeners contains invalid protocol ansible.builtin.assert: that: - result.failed @@ -93,7 +93,7 @@ register: result ignore_errors: true - - name: assert failure when listeners contains invalid instance_protocol + - name: Assert failure when listeners contains invalid instance_protocol ansible.builtin.assert: that: - result.failed @@ -119,7 +119,7 @@ register: result ignore_errors: true - - name: assert failure when healthcheck ping_protocol is invalid + - name: Assert failure when healthcheck ping_protocol is invalid ansible.builtin.assert: that: - result.failed @@ -145,7 +145,7 @@ register: result ignore_errors: true - - name: assert failure when HTTP healthcheck missing a ping_path + - name: Assert failure when HTTP healthcheck missing a ping_path ansible.builtin.assert: that: - result.failed @@ -165,7 +165,7 @@ register: result ignore_errors: true - - name: assert failure when app stickiness policy missing cookie name + - name: Assert failure when app stickiness policy missing cookie name ansible.builtin.assert: that: - result.failed @@ -185,7 +185,7 @@ register: result ignore_errors: true - - name: assert failure when access log is missing a bucket + - name: Assert failure when access log is missing a bucket ansible.builtin.assert: that: - result.failed @@ -193,7 +193,7 @@ always: # ============================================================ - - name: remove the test load balancer + - name: Remove the test load balancer amazon.aws.elb_classic_lb: name: "{{ elb_name }}" state: absent diff --git a/tests/integration/targets/elb_classic_lb/tasks/schema_change.yml b/tests/integration/targets/elb_classic_lb/tasks/schema_change.yml index 5528a043f4d..40109033a2b 100644 --- a/tests/integration/targets/elb_classic_lb/tasks/schema_change.yml +++ b/tests/integration/targets/elb_classic_lb/tasks/schema_change.yml @@ -177,7 +177,7 @@ always: # ============================================================ - - name: remove the test load balancer + - name: Remove the test load balancer amazon.aws.elb_classic_lb: name: "{{ elb_name }}" state: absent diff --git a/tests/integration/targets/elb_classic_lb/tasks/setup_instances.yml b/tests/integration/targets/elb_classic_lb/tasks/setup_instances.yml index 7576c5d2c61..ccdd3f26376 100644 --- a/tests/integration/targets/elb_classic_lb/tasks/setup_instances.yml +++ b/tests/integration/targets/elb_classic_lb/tasks/setup_instances.yml @@ -19,7 +19,7 @@ security_group: "{{ sg_b }}" register: ec2_instance_b -- name: store the Instance IDs +- name: Store the Instance IDs ansible.builtin.set_fact: instance_a: "{{ ec2_instance_a.instance_ids[0] }}" instance_b: "{{ ec2_instance_b.instance_ids[0] }}" diff --git a/tests/integration/targets/elb_classic_lb/tasks/setup_s3.yml b/tests/integration/targets/elb_classic_lb/tasks/setup_s3.yml index 05482ca142b..e00fff77c5e 100644 --- a/tests/integration/targets/elb_classic_lb/tasks/setup_s3.yml +++ b/tests/integration/targets/elb_classic_lb/tasks/setup_s3.yml @@ -5,7 +5,7 @@ amazon.aws.s3_bucket: name: "{{ s3_logging_bucket_a }}" state: present - policy: "{{ lookup('template','s3_policy.j2') }}" + policy: "{{ lookup('template', 's3_policy.j2') }}" register: logging_bucket - ansible.builtin.assert: @@ -18,7 +18,7 @@ amazon.aws.s3_bucket: name: "{{ s3_logging_bucket_b }}" state: present - policy: "{{ lookup('template','s3_policy.j2') }}" + policy: "{{ lookup('template', 's3_policy.j2') }}" register: logging_bucket - ansible.builtin.assert: diff --git a/tests/integration/targets/elb_classic_lb/tasks/setup_vpc.yml b/tests/integration/targets/elb_classic_lb/tasks/setup_vpc.yml index 03731066b83..613a43dff0d 100644 --- a/tests/integration/targets/elb_classic_lb/tasks/setup_vpc.yml +++ b/tests/integration/targets/elb_classic_lb/tasks/setup_vpc.yml @@ -1,6 +1,6 @@ --- # SETUP: vpc, subnet, security group -- name: create a VPC to work in +- name: Create a VPC to work in amazon.aws.ec2_vpc_net: cidr_block: "{{ vpc_cidr }}" state: present @@ -9,7 +9,7 @@ Name: "{{ resource_prefix }}" register: setup_vpc -- name: create a subnet +- name: Create a subnet amazon.aws.ec2_vpc_subnet: az: "{{ availability_zone_a }}" tags: "{{ resource_prefix }}" @@ -20,7 +20,7 @@ Name: "{{ resource_prefix }}-a" register: setup_subnet_1 -- name: create a subnet +- name: Create a subnet amazon.aws.ec2_vpc_subnet: az: "{{ availability_zone_b }}" tags: "{{ resource_prefix }}" @@ -31,7 +31,7 @@ Name: "{{ resource_prefix }}-b" register: setup_subnet_2 -- name: create a subnet +- name: Create a subnet amazon.aws.ec2_vpc_subnet: az: "{{ availability_zone_c }}" tags: "{{ resource_prefix }}" @@ -42,7 +42,7 @@ Name: "{{ resource_prefix }}-c" register: setup_subnet_3 -- name: create a subnet +- name: Create a subnet amazon.aws.ec2_vpc_subnet: az: "{{ availability_zone_a }}" tags: "{{ resource_prefix }}" @@ -53,7 +53,7 @@ Name: "{{ resource_prefix }}-a2" register: setup_subnet_4 -- name: create a security group +- name: Create a security group amazon.aws.ec2_security_group: name: "{{ resource_prefix }}-a" description: created by Ansible integration tests @@ -66,7 +66,7 @@ cidr_ip: "{{ vpc_cidr }}" register: setup_sg_1 -- name: create a security group +- name: Create a security group amazon.aws.ec2_security_group: name: "{{ resource_prefix }}-b" description: created by Ansible integration tests @@ -79,7 +79,7 @@ cidr_ip: "{{ vpc_cidr }}" register: setup_sg_2 -- name: create a security group +- name: Create a security group amazon.aws.ec2_security_group: name: "{{ resource_prefix }}-c" description: created by Ansible integration tests @@ -92,7 +92,7 @@ cidr_ip: "{{ vpc_cidr }}" register: setup_sg_3 -- name: store the IDs +- name: Store the IDs ansible.builtin.set_fact: subnet_a: "{{ setup_subnet_1.subnet.id }}" subnet_b: "{{ setup_subnet_2.subnet.id }}" diff --git a/tests/integration/targets/elb_classic_lb/tasks/simple_changes.yml b/tests/integration/targets/elb_classic_lb/tasks/simple_changes.yml index c16e4b9dae2..13e6e7f99de 100644 --- a/tests/integration/targets/elb_classic_lb/tasks/simple_changes.yml +++ b/tests/integration/targets/elb_classic_lb/tasks/simple_changes.yml @@ -68,7 +68,7 @@ - ansible.builtin.include_tasks: simple_logging.yml always: # ============================================================ - - name: remove the test load balancer + - name: Remove the test load balancer amazon.aws.elb_classic_lb: name: "{{ elb_name }}" state: absent diff --git a/tests/integration/targets/elb_classic_lb/tasks/simple_cross_az.yml b/tests/integration/targets/elb_classic_lb/tasks/simple_cross_az.yml index 85e30209910..21238a1043b 100644 --- a/tests/integration/targets/elb_classic_lb/tasks/simple_cross_az.yml +++ b/tests/integration/targets/elb_classic_lb/tasks/simple_cross_az.yml @@ -1,7 +1,7 @@ --- # =========================================================== -- name: disable cross-az balancing on ELB (check_mode) +- name: Disable cross-az balancing on ELB (check_mode) amazon.aws.elb_classic_lb: name: "{{ elb_name }}" state: present @@ -13,7 +13,7 @@ that: - result is changed -- name: disable cross-az balancing on ELB +- name: Disable cross-az balancing on ELB amazon.aws.elb_classic_lb: name: "{{ elb_name }}" state: present @@ -25,7 +25,7 @@ - result is changed - result.elb.cross_az_load_balancing == 'no' -- name: disable cross-az balancing on ELB - idempotency (check_mode) +- name: Disable cross-az balancing on ELB - idempotency (check_mode) amazon.aws.elb_classic_lb: name: "{{ elb_name }}" state: present @@ -37,7 +37,7 @@ that: - result is not changed -- name: disable cross-az balancing on ELB - idempotency +- name: Disable cross-az balancing on ELB - idempotency amazon.aws.elb_classic_lb: name: "{{ elb_name }}" state: present @@ -51,7 +51,7 @@ # =========================================================== -- name: re-enable cross-az balancing on ELB (check_mode) +- name: Re-enable cross-az balancing on ELB (check_mode) amazon.aws.elb_classic_lb: name: "{{ elb_name }}" state: present @@ -63,7 +63,7 @@ that: - result is changed -- name: re-enable cross-az balancing on ELB +- name: Re-enable cross-az balancing on ELB amazon.aws.elb_classic_lb: name: "{{ elb_name }}" state: present @@ -75,7 +75,7 @@ - result is changed - result.elb.cross_az_load_balancing == 'yes' -- name: re-enable cross-az balancing on ELB - idempotency (check_mode) +- name: Re-enable cross-az balancing on ELB - idempotency (check_mode) amazon.aws.elb_classic_lb: name: "{{ elb_name }}" state: present @@ -87,7 +87,7 @@ that: - result is not changed -- name: re-enable cross-az balancing on ELB - idempotency +- name: Re-enable cross-az balancing on ELB - idempotency amazon.aws.elb_classic_lb: name: "{{ elb_name }}" state: present diff --git a/tests/integration/targets/elb_classic_lb/tasks/simple_draining_timeout.yml b/tests/integration/targets/elb_classic_lb/tasks/simple_draining_timeout.yml index 588a8b1a060..3527bfd6768 100644 --- a/tests/integration/targets/elb_classic_lb/tasks/simple_draining_timeout.yml +++ b/tests/integration/targets/elb_classic_lb/tasks/simple_draining_timeout.yml @@ -1,7 +1,7 @@ --- # =========================================================== -- name: disable connection draining on ELB (check_mode) +- name: Disable connection draining on ELB (check_mode) amazon.aws.elb_classic_lb: name: "{{ elb_name }}" state: present @@ -13,7 +13,7 @@ that: - result is changed -- name: disable connection draining on ELB +- name: Disable connection draining on ELB amazon.aws.elb_classic_lb: name: "{{ elb_name }}" state: present @@ -24,7 +24,7 @@ that: - result is changed -- name: disable connection draining on ELB - idempotency (check_mode) +- name: Disable connection draining on ELB - idempotency (check_mode) amazon.aws.elb_classic_lb: name: "{{ elb_name }}" state: present @@ -36,7 +36,7 @@ that: - result is not changed -- name: disable connection draining on ELB - idempotency +- name: Disable connection draining on ELB - idempotency amazon.aws.elb_classic_lb: name: "{{ elb_name }}" state: present @@ -49,7 +49,7 @@ # =========================================================== -- name: re-enable connection draining on ELB (check_mode) +- name: Re-enable connection draining on ELB (check_mode) amazon.aws.elb_classic_lb: name: "{{ elb_name }}" state: present @@ -61,7 +61,7 @@ that: - result is changed -- name: re-enable connection draining on ELB +- name: Re-enable connection draining on ELB amazon.aws.elb_classic_lb: name: "{{ elb_name }}" state: present @@ -73,7 +73,7 @@ - result is changed - result.elb.connection_draining_timeout == default_drain_timeout -- name: re-enable connection draining on ELB - idempotency (check_mode) +- name: Re-enable connection draining on ELB - idempotency (check_mode) amazon.aws.elb_classic_lb: name: "{{ elb_name }}" state: present @@ -85,7 +85,7 @@ that: - result is not changed -- name: re-enable connection draining on ELB - idempotency +- name: Re-enable connection draining on ELB - idempotency amazon.aws.elb_classic_lb: name: "{{ elb_name }}" state: present @@ -99,7 +99,7 @@ # =========================================================== -- name: update connection draining timout on ELB (check_mode) +- name: Update connection draining timout on ELB (check_mode) amazon.aws.elb_classic_lb: name: "{{ elb_name }}" state: present @@ -111,7 +111,7 @@ that: - result is changed -- name: update connection draining timout on ELB +- name: Update connection draining timout on ELB amazon.aws.elb_classic_lb: name: "{{ elb_name }}" state: present @@ -123,7 +123,7 @@ - result is changed - result.elb.connection_draining_timeout == updated_drain_timeout -- name: update connection draining timout on ELB - idempotency (check_mode) +- name: Update connection draining timout on ELB - idempotency (check_mode) amazon.aws.elb_classic_lb: name: "{{ elb_name }}" state: present @@ -135,7 +135,7 @@ that: - result is not changed -- name: update connection draining timout on ELB - idempotency +- name: Update connection draining timout on ELB - idempotency amazon.aws.elb_classic_lb: name: "{{ elb_name }}" state: present diff --git a/tests/integration/targets/elb_classic_lb/tasks/simple_idle_timeout.yml b/tests/integration/targets/elb_classic_lb/tasks/simple_idle_timeout.yml index 7143f007a58..89b30865020 100644 --- a/tests/integration/targets/elb_classic_lb/tasks/simple_idle_timeout.yml +++ b/tests/integration/targets/elb_classic_lb/tasks/simple_idle_timeout.yml @@ -1,7 +1,7 @@ --- # =========================================================== -- name: update idle connection timeout on ELB (check_mode) +- name: Update idle connection timeout on ELB (check_mode) amazon.aws.elb_classic_lb: name: "{{ elb_name }}" state: present @@ -13,7 +13,7 @@ that: - result is changed -- name: update idle connection timeout on ELB +- name: Update idle connection timeout on ELB amazon.aws.elb_classic_lb: name: "{{ elb_name }}" state: present @@ -25,7 +25,7 @@ - result is changed - result.elb.idle_timeout == updated_idle_timeout -- name: update idle connection timeout on ELB - idempotency (check_mode) +- name: Update idle connection timeout on ELB - idempotency (check_mode) amazon.aws.elb_classic_lb: name: "{{ elb_name }}" state: present @@ -37,7 +37,7 @@ that: - result is not changed -- name: update idle connection timeout on ELB - idempotency +- name: Update idle connection timeout on ELB - idempotency amazon.aws.elb_classic_lb: name: "{{ elb_name }}" state: present diff --git a/tests/integration/targets/elb_classic_lb/tasks/simple_securitygroups.yml b/tests/integration/targets/elb_classic_lb/tasks/simple_securitygroups.yml index 26f10ef6401..a2a92c060bf 100644 --- a/tests/integration/targets/elb_classic_lb/tasks/simple_securitygroups.yml +++ b/tests/integration/targets/elb_classic_lb/tasks/simple_securitygroups.yml @@ -51,7 +51,7 @@ - sg_b in result.elb.security_group_ids - sg_c not in result.elb.security_group_ids -#===================================================================== +# ===================================================================== - name: Assign Security Groups to ELB by name (check_mode) amazon.aws.elb_classic_lb: diff --git a/tests/integration/targets/elb_classic_lb_info/defaults/main.yml b/tests/integration/targets/elb_classic_lb_info/defaults/main.yml index 7279a8194da..11c6c701535 100644 --- a/tests/integration/targets/elb_classic_lb_info/defaults/main.yml +++ b/tests/integration/targets/elb_classic_lb_info/defaults/main.yml @@ -1,2 +1,3 @@ +--- # defaults file for test_ec2_eip elb_name: ansible-test-{{ tiny_prefix }}-ecli diff --git a/tests/integration/targets/elb_classic_lb_info/meta/main.yml b/tests/integration/targets/elb_classic_lb_info/meta/main.yml index 32cf5dda7ed..23d65c7ef45 100644 --- a/tests/integration/targets/elb_classic_lb_info/meta/main.yml +++ b/tests/integration/targets/elb_classic_lb_info/meta/main.yml @@ -1 +1,2 @@ +--- dependencies: [] diff --git a/tests/integration/targets/elb_classic_lb_info/tasks/main.yml b/tests/integration/targets/elb_classic_lb_info/tasks/main.yml index 3581736b760..f7b40083e99 100644 --- a/tests/integration/targets/elb_classic_lb_info/tasks/main.yml +++ b/tests/integration/targets/elb_classic_lb_info/tasks/main.yml @@ -1,3 +1,4 @@ +--- # __Test Info__ # Create a self signed cert and upload it to AWS # http://www.akadia.com/services/ssh_test_certificate.html @@ -17,301 +18,291 @@ - 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: - # ============================================================ # create test elb with listeners, certificate, and health check - - name: Create ELB - amazon.aws.elb_classic_lb: - name: '{{ elb_name }}' - state: present - zones: - - '{{ aws_region }}a' - - '{{ aws_region }}b' - listeners: - - protocol: http - load_balancer_port: 80 - instance_port: 80 - - protocol: http - load_balancer_port: 8080 - instance_port: 8080 - health_check: - ping_protocol: http - ping_port: 80 - ping_path: /index.html - response_timeout: 5 - interval: 30 - unhealthy_threshold: 2 - healthy_threshold: 10 - register: create - - - ansible.builtin.assert: - that: - - create is changed + - name: Create ELB + amazon.aws.elb_classic_lb: + name: "{{ elb_name }}" + state: present + zones: + - "{{ aws_region }}a" + - "{{ aws_region }}b" + listeners: + - protocol: http + load_balancer_port: 80 + instance_port: 80 + - protocol: http + load_balancer_port: 8080 + instance_port: 8080 + health_check: + ping_protocol: http + ping_port: 80 + ping_path: /index.html + response_timeout: 5 + interval: 30 + unhealthy_threshold: 2 + healthy_threshold: 10 + register: create + + - ansible.builtin.assert: + that: + - create is changed # We rely on these for the info test, make sure they're what we expect - - aws_region ~ 'a' in create.elb.zones - - aws_region ~ 'b' in create.elb.zones - - create.elb.health_check.healthy_threshold == 10 - - create.elb.health_check.interval == 30 - - create.elb.health_check.target == "HTTP:80/index.html" - - create.elb.health_check.timeout == 5 - - create.elb.health_check.unhealthy_threshold == 2 - - '[80, 80, "HTTP", "HTTP"] in create.elb.listeners' - - '[8080, 8080, "HTTP", "HTTP"] in create.elb.listeners' - - - name: Get ELB info - amazon.aws.elb_classic_lb_info: - names: '{{ elb_name }}' - register: info - - - ansible.builtin.assert: - that: - - info.elbs|length == 1 - - elb.availability_zones|length == 2 - - aws_region ~ 'a' in elb.availability_zones - - aws_region ~ 'b' in elb.availability_zones - - elb.health_check.healthy_threshold == 10 - - elb.health_check.interval == 30 - - elb.health_check.target == "HTTP:80/index.html" - - elb.health_check.timeout == 5 - - elb.health_check.unhealthy_threshold == 2 - - '{"instance_port": 80, "instance_protocol": "HTTP", "load_balancer_port": - 80, "protocol": "HTTP"} == listeners[0]' - - '{"instance_port": 8080, "instance_protocol": "HTTP", "load_balancer_port": - 8080, "protocol": "HTTP"} == listeners[1]' - vars: - elb: '{{ info.elbs[0] }}' - listeners: "{{ elb.listener_descriptions|map(attribute='listener')|sort(attribute='load_balancer_port') - }}" + - aws_region ~ 'a' in create.elb.zones + - aws_region ~ 'b' in create.elb.zones + - create.elb.health_check.healthy_threshold == 10 + - create.elb.health_check.interval == 30 + - create.elb.health_check.target == "HTTP:80/index.html" + - create.elb.health_check.timeout == 5 + - create.elb.health_check.unhealthy_threshold == 2 + - '[80, 80, "HTTP", "HTTP"] in create.elb.listeners' + - '[8080, 8080, "HTTP", "HTTP"] in create.elb.listeners' + + - name: Get ELB info + amazon.aws.elb_classic_lb_info: + names: "{{ elb_name }}" + register: info + + - ansible.builtin.assert: + that: + - info.elbs|length == 1 + - elb.availability_zones|length == 2 + - aws_region ~ 'a' in elb.availability_zones + - aws_region ~ 'b' in elb.availability_zones + - elb.health_check.healthy_threshold == 10 + - elb.health_check.interval == 30 + - elb.health_check.target == "HTTP:80/index.html" + - elb.health_check.timeout == 5 + - elb.health_check.unhealthy_threshold == 2 + - '{"instance_port": 80, "instance_protocol": "HTTP", "load_balancer_port": 80, "protocol": "HTTP"} == listeners[0]' + - '{"instance_port": 8080, "instance_protocol": "HTTP", "load_balancer_port": 8080, "protocol": "HTTP"} == listeners[1]' + vars: + elb: "{{ info.elbs[0] }}" + listeners: "{{ elb.listener_descriptions | map(attribute='listener') | sort(attribute='load_balancer_port') }}" # ============================================================ # check ports, would be cool, but we are at the mercy of AWS # to start things in a timely manner - #- name: check to make sure 80 is listening - # wait_for: host={{ info.elb.dns_name }} port=80 timeout=600 - # register: result + # - name: check to make sure 80 is listening + # wait_for: host={{ info.elb.dns_name }} port=80 timeout=600 + # register: result - #- name: assert can connect to port# - # assert: 'result.state == "started"' + # - name: assert can connect to port# + # assert: 'result.state == "started"' - #- name: check to make sure 443 is listening - # wait_for: host={{ info.elb.dns_name }} port=443 timeout=600 - # register: result + # - name: check to make sure 443 is listening + # wait_for: host={{ info.elb.dns_name }} port=443 timeout=600 + # register: result - #- name: assert can connect to port# - # assert: 'result.state == "started"' + # - name: assert can connect to port# + # assert: 'result.state == "started"' # ============================================================ # Change AZ's - - name: Change AZ's - amazon.aws.elb_classic_lb: - name: '{{ elb_name }}' - state: present - zones: - - '{{ aws_region }}c' - listeners: - - protocol: http - load_balancer_port: 80 - instance_port: 80 - purge_zones: yes - health_check: - ping_protocol: http - ping_port: 80 - ping_path: /index.html - response_timeout: 5 - interval: 30 - unhealthy_threshold: 2 - healthy_threshold: 10 - register: update_az - - - ansible.builtin.assert: - that: - - update_az is changed - - update_az.elb.zones[0] == aws_region ~ 'c' - - - name: Get ELB info after changing AZ's - amazon.aws.elb_classic_lb_info: - names: '{{ elb_name }}' - register: info - - - ansible.builtin.assert: - that: - - elb.availability_zones|length == 1 - - aws_region ~ 'c' in elb.availability_zones[0] - vars: - elb: '{{ info.elbs[0] }}' + - name: Change AZ's + amazon.aws.elb_classic_lb: + name: "{{ elb_name }}" + state: present + zones: + - "{{ aws_region }}c" + listeners: + - protocol: http + load_balancer_port: 80 + instance_port: 80 + purge_zones: true + health_check: + ping_protocol: http + ping_port: 80 + ping_path: /index.html + response_timeout: 5 + interval: 30 + unhealthy_threshold: 2 + healthy_threshold: 10 + register: update_az + + - ansible.builtin.assert: + that: + - update_az is changed + - update_az.elb.zones[0] == aws_region ~ 'c' + + - name: Get ELB info after changing AZ's + amazon.aws.elb_classic_lb_info: + names: "{{ elb_name }}" + register: info + + - ansible.builtin.assert: + that: + - elb.availability_zones|length == 1 + - aws_region ~ 'c' in elb.availability_zones[0] + vars: + elb: "{{ info.elbs[0] }}" # ============================================================ # Update AZ's - - name: Update AZ's - amazon.aws.elb_classic_lb: - name: '{{ elb_name }}' - state: present - zones: - - '{{ aws_region }}a' - - '{{ aws_region }}b' - - '{{ aws_region }}c' - listeners: - - protocol: http - load_balancer_port: 80 - instance_port: 80 - purge_zones: yes - register: update_az - - - ansible.builtin.assert: - that: - - update_az is changed - - aws_region ~ 'a' in update_az.elb.zones - - aws_region ~ 'b' in update_az.elb.zones - - aws_region ~ 'c' in update_az.elb.zones - - - name: Get ELB info after updating AZ's - amazon.aws.elb_classic_lb_info: - names: '{{ elb_name }}' - register: info - - - ansible.builtin.assert: - that: - - elb.availability_zones|length == 3 - - aws_region ~ 'a' in elb.availability_zones - - aws_region ~ 'b' in elb.availability_zones - - aws_region ~ 'c' in elb.availability_zones - vars: - elb: '{{ info.elbs[0] }}' + - name: Update AZ's + amazon.aws.elb_classic_lb: + name: "{{ elb_name }}" + state: present + zones: + - "{{ aws_region }}a" + - "{{ aws_region }}b" + - "{{ aws_region }}c" + listeners: + - protocol: http + load_balancer_port: 80 + instance_port: 80 + purge_zones: true + register: update_az + + - ansible.builtin.assert: + that: + - update_az is changed + - aws_region ~ 'a' in update_az.elb.zones + - aws_region ~ 'b' in update_az.elb.zones + - aws_region ~ 'c' in update_az.elb.zones + + - name: Get ELB info after updating AZ's + amazon.aws.elb_classic_lb_info: + names: "{{ elb_name }}" + register: info + + - ansible.builtin.assert: + that: + - elb.availability_zones|length == 3 + - aws_region ~ 'a' in elb.availability_zones + - aws_region ~ 'b' in elb.availability_zones + - aws_region ~ 'c' in elb.availability_zones + vars: + elb: "{{ info.elbs[0] }}" # ============================================================ # Purge Listeners - - name: Purge Listeners - amazon.aws.elb_classic_lb: - name: '{{ elb_name }}' - state: present - zones: - - '{{ aws_region }}a' - - '{{ aws_region }}b' - - '{{ aws_region }}c' - listeners: - - protocol: http - load_balancer_port: 80 - instance_port: 81 - purge_listeners: yes - register: purge_listeners - - - ansible.builtin.assert: - that: - - purge_listeners is changed - - '[80, 81, "HTTP", "HTTP"] in purge_listeners.elb.listeners' - - purge_listeners.elb.listeners|length == 1 - - - name: Get ELB info after purging listeners - amazon.aws.elb_classic_lb_info: - names: '{{ elb_name }}' - register: info - - - ansible.builtin.assert: - that: - - elb.listener_descriptions|length == 1 - - '{"instance_port": 81, "instance_protocol": "HTTP", "load_balancer_port": - 80, "protocol": "HTTP"} == elb.listener_descriptions[0].listener' - vars: - elb: '{{ info.elbs[0] }}' - + - name: Purge Listeners + amazon.aws.elb_classic_lb: + name: "{{ elb_name }}" + state: present + zones: + - "{{ aws_region }}a" + - "{{ aws_region }}b" + - "{{ aws_region }}c" + listeners: + - protocol: http + load_balancer_port: 80 + instance_port: 81 + purge_listeners: true + register: purge_listeners + + - ansible.builtin.assert: + that: + - purge_listeners is changed + - '[80, 81, "HTTP", "HTTP"] in purge_listeners.elb.listeners' + - purge_listeners.elb.listeners|length == 1 + + - name: Get ELB info after purging listeners + amazon.aws.elb_classic_lb_info: + names: "{{ elb_name }}" + register: info + + - ansible.builtin.assert: + that: + - elb.listener_descriptions|length == 1 + - '{"instance_port": 81, "instance_protocol": "HTTP", "load_balancer_port": 80, "protocol": "HTTP"} == elb.listener_descriptions[0].listener' + vars: + elb: "{{ info.elbs[0] }}" # ============================================================ # add Listeners - - name: Add Listeners - amazon.aws.elb_classic_lb: - name: '{{ elb_name }}' - state: present - zones: - - '{{ aws_region }}a' - - '{{ aws_region }}b' - - '{{ aws_region }}c' - listeners: - - protocol: http - load_balancer_port: 8081 - instance_port: 8081 - purge_listeners: no - register: update_listeners - - - ansible.builtin.assert: - that: - - update_listeners is changed - - '[80, 81, "HTTP", "HTTP"] in update_listeners.elb.listeners' - - '[8081, 8081, "HTTP", "HTTP"] in update_listeners.elb.listeners' - - update_listeners.elb.listeners|length == 2 - - - name: Get ELB info after adding listeners - amazon.aws.elb_classic_lb_info: - names: '{{ elb_name }}' - register: info - - - ansible.builtin.assert: - that: - - elb.listener_descriptions|length == 2 - - '{"instance_port": 81, "instance_protocol": "HTTP", "load_balancer_port": - 80, "protocol": "HTTP"} == listeners[0]' - - '{"instance_port": 8081, "instance_protocol": "HTTP", "load_balancer_port": - 8081, "protocol": "HTTP"} == listeners[1]' - vars: - elb: '{{ info.elbs[0] }}' - listeners: "{{ elb.listener_descriptions|map(attribute='listener')|sort(attribute='load_balancer_port') - }}" + - name: Add Listeners + amazon.aws.elb_classic_lb: + name: "{{ elb_name }}" + state: present + zones: + - "{{ aws_region }}a" + - "{{ aws_region }}b" + - "{{ aws_region }}c" + listeners: + - protocol: http + load_balancer_port: 8081 + instance_port: 8081 + purge_listeners: false + register: update_listeners + + - ansible.builtin.assert: + that: + - update_listeners is changed + - '[80, 81, "HTTP", "HTTP"] in update_listeners.elb.listeners' + - '[8081, 8081, "HTTP", "HTTP"] in update_listeners.elb.listeners' + - update_listeners.elb.listeners|length == 2 + + - name: Get ELB info after adding listeners + amazon.aws.elb_classic_lb_info: + names: "{{ elb_name }}" + register: info + + - ansible.builtin.assert: + that: + - elb.listener_descriptions|length == 2 + - '{"instance_port": 81, "instance_protocol": "HTTP", "load_balancer_port": 80, "protocol": "HTTP"} == listeners[0]' + - '{"instance_port": 8081, "instance_protocol": "HTTP", "load_balancer_port": 8081, "protocol": "HTTP"} == listeners[1]' + vars: + elb: "{{ info.elbs[0] }}" + listeners: "{{ elb.listener_descriptions | map(attribute='listener') | sort(attribute='load_balancer_port') }}" # ============================================================ # Test getting nonexistent load balancer - - name: get nonexistent load balancer - amazon.aws.elb_classic_lb_info: - names: invalid-elb - register: info + - name: Get nonexistent load balancer + amazon.aws.elb_classic_lb_info: + names: invalid-elb + register: info - - ansible.builtin.assert: - that: - - info.elbs|length==0 + - ansible.builtin.assert: + that: + - info.elbs|length==0 # Test getting a valid and nonexistent load balancer - - name: get nonexistent load balancer - amazon.aws.elb_classic_lb_info: - names: ['{{ elb_name }}', invalid-elb] - register: info + - name: Get nonexistent load balancer + amazon.aws.elb_classic_lb_info: + names: ["{{ elb_name }}", invalid-elb] + register: info - - ansible.builtin.assert: - that: - - info.elbs|length==1 - - info.elbs[0].load_balancer_name == elb_name + - ansible.builtin.assert: + that: + - info.elbs|length==1 + - info.elbs[0].load_balancer_name == elb_name # ============================================================ - - name: get all load balancers - amazon.aws.elb_classic_lb_info: - names: '{{ omit }}' - register: info + - name: Get all load balancers + amazon.aws.elb_classic_lb_info: + names: "{{ omit }}" + register: info - - ansible.builtin.assert: - that: - - info.elbs|length>0 + - ansible.builtin.assert: + that: + - info.elbs|length>0 always: - # ============================================================ - - name: remove the test load balancer completely - amazon.aws.elb_classic_lb: - name: '{{ elb_name }}' - state: absent - register: result - ignore_errors: true + - name: Remove the test load balancer completely + amazon.aws.elb_classic_lb: + name: "{{ elb_name }}" + state: absent + register: result + ignore_errors: true diff --git a/tests/integration/targets/iam_instance_profile/tasks/main.yml b/tests/integration/targets/iam_instance_profile/tasks/main.yml index f8c62e91163..ca0a1d2bcd2 100644 --- a/tests/integration/targets/iam_instance_profile/tasks/main.yml +++ b/tests/integration/targets/iam_instance_profile/tasks/main.yml @@ -301,7 +301,7 @@ - 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}}' + complex_profile: '{{ profile_info.iam_instance_profiles | selectattr("instance_profile_name", "match", test_profile_complex) | first }}' - name: List all Instance Profiles (filter by path) amazon.aws.iam_instance_profile_info: @@ -334,7 +334,7 @@ - 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}}' + complex_profile: '{{ profile_info.iam_instance_profiles | selectattr("instance_profile_name", "match", test_profile_complex) | first }}' - name: List all Instance Profiles (filter by name - complex) amazon.aws.iam_instance_profile_info: @@ -369,7 +369,7 @@ - complex_profile.roles[0].tags == {} 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}}' + complex_profile: '{{ profile_info.iam_instance_profiles | selectattr("instance_profile_name", "match", test_profile_complex) | first }}' - name: List an Instance Profile (filter by name) amazon.aws.iam_instance_profile_info: diff --git a/tests/integration/targets/iam_instance_profile/tasks/tags.yml b/tests/integration/targets/iam_instance_profile/tasks/tags.yml index 15aa70382aa..851f8076fda 100644 --- a/tests/integration/targets/iam_instance_profile/tasks/tags.yml +++ b/tests/integration/targets/iam_instance_profile/tasks/tags.yml @@ -41,22 +41,22 @@ register: tag_profile check_mode: true - - name: assert would change + - name: Assert would change ansible.builtin.assert: that: - tag_profile is changed - - name: add tags + - name: Add tags amazon.aws.iam_instance_profile: tags: "{{ first_tags }}" state: present register: tag_profile - - name: get instance profile facts + - name: Get instance profile facts amazon.aws.iam_instance_profile_info: {} register: tag_profile_info - - name: verify the tags were added + - name: Verify the tags were added ansible.builtin.assert: that: - tag_profile is changed @@ -70,21 +70,21 @@ register: tag_profile check_mode: true - - name: assert would not change + - name: Assert would not change ansible.builtin.assert: that: - tag_profile is not changed - - name: add tags - IDEMPOTENCY + - name: Add tags - IDEMPOTENCY amazon.aws.iam_instance_profile: tags: "{{ first_tags }}" state: present register: tag_profile - - name: get instance profile facts + - name: Get instance profile facts amazon.aws.iam_instance_profile_info: {} register: tag_profile_info - - name: verify no change + - name: Verify no change ansible.builtin.assert: that: - tag_profile is not changed @@ -100,21 +100,21 @@ register: tag_profile check_mode: true - - name: assert would change + - name: Assert would change ansible.builtin.assert: that: - tag_profile is changed - - name: modify tags with purge + - name: Modify tags with purge amazon.aws.iam_instance_profile: tags: "{{ second_tags }}" state: present register: tag_profile - - name: get instance profile facts + - name: Get instance profile facts amazon.aws.iam_instance_profile_info: register: tag_profile_info - - name: verify the tags were added + - name: Verify the tags were added ansible.builtin.assert: that: - tag_profile is changed @@ -128,21 +128,21 @@ register: tag_profile check_mode: true - - name: assert would not change + - name: Assert would not change ansible.builtin.assert: that: - tag_profile is not changed - - name: modify tags with purge - IDEMPOTENCY + - name: Modify tags with purge - IDEMPOTENCY amazon.aws.iam_instance_profile: tags: "{{ second_tags }}" state: present register: tag_profile - - name: get instance profile facts + - name: Get instance profile facts amazon.aws.iam_instance_profile_info: register: tag_profile_info - - name: verify no change + - name: Verify no change ansible.builtin.assert: that: - tag_profile is not changed @@ -159,22 +159,22 @@ register: tag_profile check_mode: true - - name: assert would change + - name: Assert would change ansible.builtin.assert: that: - tag_profile is changed - - name: modify tags without purge + - name: Modify tags without purge amazon.aws.iam_instance_profile: tags: "{{ third_tags }}" state: present purge_tags: false register: tag_profile - - name: get instance profile facts + - name: Get instance profile facts amazon.aws.iam_instance_profile_info: register: tag_profile_info - - name: verify the tags were added + - name: Verify the tags were added ansible.builtin.assert: that: - tag_profile is changed @@ -189,22 +189,22 @@ register: tag_profile check_mode: true - - name: assert would not change + - name: Assert would not change ansible.builtin.assert: that: - tag_profile is not changed - - name: modify tags without purge - IDEMPOTENCY + - name: Modify tags without purge - IDEMPOTENCY amazon.aws.iam_instance_profile: tags: "{{ third_tags }}" state: present purge_tags: false register: tag_profile - - name: get instance profile facts + - name: Get instance profile facts amazon.aws.iam_instance_profile_info: register: tag_profile_info - - name: verify no change + - name: Verify no change ansible.builtin.assert: that: - tag_profile is not changed @@ -219,7 +219,7 @@ register: tag_profile check_mode: true - - name: assert would change + - name: Assert would change ansible.builtin.assert: that: - tag_profile is not changed @@ -228,11 +228,11 @@ amazon.aws.iam_instance_profile: state: present register: tag_profile - - name: get instance profile facts + - name: Get instance profile facts amazon.aws.iam_instance_profile_info: register: tag_profile_info - - name: verify the tags were added + - name: Verify the tags were added ansible.builtin.assert: that: - tag_profile is not changed @@ -248,21 +248,21 @@ register: tag_profile check_mode: true - - name: assert would change + - name: Assert would change ansible.builtin.assert: that: - tag_profile is changed - - name: remove all tags + - name: Remove all tags amazon.aws.iam_instance_profile: tags: {} state: present register: tag_profile - - name: get instance profile facts + - name: Get instance profile facts amazon.aws.iam_instance_profile_info: register: tag_profile_info - - name: verify the tags were added + - name: Verify the tags were added ansible.builtin.assert: that: - tag_profile is changed @@ -276,21 +276,21 @@ register: tag_profile check_mode: true - - name: assert would not change + - name: Assert would not change ansible.builtin.assert: that: - tag_profile is not changed - - name: remove all tags - IDEMPOTENCY + - name: Remove all tags - IDEMPOTENCY amazon.aws.iam_instance_profile: tags: {} state: present register: tag_profile - - name: get instance profile + - name: Get instance profile amazon.aws.iam_instance_profile_info: register: tag_profile_info - - name: verify no change + - name: Verify no change ansible.builtin.assert: that: - tag_profile is not changed diff --git a/tests/integration/targets/iam_managed_policy/tasks/main.yml b/tests/integration/targets/iam_managed_policy/tasks/main.yml index 6449ac3793a..65344c2df02 100644 --- a/tests/integration/targets/iam_managed_policy/tasks/main.yml +++ b/tests/integration/targets/iam_managed_policy/tasks/main.yml @@ -75,7 +75,7 @@ - name: Store policy_id ansible.builtin.set_fact: - managed_policy_id: '{{ result.policy.policy_id }}' + managed_policy_id: "{{ result.policy.policy_id }}" - name: Create IAM managed policy - idempotency check amazon.aws.iam_managed_policy: @@ -254,7 +254,7 @@ - result.policy.policy_id == managed_policy_id - name: Run tagging tests - ansible.builtin.include_tasks: 'tags.yml' + ansible.builtin.include_tasks: "tags.yml" ## Test policy deletion - name: Delete IAM managed policy - check mode @@ -385,7 +385,7 @@ - name: Store new policy_id ansible.builtin.set_fact: - managed_policy_id: '{{ result.policy.policy_id }}' + managed_policy_id: "{{ result.policy.policy_id }}" - name: Create complex IAM managed policy - idempotency check - check mode amazon.aws.iam_managed_policy: diff --git a/tests/integration/targets/iam_password_policy/tasks/main.yaml b/tests/integration/targets/iam_password_policy/tasks/main.yaml index f2315df5eca..f0e452c56b6 100644 --- a/tests/integration/targets/iam_password_policy/tasks/main.yaml +++ b/tests/integration/targets/iam_password_policy/tasks/main.yaml @@ -6,7 +6,7 @@ session_token: "{{ security_token | default(omit) }}" region: "{{ aws_region }}" block: - - name: set iam password policy + - name: Set iam password policy amazon.aws.iam_password_policy: state: present min_pw_length: 8 @@ -20,12 +20,12 @@ pw_expire: false register: result - - name: assert that changes were made + - name: Assert that changes were made ansible.builtin.assert: that: - result.changed - - name: verify iam password policy has been created + - name: Verify iam password policy has been created amazon.aws.iam_password_policy: state: present min_pw_length: 8 @@ -39,12 +39,12 @@ pw_expire: false register: result - - name: assert that no changes were made + - name: Assert that no changes were made ansible.builtin.assert: that: - not result.changed - - name: update iam password policy with different settings + - name: Update iam password policy with different settings amazon.aws.iam_password_policy: state: present min_pw_length: 15 @@ -58,13 +58,13 @@ pw_expire: true register: result - - name: assert that updates were made + - name: Assert that updates were made ansible.builtin.assert: that: - result.changed # Test for regression of #59102 - - name: update iam password policy without expiry + - name: Update iam password policy without expiry amazon.aws.iam_password_policy: state: present min_pw_length: 15 @@ -75,32 +75,32 @@ allow_pw_change: true register: result - - name: assert that changes were made + - name: Assert that changes were made ansible.builtin.assert: that: - result.changed - - name: remove iam password policy + - name: Remove iam password policy amazon.aws.iam_password_policy: state: absent register: result - - name: assert password policy has been removed + - name: Assert password policy has been removed ansible.builtin.assert: that: - result.changed - - name: verify password policy has been removed + - name: Verify password policy has been removed amazon.aws.iam_password_policy: state: absent register: result - - name: assert no changes were made + - name: Assert no changes were made ansible.builtin.assert: that: - not result.changed always: - - name: remove iam password policy + - name: Remove iam password policy amazon.aws.iam_password_policy: state: absent register: result diff --git a/tests/integration/targets/iam_policy/defaults/main.yml b/tests/integration/targets/iam_policy/defaults/main.yml index 3fce47703ff..1ef04a1d76a 100644 --- a/tests/integration/targets/iam_policy/defaults/main.yml +++ b/tests/integration/targets/iam_policy/defaults/main.yml @@ -1,6 +1,6 @@ --- -iam_name: "{{resource_prefix}}" -iam_policy_name_a: "{{resource_prefix}}-document-a" -iam_policy_name_b: "{{resource_prefix}}-document-b" -iam_policy_name_c: "{{resource_prefix}}-json-a" -iam_policy_name_d: "{{resource_prefix}}-json-b" +iam_name: "{{ resource_prefix }}" +iam_policy_name_a: "{{ resource_prefix }}-document-a" +iam_policy_name_b: "{{ resource_prefix }}-document-b" +iam_policy_name_c: "{{ resource_prefix }}-json-a" +iam_policy_name_d: "{{ resource_prefix }}-json-b" diff --git a/tests/integration/targets/iam_policy/tasks/main.yml b/tests/integration/targets/iam_policy/tasks/main.yml index afae59a0ea8..f92362f4703 100644 --- a/tests/integration/targets/iam_policy/tasks/main.yml +++ b/tests/integration/targets/iam_policy/tasks/main.yml @@ -22,7 +22,7 @@ amazon.aws.iam_role: state: present name: "{{ iam_name }}" - assume_role_policy_document: "{{ lookup('file','no_trust.json') }}" + assume_role_policy_document: "{{ lookup('file', 'no_trust.json') }}" register: result - name: Ensure role was created ansible.builtin.assert: diff --git a/tests/integration/targets/iam_policy/tasks/object.yml b/tests/integration/targets/iam_policy/tasks/object.yml index 0d460753627..82f173abb5b 100644 --- a/tests/integration/targets/iam_policy/tasks/object.yml +++ b/tests/integration/targets/iam_policy/tasks/object.yml @@ -1,15 +1,15 @@ --- -- name: Run integration tests for IAM (inline) Policy management on {{ iam_type }}s +- name: Run integration tests for IAM (inline) Policy management on {{ iam_type }} vars: iam_object_key: "{{ iam_type }}_name" block: # ============================================================ - - name: Fetch policies from {{ iam_type }} before making changes + - name: Fetch policies from resource before making changes | {{ iam_type }} amazon.aws.iam_policy_info: iam_type: "{{ iam_type }}" iam_name: "{{ iam_name }}" register: iam_policy_info - - name: Assert empty policy list + - name: Assert empty policy list | {{ iam_type }} ansible.builtin.assert: that: - iam_policy_info is succeeded @@ -17,18 +17,18 @@ - iam_policy_info.all_policy_names | length == 0 - iam_policy_info.policy_names | length == 0 - - name: Fetch policies from non-existent {{ iam_type }} + - name: Fetch policies from non-existent resource | {{ iam_type }} amazon.aws.iam_policy_info: iam_type: "{{ iam_type }}" iam_name: "{{ iam_name }}-junk" register: iam_policy_info - - name: Assert not failed + - name: Assert not failed | {{ iam_type }} ansible.builtin.assert: that: - iam_policy_info is succeeded # ============================================================ - - name: Invalid creation of policy for {{ iam_type }} - missing required parameters + - name: Invalid creation of policy for resource - missing required parameters | {{ iam_type }} amazon.aws.iam_policy: state: present iam_type: "{{ iam_type }}" @@ -37,13 +37,13 @@ skip_duplicates: true register: result ignore_errors: true - - name: Assert task failed with correct error message + - name: Assert task failed with correct error message | {{ iam_type }} ansible.builtin.assert: that: - result.failed - "'state is present but any of the following are missing: policy_json' in result.msg" - - name: Create policy using document for {{ iam_type }} (check mode) + - name: Create policy using document for resource (check mode) | {{ iam_type }} check_mode: true amazon.aws.iam_policy: state: present @@ -53,12 +53,12 @@ policy_json: '{{ lookup("file", "no_access.json") }}' skip_duplicates: true register: result - - name: Assert policy would be added for {{ iam_type }} + - name: Assert policy would be added for resource | {{ iam_type }} ansible.builtin.assert: that: - result is changed - - name: Create policy using document for {{ iam_type }} + - name: Create policy using document for resource | {{ iam_type }} amazon.aws.iam_policy: state: present iam_type: "{{ iam_type }}" @@ -71,7 +71,7 @@ iam_type: "{{ iam_type }}" iam_name: "{{ iam_name }}" register: iam_policy_info - - name: Assert policy was added for {{ iam_type }} + - name: Assert policy was added for resource | {{ iam_type }} ansible.builtin.assert: that: - result is changed @@ -86,7 +86,7 @@ - iam_policy_info.policies[0].policy_name == iam_policy_name_a - '"Id" not in iam_policy_info.policies[0].policy_document' - - name: Create policy using document for {{ iam_type }} (idempotency - check mode) + - name: Create policy using document for resource (idempotency - check mode) | {{ iam_type }} amazon.aws.iam_policy: state: present iam_type: "{{ iam_type }}" @@ -96,12 +96,12 @@ skip_duplicates: true register: result check_mode: true - - name: Assert no change would occur + - name: Assert no change would occur | {{ iam_type }} ansible.builtin.assert: that: - result is not changed - - name: Create policy using document for {{ iam_type }} (idempotency) + - name: Create policy using document for resource (idempotency) | {{ iam_type }} amazon.aws.iam_policy: state: present iam_type: "{{ iam_type }}" @@ -114,7 +114,7 @@ iam_type: "{{ iam_type }}" iam_name: "{{ iam_name }}" register: iam_policy_info - - name: Assert no change + - name: Assert no change | {{ iam_type }} ansible.builtin.assert: that: - result is not changed @@ -128,7 +128,7 @@ - '"Id" not in iam_policy_info.policies[0].policy_document' # ============================================================ - - name: Create policy using document for {{ iam_type }} (check mode) (skip_duplicates) + - name: Create policy using document for resource (check mode) (skip_duplicates) | {{ iam_type }} check_mode: true amazon.aws.iam_policy: state: present @@ -143,7 +143,7 @@ iam_name: "{{ iam_name }}" policy_name: "{{ iam_policy_name_b }}" register: iam_policy_info - - name: Assert policy would be added for {{ iam_type }} + - name: Assert policy would be added for resource | {{ iam_type }} ansible.builtin.assert: that: - result is not changed @@ -151,7 +151,7 @@ - '"policies" not in iam_policy_info' - iam_policy_name_b not in iam_policy_info.all_policy_names - - name: Create policy using document for {{ iam_type }} (skip_duplicates) + - name: Create policy using document for resource (skip_duplicates) | {{ iam_type }} amazon.aws.iam_policy: state: present iam_type: "{{ iam_type }}" @@ -165,7 +165,7 @@ iam_name: "{{ iam_name }}" policy_name: "{{ iam_policy_name_b }}" register: iam_policy_info - - name: Assert policy was not added for {{ iam_type }} (skip_duplicates) + - name: Assert policy was not added for resource (skip_duplicates) | {{ iam_type }} ansible.builtin.assert: that: - result is not changed @@ -177,7 +177,7 @@ - iam_policy_info.all_policy_names | length == 1 - iam_policy_name_b not in iam_policy_info.all_policy_names - - name: Create policy using document for {{ iam_type }} (check mode) (skip_duplicates = no) + - name: Create policy using document for resource (check mode) (skip_duplicates = no) | {{ iam_type }} check_mode: true amazon.aws.iam_policy: state: present @@ -192,7 +192,7 @@ iam_name: "{{ iam_name }}" policy_name: "{{ iam_policy_name_b }}" register: iam_policy_info - - name: Assert policy would be added for {{ iam_type }} + - name: Assert policy would be added for resource | {{ iam_type }} ansible.builtin.assert: that: - result.changed == True @@ -201,7 +201,7 @@ - iam_policy_name_a in iam_policy_info.all_policy_names - iam_policy_name_b not in iam_policy_info.all_policy_names - - name: Create policy using document for {{ iam_type }} (skip_duplicates = no) + - name: Create policy using document for resource (skip_duplicates = no) | {{ iam_type }} amazon.aws.iam_policy: state: present skip_duplicates: false @@ -215,7 +215,7 @@ iam_name: "{{ iam_name }}" policy_name: "{{ iam_policy_name_b }}" register: iam_policy_info - - name: Assert policy was added for {{ iam_type }} + - name: Assert policy was added for resource | {{ iam_type }} ansible.builtin.assert: that: - result is changed @@ -229,7 +229,7 @@ - iam_policy_info.policies[0].policy_name == iam_policy_name_b - '"Id" not in iam_policy_info.policies[0].policy_document' - - name: Create policy using document for {{ iam_type }} (idempotency - check mode) (skip_duplicates = no) + - name: Create policy using document for resource (idempotency - check mode) (skip_duplicates = no) | {{ iam_type }} amazon.aws.iam_policy: state: present skip_duplicates: false @@ -239,12 +239,12 @@ policy_json: '{{ lookup("file", "no_access.json") }}' register: result check_mode: true - - name: Assert no change would occur + - name: Assert no change would occur | {{ iam_type }} ansible.builtin.assert: that: - result is not changed - - name: Create policy using document for {{ iam_type }} (idempotency) (skip_duplicates = no) + - name: Create policy using document for resource (idempotency) (skip_duplicates = no) | {{ iam_type }} amazon.aws.iam_policy: state: present skip_duplicates: false @@ -258,7 +258,7 @@ iam_name: "{{ iam_name }}" policy_name: "{{ iam_policy_name_b }}" register: iam_policy_info - - name: Assert no change + - name: Assert no change | {{ iam_type }} ansible.builtin.assert: that: - result is not changed @@ -273,7 +273,7 @@ - '"Id" not in iam_policy_info.policies[0].policy_document' # ============================================================ - - name: Create policy using json for {{ iam_type }} (check mode) + - name: Create policy using json for resource (check mode) | {{ iam_type }} check_mode: true amazon.aws.iam_policy: state: present @@ -288,7 +288,7 @@ iam_name: "{{ iam_name }}" policy_name: "{{ iam_policy_name_c }}" register: iam_policy_info - - name: Assert policy would be added for {{ iam_type }} + - name: Assert policy would be added for resource | {{ iam_type }} ansible.builtin.assert: that: - result is changed @@ -298,7 +298,7 @@ - iam_policy_name_a in iam_policy_info.all_policy_names - iam_policy_name_b in iam_policy_info.all_policy_names - - name: Create policy using json for {{ iam_type }} + - name: Create policy using json for resource | {{ iam_type }} amazon.aws.iam_policy: state: present iam_type: "{{ iam_type }}" @@ -312,7 +312,7 @@ iam_name: "{{ iam_name }}" policy_name: "{{ iam_policy_name_c }}" register: iam_policy_info - - name: Assert policy was added for {{ iam_type }} + - name: Assert policy was added for resource | {{ iam_type }} ansible.builtin.assert: that: - result is changed @@ -327,7 +327,7 @@ - iam_policy_info.policies[0].policy_name == iam_policy_name_c - iam_policy_info.policies[0].policy_document.Id == 'MyId' - - name: Create policy using json for {{ iam_type }} (idempotency - check mode) + - name: Create policy using json for resource (idempotency - check mode) | {{ iam_type }} amazon.aws.iam_policy: state: present iam_type: "{{ iam_type }}" @@ -337,12 +337,12 @@ skip_duplicates: true register: result check_mode: true - - name: Assert no change would occur + - name: Assert no change would occur | {{ iam_type }} ansible.builtin.assert: that: - result is not changed - - name: Create policy using json for {{ iam_type }} (idempotency) + - name: Create policy using json for resource (idempotency) | {{ iam_type }} amazon.aws.iam_policy: state: present iam_type: "{{ iam_type }}" @@ -356,7 +356,7 @@ iam_name: "{{ iam_name }}" policy_name: "{{ iam_policy_name_c }}" register: iam_policy_info - - name: Assert no change + - name: Assert no change | {{ iam_type }} ansible.builtin.assert: that: - result is not changed @@ -371,7 +371,7 @@ - iam_policy_info.policies[0].policy_document.Id == 'MyId' # ============================================================ - - name: Create policy using json for {{ iam_type }} (check mode) (skip_duplicates) + - name: Create policy using json for resource (check mode) (skip_duplicates) | {{ iam_type }} check_mode: true amazon.aws.iam_policy: state: present @@ -386,7 +386,7 @@ iam_name: "{{ iam_name }}" policy_name: "{{ iam_policy_name_d }}" register: iam_policy_info - - name: Assert policy would not be added for {{ iam_type }} + - name: Assert policy would not be added for resource | {{ iam_type }} ansible.builtin.assert: that: - result is not changed @@ -397,7 +397,7 @@ - iam_policy_info.all_policy_names | length == 3 - '"policies" not in iam_policy_info' - - name: Create policy using json for {{ iam_type }} (skip_duplicates) + - name: Create policy using json for resource (skip_duplicates) | {{ iam_type }} amazon.aws.iam_policy: state: present iam_type: "{{ iam_type }}" @@ -411,7 +411,7 @@ iam_name: "{{ iam_name }}" policy_name: "{{ iam_policy_name_d }}" register: iam_policy_info - - name: Assert policy was not added for {{ iam_type }} (skip_duplicates) + - name: Assert policy was not added for resource (skip_duplicates) | {{ iam_type }} ansible.builtin.assert: that: - result is not changed @@ -425,7 +425,7 @@ - iam_policy_info.all_policy_names | length == 3 - '"policies" not in iam_policy_info' - - name: Create policy using json for {{ iam_type }} (check mode) (skip_duplicates = no) + - name: Create policy using json for resource (check mode) (skip_duplicates = no) | {{ iam_type }} check_mode: true amazon.aws.iam_policy: state: present @@ -440,12 +440,12 @@ iam_name: "{{ iam_name }}" policy_name: "{{ iam_policy_name_d }}" register: iam_policy_info - - name: Assert policy would be added for {{ iam_type }} + - name: Assert policy would be added for resource | {{ iam_type }} ansible.builtin.assert: that: - result.changed == True - - name: Create policy using json for {{ iam_type }} (skip_duplicates = no) + - name: Create policy using json for resource (skip_duplicates = no) | {{ iam_type }} amazon.aws.iam_policy: state: present skip_duplicates: false @@ -459,7 +459,7 @@ iam_name: "{{ iam_name }}" policy_name: "{{ iam_policy_name_d }}" register: iam_policy_info - - name: Assert policy was added for {{ iam_type }} + - name: Assert policy was added for resource | {{ iam_type }} ansible.builtin.assert: that: - result is changed @@ -479,7 +479,7 @@ - iam_policy_info.policies[0].policy_name == iam_policy_name_d - iam_policy_info.policies[0].policy_document.Id == 'MyId' - - name: Create policy using json for {{ iam_type }} (idempotency - check mode) (skip_duplicates = no) + - name: Create policy using json for resource (idempotency - check mode) (skip_duplicates = no) | {{ iam_type }} amazon.aws.iam_policy: state: present skip_duplicates: false @@ -489,12 +489,12 @@ policy_json: '{{ lookup("file", "no_access_with_id.json") }}' register: result check_mode: true - - name: Assert no change would occur + - name: Assert no change would occur | {{ iam_type }} ansible.builtin.assert: that: - result is not changed - - name: Create policy using json for {{ iam_type }} (idempotency) (skip_duplicates = no) + - name: Create policy using json for resource (idempotency) (skip_duplicates = no) | {{ iam_type }} amazon.aws.iam_policy: state: present skip_duplicates: false @@ -508,7 +508,7 @@ iam_name: "{{ iam_name }}" policy_name: "{{ iam_policy_name_d }}" register: iam_policy_info - - name: Assert no change + - name: Assert no change | {{ iam_type }} ansible.builtin.assert: that: - result is not changed @@ -524,12 +524,12 @@ - iam_policy_info.policies[0].policy_document.Id == 'MyId' # ============================================================ - - name: Test fetching multiple policies from {{ iam_type }} + - name: Test fetching multiple policies from resource | {{ iam_type }} amazon.aws.iam_policy_info: iam_type: "{{ iam_type }}" iam_name: "{{ iam_name }}" register: iam_policy_info - - name: Assert all policies returned + - name: Assert all policies returned | {{ iam_type }} ansible.builtin.assert: that: - iam_policy_info is succeeded @@ -546,7 +546,7 @@ - iam_policy_name_d in (iam_policy_info.policies | community.general.json_query('[?policy_document.Id == `MyId`].policy_name') | list) # ============================================================ - - name: Update policy using document for {{ iam_type }} (check mode) (skip_duplicates) + - name: Update policy using document for resource (check mode) (skip_duplicates) | {{ iam_type }} check_mode: true amazon.aws.iam_policy: state: present @@ -561,14 +561,14 @@ iam_name: "{{ iam_name }}" policy_name: "{{ iam_policy_name_a }}" register: iam_policy_info - - name: Assert policy would not be added for {{ iam_type }} + - name: Assert policy would not be added for resource | {{ iam_type }} ansible.builtin.assert: that: - result is not changed - iam_policy_info.policies[0].policy_name == iam_policy_name_a - '"Id" not in iam_policy_info.policies[0].policy_document' - - name: Update policy using document for {{ iam_type }} (skip_duplicates) + - name: Update policy using document for resource (skip_duplicates) | {{ iam_type }} amazon.aws.iam_policy: state: present iam_type: "{{ iam_type }}" @@ -582,7 +582,7 @@ iam_name: "{{ iam_name }}" policy_name: "{{ iam_policy_name_a }}" register: iam_policy_info - - name: Assert policy was not updated for {{ iam_type }} (skip_duplicates) + - name: Assert policy was not updated for resource (skip_duplicates) | {{ iam_type }} ansible.builtin.assert: that: - result is not changed @@ -593,7 +593,7 @@ - iam_policy_info.policies[0].policy_name == iam_policy_name_a - '"Id" not in iam_policy_info.policies[0].policy_document' - - name: Update policy using document for {{ iam_type }} (check mode) (skip_duplicates = no) + - name: Update policy using document for resource (check mode) (skip_duplicates = no) | {{ iam_type }} check_mode: true amazon.aws.iam_policy: state: present @@ -608,7 +608,7 @@ iam_name: "{{ iam_name }}" policy_name: "{{ iam_policy_name_a }}" register: iam_policy_info - - name: Assert policy would be updated for {{ iam_type }} + - name: Assert policy would be updated for resource | {{ iam_type }} ansible.builtin.assert: that: - result.changed == True @@ -616,7 +616,7 @@ - iam_policy_info.policies[0].policy_name == iam_policy_name_a - '"Id" not in iam_policy_info.policies[0].policy_document' - - name: Update policy using document for {{ iam_type }} (skip_duplicates = no) + - name: Update policy using document for resource (skip_duplicates = no) | {{ iam_type }} amazon.aws.iam_policy: state: present skip_duplicates: false @@ -630,7 +630,7 @@ iam_name: "{{ iam_name }}" policy_name: "{{ iam_policy_name_a }}" register: iam_policy_info - - name: Assert policy was updated for {{ iam_type }} + - name: Assert policy was updated for resource | {{ iam_type }} ansible.builtin.assert: that: - result is changed @@ -639,7 +639,7 @@ - result[iam_object_key] == iam_name - iam_policy_info.policies[0].policy_document.Id == 'MyId' - - name: Update policy using document for {{ iam_type }} (idempotency - check mode) (skip_duplicates = no) + - name: Update policy using document for resource (idempotency - check mode) (skip_duplicates = no) | {{ iam_type }} amazon.aws.iam_policy: state: present skip_duplicates: false @@ -649,12 +649,12 @@ policy_json: '{{ lookup("file", "no_access_with_id.json") }}' register: result check_mode: true - - name: Assert no change would occur + - name: Assert no change would occur | {{ iam_type }} ansible.builtin.assert: that: - result is not changed - - name: Update policy using document for {{ iam_type }} (idempotency) (skip_duplicates = no) + - name: Update policy using document for resource (idempotency) (skip_duplicates = no) | {{ iam_type }} amazon.aws.iam_policy: state: present skip_duplicates: false @@ -668,7 +668,7 @@ iam_name: "{{ iam_name }}" policy_name: "{{ iam_policy_name_a }}" register: iam_policy_info - - name: Assert no change + - name: Assert no change | {{ iam_type }} ansible.builtin.assert: that: - result is not changed @@ -677,7 +677,7 @@ - result[iam_object_key] == iam_name - iam_policy_info.policies[0].policy_document.Id == 'MyId' - - name: Delete policy A + - name: Delete policy A | {{ iam_type }} amazon.aws.iam_policy: state: absent iam_type: "{{ iam_type }}" @@ -689,7 +689,7 @@ iam_name: "{{ iam_name }}" policy_name: "{{ iam_policy_name_a }}" register: iam_policy_info - - name: Assert deleted + - name: Assert deleted | {{ iam_type }} ansible.builtin.assert: that: - result is changed @@ -704,7 +704,7 @@ # Update C with no_access.json # Delete C - - name: Update policy using json for {{ iam_type }} (check mode) (skip_duplicates) + - name: Update policy using json for resource (check mode) (skip_duplicates) | {{ iam_type }} check_mode: true amazon.aws.iam_policy: state: present @@ -719,13 +719,13 @@ iam_name: "{{ iam_name }}" policy_name: "{{ iam_policy_name_c }}" register: iam_policy_info - - name: Assert policy would not be added for {{ iam_type }} + - name: Assert policy would not be added for resource | {{ iam_type }} ansible.builtin.assert: that: - result is not changed - iam_policy_info.policies[0].policy_document.Id == 'MyId' - - name: Update policy using json for {{ iam_type }} (skip_duplicates) + - name: Update policy using json for resource (skip_duplicates) | {{ iam_type }} amazon.aws.iam_policy: state: present iam_type: "{{ iam_type }}" @@ -739,7 +739,7 @@ iam_name: "{{ iam_name }}" policy_name: "{{ iam_policy_name_c }}" register: iam_policy_info - - name: Assert policy was not updated for {{ iam_type }} (skip_duplicates) + - name: Assert policy was not updated for resource (skip_duplicates) | {{ iam_type }} ansible.builtin.assert: that: - result is not changed @@ -748,7 +748,7 @@ - result[iam_object_key] == iam_name - iam_policy_info.policies[0].policy_document.Id == 'MyId' - - name: Update policy using json for {{ iam_type }} (check mode) (skip_duplicates = no) + - name: Update policy using json for resource (check mode) (skip_duplicates = no) | {{ iam_type }} check_mode: true amazon.aws.iam_policy: state: present @@ -763,13 +763,13 @@ iam_name: "{{ iam_name }}" policy_name: "{{ iam_policy_name_c }}" register: iam_policy_info - - name: Assert policy would be updated for {{ iam_type }} + - name: Assert policy would be updated for resource | {{ iam_type }} ansible.builtin.assert: that: - result.changed == True - iam_policy_info.policies[0].policy_document.Id == 'MyId' - - name: Update policy using json for {{ iam_type }} (skip_duplicates = no) + - name: Update policy using json for resource (skip_duplicates = no) | {{ iam_type }} amazon.aws.iam_policy: state: present skip_duplicates: false @@ -783,7 +783,7 @@ iam_name: "{{ iam_name }}" policy_name: "{{ iam_policy_name_c }}" register: iam_policy_info - - name: Assert policy was updated for {{ iam_type }} + - name: Assert policy was updated for resource | {{ iam_type }} ansible.builtin.assert: that: - result is changed @@ -792,7 +792,7 @@ - result[iam_object_key] == iam_name - '"Id" not in iam_policy_info.policies[0].policy_document' - - name: Update policy using json for {{ iam_type }} (idempotency - check mode) (skip_duplicates = no) + - name: Update policy using json for resource (idempotency - check mode) (skip_duplicates = no) | {{ iam_type }} amazon.aws.iam_policy: state: present skip_duplicates: false @@ -802,12 +802,12 @@ policy_json: '{{ lookup("file", "no_access.json") }}' register: result check_mode: true - - name: Assert no change would occur + - name: Assert no change would occur | {{ iam_type }} ansible.builtin.assert: that: - result is not changed - - name: Update policy using json for {{ iam_type }} (idempotency) (skip_duplicates = no) + - name: Update policy using json for resource (idempotency) (skip_duplicates = no) | {{ iam_type }} amazon.aws.iam_policy: state: present skip_duplicates: false @@ -821,7 +821,7 @@ iam_name: "{{ iam_name }}" policy_name: "{{ iam_policy_name_c }}" register: iam_policy_info - - name: Assert no change + - name: Assert no change | {{ iam_type }} ansible.builtin.assert: that: - result is not changed @@ -830,7 +830,7 @@ - result[iam_object_key] == iam_name - '"Id" not in iam_policy_info.policies[0].policy_document' - - name: Delete policy C + - name: Delete policy C | {{ iam_type }} amazon.aws.iam_policy: state: absent iam_type: "{{ iam_type }}" @@ -842,7 +842,7 @@ iam_name: "{{ iam_name }}" policy_name: "{{ iam_policy_name_c }}" register: iam_policy_info - - name: Assert deleted + - name: Assert deleted | {{ iam_type }} ansible.builtin.assert: that: - result is changed @@ -854,7 +854,7 @@ - iam_policy_name_c not in iam_policy_info.all_policy_names # ============================================================ - - name: Update policy using document for {{ iam_type }} (check mode) + - name: Update policy using document for resource (check mode) | {{ iam_type }} check_mode: true amazon.aws.iam_policy: state: present @@ -868,13 +868,13 @@ iam_name: "{{ iam_name }}" policy_name: "{{ iam_policy_name_b }}" register: iam_policy_info - - name: Assert policy would be updated for {{ iam_type }} + - name: Assert policy would be updated for resource | {{ iam_type }} ansible.builtin.assert: that: - result.changed == True - '"Id" not in iam_policy_info.policies[0].policy_document' - - name: Update policy using document for {{ iam_type }} + - name: Update policy using document for resource | {{ iam_type }} amazon.aws.iam_policy: state: present iam_type: "{{ iam_type }}" @@ -887,7 +887,7 @@ iam_name: "{{ iam_name }}" policy_name: "{{ iam_policy_name_b }}" register: iam_policy_info - - name: Assert policy was updated for {{ iam_type }} + - name: Assert policy was updated for resource | {{ iam_type }} ansible.builtin.assert: that: - result is changed @@ -896,7 +896,7 @@ - result[iam_object_key] == iam_name - iam_policy_info.policies[0].policy_document.Id == 'MyOtherId' - - name: Update policy using document for {{ iam_type }} (idempotency - check mode) + - name: Update policy using document for resource (idempotency - check mode) | {{ iam_type }} amazon.aws.iam_policy: state: present iam_type: "{{ iam_type }}" @@ -905,12 +905,12 @@ policy_json: '{{ lookup("file", "no_access_with_second_id.json") }}' register: result check_mode: true - - name: Assert no change would occur + - name: Assert no change would occur | {{ iam_type }} ansible.builtin.assert: that: - result is not changed - - name: Update policy using document for {{ iam_type }} (idempotency) + - name: Update policy using document for resource (idempotency) | {{ iam_type }} amazon.aws.iam_policy: state: present iam_type: "{{ iam_type }}" @@ -923,7 +923,7 @@ iam_name: "{{ iam_name }}" policy_name: "{{ iam_policy_name_b }}" register: iam_policy_info - - name: Assert no change + - name: Assert no change | {{ iam_type }} ansible.builtin.assert: that: - result is not changed @@ -932,7 +932,7 @@ - result[iam_object_key] == iam_name - iam_policy_info.policies[0].policy_document.Id == 'MyOtherId' - - name: Delete policy B + - name: Delete policy B | {{ iam_type }} amazon.aws.iam_policy: state: absent iam_type: "{{ iam_type }}" @@ -944,7 +944,7 @@ iam_name: "{{ iam_name }}" policy_name: "{{ iam_policy_name_b }}" register: iam_policy_info - - name: Assert deleted + - name: Assert deleted | {{ iam_type }} ansible.builtin.assert: that: - result is changed @@ -956,7 +956,7 @@ - iam_policy_name_b not in iam_policy_info.all_policy_names # ============================================================ - - name: Update policy using json for {{ iam_type }} (check mode) + - name: Update policy using json for resource (check mode) | {{ iam_type }} check_mode: true amazon.aws.iam_policy: state: present @@ -970,13 +970,13 @@ iam_name: "{{ iam_name }}" policy_name: "{{ iam_policy_name_d }}" register: iam_policy_info - - name: Assert policy would be updated for {{ iam_type }} + - name: Assert policy would be updated for resource | {{ iam_type }} ansible.builtin.assert: that: - result.changed == True - iam_policy_info.policies[0].policy_document.Id == 'MyId' - - name: Update policy using json for {{ iam_type }} + - name: Update policy using json for resource | {{ iam_type }} amazon.aws.iam_policy: state: present iam_type: "{{ iam_type }}" @@ -989,7 +989,7 @@ iam_name: "{{ iam_name }}" policy_name: "{{ iam_policy_name_d }}" register: iam_policy_info - - name: Assert policy was updated for {{ iam_type }} + - name: Assert policy was updated for resource | {{ iam_type }} ansible.builtin.assert: that: - result is changed @@ -998,7 +998,7 @@ - result[iam_object_key] == iam_name - iam_policy_info.policies[0].policy_document.Id == 'MyOtherId' - - name: Update policy using json for {{ iam_type }} (idempotency - check mode) + - name: Update policy using json for resource (idempotency - check mode) | {{ iam_type }} amazon.aws.iam_policy: state: present skip_duplicates: false @@ -1008,12 +1008,12 @@ policy_json: '{{ lookup("file", "no_access_with_second_id.json") }}' register: result check_mode: true - - name: Assert no change would occur + - name: Assert no change would occur | {{ iam_type }} ansible.builtin.assert: that: - result is not changed - - name: Update policy using json for {{ iam_type }} (idempotency) + - name: Update policy using json for resource (idempotency) | {{ iam_type }} amazon.aws.iam_policy: state: present skip_duplicates: false @@ -1027,7 +1027,7 @@ iam_name: "{{ iam_name }}" policy_name: "{{ iam_policy_name_d }}" register: iam_policy_info - - name: Assert no change + - name: Assert no change | {{ iam_type }} ansible.builtin.assert: that: - result is not changed @@ -1037,7 +1037,7 @@ - iam_policy_info.policies[0].policy_document.Id == 'MyOtherId' # ============================================================ - - name: Delete policy D (check_mode) + - name: Delete policy D (check_mode) | {{ iam_type }} check_mode: true amazon.aws.iam_policy: state: absent @@ -1050,7 +1050,7 @@ iam_name: "{{ iam_name }}" policy_name: "{{ iam_policy_name_d }}" register: iam_policy_info - - name: Assert not deleted + - name: Assert not deleted | {{ iam_type }} ansible.builtin.assert: that: - result is changed @@ -1061,7 +1061,7 @@ - iam_policy_name_d in iam_policy_info.all_policy_names - iam_policy_info.policies[0].policy_document.Id == 'MyOtherId' - - name: Delete policy D + - name: Delete policy D | {{ iam_type }} amazon.aws.iam_policy: state: absent iam_type: "{{ iam_type }}" @@ -1073,7 +1073,7 @@ iam_name: "{{ iam_name }}" policy_name: "{{ iam_policy_name_d }}" register: iam_policy_info - - name: Assert deleted + - name: Assert deleted | {{ iam_type }} ansible.builtin.assert: that: - result is changed @@ -1083,7 +1083,7 @@ - '"policies" not in iam_policy_info' - iam_policy_info.all_policy_names | length == 0 - - name: Delete policy D (test idempotency) + - name: Delete policy D (test idempotency) | {{ iam_type }} amazon.aws.iam_policy: state: absent iam_type: "{{ iam_type }}" @@ -1095,14 +1095,14 @@ iam_name: "{{ iam_name }}" policy_name: "{{ iam_policy_name_d }}" register: iam_policy_info - - name: Assert deleted + - name: Assert deleted | {{ iam_type }} ansible.builtin.assert: that: - result is not changed - '"policies" not in iam_policy_info' - iam_policy_info.all_policy_names | length == 0 - - name: Delete policy D (check_mode) (test idempotency) + - name: Delete policy D (check_mode) (test idempotency) | {{ iam_type }} check_mode: true amazon.aws.iam_policy: state: absent @@ -1115,7 +1115,7 @@ iam_name: "{{ iam_name }}" policy_name: "{{ iam_policy_name_d }}" register: iam_policy_info - - name: Assert deleted + - name: Assert deleted | {{ iam_type }} ansible.builtin.assert: that: - result is not changed @@ -1124,28 +1124,28 @@ always: # ============================================================ - - name: Delete policy A for {{ iam_type }} + - name: Delete policy A for resource | {{ iam_type }} amazon.aws.iam_policy: state: absent iam_type: "{{ iam_type }}" iam_name: "{{ iam_name }}" policy_name: "{{ iam_policy_name_a }}" ignore_errors: true - - name: Delete policy B for {{ iam_type }} + - name: Delete policy B for resource | {{ iam_type }} amazon.aws.iam_policy: state: absent iam_type: "{{ iam_type }}" iam_name: "{{ iam_name }}" policy_name: "{{ iam_policy_name_b }}" ignore_errors: true - - name: Delete policy C for {{ iam_type }} + - name: Delete policy C for resource | {{ iam_type }} amazon.aws.iam_policy: state: absent iam_type: "{{ iam_type }}" iam_name: "{{ iam_name }}" policy_name: "{{ iam_policy_name_c }}" ignore_errors: true - - name: Delete policy D for {{ iam_type }} + - name: Delete policy D for resource | {{ iam_type }} amazon.aws.iam_policy: state: absent iam_type: "{{ iam_type }}" diff --git a/tests/integration/targets/iam_role/tasks/boundary_policy.yml b/tests/integration/targets/iam_role/tasks/boundary_policy.yml index f24731f088f..b9e70e8365a 100644 --- a/tests/integration/targets/iam_role/tasks/boundary_policy.yml +++ b/tests/integration/targets/iam_role/tasks/boundary_policy.yml @@ -53,7 +53,7 @@ - iam_role is not changed - iam_role.iam_role.role_name == test_role -- name: iam_role_info after adding boundary policy +- name: Iam_role_info after adding boundary policy amazon.aws.iam_role_info: name: "{{ test_role }}" register: role_info diff --git a/tests/integration/targets/iam_role/tasks/complex_role_creation.yml b/tests/integration/targets/iam_role/tasks/complex_role_creation.yml index e0a33d7ca12..56265ed4540 100644 --- a/tests/integration/targets/iam_role/tasks/complex_role_creation.yml +++ b/tests/integration/targets/iam_role/tasks/complex_role_creation.yml @@ -19,7 +19,7 @@ that: - iam_role is changed -- name: iam_role_info after Complex Role creation in check_mode +- name: Iam_role_info after Complex Role creation in check_mode amazon.aws.iam_role_info: name: "{{ test_role }}" register: role_info @@ -98,7 +98,7 @@ - iam_role is not changed - iam_role.iam_role.role_name == test_role -- name: iam_role_info after Role creation +- name: Iam_role_info after Role creation amazon.aws.iam_role_info: name: "{{ test_role }}" register: role_info diff --git a/tests/integration/targets/iam_role/tasks/creation_deletion.yml b/tests/integration/targets/iam_role/tasks/creation_deletion.yml index 694c4d16b75..148956df5bc 100644 --- a/tests/integration/targets/iam_role/tasks/creation_deletion.yml +++ b/tests/integration/targets/iam_role/tasks/creation_deletion.yml @@ -49,14 +49,14 @@ # =================================================================== # Role Creation # (without Instance profile) -- name: iam_role_info before Role creation (no args) +- name: Iam_role_info before Role creation (no args) amazon.aws.iam_role_info: register: role_info - ansible.builtin.assert: that: - role_info is succeeded -- name: iam_role_info before Role creation (search for test role) +- name: Iam_role_info before Role creation (search for test role) amazon.aws.iam_role_info: name: "{{ test_role }}" register: role_info @@ -75,7 +75,7 @@ that: - iam_role is changed -- name: iam_role_info after Role creation in check_mode +- name: Iam_role_info after Role creation in check_mode amazon.aws.iam_role_info: name: "{{ test_role }}" register: role_info @@ -125,7 +125,7 @@ - iam_role is not changed - iam_role.iam_role.role_name == test_role -- name: iam_role_info after Role creation +- name: Iam_role_info after Role creation amazon.aws.iam_role_info: name: "{{ test_role }}" register: role_info @@ -160,7 +160,7 @@ that: - iam_role is changed -- name: iam_role_info after Role deletion +- name: Iam_role_info after Role deletion amazon.aws.iam_role_info: name: "{{ test_role }}" register: role_info @@ -233,7 +233,7 @@ - iam_role is not changed - iam_role.iam_role.role_name == test_role -- name: iam_role_info after Role creation +- name: Iam_role_info after Role creation amazon.aws.iam_role_info: name: "{{ test_role }}" register: role_info @@ -259,7 +259,7 @@ - role_info.iam_roles[0].role_name == test_role - role_info.iam_roles[0].tags | length == 0 -- name: iam_role_info after Role creation (searching a path) +- name: Iam_role_info after Role creation (searching a path) amazon.aws.iam_role_info: path_prefix: "{{ test_path }}" register: role_info @@ -285,7 +285,7 @@ - role_info.iam_roles[0].role_name == test_role - role_info.iam_roles[0].tags | length == 0 -- name: iam_role_info after Role creation (searching a path without / prefix and suffix) +- name: Iam_role_info after Role creation (searching a path without / prefix and suffix) amazon.aws.iam_role_info: path_prefix: "{{ bad_test_path }}" register: role_info @@ -322,7 +322,7 @@ that: - iam_role is changed -- name: iam_role_info after Role deletion +- name: Iam_role_info after Role deletion amazon.aws.iam_role_info: name: "{{ test_role }}" register: role_info @@ -384,7 +384,7 @@ - iam_role is not changed - iam_role.iam_role.role_name == test_role -- name: iam_role_info after Role creation +- name: Iam_role_info after Role creation amazon.aws.iam_role_info: name: "{{ test_role }}" register: role_info diff --git a/tests/integration/targets/iam_role/tasks/description_update.yml b/tests/integration/targets/iam_role/tasks/description_update.yml index edb88f7ddc9..4ecfe4f0688 100644 --- a/tests/integration/targets/iam_role/tasks/description_update.yml +++ b/tests/integration/targets/iam_role/tasks/description_update.yml @@ -41,7 +41,7 @@ - iam_role.iam_role.role_name == test_role - iam_role.iam_role.description == "Ansible Test Role "+resource_prefix -- name: iam_role_info after adding Description +- name: Iam_role_info after adding Description amazon.aws.iam_role_info: name: "{{ test_role }}" register: role_info @@ -111,7 +111,7 @@ - iam_role.iam_role.role_name == test_role - iam_role.iam_role.description == 'Ansible Test Role (updated) '+resource_prefix -- name: iam_role_info after updating Description +- name: Iam_role_info after updating Description amazon.aws.iam_role_info: name: "{{ test_role }}" register: role_info diff --git a/tests/integration/targets/iam_role/tasks/inline_policy_update.yml b/tests/integration/targets/iam_role/tasks/inline_policy_update.yml index 5b3e424588e..856d6b71354 100644 --- a/tests/integration/targets/iam_role/tasks/inline_policy_update.yml +++ b/tests/integration/targets/iam_role/tasks/inline_policy_update.yml @@ -13,7 +13,7 @@ iam_name: "{{ test_role }}" policy_name: inline-policy-b policy_json: '{{ lookup("file", "deny-all-b.json") }}' -- name: iam_role_info after attaching inline policies (using iam_policy) +- name: Iam_role_info after attaching inline policies (using iam_policy) amazon.aws.iam_role_info: name: "{{ test_role }}" register: role_info diff --git a/tests/integration/targets/iam_role/tasks/instance_profile.yml b/tests/integration/targets/iam_role/tasks/instance_profile.yml index df59d7fbbd2..993f3511611 100644 --- a/tests/integration/targets/iam_role/tasks/instance_profile.yml +++ b/tests/integration/targets/iam_role/tasks/instance_profile.yml @@ -1,5 +1,4 @@ --- - - block: # Ensure profile doesn't already exist (from an old test) - name: Delete Instance Profile @@ -110,7 +109,6 @@ that: - iam_instance_profile.iam_instance_profiles | length == 1 - # Profile does exist, don't delete - name: Remove IAM Role and don't delete profile (with existent profile) amazon.aws.iam_role: diff --git a/tests/integration/targets/iam_role/tasks/main.yml b/tests/integration/targets/iam_role/tasks/main.yml index 2e6ff46e75f..dbb42919784 100644 --- a/tests/integration/targets/iam_role/tasks/main.yml +++ b/tests/integration/targets/iam_role/tasks/main.yml @@ -70,7 +70,7 @@ path: "{{ test_path }}" delete_instance_profile: true ignore_errors: true - - name: iam_role_info after Role deletion + - name: Iam_role_info after Role deletion amazon.aws.iam_role_info: name: "{{ test_role }}" ignore_errors: true diff --git a/tests/integration/targets/iam_role/tasks/max_session_update.yml b/tests/integration/targets/iam_role/tasks/max_session_update.yml index 576e6b24c0b..488689b7e60 100644 --- a/tests/integration/targets/iam_role/tasks/max_session_update.yml +++ b/tests/integration/targets/iam_role/tasks/max_session_update.yml @@ -39,7 +39,7 @@ that: - iam_role is not changed -- name: iam_role_info after updating Max Session Duration +- name: Iam_role_info after updating Max Session Duration amazon.aws.iam_role_info: name: "{{ test_role }}" register: role_info diff --git a/tests/integration/targets/iam_role/tasks/policy_update.yml b/tests/integration/targets/iam_role/tasks/policy_update.yml index 27b911ae7d4..5f32ff01a27 100644 --- a/tests/integration/targets/iam_role/tasks/policy_update.yml +++ b/tests/integration/targets/iam_role/tasks/policy_update.yml @@ -47,7 +47,7 @@ - iam_role is not changed - iam_role.iam_role.role_name == test_role -- name: iam_role_info after adding Managed Policy +- name: Iam_role_info after adding Managed Policy amazon.aws.iam_role_info: name: "{{ test_role }}" register: role_info @@ -127,7 +127,7 @@ - iam_role is not changed - iam_role.iam_role.role_name == test_role -- name: iam_role_info after updating Managed Policy without purge +- name: Iam_role_info after updating Managed Policy without purge amazon.aws.iam_role_info: name: "{{ test_role }}" register: role_info @@ -204,7 +204,7 @@ - iam_role is not changed - iam_role.iam_role.role_name == test_role -- name: iam_role_info after updating Managed Policy with purge +- name: Iam_role_info after updating Managed Policy with purge amazon.aws.iam_role_info: name: "{{ test_role }}" register: role_info diff --git a/tests/integration/targets/iam_role/tasks/role_removal.yml b/tests/integration/targets/iam_role/tasks/role_removal.yml index f4e79252aa1..357a0b9288c 100644 --- a/tests/integration/targets/iam_role/tasks/role_removal.yml +++ b/tests/integration/targets/iam_role/tasks/role_removal.yml @@ -10,7 +10,7 @@ that: - iam_role is changed -- name: iam_role_info after deleting role in check mode +- name: Iam_role_info after deleting role in check mode amazon.aws.iam_role_info: name: "{{ test_role }}" register: role_info @@ -29,7 +29,7 @@ that: - iam_role is changed -- name: iam_role_info after deleting role +- name: Iam_role_info after deleting role amazon.aws.iam_role_info: name: "{{ test_role }}" register: role_info diff --git a/tests/integration/targets/iam_role/tasks/tags_update.yml b/tests/integration/targets/iam_role/tasks/tags_update.yml index 45d703cc1af..f80847e6774 100644 --- a/tests/integration/targets/iam_role/tasks/tags_update.yml +++ b/tests/integration/targets/iam_role/tasks/tags_update.yml @@ -48,7 +48,7 @@ - '"TagA" in iam_role.iam_role.tags' - iam_role.iam_role.tags.TagA == "ValueA" -- name: iam_role_info after adding Tags +- name: Iam_role_info after adding Tags amazon.aws.iam_role_info: name: "{{ test_role }}" register: role_info @@ -126,7 +126,7 @@ - '"TagA" in iam_role.iam_role.tags' - iam_role.iam_role.tags.TagA == "AValue" -- name: iam_role_info after updating Tag +- name: Iam_role_info after updating Tag amazon.aws.iam_role_info: name: "{{ test_role }}" register: role_info @@ -208,7 +208,7 @@ - '"TagB" in iam_role.iam_role.tags' - iam_role.iam_role.tags.TagB == "ValueB" -- name: iam_role_info after adding second Tag without purge +- name: Iam_role_info after adding second Tag without purge amazon.aws.iam_role_info: name: "{{ test_role }}" register: role_info @@ -291,7 +291,7 @@ - '"TagB" in iam_role.iam_role.tags' - iam_role.iam_role.tags.TagB == "ValueB" -- name: iam_role_info after purging first Tag +- name: Iam_role_info after purging first Tag amazon.aws.iam_role_info: name: "{{ test_role }}" register: role_info diff --git a/tests/integration/targets/inventory_aws_ec2/playbooks/create_environment_script.yml b/tests/integration/targets/inventory_aws_ec2/playbooks/create_environment_script.yml index 85dc87122d5..8149cd5998d 100644 --- a/tests/integration/targets/inventory_aws_ec2/playbooks/create_environment_script.yml +++ b/tests/integration/targets/inventory_aws_ec2/playbooks/create_environment_script.yml @@ -1,5 +1,6 @@ --- -- hosts: localhost +- name: Prepare common credentials file + hosts: localhost connection: local gather_facts: false tasks: @@ -7,3 +8,4 @@ ansible.builtin.copy: dest: ../access_key.sh content: export MY_ACCESS_KEY="{{ aws_access_key }}" + mode: "0644" diff --git a/tests/integration/targets/inventory_aws_ec2/playbooks/create_inventory_config.yml b/tests/integration/targets/inventory_aws_ec2/playbooks/create_inventory_config.yml index 282ca43ee86..e7c799d13a3 100644 --- a/tests/integration/targets/inventory_aws_ec2/playbooks/create_inventory_config.yml +++ b/tests/integration/targets/inventory_aws_ec2/playbooks/create_inventory_config.yml @@ -1,16 +1,19 @@ --- -- hosts: 127.0.0.1 +- name: Prepare inventory/ini files for test run + hosts: 127.0.0.1 connection: local gather_facts: false vars: template_name: ../templates/{{ template | default('inventory.yml.j2') }} tasks: - - name: write inventory config file + - name: Write inventory config file ansible.builtin.copy: dest: ../test.aws_ec2.yml content: "{{ lookup('template', template_name) }}" + mode: "0644" - - name: write ini configuration + - name: Write ini configuration ansible.builtin.copy: dest: ../config.ini content: "{{ lookup('template', '../templates/config.ini.j2') }}" + mode: "0644" diff --git a/tests/integration/targets/inventory_aws_ec2/playbooks/empty_inventory_config.yml b/tests/integration/targets/inventory_aws_ec2/playbooks/empty_inventory_config.yml index b2ed5b98ebd..fb731d057c6 100644 --- a/tests/integration/targets/inventory_aws_ec2/playbooks/empty_inventory_config.yml +++ b/tests/integration/targets/inventory_aws_ec2/playbooks/empty_inventory_config.yml @@ -1,9 +1,11 @@ --- -- hosts: 127.0.0.1 +- name: Prepare empty inventory configs + hosts: 127.0.0.1 connection: local gather_facts: false tasks: - - name: write inventory config file + - name: Write inventory config file ansible.builtin.copy: dest: ../test.aws_ec2.yml content: "" + mode: "0644" diff --git a/tests/integration/targets/inventory_aws_ec2/playbooks/manage_ec2_instances.yml b/tests/integration/targets/inventory_aws_ec2/playbooks/manage_ec2_instances.yml index be1b9dc03fa..73700ed8c37 100644 --- a/tests/integration/targets/inventory_aws_ec2/playbooks/manage_ec2_instances.yml +++ b/tests/integration/targets/inventory_aws_ec2/playbooks/manage_ec2_instances.yml @@ -1,5 +1,6 @@ --- -- hosts: 127.0.0.1 +- name: Prepare / Cleanup instances | {{ task }} + hosts: 127.0.0.1 connection: local gather_facts: false diff --git a/tests/integration/targets/inventory_aws_ec2/playbooks/populate_cache.yml b/tests/integration/targets/inventory_aws_ec2/playbooks/populate_cache.yml index f230e544350..4bdef29fd88 100644 --- a/tests/integration/targets/inventory_aws_ec2/playbooks/populate_cache.yml +++ b/tests/integration/targets/inventory_aws_ec2/playbooks/populate_cache.yml @@ -1,5 +1,6 @@ --- -- hosts: 127.0.0.1 +- name: Populate inventory cache and then remove the instance without updating cache + hosts: 127.0.0.1 connection: local gather_facts: false environment: "{{ ansible_test.environment }}" diff --git a/tests/integration/targets/inventory_aws_ec2/playbooks/test_invalid_aws_ec2_inventory_config.yml b/tests/integration/targets/inventory_aws_ec2/playbooks/test_invalid_aws_ec2_inventory_config.yml index 8aec5bc4f1c..00451438c58 100644 --- a/tests/integration/targets/inventory_aws_ec2/playbooks/test_invalid_aws_ec2_inventory_config.yml +++ b/tests/integration/targets/inventory_aws_ec2/playbooks/test_invalid_aws_ec2_inventory_config.yml @@ -1,9 +1,10 @@ --- -- hosts: 127.0.0.1 +- name: Test expected behaviour with bad plugin configuration + hosts: 127.0.0.1 connection: local gather_facts: false tasks: - - name: assert inventory was not populated by aws_ec2 inventory plugin + - name: Assert inventory was not populated by aws_ec2 inventory plugin ansible.builtin.assert: that: - "'aws_ec2' not in groups" diff --git a/tests/integration/targets/inventory_aws_ec2/playbooks/test_inventory_cache.yml b/tests/integration/targets/inventory_aws_ec2/playbooks/test_inventory_cache.yml index b8a36fac58c..da32e48b71c 100644 --- a/tests/integration/targets/inventory_aws_ec2/playbooks/test_inventory_cache.yml +++ b/tests/integration/targets/inventory_aws_ec2/playbooks/test_inventory_cache.yml @@ -1,16 +1,19 @@ --- -- hosts: 127.0.0.1 +# Assumes that a cache was built, then the instances were removed. +- name: Verify cache is updated upon refresh_inventory + hosts: 127.0.0.1 connection: local gather_facts: false tasks: - - name: assert cache was used to populate inventory + - name: Assert cache was used to populate inventory ansible.builtin.assert: that: - "'aws_ec2' in groups" - groups.aws_ec2 | length > 0 + # When we refresh the inventory the cached hosts should be removed - ansible.builtin.meta: refresh_inventory - - name: assert refresh_inventory updated the cache + - name: Assert refresh_inventory updated the cache ansible.builtin.assert: that: - "'aws_ec2' in groups" diff --git a/tests/integration/targets/inventory_aws_ec2/playbooks/test_inventory_ssm.yml b/tests/integration/targets/inventory_aws_ec2/playbooks/test_inventory_ssm.yml index 22c84be35ca..8993607b842 100644 --- a/tests/integration/targets/inventory_aws_ec2/playbooks/test_inventory_ssm.yml +++ b/tests/integration/targets/inventory_aws_ec2/playbooks/test_inventory_ssm.yml @@ -1,5 +1,6 @@ --- -- hosts: 127.0.0.1 +- name: Run inventory test using SSM to suppliment inventory information + hosts: 127.0.0.1 connection: local gather_facts: false environment: "{{ ansible_test.environment }}" @@ -21,7 +22,7 @@ tasks: - block: - ansible.builtin.include_role: - name: ../setup_ec2_facts + name: setup_ec2_facts # Create VPC, subnet, security group, and find image_id to create instance - ansible.builtin.include_tasks: tasks/setup.yml @@ -62,7 +63,7 @@ retries: 18 delay: 10 - - name: validate EC2 ssm-configured instance + - name: Validate EC2 ssm-configured instance ansible.builtin.assert: that: - result.ssm_inventory != {} @@ -82,8 +83,9 @@ # refresh inventory - ansible.builtin.meta: refresh_inventory - - ansible.builtin.debug: var=hostvars - - name: assert hostvars was populated with ssm_inventory information + - ansible.builtin.debug: + var: hostvars + - name: Assert hostvars was populated with ssm_inventory information ansible.builtin.assert: that: - ssm_hostname in hostvars diff --git a/tests/integration/targets/inventory_aws_ec2/playbooks/test_populating_inventory.yml b/tests/integration/targets/inventory_aws_ec2/playbooks/test_populating_inventory.yml index aa16e6d8acd..e50a3c76621 100644 --- a/tests/integration/targets/inventory_aws_ec2/playbooks/test_populating_inventory.yml +++ b/tests/integration/targets/inventory_aws_ec2/playbooks/test_populating_inventory.yml @@ -1,10 +1,11 @@ --- -- hosts: 127.0.0.1 +- name: Perform basic inventory tests + hosts: 127.0.0.1 connection: local gather_facts: false environment: "{{ ansible_test.environment }}" tasks: - - name: assert group was populated with inventory and is no longer empty + - name: Assert group was populated with inventory and is no longer empty ansible.builtin.assert: that: - "'aws_ec2' in groups" diff --git a/tests/integration/targets/inventory_aws_ec2/playbooks/test_populating_inventory_with_concatenation.yml b/tests/integration/targets/inventory_aws_ec2/playbooks/test_populating_inventory_with_concatenation.yml index c94c4cc9be3..5c156060bfc 100644 --- a/tests/integration/targets/inventory_aws_ec2/playbooks/test_populating_inventory_with_concatenation.yml +++ b/tests/integration/targets/inventory_aws_ec2/playbooks/test_populating_inventory_with_concatenation.yml @@ -1,5 +1,6 @@ --- -- hosts: 127.0.0.1 +- name: Run a test using constructed features (concatination) + hosts: 127.0.0.1 connection: local gather_facts: false environment: "{{ ansible_test.environment }}" @@ -13,7 +14,7 @@ block: # Create VPC, subnet, security group, and find image_id to create instance - ansible.builtin.include_tasks: tasks/setup.yml - - name: create a new host + - name: Create a new host amazon.aws.ec2_instance: image_id: "{{ image_id }}" name: "{{ resource_prefix }}" @@ -27,7 +28,7 @@ register: setup_instance - ansible.builtin.meta: refresh_inventory - - name: register the current hostname + - name: Register the current hostname ansible.builtin.set_fact: expected_hostname: value_{{ resource_prefix }} diff --git a/tests/integration/targets/inventory_aws_ec2/playbooks/test_populating_inventory_with_constructed.yml b/tests/integration/targets/inventory_aws_ec2/playbooks/test_populating_inventory_with_constructed.yml index ddaaed982df..4b9a12c74d4 100644 --- a/tests/integration/targets/inventory_aws_ec2/playbooks/test_populating_inventory_with_constructed.yml +++ b/tests/integration/targets/inventory_aws_ec2/playbooks/test_populating_inventory_with_constructed.yml @@ -1,5 +1,6 @@ --- -- hosts: 127.0.0.1 +- name: Run a test using constructed features + hosts: 127.0.0.1 connection: local gather_facts: false environment: "{{ ansible_test.environment }}" @@ -14,7 +15,7 @@ # Create VPC, subnet, security group, and find image_id to create instance - ansible.builtin.include_tasks: tasks/setup.yml - - name: create a new host + - name: Create a new host amazon.aws.ec2_instance: image_id: "{{ image_id }}" name: "{{ resource_prefix }}" @@ -29,15 +30,15 @@ register: setup_instance - ansible.builtin.meta: refresh_inventory - - name: register the keyed sg group name + - name: Register the keyed sg group name ansible.builtin.set_fact: sg_group_name: security_groups_{{ sg_id | replace('-', '_') }} - - name: register one of the keyed tag groups name + - name: Register one of the keyed tag groups name ansible.builtin.set_fact: tag_group_name: tag_Name_{{ resource_prefix | replace('-', '_') }} - - name: assert the keyed groups and groups from constructed config were added to inventory and composite var added to hostvars + - name: Assert the keyed groups and groups from constructed config were added to inventory and composite var added to hostvars ansible.builtin.assert: that: # There are 9 groups: all, ungrouped, aws_ec2, sg keyed group, 3 tag keyed group (one per tag), arch keyed group, constructed group diff --git a/tests/integration/targets/inventory_aws_ec2/playbooks/test_populating_inventory_with_hostnames_using_tags.yml b/tests/integration/targets/inventory_aws_ec2/playbooks/test_populating_inventory_with_hostnames_using_tags.yml index bace813f790..98d51fdc1b0 100644 --- a/tests/integration/targets/inventory_aws_ec2/playbooks/test_populating_inventory_with_hostnames_using_tags.yml +++ b/tests/integration/targets/inventory_aws_ec2/playbooks/test_populating_inventory_with_hostnames_using_tags.yml @@ -1,5 +1,6 @@ --- -- hosts: 127.0.0.1 +- name: Run a test using constructed features (tag/value based groups) + hosts: 127.0.0.1 connection: local gather_facts: false environment: "{{ ansible_test.environment }}" @@ -13,7 +14,7 @@ block: # Create VPC, subnet, security group, and find image_id to create instance - ansible.builtin.include_tasks: tasks/setup.yml - - name: create a new host + - name: Create a new host amazon.aws.ec2_instance: image_id: "{{ image_id }}" name: "{{ resource_prefix }}" @@ -32,7 +33,7 @@ - ansible.builtin.debug: var: groups - - name: assert groups and hostvars were populated with inventory + - name: Assert groups and hostvars were populated with inventory ansible.builtin.assert: that: - "'aws_ec2' in groups" diff --git a/tests/integration/targets/inventory_aws_ec2/playbooks/test_populating_inventory_with_hostnames_using_tags_classic.yml b/tests/integration/targets/inventory_aws_ec2/playbooks/test_populating_inventory_with_hostnames_using_tags_classic.yml index a7ba9defb04..14f85564937 100644 --- a/tests/integration/targets/inventory_aws_ec2/playbooks/test_populating_inventory_with_hostnames_using_tags_classic.yml +++ b/tests/integration/targets/inventory_aws_ec2/playbooks/test_populating_inventory_with_hostnames_using_tags_classic.yml @@ -1,5 +1,6 @@ --- -- hosts: 127.0.0.1 +- name: Run a test using constructed features (tag based groups) + hosts: 127.0.0.1 connection: local gather_facts: false environment: "{{ ansible_test.environment }}" @@ -13,7 +14,7 @@ block: # Create VPC, subnet, security group, and find image_id to create instance - ansible.builtin.include_tasks: tasks/setup.yml - - name: create a new host + - name: Create a new host amazon.aws.ec2_instance: image_id: "{{ image_id }}" name: "{{ resource_prefix }}" @@ -32,7 +33,7 @@ - ansible.builtin.debug: var: groups - - name: assert groups and hostvars were populated with inventory + - name: Assert groups and hostvars were populated with inventory ansible.builtin.assert: that: - "'aws_ec2' in groups" diff --git a/tests/integration/targets/inventory_aws_ec2/playbooks/test_populating_inventory_with_hostnames_with_jinja2_filters.yml b/tests/integration/targets/inventory_aws_ec2/playbooks/test_populating_inventory_with_hostnames_with_jinja2_filters.yml index 8fee67973f7..668fc85fd80 100644 --- a/tests/integration/targets/inventory_aws_ec2/playbooks/test_populating_inventory_with_hostnames_with_jinja2_filters.yml +++ b/tests/integration/targets/inventory_aws_ec2/playbooks/test_populating_inventory_with_hostnames_with_jinja2_filters.yml @@ -1,5 +1,6 @@ --- -- hosts: 127.0.0.1 +- name: Run a test using jinja2 filters in the inventory configuration + hosts: 127.0.0.1 connection: local gather_facts: false environment: "{{ ansible_test.environment }}" @@ -43,7 +44,7 @@ - '"tag1.prod-Ansible" in hostvars' - '"tag2.prod-Ansible" in hostvars' when: - - search_multiple_tags | default(false) | bool + - search_multiple_tags | default(false) | bool - (allow_duplicated_hosts | default(false) | bool) - name: Assert that hostvars contain only 1 hostname (hostnames with multiple tags and allow_duplicated_hosts=false) @@ -52,7 +53,7 @@ - hostvars.keys() | length == 1 - '"tag1.prod-Ansible" in hostvars' when: - - search_multiple_tags | default(false) | bool + - search_multiple_tags | default(false) | bool - not (allow_duplicated_hosts | default(false) | bool) - name: Assert that hostvars contain only 1 hostname (hostnames with single tag) diff --git a/tests/integration/targets/inventory_aws_ec2/playbooks/test_populating_inventory_with_hostvars_prefix_suffix.yml b/tests/integration/targets/inventory_aws_ec2/playbooks/test_populating_inventory_with_hostvars_prefix_suffix.yml index 31ec19c0f67..aa7731de8b6 100644 --- a/tests/integration/targets/inventory_aws_ec2/playbooks/test_populating_inventory_with_hostvars_prefix_suffix.yml +++ b/tests/integration/targets/inventory_aws_ec2/playbooks/test_populating_inventory_with_hostvars_prefix_suffix.yml @@ -1,5 +1,6 @@ --- -- hosts: 127.0.0.1 +- name: Run a test using vars_prefix/vars_suffix + hosts: 127.0.0.1 connection: local gather_facts: false environment: "{{ ansible_test.environment }}" @@ -14,7 +15,7 @@ # Create VPC, subnet, security group, and find image_id to create instance - ansible.builtin.include_tasks: tasks/setup.yml - - name: create a new host + - name: Create a new host amazon.aws.ec2_instance: image_id: "{{ image_id }}" name: "{{ resource_prefix }}_1" @@ -28,7 +29,7 @@ register: setup_instance_1 - ansible.builtin.meta: refresh_inventory - - name: assert the hostvars are defined with prefix and/or suffix + - name: Assert the hostvars are defined with prefix and/or suffix ansible.builtin.assert: that: - hostvars[resource_prefix+'_1'][vars_prefix+'instance_type'+vars_suffix] == 't2.micro' diff --git a/tests/integration/targets/inventory_aws_ec2/playbooks/test_populating_inventory_with_include_or_exclude_filters.yml b/tests/integration/targets/inventory_aws_ec2/playbooks/test_populating_inventory_with_include_or_exclude_filters.yml index a6db5a2eb04..16ebdabcc92 100644 --- a/tests/integration/targets/inventory_aws_ec2/playbooks/test_populating_inventory_with_include_or_exclude_filters.yml +++ b/tests/integration/targets/inventory_aws_ec2/playbooks/test_populating_inventory_with_include_or_exclude_filters.yml @@ -1,5 +1,6 @@ --- -- hosts: 127.0.0.1 +- name: Run a test using filters + hosts: 127.0.0.1 connection: local gather_facts: false environment: "{{ ansible_test.environment }}" @@ -14,7 +15,7 @@ # Create VPC, subnet, security group, and find image_id to create instance - ansible.builtin.include_tasks: tasks/setup.yml - - name: create a new host (1/3) + - name: Create a new host (1/3) amazon.aws.ec2_instance: image_id: "{{ image_id }}" name: "{{ resource_prefix }}_1" @@ -25,7 +26,7 @@ vpc_subnet_id: "{{ subnet_id }}" wait: false - - name: create a new host (2/3) + - name: Create a new host (2/3) amazon.aws.ec2_instance: image_id: "{{ image_id }}" name: "{{ resource_prefix }}_2" @@ -36,7 +37,7 @@ vpc_subnet_id: "{{ subnet_id }}" wait: false - - name: create a new host (3/3) + - name: Create a new host (3/3) amazon.aws.ec2_instance: image_id: "{{ image_id }}" name: "{{ resource_prefix }}_3" @@ -48,7 +49,7 @@ wait: false - ansible.builtin.meta: refresh_inventory - - name: assert the keyed groups and groups from constructed config were added to inventory and composite var added to hostvars + - name: Assert the keyed groups and groups from constructed config were added to inventory and composite var added to hostvars ansible.builtin.assert: that: # There are 9 groups: all, ungrouped, aws_ec2, sg keyed group, 3 tag keyed group (one per tag), arch keyed group, constructed group diff --git a/tests/integration/targets/inventory_aws_ec2/playbooks/test_populating_inventory_with_literal_string.yml b/tests/integration/targets/inventory_aws_ec2/playbooks/test_populating_inventory_with_literal_string.yml index daec3ed9ad4..6c3bbb0368b 100644 --- a/tests/integration/targets/inventory_aws_ec2/playbooks/test_populating_inventory_with_literal_string.yml +++ b/tests/integration/targets/inventory_aws_ec2/playbooks/test_populating_inventory_with_literal_string.yml @@ -1,5 +1,6 @@ --- -- hosts: 127.0.0.1 +- name: Run tests using literal strings when constructing hostnames + hosts: 127.0.0.1 connection: local gather_facts: false environment: "{{ ansible_test.environment }}" @@ -13,7 +14,7 @@ block: # Create VPC, subnet, security group, and find image_id to create instance - ansible.builtin.include_tasks: tasks/setup.yml - - name: create a new host + - name: Create a new host amazon.aws.ec2_instance: image_id: "{{ image_id }}" name: "{{ resource_prefix }}" @@ -27,7 +28,7 @@ register: setup_instance - ansible.builtin.meta: refresh_inventory - - name: register the current hostname + - name: Register the current hostname ansible.builtin.set_fact: expected_hostname: aws-{{ resource_prefix }} diff --git a/tests/integration/targets/inventory_aws_ec2/playbooks/test_populating_inventory_with_use_contrib_script_keys.yml b/tests/integration/targets/inventory_aws_ec2/playbooks/test_populating_inventory_with_use_contrib_script_keys.yml index 14760b120f3..4ac9e84b7f1 100644 --- a/tests/integration/targets/inventory_aws_ec2/playbooks/test_populating_inventory_with_use_contrib_script_keys.yml +++ b/tests/integration/targets/inventory_aws_ec2/playbooks/test_populating_inventory_with_use_contrib_script_keys.yml @@ -1,5 +1,6 @@ --- -- hosts: 127.0.0.1 +- name: Run tests using ec2_tag_keys compatible with the (old) contrib_script format + hosts: 127.0.0.1 connection: local gather_facts: false environment: "{{ ansible_test.environment }}" @@ -13,7 +14,7 @@ block: # Create VPC, subnet, security group, and find image_id to create instance - ansible.builtin.include_tasks: tasks/setup.yml - - name: create a new host + - name: Create a new host amazon.aws.ec2_instance: image_id: "{{ image_id }}" name: "{{ resource_prefix }}:/aa" @@ -26,7 +27,7 @@ register: setup_instance - ansible.builtin.meta: refresh_inventory - - name: "register the current hostname, the : and / a replaced with _" + - name: "Register the current hostname, the : and / a replaced with _" ansible.builtin.set_fact: expected_hostname: "{{ resource_prefix }}__aa" diff --git a/tests/integration/targets/inventory_aws_ec2/runme.sh b/tests/integration/targets/inventory_aws_ec2/runme.sh index aa2c6a2e867..fd727e89348 100755 --- a/tests/integration/targets/inventory_aws_ec2/runme.sh +++ b/tests/integration/targets/inventory_aws_ec2/runme.sh @@ -14,6 +14,8 @@ function cleanup() { exit 1 } +ln -s "$(pwd)/../" playbooks/roles + trap 'cleanup "${@}"' ERR # ensure test config is empty diff --git a/tests/integration/targets/inventory_aws_ec2/tasks/setup.yml b/tests/integration/targets/inventory_aws_ec2/tasks/setup.yml index ed1a2d44d48..db7311c91fb 100644 --- a/tests/integration/targets/inventory_aws_ec2/tasks/setup.yml +++ b/tests/integration/targets/inventory_aws_ec2/tasks/setup.yml @@ -1,6 +1,6 @@ --- - ansible.builtin.include_role: - name: ../setup_ec2_facts + name: setup_ec2_facts - name: Set image id, vpc cidr and subnet cidr ansible.builtin.set_fact: @@ -8,7 +8,7 @@ vpc_cidr: 10.{{ 256 | random(seed=resource_prefix) }}.0.0/16 subnet_cidr: 10.{{ 256 | random(seed=resource_prefix) }}.0.0/24 -- name: create a VPC to work in +- name: Create a VPC to work in amazon.aws.ec2_vpc_net: cidr_block: "{{ vpc_cidr }}" state: present @@ -21,7 +21,7 @@ ansible.builtin.set_fact: vpc_id: "{{ setup_vpc.vpc.id }}" -- name: create a subnet to use for creating an ec2 instance +- name: Create a subnet to use for creating an ec2 instance amazon.aws.ec2_vpc_subnet: az: "{{ aws_region }}a" vpc_id: "{{ setup_vpc.vpc.id }}" @@ -35,7 +35,7 @@ ansible.builtin.set_fact: subnet_id: "{{ setup_subnet.subnet.id }}" -- name: create a security group to use for creating an ec2 instance +- name: Create a security group to use for creating an ec2 instance amazon.aws.ec2_security_group: name: "{{ resource_prefix }}_setup" description: created by Ansible integration tests diff --git a/tests/integration/targets/inventory_aws_ec2/tasks/tear_down.yml b/tests/integration/targets/inventory_aws_ec2/tasks/tear_down.yml index aae674e2c4d..7de349c2856 100644 --- a/tests/integration/targets/inventory_aws_ec2/tasks/tear_down.yml +++ b/tests/integration/targets/inventory_aws_ec2/tasks/tear_down.yml @@ -4,31 +4,32 @@ vpc_cidr: 10.{{ 256 | random(seed=resource_prefix) }}.0.0/16 subnet_cidr: 10.{{ 256 | random(seed=resource_prefix) }}.0.0/24 -- name: describe vpc +- name: Describe vpc amazon.aws.ec2_vpc_net_info: filters: tag:Name: "{{ resource_prefix }}_setup" register: vpc_info - name: Tear down + when: vpc_info.vpcs | length > 0 block: - name: Set facts vpc_cidr, subnet_cidr ansible.builtin.set_fact: vpc_id: "{{ vpc_info.vpcs.0.vpc_id }}" - - name: list existing instances + - name: List existing instances amazon.aws.ec2_instance_info: filters: vpc-id: "{{ vpc_id }}" register: existing - - name: remove ec2 instances + - name: Remove ec2 instances amazon.aws.ec2_instance: instance_ids: "{{ existing.instances | map(attribute='instance_id') | list }}" wait: true state: absent - - name: remove setup security group + - name: Remove setup security group amazon.aws.ec2_security_group: name: "{{ resource_prefix }}_setup" description: created by Ansible integration tests @@ -36,7 +37,7 @@ vpc_id: "{{ vpc_id }}" ignore_errors: true - - name: remove setup subnet + - name: Remove setup subnet amazon.aws.ec2_vpc_subnet: az: "{{ aws_region }}a" tags: "{{ resource_prefix }}_setup" @@ -47,7 +48,7 @@ Name: "{{ resource_prefix }}_setup" ignore_errors: true - - name: remove setup VPC + - name: Remove setup VPC amazon.aws.ec2_vpc_net: cidr_block: "{{ vpc_cidr }}" state: absent @@ -55,5 +56,3 @@ resource_tags: Name: "{{ resource_prefix }}_setup" ignore_errors: true - - when: vpc_info.vpcs | length > 0 diff --git a/tests/integration/targets/inventory_aws_ec2/tasks/test_refresh_inventory.yml b/tests/integration/targets/inventory_aws_ec2/tasks/test_refresh_inventory.yml deleted file mode 100644 index d533975f781..00000000000 --- a/tests/integration/targets/inventory_aws_ec2/tasks/test_refresh_inventory.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- -- hosts: 127.0.0.1 - connection: local - gather_facts: false - tasks: - - block: - - name: assert group was populated with inventory and is no longer empty - assert: - that: - - "'aws_ec2' in groups" - - groups.aws_ec2 | length == 1 - - groups.aws_ec2.0 == resource_prefix diff --git a/tests/integration/targets/inventory_aws_rds/playbooks/create_inventory_config.yml b/tests/integration/targets/inventory_aws_rds/playbooks/create_inventory_config.yml index f297e2c12be..aee7cb12be3 100644 --- a/tests/integration/targets/inventory_aws_rds/playbooks/create_inventory_config.yml +++ b/tests/integration/targets/inventory_aws_rds/playbooks/create_inventory_config.yml @@ -1,5 +1,6 @@ --- -- hosts: 127.0.0.1 +- name: Prepare inventory config files + hosts: 127.0.0.1 connection: local gather_facts: false @@ -10,7 +11,8 @@ - vars/main.yml tasks: - - name: write inventory config file + - name: Write inventory config file ansible.builtin.copy: dest: ../test.aws_rds.yml content: "{{ lookup('template', template_name) }}" + mode: "0644" diff --git a/tests/integration/targets/inventory_aws_rds/playbooks/empty_inventory_config.yml b/tests/integration/targets/inventory_aws_rds/playbooks/empty_inventory_config.yml index 523e9bf7646..182b4e48fe5 100644 --- a/tests/integration/targets/inventory_aws_rds/playbooks/empty_inventory_config.yml +++ b/tests/integration/targets/inventory_aws_rds/playbooks/empty_inventory_config.yml @@ -1,9 +1,11 @@ --- -- hosts: 127.0.0.1 +- name: Prepare empty inventory config file + hosts: 127.0.0.1 connection: local gather_facts: false tasks: - - name: write inventory config file + - name: Write inventory config file ansible.builtin.copy: dest: ../test.aws_rds.yml content: "" + mode: "0644" diff --git a/tests/integration/targets/inventory_aws_rds/playbooks/populate_cache.yml b/tests/integration/targets/inventory_aws_rds/playbooks/populate_cache.yml index 3fef4a536a7..f8e4c1b4d45 100644 --- a/tests/integration/targets/inventory_aws_rds/playbooks/populate_cache.yml +++ b/tests/integration/targets/inventory_aws_rds/playbooks/populate_cache.yml @@ -1,5 +1,6 @@ --- -- hosts: 127.0.0.1 +- name: Populate inventory cache and then remove the instance without updating cache + hosts: 127.0.0.1 connection: local gather_facts: false @@ -16,9 +17,9 @@ region: "{{ aws_region }}" tasks: - - name: refresh inventory to populate cache + - name: Refresh inventory to populate cache ansible.builtin.meta: refresh_inventory - - name: assert group was populated with inventory but is empty + - name: Assert group was populated with inventory but is empty ansible.builtin.assert: that: - "'aws_rds' in groups" diff --git a/tests/integration/targets/inventory_aws_rds/playbooks/setup_instance.yml b/tests/integration/targets/inventory_aws_rds/playbooks/setup_instance.yml index 65dfe4bdc4a..191930abfd8 100644 --- a/tests/integration/targets/inventory_aws_rds/playbooks/setup_instance.yml +++ b/tests/integration/targets/inventory_aws_rds/playbooks/setup_instance.yml @@ -1,5 +1,6 @@ --- -- hosts: 127.0.0.1 +- name: Create RDS instances + hosts: 127.0.0.1 connection: local gather_facts: false diff --git a/tests/integration/targets/inventory_aws_rds/playbooks/tasks/rds_instance_delete.yml b/tests/integration/targets/inventory_aws_rds/playbooks/tasks/rds_instance_delete.yml index 47b047db3fa..a30578c6ee3 100644 --- a/tests/integration/targets/inventory_aws_rds/playbooks/tasks/rds_instance_delete.yml +++ b/tests/integration/targets/inventory_aws_rds/playbooks/tasks/rds_instance_delete.yml @@ -1,5 +1,5 @@ --- -- name: remove mariadb instance +- name: Remove mariadb instance amazon.aws.rds_instance: state: absent engine: "{{ instance_engine }}" diff --git a/tests/integration/targets/inventory_aws_rds/playbooks/test_invalid_aws_rds_inventory_config.yml b/tests/integration/targets/inventory_aws_rds/playbooks/test_invalid_aws_rds_inventory_config.yml index d1206695d47..b4d5e4f7379 100644 --- a/tests/integration/targets/inventory_aws_rds/playbooks/test_invalid_aws_rds_inventory_config.yml +++ b/tests/integration/targets/inventory_aws_rds/playbooks/test_invalid_aws_rds_inventory_config.yml @@ -1,9 +1,10 @@ --- -- hosts: 127.0.0.1 +- name: Test inventory is empty if the plugin is misconfigured + hosts: 127.0.0.1 connection: local gather_facts: false tasks: - - name: assert inventory was not populated by aws_rds inventory plugin + - name: Assert inventory was not populated by aws_rds inventory plugin ansible.builtin.assert: that: - "'aws_rds' not in groups" diff --git a/tests/integration/targets/inventory_aws_rds/playbooks/test_inventory_cache.yml b/tests/integration/targets/inventory_aws_rds/playbooks/test_inventory_cache.yml index 5fb4deb5873..387ff2f23df 100644 --- a/tests/integration/targets/inventory_aws_rds/playbooks/test_inventory_cache.yml +++ b/tests/integration/targets/inventory_aws_rds/playbooks/test_inventory_cache.yml @@ -1,16 +1,17 @@ --- -- hosts: 127.0.0.1 +- name: Test inventory is pulled from cache and then reset when the inventory's explicitly updated + hosts: 127.0.0.1 connection: local gather_facts: false tasks: - - name: assert cache was used to populate inventory + - name: Assert cache was used to populate inventory ansible.builtin.assert: that: - "'aws_rds' in groups" - groups.aws_rds | length == 1 - ansible.builtin.meta: refresh_inventory - - name: assert refresh_inventory updated the cache + - name: Assert refresh_inventory updated the cache ansible.builtin.assert: that: - "'aws_rds' in groups" diff --git a/tests/integration/targets/inventory_aws_rds/playbooks/test_inventory_no_hosts.yml b/tests/integration/targets/inventory_aws_rds/playbooks/test_inventory_no_hosts.yml index aaa674048b5..7f7754b4d4c 100644 --- a/tests/integration/targets/inventory_aws_rds/playbooks/test_inventory_no_hosts.yml +++ b/tests/integration/targets/inventory_aws_rds/playbooks/test_inventory_no_hosts.yml @@ -1,10 +1,11 @@ --- -- hosts: 127.0.0.1 +- name: Test inventory is empty + hosts: 127.0.0.1 connection: local gather_facts: false environment: "{{ ansible_test.environment }}" tasks: - - name: assert group was populated with inventory but is empty + - name: Assert group was populated with inventory but is empty ansible.builtin.assert: that: - "'aws_rds' in groups" diff --git a/tests/integration/targets/inventory_aws_rds/playbooks/test_inventory_with_hostvars_prefix_suffix.yml b/tests/integration/targets/inventory_aws_rds/playbooks/test_inventory_with_hostvars_prefix_suffix.yml index 3cbd5b2e30a..e98475a94e8 100644 --- a/tests/integration/targets/inventory_aws_rds/playbooks/test_inventory_with_hostvars_prefix_suffix.yml +++ b/tests/integration/targets/inventory_aws_rds/playbooks/test_inventory_with_hostvars_prefix_suffix.yml @@ -1,5 +1,6 @@ --- -- hosts: 127.0.0.1 +- name: Test the use of vars_suffix/vars_prefix + hosts: 127.0.0.1 connection: local gather_facts: false @@ -16,7 +17,7 @@ region: "{{ aws_region }}" tasks: - - name: assert the hostvars are defined with prefix and/or suffix + - name: Assert the hostvars are defined with prefix and/or suffix ansible.builtin.assert: that: - hostvars[instance_id][vars_prefix+"db_instance_class"+vars_suffix] == 'db.t3.micro' diff --git a/tests/integration/targets/inventory_aws_rds/playbooks/test_populating_inventory.yml b/tests/integration/targets/inventory_aws_rds/playbooks/test_populating_inventory.yml index 0d950c08567..e90abe542d5 100644 --- a/tests/integration/targets/inventory_aws_rds/playbooks/test_populating_inventory.yml +++ b/tests/integration/targets/inventory_aws_rds/playbooks/test_populating_inventory.yml @@ -1,5 +1,6 @@ --- -- hosts: 127.0.0.1 +- name: Test populating inventory + hosts: 127.0.0.1 connection: local gather_facts: false @@ -9,7 +10,7 @@ - vars/main.yml tasks: - - name: assert aws_rds inventory group contains RDS instance created by previous playbook + - name: Assert aws_rds inventory group contains RDS instance created by previous playbook ansible.builtin.assert: that: - "'aws_rds' in groups" diff --git a/tests/integration/targets/inventory_aws_rds/playbooks/test_populating_inventory_with_constructed.yml b/tests/integration/targets/inventory_aws_rds/playbooks/test_populating_inventory_with_constructed.yml index be53a8d7551..064df7754ba 100644 --- a/tests/integration/targets/inventory_aws_rds/playbooks/test_populating_inventory_with_constructed.yml +++ b/tests/integration/targets/inventory_aws_rds/playbooks/test_populating_inventory_with_constructed.yml @@ -1,5 +1,6 @@ --- -- hosts: 127.0.0.1 +- name: Run a test using constructed features + hosts: 127.0.0.1 connection: local gather_facts: false @@ -24,13 +25,13 @@ - ansible.builtin.debug: var: groups - - name: generate expected group name based off the db parameter groups + - name: Generate expected group name based off the db parameter groups vars: parameter_group_name: "{{ db_info.instances[0].db_parameter_groups[0].db_parameter_group_name }}" ansible.builtin.set_fact: parameter_group_key: rds_parameter_group_{{ parameter_group_name | replace(".", "_") }} - - name: assert the keyed groups from constructed config were added to inventory + - name: Assert the keyed groups from constructed config were added to inventory ansible.builtin.assert: that: # There are 6 groups: all, ungrouped, aws_rds, tag keyed group, engine keyed group, parameter group keyed group diff --git a/tests/integration/targets/kms_key/roles/kms_key/tasks/test_states.yml b/tests/integration/targets/kms_key/roles/kms_key/tasks/test_states.yml index 8b56cb2ca59..48482fbe116 100644 --- a/tests/integration/targets/kms_key/roles/kms_key/tasks/test_states.yml +++ b/tests/integration/targets/kms_key/roles/kms_key/tasks/test_states.yml @@ -518,12 +518,12 @@ - name: Fetch updated state of key amazon.aws.kms_key_info: alias: "{{ kms_key_alias }}" - pending_deletion: True + pending_deletion: true register: deleted_kms - name: Assert that state is pending deletion vars: - deleted_key: '{{ deleted_kms.kms_keys[0] }}' + deleted_key: "{{ deleted_kms.kms_keys[0] }}" now_time: '{{ lookup("pipe", "date -u +%Y-%m-%d\ %H:%M:%S") }}' deletion_time: '{{ deleted_key.deletion_date[:19] | to_datetime("%Y-%m-%dT%H:%M:%S") }}' ansible.builtin.assert: diff --git a/tests/integration/targets/lambda/tasks/main.yml b/tests/integration/targets/lambda/tasks/main.yml index 9db80106785..64ec629521c 100644 --- a/tests/integration/targets/lambda/tasks/main.yml +++ b/tests/integration/targets/lambda/tasks/main.yml @@ -1,5 +1,5 @@ --- -- name: set connection information for AWS modules and run tests +- name: Set connection information for AWS modules and run tests module_defaults: group/aws: access_key: "{{ aws_access_key }}" @@ -13,7 +13,7 @@ ansible_async_dir: "{{ lookup('env', 'HOME') }}/.ansible_async_{{ tiny_prefix }}/" when: (lookup('env', 'HOME')) # Preparation - - name: create minimal lambda role + - name: Create minimal lambda role amazon.aws.iam_role: name: "{{ lambda_role_name }}" assume_role_policy_document: '{{ lookup("file", "minimal_trust_policy.json") }}' @@ -21,64 +21,64 @@ managed_policies: - arn:aws:iam::aws:policy/AWSXrayWriteOnlyAccess register: iam_role - - name: wait 10 seconds for role to become available + - name: Wait 10 seconds for role to become available ansible.builtin.pause: seconds: 10 - when: iam_role.changed - - name: move lambda into place for archive module + - name: Move lambda into place for archive module ansible.builtin.copy: src: mini_lambda.py dest: "{{ output_dir }}/mini_lambda.py" mode: preserve - - name: bundle lambda into a zip + - name: Bundle lambda into a zip register: zip_res community.general.archive: format: zip path: "{{ output_dir }}/mini_lambda.py" dest: "{{ output_dir }}/mini_lambda.zip" + mode: "0644" # Parameter tests - - name: test with no parameters + - name: Test with no parameters amazon.aws.lambda: register: result ignore_errors: true - - name: assert failure when called with no parameters + - name: Assert failure when called with no parameters ansible.builtin.assert: that: - result.failed - 'result.msg.startswith("missing required arguments: ")' - '"name" in result.msg' - - name: test with no parameters except state absent + - name: Test with no parameters except state absent amazon.aws.lambda: state: absent register: result ignore_errors: true - - name: assert failure when called with no parameters + - name: Assert failure when called with no parameters ansible.builtin.assert: that: - result.failed - 'result.msg.startswith("missing required arguments: name")' - - name: test with no role + - name: Test with no role amazon.aws.lambda: name: ansible-testing-fake-should-not-be-created register: result ignore_errors: true - - name: assert failure when called with no parameters + - name: Assert failure when called with no parameters ansible.builtin.assert: that: - result.failed - 'result.msg.startswith("state is present but all of the following are missing: ")' - '"role" in result.msg' - - name: test with no handler/image_uri + - name: Test with no handler/image_uri amazon.aws.lambda: name: ansible-testing-fake-should-not-be-created role: "{{ lambda_role_name }}" register: result ignore_errors: true - - name: assert failure when called with no parameters + - name: Assert failure when called with no parameters ansible.builtin.assert: that: - result.failed @@ -86,17 +86,17 @@ - '"runtime" in result.msg' - '"image_uri" in result.msg' - - name: test execute lambda with no function arn or name + - name: Test execute lambda with no function arn or name amazon.aws.lambda_execute: register: result ignore_errors: true - - name: assert failure when called with no parameters + - name: Assert failure when called with no parameters ansible.builtin.assert: that: - result.failed - "result.msg == 'one of the following is required: name, function_arn'" - - name: test state=present with security group but no vpc + - name: Test state=present with security group but no vpc amazon.aws.lambda: name: "{{ lambda_function_name }}" runtime: "{{ lambda_python_runtime }}" @@ -110,7 +110,7 @@ dead_letter_arn: "{{ omit }}" register: result ignore_errors: true - - name: assert lambda fails with proper message + - name: Assert lambda fails with proper message ansible.builtin.assert: that: - result is failed @@ -118,7 +118,7 @@ - result.changed == False - '"parameters are required together" in result.msg' - - name: test state=present with incomplete layers + - name: Test state=present with incomplete layers amazon.aws.lambda: name: "{{ lambda_function_name }}" runtime: "{{ lambda_python_runtime }}" @@ -130,14 +130,14 @@ check_mode: true register: result ignore_errors: true - - name: assert lambda fails with proper message + - name: Assert lambda fails with proper message ansible.builtin.assert: that: - result is failed - result is not changed - '"parameters are required together: layer_name, version found in layers" in result.msg' - - name: test state=present with incomplete layers + - name: Test state=present with incomplete layers amazon.aws.lambda: name: "{{ lambda_function_name }}" runtime: "{{ lambda_python_runtime }}" @@ -150,7 +150,7 @@ check_mode: true register: result ignore_errors: true - - name: assert lambda fails with proper message + - name: Assert lambda fails with proper message ansible.builtin.assert: that: - result is failed @@ -158,7 +158,7 @@ - '"parameters are mutually exclusive: version|layer_version_arn found in layers" in result.msg' # Prepare minimal Lambda - - name: test state=present - upload the lambda (check mode) + - name: Test state=present - upload the lambda (check mode) amazon.aws.lambda: name: "{{ lambda_function_name }}" runtime: "{{ lambda_python_runtime }}" @@ -168,12 +168,12 @@ architecture: arm64 register: result check_mode: true - - name: assert lambda upload succeeded + - name: Assert lambda upload succeeded ansible.builtin.assert: that: - result.changed - - name: test state=present - upload the lambda + - name: Test state=present - upload the lambda amazon.aws.lambda: name: "{{ lambda_function_name }}" runtime: "{{ lambda_python_runtime }}" @@ -182,7 +182,7 @@ zip_file: "{{ zip_res.dest }}" architecture: arm64 register: result - - name: assert lambda upload succeeded + - name: Assert lambda upload succeeded ansible.builtin.assert: that: - result.changed @@ -194,47 +194,47 @@ lambda_function_arn: "{{ result['configuration']['function_arn'] }}" - ansible.builtin.include_tasks: tagging.yml - - name: test lambda works (check mode) + - name: Test lambda works (check mode) amazon.aws.lambda_execute: - name: "{{lambda_function_name}}" + name: "{{ lambda_function_name }}" payload: name: Mr Ansible Tests register: result check_mode: true - - name: assert check mode works correctly + - name: Assert check mode works correctly ansible.builtin.assert: that: - result.changed - "'result' not in result" - - name: test lambda works + - name: Test lambda works amazon.aws.lambda_execute: - name: "{{lambda_function_name}}" + name: "{{ lambda_function_name }}" payload: name: Mr Ansible Tests register: result - - name: assert lambda manages to respond as expected + - name: Assert lambda manages to respond as expected ansible.builtin.assert: that: - result is not failed - result.result.output.message == "hello Mr Ansible Tests" - - name: test execute lambda with function arn + - name: Test execute lambda with function arn amazon.aws.lambda_execute: function_arn: "{{ lambda_function_arn }}" payload: name: Mr Ansible Tests register: result - - name: assert lambda manages to respond as expected + - name: Assert lambda manages to respond as expected ansible.builtin.assert: that: - result is not failed - result.result.output.message == "hello Mr Ansible Tests" # Test updating Lambda - - name: test lambda config updates (check mode) + - name: Test lambda config updates (check mode) amazon.aws.lambda: - name: "{{lambda_function_name}}" + name: "{{ lambda_function_name }}" runtime: nodejs14.x tracing_mode: Active handler: "{{ lambda_python_handler }}" @@ -245,15 +245,15 @@ Spaced key: A value with spaces register: update_result check_mode: true - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is not failed - update_result.changed == True - - name: test lambda config updates + - name: Test lambda config updates amazon.aws.lambda: - name: "{{lambda_function_name}}" + name: "{{ lambda_function_name }}" runtime: nodejs14.x tracing_mode: Active handler: "{{ lambda_python_handler }}" @@ -263,7 +263,7 @@ snake_case: a_snake_case_value Spaced key: A value with spaces register: update_result - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is not failed @@ -271,9 +271,9 @@ - update_result.configuration.runtime == 'nodejs14.x' - update_result.configuration.tracing_config.mode == 'Active' - - name: test no changes are made with the same parameters repeated (check mode) + - name: Test no changes are made with the same parameters repeated (check mode) amazon.aws.lambda: - name: "{{lambda_function_name}}" + name: "{{ lambda_function_name }}" runtime: nodejs14.x tracing_mode: Active handler: "{{ lambda_python_handler }}" @@ -284,15 +284,15 @@ Spaced key: A value with spaces register: update_result check_mode: true - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is not failed - update_result.changed == False - - name: test no changes are made with the same parameters repeated + - name: Test no changes are made with the same parameters repeated amazon.aws.lambda: - name: "{{lambda_function_name}}" + name: "{{ lambda_function_name }}" runtime: nodejs14.x tracing_mode: Active handler: "{{ lambda_python_handler }}" @@ -302,7 +302,7 @@ snake_case: a_snake_case_value Spaced key: A value with spaces register: update_result - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is not failed @@ -310,15 +310,15 @@ - update_result.configuration.runtime == 'nodejs14.x' - update_result.configuration.tracing_config.mode == 'Active' - - name: reset config updates for the following tests + - name: Reset config updates for the following tests amazon.aws.lambda: - name: "{{lambda_function_name}}" + name: "{{ lambda_function_name }}" runtime: "{{ lambda_python_runtime }}" tracing_mode: PassThrough handler: "{{ lambda_python_handler }}" role: "{{ lambda_role_name }}" register: result - - name: assert that reset succeeded + - name: Assert that reset succeeded ansible.builtin.assert: that: - result is not failed @@ -327,12 +327,12 @@ - result.configuration.tracing_config.mode == 'PassThrough' # Test lambda_info - - name: lambda_info | Gather all infos for all lambda functions + - name: Gather all infos for all lambda functions amazon.aws.lambda_info: query: all register: lambda_infos_all check_mode: true - - name: lambda_info | Assert successfull retrieval of all information 1 + - name: Assert successfull retrieval of all information 1 vars: lambda_info: "{{ lambda_infos_all.functions | selectattr('function_name', 'eq', lambda_function_name) | first }}" ansible.builtin.assert: @@ -351,11 +351,11 @@ - lambda_info.tags is defined - lambda_info.architectures == ['arm64'] - - name: lambda_info | Ensure default query value is 'config' when function name omitted + - name: Ensure default query value is 'config' when function name omitted amazon.aws.lambda_info: register: lambda_infos_query_config check_mode: true - - name: lambda_info | Assert successfull retrieval of all information 2 + - name: Assert successfull retrieval of all information 2 vars: lambda_info: "{{ lambda_infos_query_config.functions | selectattr('function_name', 'eq', lambda_function_name) | first }}" ansible.builtin.assert: @@ -373,11 +373,11 @@ - lambda_info.mappings is not defined - lambda_info.tags is not defined - - name: lambda_info | Ensure default query value is 'all' when function name specified + - name: Ensure default query value is 'all' when function name specified amazon.aws.lambda_info: name: "{{ lambda_function_name }}" register: lambda_infos_query_all - - name: lambda_info | Assert successfull retrieval of all information 3 + - name: Assert successfull retrieval of all information 3 ansible.builtin.assert: that: - lambda_infos_query_all is not failed @@ -389,12 +389,12 @@ - lambda_infos_query_all.functions[0].mappings is defined - lambda_infos_query_all.functions[0].tags is defined - - name: lambda_info | Gather version infos for given lambda function + - name: Gather version infos for given lambda function amazon.aws.lambda_info: name: "{{ lambda_function_name }}" query: versions register: lambda_infos_versions - - name: lambda_info | Assert successfull retrieval of versions information + - name: Assert successfull retrieval of versions information ansible.builtin.assert: that: - lambda_infos_versions is not failed @@ -406,12 +406,12 @@ - lambda_infos_versions.functions[0].mappings is undefined - lambda_infos_versions.functions[0].tags is undefined - - name: lambda_info | Gather config infos for given lambda function + - name: Gather config infos for given lambda function amazon.aws.lambda_info: name: "{{ lambda_function_name }}" query: config register: lambda_infos_config - - name: lambda_info | Assert successfull retrieval of config information + - name: Assert successfull retrieval of config information ansible.builtin.assert: that: - lambda_infos_config is not failed @@ -424,12 +424,12 @@ - lambda_infos_config.functions[0].mappings is undefined - lambda_infos_config.functions[0].tags is undefined - - name: lambda_info | Gather policy infos for given lambda function + - name: Gather policy infos for given lambda function amazon.aws.lambda_info: name: "{{ lambda_function_name }}" query: policy register: lambda_infos_policy - - name: lambda_info | Assert successfull retrieval of policy information + - name: Assert successfull retrieval of policy information ansible.builtin.assert: that: - lambda_infos_policy is not failed @@ -441,12 +441,12 @@ - lambda_infos_policy.functions[0].mappings is undefined - lambda_infos_policy.functions[0].tags is undefined - - name: lambda_info | Gather aliases infos for given lambda function + - name: Gather aliases infos for given lambda function amazon.aws.lambda_info: name: "{{ lambda_function_name }}" query: aliases register: lambda_infos_aliases - - name: lambda_info | Assert successfull retrieval of aliases information + - name: Assert successfull retrieval of aliases information ansible.builtin.assert: that: - lambda_infos_aliases is not failed @@ -458,12 +458,12 @@ - lambda_infos_aliases.functions[0].mappings is undefined - lambda_infos_aliases.functions[0].tags is undefined - - name: lambda_info | Gather mappings infos for given lambda function + - name: Gather mappings infos for given lambda function amazon.aws.lambda_info: name: "{{ lambda_function_name }}" query: mappings register: lambda_infos_mappings - - name: lambda_info | Assert successfull retrieval of mappings information + - name: Assert successfull retrieval of mappings information ansible.builtin.assert: that: - lambda_infos_mappings is not failed @@ -499,171 +499,171 @@ # - result is not failed # - result.changed == False - - name: test putting an environment variable changes lambda (check mode) + - name: Test putting an environment variable changes lambda (check mode) amazon.aws.lambda: - name: "{{lambda_function_name}}" + name: "{{ lambda_function_name }}" runtime: "{{ lambda_python_runtime }}" handler: "{{ lambda_python_handler }}" role: "{{ lambda_role_name }}" - zip_file: "{{zip_res.dest}}" + zip_file: "{{ zip_res.dest }}" environment_variables: EXTRA_MESSAGE: I think you are great!! register: result check_mode: true - - name: assert lambda upload succeeded + - name: Assert lambda upload succeeded ansible.builtin.assert: that: - result is not failed - result.changed == True - - name: test putting an environment variable changes lambda + - name: Test putting an environment variable changes lambda amazon.aws.lambda: - name: "{{lambda_function_name}}" + name: "{{ lambda_function_name }}" runtime: "{{ lambda_python_runtime }}" handler: "{{ lambda_python_handler }}" role: "{{ lambda_role_name }}" - zip_file: "{{zip_res.dest}}" + zip_file: "{{ zip_res.dest }}" environment_variables: EXTRA_MESSAGE: I think you are great!! register: result - - name: assert lambda upload succeeded + - name: Assert lambda upload succeeded ansible.builtin.assert: that: - result is not failed - result.changed == True - result.configuration.environment.variables.extra_message == "I think you are great!!" - - name: test lambda works + - name: Test lambda works amazon.aws.lambda_execute: - name: "{{lambda_function_name}}" + name: "{{ lambda_function_name }}" payload: name: Mr Ansible Tests register: result - - name: assert lambda manages to respond as expected + - name: Assert lambda manages to respond as expected ansible.builtin.assert: that: - result is not failed - result.result.output.message == "hello Mr Ansible Tests. I think you are great!!" # Deletion behavious - - name: test state=absent (expect changed=True) (check mode) + - name: Test state=absent (expect changed=True) (check mode) amazon.aws.lambda: - name: "{{lambda_function_name}}" + name: "{{ lambda_function_name }}" state: absent register: result check_mode: true - - name: assert state=absent + - name: Assert state=absent ansible.builtin.assert: that: - result is not failed - result is changed - - name: test state=absent (expect changed=True) + - name: Test state=absent (expect changed=True) amazon.aws.lambda: - name: "{{lambda_function_name}}" + name: "{{ lambda_function_name }}" state: absent register: result - - name: assert state=absent + - name: Assert state=absent ansible.builtin.assert: that: - result is not failed - result is changed - - name: test state=absent (expect changed=False) when already deleted (check mode) + - name: Test state=absent (expect changed=False) when already deleted (check mode) amazon.aws.lambda: - name: "{{lambda_function_name}}" + name: "{{ lambda_function_name }}" state: absent register: result check_mode: true - - name: assert state=absent + - name: Assert state=absent ansible.builtin.assert: that: - result is not failed - result is not changed - - name: test state=absent (expect changed=False) when already deleted + - name: Test state=absent (expect changed=False) when already deleted amazon.aws.lambda: - name: "{{lambda_function_name}}" + name: "{{ lambda_function_name }}" state: absent register: result - - name: assert state=absent + - name: Assert state=absent ansible.builtin.assert: that: - result is not failed - result is not changed # Parallel creations and deletions - - name: parallel lambda creation 1/4 + - name: Parallel lambda creation 1/4 amazon.aws.lambda: - name: "{{lambda_function_name}}_1" + name: "{{ lambda_function_name }}_1" runtime: "{{ lambda_python_runtime }}" handler: "{{ lambda_python_handler }}" role: "{{ lambda_role_name }}" - zip_file: "{{zip_res.dest}}" + zip_file: "{{ zip_res.dest }}" async: 1000 register: async_1 - - name: parallel lambda creation 2/4 + - name: Parallel lambda creation 2/4 amazon.aws.lambda: - name: "{{lambda_function_name}}_2" + name: "{{ lambda_function_name }}_2" runtime: "{{ lambda_python_runtime }}" handler: "{{ lambda_python_handler }}" role: "{{ lambda_role_name }}" - zip_file: "{{zip_res.dest}}" + zip_file: "{{ zip_res.dest }}" async: 1000 register: async_2 - - name: parallel lambda creation 3/4 + - name: Parallel lambda creation 3/4 amazon.aws.lambda: - name: "{{lambda_function_name}}_3" + name: "{{ lambda_function_name }}_3" runtime: "{{ lambda_python_runtime }}" handler: "{{ lambda_python_handler }}" role: "{{ lambda_role_name }}" - zip_file: "{{zip_res.dest}}" + zip_file: "{{ zip_res.dest }}" async: 1000 register: async_3 - - name: parallel lambda creation 4/4 + - name: Parallel lambda creation 4/4 amazon.aws.lambda: - name: "{{lambda_function_name}}_4" + name: "{{ lambda_function_name }}_4" runtime: "{{ lambda_python_runtime }}" handler: "{{ lambda_python_handler }}" role: "{{ lambda_role_name }}" - zip_file: "{{zip_res.dest}}" + zip_file: "{{ zip_res.dest }}" register: result - - name: assert lambda manages to respond as expected + - name: Assert lambda manages to respond as expected ansible.builtin.assert: that: - result is not failed - - name: parallel lambda deletion 1/4 + - name: Parallel lambda deletion 1/4 amazon.aws.lambda: - name: "{{lambda_function_name}}_1" + name: "{{ lambda_function_name }}_1" state: absent - zip_file: "{{zip_res.dest}}" + zip_file: "{{ zip_res.dest }}" async: 1000 register: async_1 - - name: parallel lambda deletion 2/4 + - name: Parallel lambda deletion 2/4 amazon.aws.lambda: - name: "{{lambda_function_name}}_2" + name: "{{ lambda_function_name }}_2" state: absent - zip_file: "{{zip_res.dest}}" + zip_file: "{{ zip_res.dest }}" async: 1000 register: async_2 - - name: parallel lambda deletion 3/4 + - name: Parallel lambda deletion 3/4 amazon.aws.lambda: - name: "{{lambda_function_name}}_3" + name: "{{ lambda_function_name }}_3" state: absent - zip_file: "{{zip_res.dest}}" + zip_file: "{{ zip_res.dest }}" async: 1000 register: async_3 - - name: parallel lambda deletion 4/4 + - name: Parallel lambda deletion 4/4 amazon.aws.lambda: - name: "{{lambda_function_name}}_4" + name: "{{ lambda_function_name }}_4" state: absent - zip_file: "{{zip_res.dest}}" + zip_file: "{{ zip_res.dest }}" register: result - - name: assert lambda creation has succeeded + - name: Assert lambda creation has succeeded ansible.builtin.assert: that: - result is not failed @@ -679,6 +679,7 @@ ansible.builtin.file: path: "{{ remote_tmp_dir }}/python" state: directory + mode: "0755" - name: Create lambda layer library ansible.builtin.copy: @@ -687,12 +688,14 @@ print("Hello from the ansible amazon.aws lambda layer") return 1 dest: "{{ remote_tmp_dir }}/python/lambda_layer.py" + mode: "0644" - name: Create lambda layer archive community.general.archive: format: zip path: "{{ remote_tmp_dir }}" dest: "{{ remote_tmp_dir }}/lambda_layer.zip" + mode: "0644" - name: Create lambda layer amazon.aws.lambda_layer: @@ -792,7 +795,7 @@ ignore_errors: true with_items: "{{ lambda_python_layers_names }}" - - name: ensure functions are absent at end of test + - name: Ensure functions are absent at end of test amazon.aws.lambda: name: "{{ item }}" state: absent @@ -804,7 +807,7 @@ - "{{ lambda_function_name }}_3" - "{{ lambda_function_name }}_4" - - name: ensure role has been removed at end of test + - name: Ensure role has been removed at end of test amazon.aws.iam_role: name: "{{ lambda_role_name }}" state: absent diff --git a/tests/integration/targets/lambda/tasks/tagging.yml b/tests/integration/targets/lambda/tasks/tagging.yml index 439a9aa9d41..80e7d793f0d 100644 --- a/tests/integration/targets/lambda/tasks/tagging.yml +++ b/tests/integration/targets/lambda/tasks/tagging.yml @@ -35,45 +35,45 @@ block: ### - - name: test adding tags to lambda (check mode) + - name: Test adding tags to lambda (check mode) amazon.aws.lambda: name: "{{ lambda_function_name }}" tags: "{{ first_tags }}" register: update_result check_mode: true - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is changed - - name: test adding tags to lambda + - name: Test adding tags to lambda amazon.aws.lambda: name: "{{ lambda_function_name }}" tags: "{{ first_tags }}" register: update_result - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is changed - update_result.tags == first_tags - - name: test adding tags to lambda - idempotency (check mode) + - name: Test adding tags to lambda - idempotency (check mode) amazon.aws.lambda: name: "{{ lambda_function_name }}" tags: "{{ first_tags }}" register: update_result check_mode: true - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is not changed - - name: test adding tags to lambda - idempotency + - name: Test adding tags to lambda - idempotency amazon.aws.lambda: name: "{{ lambda_function_name }}" tags: "{{ first_tags }}" register: update_result - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is not changed @@ -81,45 +81,45 @@ ### - - name: test updating tags with purge on lambda (check mode) + - name: Test updating tags with purge on lambda (check mode) amazon.aws.lambda: name: "{{ lambda_function_name }}" tags: "{{ second_tags }}" register: update_result check_mode: true - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is changed - - name: test updating tags with purge on lambda + - name: Test updating tags with purge on lambda amazon.aws.lambda: name: "{{ lambda_function_name }}" tags: "{{ second_tags }}" register: update_result - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is changed - update_result.tags == second_tags - - name: test updating tags with purge on lambda - idempotency (check mode) + - name: Test updating tags with purge on lambda - idempotency (check mode) amazon.aws.lambda: name: "{{ lambda_function_name }}" tags: "{{ second_tags }}" register: update_result check_mode: true - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is not changed - - name: test updating tags with purge on lambda - idempotency + - name: Test updating tags with purge on lambda - idempotency amazon.aws.lambda: name: "{{ lambda_function_name }}" tags: "{{ second_tags }}" register: update_result - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is not changed @@ -127,49 +127,49 @@ ### - - name: test updating tags without purge on lambda (check mode) + - name: Test updating tags without purge on lambda (check mode) amazon.aws.lambda: name: "{{ lambda_function_name }}" tags: "{{ third_tags }}" purge_tags: false register: update_result check_mode: true - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is changed - - name: test updating tags without purge on lambda + - name: Test updating tags without purge on lambda amazon.aws.lambda: name: "{{ lambda_function_name }}" tags: "{{ third_tags }}" purge_tags: false register: update_result - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is changed - update_result.tags == final_tags - - name: test updating tags without purge on lambda - idempotency (check mode) + - name: Test updating tags without purge on lambda - idempotency (check mode) amazon.aws.lambda: name: "{{ lambda_function_name }}" tags: "{{ third_tags }}" purge_tags: false register: update_result check_mode: true - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is not changed - - name: test updating tags without purge on lambda - idempotency + - name: Test updating tags without purge on lambda - idempotency amazon.aws.lambda: name: "{{ lambda_function_name }}" tags: "{{ third_tags }}" purge_tags: false register: update_result - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is not changed @@ -177,22 +177,22 @@ ### - - name: test no tags param lambda (check mode) + - name: Test no tags param lambda (check mode) amazon.aws.lambda: name: "{{ lambda_function_name }}" register: update_result check_mode: true - - name: assert no change + - name: Assert no change ansible.builtin.assert: that: - update_result is not changed - update_result.tags == final_tags - - name: test no tags param lambda + - name: Test no tags param lambda amazon.aws.lambda: name: "{{ lambda_function_name }}" register: update_result - - name: assert no change + - name: Assert no change ansible.builtin.assert: that: - update_result is not changed @@ -200,45 +200,45 @@ ### - - name: test removing tags from lambda (check mode) + - name: Test removing tags from lambda (check mode) amazon.aws.lambda: name: "{{ lambda_function_name }}" tags: {} register: update_result check_mode: true - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is changed - - name: test removing tags from lambda + - name: Test removing tags from lambda amazon.aws.lambda: name: "{{ lambda_function_name }}" tags: {} register: update_result - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is changed - update_result.tags == {} - - name: test removing tags from lambda - idempotency (check mode) + - name: Test removing tags from lambda - idempotency (check mode) amazon.aws.lambda: name: "{{ lambda_function_name }}" tags: {} register: update_result check_mode: true - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is not changed - - name: test removing tags from lambda - idempotency + - name: Test removing tags from lambda - idempotency amazon.aws.lambda: name: "{{ lambda_function_name }}" tags: {} register: update_result - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - update_result is not changed diff --git a/tests/integration/targets/lambda_alias/tasks/main.yml b/tests/integration/targets/lambda_alias/tasks/main.yml index 01cde99cb79..311b2397a5d 100644 --- a/tests/integration/targets/lambda_alias/tasks/main.yml +++ b/tests/integration/targets/lambda_alias/tasks/main.yml @@ -1,5 +1,5 @@ --- -- name: set connection information for AWS modules and run tests +- name: Set connection information for AWS modules and run tests module_defaults: group/aws: access_key: "{{ aws_access_key }}" @@ -9,7 +9,7 @@ block: # ============================================================== # Preparation - - name: create minimal lambda role + - name: Create minimal lambda role amazon.aws.iam_role: name: "{{ lambda_role_name }}" assume_role_policy_document: '{{ lookup("file", "minimal_trust_policy.json") }}' @@ -17,21 +17,21 @@ managed_policies: - arn:aws:iam::aws:policy/AWSXrayWriteOnlyAccess register: iam_role - - name: wait 10 seconds for role to become available + - name: Wait 10 seconds for role to become available ansible.builtin.pause: seconds: 10 - when: iam_role.changed - - name: move lambda into place for archive module + - name: Move lambda into place for archive module ansible.builtin.copy: src: mini_lambda.py dest: "{{ output_dir }}/mini_lambda.py" mode: preserve - - name: bundle lambda into a zip + - name: Bundle lambda into a zip register: zip_res community.general.archive: format: zip path: "{{ output_dir }}/mini_lambda.py" dest: "{{ output_dir }}/mini_lambda.zip" + mode: "0644" - name: Upload test lambda (version 1) amazon.aws.lambda: @@ -41,7 +41,7 @@ role: "{{ lambda_role_name }}" zip_file: "{{ zip_res.dest }}" register: lambda_a - - name: assert lambda upload succeeded + - name: Assert lambda upload succeeded ansible.builtin.assert: that: - lambda_a is changed @@ -53,7 +53,7 @@ handler: mini_lambda.handler role: "{{ lambda_role_name }}" register: lambda_b - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - lambda_b is changed @@ -65,7 +65,7 @@ handler: mini_lambda.handler role: "{{ lambda_role_name }}" register: lambda_c - - name: assert that update succeeded + - name: Assert that update succeeded ansible.builtin.assert: that: - lambda_c is changed @@ -344,8 +344,8 @@ state: present function_name: "{{ lambda_function_name }}" name: Testing - # docs state that when not defined defaults to LATEST - #function_version: 1 + # # docs state that when not defined defaults to LATEST + # function_version: 1 check_mode: true register: update_alias_version - name: Check changed @@ -358,8 +358,8 @@ state: present function_name: "{{ lambda_function_name }}" name: Testing - # docs state that when not defined defaults to LATEST - #function_version: 1 + # # docs state that when not defined defaults to LATEST + # function_version: 1 register: update_alias_version - name: Check changed and returned values ansible.builtin.assert: @@ -608,12 +608,12 @@ # ============================================================== # Cleanup always: - - name: ensure function is absent at end of test + - name: Ensure function is absent at end of test amazon.aws.lambda: - name: "{{lambda_function_name}}" + name: "{{ lambda_function_name }}" state: absent ignore_errors: true - - name: ensure role has been removed at end of test + - name: Ensure role has been removed at end of test amazon.aws.iam_role: name: "{{ lambda_role_name }}" state: absent diff --git a/tests/integration/targets/lambda_event/tasks/main.yml b/tests/integration/targets/lambda_event/tasks/main.yml index 1e49d1373a3..3bbcf4e53c2 100644 --- a/tests/integration/targets/lambda_event/tasks/main.yml +++ b/tests/integration/targets/lambda_event/tasks/main.yml @@ -1,5 +1,5 @@ --- -- name: set connection information for AWS modules and run tests +- name: Set connection information for AWS modules and run tests module_defaults: group/aws: access_key: "{{ aws_access_key }}" @@ -53,8 +53,9 @@ AWS_SESSION_TOKEN: "{{ security_token | default('') }}" AWS_DEFAULT_REGION: "{{ aws_region }}" register: lambda_function_details + changed_when: false - - name: convert it to an object + - name: Convert it to an object ansible.builtin.set_fact: lambda_function_details_obj: "{{ lambda_function_details.stdout | from_json }}" diff --git a/tests/integration/targets/lambda_event/tasks/setup.yml b/tests/integration/targets/lambda_event/tasks/setup.yml index 1f77a5e40fe..244414d7a76 100644 --- a/tests/integration/targets/lambda_event/tasks/setup.yml +++ b/tests/integration/targets/lambda_event/tasks/setup.yml @@ -1,5 +1,6 @@ --- -- ansible.builtin.debug: msg="Starting test setup......" +- ansible.builtin.debug: + msg: "Starting test setup......" - name: Create minimal dynamo table community.aws.dynamodb_table: name: "{{ dynamodb_table_name }}" @@ -18,7 +19,9 @@ AWS_SESSION_TOKEN: "{{ security_token | default('') }}" AWS_DEFAULT_REGION: "{{ aws_region }}" register: enable_stream_result -- name: convert it to an object + changed_when: true + +- name: Convert it to an object ansible.builtin.set_fact: enable_stream_result: "{{ enable_stream_result.stdout | from_json }}" - name: Get DynamoDB stream ARN @@ -32,34 +35,34 @@ ansible_async_dir: "{{ lookup('env', 'HOME') }}/.ansible_async_{{ tiny_prefix }}/" when: (lookup('env', 'HOME')) -- name: create minimal lambda role +- name: Create minimal lambda role amazon.aws.iam_role: name: "{{ lambda_role_name }}" - assume_role_policy_document: '{{ lookup("file", "minimal_trust_policy.json")}}' + assume_role_policy_document: '{{ lookup("file", "minimal_trust_policy.json") }}' create_instance_profile: false managed_policies: - arn:aws:iam::aws:policy/AWSXrayWriteOnlyAccess - arn:aws:iam::aws:policy/AWSLambdaInvocation-DynamoDB - arn:aws:iam::aws:policy/service-role/AWSLambdaDynamoDBExecutionRole register: iam_role -- name: wait 10 seconds for role to become available +- name: Wait 10 seconds for role to become available ansible.builtin.pause: seconds: 10 - when: iam_role.changed -- name: move lambda into place for archive module +- name: Move lambda into place for archive module ansible.builtin.copy: src: mini_lambda.py dest: "{{ output_dir }}/mini_lambda.py" mode: preserve -- name: bundle lambda into a zip +- name: Bundle lambda into a zip register: zip_res community.general.archive: format: zip path: "{{ output_dir }}/mini_lambda.py" dest: "{{ output_dir }}/mini_lambda.zip" + mode: "0644" -- name: test state=present - upload the lambda +- name: Test state=present - upload the lambda amazon.aws.lambda: name: "{{ lambda_function_name }}" runtime: "{{ lambda_python_runtime }}" @@ -69,7 +72,7 @@ architecture: x86_64 register: result -- name: assert lambda upload succeeded +- name: Assert lambda upload succeeded ansible.builtin.assert: that: - result.changed diff --git a/tests/integration/targets/lambda_event/tasks/teardown.yml b/tests/integration/targets/lambda_event/tasks/teardown.yml index 2f13e1de489..991b649cd03 100644 --- a/tests/integration/targets/lambda_event/tasks/teardown.yml +++ b/tests/integration/targets/lambda_event/tasks/teardown.yml @@ -1,5 +1,6 @@ --- -- ansible.builtin.debug: msg="Starting test Teardown......" +- ansible.builtin.debug: + msg: "Starting test Teardown......" - name: Delete DynamoDB stream event mapping (trigger) amazon.aws.lambda_event: state: absent @@ -28,5 +29,5 @@ - name: Delete the role amazon.aws.iam_role: name: "{{ lambda_role_name }}" - assume_role_policy_document: '{{ lookup("file", "minimal_trust_policy.json")}}' + assume_role_policy_document: '{{ lookup("file", "minimal_trust_policy.json") }}' state: absent diff --git a/tests/integration/targets/lambda_layer/tasks/main.yml b/tests/integration/targets/lambda_layer/tasks/main.yml index 4384aa56ad1..9a527cb50a6 100644 --- a/tests/integration/targets/lambda_layer/tasks/main.yml +++ b/tests/integration/targets/lambda_layer/tasks/main.yml @@ -22,6 +22,7 @@ content: "{{ lambda_hander_content }}" dest: "{{ _dir.path }}/lambda_handler.py" remote_src: true + mode: "0644" - ansible.builtin.set_fact: zip_file_path: "{{ _dir.path }}/lambda_handler.zip" @@ -31,13 +32,14 @@ path: "{{ _dir.path }}/lambda_handler.py" dest: "{{ zip_file_path }}" format: zip + mode: "0644" - name: Create S3 bucket for testing amazon.aws.s3_bucket: name: "{{ s3_bucket_name }}" state: present - - name: add object into bucket + - name: Add object into bucket amazon.aws.s3_object: bucket: "{{ s3_bucket_name }}" mode: put diff --git a/tests/integration/targets/lambda_policy/tasks/main.yml b/tests/integration/targets/lambda_policy/tasks/main.yml index 1289434425c..0a94655c5dc 100644 --- a/tests/integration/targets/lambda_policy/tasks/main.yml +++ b/tests/integration/targets/lambda_policy/tasks/main.yml @@ -7,7 +7,7 @@ session_token: "{{ security_token | default(omit) }}" region: "{{ aws_region }}" block: - - name: create minimal lambda role + - name: Create minimal lambda role amazon.aws.iam_role: name: "{{ lambda_role_name }}" assume_role_policy_document: '{{ lookup("file", "minimal_trust_policy.json") }}' @@ -15,16 +15,15 @@ managed_policies: - arn:aws:iam::aws:policy/AWSXrayWriteOnlyAccess register: iam_role - - name: wait 10 seconds for role to become available + - name: Wait 10 seconds for role to become available ansible.builtin.pause: seconds: 10 - when: iam_role.changed - - name: test with no parameters + - name: Test with no parameters amazon.aws.lambda_policy: register: result ignore_errors: true - - name: assert failure when called with no parameters + - name: Assert failure when called with no parameters ansible.builtin.assert: that: - result.failed @@ -34,65 +33,66 @@ - '"principal" in result.msg' - '"statement_id" in result.msg' - - name: move lambda into place for archive module + - name: Move lambda into place for archive module ansible.builtin.copy: src: mini_http_lambda.py dest: "{{ output_dir }}/mini_http_lambda.py" mode: preserve - - name: bundle lambda into a zip + - name: Bundle lambda into a zip register: zip_res community.general.archive: format: zip path: "{{ output_dir }}/mini_http_lambda.py" dest: "{{ output_dir }}/mini_http_lambda.zip" - - name: create minimal lambda role + mode: "0644" + - name: Create minimal lambda role amazon.aws.iam_role: name: ansible_lambda_role assume_role_policy_document: "{{ lookup('file', 'minimal_trust_policy.json', convert_data=False) }}" create_instance_profile: false register: iam_role - - name: wait 10 seconds for role to become available + - name: Wait 10 seconds for role to become available ansible.builtin.pause: seconds: 10 - when: iam_role.changed - - name: test state=present - upload the lambda + - name: Test state=present - upload the lambda amazon.aws.lambda: - name: "{{lambda_function_name}}" + name: "{{ lambda_function_name }}" runtime: python3.9 handler: mini_http_lambda.handler role: "{{ lambda_role_name }}" - zip_file: "{{zip_res.dest}}" + zip_file: "{{ zip_res.dest }}" register: lambda_result - - name: get the aws account ID for use in future commands + - name: Get the aws account ID for use in future commands amazon.aws.aws_caller_info: {} register: aws_caller_info - - name: register lambda uri for use in template + - name: Register lambda uri for use in template ansible.builtin.set_fact: mini_lambda_uri: arn:aws:apigateway:{{ aws_region }}:lambda:path/2015-03-31/functions/arn:aws:lambda:{{ aws_region }}:{{ aws_caller_info.account }}:function:{{ lambda_result.configuration.function_name }}/invocations - - name: build API file + - name: Build API file ansible.builtin.template: src: endpoint-test-swagger-api.yml.j2 - dest: "{{output_dir}}/endpoint-test-swagger-api.yml.j2" - - name: deploy new API + dest: "{{ output_dir }}/endpoint-test-swagger-api.yml.j2" + mode: "0644" + - name: Deploy new API community.aws.api_gateway: - api_file: "{{output_dir}}/endpoint-test-swagger-api.yml.j2" + api_file: "{{ output_dir }}/endpoint-test-swagger-api.yml.j2" stage: lambdabased register: create_result - - name: register api id for later + - name: Register api id for later ansible.builtin.set_fact: api_id: "{{ create_result.api_id }}" - - name: check API fails with permissions failure + - name: Check API fails with permissions failure ansible.builtin.uri: - url: https://{{create_result.api_id}}.execute-api.{{aws_region}}.amazonaws.com/lambdabased/mini/Mr_Ansible_Tester + url: https://{{ create_result.api_id }}.execute-api.{{ aws_region }}.amazonaws.com/lambdabased/mini/Mr_Ansible_Tester register: unauth_uri_result ignore_errors: true - - name: assert internal server error due to permissions + - name: Assert internal server error due to permissions ansible.builtin.assert: that: - unauth_uri_result is failed - unauth_uri_result.status == 500 - - name: give api gateway execute permissions on lambda + - name: Give api gateway execute permissions on lambda amazon.aws.lambda_policy: function_name: "{{ lambda_function_name }}" state: present @@ -100,7 +100,7 @@ action: lambda:InvokeFunction principal: apigateway.amazonaws.com source_arn: arn:aws:execute-api:{{ aws_region }}:{{ aws_caller_info.account }}:*/* - - name: try again but with ARN + - name: Try again but with ARN amazon.aws.lambda_policy: function_name: "{{ lambda_result.configuration.function_arn }}" state: present @@ -111,31 +111,31 @@ - name: Wait for permissions to propagate ansible.builtin.pause: seconds: 5 - - name: check API works with execute permissions + - name: Check API works with execute permissions ansible.builtin.uri: - url: https://{{create_result.api_id}}.execute-api.{{aws_region}}.amazonaws.com/lambdabased/mini/Mr_Ansible_Tester + url: https://{{ create_result.api_id }}.execute-api.{{ aws_region }}.amazonaws.com/lambdabased/mini/Mr_Ansible_Tester register: uri_result - - name: assert API works success + - name: Assert API works success ansible.builtin.assert: that: - uri_result - - name: deploy new API + - name: Deploy new API community.aws.api_gateway: - api_file: "{{output_dir}}/endpoint-test-swagger-api.yml.j2" + api_file: "{{ output_dir }}/endpoint-test-swagger-api.yml.j2" stage: lambdabased register: create_result ignore_errors: true always: - - name: destroy lambda for test cleanup if created + - name: Destroy lambda for test cleanup if created amazon.aws.lambda: - name: "{{lambda_function_name}}" + name: "{{ lambda_function_name }}" state: absent register: result ignore_errors: true - - name: destroy API for test cleanup if created + - name: Destroy API for test cleanup if created community.aws.api_gateway: state: absent - api_id: "{{api_id}}" + api_id: "{{ api_id }}" register: destroy_result ignore_errors: true - name: Clean up test role diff --git a/tests/integration/targets/lookup_aws_collection_constants/tasks/main.yaml b/tests/integration/targets/lookup_aws_collection_constants/tasks/main.yaml index 8dbac1d05e6..0903a6af16f 100644 --- a/tests/integration/targets/lookup_aws_collection_constants/tasks/main.yaml +++ b/tests/integration/targets/lookup_aws_collection_constants/tasks/main.yaml @@ -1,48 +1,48 @@ --- - name: MINIMUM_BOTOCORE_VERSION ansible.builtin.set_fact: - MINIMUM_BOTOCORE_VERSION: "{{ lookup('amazon.aws.aws_collection_constants', 'MINIMUM_BOTOCORE_VERSION') }}" + minimum_botocore_version: "{{ lookup('amazon.aws.aws_collection_constants', 'MINIMUM_BOTOCORE_VERSION') }}" - ansible.builtin.assert: that: - - MINIMUM_BOTOCORE_VERSION.startswith("1.") + - minimum_botocore_version.startswith("1.") - name: MINIMUM_BOTO3_VERSION ansible.builtin.set_fact: - MINIMUM_BOTO3_VERSION: "{{ lookup('amazon.aws.aws_collection_constants', 'MINIMUM_BOTO3_VERSION') }}" + minimum_boto3_version: "{{ lookup('amazon.aws.aws_collection_constants', 'MINIMUM_BOTO3_VERSION') }}" - ansible.builtin.assert: that: - - MINIMUM_BOTO3_VERSION.startswith("1.") + - minimum_boto3_version.startswith("1.") - name: HAS_BOTO3 ansible.builtin.set_fact: - HAS_BOTO3: "{{ lookup('amazon.aws.aws_collection_constants', 'HAS_BOTO3') }}" + has_boto3: "{{ lookup('amazon.aws.aws_collection_constants', 'HAS_BOTO3') }}" - ansible.builtin.assert: that: - - HAS_BOTO3 | bool + - has_boto3 | bool - name: AMAZON_AWS_COLLECTION_VERSION ansible.builtin.set_fact: - AMAZON_AWS_COLLECTION_VERSION: "{{ lookup('amazon.aws.aws_collection_constants', 'AMAZON_AWS_COLLECTION_VERSION') }}" + amazon_aws_collection_version: "{{ lookup('amazon.aws.aws_collection_constants', 'AMAZON_AWS_COLLECTION_VERSION') }}" - name: AMAZON_AWS_COLLECTION_NAME ansible.builtin.set_fact: - AMAZON_AWS_COLLECTION_NAME: "{{ lookup('amazon.aws.aws_collection_constants', 'AMAZON_AWS_COLLECTION_NAME') }}" + amazon_aws_collection_name: "{{ lookup('amazon.aws.aws_collection_constants', 'AMAZON_AWS_COLLECTION_NAME') }}" - ansible.builtin.assert: that: - - AMAZON_AWS_COLLECTION_NAME == "amazon.aws" + - amazon_aws_collection_name == "amazon.aws" - name: COMMUNITY_AWS_COLLECTION_VERSION ansible.builtin.set_fact: - COMMUNITY_AWS_COLLECTION_VERSION: "{{ lookup('amazon.aws.aws_collection_constants', 'COMMUNITY_AWS_COLLECTION_VERSION') }}" + community_aws_collection_version: "{{ lookup('amazon.aws.aws_collection_constants', 'COMMUNITY_AWS_COLLECTION_VERSION') }}" - name: COMMUNITY_AWS_COLLECTION_NAME ansible.builtin.set_fact: - COMMUNITY_AWS_COLLECTION_NAME: "{{ lookup('amazon.aws.aws_collection_constants', 'COMMUNITY_AWS_COLLECTION_NAME') }}" + community_aws_collection_name: "{{ lookup('amazon.aws.aws_collection_constants', 'COMMUNITY_AWS_COLLECTION_NAME') }}" - ansible.builtin.assert: that: - - COMMUNITY_AWS_COLLECTION_NAME == "community.aws" + - community_aws_collection_name == "community.aws" diff --git a/tests/integration/targets/lookup_aws_service_ip_ranges/tasks/main.yaml b/tests/integration/targets/lookup_aws_service_ip_ranges/tasks/main.yaml index cc6437b2b25..08e518326ce 100644 --- a/tests/integration/targets/lookup_aws_service_ip_ranges/tasks/main.yaml +++ b/tests/integration/targets/lookup_aws_service_ip_ranges/tasks/main.yaml @@ -1,20 +1,20 @@ --- -- name: lookup range with no arguments +- name: Lookup range with no arguments ansible.builtin.set_fact: no_params: "{{ lookup('amazon.aws.aws_service_ip_ranges') }}" -- name: assert that we're returned a single string +- name: Assert that we're returned a single string ansible.builtin.assert: that: - no_params is defined - no_params is string -- name: lookup range with wantlist +- name: Lookup range with wantlist ansible.builtin.set_fact: want_list: "{{ lookup('amazon.aws.aws_service_ip_ranges', wantlist=True) }}" want_ipv6_list: "{{ lookup('amazon.aws.aws_service_ip_ranges', wantlist=True, ipv6_prefixes=True) }}" -- name: assert that we're returned a list +- name: Assert that we're returned a list ansible.builtin.assert: that: - want_list is defined @@ -28,12 +28,12 @@ - want_ipv6_list | length > 1 - want_ipv6_list[0] | ansible.utils.ipv6 -- name: lookup range with service +- name: Lookup range with service ansible.builtin.set_fact: s3_ips: "{{ lookup('amazon.aws.aws_service_ip_ranges', service='S3', wantlist=True) }}" s3_ipv6s: "{{ lookup('amazon.aws.aws_service_ip_ranges', service='S3', wantlist=True, ipv6_prefixes=True) }}" -- name: assert that we're returned a list +- name: Assert that we're returned a list ansible.builtin.assert: that: - s3_ips is defined @@ -47,12 +47,12 @@ - s3_ipv6s | length > 1 - s3_ipv6s[0] | ansible.utils.ipv6 -- name: lookup range with a different service +- name: Lookup range with a different service ansible.builtin.set_fact: route53_ips: "{{ lookup('amazon.aws.aws_service_ip_ranges', service='ROUTE53_HEALTHCHECKS', wantlist=True) }}" route53_ipv6s: "{{ lookup('amazon.aws.aws_service_ip_ranges', service='ROUTE53_HEALTHCHECKS', wantlist=True, ipv6_prefixes=True) }}" -- name: assert that we're returned a list +- name: Assert that we're returned a list ansible.builtin.assert: that: - route53_ips is defined @@ -66,21 +66,21 @@ - route53_ipv6s | length > 1 - route53_ipv6s[0] | ansible.utils.ipv6 -- name: assert that service IPV4s and IPV6s do not overlap +- name: Assert that service IPV4s and IPV6s do not overlap ansible.builtin.assert: that: - route53_ips | intersect(s3_ips) | length == 0 - route53_ipv6s | intersect(s3_ipv6s) | length == 0 -- name: lookup range with region +- name: Lookup range with region ansible.builtin.set_fact: us_east_1_ips: "{{ lookup('amazon.aws.aws_service_ip_ranges', region='us-east-1', wantlist=True) }}" -- name: lookup IPV6 range with region +- name: Lookup IPV6 range with region ansible.builtin.set_fact: us_east_1_ipv6s: "{{ lookup('amazon.aws.aws_service_ip_ranges', region='us-east-1', wantlist=True, ipv6_prefixes=True) }}" -- name: assert that we're returned a list +- name: Assert that we're returned a list ansible.builtin.assert: that: - us_east_1_ips is defined @@ -94,12 +94,12 @@ - us_east_1_ipv6s | length > 1 - us_east_1_ipv6s[0] | ansible.utils.ipv6 -- name: lookup range with a different region +- name: Lookup range with a different region ansible.builtin.set_fact: eu_central_1_ips: "{{ lookup('amazon.aws.aws_service_ip_ranges', region='eu-central-1', wantlist=True) }}" eu_central_1_ipv6s: "{{ lookup('amazon.aws.aws_service_ip_ranges', region='eu-central-1', wantlist=True, ipv6_prefixes=True) }}" -- name: assert that we're returned a list +- name: Assert that we're returned a list ansible.builtin.assert: that: - eu_central_1_ips is defined @@ -113,18 +113,18 @@ - eu_central_1_ipv6s | length > 1 - eu_central_1_ipv6s[0] | ansible.utils.ipv6 -- name: assert that regional IPs don't overlap +- name: Assert that regional IPs don't overlap ansible.builtin.assert: that: - eu_central_1_ips | intersect(us_east_1_ips) | length == 0 - eu_central_1_ipv6s | intersect(us_east_1_ipv6s) | length == 0 -- name: lookup range with service and region +- name: Lookup range with service and region ansible.builtin.set_fact: s3_us_ips: "{{ lookup('amazon.aws.aws_service_ip_ranges', region='us-east-1', service='S3', wantlist=True) }}" s3_us_ipv6s: "{{ lookup('amazon.aws.aws_service_ip_ranges', region='us-east-1', service='S3', wantlist=True, ipv6_prefixes=True) }}" -- name: assert that we're returned a list +- name: Assert that we're returned a list ansible.builtin.assert: that: - s3_us_ips is defined @@ -138,7 +138,7 @@ - s3_us_ipv6s | length > 1 - s3_us_ipv6s[0] | ansible.utils.ipv6 -- name: assert that the regional service IPs are a subset of the regional IPs and service IPs. +- name: Assert that the regional service IPs are a subset of the regional IPs and service IPs. ansible.builtin.assert: that: - ( s3_us_ips | intersect(us_east_1_ips) | length ) == ( s3_us_ips | length ) diff --git a/tests/integration/targets/lookup_secretsmanager_secret/tasks/main.yaml b/tests/integration/targets/lookup_secretsmanager_secret/tasks/main.yaml index 74726e8c1ea..efec68d7487 100644 --- a/tests/integration/targets/lookup_secretsmanager_secret/tasks/main.yaml +++ b/tests/integration/targets/lookup_secretsmanager_secret/tasks/main.yaml @@ -15,45 +15,45 @@ secret_key: "{{ aws_secret_key }}" session_token: "{{ security_token | default(omit) }}" block: - - name: define secret name + - name: Define secret name ansible.builtin.set_fact: secret_name: ansible-test-{{ tiny_prefix }}-secret secret_value: "{{ lookup('password', '/dev/null chars=ascii_lowercase,digits,punctuation length=16') }}" skip: skip warn: warn - - name: lookup missing secret (skip) + - name: Lookup missing secret (skip) ansible.builtin.set_fact: missing_secret: "{{ lookup('amazon.aws.secretsmanager_secret', secret_name, on_missing=skip, **connection_args) }}" - - name: assert that missing_secret is defined + - name: Assert that missing_secret is defined ansible.builtin.assert: that: - missing_secret is defined - missing_secret | list | length == 0 - - name: lookup missing secret (warn) + - name: Lookup missing secret (warn) ansible.builtin.set_fact: missing_secret: "{{ lookup('amazon.aws.secretsmanager_secret', secret_name, on_missing=warn, **connection_args) }}" - - name: assert that missing_secret is defined + - name: Assert that missing_secret is defined ansible.builtin.assert: that: - missing_secret is defined - missing_secret | list | length == 0 - - name: lookup missing secret (error) + - name: Lookup missing secret (error) ansible.builtin.set_fact: missing_secret: "{{ lookup('amazon.aws.secretsmanager_secret', secret_name, **connection_args) }}" ignore_errors: true register: get_missing_secret - - name: assert that setting the missing_secret failed + - name: Assert that setting the missing_secret failed ansible.builtin.assert: that: - get_missing_secret is failed - - name: create secret "{{ secret_name }}" + - name: Create secret "{{ secret_name }}" community.aws.secretsmanager_secret: name: "{{ secret_name }}" secret: "{{ secret_value }}" @@ -62,67 +62,66 @@ state: present register: create_secret - - name: read secret value + - name: Read secret value ansible.builtin.set_fact: look_secret: "{{ lookup('amazon.aws.secretsmanager_secret', secret_name, **connection_args) }}" - - name: assert that secret was successfully retrieved + - name: Assert that secret was successfully retrieved ansible.builtin.assert: that: - look_secret == secret_value - - name: read secret value (by ARN) + - name: Read secret value (by ARN) ansible.builtin.set_fact: look_secret_by_arn: "{{ lookup('amazon.aws.secretsmanager_secret', create_secret.secret.arn, **connection_args) }}" - - name: assert that secret was successfully retrieved + - name: Assert that secret was successfully retrieved ansible.builtin.assert: that: - look_secret_by_arn == secret_value - - name: delete secret + - name: Delete secret community.aws.secretsmanager_secret: name: "{{ secret_name }}" state: absent recovery_window: 7 - - name: lookup deleted secret (skip) + - name: Lookup deleted secret (skip) ansible.builtin.set_fact: deleted_secret: "{{ lookup('amazon.aws.secretsmanager_secret', secret_name, on_deleted=skip, **connection_args) }}" - - name: assert that deleted_secret is defined + - name: Assert that deleted_secret is defined ansible.builtin.assert: that: - deleted_secret is defined - deleted_secret | list | length == 0 - - name: lookup deleted secret (warn) + - name: Lookup deleted secret (warn) ansible.builtin.set_fact: deleted_secret: "{{ lookup('amazon.aws.secretsmanager_secret', secret_name, on_deleted=warn, **connection_args) }}" - - name: assert that deleted_secret is defined + - name: Assert that deleted_secret is defined ansible.builtin.assert: that: - deleted_secret is defined - deleted_secret | list | length == 0 - - name: lookup deleted secret (error) + - name: Lookup deleted secret (error) ansible.builtin.set_fact: missing_secret: "{{ lookup('amazon.aws.secretsmanager_secret', secret_name, **connection_args) }}" ignore_errors: true register: get_deleted_secret - - name: assert that setting the deleted_secret failed + - name: Assert that setting the deleted_secret failed ansible.builtin.assert: that: - get_deleted_secret is failed # Test with nested secrets - - include_tasks: tasks/nested.yaml - + - ansible.builtin.include_tasks: tasks/nested.yaml always: # delete secret created - - name: delete secret + - name: Delete secret community.aws.secretsmanager_secret: name: "{{ secret_name }}" state: absent diff --git a/tests/integration/targets/lookup_secretsmanager_secret/tasks/nested.yaml b/tests/integration/targets/lookup_secretsmanager_secret/tasks/nested.yaml index 5817c2a7e51..60f0973ad84 100644 --- a/tests/integration/targets/lookup_secretsmanager_secret/tasks/nested.yaml +++ b/tests/integration/targets/lookup_secretsmanager_secret/tasks/nested.yaml @@ -3,49 +3,52 @@ json_secret_name: "ansible-test-{{ tiny_prefix }}-secret-json" json_secret_value: "{{ json_secret | to_json }}" block: - - name: create secret "{{ json_secret_name }}" + - name: Create secret "{{ json_secret_name }}" community.aws.secretsmanager_secret: name: "{{ json_secret_name }}" secret: "{{ json_secret_value }}" state: present - name: Validate nested secret value - assert: + ansible.builtin.assert: that: - lookup('amazon.aws.secretsmanager_secret', json_secret_name + '.resource_prefix', nested=True, **connection_args) == resource_prefix - - name: Read missing secret variable using 'on_missing==error' - set_fact: - missing_err_secret: "{{ lookup('amazon.aws.secretsmanager_secret', json_secret_name + '.missing_err_secret', nested=True, on_missing='error', **connection_args) }}" + - name: Read missing secret variable using 'on_missing==error' + ansible.builtin.set_fact: + missing_err_secret: "{{ lookup('amazon.aws.secretsmanager_secret', json_secret_name + '.missing_err_secret', nested=True, on_missing='error', **connection_args) + }}" register: on_missing_error ignore_errors: true - name: Ensure the lookup raised an error - assert: + ansible.builtin.assert: that: - on_missing_error is failed - on_missing_error.msg == "Successfully retrieved secret but there exists no key missing_err_secret in the secret" - missing_err_secret is undefined - - - name: Read missing secret variable using 'on_missing==error' - set_fact: - resource_prefix_child: "{{ lookup('amazon.aws.secretsmanager_secret', json_secret_name + '.resource_prefix.child', nested=True, on_missing='error', **connection_args) }}" + + - name: Read missing secret variable using 'on_missing==error' + ansible.builtin.set_fact: + resource_prefix_child: "{{ lookup('amazon.aws.secretsmanager_secret', json_secret_name + '.resource_prefix.child', nested=True, on_missing='error', **connection_args) + }}" register: nested_child ignore_errors: true - name: Ensure the lookup raised an error - assert: + ansible.builtin.assert: that: - nested_child is failed - nested_child.msg == "Successfully retrieved secret but there exists no key resource_prefix.child in the secret" - resource_prefix_child is undefined - - name: Read missing secret variable using 'on_missing==warn' - set_fact: - missing_wrn_secret: "{{ lookup('amazon.aws.secretsmanager_secret', json_secret_name + '.missing_wrn_secret', nested=True, on_missing='warn', **connection_args) }}" + - name: Read missing secret variable using 'on_missing==warn' + ansible.builtin.set_fact: + missing_wrn_secret: "{{ lookup('amazon.aws.secretsmanager_secret', json_secret_name + '.missing_wrn_secret', nested=True, on_missing='warn', **connection_args) + }}" - name: Ensure that the variable has not been defined - assert: + ansible.builtin.assert: that: - missing_wrn_secret == [] diff --git a/tests/integration/targets/lookup_ssm_parameter/tasks/main.yml b/tests/integration/targets/lookup_ssm_parameter/tasks/main.yml index ed8cbe5fbb8..7429e80a162 100644 --- a/tests/integration/targets/lookup_ssm_parameter/tasks/main.yml +++ b/tests/integration/targets/lookup_ssm_parameter/tasks/main.yml @@ -8,7 +8,7 @@ session_token: "{{ security_token | default(omit) }}" no_log: true -- name: aws_ssm lookup plugin integration tests +- name: Aws_ssm lookup plugin integration tests module_defaults: group/aws: access_key: "{{ aws_access_key }}" @@ -44,7 +44,7 @@ block: # ============================================================ # Simple key/value - - name: lookup a missing key (error) + - name: Lookup a missing key (error) ansible.builtin.set_fact: lookup_value: "{{ lookup('amazon.aws.aws_ssm', simple_name, **connection_args) }}" ignore_errors: true @@ -53,7 +53,7 @@ that: - lookup_missing is failed - - name: lookup a missing key (warn) + - name: Lookup a missing key (warn) ansible.builtin.set_fact: lookup_value: "{{ lookup('amazon.aws.aws_ssm', simple_name, on_missing=warn, **connection_args) }}" register: lookup_missing @@ -61,7 +61,7 @@ that: - lookup_value | list | length == 0 - - name: lookup a single missing key (skip) + - name: Lookup a single missing key (skip) ansible.builtin.set_fact: lookup_value: "{{ lookup('amazon.aws.aws_ssm', simple_name, on_missing=skip, **connection_args) }}" register: lookup_missing @@ -137,15 +137,15 @@ - name: Create nested key/value pair in aws parameter store (4) community.aws.ssm_parameter: - name: '{{ path_name_d }}' - description: '{{ path_description }}' - value: '{{ path_value_d }}' + name: "{{ path_name_d }}" + description: "{{ path_description }}" + value: "{{ path_value_d }}" # ============================================================ - name: Lookup a keys using bypath ansible.builtin.set_fact: - lookup_value: "{{ lookup('amazon.aws.aws_ssm', path_name, bypath=True, wantlist=True, **connection_args ) | first }}" + lookup_value: "{{ lookup('amazon.aws.aws_ssm', path_name, bypath=True, wantlist=True, **connection_args) | first }}" - ansible.builtin.assert: that: - path_name_a in lookup_value @@ -156,7 +156,7 @@ - name: Lookup a keys using bypath and recursive ansible.builtin.set_fact: - lookup_value: "{{ lookup('amazon.aws.aws_ssm', path_name, bypath=True, recursive=True, wantlist=True, **connection_args ) | first }}" + lookup_value: "{{ lookup('amazon.aws.aws_ssm', path_name, bypath=True, recursive=True, wantlist=True, **connection_args) | first }}" - ansible.builtin.assert: that: - path_name_a in lookup_value @@ -171,7 +171,7 @@ - name: Lookup a keys using bypath and shortname ansible.builtin.set_fact: - lookup_value: "{{ lookup('amazon.aws.aws_ssm', path_name, bypath=True, shortnames=True, wantlist=True, **connection_args ) | first }}" + lookup_value: "{{ lookup('amazon.aws.aws_ssm', path_name, bypath=True, shortnames=True, wantlist=True, **connection_args) | first }}" - ansible.builtin.assert: that: - path_shortname_a in lookup_value @@ -182,7 +182,7 @@ - name: Lookup a keys using bypath and recursive and shortname ansible.builtin.set_fact: - lookup_value: "{{ lookup('amazon.aws.aws_ssm', path_name, bypath=True, recursive=True, shortnames=True, wantlist=True, **connection_args ) | first }}" + lookup_value: "{{ lookup('amazon.aws.aws_ssm', path_name, bypath=True, recursive=True, shortnames=True, wantlist=True, **connection_args) | first }}" - ansible.builtin.assert: that: - path_shortname_a in lookup_value @@ -195,7 +195,7 @@ - name: Lookup a keys using bypath and recursive and droppath ansible.builtin.set_fact: - lookup_value: "{{ lookup('amazon.aws.aws_ssm', path_name, bypath=True, recursive=True, droppath=True, wantlist=True, **connection_args ) | first }}" + lookup_value: "{{ lookup('amazon.aws.aws_ssm', path_name, bypath=True, recursive=True, droppath=True, wantlist=True, **connection_args) | first }}" - ansible.builtin.assert: that: - path_droppath_name_a in lookup_value @@ -295,7 +295,7 @@ # ============================================================ - name: Delete remaining key/value pairs in aws parameter store community.aws.ssm_parameter: - name: "{{item}}" + name: "{{ item }}" state: absent ignore_errors: true with_items: diff --git a/tests/integration/targets/module_utils_botocore_recorder/main.yml b/tests/integration/targets/module_utils_botocore_recorder/main.yml index 1b7aef23881..5779b3bc2a8 100644 --- a/tests/integration/targets/module_utils_botocore_recorder/main.yml +++ b/tests/integration/targets/module_utils_botocore_recorder/main.yml @@ -1,5 +1,6 @@ --- -- hosts: localhost +- name: Run aws_az_info tests using a placebo recording + hosts: localhost tasks: - name: Call aws_az_info amazon.aws.aws_az_info: @@ -9,4 +10,6 @@ register: result - ansible.builtin.assert: that: - - lookup('ansible.builtin.env', '_ANSIBLE_PLACEBO_RECORD') or (lookup('ansible.builtin.env', '_ANSIBLE_PLACEBO_REPLAY') and result.user_id == "AWZBREIZHEOMABRONIFVGFS6GH") + - result.user_id == "AIDA12345EXAMPLE54321" + when: + - lookup('ansible.builtin.env', '_ANSIBLE_PLACEBO_REPLAY') diff --git a/tests/integration/targets/module_utils_botocore_recorder/recording.tar.gz b/tests/integration/targets/module_utils_botocore_recorder/recording.tar.gz index 29c8dd90a11..cd87396da94 100644 Binary files a/tests/integration/targets/module_utils_botocore_recorder/recording.tar.gz and b/tests/integration/targets/module_utils_botocore_recorder/recording.tar.gz differ diff --git a/tests/integration/targets/module_utils_core/main.yml b/tests/integration/targets/module_utils_core/main.yml index 9c2f3fa14f9..012f65a020a 100644 --- a/tests/integration/targets/module_utils_core/main.yml +++ b/tests/integration/targets/module_utils_core/main.yml @@ -1,5 +1,6 @@ --- -- hosts: all +- name: Run tests for common credential/connection helpers + hosts: all gather_facts: false roles: # Test the behaviour of module_utils.core.AnsibleAWSModule.client (boto3) diff --git a/tests/integration/targets/module_utils_core/setup.yml b/tests/integration/targets/module_utils_core/setup.yml index 992498fc3b1..9081dfec04b 100644 --- a/tests/integration/targets/module_utils_core/setup.yml +++ b/tests/integration/targets/module_utils_core/setup.yml @@ -1,5 +1,6 @@ --- -- hosts: localhost +- name: Prepare environment for common credential/connection helper tests + hosts: localhost connection: local gather_facts: false tasks: @@ -33,8 +34,10 @@ ansible.builtin.template: dest: ./session_credentials.yml src: session_credentials.yml.j2 + mode: "0600" - name: Write out boto config file ansible.builtin.template: dest: ./boto3_config src: boto_config.j2 + mode: "0644" diff --git a/tests/integration/targets/module_utils_waiter/main.yml b/tests/integration/targets/module_utils_waiter/main.yml index 2bb3fc49036..be4a3ba974e 100644 --- a/tests/integration/targets/module_utils_waiter/main.yml +++ b/tests/integration/targets/module_utils_waiter/main.yml @@ -1,5 +1,6 @@ --- -- hosts: all +- name: Tests for common waiter helpers + hosts: all gather_facts: false roles: # Test the behaviour of module_utils.core.AnsibleAWSModule.client (boto3) diff --git a/tests/integration/targets/rds_cluster_create/defaults/main.yml b/tests/integration/targets/rds_cluster_create/defaults/main.yml index c65e705f14e..13ee7e985a7 100644 --- a/tests/integration/targets/rds_cluster_create/defaults/main.yml +++ b/tests/integration/targets/rds_cluster_create/defaults/main.yml @@ -6,7 +6,7 @@ cluster_id: ansible-test-cluster-{{ tiny_prefix }} username: testrdsusername password: test-rds_password engine: aurora-mysql -port: 3306 +db_port: 3306 tags_create: Name: ansible-test-cluster-{{ tiny_prefix }} Created_By: Ansible_rds_cluster_integration_test diff --git a/tests/integration/targets/rds_cluster_create/tasks/main.yaml b/tests/integration/targets/rds_cluster_create/tasks/main.yaml index 5689efbbaa5..5d705f39721 100644 --- a/tests/integration/targets/rds_cluster_create/tasks/main.yaml +++ b/tests/integration/targets/rds_cluster_create/tasks/main.yaml @@ -10,7 +10,7 @@ amazon.aws.rds_cluster: id: "{{ cluster_id }}" state: absent - engine: "{{ engine}}" + engine: "{{ engine }}" username: "{{ username }}" password: "{{ password }}" skip_final_snapshot: true @@ -73,7 +73,7 @@ - "'master_username' in _result_create_db_cluster" - _result_create_db_cluster.master_username == username - "'port' in _result_create_db_cluster" - - _result_create_db_cluster.port == port + - _result_create_db_cluster.port == db_port - "'status' in _result_create_db_cluster" - _result_create_db_cluster.status == 'available' - _result_create_db_cluster.storage_encrypted == false @@ -129,7 +129,7 @@ storage_type: aurora-iopt1 register: _result_create_db_cluster_io_optimized - - assert: + - ansible.builtin.assert: that: - _result_create_db_cluster_io_optimized.changed # as of 5/2024, API does not return the value of storage_type when storage_type not set or set to "aurora" @@ -150,7 +150,7 @@ register: _result_create_db_cluster_io_optimized ignore_errors: true - - assert: + - ansible.builtin.assert: that: - not _result_create_db_cluster_io_optimized.changed - _result_create_db_cluster_io_optimized.failed diff --git a/tests/integration/targets/rds_cluster_create_sgs/defaults/main.yml b/tests/integration/targets/rds_cluster_create_sgs/defaults/main.yml index 1db33548a30..474f58693ac 100644 --- a/tests/integration/targets/rds_cluster_create_sgs/defaults/main.yml +++ b/tests/integration/targets/rds_cluster_create_sgs/defaults/main.yml @@ -6,7 +6,7 @@ cluster_id: ansible-test-cluster-{{ tiny_prefix }} username: testrdsusername password: test-rds_password engine: aurora-mysql -port: 3306 +db_port: 3306 # Create cluster in a VPC vpc_name: ansible-test-vpc-{{ tiny_prefix }} 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 6e6c1c41e8c..3dec6df1668 100644 --- a/tests/integration/targets/rds_cluster_create_sgs/tasks/main.yaml +++ b/tests/integration/targets/rds_cluster_create_sgs/tasks/main.yaml @@ -10,7 +10,7 @@ amazon.aws.rds_cluster: id: "{{ cluster_id }}" state: absent - engine: "{{ engine}}" + engine: "{{ engine }}" username: "{{ username }}" password: "{{ password }}" skip_final_snapshot: true @@ -83,7 +83,7 @@ - "'master_username' in _result_create_db_cluster" - _result_create_db_cluster.master_username == username - "'port' in _result_create_db_cluster" - - _result_create_db_cluster.port == port + - _result_create_db_cluster.port == db_port - "'status' in _result_create_db_cluster" - _result_create_db_cluster.status == 'available' - _result_create_db_cluster.storage_encrypted == false @@ -137,7 +137,7 @@ - "'master_username' in _result_create_db_cluster" - _result_create_db_cluster.master_username == username - "'port' in _result_create_db_cluster" - - _result_create_db_cluster.port == port + - _result_create_db_cluster.port == db_port - "'status' in _result_create_db_cluster" - _result_create_db_cluster.status == 'available' - _result_create_db_cluster.storage_encrypted == false diff --git a/tests/integration/targets/rds_cluster_modify/defaults/main.yml b/tests/integration/targets/rds_cluster_modify/defaults/main.yml index ccfc6d3d25a..083ee8144bc 100644 --- a/tests/integration/targets/rds_cluster_modify/defaults/main.yml +++ b/tests/integration/targets/rds_cluster_modify/defaults/main.yml @@ -6,7 +6,7 @@ cluster_id: ansible-test-cluster-{{ tiny_prefix }} username: testrdsusername password: test-rds_password engine: aurora -port: 3306 +db_port: 3306 # Modify cluster new_cluster_id: ansible-test-cluster-{{ tiny_prefix }}-new diff --git a/tests/integration/targets/rds_cluster_modify/tasks/create_update_cluster_serverless_v2_scaling_configuration.yaml b/tests/integration/targets/rds_cluster_modify/tasks/create_update_cluster_serverless_v2_scaling_configuration.yaml index e97fcd01133..522a8c9c76c 100644 --- a/tests/integration/targets/rds_cluster_modify/tasks/create_update_cluster_serverless_v2_scaling_configuration.yaml +++ b/tests/integration/targets/rds_cluster_modify/tasks/create_update_cluster_serverless_v2_scaling_configuration.yaml @@ -21,7 +21,7 @@ region: "{{ aws_region }}" register: result - - assert: + - ansible.builtin.assert: that: - create_result_check_mode is changed - create_result_check_mode is not failed @@ -46,7 +46,7 @@ region: "{{ aws_region }}" register: result - - assert: + - ansible.builtin.assert: that: - create_result is changed - create_result is not failed @@ -73,7 +73,7 @@ region: "{{ aws_region }}" register: result - - assert: + - ansible.builtin.assert: that: - modify_result_check_mode is changed - modify_result_check_mode is not failed @@ -99,7 +99,7 @@ region: "{{ aws_region }}" register: result - - assert: + - ansible.builtin.assert: that: - modify_result is changed - modify_result is not failed @@ -108,11 +108,10 @@ - result.clusters[0].serverless_v2_scaling_configuration.max_capacity == 5 always: - - name: Delete DB cluster created in this test amazon.aws.rds_cluster: cluster_id: "{{ cluster_id }}" region: "{{ aws_region }}" skip_final_snapshot: true state: absent - ignore_errors: true \ No newline at end of file + ignore_errors: true diff --git a/tests/integration/targets/rds_cluster_modify/tasks/main.yaml b/tests/integration/targets/rds_cluster_modify/tasks/main.yaml index 5bc460de09a..6d1539b404f 100644 --- a/tests/integration/targets/rds_cluster_modify/tasks/main.yaml +++ b/tests/integration/targets/rds_cluster_modify/tasks/main.yaml @@ -12,13 +12,12 @@ # import_tasks: remove_from_global_db.yaml - name: Run tests for testing serverless v2 scaling configuration - import_tasks: create_update_cluster_serverless_v2_scaling_configuration.yaml - + ansible.builtin.import_tasks: create_update_cluster_serverless_v2_scaling_configuration.yaml - name: Ensure the resource doesn't exist amazon.aws.rds_cluster: id: "{{ cluster_id }}" state: absent - engine: "{{ engine}}" + engine: "{{ engine }}" username: "{{ username }}" password: "{{ password }}" skip_final_snapshot: true @@ -63,7 +62,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 == db_port - "'status' in _result_create_source_db_cluster" - _result_create_source_db_cluster.status == "available" - "'tags' in _result_create_source_db_cluster" @@ -98,7 +97,7 @@ - "'master_username' in _result_modify_password" - _result_modify_password.master_username == username - "'port' in _result_create_source_db_cluster" - - _result_modify_password.port == port + - _result_modify_password.port == db_port - "'status' in _result_modify_password" - _result_modify_password.status == "available" - "'tags' in _result_modify_password" @@ -172,27 +171,18 @@ - "'tags' in _result_modify_id" - "'vpc_security_groups' in _result_modify_id" - - name: Check if DB cluster parameter group exists - ansible.builtin.command: aws rds describe-db-cluster-parameter-groups --db-cluster-parameter-group-name {{ new_db_parameter_group_name }} - environment: - AWS_ACCESS_KEY_ID: "{{ aws_access_key }}" - AWS_SECRET_ACCESS_KEY: "{{ aws_secret_key }}" - AWS_SESSION_TOKEN: "{{ security_token | default('') }}" - AWS_DEFAULT_REGION: "{{ aws_region }}" - register: _result_check_db_parameter_group - ignore_errors: true - changed_when: _result_check_db_parameter_group.rc == 0 - - name: Create DB cluster parameter group if not exists - ansible.builtin.command: aws rds create-db-cluster-parameter-group --db-cluster-parameter-group-name {{ new_db_parameter_group_name }} --db-parameter-group-family - aurora-mysql8.0 --description "Test DB cluster parameter group" - environment: - AWS_ACCESS_KEY_ID: "{{ aws_access_key }}" - AWS_SECRET_ACCESS_KEY: "{{ aws_secret_key }}" - AWS_SESSION_TOKEN: "{{ security_token | default('') }}" - AWS_DEFAULT_REGION: "{{ aws_region }}" + amazon.aws.rds_cluster_param_group: + name: "{{ new_db_parameter_group_name }}" + state: present + db_parameter_group_family: aurora-mysql8.0 + description: "Test DB cluster parameter group" register: _result_create_db_parameter_group - when: _result_check_db_parameter_group.rc != 0 + + - name: Check param group was successfully created + ansible.builtin.assert: + that: + - _result_create_db_parameter_group is changed - name: Modify DB cluster parameter group amazon.aws.rds_cluster: @@ -270,11 +260,8 @@ skip_final_snapshot: true ignore_errors: true - - name: Delete cluster parameter group - ansible.builtin.command: aws rds delete-db-cluster-parameter-group --db-cluster-parameter-group-name {{ new_db_parameter_group_name }} - environment: - AWS_ACCESS_KEY_ID: "{{ aws_access_key }}" - AWS_SECRET_ACCESS_KEY: "{{ aws_secret_key }}" - AWS_SESSION_TOKEN: "{{ security_token | default('') }}" - AWS_DEFAULT_REGION: "{{ aws_region }}" - ignore_errors: true + - name: Create DB cluster parameter group if not exists + amazon.aws.rds_cluster_param_group: + name: "{{ new_db_parameter_group_name }}" + state: absent + ignore_errors: true # noqa: ignore-errors diff --git a/tests/integration/targets/rds_cluster_modify/tasks/remove_from_global_db.yaml b/tests/integration/targets/rds_cluster_modify/tasks/remove_from_global_db.yaml index 0ff687f0b35..5c3d31d97f3 100644 --- a/tests/integration/targets/rds_cluster_modify/tasks/remove_from_global_db.yaml +++ b/tests/integration/targets/rds_cluster_modify/tasks/remove_from_global_db.yaml @@ -47,8 +47,9 @@ AWS_SESSION_TOKEN: "{{ security_token | default('') }}" AWS_DEFAULT_REGION: "{{ test_primary_cluster_region }}" register: global_cluster_info_result + changed_when: false - - name: convert it to an object + - name: Convert it to an object ansible.builtin.set_fact: global_cluster_info: "{{ global_cluster_info_result.stdout | from_json }}" @@ -82,8 +83,9 @@ AWS_SESSION_TOKEN: "{{ security_token | default('') }}" AWS_DEFAULT_REGION: "{{ test_primary_cluster_region }}" register: global_cluster_info_result + changed_when: false - - name: convert it to an object + - name: Convert it to an object ansible.builtin.set_fact: global_cluster_info: "{{ global_cluster_info_result.stdout | from_json }}" @@ -143,8 +145,9 @@ AWS_SESSION_TOKEN: "{{ security_token | default('') }}" AWS_DEFAULT_REGION: "{{ test_primary_cluster_region }}" register: global_cluster_info_result + changed_when: false - - name: convert it to an object + - name: Convert it to an object ansible.builtin.set_fact: global_cluster_info: "{{ global_cluster_info_result.stdout | from_json }}" @@ -187,8 +190,9 @@ AWS_SESSION_TOKEN: "{{ security_token | default('') }}" AWS_DEFAULT_REGION: "{{ test_primary_cluster_region }}" register: global_cluster_info_result + changed_when: false - - name: convert it to an object + - name: Convert it to an object ansible.builtin.set_fact: global_cluster_info: "{{ global_cluster_info_result.stdout | from_json }}" diff --git a/tests/integration/targets/rds_cluster_param_group/tasks/main.yaml b/tests/integration/targets/rds_cluster_param_group/tasks/main.yaml index 3eb85f61717..4ee041c6484 100644 --- a/tests/integration/targets/rds_cluster_param_group/tasks/main.yaml +++ b/tests/integration/targets/rds_cluster_param_group/tasks/main.yaml @@ -202,7 +202,8 @@ - "'parameter_value' not in auth_timeout_param" vars: array_nulls_param: "{{ initial_params.db_cluster_parameter_groups.0.db_parameters | selectattr('parameter_name', 'equalto', 'array_nulls') | first }}" - auth_timeout_param: "{{ initial_params.db_cluster_parameter_groups.0.db_parameters | selectattr('parameter_name', 'equalto', 'authentication_timeout') | first }}" + auth_timeout_param: "{{ initial_params.db_cluster_parameter_groups.0.db_parameters | selectattr('parameter_name', 'equalto', 'authentication_timeout') | first + }}" - name: Modify RDS cluster parameter group with new parameters amazon.aws.rds_cluster_param_group: @@ -228,8 +229,10 @@ ansible.builtin.assert: that: - update_parameters is changed - - cluster_params.db_cluster_parameter_groups.0.db_parameters | selectattr('parameter_name', 'equalto', 'array_nulls') | first | community.general.json_query('parameter_value') == "0" - - cluster_params.db_cluster_parameter_groups.0.db_parameters | selectattr('parameter_name', 'equalto', 'authentication_timeout') | first | community.general.json_query('parameter_value') == "50" + - cluster_params.db_cluster_parameter_groups.0.db_parameters | selectattr('parameter_name', 'equalto', 'array_nulls') | first | community.general.json_query('parameter_value') + == "0" + - cluster_params.db_cluster_parameter_groups.0.db_parameters | selectattr('parameter_name', 'equalto', 'authentication_timeout') | first | community.general.json_query('parameter_value') + == "50" # Test Modify parameters (idempotency) - name: Modify RDS cluster parameter group with new parameters (idempotency with check_mode) @@ -284,7 +287,7 @@ register: cluster_params - name: Validate that module execution reported change but the RDS cluster param group was not deleted - assert: + ansible.builtin.assert: that: - delete_cluster_param_checkmode is changed - cluster_params.db_cluster_parameter_groups | length == 1 diff --git a/tests/integration/targets/rds_cluster_promote/defaults/main.yml b/tests/integration/targets/rds_cluster_promote/defaults/main.yml index ef6fed001b4..20ee95552b2 100644 --- a/tests/integration/targets/rds_cluster_promote/defaults/main.yml +++ b/tests/integration/targets/rds_cluster_promote/defaults/main.yml @@ -6,4 +6,4 @@ cluster_id: ansible-test-cluster-{{ tiny_prefix }} username: testrdsusername password: test-rds_password engine: aurora -port: 3306 +db_port: 3306 diff --git a/tests/integration/targets/rds_cluster_promote/tasks/main.yaml b/tests/integration/targets/rds_cluster_promote/tasks/main.yaml index 16dda531ba4..47d9cd829d8 100644 --- a/tests/integration/targets/rds_cluster_promote/tasks/main.yaml +++ b/tests/integration/targets/rds_cluster_promote/tasks/main.yaml @@ -10,7 +10,7 @@ amazon.aws.rds_cluster: id: "{{ cluster_id }}" state: absent - engine: "{{ engine}}" + engine: "{{ engine }}" username: "{{ username }}" password: "{{ password }}" skip_final_snapshot: true @@ -30,7 +30,7 @@ amazon.aws.rds_cluster: cluster_id: "{{ cluster_id }}" state: present - engine: "{{ engine}}" + engine: "{{ engine }}" username: "{{ username }}" password: "{{ password }}" region: "{{ region_src }}" @@ -59,7 +59,7 @@ - "'master_username' in _result_create_src_db_cluster" - _result_create_src_db_cluster.master_username == username - "'port' in _result_create_src_db_cluster" - - _result_create_src_db_cluster.port == port + - _result_create_src_db_cluster.port == db_port - "'status' in _result_create_src_db_cluster" - _result_create_src_db_cluster.status == "available" - "'tags' in _result_create_src_db_cluster" @@ -79,14 +79,14 @@ - name: Set the ARN of the source DB cluster ansible.builtin.set_fact: - src_db_cluster_arn: "{{ _result_cluster_info.clusters[0].db_cluster_arn}}" + src_db_cluster_arn: "{{ _result_cluster_info.clusters[0].db_cluster_arn }}" - name: Create a DB cluster read replica in a different region amazon.aws.rds_cluster: id: "{{ cluster_id }}-replica" state: present replication_source_identifier: "{{ src_db_cluster_arn }}" - engine: "{{ engine}}" + engine: "{{ engine }}" region: "{{ region_dest }}" tags: Name: "{{ cluster_id }}" @@ -114,7 +114,7 @@ - "'master_username' in _result_create_replica_db_cluster" - _result_create_replica_db_cluster.master_username == username - "'port' in _result_create_replica_db_cluster" - - _result_create_replica_db_cluster.port == port + - _result_create_replica_db_cluster.port == db_port - "'status' in _result_create_replica_db_cluster" - _result_create_replica_db_cluster.status == "available" - "'tags' in _result_create_replica_db_cluster" @@ -128,7 +128,7 @@ id: "{{ cluster_id }}-replica" state: present replication_source_identifier: "{{ src_db_cluster_arn }}" - engine: "{{ engine}}" + engine: "{{ engine }}" region: "{{ region_dest }}" tags: Name: "{{ cluster_id }}" diff --git a/tests/integration/targets/rds_cluster_restore/defaults/main.yml b/tests/integration/targets/rds_cluster_restore/defaults/main.yml index 849d85fe27d..05a8f96dd02 100644 --- a/tests/integration/targets/rds_cluster_restore/defaults/main.yml +++ b/tests/integration/targets/rds_cluster_restore/defaults/main.yml @@ -6,4 +6,4 @@ cluster_id: ansible-test-cluster-{{ tiny_prefix }} username: testrdsusername password: test-rds_password engine: aurora-mysql -port: 3306 +db_port: 3306 diff --git a/tests/integration/targets/rds_cluster_restore/tasks/main.yaml b/tests/integration/targets/rds_cluster_restore/tasks/main.yaml index 9df00620c7d..905770be17e 100644 --- a/tests/integration/targets/rds_cluster_restore/tasks/main.yaml +++ b/tests/integration/targets/rds_cluster_restore/tasks/main.yaml @@ -10,7 +10,7 @@ amazon.aws.rds_cluster: id: "{{ cluster_id }}" state: absent - engine: "{{ engine}}" + engine: "{{ engine }}" username: "{{ username }}" password: "{{ password }}" skip_final_snapshot: true @@ -25,7 +25,7 @@ amazon.aws.rds_cluster: id: "{{ cluster_id }}" state: present - engine: "{{ engine}}" + engine: "{{ engine }}" backup_retention_period: 1 username: "{{ username }}" password: "{{ password }}" @@ -53,7 +53,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 == db_port - "'status' in _result_create_source_db_cluster" - _result_create_source_db_cluster.status == 'available' - _result_create_source_db_cluster.storage_encrypted == false @@ -66,7 +66,7 @@ id: "{{ cluster_id }}-point-in-time" source_db_cluster_identifier: "{{ cluster_id }}" creation_source: cluster - engine: "{{ engine}}" + engine: "{{ engine }}" username: "{{ username }}" password: "{{ password }}" use_latest_restorable_time: true @@ -95,7 +95,7 @@ - "'master_username' in _result_restored_db_cluster" - _result_restored_db_cluster.master_username == username - "'port' in _result_restored_db_cluster" - - _result_restored_db_cluster.port == port + - _result_restored_db_cluster.port == db_port - "'status' in _result_restored_db_cluster" - _result_restored_db_cluster.status == "available" - "'tags' in _result_restored_db_cluster" @@ -110,7 +110,7 @@ id: "{{ cluster_id }}-point-in-time" source_db_cluster_identifier: "{{ cluster_id }}" creation_source: cluster - engine: "{{ engine}}" + engine: "{{ engine }}" username: "{{ username }}" password: "{{ password }}" restore_to_time: "{{ _result_restored_db_cluster.latest_restorable_time }}" @@ -164,7 +164,7 @@ - "'master_username' in _result_restored_db_cluster" - _result_restored_db_cluster.master_username == username - "'port' in _result_restored_db_cluster" - - _result_restored_db_cluster.port == port + - _result_restored_db_cluster.port == db_port - "'status' in _result_restored_db_cluster" - _result_restored_db_cluster.status == "available" - "'tags' in _result_restored_db_cluster" diff --git a/tests/integration/targets/rds_cluster_snapshot/defaults/main.yml b/tests/integration/targets/rds_cluster_snapshot/defaults/main.yml index 39e3dfaf41c..b7f619adbba 100644 --- a/tests/integration/targets/rds_cluster_snapshot/defaults/main.yml +++ b/tests/integration/targets/rds_cluster_snapshot/defaults/main.yml @@ -7,7 +7,7 @@ cluster_id: "{{ _resource_prefix }}-rds-cluster" username: testrdsusername password: "{{ lookup('password', 'dev/null length=12 chars=ascii_letters,digits') }}" engine: aurora-mysql -port: 3306 +db_port: 3306 # Create snapshot snapshot_id: "{{ _resource_prefix }}-rds-cluster-snapshot" diff --git a/tests/integration/targets/rds_cluster_snapshot/tasks/main.yml b/tests/integration/targets/rds_cluster_snapshot/tasks/main.yml index 25165e37765..217ea2c360b 100644 --- a/tests/integration/targets/rds_cluster_snapshot/tasks/main.yml +++ b/tests/integration/targets/rds_cluster_snapshot/tasks/main.yml @@ -11,7 +11,7 @@ amazon.aws.rds_cluster: id: "{{ cluster_id }}" state: present - engine: "{{ engine}}" + engine: "{{ engine }}" backup_retention_period: 1 username: "{{ username }}" password: "{{ password }}" @@ -38,7 +38,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 == db_port - "'status' in _result_create_source_db_cluster" - _result_create_source_db_cluster.status == "available" - "'tags' in _result_create_source_db_cluster" @@ -125,7 +125,7 @@ amazon.aws.rds_cluster: id: "{{ cluster_id }}-b" state: present - engine: "{{ engine}}" + engine: "{{ engine }}" backup_retention_period: 1 username: "{{ username }}" password: "{{ password }}" @@ -152,7 +152,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 == db_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_cluster_states/tasks/main.yml b/tests/integration/targets/rds_cluster_states/tasks/main.yml index 699cba9a166..78fc2e54331 100644 --- a/tests/integration/targets/rds_cluster_states/tasks/main.yml +++ b/tests/integration/targets/rds_cluster_states/tasks/main.yml @@ -12,7 +12,7 @@ amazon.aws.rds_cluster: id: "{{ cluster_id }}" state: absent - engine: "{{ engine}}" + engine: "{{ engine }}" username: "{{ username }}" password: "{{ password }}" skip_final_snapshot: true diff --git a/tests/integration/targets/rds_cluster_tag/defaults/main.yml b/tests/integration/targets/rds_cluster_tag/defaults/main.yml index 1cdd511ef87..e69d4204e71 100644 --- a/tests/integration/targets/rds_cluster_tag/defaults/main.yml +++ b/tests/integration/targets/rds_cluster_tag/defaults/main.yml @@ -6,7 +6,7 @@ cluster_id: ansible-test-cluster-{{ tiny_prefix }} username: testrdsusername password: test-rds_password engine: aurora-mysql -port: 3306 +db_port: 3306 tags_create: Name: ansible-test-cluster-{{ tiny_prefix }} Created_By: Ansible_rds_cluster_integration_test diff --git a/tests/integration/targets/rds_cluster_tag/tasks/main.yaml b/tests/integration/targets/rds_cluster_tag/tasks/main.yaml index c0968cd05d4..5f0ffabae80 100644 --- a/tests/integration/targets/rds_cluster_tag/tasks/main.yaml +++ b/tests/integration/targets/rds_cluster_tag/tasks/main.yaml @@ -10,7 +10,7 @@ amazon.aws.rds_cluster: id: "{{ cluster_id }}" state: absent - engine: "{{ engine}}" + engine: "{{ engine }}" username: "{{ username }}" password: "{{ password }}" skip_final_snapshot: true @@ -51,7 +51,7 @@ - "'master_username' in _result_create_db_cluster" - _result_create_db_cluster.master_username == username - "'port' in _result_create_db_cluster" - - _result_create_db_cluster.port == port + - _result_create_db_cluster.port == db_port - "'status' in _result_create_db_cluster" - _result_create_db_cluster.status == 'available' - _result_create_db_cluster.storage_encrypted == false @@ -92,7 +92,7 @@ - "'master_username' in _result_tag_db_cluster" - _result_tag_db_cluster.master_username == username - "'port' in _result_tag_db_cluster" - - _result_tag_db_cluster.port == port + - _result_tag_db_cluster.port == db_port - "'status' in _result_tag_db_cluster" - _result_tag_db_cluster.status == 'available' - _result_tag_db_cluster.storage_encrypted == false @@ -130,7 +130,7 @@ - "'master_username' in _result_tag_db_cluster" - _result_tag_db_cluster.master_username == username - "'port' in _result_tag_db_cluster" - - _result_tag_db_cluster.port == port + - _result_tag_db_cluster.port == db_port - "'status' in _result_tag_db_cluster" - _result_tag_db_cluster.status == 'available' - _result_tag_db_cluster.storage_encrypted == false @@ -185,7 +185,7 @@ - "'master_username' in _result_tag_db_cluster" - _result_tag_db_cluster.master_username == username - "'port' in _result_tag_db_cluster" - - _result_tag_db_cluster.port == port + - _result_tag_db_cluster.port == db_port - "'status' in _result_tag_db_cluster" - _result_tag_db_cluster.status == 'available' - _result_tag_db_cluster.storage_encrypted == false @@ -240,7 +240,7 @@ - "'master_username' in _result_tag_db_cluster" - _result_tag_db_cluster.master_username == username - "'port' in _result_tag_db_cluster" - - _result_tag_db_cluster.port == port + - _result_tag_db_cluster.port == db_port - "'status' in _result_tag_db_cluster" - _result_tag_db_cluster.status == 'available' - _result_tag_db_cluster.storage_encrypted == false @@ -279,7 +279,7 @@ - "'master_username' in _result_tag_db_cluster" - _result_tag_db_cluster.master_username == username - "'port' in _result_tag_db_cluster" - - _result_tag_db_cluster.port == port + - _result_tag_db_cluster.port == db_port - "'status' in _result_tag_db_cluster" - _result_tag_db_cluster.status == 'available' - _result_tag_db_cluster.storage_encrypted == false diff --git a/tests/integration/targets/rds_instance_aurora/tasks/main.yml b/tests/integration/targets/rds_instance_aurora/tasks/main.yml index db2fec81f53..9af8c04418c 100644 --- a/tests/integration/targets/rds_instance_aurora/tasks/main.yml +++ b/tests/integration/targets/rds_instance_aurora/tasks/main.yml @@ -1,5 +1,5 @@ --- -- name: rds_instance / aurora integration tests +- name: Rds_instance / aurora integration tests module_defaults: group/aws: diff --git a/tests/integration/targets/rds_instance_complex/tasks/main.yml b/tests/integration/targets/rds_instance_complex/tasks/main.yml index 4a6813b1fe6..a7b8f330f6c 100644 --- a/tests/integration/targets/rds_instance_complex/tasks/main.yml +++ b/tests/integration/targets/rds_instance_complex/tasks/main.yml @@ -1,5 +1,5 @@ --- -- name: rds_instance / complex integration tests +- name: Rds_instance / complex integration tests module_defaults: group/aws: @@ -9,7 +9,7 @@ region: "{{ aws_region }}" block: - #TODO: test availability_zone and multi_az + # TODO: test availability_zone and multi_az - name: Ensure the resource doesn't exist amazon.aws.rds_instance: id: "{{ instance_id }}" @@ -24,7 +24,7 @@ - name: Create an enhanced monitoring role amazon.aws.iam_role: - assume_role_policy_document: "{{ lookup('file','files/enhanced_monitoring_assume_policy.json') }}" + assume_role_policy_document: "{{ lookup('file', 'files/enhanced_monitoring_assume_policy.json') }}" name: "{{ instance_id }}-role" state: present managed_policy: arn:aws:iam::aws:policy/service-role/AmazonRDSEnhancedMonitoringRole @@ -191,7 +191,7 @@ - name: Remove enhanced monitoring role amazon.aws.iam_role: - assume_role_policy_document: "{{ lookup('file','files/enhanced_monitoring_assume_policy.json') }}" + assume_role_policy_document: "{{ lookup('file', 'files/enhanced_monitoring_assume_policy.json') }}" name: "{{ instance_id }}-role" state: absent ignore_errors: true diff --git a/tests/integration/targets/rds_instance_modify/tasks/main.yml b/tests/integration/targets/rds_instance_modify/tasks/main.yml index 7a8ba788810..273db0684da 100644 --- a/tests/integration/targets/rds_instance_modify/tasks/main.yml +++ b/tests/integration/targets/rds_instance_modify/tasks/main.yml @@ -1,5 +1,5 @@ --- -- name: rds_instance / modify integration tests +- name: Rds_instance / modify integration tests module_defaults: group/aws: @@ -296,9 +296,9 @@ - result is not changed - result is not failed - db_info.instances[0].ca_certificate_identifier == "rds-ca-ecc384-g1" - # Test modifying CA certificate identifier Complete------------------------------------------- + # Test modifying CA certificate identifier Complete------------------------------------------- - # Test modifying cloudwatch log exports ------------------------------------------- + # Test modifying cloudwatch log exports ------------------------------------------- - name: Enable all cloudwatch log exports - check_mode amazon.aws.rds_instance: state: present diff --git a/tests/integration/targets/rds_instance_processor/tasks/main.yml b/tests/integration/targets/rds_instance_processor/tasks/main.yml index 56aeebb1bf4..d31f58a36fd 100644 --- a/tests/integration/targets/rds_instance_processor/tasks/main.yml +++ b/tests/integration/targets/rds_instance_processor/tasks/main.yml @@ -1,5 +1,5 @@ --- -- name: rds_instance / processor integration tests +- name: Rds_instance / processor integration tests module_defaults: group/aws: @@ -114,10 +114,11 @@ - ansible.builtin.assert: that: - not result.changed - - (result.pending_modified_values.processor_features.coreCount is defined and result.pending_modified_values.processor_features.coreCount | int == modified_processor_features.coreCount) or - (result.processor_features.coreCount is defined and result.processor_features.coreCount | int == modified_processor_features.coreCount) - - (result.pending_modified_values.processor_features.threadsPerCore is defined and result.pending_modified_values.processor_features.threadsPerCore | int == modified_processor_features.threadsPerCore) or - (result.processor_features.threadsPerCore is defined and result.processor_features.threadsPerCore | int == modified_processor_features.threadsPerCore) + - (result.pending_modified_values.processor_features.coreCount is defined and result.pending_modified_values.processor_features.coreCount | int == modified_processor_features.coreCount) + or (result.processor_features.coreCount is defined and result.processor_features.coreCount | int == modified_processor_features.coreCount) + - (result.pending_modified_values.processor_features.threadsPerCore is defined and result.pending_modified_values.processor_features.threadsPerCore | int + == modified_processor_features.threadsPerCore) or (result.processor_features.threadsPerCore is defined and result.processor_features.threadsPerCore | + int == modified_processor_features.threadsPerCore) always: - name: Delete the DB instance diff --git a/tests/integration/targets/rds_instance_replica/tasks/main.yml b/tests/integration/targets/rds_instance_replica/tasks/main.yml index 56c212aac4a..dbdf11527f9 100644 --- a/tests/integration/targets/rds_instance_replica/tasks/main.yml +++ b/tests/integration/targets/rds_instance_replica/tasks/main.yml @@ -1,5 +1,5 @@ --- -- name: rds_instance / replica integration tests +- name: Rds_instance / replica integration tests module_defaults: group/aws: @@ -9,7 +9,7 @@ region: "{{ aws_region }}" block: - - name: set the two regions for the source DB and the replica + - name: Set the two regions for the source DB and the replica ansible.builtin.set_fact: region_src: "{{ aws_region }}" region_dest: "{{ aws_region }}" diff --git a/tests/integration/targets/rds_instance_restore/tasks/main.yml b/tests/integration/targets/rds_instance_restore/tasks/main.yml index 48e31876fd1..350474e440c 100644 --- a/tests/integration/targets/rds_instance_restore/tasks/main.yml +++ b/tests/integration/targets/rds_instance_restore/tasks/main.yml @@ -1,5 +1,5 @@ --- -- name: rds_instance / restore integration tests +- name: Rds_instance / restore integration tests module_defaults: group/aws: diff --git a/tests/integration/targets/rds_instance_sgroups/tasks/main.yml b/tests/integration/targets/rds_instance_sgroups/tasks/main.yml index ee85f482834..24f15baf9b1 100644 --- a/tests/integration/targets/rds_instance_sgroups/tasks/main.yml +++ b/tests/integration/targets/rds_instance_sgroups/tasks/main.yml @@ -1,5 +1,5 @@ --- -- name: rds_instance / sgroups integration tests +- name: Rds_instance / sgroups integration tests module_defaults: group/aws: @@ -9,7 +9,7 @@ region: "{{ aws_region }}" block: - - name: create a VPC + - name: Create a VPC amazon.aws.ec2_vpc_net: name: "{{ resource_prefix }}-vpc" state: present @@ -19,7 +19,7 @@ Description: created by rds_instance integration tests register: vpc_result - - name: create subnets + - name: Create subnets amazon.aws.ec2_vpc_subnet: cidr: "{{ item.cidr }}" az: "{{ item.zone }}" @@ -288,7 +288,7 @@ until: sgs_result is not failed delay: 10 - - name: remove subnets + - name: Remove subnets amazon.aws.ec2_vpc_subnet: cidr: "{{ item.cidr }}" az: "{{ item.zone }}" diff --git a/tests/integration/targets/rds_instance_snapshot/tasks/main.yml b/tests/integration/targets/rds_instance_snapshot/tasks/main.yml index ddaab5167f5..e2d81b8eff1 100644 --- a/tests/integration/targets/rds_instance_snapshot/tasks/main.yml +++ b/tests/integration/targets/rds_instance_snapshot/tasks/main.yml @@ -11,7 +11,7 @@ amazon.aws.rds_instance: id: "{{ instance_id }}" state: present - engine: "{{ engine}}" + engine: "{{ engine }}" engine_version: "{{ mariadb_engine_version }}" allow_major_version_upgrade: true username: "{{ username }}" @@ -198,7 +198,7 @@ - ansible.builtin.assert: that: - _result_instance_snapshot_info is successful - #- _result_instance_snapshot_info.cluster_snapshots | length == 3 + # - _result_instance_snapshot_info.cluster_snapshots | length == 3 - name: Delete existing DB instance snapshot (CHECK_MODE) amazon.aws.rds_instance_snapshot: 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 8f05d3b4e42..91751319663 100644 --- a/tests/integration/targets/rds_instance_snapshot_mgmt/tasks/main.yml +++ b/tests/integration/targets/rds_instance_snapshot_mgmt/tasks/main.yml @@ -1,5 +1,5 @@ --- -- name: rds_instance / snapshot_mgmt integration tests +- name: Rds_instance / snapshot_mgmt integration tests module_defaults: group/aws: diff --git a/tests/integration/targets/rds_instance_states/tasks/main.yml b/tests/integration/targets/rds_instance_states/tasks/main.yml index 8221c3ab30c..446811fddf4 100644 --- a/tests/integration/targets/rds_instance_states/tasks/main.yml +++ b/tests/integration/targets/rds_instance_states/tasks/main.yml @@ -1,5 +1,5 @@ --- -- name: rds_instance / states integration tests +- name: Rds_instance / states integration tests module_defaults: group/aws: diff --git a/tests/integration/targets/rds_instance_tagging/tasks/main.yml b/tests/integration/targets/rds_instance_tagging/tasks/main.yml index 146ac2099e1..b88755d67d9 100644 --- a/tests/integration/targets/rds_instance_tagging/tasks/main.yml +++ b/tests/integration/targets/rds_instance_tagging/tasks/main.yml @@ -1,5 +1,5 @@ --- -- name: rds_instance / tagging integration tests +- name: Rds_instance / tagging integration tests module_defaults: group/aws: diff --git a/tests/integration/targets/rds_instance_upgrade/tasks/main.yml b/tests/integration/targets/rds_instance_upgrade/tasks/main.yml index cd11fa60aaf..3ba0a5a9d17 100644 --- a/tests/integration/targets/rds_instance_upgrade/tasks/main.yml +++ b/tests/integration/targets/rds_instance_upgrade/tasks/main.yml @@ -1,5 +1,5 @@ --- -- name: rds_instance / upgrade integration tests +- name: Rds_instance / upgrade integration tests module_defaults: group/aws: diff --git a/tests/integration/targets/rds_param_group/defaults/main.yml b/tests/integration/targets/rds_param_group/defaults/main.yml index 53431cf16a2..7fb2b2341c7 100644 --- a/tests/integration/targets/rds_param_group/defaults/main.yml +++ b/tests/integration/targets/rds_param_group/defaults/main.yml @@ -1,6 +1,6 @@ --- rds_param_group: - name: "{{ resource_prefix}}rds-param-group" + name: "{{ resource_prefix }}rds-param-group" description: Test group for rds_param_group Ansible module engine: postgres9.6 engine_to_modify_to: postgres10 diff --git a/tests/integration/targets/rds_param_group/tasks/main.yml b/tests/integration/targets/rds_param_group/tasks/main.yml index d5c89b47bdf..18063b79e4b 100644 --- a/tests/integration/targets/rds_param_group/tasks/main.yml +++ b/tests/integration/targets/rds_param_group/tasks/main.yml @@ -12,7 +12,7 @@ # ============================================================ -- name: rds_option_group tests +- name: Rds_option_group tests module_defaults: group/aws: access_key: "{{ aws_access_key }}" diff --git a/tests/integration/targets/route53/tasks/main.yml b/tests/integration/targets/route53/tasks/main.yml index ca09cee54ed..097dce963a0 100644 --- a/tests/integration/targets/route53/tasks/main.yml +++ b/tests/integration/targets/route53/tasks/main.yml @@ -18,7 +18,7 @@ # Route53 is explicitly a global service region: block: - - name: create VPC + - name: Create VPC amazon.aws.ec2_vpc_net: cidr_block: 192.0.2.0/24 name: "{{ resource_prefix }}_vpc" @@ -240,7 +240,7 @@ - mv_a_record is not changed # Get resulting A record and ensure max_items is applied - - name: get Route53 A record information + - name: Get Route53 A record information amazon.aws.route53_info: type: A query: record_sets @@ -289,7 +289,7 @@ - del_a_record is not failed - del_a_record is changed - - name: get Route53 zone A record information + - name: Get Route53 zone A record information amazon.aws.route53_info: type: A query: record_sets @@ -443,7 +443,7 @@ - wc_a_record is changed - wc_a_record.diff.after == {} - - name: create a record with different TTL + - name: Create a record with different TTL amazon.aws.route53: state: present zone: "{{ zone_one }}" @@ -452,32 +452,32 @@ value: 127.0.0.1 ttl: 30 register: ttl30 - - name: check return values + - name: Check return values ansible.builtin.assert: that: - ttl30.resource_record_sets[0].ttl == "30" - ttl30 is changed - - name: delete previous record without mention ttl and value + - name: Delete previous record without mention ttl and value amazon.aws.route53: state: absent zone: "{{ zone_one }}" record: localhost.{{ zone_one }} type: A register: ttl30 - - name: check if record is deleted + - name: Check if record is deleted ansible.builtin.assert: that: - ttl30 is changed - - name: immutable delete previous record without mention ttl and value + - name: Immutable delete previous record without mention ttl and value amazon.aws.route53: state: absent zone: "{{ zone_one }}" record: localhost.{{ zone_one }} type: A register: ttl30 - - name: check if record was deleted + - name: Check if record was deleted ansible.builtin.assert: that: - ttl30 is not changed @@ -690,7 +690,7 @@ - weighted_record is not failed - weighted_record is not changed - #Test Geo Location - Continent Code + # Test Geo Location - Continent Code - name: Create a record with geo_location - continent_code (check_mode) amazon.aws.route53: state: present @@ -725,7 +725,7 @@ continent_code: NA register: create_geo_continent # Get resulting A record and geo_location parameters are applied - - name: get Route53 A record information + - name: Get Route53 A record information amazon.aws.route53_info: type: A query: record_sets @@ -779,7 +779,7 @@ - create_geo_continent_idem_check is not failed - '"route53:ChangeResourceRecordSets" not in create_geo_continent_idem_check.resource_actions' - #Test Geo Location - Country Code + # Test Geo Location - Country Code - name: Create a record with geo_location - country_code (check_mode) amazon.aws.route53: state: present @@ -812,7 +812,7 @@ country_code: US register: create_geo_country # Get resulting A record and geo_location parameters are applied - - name: get Route53 A record information + - name: Get Route53 A record information amazon.aws.route53_info: type: A query: record_sets @@ -865,7 +865,7 @@ - create_geo_country_idem_check is not failed - '"route53:ChangeResourceRecordSets" not in create_geo_country_idem_check.resource_actions' - #Test Geo Location - Subdivision Code + # Test Geo Location - Subdivision Code - name: Create a record with geo_location - subdivision_code (check_mode) amazon.aws.route53: state: present @@ -900,7 +900,7 @@ subdivision_code: TX register: create_geo_subdivision # Get resulting A record and geo_location parameters are applied - - name: get Route53 A record information + - name: Get Route53 A record information amazon.aws.route53_info: type: A query: record_sets @@ -956,10 +956,11 @@ - create_geo_subdivision_idem_check is not failed - '"route53:ChangeResourceRecordSets" not in create_geo_subdivision_idem_check.resource_actions' - #Cleanup------------------------------------------------------ + # ------------------------------------------------------ + # Cleanup always: - - name: delete a record with geo_location - continent_code + - name: Delete a record with geo_location - continent_code amazon.aws.route53: state: absent zone: "{{ zone_one }}" @@ -972,7 +973,7 @@ continent_code: NA ignore_errors: true - - name: delete a record with geo_location - country_code + - name: Delete a record with geo_location - country_code amazon.aws.route53: state: absent zone: "{{ zone_one }}" @@ -985,7 +986,7 @@ country_code: US ignore_errors: true - - name: delete a record with geo_location - subdivision_code + - name: Delete a record with geo_location - subdivision_code amazon.aws.route53: state: absent zone: "{{ zone_one }}" @@ -1113,7 +1114,7 @@ retries: 10 until: delete_two is not failed - - name: destroy VPC + - name: Destroy VPC amazon.aws.ec2_vpc_net: cidr_block: 192.0.2.0/24 name: "{{ resource_prefix }}_vpc" diff --git a/tests/integration/targets/route53_health_check/defaults/main.yml b/tests/integration/targets/route53_health_check/defaults/main.yml index ab40fb5f650..82249310873 100644 --- a/tests/integration/targets/route53_health_check/defaults/main.yml +++ b/tests/integration/targets/route53_health_check/defaults/main.yml @@ -9,10 +9,10 @@ # - type # - request_interval -#ip_address: We allocate an EIP due to route53 restrictions +# ip_address: We allocate an EIP due to route53 restrictions fqdn: "{{ tiny_prefix }}.route53-health.ansible.test" fqdn_1: "{{ tiny_prefix }}-1.route53-health.ansible.test" -port: 8080 +check_port: 8080 updated_port: 8181 type: TCP request_interval: 30 diff --git a/tests/integration/targets/route53_health_check/tasks/calculate_health_check.yml b/tests/integration/targets/route53_health_check/tasks/calculate_health_check.yml index 37a88414af8..85b464f2043 100644 --- a/tests/integration/targets/route53_health_check/tasks/calculate_health_check.yml +++ b/tests/integration/targets/route53_health_check/tasks/calculate_health_check.yml @@ -6,7 +6,7 @@ state: present name: "{{ tiny_prefix }}-{{ resource_path }}-test-hc-tag-operations" ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type_http }}" resource_path: "{{ resource_path }}" use_unique_names: true @@ -18,7 +18,7 @@ amazon.aws.route53_health_check: health_check_name: calculated_health_check ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: CALCULATED use_unique_names: true fqdn: "{{ fqdn }}" @@ -128,7 +128,7 @@ state: absent name: "{{ tiny_prefix }}-{{ resource_path }}-test-hc-tag-operations" ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type_http }}" resource_path: "{{ resource_path }}" use_unique_names: true diff --git a/tests/integration/targets/route53_health_check/tasks/create_multiple_health_checks.yml b/tests/integration/targets/route53_health_check/tasks/create_multiple_health_checks.yml index 2bd8cc9a499..f1f0d416b36 100644 --- a/tests/integration/targets/route53_health_check/tasks/create_multiple_health_checks.yml +++ b/tests/integration/targets/route53_health_check/tasks/create_multiple_health_checks.yml @@ -5,7 +5,7 @@ state: present name: "{{ tiny_prefix }}-{{ item }}-test-hc-delete-if-found" ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type_http }}" resource_path: "{{ item }}" use_unique_names: true @@ -28,7 +28,7 @@ state: present name: "{{ tiny_prefix }}-{{ item }}-test-hc-delete-if-found" ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type_http }}" resource_path: "{{ item }}" use_unique_names: true @@ -72,7 +72,7 @@ state: present name: "{{ tiny_prefix }}-{{ item }}-test-hc-delete-if-found" ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type_http }}" resource_path: "{{ item }}" use_unique_names: true @@ -97,7 +97,7 @@ state: present name: "{{ tiny_prefix }}-{{ item }}-test-hc-delete-if-found" ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type_http }}" resource_path: "{{ item }}" use_unique_names: true @@ -176,7 +176,7 @@ state: absent name: "{{ tiny_prefix }}-{{ item }}-test-hc-delete-if-found" ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type_http }}" resource_path: "{{ item }}" use_unique_names: true diff --git a/tests/integration/targets/route53_health_check/tasks/main.yml b/tests/integration/targets/route53_health_check/tasks/main.yml index 073f00fb212..14dabec56df 100644 --- a/tests/integration/targets/route53_health_check/tasks/main.yml +++ b/tests/integration/targets/route53_health_check/tasks/main.yml @@ -44,7 +44,7 @@ amazon.aws.route53_health_check: state: present ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type }}" register: create_check check_mode: true @@ -59,7 +59,7 @@ amazon.aws.route53_health_check: state: present ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type }}" register: create_check @@ -89,7 +89,7 @@ - _check_config.failure_threshold == 3 - _check_config.request_interval == 30 - _check_config.ip_address == ip_address - - _check_config.port == port + - _check_config.port == check_port vars: _health_check: "{{ create_check.health_check }}" _check_config: "{{ _health_check.health_check_config }}" @@ -101,7 +101,7 @@ amazon.aws.route53_health_check: state: present ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type }}" register: create_check check_mode: true @@ -116,7 +116,7 @@ amazon.aws.route53_health_check: state: present ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type }}" register: create_check @@ -148,7 +148,7 @@ - _check_config.request_interval == 30 - _check_config.failure_threshold == 3 - _check_config.ip_address == ip_address - - _check_config.port == port + - _check_config.port == check_port vars: _health_check: "{{ create_check.health_check }}" _check_config: "{{ _health_check.health_check_config }}" @@ -158,7 +158,7 @@ amazon.aws.route53_health_check: state: present ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type }}" failure_threshold: "{{ failure_threshold_updated }}" register: update_threshold @@ -174,7 +174,7 @@ amazon.aws.route53_health_check: state: present ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type }}" failure_threshold: "{{ failure_threshold_updated }}" register: update_threshold @@ -206,7 +206,7 @@ - _check_config.request_interval == 30 - _check_config.failure_threshold == failure_threshold_updated - _check_config.ip_address == ip_address - - _check_config.port == port + - _check_config.port == check_port vars: _health_check: "{{ update_threshold.health_check }}" _check_config: "{{ _health_check.health_check_config }}" @@ -215,7 +215,7 @@ amazon.aws.route53_health_check: state: present ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type }}" failure_threshold: "{{ failure_threshold_updated }}" register: update_threshold @@ -231,7 +231,7 @@ amazon.aws.route53_health_check: state: present ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type }}" failure_threshold: "{{ failure_threshold_updated }}" register: update_threshold @@ -263,7 +263,7 @@ - _check_config.request_interval == 30 - _check_config.failure_threshold == failure_threshold_updated - _check_config.ip_address == ip_address - - _check_config.port == port + - _check_config.port == check_port vars: _health_check: "{{ update_threshold.health_check }}" _check_config: "{{ _health_check.health_check_config }}" @@ -272,7 +272,7 @@ amazon.aws.route53_health_check: state: present ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type }}" disabled: true register: update_disabled @@ -288,7 +288,7 @@ amazon.aws.route53_health_check: state: present ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type }}" disabled: true register: update_disabled @@ -320,7 +320,7 @@ - _check_config.request_interval == 30 - _check_config.failure_threshold == failure_threshold_updated - _check_config.ip_address == ip_address - - _check_config.port == port + - _check_config.port == check_port vars: _health_check: "{{ update_disabled.health_check }}" _check_config: "{{ _health_check.health_check_config }}" @@ -329,7 +329,7 @@ amazon.aws.route53_health_check: state: present ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type }}" disabled: true register: update_disabled @@ -345,7 +345,7 @@ amazon.aws.route53_health_check: state: present ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type }}" disabled: true register: update_disabled @@ -377,7 +377,7 @@ - _check_config.request_interval == 30 - _check_config.failure_threshold == failure_threshold_updated - _check_config.ip_address == ip_address - - _check_config.port == port + - _check_config.port == check_port vars: _health_check: "{{ update_disabled.health_check }}" _check_config: "{{ _health_check.health_check_config }}" @@ -386,7 +386,7 @@ amazon.aws.route53_health_check: state: present ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type }}" tags: CamelCase: CamelCaseValue @@ -406,7 +406,7 @@ amazon.aws.route53_health_check: state: present ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type }}" tags: CamelCase: CamelCaseValue @@ -448,7 +448,7 @@ - _check_config.request_interval == 30 - _check_config.failure_threshold == failure_threshold_updated - _check_config.ip_address == ip_address - - _check_config.port == port + - _check_config.port == check_port vars: _health_check: "{{ update_tags.health_check }}" _check_config: "{{ _health_check.health_check_config }}" @@ -457,7 +457,7 @@ amazon.aws.route53_health_check: state: present ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type }}" tags: CamelCase: CamelCaseValue @@ -477,7 +477,7 @@ amazon.aws.route53_health_check: state: present ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type }}" tags: CamelCase: CamelCaseValue @@ -519,7 +519,7 @@ - _check_config.request_interval == 30 - _check_config.failure_threshold == failure_threshold_updated - _check_config.ip_address == ip_address - - _check_config.port == port + - _check_config.port == check_port vars: _health_check: "{{ update_tags.health_check }}" _check_config: "{{ _health_check.health_check_config }}" @@ -528,7 +528,7 @@ amazon.aws.route53_health_check: state: present ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type }}" tags: anotherTag: anotherValue @@ -546,7 +546,7 @@ amazon.aws.route53_health_check: state: present ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type }}" tags: anotherTag: anotherValue @@ -588,7 +588,7 @@ - _check_config.request_interval == 30 - _check_config.failure_threshold == failure_threshold_updated - _check_config.ip_address == ip_address - - _check_config.port == port + - _check_config.port == check_port vars: _health_check: "{{ add_tags.health_check }}" _check_config: "{{ _health_check.health_check_config }}" @@ -597,7 +597,7 @@ amazon.aws.route53_health_check: state: present ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type }}" tags: anotherTag: anotherValue @@ -615,7 +615,7 @@ amazon.aws.route53_health_check: state: present ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type }}" tags: anotherTag: anotherValue @@ -657,7 +657,7 @@ - _check_config.request_interval == 30 - _check_config.failure_threshold == failure_threshold_updated - _check_config.ip_address == ip_address - - _check_config.port == port + - _check_config.port == check_port vars: _health_check: "{{ add_tags.health_check }}" _check_config: "{{ _health_check.health_check_config }}" @@ -666,7 +666,7 @@ amazon.aws.route53_health_check: state: present ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type }}" tags: anotherTag: anotherValue @@ -684,7 +684,7 @@ amazon.aws.route53_health_check: state: present ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type }}" tags: anotherTag: anotherValue @@ -723,7 +723,7 @@ - _check_config.request_interval == 30 - _check_config.failure_threshold == failure_threshold_updated - _check_config.ip_address == ip_address - - _check_config.port == port + - _check_config.port == check_port vars: _health_check: "{{ purge_tags.health_check }}" _check_config: "{{ _health_check.health_check_config }}" @@ -732,7 +732,7 @@ amazon.aws.route53_health_check: state: present ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type }}" tags: anotherTag: anotherValue @@ -750,7 +750,7 @@ amazon.aws.route53_health_check: state: present ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type }}" tags: anotherTag: anotherValue @@ -789,7 +789,7 @@ - _check_config.request_interval == 30 - _check_config.failure_threshold == failure_threshold_updated - _check_config.ip_address == ip_address - - _check_config.port == port + - _check_config.port == check_port vars: _health_check: "{{ purge_tags.health_check }}" _check_config: "{{ _health_check.health_check_config }}" @@ -799,7 +799,7 @@ amazon.aws.route53_health_check: state: absent ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type }}" register: delete_tcp check_mode: true @@ -814,7 +814,7 @@ amazon.aws.route53_health_check: state: absent ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type }}" register: delete_tcp @@ -828,7 +828,7 @@ amazon.aws.route53_health_check: state: absent ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type }}" register: delete_tcp check_mode: true @@ -843,7 +843,7 @@ amazon.aws.route53_health_check: state: absent ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type }}" register: delete_tcp @@ -858,7 +858,7 @@ amazon.aws.route53_health_check: state: present ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type_https_match }}" fqdn: "{{ fqdn }}" request_interval: "{{ request_interval }}" @@ -876,7 +876,7 @@ amazon.aws.route53_health_check: state: present ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type_https_match }}" fqdn: "{{ fqdn }}" request_interval: "{{ request_interval }}" @@ -911,7 +911,7 @@ - _check_config.failure_threshold == 3 - _check_config.fully_qualified_domain_name == fqdn - _check_config.ip_address == ip_address - - _check_config.port == port + - _check_config.port == check_port - _check_config.search_string == string_match vars: _health_check: "{{ create_match.health_check }}" @@ -924,7 +924,7 @@ amazon.aws.route53_health_check: state: present ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type_https_match }}" fqdn: "{{ fqdn }}" request_interval: "{{ request_interval }}" @@ -942,7 +942,7 @@ amazon.aws.route53_health_check: state: present ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type_https_match }}" fqdn: "{{ fqdn }}" request_interval: "{{ request_interval }}" @@ -977,7 +977,7 @@ - _check_config.failure_threshold == 3 - _check_config.fully_qualified_domain_name == fqdn - _check_config.ip_address == ip_address - - _check_config.port == port + - _check_config.port == check_port - _check_config.search_string == string_match vars: _health_check: "{{ create_match.health_check }}" @@ -987,7 +987,7 @@ amazon.aws.route53_health_check: state: present ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type_https_match }}" fqdn: "{{ fqdn }}" request_interval: "{{ request_interval }}" @@ -1005,7 +1005,7 @@ amazon.aws.route53_health_check: state: present ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type_https_match }}" fqdn: "{{ fqdn }}" request_interval: "{{ request_interval }}" @@ -1040,7 +1040,7 @@ - _check_config.failure_threshold == 3 - _check_config.fully_qualified_domain_name == fqdn - _check_config.ip_address == ip_address - - _check_config.port == port + - _check_config.port == check_port - _check_config.resource_path == resource_path - _check_config.search_string == string_match vars: @@ -1051,7 +1051,7 @@ amazon.aws.route53_health_check: state: present ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type_https_match }}" fqdn: "{{ fqdn }}" request_interval: "{{ request_interval }}" @@ -1069,7 +1069,7 @@ amazon.aws.route53_health_check: state: present ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type_https_match }}" fqdn: "{{ fqdn }}" request_interval: "{{ request_interval }}" @@ -1104,7 +1104,7 @@ - _check_config.failure_threshold == 3 - _check_config.fully_qualified_domain_name == fqdn - _check_config.ip_address == ip_address - - _check_config.port == port + - _check_config.port == check_port - _check_config.resource_path == resource_path - _check_config.search_string == string_match vars: @@ -1115,7 +1115,7 @@ amazon.aws.route53_health_check: state: present ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type_https_match }}" fqdn: "{{ fqdn }}" request_interval: "{{ request_interval }}" @@ -1133,7 +1133,7 @@ amazon.aws.route53_health_check: state: present ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type_https_match }}" fqdn: "{{ fqdn }}" request_interval: "{{ request_interval }}" @@ -1168,7 +1168,7 @@ - _check_config.failure_threshold == 3 - _check_config.fully_qualified_domain_name == fqdn - _check_config.ip_address == ip_address - - _check_config.port == port + - _check_config.port == check_port - _check_config.resource_path == resource_path - _check_config.search_string == string_match_updated vars: @@ -1179,7 +1179,7 @@ amazon.aws.route53_health_check: state: present ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type_https_match }}" fqdn: "{{ fqdn }}" request_interval: "{{ request_interval }}" @@ -1197,7 +1197,7 @@ amazon.aws.route53_health_check: state: present ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type_https_match }}" fqdn: "{{ fqdn }}" request_interval: "{{ request_interval }}" @@ -1232,7 +1232,7 @@ - _check_config.failure_threshold == 3 - _check_config.fully_qualified_domain_name == fqdn - _check_config.ip_address == ip_address - - _check_config.port == port + - _check_config.port == check_port - _check_config.resource_path == resource_path - _check_config.search_string == string_match_updated vars: @@ -1244,7 +1244,7 @@ amazon.aws.route53_health_check: state: absent ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type_https_match }}" fqdn: "{{ fqdn }}" request_interval: "{{ request_interval }}" @@ -1261,7 +1261,7 @@ amazon.aws.route53_health_check: state: absent ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type_https_match }}" fqdn: "{{ fqdn }}" request_interval: "{{ request_interval }}" @@ -1277,7 +1277,7 @@ amazon.aws.route53_health_check: state: absent ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type_https_match }}" fqdn: "{{ fqdn }}" request_interval: "{{ request_interval }}" @@ -1294,7 +1294,7 @@ amazon.aws.route53_health_check: state: absent ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type_https_match }}" fqdn: "{{ fqdn }}" request_interval: "{{ request_interval }}" @@ -1311,7 +1311,7 @@ amazon.aws.route53_health_check: state: present ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type_http_match }}" fqdn: "{{ fqdn }}" request_interval: "{{ request_interval }}" @@ -1337,7 +1337,7 @@ amazon.aws.route53_health_check: state: present ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type_http_match }}" fqdn: "{{ fqdn }}" request_interval: "{{ request_interval }}" @@ -1387,7 +1387,7 @@ - _check_config.failure_threshold == failure_threshold - _check_config.fully_qualified_domain_name == fqdn - _check_config.ip_address == ip_address - - _check_config.port == port + - _check_config.port == check_port - _check_config.resource_path == resource_path - _check_config.search_string == string_match vars: @@ -1401,7 +1401,7 @@ amazon.aws.route53_health_check: state: present ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type_http_match }}" fqdn: "{{ fqdn }}" request_interval: "{{ request_interval }}" @@ -1427,7 +1427,7 @@ amazon.aws.route53_health_check: state: present ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type_http_match }}" fqdn: "{{ fqdn }}" request_interval: "{{ request_interval }}" @@ -1476,7 +1476,7 @@ - _check_config.failure_threshold == failure_threshold - _check_config.fully_qualified_domain_name == fqdn - _check_config.ip_address == ip_address - - _check_config.port == port + - _check_config.port == check_port - _check_config.resource_path == resource_path - _check_config.search_string == string_match vars: @@ -1487,7 +1487,7 @@ amazon.aws.route53_health_check: state: present ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type_http_match }}" fqdn: "{{ fqdn }}" request_interval: "{{ request_interval }}" @@ -1507,7 +1507,7 @@ amazon.aws.route53_health_check: state: present ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type_http_match }}" fqdn: "{{ fqdn }}" request_interval: "{{ request_interval }}" @@ -1550,7 +1550,7 @@ - _check_config.failure_threshold == failure_threshold_updated - _check_config.fully_qualified_domain_name == fqdn - _check_config.ip_address == ip_address - - _check_config.port == port + - _check_config.port == check_port - _check_config.resource_path == resource_path_updated - _check_config.search_string == string_match_updated vars: @@ -1561,7 +1561,7 @@ amazon.aws.route53_health_check: state: present ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type_http_match }}" fqdn: "{{ fqdn }}" request_interval: "{{ request_interval }}" @@ -1581,7 +1581,7 @@ amazon.aws.route53_health_check: state: present ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type_http_match }}" fqdn: "{{ fqdn }}" request_interval: "{{ request_interval }}" @@ -1624,7 +1624,7 @@ - _check_config.failure_threshold == failure_threshold_updated - _check_config.fully_qualified_domain_name == fqdn - _check_config.ip_address == ip_address - - _check_config.port == port + - _check_config.port == check_port - _check_config.resource_path == resource_path_updated - _check_config.search_string == string_match_updated vars: @@ -1635,7 +1635,7 @@ amazon.aws.route53_health_check: state: absent ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type_http_match }}" fqdn: "{{ fqdn }}" request_interval: "{{ request_interval }}" @@ -1652,7 +1652,7 @@ amazon.aws.route53_health_check: state: absent ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type_http_match }}" fqdn: "{{ fqdn }}" request_interval: "{{ request_interval }}" @@ -1668,7 +1668,7 @@ amazon.aws.route53_health_check: state: absent ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type_http_match }}" fqdn: "{{ fqdn }}" request_interval: "{{ request_interval }}" @@ -1685,7 +1685,7 @@ amazon.aws.route53_health_check: state: absent ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type_http_match }}" fqdn: "{{ fqdn }}" request_interval: "{{ request_interval }}" @@ -1704,7 +1704,7 @@ health_check_name: "{{ tiny_prefix }}-hc-latency-graph" use_unique_names: true ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type }}" measure_latency: true register: create_check @@ -1758,7 +1758,7 @@ health_check_name: "{{ tiny_prefix }}-hc-latency-graph" use_unique_names: true ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type }}" measure_latency: false register: update_check @@ -1781,7 +1781,7 @@ health_check_name: "{{ tiny_prefix }}-hc-latency-graph" use_unique_names: true ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type }}" measure_latency: true ignore_errors: true @@ -1790,7 +1790,7 @@ amazon.aws.route53_health_check: state: absent ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type }}" ignore_errors: true @@ -1798,7 +1798,7 @@ amazon.aws.route53_health_check: state: absent ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type_https_match }}" fqdn: "{{ fqdn }}" request_interval: "{{ request_interval }}" @@ -1808,13 +1808,13 @@ amazon.aws.route53_health_check: state: absent ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type_http_match }}" fqdn: "{{ fqdn }}" request_interval: "{{ request_interval }}" ignore_errors: true - - name: release EIP + - name: Release EIP amazon.aws.ec2_eip: state: absent public_ip: "{{ ip_address }}" diff --git a/tests/integration/targets/route53_health_check/tasks/named_health_check_tag_operations.yml b/tests/integration/targets/route53_health_check/tasks/named_health_check_tag_operations.yml index 044bb171adc..91d551d39d7 100644 --- a/tests/integration/targets/route53_health_check/tasks/named_health_check_tag_operations.yml +++ b/tests/integration/targets/route53_health_check/tasks/named_health_check_tag_operations.yml @@ -6,7 +6,7 @@ state: present name: "{{ tiny_prefix }}-{{ resource_path }}-test-hc-tag-operations" ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type_http }}" resource_path: "{{ resource_path }}" use_unique_names: true @@ -43,7 +43,7 @@ state: present name: "{{ tiny_prefix }}-{{ resource_path }}-test-hc-tag-operations" ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type_http }}" resource_path: "{{ resource_path }}" use_unique_names: true @@ -80,7 +80,7 @@ state: present name: "{{ tiny_prefix }}-{{ resource_path }}-test-hc-tag-operations" ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type_http }}" resource_path: "{{ resource_path }}" use_unique_names: true @@ -117,7 +117,7 @@ state: present name: "{{ tiny_prefix }}-{{ resource_path }}-test-hc-tag-operations" ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type_http }}" resource_path: "{{ resource_path }}" use_unique_names: true @@ -155,7 +155,7 @@ state: present name: "{{ tiny_prefix }}-{{ resource_path }}-test-hc-tag-operations" ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type_http }}" resource_path: "{{ resource_path }}" use_unique_names: true @@ -188,7 +188,7 @@ state: present name: "{{ tiny_prefix }}-{{ resource_path }}-test-hc-tag-operations" ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type_http }}" resource_path: "{{ resource_path }}" use_unique_names: true @@ -220,7 +220,7 @@ state: present name: "{{ tiny_prefix }}-{{ resource_path }}-test-hc-tag-operations" ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type_http }}" resource_path: "{{ resource_path }}" use_unique_names: true @@ -255,7 +255,7 @@ state: absent name: "{{ tiny_prefix }}-{{ resource_path }}-test-hc-tag-operations" ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type_http }}" resource_path: "{{ resource_path }}" use_unique_names: true 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 0d111c9d72d..c69393a2da8 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 @@ -5,7 +5,7 @@ state: present name: "{{ tiny_prefix }}-test-update-delete-by-id" ip_address: "{{ ip_address }}" - port: "{{ port }}" + port: "{{ check_port }}" type: "{{ type_http }}" resource_path: "{{ resource_path }}" fqdn: "{{ fqdn }}" diff --git a/tests/integration/targets/route53_zone/tasks/main.yml b/tests/integration/targets/route53_zone/tasks/main.yml index 812c8329f6e..0fb16991997 100644 --- a/tests/integration/targets/route53_zone/tasks/main.yml +++ b/tests/integration/targets/route53_zone/tasks/main.yml @@ -1,5 +1,5 @@ --- -- name: route53_zone integration tests +- name: Route53_zone integration tests module_defaults: group/aws: @@ -558,7 +558,7 @@ - name: Delete zone using attribute hosted_zone_id (CHECK MODE) amazon.aws.route53_zone: zone: "{{ resource_prefix }}.public2" - hosted_zone_id: "{{new_zone.zone_id}}" + hosted_zone_id: "{{ new_zone.zone_id }}" state: absent register: output check_mode: true @@ -571,7 +571,7 @@ - name: Delete zone using attribute hosted_zone_id amazon.aws.route53_zone: zone: "{{ resource_prefix }}.public2" - hosted_zone_id: "{{new_zone.zone_id}}" + hosted_zone_id: "{{ new_zone.zone_id }}" state: absent register: output @@ -605,7 +605,7 @@ ignore_errors: true retries: 10 - - name: remove the VPC + - name: Remove the VPC amazon.aws.ec2_vpc_net: name: "{{ resource_prefix }}-vpc" cidr_block: 10.22.32.0/23 diff --git a/tests/integration/targets/s3_bucket/main.yml b/tests/integration/targets/s3_bucket/main.yml index 0b02546fccd..b01229de042 100644 --- a/tests/integration/targets/s3_bucket/main.yml +++ b/tests/integration/targets/s3_bucket/main.yml @@ -4,9 +4,10 @@ # '{{ inventory_hostname }}'.yml file in roles/s3_bucket/tasks/ # VPC should get cleaned up once all hosts have run -- hosts: all +- name: Run s3_bucket tests in parallel + hosts: all gather_facts: false strategy: free - #serial: 10 + # serial: 10 roles: - s3_bucket diff --git a/tests/integration/targets/s3_bucket/roles/s3_bucket/defaults/main.yml b/tests/integration/targets/s3_bucket/roles/s3_bucket/defaults/main.yml index 526782550be..621238544c2 100644 --- a/tests/integration/targets/s3_bucket/roles/s3_bucket/defaults/main.yml +++ b/tests/integration/targets/s3_bucket/roles/s3_bucket/defaults/main.yml @@ -1,2 +1,2 @@ --- -bucket_name: "{{ resource_prefix }}" +s3_bucket_name: "{{ resource_prefix }}" diff --git a/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/accelerate.yml b/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/accelerate.yml index f4def35f60c..dcd59f225b4 100644 --- a/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/accelerate.yml +++ b/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/accelerate.yml @@ -7,7 +7,7 @@ region: "{{ aws_region }}" block: - ansible.builtin.set_fact: - local_bucket_name: "{{ bucket_name | hash('md5')}}-accelerate" + local_bucket_name: "{{ s3_bucket_name | hash('md5') }}-accelerate" # ============================================================ diff --git a/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/acl.yml b/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/acl.yml index 03141925cef..e5d170f80bd 100644 --- a/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/acl.yml +++ b/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/acl.yml @@ -7,7 +7,7 @@ region: "{{ aws_region }}" block: - ansible.builtin.set_fact: - local_bucket_name: "{{ bucket_name | hash('md5')}}acl" + local_bucket_name: "{{ s3_bucket_name | hash('md5') }}acl" - name: Create a simple bucket amazon.aws.s3_bucket: diff --git a/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/complex.yml b/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/complex.yml index 1ffe1c12c62..1d2f584da79 100644 --- a/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/complex.yml +++ b/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/complex.yml @@ -1,12 +1,12 @@ --- - block: - ansible.builtin.set_fact: - local_bucket_name: "{{ bucket_name | hash('md5')}}complex" + local_bucket_name: "{{ s3_bucket_name | hash('md5') }}complex" - name: Create more complex s3_bucket amazon.aws.s3_bucket: name: "{{ local_bucket_name }}" state: present - policy: "{{ lookup('template','policy.json') }}" + policy: "{{ lookup('template', 'policy.json') }}" requester_pays: true versioning: true public_access: @@ -42,7 +42,7 @@ amazon.aws.s3_bucket: name: "{{ local_bucket_name }}" state: present - policy: "{{ lookup('template','policy.json') }}" + policy: "{{ lookup('template', 'policy.json') }}" requester_pays: true versioning: true tags: @@ -70,7 +70,7 @@ amazon.aws.s3_bucket: name: "{{ local_bucket_name }}" state: present - policy: "{{ lookup('template','policy-updated.json') }}" + policy: "{{ lookup('template', 'policy-updated.json') }}" requester_pays: true versioning: true tags: @@ -98,7 +98,7 @@ amazon.aws.s3_bucket: name: "{{ local_bucket_name }}" state: present - policy: "{{ lookup('template','policy.json') }}" + policy: "{{ lookup('template', 'policy.json') }}" requester_pays: false versioning: false tags: diff --git a/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/default_retention.yml b/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/default_retention.yml index 638572cf6f0..d207dae13ba 100644 --- a/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/default_retention.yml +++ b/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/default_retention.yml @@ -7,7 +7,7 @@ region: "{{ aws_region }}" block: - ansible.builtin.set_fact: - local_bucket_name: "{{ bucket_name | hash('md5')}}-default-retention" + local_bucket_name: "{{ s3_bucket_name | hash('md5') }}-default-retention" # ============================================================ diff --git a/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/dotted.yml b/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/dotted.yml index 2a6a2f4ee87..00c477e9ba6 100644 --- a/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/dotted.yml +++ b/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/dotted.yml @@ -2,7 +2,7 @@ - block: - name: Ensure bucket_name contains a . ansible.builtin.set_fact: - local_bucket_name: "{{ bucket_name | hash('md5')}}.dotted" + local_bucket_name: "{{ s3_bucket_name | hash('md5') }}.dotted" # ============================================================ # diff --git a/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/encryption_bucket_key.yml b/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/encryption_bucket_key.yml index 44d7200b8e3..92fff15a739 100644 --- a/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/encryption_bucket_key.yml +++ b/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/encryption_bucket_key.yml @@ -8,7 +8,7 @@ block: - name: Set facts for encryption_bucket_key test ansible.builtin.set_fact: - local_bucket_name: "{{ bucket_name | hash('md5') }}-bucket-key" + local_bucket_name: "{{ s3_bucket_name | hash('md5') }}-bucket-key" # ============================================================ - name: Create a simple bucket diff --git a/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/encryption_kms.yml b/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/encryption_kms.yml index b24479c72cf..f04c7c94e52 100644 --- a/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/encryption_kms.yml +++ b/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/encryption_kms.yml @@ -7,7 +7,7 @@ region: "{{ aws_region }}" block: - ansible.builtin.set_fact: - local_bucket_name: "{{ bucket_name | hash('md5')}}e-kms" + local_bucket_name: "{{ s3_bucket_name | hash('md5') }}e-kms" # ============================================================ - name: Create a simple bucket diff --git a/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/encryption_sse.yml b/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/encryption_sse.yml index 88ae220350f..248c7429966 100644 --- a/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/encryption_sse.yml +++ b/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/encryption_sse.yml @@ -7,7 +7,7 @@ region: "{{ aws_region }}" block: - ansible.builtin.set_fact: - local_bucket_name: "{{ bucket_name | hash('md5')}}e-sse" + local_bucket_name: "{{ s3_bucket_name | hash('md5') }}e-sse" # ============================================================ - name: Create a simple bucket diff --git a/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/inventory.yml b/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/inventory.yml index 4c7df7c105c..fad376dae2c 100644 --- a/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/inventory.yml +++ b/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/inventory.yml @@ -7,9 +7,9 @@ region: "{{ aws_region }}" block: - ansible.builtin.set_fact: - local_bucket_name: "{{ bucket_name | hash('md5')}}-inventory-source" - local_dest_bucket_name: "{{ bucket_name | hash('md5')}}-inventory-target" - - name: Create a simple bucket to be inventory destination + local_bucket_name: "{{ s3_bucket_name | hash('md5') }}-inventory-source" + local_dest_bucket_name: "{{ s3_bucket_name | hash('md5') }}-inventory-target" + - name: Create a simple bucket to be inventory destination amazon.aws.s3_bucket: name: "{{ local_dest_bucket_name }}" state: present @@ -24,14 +24,14 @@ name: "{{ local_bucket_name }}" state: present inventory: - - id: "{{ local_dest_bucket_name }}" - destination: - bucket: "arn:aws:s3:::{{ local_dest_bucket_name }}" - format: "CSV" - optional_fields: - - "Size" - included_object_versions: "All" - schedule: "Weekly" + - id: "{{ local_dest_bucket_name }}" + destination: + bucket: "arn:aws:s3:::{{ local_dest_bucket_name }}" + format: "CSV" + optional_fields: + - "Size" + included_object_versions: "All" + schedule: "Weekly" register: output - ansible.builtin.assert: @@ -44,14 +44,14 @@ name: "{{ local_bucket_name }}" state: present inventory: - - id: "{{ local_dest_bucket_name }}" - destination: - bucket: "arn:aws:s3:::{{ local_dest_bucket_name }}" - format: "CSV" - optional_fields: - - "Size" - schedule: "Daily" - included_object_versions: "All" + - id: "{{ local_dest_bucket_name }}" + destination: + bucket: "arn:aws:s3:::{{ local_dest_bucket_name }}" + format: "CSV" + optional_fields: + - "Size" + schedule: "Daily" + included_object_versions: "All" register: output - ansible.builtin.assert: @@ -64,14 +64,14 @@ name: "{{ local_bucket_name }}" state: present inventory: - - id: "{{ local_dest_bucket_name }}" - destination: - bucket: "arn:aws:s3:::{{ local_dest_bucket_name }}" - format: "CSV" - optional_fields: - - "Size" - schedule: "Daily" - included_object_versions: "All" + - id: "{{ local_dest_bucket_name }}" + destination: + bucket: "arn:aws:s3:::{{ local_dest_bucket_name }}" + format: "CSV" + optional_fields: + - "Size" + schedule: "Daily" + included_object_versions: "All" register: output - ansible.builtin.assert: @@ -79,7 +79,6 @@ - output is not changed - output.bucket_inventory - - name: Delete inventory configuration amazon.aws.s3_bucket: name: "{{ local_bucket_name }}" @@ -116,7 +115,6 @@ that: - output.changed - - name: Delete testing inventory s3 bucket amazon.aws.s3_bucket: name: "{{ local_dest_bucket_name }}" @@ -127,7 +125,6 @@ that: - output.changed - # ============================================================ always: - name: Ensure all buckets are deleted diff --git a/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/main.yml b/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/main.yml index 9888d7117a8..5b7706ed9b4 100644 --- a/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/main.yml +++ b/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/main.yml @@ -14,7 +14,7 @@ region: "{{ aws_region }}" block: - ansible.builtin.debug: - msg: "{{ inventory_hostname }} start: {{ lookup('pipe','date') }}" + msg: "{{ inventory_hostname }} start: {{ lookup('pipe', 'date') }}" - ansible.builtin.include_tasks: "{{ inventory_hostname }}.yml" - ansible.builtin.debug: - msg: "{{ inventory_hostname }} finish: {{ lookup('pipe','date') }}" + msg: "{{ inventory_hostname }} finish: {{ lookup('pipe', 'date') }}" diff --git a/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/missing.yml b/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/missing.yml index 07464f2672c..864eed3061c 100644 --- a/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/missing.yml +++ b/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/missing.yml @@ -2,7 +2,7 @@ - name: Attempt to delete non-existent buckets block: - ansible.builtin.set_fact: - local_bucket_name: "{{ bucket_name | hash('md5')}}-missing" + local_bucket_name: "{{ s3_bucket_name | hash('md5') }}-missing" # ============================================================ # # While in theory the 'simple' test case covers this there are diff --git a/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/object_lock.yml b/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/object_lock.yml index a95b9c025a5..77531dc28f2 100644 --- a/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/object_lock.yml +++ b/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/object_lock.yml @@ -7,7 +7,7 @@ region: "{{ aws_region }}" block: - ansible.builtin.set_fact: - local_bucket_name: "{{ bucket_name | hash('md5')}}-objectlock" + local_bucket_name: "{{ s3_bucket_name | hash('md5') }}-objectlock" # ============================================================ diff --git a/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/ownership_controls.yml b/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/ownership_controls.yml index 9c721196aa9..3f5d3da57c2 100644 --- a/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/ownership_controls.yml +++ b/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/ownership_controls.yml @@ -7,7 +7,7 @@ region: "{{ aws_region }}" block: - ansible.builtin.set_fact: - local_bucket_name: "{{ bucket_name | hash('md5')}}ownership" + local_bucket_name: "{{ s3_bucket_name | hash('md5') }}ownership" - name: Create a simple bucket bad value for ownership controls amazon.aws.s3_bucket: @@ -33,12 +33,12 @@ - output.changed - not output.object_ownership|bool - - name: delete s3 bucket + - name: Delete s3 bucket amazon.aws.s3_bucket: name: "{{ local_bucket_name }}" state: absent - - name: create s3 bucket with object ownership controls + - name: Create s3 bucket with object ownership controls amazon.aws.s3_bucket: name: "{{ local_bucket_name }}" state: present @@ -51,7 +51,7 @@ - output.object_ownership - output.object_ownership == 'ObjectWriter' - - name: update s3 bucket ownership preferred controls + - name: Update s3 bucket ownership preferred controls amazon.aws.s3_bucket: name: "{{ local_bucket_name }}" state: present @@ -64,7 +64,7 @@ - output.object_ownership - output.object_ownership == 'BucketOwnerPreferred' - - name: test idempotency update s3 bucket ownership preferred controls + - name: Test idempotency update s3 bucket ownership preferred controls amazon.aws.s3_bucket: name: "{{ local_bucket_name }}" state: present @@ -77,7 +77,7 @@ - output.object_ownership - output.object_ownership == 'BucketOwnerPreferred' - - name: update s3 bucket ownership enforced controls + - name: Update s3 bucket ownership enforced controls amazon.aws.s3_bucket: name: "{{ local_bucket_name }}" state: present @@ -90,7 +90,7 @@ - output.object_ownership - output.object_ownership == 'BucketOwnerEnforced' - - name: test idempotency update s3 bucket ownership preferred controls + - name: Test idempotency update s3 bucket ownership preferred controls amazon.aws.s3_bucket: name: "{{ local_bucket_name }}" state: present @@ -103,7 +103,7 @@ - output.object_ownership - output.object_ownership == 'BucketOwnerEnforced' - - name: delete s3 bucket ownership controls + - name: Delete s3 bucket ownership controls amazon.aws.s3_bucket: name: "{{ local_bucket_name }}" state: present @@ -115,7 +115,7 @@ - output.changed - not output.object_ownership|bool - - name: delete s3 bucket ownership controls once again (idempotency) + - name: Delete s3 bucket ownership controls once again (idempotency) amazon.aws.s3_bucket: name: "{{ local_bucket_name }}" state: present @@ -129,7 +129,7 @@ # ============================================================ always: - - name: delete s3 bucket ownership controls + - name: Delete s3 bucket ownership controls amazon.aws.s3_bucket: name: "{{ local_bucket_name }}" state: present diff --git a/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/public_access.yml b/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/public_access.yml index f5fb6dec2a9..98d8f194037 100644 --- a/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/public_access.yml +++ b/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/public_access.yml @@ -7,7 +7,7 @@ region: "{{ aws_region }}" block: - ansible.builtin.set_fact: - local_bucket_name: "{{ bucket_name | hash('md5')}}-public" + local_bucket_name: "{{ s3_bucket_name | hash('md5') }}-public" # ============================================================ - name: Create a simple bucket with public access block configuration diff --git a/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/simple.yml b/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/simple.yml index 2a262d5359e..7d2e5adab92 100644 --- a/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/simple.yml +++ b/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/simple.yml @@ -2,7 +2,7 @@ - name: Run simple tests block: - ansible.builtin.set_fact: - local_bucket_name: "{{ bucket_name | hash('md5')}}-simple" + local_bucket_name: "{{ s3_bucket_name | hash('md5') }}-simple" # Note: s3_bucket doesn't support check_mode # ============================================================ diff --git a/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/tags.yml b/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/tags.yml index 36902ea9d3e..8fa6b3db0d0 100644 --- a/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/tags.yml +++ b/tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/tags.yml @@ -2,7 +2,7 @@ - name: Run tagging tests block: - ansible.builtin.set_fact: - local_bucket_name: "{{ bucket_name | hash('md5')}}-tags" + local_bucket_name: "{{ s3_bucket_name | hash('md5') }}-tags" # ============================================================ - name: Create simple s3_bucket for testing tagging amazon.aws.s3_bucket: @@ -83,10 +83,10 @@ ## ============================================================ - #- name: 'Pause to help with s3 bucket eventual consistency' - # wait_for: - # timeout: 10 - # delegate_to: localhost + # - name: 'Pause to help with s3 bucket eventual consistency' + # wait_for: + # timeout: 10 + # delegate_to: localhost ## ============================================================ @@ -124,10 +124,10 @@ ## ============================================================ - #- name: 'Pause to help with s3 bucket eventual consistency' - # wait_for: - # timeout: 10 - # delegate_to: localhost + # - name: 'Pause to help with s3 bucket eventual consistency' + # wait_for: + # timeout: 10 + # delegate_to: localhost ## ============================================================ @@ -165,10 +165,10 @@ ## ============================================================ - #- name: 'Pause to help with s3 bucket eventual consistency' - # wait_for: - # timeout: 10 - # delegate_to: localhost + # - name: 'Pause to help with s3 bucket eventual consistency' + # wait_for: + # timeout: 10 + # delegate_to: localhost ## ============================================================ @@ -189,10 +189,10 @@ ## ============================================================ - #- name: 'Pause to help with s3 bucket eventual consistency' - # wait_for: - # timeout: 10 - # delegate_to: localhost + # - name: 'Pause to help with s3 bucket eventual consistency' + # wait_for: + # timeout: 10 + # delegate_to: localhost ## ============================================================ diff --git a/tests/integration/targets/s3_object/tasks/copy_multipart_upload.yml b/tests/integration/targets/s3_object/tasks/copy_multipart_upload.yml index edab77b6e88..c0ca19015a9 100644 --- a/tests/integration/targets/s3_object/tasks/copy_multipart_upload.yml +++ b/tests/integration/targets/s3_object/tasks/copy_multipart_upload.yml @@ -1,3 +1,4 @@ +--- - name: Test copying object create using multipart upload vars: test_bucket: "{{ resource_prefix }}-multipart" diff --git a/tests/integration/targets/s3_object/tasks/copy_object.yml b/tests/integration/targets/s3_object/tasks/copy_object.yml index 85a2b57daf8..cc15b0d62dc 100644 --- a/tests/integration/targets/s3_object/tasks/copy_object.yml +++ b/tests/integration/targets/s3_object/tasks/copy_object.yml @@ -10,18 +10,18 @@ another: meta mode: copy block: - - name: define bucket name used for tests + - name: Define bucket name used for tests ansible.builtin.set_fact: copy_bucket: src: "{{ bucket_name }}-copysrc" dst: "{{ bucket_name }}-copydst" - - name: create bucket source + - name: Create bucket source amazon.aws.s3_bucket: name: "{{ copy_bucket.src }}" state: present - - name: create bucket destination + - name: Create bucket destination amazon.aws.s3_bucket: name: "{{ copy_bucket.dst }}" state: present @@ -68,7 +68,7 @@ object: destination.txt register: copy_content - - name: assert that the content is matching with the source + - name: Assert that the content is matching with the source ansible.builtin.assert: that: - content == copy_content.contents @@ -80,7 +80,7 @@ object: destination.txt register: copy_url - - name: assert that tags are the same in the destination bucket + - name: Assert that tags are the same in the destination bucket ansible.builtin.assert: that: - put_result.tags == copy_url.tags @@ -95,7 +95,7 @@ object: source.txt register: copy_idempotency - - name: assert that no change was made + - name: Assert that no change was made ansible.builtin.assert: that: - copy_idempotency is not changed @@ -113,7 +113,7 @@ object: source.txt register: copy_result - - name: assert that tags were updated + - name: Assert that tags were updated ansible.builtin.assert: that: - copy_result is changed @@ -131,7 +131,7 @@ object: source.txt register: copy_result - - name: assert that no change was made + - name: Assert that no change was made ansible.builtin.assert: that: - copy_result is not changed @@ -207,7 +207,7 @@ - copywithmeta register: obj_info - - assert: + - ansible.builtin.assert: that: - obj_info.results | selectattr('item', 'equalto', 'nometa') | map(attribute='object_info.0.object_data.metadata') | first == {} - obj_info.results | selectattr('item', 'equalto', 'withmeta') | map(attribute='object_info.0.object_data.metadata') | first == withmeta_data diff --git a/tests/integration/targets/s3_object/tasks/copy_object_acl_disabled_bucket.yml b/tests/integration/targets/s3_object/tasks/copy_object_acl_disabled_bucket.yml index e0ef19342b5..95dd4cc51cb 100644 --- a/tests/integration/targets/s3_object/tasks/copy_object_acl_disabled_bucket.yml +++ b/tests/integration/targets/s3_object/tasks/copy_object_acl_disabled_bucket.yml @@ -1,5 +1,5 @@ --- -- name: test copying objects to bucket with ACL disabled +- name: Test copying objects to bucket with ACL disabled block: - name: Create a bucket with ACL disabled for the test amazon.aws.s3_bucket: @@ -23,6 +23,7 @@ ansible.builtin.copy: content: "{{ content }}" dest: "{{ remote_tmp_dir }}/acl_disabled_upload_test.txt" + mode: "0644" - name: Upload a file to the bucket (check_mode) amazon.aws.s3_object: diff --git a/tests/integration/targets/s3_object/tasks/copy_recursively.yml b/tests/integration/targets/s3_object/tasks/copy_recursively.yml index 39637ce5466..76998feddaa 100644 --- a/tests/integration/targets/s3_object/tasks/copy_recursively.yml +++ b/tests/integration/targets/s3_object/tasks/copy_recursively.yml @@ -1,5 +1,23 @@ --- - name: Test copy recursively object from one bucket to another one. + vars: + bucket_src: "{{ bucket_name }}-recursive-src" + bucket_dst: "{{ bucket_name }}-recursive-dst" + s3_objects: + - object: file1.txt + content: | + some content for file1.txt + - object: file2.txt + content: | + some content for file2.txt + - object: file3.txt + content: | + some content for file3.txt + - object: testfile.py + content: This is a sample text file + - object: another.txt + content: another file to create into bucket + block: - name: Create S3 bucket amazon.aws.s3_bucket: @@ -25,7 +43,7 @@ bucket: "{{ bucket_src }}" check_mode: true - - name: list objects from bucket + - name: List objects from bucket amazon.aws.s3_object: bucket: "{{ bucket_dst }}" mode: list @@ -37,7 +55,7 @@ - _objects.s3_keys | length == 0 # Test: Copy all objects using prefix - - name: copy object using prefix + - name: Copy object using prefix amazon.aws.s3_object: bucket: "{{ bucket_dst }}" mode: copy @@ -46,7 +64,7 @@ prefix: file register: _copy_with_prefix - - name: list objects from bucket + - name: List objects from bucket amazon.aws.s3_object: bucket: "{{ bucket_dst }}" mode: list @@ -62,7 +80,7 @@ - '"file3.txt" in _objects.s3_keys' # Test: Copy all objects using prefix (idempotency) - - name: copy object using prefix (idempotency) + - name: Copy object using prefix (idempotency) amazon.aws.s3_object: bucket: "{{ bucket_dst }}" mode: copy @@ -71,7 +89,7 @@ prefix: file register: _copy_with_prefix_idempotency - - name: list objects from bucket + - name: List objects from bucket amazon.aws.s3_object: bucket: "{{ bucket_dst }}" mode: list @@ -86,7 +104,7 @@ - '"file2.txt" in _objects.s3_keys' - '"file3.txt" in _objects.s3_keys' - - name: test list to get just 1 object from the bucket + - name: Test list to get just 1 object from the bucket amazon.aws.s3_object: bucket: "{{ bucket_dst }}" mode: list @@ -101,7 +119,7 @@ - result.msg == "LIST operation complete" # Test: Copy all objects from source bucket - - name: copy all objects from source bucket + - name: Copy all objects from source bucket amazon.aws.s3_object: bucket: "{{ bucket_dst }}" mode: copy @@ -109,7 +127,7 @@ bucket: "{{ bucket_src }}" register: _copy_all - - name: list objects from bucket + - name: List objects from bucket amazon.aws.s3_object: bucket: "{{ bucket_dst }}" mode: list @@ -122,7 +140,7 @@ - _objects.s3_keys | length == 5 # Test: Copy all objects from source bucket (idempotency) - - name: copy all objects from source bucket (idempotency) + - name: Copy all objects from source bucket (idempotency) amazon.aws.s3_object: bucket: "{{ bucket_dst }}" mode: copy @@ -130,7 +148,7 @@ bucket: "{{ bucket_src }}" register: _copy_all_idempotency - - name: list objects from bucket + - name: List objects from bucket amazon.aws.s3_object: bucket: "{{ bucket_dst }}" mode: list @@ -142,24 +160,6 @@ - _copy_all_idempotency is not changed - _objects.s3_keys | length == 5 - vars: - bucket_src: "{{ bucket_name }}-recursive-src" - bucket_dst: "{{ bucket_name }}-recursive-dst" - s3_objects: - - object: file1.txt - content: | - some content for file1.txt - - object: file2.txt - content: | - some content for file2.txt - - object: file3.txt - content: | - some content for file3.txt - - object: testfile.py - content: This is a sample text file - - object: another.txt - content: another file to create into bucket - always: - ansible.builtin.include_tasks: delete_bucket.yml with_items: diff --git a/tests/integration/targets/s3_object/tasks/delete_bucket.yml b/tests/integration/targets/s3_object/tasks/delete_bucket.yml index 9a33c8132f3..ce0ba78627a 100644 --- a/tests/integration/targets/s3_object/tasks/delete_bucket.yml +++ b/tests/integration/targets/s3_object/tasks/delete_bucket.yml @@ -1,13 +1,13 @@ --- -- name: delete bucket at the end of Integration tests +- name: Delete bucket at the end of Integration tests block: - - name: list bucket object + - name: List bucket object amazon.aws.s3_object_info: bucket_name: "{{ item }}" register: objects ignore_errors: true - - name: remove objects from bucket + - name: Remove objects from bucket amazon.aws.s3_object: bucket: "{{ item }}" mode: delobj @@ -18,7 +18,7 @@ when: "'s3_keys' in objects" ignore_errors: true - - name: delete the bucket + - name: Delete the bucket amazon.aws.s3_bucket: name: "{{ item }}" state: absent diff --git a/tests/integration/targets/s3_object/tasks/main.yml b/tests/integration/targets/s3_object/tasks/main.yml index 70041d36ad2..5114d7372d0 100644 --- a/tests/integration/targets/s3_object/tasks/main.yml +++ b/tests/integration/targets/s3_object/tasks/main.yml @@ -14,15 +14,15 @@ ansible_async_dir: "{{ lookup('env', 'HOME') }}/.ansible_async_{{ tiny_prefix }}/" when: (lookup('env', 'HOME')) - - name: get ARN of calling user + - name: Get ARN of calling user amazon.aws.aws_caller_info: register: aws_caller_info - - name: register account id + - name: Register account id ansible.builtin.set_fact: aws_account: "{{ aws_caller_info.account }}" - - name: check that temp directory was made + - name: Check that temp directory was made ansible.builtin.assert: that: - remote_tmp_dir is defined @@ -31,13 +31,13 @@ ansible.builtin.set_fact: content: "{{ lookup('password', '/dev/null chars=ascii_letters,digits,hexdigits,punctuation') }}" - - name: test create bucket + - name: Test create bucket amazon.aws.s3_bucket: name: "{{ bucket_name }}" state: present register: result - - name: list objects from empty bucket + - name: List objects from empty bucket amazon.aws.s3_object_info: bucket_name: "{{ bucket_name }}" register: objects @@ -51,7 +51,7 @@ that: - result is changed - - name: make a bucket with the bucket-owner-full-control ACL + - name: Make a bucket with the bucket-owner-full-control ACL amazon.aws.s3_bucket: name: "{{ bucket_name_acl }}" state: present @@ -66,14 +66,15 @@ ansible.builtin.copy: content: "{{ content }}" dest: "{{ remote_tmp_dir }}/upload.txt" + mode: "0644" - - name: stat the file + - name: Stat the file ansible.builtin.stat: path: "{{ remote_tmp_dir }}/upload.txt" get_checksum: true register: upload_file - - name: test putting an object in the bucket + - name: Test putting an object in the bucket amazon.aws.s3_object: bucket: "{{ bucket_name }}" mode: put @@ -148,7 +149,7 @@ - '"last_modified" in info_result.object_info[0].object_data' - '"content_type" in info_result.object_info[0].object_data' - - name: test using s3_object with async + - name: Test using s3_object with async amazon.aws.s3_object: bucket: "{{ bucket_name }}" mode: put @@ -158,14 +159,14 @@ async: 30 poll: 0 - - name: ensure it completed + - name: Ensure it completed ansible.builtin.async_status: jid: "{{ test_async.ansible_job_id }}" register: status until: status is finished retries: 30 - - name: test put with overwrite=different and unmodified object + - name: Test put with overwrite=different and unmodified object amazon.aws.s3_object: bucket: "{{ bucket_name }}" mode: put @@ -179,7 +180,7 @@ that: - result is not changed - - name: check that roles file lookups work as expected + - name: Check that roles file lookups work as expected amazon.aws.s3_object: bucket: "{{ bucket_name }}" mode: put @@ -197,7 +198,7 @@ # s3_object (and its old alias) use an action plugin to support using the # 'file' lookup path or a remote path. Keeping this working is dependent on # having a redirect for both the module and the action plugin - - name: check that roles file lookups work as expected when using old name + - name: Check that roles file lookups work as expected when using old name amazon.aws.s3_object: bucket: "{{ bucket_name }}" mode: put @@ -213,7 +214,7 @@ - result is changed - result.msg == "PUT operation complete" - - name: test put with overwrite=never + - name: Test put with overwrite=never amazon.aws.s3_object: bucket: "{{ bucket_name }}" mode: put @@ -228,7 +229,7 @@ that: - result is not changed - - name: test put with overwrite=different and modified object + - name: Test put with overwrite=different and modified object amazon.aws.s3_object: bucket: "{{ bucket_name }}" mode: put @@ -243,7 +244,7 @@ that: - result is changed - - name: test put with overwrite=always + - name: Test put with overwrite=always amazon.aws.s3_object: bucket: "{{ bucket_name }}" mode: put @@ -258,7 +259,7 @@ that: - result is changed - - name: test get object + - name: Test get object amazon.aws.s3_object: bucket: "{{ bucket_name }}" mode: get @@ -269,7 +270,7 @@ register: result until: result.msg == 'GET operation complete' - - name: stat the file so we can compare the checksums + - name: Stat the file so we can compare the checksums ansible.builtin.stat: path: "{{ remote_tmp_dir }}/download.txt" get_checksum: true @@ -279,7 +280,7 @@ that: - upload_file.stat.checksum == download_file.stat.checksum - - name: test get object (absolute path) + - name: Test get object (absolute path) amazon.aws.s3_object: bucket: "{{ bucket_name }}" mode: get @@ -290,7 +291,7 @@ register: result until: result.msg == 'GET operation complete' - - name: stat the file so we can compare the checksums + - name: Stat the file so we can compare the checksums ansible.builtin.stat: path: "{{ remote_tmp_dir }}/download-2.txt" get_checksum: true @@ -300,7 +301,7 @@ that: - upload_file.stat.checksum == download_file.stat.checksum - - name: test get with overwrite=different and identical files + - name: Test get with overwrite=different and identical files amazon.aws.s3_object: bucket: "{{ bucket_name }}" mode: get @@ -314,12 +315,13 @@ that: - result is not changed - - name: modify destination + - name: Modify destination ansible.builtin.copy: dest: "{{ remote_tmp_dir }}/download.txt" src: hello.txt + mode: "0644" - - name: test get with overwrite=never + - name: Test get with overwrite=never amazon.aws.s3_object: bucket: "{{ bucket_name }}" mode: get @@ -334,7 +336,7 @@ that: - result is not changed - - name: test get with overwrite=different and modified file + - name: Test get with overwrite=different and modified file amazon.aws.s3_object: bucket: "{{ bucket_name }}" mode: get @@ -348,7 +350,7 @@ that: - result is changed - - name: test get with overwrite=always + - name: Test get with overwrite=always amazon.aws.s3_object: bucket: "{{ bucket_name }}" mode: get @@ -363,7 +365,7 @@ that: - result is changed - - name: test get with overwrite=latest and identical files + - name: Test get with overwrite=latest and identical files amazon.aws.s3_object: bucket: "{{ bucket_name }}" mode: get @@ -378,9 +380,10 @@ that: - result is not changed - - name: modify mtime for local file to past - ansible.builtin.shell: touch -mt 197001010900.00 "{{ remote_tmp_dir }}/download.txt" - - name: test get with overwrite=latest and files that mtimes are different + - name: Modify mtime for local file to past + ansible.builtin.command: touch -mt 197001010900.00 "{{ remote_tmp_dir }}/download.txt" # noqa: no-changed-when + + - name: Test get with overwrite=latest and files that mtimes are different amazon.aws.s3_object: bucket: "{{ bucket_name }}" mode: get @@ -395,7 +398,7 @@ that: - result is changed - - name: test geturl of the object + - name: Test geturl of the object amazon.aws.s3_object: bucket: "{{ bucket_name }}" mode: geturl @@ -410,7 +413,7 @@ - "'Download url:' in result.msg" - result is changed - - name: test geturl of the object with sigv4 + - name: Test geturl of the object with sigv4 amazon.aws.s3_object: bucket: "{{ bucket_name }}" mode: geturl @@ -426,7 +429,7 @@ - "'Download url:' in result.msg" - result is changed - - name: test getstr of the object + - name: Test getstr of the object amazon.aws.s3_object: bucket: "{{ bucket_name }}" mode: getstr @@ -440,7 +443,7 @@ - result.msg == "GET operation complete" - result.contents == content - - name: test list to get all objects in the bucket + - name: Test list to get all objects in the bucket amazon.aws.s3_object: bucket: "{{ bucket_name }}" mode: list @@ -453,7 +456,7 @@ - "'delete.txt' in result.s3_keys" - result.msg == "LIST operation complete" - - name: test delobj to just delete an object in the bucket + - name: Test delobj to just delete an object in the bucket amazon.aws.s3_object: bucket: "{{ bucket_name }}" mode: delobj @@ -467,7 +470,7 @@ - "'Object deleted from bucket' in result.msg" - result is changed - - name: test putting an object in the bucket with metadata set + - name: Test putting an object in the bucket with metadata set amazon.aws.s3_object: bucket: "{{ bucket_name }}" mode: put @@ -486,7 +489,7 @@ - result is changed - result.msg == "PUT operation complete" - - name: test delobj to just delete an object in the bucket + - name: Test delobj to just delete an object in the bucket amazon.aws.s3_object: bucket: "{{ bucket_name }}" mode: delobj @@ -495,7 +498,7 @@ delay: 3 register: result - - name: test putting an encrypted object in the bucket + - name: Test putting an encrypted object in the bucket amazon.aws.s3_object: bucket: "{{ bucket_name }}" mode: put @@ -511,7 +514,7 @@ - result is changed - result.msg == "PUT operation complete" - - name: test get encrypted object + - name: Test get encrypted object amazon.aws.s3_object: bucket: "{{ bucket_name }}" mode: get @@ -522,7 +525,7 @@ register: result until: result.msg == 'GET operation complete' - - name: stat the file so we can compare the checksums + - name: Stat the file so we can compare the checksums ansible.builtin.stat: path: "{{ remote_tmp_dir }}/download_encrypted.txt" get_checksum: true @@ -532,7 +535,7 @@ that: - upload_file.stat.checksum == download_file.stat.checksum - - name: delete encrypted file + - name: Delete encrypted file amazon.aws.s3_object: bucket: "{{ bucket_name }}" mode: delobj @@ -540,7 +543,7 @@ retries: 3 delay: 3 - - name: test putting an aws:kms encrypted object in the bucket + - name: Test putting an aws:kms encrypted object in the bucket amazon.aws.s3_object: bucket: "{{ bucket_name }}" mode: put @@ -557,7 +560,7 @@ - result is changed - result.msg == "PUT operation complete" - - name: test get KMS encrypted object + - name: Test get KMS encrypted object amazon.aws.s3_object: bucket: "{{ bucket_name }}" mode: get @@ -568,7 +571,7 @@ register: result until: result.msg == 'GET operation complete' - - name: get the stat of the file so we can compare the checksums + - name: Get the stat of the file so we can compare the checksums ansible.builtin.stat: path: "{{ remote_tmp_dir }}/download_kms.txt" get_checksum: true @@ -580,7 +583,7 @@ # FIXME - could use a test that checks uploaded file is *actually* aws:kms encrypted - - name: delete KMS encrypted file + - name: Delete KMS encrypted file amazon.aws.s3_object: bucket: "{{ bucket_name }}" mode: delobj @@ -592,7 +595,7 @@ # but that would require ability to create and remove such keys. # PRs exist for that, but propose deferring until after merge. - - name: test creation of empty path + - name: Test creation of empty path amazon.aws.s3_object: bucket: "{{ bucket_name }}" mode: create @@ -606,7 +609,7 @@ - "'Virtual directory foo/bar/baz/ created' in result.msg" - result is changed - - name: test deletion of empty path + - name: Test deletion of empty path amazon.aws.s3_object: bucket: "{{ bucket_name }}" mode: delobj @@ -614,7 +617,7 @@ retries: 3 delay: 3 - - name: test delete bucket + - name: Test delete bucket amazon.aws.s3_bucket: name: "{{ bucket_name }}" state: absent @@ -632,28 +635,32 @@ name: "{{ bucket_name }}" state: present - - name: test multipart download - platform specific + - name: Test multipart download - platform specific when: - ansible_system == 'Linux' or ansible_distribution == 'MacOSX' block: - - name: make tempfile 4 GB for OSX - ansible.builtin.command: - _raw_params: dd if=/dev/zero of={{ remote_tmp_dir }}/largefile bs=1m count=4096 + - name: Make tempfile 4 GB for OSX + ansible.builtin.command: | + dd if=/dev/zero of={{ remote_tmp_dir }}/largefile bs=1m count=4096 + args: + creates: "{{ remote_tmp_dir }}/largefile" when: ansible_distribution == 'MacOSX' - - name: make tempfile 4 GB for linux - ansible.builtin.command: - _raw_params: dd if=/dev/zero of={{ remote_tmp_dir }}/largefile bs=1M count=4096 + - name: Make tempfile 4 GB for linux + ansible.builtin.command: | + dd if=/dev/zero of={{ remote_tmp_dir }}/largefile bs=1M count=4096 + args: + creates: "{{ remote_tmp_dir }}/largefile" when: ansible_system == 'Linux' - - name: upload the file to the bucket + - name: Upload the file to the bucket amazon.aws.s3_object: bucket: "{{ bucket_name }}" mode: put src: "{{ remote_tmp_dir }}/largefile" object: multipart.txt - - name: download file once + - name: Download file once amazon.aws.s3_object: bucket: "{{ bucket_name }}" mode: get @@ -669,7 +676,7 @@ that: - result is changed - - name: download file again + - name: Download file again amazon.aws.s3_object: bucket: "{{ bucket_name }}" mode: get @@ -683,7 +690,7 @@ - result is not changed # Public objects aren't allowed by default - - name: fail to upload the file to the bucket with an ACL + - name: Fail to upload the file to the bucket with an ACL amazon.aws.s3_object: bucket: "{{ bucket_name_acl }}" mode: put @@ -698,7 +705,7 @@ that: - upload_private is failed - - name: upload the file to the bucket with an ACL + - name: Upload the file to the bucket with an ACL amazon.aws.s3_object: bucket: "{{ bucket_name_acl }}" mode: put @@ -712,7 +719,7 @@ that: - upload_owner is changed - - name: create an object from static content + - name: Create an object from static content amazon.aws.s3_object: bucket: "{{ bucket_name }}" object: put-content.txt @@ -725,7 +732,7 @@ that: - result is changed - - name: ensure idempotency on static content + - name: Ensure idempotency on static content amazon.aws.s3_object: bucket: "{{ bucket_name }}" object: put-content.txt @@ -738,7 +745,7 @@ that: - result is not changed - - name: fetch test content + - name: Fetch test content amazon.aws.s3_object: bucket: "{{ bucket_name }}" mode: getstr @@ -752,7 +759,7 @@ - ansible.builtin.set_fact: put_template_text: test template - - name: create an object from a template + - name: Create an object from a template amazon.aws.s3_object: bucket: "{{ bucket_name }}" object: put-template.txt @@ -764,7 +771,7 @@ that: - result is changed - - name: create an object from a template (idempotency) + - name: Create an object from a template (idempotency) amazon.aws.s3_object: bucket: "{{ bucket_name }}" object: put-template.txt @@ -776,7 +783,7 @@ that: - result is not changed - - name: fetch template content + - name: Fetch template content amazon.aws.s3_object: bucket: "{{ bucket_name }}" mode: getstr @@ -792,7 +799,7 @@ src: "{{ role_path }}/files/test.png" register: put_binary - - name: create an object from binary data + - name: Create an object from binary data amazon.aws.s3_object: bucket: "{{ bucket_name }}" object: put-binary.bin @@ -804,7 +811,7 @@ that: - result is changed - - name: create an object from binary data (idempotency) + - name: Create an object from binary data (idempotency) amazon.aws.s3_object: bucket: "{{ bucket_name }}" object: put-binary.bin @@ -816,7 +823,7 @@ that: - result is not changed - - name: fetch binary content + - name: Fetch binary content amazon.aws.s3_object: bucket: "{{ bucket_name }}" mode: get @@ -824,7 +831,7 @@ object: put-binary.bin register: result - - name: stat the files so we can compare the checksums + - name: Stat the files so we can compare the checksums ansible.builtin.stat: path: "{{ item }}" get_checksum: true @@ -840,7 +847,7 @@ - name: Run tagging tests block: # ============================================================ - - name: create an object from static content + - name: Create an object from static content amazon.aws.s3_object: bucket: "{{ bucket_name }}" object: put-content.txt @@ -860,7 +867,7 @@ - result.tags["tag_one"] == resource_prefix +' One' - result.tags["Tag Two"] == 'two '+ resource_prefix - - name: ensure idempotency on static content + - name: Ensure idempotency on static content amazon.aws.s3_object: bucket: "{{ bucket_name }}" object: put-content.txt @@ -1076,13 +1083,13 @@ - ansible.builtin.include_tasks: copy_object_acl_disabled_bucket.yml - ansible.builtin.include_tasks: copy_multipart_upload.yml always: - - name: delete temporary files - file: + - name: Delete temporary files + ansible.builtin.file: state: absent path: "{{ remote_tmp_dir }}" - ignore_errors: true + ignore_errors: true # noqa: ignore-errors - - include_tasks: delete_bucket.yml + - ansible.builtin.include_tasks: delete_bucket.yml with_items: - "{{ bucket_name }}" - "{{ bucket_name_with_dot }}" diff --git a/tests/integration/targets/setup_botocore_pip/tasks/main.yml b/tests/integration/targets/setup_botocore_pip/tasks/main.yml index 3cdc538806e..8d218d5286a 100644 --- a/tests/integration/targets/setup_botocore_pip/tasks/main.yml +++ b/tests/integration/targets/setup_botocore_pip/tasks/main.yml @@ -13,22 +13,21 @@ notify: - Delete temporary pip environment -- name: Record temporary directory +- name: Record Python virtual environment details ansible.builtin.set_fact: - botocore_pip_directory: "{{ botocore_pip_directory.path }}" - -- ansible.builtin.set_fact: - botocore_virtualenv: "{{ botocore_pip_directory }}/virtualenv" + botocore_pip_directory: "{{ pip_dir }}" botocore_virtualenv_command: "{{ ansible_python_interpreter }} -m virtualenv" + botocore_virtualenv: "{{ venv_dir }}" + botocore_virtualenv_interpreter: "{{ venv_dir }}/bin/python" + vars: + pip_dir: "{{ botocore_pip_directory.path }}" + venv_dir: "{{ pip_dir }}/virtualenv" -- ansible.builtin.set_fact: - botocore_virtualenv_interpreter: "{{ botocore_virtualenv }}/bin/python" - -- ansible.builtin.pip: +- name: Install specific boto3 and botocore versions + ansible.builtin.pip: name: - boto3{{ _boto3_comparison }}{{ _boto3_version }} - botocore{{ _botocore_comparison }}{{ _botocore_version }} - - coverage<5 virtualenv: "{{ botocore_virtualenv }}" virtualenv_command: "{{ botocore_virtualenv_command }}" virtualenv_site_packages: false diff --git a/tests/integration/targets/setup_ec2_facts/tasks/main.yml b/tests/integration/targets/setup_ec2_facts/tasks/main.yml index ad282d9f339..10d679eb7a4 100644 --- a/tests/integration/targets/setup_ec2_facts/tasks/main.yml +++ b/tests/integration/targets/setup_ec2_facts/tasks/main.yml @@ -8,7 +8,8 @@ # rather than hardcoding the IDs so we're not limited to specific Regions # - ec2_ami_id # -- module_defaults: +- name: Setup common facts about the AWS region + module_defaults: group/aws: access_key: "{{ aws_access_key }}" secret_key: "{{ aws_secret_key }}" diff --git a/tests/integration/targets/setup_ec2_instance_env/defaults/main.yml b/tests/integration/targets/setup_ec2_instance_env/defaults/main.yml index 42208900c34..edb025ffa7d 100644 --- a/tests/integration/targets/setup_ec2_instance_env/defaults/main.yml +++ b/tests/integration/targets/setup_ec2_instance_env/defaults/main.yml @@ -4,7 +4,7 @@ ec2_instance_test_name: ec2_instance ec2_instance_owner: integration-run-{{ ec2_instance_test_name }} ec2_instance_type: t3.micro -ec2_instance_tag_TestId: "{{ resource_prefix }}-{{ ec2_instance_test_name }}" +ec2_instance_tag_testid: "{{ resource_prefix }}-{{ ec2_instance_test_name }}" vpc_name: "{{ resource_prefix }}-{{ ec2_instance_test_name }}" vpc_seed: "{{ resource_prefix }}-{{ ec2_instance_test_name }}" diff --git a/tests/integration/targets/setup_ec2_instance_env/tasks/cleanup.yml b/tests/integration/targets/setup_ec2_instance_env/tasks/cleanup.yml index 7d731015695..43b49c53f1a 100644 --- a/tests/integration/targets/setup_ec2_instance_env/tasks/cleanup.yml +++ b/tests/integration/targets/setup_ec2_instance_env/tasks/cleanup.yml @@ -1,5 +1,6 @@ --- -- module_defaults: +- name: Cleanup common VPC resources + module_defaults: group/aws: access_key: "{{ aws_access_key }}" secret_key: "{{ aws_secret_key }}" @@ -12,7 +13,7 @@ instance-state-name: [pending, running, stopping, stopped] vpc-id: "{{ testing_vpc.vpc.id }}" termination_protection: false - ignore_errors: true + ignore_errors: true # noqa: ignore-errors - name: (Cleanup) Find all remaining Instances amazon.aws.ec2_instance_info: @@ -26,7 +27,7 @@ state: absent instance_ids: "{{ item.instance_id }}" wait: false - ignore_errors: true + ignore_errors: true # noqa: ignore-errors loop: "{{ instances.instances }}" - name: (Cleanup) Remove Instances (wait for completion) @@ -37,7 +38,7 @@ instance-state-name: [pending, running, shutting-down, stopping, stopped] vpc-id: "{{ testing_vpc.vpc.id }}" wait: true - ignore_errors: true + ignore_errors: true # noqa: ignore-errors loop: "{{ instances.instances }}" - name: (Cleanup) Find all remaining ENIs @@ -53,7 +54,7 @@ register: eni_removed until: eni_removed is not failed with_items: "{{ enis.network_interfaces }}" - ignore_errors: true + ignore_errors: true # noqa: ignore-errors retries: 10 - name: (Cleanup) Find all remaining Security Groups @@ -73,7 +74,7 @@ loop: "{{ security_groups.security_groups }}" register: sg_removed until: sg_removed is not failed - ignore_errors: true + ignore_errors: true # noqa: ignore-errors retries: 10 - name: (Cleanup) Remove the security groups @@ -85,7 +86,7 @@ - item.group_name != 'default' register: sg_removed until: sg_removed is not failed - ignore_errors: true + ignore_errors: true # noqa: ignore-errors retries: 10 - name: (Cleanup) Find all remaining Subnets @@ -102,7 +103,7 @@ register: removed loop: "{{ subnets.subnets }}" until: removed is not failed - ignore_errors: true + ignore_errors: true # noqa: ignore-errors retries: 10 - name: (Cleanup) Remove the VPC @@ -115,5 +116,5 @@ tenancy: default register: removed until: removed is not failed - ignore_errors: true + ignore_errors: true # noqa: ignore-errors retries: 10 diff --git a/tests/integration/targets/setup_ec2_instance_env/tasks/main.yml b/tests/integration/targets/setup_ec2_instance_env/tasks/main.yml index b084e3d0dbd..9353563000f 100644 --- a/tests/integration/targets/setup_ec2_instance_env/tasks/main.yml +++ b/tests/integration/targets/setup_ec2_instance_env/tasks/main.yml @@ -1,5 +1,6 @@ --- -- run_once: '{{ setup_run_once | default("no") | bool }}' +- name: Setup common VPC components + run_once: '{{ setup_run_once | default("no") | bool }}' module_defaults: group/aws: access_key: "{{ aws_access_key }}" @@ -41,7 +42,7 @@ Name: "{{ subnet_b_name }}" register: testing_subnet_b - - name: create a security group with the vpc + - name: Create a security group with the vpc amazon.aws.ec2_security_group: state: present name: "{{ security_group_name_1 }}" @@ -58,7 +59,7 @@ cidr_ip: "0.0.0.0/0" register: sg - - name: create secondary security group with the vpc + - name: Create secondary security group with the vpc amazon.aws.ec2_security_group: name: "{{ security_group_name_2 }}" description: a secondary security group for ansible tests diff --git a/tests/integration/targets/setup_ec2_vpc/tasks/cleanup.yml b/tests/integration/targets/setup_ec2_vpc/tasks/cleanup.yml index 32a6259a1ba..3d2106fb1ac 100644 --- a/tests/integration/targets/setup_ec2_vpc/tasks/cleanup.yml +++ b/tests/integration/targets/setup_ec2_vpc/tasks/cleanup.yml @@ -5,7 +5,7 @@ group/aws: access_key: "{{ aws_access_key }}" secret_key: "{{ aws_secret_key }}" - session_token: "{{ security_token | default(omit)}}" + session_token: "{{ security_token | default(omit) }}" region: "{{ aws_region }}" block: # ============================================================ @@ -14,31 +14,31 @@ - name: (VPC Cleanup) Find all remaining ENIs amazon.aws.ec2_eni_info: filters: - vpc-id: "{{ vpc_id }}" + vpc-id: "{{ setup_ec2_vpc_id }}" register: remaining_enis - name: (VPC Cleanup) Retrieve security group info based on VPC ID amazon.aws.ec2_security_group_info: filters: - vpc-id: "{{ vpc_id }}" + vpc-id: "{{ setup_ec2_vpc_id }}" register: remaining_groups - name: (VPC Cleanup) Retrieve subnet info based on VPC ID amazon.aws.ec2_vpc_subnet_info: filters: - vpc-id: "{{ vpc_id }}" + vpc-id: "{{ setup_ec2_vpc_id }}" register: remaining_subnets - name: (VPC Cleanup) Retrieve route table info based on VPC ID amazon.aws.ec2_vpc_route_table_info: filters: - vpc-id: "{{ vpc_id }}" + vpc-id: "{{ setup_ec2_vpc_id }}" register: remaining_rtbs - name: (VPC Cleanup) Retrieve VPC info based on VPC ID amazon.aws.ec2_vpc_net_info: vpc_ids: - - "{{ vpc_id }}" + - "{{ setup_ec2_vpc_id }}" register: remaining_vpc # ============================================================ @@ -66,7 +66,7 @@ rules: [] rules_egress: [] loop: "{{ remaining_groups.security_groups }}" - ignore_errors: true + ignore_errors: true # noqa: ignore-errors - name: (VPC Cleanup) Delete remaining SGs amazon.aws.ec2_security_group: @@ -75,21 +75,21 @@ loop: "{{ remaining_groups.security_groups }}" when: - item.group_name != 'default' - ignore_errors: true + ignore_errors: true # noqa: ignore-errors # ============================================================ - name: (VPC Cleanup) Delete remaining subnets amazon.aws.ec2_vpc_subnet: state: absent - vpc_id: "{{ vpc_id }}" + vpc_id: "{{ setup_ec2_vpc_id }}" cidr: "{{ item.cidr_block }}" register: subnets_removed loop: "{{ remaining_subnets.subnets }}" until: subnets_removed is not failed when: - (item.name | default("")) != 'default' - ignore_errors: true + ignore_errors: true # noqa: ignore-errors retries: 10 # ============================================================ @@ -97,7 +97,7 @@ - name: (VPC Cleanup) Delete IGW amazon.aws.ec2_vpc_igw: state: absent - vpc_id: "{{ vpc_id }}" + vpc_id: "{{ setup_ec2_vpc_id }}" register: igw_deletion retries: 10 delay: 5 @@ -109,26 +109,26 @@ - name: (VPC Cleanup) Delete route tables (excluding main table) amazon.aws.ec2_vpc_route_table: state: absent - vpc_id: "{{ vpc_id }}" + vpc_id: "{{ setup_ec2_vpc_id }}" route_table_id: "{{ item.id }}" lookup: id register: rtbs_removed loop: "{{ remaining_rtbs.route_tables }}" when: - True not in main_associations - ignore_errors: true + ignore_errors: true # noqa: ignore-errors vars: - main_associations: "{{ item.associations | default([]) | map(attribute='main') | list}}" + main_associations: "{{ item.associations | default([]) | map(attribute='main') | list }}" # ============================================================ - name: (VPC Cleanup) Remove the VPC amazon.aws.ec2_vpc_net: state: absent - vpc_id: "{{ vpc_id }}" + vpc_id: "{{ setup_ec2_vpc_id }}" register: vpc_removed until: vpc_removed is not failed - ignore_errors: true + ignore_errors: true # noqa: ignore-errors retries: 10 # ============================================================ @@ -136,9 +136,9 @@ - name: (VPC Cleanup) (retry) Delete remaining route tables (including main table) amazon.aws.ec2_vpc_route_table: state: absent - vpc_id: "{{ vpc_id }}" + vpc_id: "{{ setup_ec2_vpc_id }}" route_table_id: "{{ item.id }}" lookup: id register: rtbs_removed loop: "{{ remaining_rtbs.route_tables }}" - ignore_errors: true + ignore_errors: true # noqa: ignore-errors diff --git a/tests/integration/targets/setup_ec2_vpc/tasks/main.yml b/tests/integration/targets/setup_ec2_vpc/tasks/main.yml index 8fe5dae64cf..9f760b57c77 100644 --- a/tests/integration/targets/setup_ec2_vpc/tasks/main.yml +++ b/tests/integration/targets/setup_ec2_vpc/tasks/main.yml @@ -1,3 +1,4 @@ --- -- ansible.builtin.debug: +- name: Load VPC cleanup role + ansible.builtin.debug: msg: VPC Cleanup module loaded diff --git a/tests/integration/targets/setup_remote_tmp_dir/handlers/main.yml b/tests/integration/targets/setup_remote_tmp_dir/handlers/main.yml index 71caeda609d..124e62f1d7c 100644 --- a/tests/integration/targets/setup_remote_tmp_dir/handlers/main.yml +++ b/tests/integration/targets/setup_remote_tmp_dir/handlers/main.yml @@ -1,5 +1,5 @@ --- -- name: delete temporary directory +- name: Delete temporary directory ansible.builtin.include_tasks: default-cleanup.yml -- name: delete temporary directory (windows) +- name: Delete temporary directory (windows) ansible.builtin.include_tasks: windows-cleanup.yml diff --git a/tests/integration/targets/setup_remote_tmp_dir/tasks/default-cleanup.yml b/tests/integration/targets/setup_remote_tmp_dir/tasks/default-cleanup.yml index 8cfe819a205..6c789b73034 100644 --- a/tests/integration/targets/setup_remote_tmp_dir/tasks/default-cleanup.yml +++ b/tests/integration/targets/setup_remote_tmp_dir/tasks/default-cleanup.yml @@ -1,5 +1,5 @@ --- -- name: delete temporary directory +- name: Delete temporary directory ansible.builtin.file: path: "{{ remote_tmp_dir }}" state: absent diff --git a/tests/integration/targets/setup_remote_tmp_dir/tasks/default.yml b/tests/integration/targets/setup_remote_tmp_dir/tasks/default.yml index 7e69b114daf..a449d4ddf90 100644 --- a/tests/integration/targets/setup_remote_tmp_dir/tasks/default.yml +++ b/tests/integration/targets/setup_remote_tmp_dir/tasks/default.yml @@ -1,13 +1,13 @@ --- -- name: create temporary directory +- name: Create temporary directory ansible.builtin.tempfile: path: /var/tmp state: directory suffix: .test register: remote_tmp_dir notify: - - delete temporary directory + - Delete temporary directory -- name: record temporary directory +- name: Record temporary directory ansible.builtin.set_fact: remote_tmp_dir: "{{ remote_tmp_dir.path }}" diff --git a/tests/integration/targets/setup_remote_tmp_dir/tasks/main.yml b/tests/integration/targets/setup_remote_tmp_dir/tasks/main.yml index 7d0156db215..1dda65457f6 100644 --- a/tests/integration/targets/setup_remote_tmp_dir/tasks/main.yml +++ b/tests/integration/targets/setup_remote_tmp_dir/tasks/main.yml @@ -1,10 +1,11 @@ --- -- name: make sure we have the ansible_os_family and ansible_distribution_version facts +- name: Make sure we have the ansible_os_family and ansible_distribution_version facts ansible.builtin.setup: gather_subset: distribution when: ansible_facts == {} -- ansible.builtin.include_tasks: "{{ lookup('first_found', files)}}" +- name: Include temporary directory setup based on OS family (Windows vs default/Linux) + ansible.builtin.include_tasks: "{{ lookup('first_found', files) }}" vars: files: - "{{ ansible_os_family | lower }}.yml" diff --git a/tests/integration/targets/setup_remote_tmp_dir/tasks/windows-cleanup.yml b/tests/integration/targets/setup_remote_tmp_dir/tasks/windows-cleanup.yml index 515488dc8f6..17f3126a025 100644 --- a/tests/integration/targets/setup_remote_tmp_dir/tasks/windows-cleanup.yml +++ b/tests/integration/targets/setup_remote_tmp_dir/tasks/windows-cleanup.yml @@ -1,5 +1,5 @@ --- -- name: delete temporary directory (windows) +- name: Delete temporary directory (windows) ansible.windows.win_file: path: "{{ remote_tmp_dir }}" state: absent diff --git a/tests/integration/targets/setup_remote_tmp_dir/tasks/windows.yml b/tests/integration/targets/setup_remote_tmp_dir/tasks/windows.yml index 4f3389cb745..73ef44f8d96 100644 --- a/tests/integration/targets/setup_remote_tmp_dir/tasks/windows.yml +++ b/tests/integration/targets/setup_remote_tmp_dir/tasks/windows.yml @@ -1,11 +1,11 @@ --- -- name: create temporary directory +- name: Create temporary directory register: remote_tmp_dir notify: - - delete temporary directory (windows) + - Delete temporary directory (windows) ansible.windows.win_tempfile: state: directory suffix: .test -- name: record temporary directory +- name: Record temporary directory ansible.builtin.set_fact: remote_tmp_dir: "{{ remote_tmp_dir.path }}" diff --git a/tests/integration/targets/setup_sshkey/tasks/main.yml b/tests/integration/targets/setup_sshkey/tasks/main.yml index b6229233183..fc32954d890 100644 --- a/tests/integration/targets/setup_sshkey/tasks/main.yml +++ b/tests/integration/targets/setup_sshkey/tasks/main.yml @@ -16,14 +16,14 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . -- name: create a temp dir +- name: Create a temp dir ansible.builtin.tempfile: state: directory register: sshkey_dir tags: - prepare -- name: ensure script is available +- name: Ensure script is available ansible.builtin.copy: src: ec2-fingerprint.py dest: "{{ sshkey_dir.path }}/ec2-fingerprint.py" @@ -39,34 +39,40 @@ another_sshkey_pub: "{{ sshkey_dir.path }}/key_two.pub" # Because some older OSes don't like the Elliptic Curve keys we'll stick to 4096 bit RSA for now -- name: generate sshkey (4096 bit RSA) - ansible.builtin.shell: echo 'y' | ssh-keygen -t rsa -b 4096 -P '' -f '{{ sshkey }}' +- name: Generate sshkey (4096 bit RSA) + ansible.builtin.command: ssh-keygen -t rsa -b 4096 -P '' -f '{{ sshkey }}' + args: + creates: '{{ sshkey }}' tags: - prepare # AWS uses a custom MD5 checksum for its RSA keys (rather than the modern default of a base64 encoded sha256 hash) -- name: record fingerprint - ansible.builtin.shell: "{{ sshkey_dir.path }}/ec2-fingerprint.py {{ sshkey_pub }}" +- name: Record fingerprint + ansible.builtin.command: "{{ sshkey_dir.path }}/ec2-fingerprint.py {{ sshkey_pub }}" + changed_when: false register: fingerprint tags: - prepare # With OpenSSH 9.5 the default changed to ED25519, to avoid confusing issues when running locally vs # in CI, we set the default -- name: generate another_sshkey (ED25519) - ansible.builtin.shell: echo 'y' | ssh-keygen -t ed25519 -P '' -f {{ another_sshkey }} +- name: Generate another_sshkey (ED25519) + ansible.builtin.command: ssh-keygen -t ed25519 -P '' -f {{ another_sshkey }} + args: + creates: '{{ another_sshkey }}' tags: - prepare # When adding support for ED25519 Amazon stuck to the newer default of base64 encoded sha256 hashes, this means we can # ask ssh-keygen for the fingerprint, but we'll explicitly ask for the sha256 version just in case the default changes -- name: record another fingerprint - ansible.builtin.shell: "ssh-keygen -l -E sha256 -f {{ another_sshkey_pub }} | cut -c 12-54" +- name: Record another fingerprint + ansible.builtin.command: "ssh-keygen -l -E sha256 -f {{ another_sshkey_pub }}" + changed_when: false register: another_fingerprint tags: - prepare -- name: set facts for future roles +- name: Set facts for future roles ansible.builtin.set_fact: # Public SSH keys (OpenSSH format) # - 4096 bit RSA (broad support) @@ -77,6 +83,6 @@ # - RSA: MD5sum based fingerprint: "{{ fingerprint.stdout }}" # - ED25519: AWS pad the base64 output (technically correct), ssh-keygen truncates the output - another_fingerprint: "{{ another_fingerprint.stdout }}=" + another_fingerprint: "{{ another_fingerprint.stdout[11:54] }}=" tags: - prepare diff --git a/tests/integration/targets/sts_assume_role/tasks/main.yml b/tests/integration/targets/sts_assume_role/tasks/main.yml index c528ac3437d..8b9b488b0dc 100644 --- a/tests/integration/targets/sts_assume_role/tasks/main.yml +++ b/tests/integration/targets/sts_assume_role/tasks/main.yml @@ -11,19 +11,19 @@ block: # Get some information about who we are before starting our tests # we'll need this as soon as we start working on the policies - - name: get ARN of calling user + - name: Get ARN of calling user amazon.aws.aws_caller_info: register: aws_caller_info - - name: register account id + - name: Register account id ansible.builtin.set_fact: aws_account: "{{ aws_caller_info.account }}" # ============================================================ - - name: create test iam role + - name: Create test iam role amazon.aws.iam_role: name: "{{ iam_role_name }}" - assume_role_policy_document: "{{ lookup('template','policy.json.j2') }}" + assume_role_policy_document: "{{ lookup('template', 'policy.json.j2') }}" create_instance_profile: false managed_policy: - arn:aws:iam::aws:policy/IAMReadOnlyAccess @@ -31,68 +31,68 @@ register: test_role # ============================================================ - - name: pause to ensure role exists before using + - name: Pause to ensure role exists before using ansible.builtin.pause: seconds: 30 # ============================================================ - - name: test with no parameters - community.aws.sts_assume_role: + - name: Test with no parameters + amazon.aws.sts_assume_role: access_key: "{{ omit }}" secret_key: "{{ omit }}" session_token: "{{ omit }}" register: result ignore_errors: true - - name: assert with no parameters + - name: Assert with no parameters ansible.builtin.assert: that: - result.failed - "'missing required arguments:' in result.msg" # ============================================================ - - name: test with only 'role_arn' parameter - community.aws.sts_assume_role: + - name: Test with only 'role_arn' parameter + amazon.aws.sts_assume_role: role_arn: "{{ test_role.iam_role.arn }}" register: result ignore_errors: true - - name: assert with only 'role_arn' parameter + - name: Assert with only 'role_arn' parameter ansible.builtin.assert: that: - result.failed - "'missing required arguments: role_session_name' in result.msg" # ============================================================ - - name: test with only 'role_session_name' parameter - community.aws.sts_assume_role: + - name: Test with only 'role_session_name' parameter + amazon.aws.sts_assume_role: role_session_name: AnsibleTest register: result ignore_errors: true - - name: assert with only 'role_session_name' parameter + - name: Assert with only 'role_session_name' parameter ansible.builtin.assert: that: - result.failed - "'missing required arguments: role_arn' in result.msg" # ============================================================ - - name: test assume role with invalid policy - community.aws.sts_assume_role: + - name: Test assume role with invalid policy + amazon.aws.sts_assume_role: role_arn: "{{ test_role.iam_role.arn }}" role_session_name: AnsibleTest policy: invalid policy register: result ignore_errors: true - - name: assert assume role with invalid policy + - name: Assert assume role with invalid policy ansible.builtin.assert: that: - result.failed - "'The policy is not in the valid JSON format.' in result.msg" when: result.module_stderr is not defined - - name: assert assume role with invalid policy + - name: Assert assume role with invalid policy ansible.builtin.assert: that: - result.failed @@ -100,15 +100,15 @@ when: result.module_stderr is defined # ============================================================ - - name: test assume role with invalid duration seconds - community.aws.sts_assume_role: + - name: Test assume role with invalid duration seconds + amazon.aws.sts_assume_role: role_arn: "{{ test_role.iam_role.arn }}" role_session_name: AnsibleTest duration_seconds: invalid duration register: result ignore_errors: true - - name: assert assume role with invalid duration seconds + - name: Assert assume role with invalid duration seconds ansible.builtin.assert: that: - result is failed @@ -116,22 +116,22 @@ - "'cannot be converted to an int' in result.msg" # ============================================================ - - name: test assume role with invalid external id - community.aws.sts_assume_role: + - name: Test assume role with invalid external id + amazon.aws.sts_assume_role: role_arn: "{{ test_role.iam_role.arn }}" role_session_name: AnsibleTest external_id: invalid external id register: result ignore_errors: true - - name: assert assume role with invalid external id + - name: Assert assume role with invalid external id ansible.builtin.assert: that: - result.failed - "'Member must satisfy regular expression pattern:' in result.msg" when: result.module_stderr is not defined - - name: assert assume role with invalid external id + - name: Assert assume role with invalid external id ansible.builtin.assert: that: - result.failed @@ -139,22 +139,22 @@ when: result.module_stderr is defined # ============================================================ - - name: test assume role with invalid mfa serial number - community.aws.sts_assume_role: + - name: Test assume role with invalid mfa serial number + amazon.aws.sts_assume_role: role_arn: "{{ test_role.iam_role.arn }}" role_session_name: AnsibleTest mfa_serial_number: invalid serial number register: result ignore_errors: true - - name: assert assume role with invalid mfa serial number + - name: Assert assume role with invalid mfa serial number ansible.builtin.assert: that: - result.failed - "'Member must satisfy regular expression pattern:' in result.msg" when: result.module_stderr is not defined - - name: assert assume role with invalid mfa serial number + - name: Assert assume role with invalid mfa serial number ansible.builtin.assert: that: - result.failed @@ -162,22 +162,22 @@ when: result.module_stderr is defined # ============================================================ - - name: test assume role with invalid mfa token code - community.aws.sts_assume_role: + - name: Test assume role with invalid mfa token code + amazon.aws.sts_assume_role: role_arn: "{{ test_role.iam_role.arn }}" role_session_name: AnsibleTest mfa_token: invalid token code register: result ignore_errors: true - - name: assert assume role with invalid mfa token code + - name: Assert assume role with invalid mfa token code ansible.builtin.assert: that: - result.failed - "'Member must satisfy regular expression pattern:' in result.msg" when: result.module_stderr is not defined - - name: assert assume role with invalid mfa token code + - name: Assert assume role with invalid mfa token code ansible.builtin.assert: that: - result.failed @@ -185,21 +185,21 @@ when: result.module_stderr is defined # ============================================================ - - name: test assume role with invalid role_arn - community.aws.sts_assume_role: + - name: Test assume role with invalid role_arn + amazon.aws.sts_assume_role: role_arn: invalid role arn role_session_name: AnsibleTest register: result ignore_errors: true - - name: assert assume role with invalid role_arn + - name: Assert assume role with invalid role_arn ansible.builtin.assert: that: - result.failed - "'Invalid length for parameter RoleArn' in result.msg" when: result.module_stderr is not defined - - name: assert assume role with invalid role_arn + - name: Assert assume role with invalid role_arn ansible.builtin.assert: that: - result.failed @@ -207,21 +207,21 @@ when: result.module_stderr is defined # ============================================================ - - name: test assume not existing sts role - community.aws.sts_assume_role: + - name: Test assume not existing sts role + amazon.aws.sts_assume_role: role_arn: arn:aws:iam::123456789:role/non-existing-role role_session_name: AnsibleTest register: result ignore_errors: true - - name: assert assume not existing sts role + - name: Assert assume not existing sts role ansible.builtin.assert: that: - result.failed - "'is not authorized to perform: sts:AssumeRole' in result.msg" when: result.module_stderr is not defined - - name: assert assume not existing sts role + - name: Assert assume not existing sts role ansible.builtin.assert: that: - result.failed @@ -229,13 +229,13 @@ when: result.module_stderr is defined # ============================================================ - - name: test assume role - community.aws.sts_assume_role: + - name: Test assume role + amazon.aws.sts_assume_role: role_arn: "{{ test_role.iam_role.arn }}" role_session_name: AnsibleTest register: assumed_role - - name: assert assume role + - name: Assert assume role ansible.builtin.assert: that: - not assumed_role.failed @@ -245,18 +245,18 @@ - "'session_token' in assumed_role.sts_creds" # ============================================================ - - name: test that assumed credentials have IAM read-only access + - name: Test that assumed credentials have IAM read-only access amazon.aws.iam_role: access_key: "{{ assumed_role.sts_creds.access_key }}" secret_key: "{{ assumed_role.sts_creds.secret_key }}" session_token: "{{ assumed_role.sts_creds.session_token }}" name: "{{ iam_role_name }}" - assume_role_policy_document: "{{ lookup('template','policy.json.j2') }}" + assume_role_policy_document: "{{ lookup('template', 'policy.json.j2') }}" create_instance_profile: false state: present register: result - - name: assert assumed role with privileged action (expect changed=false) + - name: Assert assumed role with privileged action (expect changed=false) ansible.builtin.assert: that: - not result.failed @@ -264,18 +264,18 @@ - "'iam_role' in result" # ============================================================ - - name: test assumed role with unprivileged action + - name: Test assumed role with unprivileged action amazon.aws.iam_role: access_key: "{{ assumed_role.sts_creds.access_key }}" secret_key: "{{ assumed_role.sts_creds.secret_key }}" session_token: "{{ assumed_role.sts_creds.session_token }}" name: "{{ iam_role_name }}-new" - assume_role_policy_document: "{{ lookup('template','policy.json.j2') }}" + assume_role_policy_document: "{{ lookup('template', 'policy.json.j2') }}" state: present register: result ignore_errors: true - - name: assert assumed role with unprivileged action (expect changed=false) + - name: Assert assumed role with unprivileged action (expect changed=false) ansible.builtin.assert: that: - result.failed @@ -283,7 +283,7 @@ # runs on Python2 when: result.module_stderr is not defined - - name: assert assumed role with unprivileged action (expect changed=false) + - name: Assert assumed role with unprivileged action (expect changed=false) ansible.builtin.assert: that: - result.failed @@ -293,10 +293,10 @@ # ============================================================ always: - - name: delete test iam role + - name: Delete test iam role amazon.aws.iam_role: name: "{{ iam_role_name }}" - assume_role_policy_document: "{{ lookup('template','policy.json.j2') }}" + assume_role_policy_document: "{{ lookup('template', 'policy.json.j2') }}" delete_instance_profile: true managed_policy: - arn:aws:iam::aws:policy/IAMReadOnlyAccess diff --git a/tox.ini b/tox.ini index 9925eddbfd7..706c867fe9f 100644 --- a/tox.ini +++ b/tox.ini @@ -67,7 +67,7 @@ commands = rm -rf tests/output/ htmlcov/ .mypy_cache/ complexity/ [testenv:complexity-report] -labels = lint +labels = future-lint description = Generate a HTML complexity report in the complexity directory deps = flake8-pyproject @@ -85,8 +85,11 @@ labels = lint description = Run ansible-lint deps = ansible-lint >= 24.7.0 + jmespath commands = - ansible-lint {posargs:{[common]lint_dirs}} + ansible-lint \ + --skip-list=name[missing],yaml[line-length],args[module],run-once[task],ignore-errors,sanity[cannot-ignore],run-once[play] \ + {posargs:{[common]lint_dirs}} [testenv:black] labels = format @@ -189,7 +192,8 @@ deps = shellcheck-py commands = cd {[future-lint]full_tmp_path} - ansible-lint --skip-list=name[missing],args[module],ignore-errors,yaml[line-length] {posargs:tests/integration/targets} + ansible-lint \ + {posargs:plugins/ tests/} [testenv:ansible-sanity] allowlist_externals = echo,cd,rm,mkdir,ln,ls