Skip to content

Commit

Permalink
Ensure only running instance facts are retrieved to match the followi…
Browse files Browse the repository at this point in the history
…ng assertion

Otherwise lingering terminated instances may be in the result
Use the instance profile arn or the role name, but not the role arn
Mark tests as unstable
  • Loading branch information
s-hertel committed Jul 2, 2019
1 parent a6d757e commit 7ec3119
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions test/integration/targets/ec2_instance/aliases
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
cloud/aws
shippable/aws/group2
unstable
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
image_id: "{{ ec2_ami_image[aws_region] }}"
security_groups: "{{ sg.group_id }}"
instance_type: t2.micro
instance_role: "{{ iam_role.arn }}"
instance_role: "{{ iam_role.arn.replace(':role/', ':instance-profile/') }}"
<<: *aws_connection_info
check_mode: yes

Expand Down Expand Up @@ -80,7 +80,7 @@
image_id: "{{ ec2_ami_image[aws_region] }}"
security_groups: "{{ sg.group_id }}"
instance_type: t2.micro
instance_role: "{{ iam_role_2.arn }}"
instance_role: "{{ iam_role_2.arn.replace(':role/', ':instance-profile/') }}"
<<: *aws_connection_info
register: instance_with_updated_role
until: instance_with_updated_role is not failed
Expand Down
4 changes: 1 addition & 3 deletions test/integration/targets/ec2_instance/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
# - EC2_REGION -> AWS_REGION
#

# - include: ../../../../../setup_ec2/tasks/common.yml module_name: ec2_instance

- block:

- include_tasks: env_setup.yml
Expand All @@ -24,4 +22,4 @@

always:
- include_tasks: env_cleanup.yml
when: aws_cleanup
when: aws_cleanup
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
termination_protection: true
instance_type: t2.micro
state: running
wait: yes
<<: *aws_connection_info
register: in_test_vpc

Expand All @@ -39,6 +40,7 @@
ec2_instance_info:
filters:
"tag:Name": "{{ resource_prefix }}-test-protected-instance-in-vpc"
"instance-state-name": "running"
<<: *aws_connection_info
register: presented_instance_fact

Expand Down

0 comments on commit 7ec3119

Please sign in to comment.