Debian Codegraph @

ansible_collections/amazon/aws/tests/integration/targets/ec2_instance_uptime/tasks/main.yml

raw
1 ---
2 - module_defaults:
3 group/aws:
4 access_key: "{{ aws_access_key }}"
5 secret_key: "{{ aws_secret_key }}"
6 session_token: "{{ security_token | default(omit) }}"
7 region: "{{ aws_region }}"
8 block:
9 - name: Create t3.nano instance
10 amazon.aws.ec2_instance:
11 state: running
12 name: "{{ resource_prefix }}-test-uptime"
13 region: "{{ aws_region }}"
14 image_id: "{{ ec2_ami_id }}"
15 tags:
16 TestId: "{{ ec2_instance_tag_testid }}"
17 vpc_subnet_id: "{{ testing_subnet_a.subnet.id }}"
18 instance_type: t3.nano
19 wait: true
20
21 - name: Check ec2 instance
22 amazon.aws.ec2_instance_info:
23 filters:
24 tag:Name: "{{ resource_prefix }}-test-uptime"
25 instance-state-name: [running]
26 register: instance_facts
27
28 - name: Confirm existence of instance id.
29 ansible.builtin.assert:
30 that:
31 - instance_facts.instances | length == 1
32
33 - name: Check using uptime 100 hours - should find nothing
34 amazon.aws.ec2_instance_info:
35 region: "{{ aws_region }}"
36 uptime: 6000
37 filters:
38 instance-state-name: [running]
39 tag:Name: "{{ resource_prefix }}-test-uptime"
40 register: instance_facts
41
42 - name: Confirm there is no running instance
43 ansible.builtin.assert:
44 that:
45 - instance_facts.instances | length == 0
46
47 - name: Sleep for 61 seconds and continue with play
48 ansible.builtin.wait_for:
49 timeout: 61
50 delegate_to: localhost
51
52 - name: Check using uptime 1 minute
53 amazon.aws.ec2_instance_info:
54 region: "{{ aws_region }}"
55 uptime: 1
56 filters:
57 instance-state-name: [running]
58 tag:Name: "{{ resource_prefix }}-test-uptime"
59 register: instance_facts
60
61 - name: Confirm there is one running instance
62 ansible.builtin.assert:
63 that:
64 - instance_facts.instances | length == 1