Skip to content

Commit

Permalink
[PR #1468/1cd7cebb backport][stable-4] tests/autoscaling_{group,lifec…
Browse files Browse the repository at this point in the history
…ycle_hook}: use setup_ec2_facts (#1499)

[PR #1468/1cd7cebb backport][stable-4] tests/autoscaling_{group,lifecycle_hook}: use setup_ec2_facts

This is a backport of PR #1468 as merged into main (1cd7ceb).
amzn2-ami-hvm-2.0.20190612-x86_64-gp2 is not available anymore, we now use setup_ec2_facts to get the right AMI ID.

Reviewed-by: Mark Chappell <None>
  • Loading branch information
patchback[bot] authored Sep 19, 2022
1 parent f1a487d commit 8786f8b
Show file tree
Hide file tree
Showing 12 changed files with 13 additions and 31 deletions.
2 changes: 2 additions & 0 deletions tests/integration/targets/ec2_asg/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
security_token: "{{ security_token | default(omit) }}"
region: "{{ aws_region }}"
block:
- include_role:
name: 'setup_ec2_facts'
- include_role:
name: 'ec2_asg'
tasks_from: env_setup.yml
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/targets/ec2_asg/meta/main.yml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
dependencies: []
dependencies:
- setup_ec2_facts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
---
# defaults file for ec2_asg
# Amazon Linux 2 AMI 2019.06.12 (HVM), GP2 Volume Type
ec2_ami_name: 'amzn2-ami-hvm-2.0.20190612-x86_64-gp2'
load_balancer_name: "{{ tiny_prefix }}-lb"
ec2_asg_setup_run_once: true
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
ec2_lc:
name: "{{ item }}"
assign_public_ip: true
image_id: "{{ ec2_ami_image }}"
image_id: "{{ ec2_ami_id }}"
user_data: |
#cloud-config
package_upgrade: true
Expand Down Expand Up @@ -431,7 +431,7 @@
- name: create launch template for autoscaling group to test its mixed instances policy
ec2_launch_template:
template_name: "{{ resource_prefix }}-lt"
image_id: "{{ ec2_ami_image }}"
image_id: "{{ ec2_ami_id }}"
instance_type: t3.micro
credit_specification:
cpu_credits: standard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,6 @@
run_once: '{{ ec2_asg_setup_run_once }}'
block:

# ============================================================

- name: Find AMI to use
ec2_ami_info:
owners: 'amazon'
filters:
name: '{{ ec2_ami_name }}'
register: ec2_amis
- set_fact:
ec2_ami_image: '{{ ec2_amis.images[0].image_id }}'

# Set up the testing dependencies: VPC, subnet, security group, and two launch configurations
- name: Create VPC for use in testing
ec2_vpc_net:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
- name: create a launch configuration
ec2_lc:
name: "{{ resource_prefix }}-lc-detach-test"
image_id: "{{ ec2_ami_image }}"
image_id: "{{ ec2_ami_id }}"
region: "{{ aws_region }}"
instance_type: t2.micro
assign_public_ip: yes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
- name: create a launch configuration
ec2_lc:
name: "{{ resource_prefix }}-lc-tag-test"
image_id: "{{ ec2_ami_image }}"
image_id: "{{ ec2_ami_id }}"
region: "{{ aws_region }}"
instance_type: t2.micro
assign_public_ip: yes
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/targets/ec2_asg_lifecycle_hook/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
# running an 'include' that was run_once
setup_run_once: yes
block:
- include_role:
name: 'setup_ec2_facts'
- include_role:
name: 'ec2_asg_lifecycle_hook'
tasks_from: env_setup.yml
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
dependencies: []
dependencies:
- setup_ec2_facts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
# defaults file for ec2_asg_lifecycle_hook
# Amazon Linux 2 AMI 2019.06.12 (HVM), GP2 Volume Type
ec2_ami_name: 'amzn2-ami-hvm-2.0.20190612-x86_64-gp2'
load_balancer_name: "{{ tiny_prefix }}-lb"
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- name: create a launch configuration
ec2_lc:
name: "{{ resource_prefix }}-lc"
image_id: "{{ ec2_ami_image }}"
image_id: "{{ ec2_ami_id }}"
region: "{{ aws_region }}"
instance_type: t2.micro
assign_public_ip: yes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,6 @@

# ============================================================

- name: Find AMI to use
ec2_ami_info:
owners: 'amazon'
filters:
name: '{{ ec2_ami_name }}'
register: ec2_amis
- set_fact:
ec2_ami_image: '{{ ec2_amis.images[0].image_id }}'

# Set up the testing dependencies: VPC, subnet, security group, and two launch configurations
- name: Create VPC for use in testing
ec2_vpc_net:
Expand Down

0 comments on commit 8786f8b

Please sign in to comment.