This repository was archived by the owner on Feb 12, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbootstrap.yml
198 lines (195 loc) · 5.71 KB
/
bootstrap.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
---
- hosts: all
vars:
owner: root
is_vm: false
streams:
- url: "webcast.sermonaudio.com/sa"
key: "some-sa-key"
- url: "a.rtmp.youtube.com/live2"
key: "some-youtube-key"
tasks:
- name: Ensure directories exist
file: path={{ item.path }}
state=directory
mode={{ item.mode }}
owner={{ owner }}
group={{ owner }}
with_items:
- path: /var/www/html
mode: "0755"
- path: /var/www/live
mode: "0755"
tags:
- frontend
- name: Ensure directories exist - Alpine
file: path={{ item.path }}
state=directory
mode="{{ item.mode }}"
owner={{ owner }}
group={{ owner }}
with_items:
- path: /lib64
mode: "0755"
when: ansible_os_family == "Alpine"
- name: Install packages - Debian
apt:
pkg:
- build-essential
- unzip
update_cache: yes
state: present
tags:
- backend
when: ansible_os_family == 'Debian'
- name: Install packages - Alpine
command: "apk add --no-cache --virtual .build-deps alpine-sdk unzip perl linux-headers"
when: ansible_os_family == 'Alpine'
- name: Download components
get_url:
url: "{{ item.url }}"
dest: "${HOME}/{{ item.dest }}"
timeout: 300
with_items:
- dest: nginx-1.18.0.tar.gz
url: https://nginx.org/download/nginx-1.18.0.tar.gz
- dest: nginx-rtmp-module.zip
url: https://github.com/sergey-dryabzhinsky/nginx-rtmp-module/archive/dev.zip
- dest: zlib-1.2.12.tar.gz
url: http://zlib.net/zlib-1.2.12.tar.gz
- dest: pcre-8.45.tar.bz2
url: https://sourceforge.net/projects/pcre/files/pcre/8.45/pcre-8.45.tar.bz2
- dest: openssl-1.1.1k.tar.gz
url: https://www.openssl.org/source/openssl-1.1.1k.tar.gz
- dest: go1.14.4.linux-amd64.tar.gz
url: https://dl.google.com/go/go1.14.4.linux-amd64.tar.gz
- dest: supervisord_0.7.3_Linux_64-bit.tar.gz
url: https://github.com/ochinchina/supervisord/releases/download/v0.7.3/supervisord_0.7.3_Linux_64-bit.tar.gz
tags:
- proxy
- name: Unzip components
unarchive:
src: "${HOME}/{{ item.src }}"
dest: "{{ item.dest }}"
remote_src: yes
with_items:
- src: nginx-1.18.0.tar.gz
dest: "${HOME}"
- src: nginx-rtmp-module.zip
dest: "${HOME}"
- src: zlib-1.2.12.tar.gz
dest: "${HOME}"
- src: pcre-8.45.tar.bz2
dest: "${HOME}"
- src: openssl-1.1.1k.tar.gz
dest: "${HOME}"
- src: go1.14.4.linux-amd64.tar.gz
dest: /usr/local
- src: supervisord_0.7.3_Linux_64-bit.tar.gz
dest: /usr/local/bin
tags:
- proxy
- name: Copy files over
copy:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
force: yes
owner: "{{ owner }}"
group: "{{ owner }}"
with_items:
- src: ../client/index.html
dest: /var/www/html/index.html
- src: ../client/app.js
dest: /var/www/html/app.js
- src: ../client/app.css
dest: /var/www/html/app.css
- src: ../client/app.css
dest: /var/www/html/app.css
- src: ./supervisor.conf
dest: /etc/supervisor.conf
tags:
- frontend
- name: Copy over go files
copy: src="{{ item }}"
dest="${HOME}/"
with_fileglob:
- "../*.go"
- "../*.mod"
- "../*.sum"
tags:
- backend
- name: Symlink libc - Alpine
file: src="/lib/libc.musl-x86_64.so.1"
dest="/lib64/ld-linux-x86-64.so.2"
state=link
tags:
- backend
when: ansible_os_family == "Alpine"
- name: Compile backend
command: "/usr/local/go/bin/go build -o /usr/bin/streaming-server"
args:
chdir: "${HOME}"
become: true
tags:
- backend
- name: Configure nginx
command: |
./configure --with-http_ssl_module --with-zlib=../zlib-1.2.12 --add-module=../nginx-rtmp-module-dev --with-pcre=../pcre-8.45 --with-openssl=../openssl-1.1.1k
args:
chdir: "${HOME}/nginx-1.18.0"
tags:
- proxy
- name: Build nginx
make:
chdir: "${HOME}/nginx-1.18.0"
tags:
- proxy
- name: Install nginx
make:
chdir: "${HOME}/nginx-1.18.0"
target: install
become: yes
tags:
- proxy
notify: Remove build-deps
- name: Send our config over
template:
src: nginx.conf.j2
dest: /usr/local/nginx/conf/nginx.conf
force: yes
tags:
- proxy
- name: Rename supervisord folder
command: mv /usr/local/bin//supervisord_0.7.3_Linux_64-bit /usr/local/bin/supervisord
- name: Start server
command: "/usr/local/bin/supervisord/supervisord_static -c /etc/supervisor.conf -d"
become: true
when: is_vm is true
tags:
- supervisor
- name: Cleanup extra stuff
assert: { that: true, quiet: true }
changed_when: true
when: is_vm is false
notify: 'Cleanup'
handlers:
- name: Remove golang
file:
path: "{{ item }}"
state: absent
listen: 'Cleanup'
with_items:
- /usr/local/bin/go
- /usr/local/bin/gofmt
- /usr/local/go
- name: Remove build-deps
command: "apk del .build-deps"
listen: 'Cleanup'
- name: Remove tmp files
file: "path={{ item.path }} state={{ item.state }}"
listen: 'Cleanup'
with_items:
- path: /root/
state: absent
- path: /root/
state: directory