forked from lobsterdore/aws-ha-deployment-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprovision.yml
99 lines (86 loc) · 2.64 KB
/
provision.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
---
- hosts: all
tasks:
- name: Install essential packages
sudo: yes
apt:
update_cache: yes
name: "{{ item }}"
with_items:
- golang
- vim
- build-essential
- git
- unzip
- supervisor
- python-setuptools
- name: Download AWS cfn-bootstrap
sudo: yes
get_url:
url: https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gz
dest: /usr/local/src/aws-cfn-bootstrap-latest.tar.gz
- name: Prepare AWS cfn-bootstrap folder
sudo: yes
file:
name: /usr/local/src/aws-cfn-bootstrap-latest
state: directory
- name: Extract AWS cfn-bootstrap
sudo: yes
shell: tar xvfz /usr/local/src/aws-cfn-bootstrap-latest.tar.gz --strip-components=1 -C /usr/local/src/aws-cfn-bootstrap-latest
args:
creates: /usr/local/src/aws-cfn-bootstrap-latest/setup.py
- name: Install AWS cfn-bootstrap
sudo: yes
shell: easy_install /usr/local/src/aws-cfn-bootstrap-latest
args:
creates: /usr/local/bin/cfn-init
- name: Ensure hello-app user
sudo: yes
user:
name: hello-app
shell: /bin/bash
- name: Ensure hello-app directory
sudo: yes
file:
path: /home/hello-app/go/src/github.com/lobsterdore
state: directory
recurse: yes
owner: hello-app
group: hello-app
- name: Ensure hello-app log directory
sudo: yes
file:
path: /home/hello-app/logs
state: directory
recurse: yes
owner: hello-app
group: hello-app
- name: Copy hello-app from /tmp
sudo: yes
shell: "cp -R /tmp/hello-app/ /home/hello-app/go/src/github.com/lobsterdore/; chown -R hello-app:hello-app /home/hello-app/go/src/github.com/lobsterdore/"
args:
creates: /home/hello-app/go/src/github.com/lobsterdore/hello-app
- name: Build hello-app
sudo: yes
sudo_user: hello-app
command: "make build"
environment:
GOPATH: /home/hello-app/go
args:
chdir: /home/hello-app/go/src/github.com/lobsterdore/hello-app
creates: /home/hello-app/go/bin/hello-app
- name: Create supervisor config
sudo: yes
shell: "cp /tmp/hello-app/supervisor.conf /etc/supervisor/conf.d/hello-app.conf"
args:
creates: /etc/supervisor/conf.d/hello-app.conf
notify:
- Reread supervisor
- Update supervisor
handlers:
- name: Reread supervisor
sudo: yes
command: supervisorctl reread
- name: Update supervisor
sudo: yes
command: supervisorctl update