forked from janowicz/sample-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbake.yml
More file actions
103 lines (97 loc) · 2.66 KB
/
Copy pathbake.yml
File metadata and controls
103 lines (97 loc) · 2.66 KB
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
100
101
102
103
# Playbook to bake image
- hosts: 127.0.0.1
connection: local
tasks:
- name: Install latest version of nginx
apt:
name: nginx
state: latest
- name: Add nginx config for app
become: yes
blockinfile:
dest: /etc/nginx/sites-enabled/sample-app
create: yes
block: |
server {
listen 80 default_server;
listen [::]:80 default_server;
location / {
proxy_pass http://127.0.0.1:8081;
}
}
- name: Disable default nginx site
file:
path: "/etc/nginx/sites-enabled/default"
state: absent
- name: Download golang
become: yes
get_url:
url: "https://storage.googleapis.com/golang/go1.8.1.linux-amd64.tar.gz"
dest: "/root/go.tar.gz"
sha256sum: "a579ab19d5237e263254f1eac5352efcf1d70b9dacadb6d6bb12b0911ede8994"
- name: Unarchive golang to installation directory
become: yes
unarchive:
src: "/root/go.tar.gz"
dest: "/usr/local"
owner: root
group: root
copy: no
creates: "/usr/local/go"
- name: Add go to PATH
become: yes
lineinfile:
dest: /etc/profile
line: "export PATH=$PATH:/usr/local/go/bin"
- name: Install app dependencies
become: yes
shell: GOPATH=/opt/go /usr/local/go/bin/go get ./...
args:
chdir: /opt/go/src/deploy
- name: Compile app dependencies
become: yes
shell: GOPATH=/opt/go /usr/local/go/bin/go install
args:
chdir: /opt/go/src/deploy
creates: /opt/go/bin/deploy
- name: Add the systemd service file for the backend
become: yes
blockinfile:
dest: /etc/systemd/system/sample-app-backend.service
create: yes
block: |
[Unit]
Description=Sample App Backend
[Service]
Restart=always
TimeoutStartSec=0
RestartSec=3
WorkingDirectory=/opt/go/src/deploy
ExecStart=/opt/go/bin/deploy
[Install]
WantedBy=multi-user.target
- name: Add the systemd service file for the frontend
become: yes
blockinfile:
dest: /etc/systemd/system/sample-app-frontend.service
create: yes
block: |
[Unit]
Description=Sample App Frontend
[Service]
Restart=always
TimeoutStartSec=0
RestartSec=3
WorkingDirectory=/opt/go/src/deploy
ExecStart=/opt/go/bin/deploy -port 8081 -frontend -backend-service http://127.0.0.1:8080
[Install]
WantedBy=multi-user.target
- name: Enable the services
systemd:
name: "{{item}}"
daemon_reload: yes
enabled: True
state: stopped
with_items:
- sample-app-backend
- sample-app-frontend