forked from redhat-cop/agnosticd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathec2_instances_start.yaml
32 lines (30 loc) · 1.09 KB
/
ec2_instances_start.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
---
- name: Get all EC2 instances
amazon.aws.ec2_instance_info:
filters:
"tag:guid": "{{ guid }}"
"tag:env_type": "{{ env_type }}"
instance-state-name: stopped
register: r_stopped_instances
# Wk: Don't wait for instances to be running. Otherwise this is
# a very sequential task. Just start the instances.
# The next task will wait until all instances are running - but
# this happens now in parallel instead of sequentially.
- name: Ensure EC2 instances are running
when: r_stopped_instances.instances | length > 0
amazon.aws.ec2_instance:
instance_ids: "{{ item.instance_id }}"
state: started
wait: false
loop: "{{ r_stopped_instances.instances }}"
- name: Wait until all EC2 instances are running
when: r_stopped_instances.instances | length > 0
amazon.aws.ec2_instance_info:
filters:
"tag:guid": "{{ guid }}"
"tag:env_type": "{{ env_type }}"
instance-state-name: running
register: r_running_instances
until: r_running_instances.instances | length | int >= r_stopped_instances.instances | length | int
delay: 10
retries: 60