commit | author | age
|
699c28
|
1 |
--- |
GC |
2 |
- environment: |
|
3 |
AWS_ACCESS_KEY_ID: "{{aws_access_key_id}}" |
|
4 |
AWS_SECRET_ACCESS_KEY: "{{aws_secret_access_key}}" |
|
5 |
AWS_DEFAULT_REGION: "{{aws_region_final|d(aws_region)}}" |
|
6 |
block: |
|
7 |
- when: ACTION == 'stop' |
|
8 |
name: Stop instances by (guid,env_type) tags |
|
9 |
ec2_instance: |
|
10 |
state: stopped |
|
11 |
wait: no |
|
12 |
filters: |
|
13 |
"tag:guid": "{{ guid }}" |
|
14 |
# TODO: uncomment this after a few weeks |
|
15 |
#"tag:env_type": "{{ env_type }}" |
|
16 |
|
|
17 |
- when: ACTION == 'start' |
|
18 |
name: Start instances by (guid, env_type) tags |
|
19 |
ec2_instance: |
|
20 |
state: started |
|
21 |
wait: no |
|
22 |
filters: |
|
23 |
"tag:guid": "{{ guid }}" |
|
24 |
# TODO: uncomment this after a few weeks |
|
25 |
#"tag:env_type": "{{ env_type }}" |
|
26 |
|
|
27 |
- when: ACTION == 'status' |
|
28 |
block: |
|
29 |
- name: Get EC2 facts using (guid, env_type) tag |
|
30 |
ec2_instance_facts: |
|
31 |
filters: |
|
32 |
"tag:guid": "{{ guid }}" |
|
33 |
# TODO: uncomment this after a few weeks |
|
34 |
#"tag:env_type": "{{ env_type }}" |
|
35 |
register: r_instances |
|
36 |
|
|
37 |
- name: Print status information to a file |
|
38 |
copy: |
|
39 |
dest: "{{ output_dir }}/status.txt" |
|
40 |
content: |- |
|
41 |
{{ "%-60s" | format('Instance') }} State Type |
|
42 |
---------------------------------------------------------------- |
|
43 |
{% for instance in r_instances.instances %} |
|
44 |
{{ "%-60s" | format(instance.tags.Name) }} {{ "%-10s" | format(instance.state.name) }} {{ instance.instance_type }} |
|
45 |
{% endfor %} |