Ensure only running instance facts are retrieved to match the following 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
This commit is contained in:
s-hertel 2019-07-02 09:17:18 -04:00 committed by Sloane Hertel
parent a6d757e074
commit 7ec31194a5
4 changed files with 6 additions and 5 deletions

View file

@ -1,2 +1,3 @@
cloud/aws cloud/aws
shippable/aws/group2 shippable/aws/group2
unstable

View file

@ -50,7 +50,7 @@
image_id: "{{ ec2_ami_image[aws_region] }}" image_id: "{{ ec2_ami_image[aws_region] }}"
security_groups: "{{ sg.group_id }}" security_groups: "{{ sg.group_id }}"
instance_type: t2.micro instance_type: t2.micro
instance_role: "{{ iam_role.arn }}" instance_role: "{{ iam_role.arn.replace(':role/', ':instance-profile/') }}"
<<: *aws_connection_info <<: *aws_connection_info
check_mode: yes check_mode: yes
@ -80,7 +80,7 @@
image_id: "{{ ec2_ami_image[aws_region] }}" image_id: "{{ ec2_ami_image[aws_region] }}"
security_groups: "{{ sg.group_id }}" security_groups: "{{ sg.group_id }}"
instance_type: t2.micro instance_type: t2.micro
instance_role: "{{ iam_role_2.arn }}" instance_role: "{{ iam_role_2.arn.replace(':role/', ':instance-profile/') }}"
<<: *aws_connection_info <<: *aws_connection_info
register: instance_with_updated_role register: instance_with_updated_role
until: instance_with_updated_role is not failed until: instance_with_updated_role is not failed

View file

@ -6,8 +6,6 @@
# - EC2_REGION -> AWS_REGION # - EC2_REGION -> AWS_REGION
# #
# - include: ../../../../../setup_ec2/tasks/common.yml module_name: ec2_instance
- block: - block:
- include_tasks: env_setup.yml - include_tasks: env_setup.yml
@ -24,4 +22,4 @@
always: always:
- include_tasks: env_cleanup.yml - include_tasks: env_cleanup.yml
when: aws_cleanup when: aws_cleanup

View file

@ -19,6 +19,7 @@
termination_protection: true termination_protection: true
instance_type: t2.micro instance_type: t2.micro
state: running state: running
wait: yes
<<: *aws_connection_info <<: *aws_connection_info
register: in_test_vpc register: in_test_vpc
@ -39,6 +40,7 @@
ec2_instance_info: ec2_instance_info:
filters: filters:
"tag:Name": "{{ resource_prefix }}-test-protected-instance-in-vpc" "tag:Name": "{{ resource_prefix }}-test-protected-instance-in-vpc"
"instance-state-name": "running"
<<: *aws_connection_info <<: *aws_connection_info
register: presented_instance_fact register: presented_instance_fact