forked from redhat-cop/agnosticd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lifecycle.yml
42 lines (37 loc) · 1.14 KB
/
lifecycle.yml
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
33
34
35
36
37
38
39
40
41
42
---
# This file is the default playbook for common actions.
# You should implement those actions in your config if you
# need a specific process.
- import_playbook: setup_runtime.yml
- name: Run stop/start/status/... actions
hosts: localhost
connection: local
gather_facts: False
become: no
tasks:
- fail:
msg: "project_tag is not defined"
when: project_tag is not defined or project_tag == ''
- fail:
msg: "ACTION is not defined"
when: ACTION is not defined
- when: cloud_provider == 'ec2'
environment:
AWS_ACCESS_KEY_ID: "{{aws_access_key_id}}"
AWS_SECRET_ACCESS_KEY: "{{aws_secret_access_key}}"
AWS_DEFAULT_REGION: "{{aws_region_final|d(aws_region)}}"
block:
- when: ACTION == 'stop'
name: Stop instances
ec2_instance:
state: stopped
wait: no
filters:
"tag:Project": "{{project_tag}}"
- when: ACTION == 'start'
name: Start instances
ec2_instance:
state: started
wait: no
filters:
"tag:Project": "{{project_tag}}"