Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added media-server deployment #1

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
7dba9be
added digiplay mount role
connor642 Mar 29, 2020
68c2653
added raw.medianet to hosts
connor642 Mar 29, 2020
8d1a71f
fix option quotes
connor642 Mar 29, 2020
2c43975
forgot to make tasks a list
connor642 Mar 29, 2020
77dcd98
added readme for mount role, added dest variable
connor642 Mar 29, 2020
d8e402b
improved digiplay mount readme
connor642 Mar 29, 2020
d22cbe1
added readme for autologin_user, renamed user var and added default v…
connor642 Mar 29, 2020
e7f41db
added status server role
connor642 Mar 29, 2020
e827a1e
added modular status hosts
connor642 Mar 29, 2020
82f0382
ensure docker pip installed
connor642 Mar 29, 2020
f6a1d56
make sure pip is installed
connor642 Mar 29, 2020
23af5e9
fixed my stupid typo
connor642 Mar 29, 2020
121a9c3
fix port forwarding
connor642 Mar 29, 2020
8506d51
added websockify install
connor642 Mar 29, 2020
480fa50
added websockify as docker
connor642 Mar 30, 2020
bb715b9
added args to websockify docker
connor642 Mar 30, 2020
d31f8df
fix typo
connor642 Mar 30, 2020
3bd2097
fix another typo
connor642 Mar 30, 2020
aa9043b
added pulling new containers for modular-status
connor642 Mar 30, 2020
b7360b0
Added media-server deployment
Apr 1, 2020
a449915
Fixed small typo
Apr 1, 2020
c5318f8
Made local media path more sensible.
Apr 1, 2020
4c4cba9
Update media directory ensure task.
Apr 1, 2020
93efa2d
Notify start media handler if host dir changes.
Apr 1, 2020
00ddfa4
added website server role
connor642 Apr 4, 2020
38201ac
added pip install and docker compose install
connor642 Apr 4, 2020
195bc9e
Update plumbus.conf.j2
connor642 Apr 4, 2020
ab41985
Update main.yml
connor642 Apr 4, 2020
a54c98e
missed var prefix
connor642 Apr 4, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions group_vars/media/vars
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
upload_user: upload_user
14 changes: 14 additions & 0 deletions group_vars/modular_status/vars
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
status_server_websockify:
- server: onair1.medianet
port: 5900
token: onair1
- server: onair2.medianet
port: 5900
token: onair2
- server: playout1.medianet
port: 5900
token: playout1
- server: playout2.medianet
port: 5900
token: playout2
2 changes: 1 addition & 1 deletion group_vars/onair
Original file line number Diff line number Diff line change
@@ -1 +1 @@
autologin_user: raw
autologin_user_username: raw
1 change: 0 additions & 1 deletion group_vars/playout

This file was deleted.

2 changes: 2 additions & 0 deletions group_vars/website/vars
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
website_server_graphql_host: https://graphql.radio.warwick.ac.uk/graphql
docker_install_compose: true
1 change: 1 addition & 0 deletions host_vars/digiplay2.medianet/vars
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
digiplay_mount_options: defaults
13 changes: 12 additions & 1 deletion hosts.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
---
all:
hosts:
raw.medianet:
fs0.medianet:
dps0.medianet:
bak0.medianet:
children:
digiplay2.medianet:
children:
playout:
hosts:
playout1.medianet:
Expand All @@ -17,9 +19,18 @@ all:
hosts:
log1.medianet:
log2.medianet:
modular_status:
hosts:
status.medianet:
screen:
hosts:
screen1.medianet:
screen2.medianet:
screen3.medianet:
screen4.medianet:
website:
hosts:
website.medianet:
media:
hosts:
media2.medianet:
12 changes: 12 additions & 0 deletions playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@
- hosts: onair
roles:
- onair
- hosts: playout:digiplay2.medianet:fs0.medianet:raw.medianet
roles:
- digiplay_mount
- hosts: modular_status
roles:
- status_server
- hosts: media
roles:
- media_server
- hosts: website
roles:
- website_server
- hosts: all
roles:
- common
4 changes: 4 additions & 0 deletions requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
roles:
- name: geerlingguy.docker
version: 2.7.0
13 changes: 13 additions & 0 deletions roles/autologin_user/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Autologin User

This role is designed for debian systems. When applied this role will enable automatic terminal login for the specified user on system boot.

## Role Variables

Variable | Required | Default | Choices | Comments
--- | --- | --- | --- | --- |
autlogin_user_username | no | root | any user | user must exist

## Dependencies

None
1 change: 1 addition & 0 deletions roles/autologin_user/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
autologin_user_username: root
2 changes: 1 addition & 1 deletion roles/autologin_user/templates/override.conf.j2
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[Service]
ExecStart=
ExecStart=-/sbin/agetty --autologin {{ autologin_user }} --noclear %I 38400 linux
ExecStart=-/sbin/agetty --autologin {{ autologin_user_username }} --noclear %I 38400 linux
14 changes: 14 additions & 0 deletions roles/digiplay_mount/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Digiplay Mount

The role sets up an NFS mount of the music file share that are exported on `dps0.medianet`.

## Role Variables

Variable | Required | Default | Choices | Comments
--- | --- | --- | --- | --- |
digiplay_mount_options | no | ro,defaults | any fstab options | see `man fstab`
digiplay_mount_dest | no | /mnt/dps0-0 | any valid path | destination of the mount

## Dependencies

None
2 changes: 2 additions & 0 deletions roles/digiplay_mount/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
digiplay_mount_options: ro,defaults
digiplay_mount_dest: /mnt/dps0-0
12 changes: 12 additions & 0 deletions roles/digiplay_mount/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
- name: ensure nfs-common is installed
apt:
name: nfs-common
state: latest
- name: ensure dps0 is mounted
mount:
path: "{{ digiplay_mount_dest }}"
src: dps0.medianet:/export/dps0-0
opts: "{{ digiplay_mount_options }}"
fstype: nfs
state: mounted
11 changes: 11 additions & 0 deletions roles/media_server/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
- name: start media-server container
docker_container:
name: media
image: "raw1251am/media-server:latest"
state: started
env_file: /etc/media-server.env
restart_policy: always
published_ports:
- "8080:8080"
mounts:
- "type=bind,source=/var/media/static,target=/www/media/static"
3 changes: 3 additions & 0 deletions roles/media_server/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
dependencies:
- role: geerlingguy.docker
26 changes: 26 additions & 0 deletions roles/media_server/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
- name: ensure pip is installed
apt:
name: python-pip
state: latest
- name: ensure docker pip installed
pip:
name: docker
state: latest

- name: ensure static media directory exists
file:
path: /var/media/static
state: directory
notify: start media-server container
- name: ensure media-server env file exists
template:
src: media_server.env.j2
dest: /etc/media-server.env
notify: start media-server container
- name: ensure media-server image is latest
docker_image:
name: "raw1251am/media-server:latest"
source: pull
force_source: yes
notify: start media-server container
3 changes: 3 additions & 0 deletions roles/media_server/templates/media_server.env.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
UPLOAD_USER={{ upload_user }}
UPLOAD_PASSWORD={{ vault_upload_password }}
DISCOGS_API_KEY={{ vault_discogs_api_key }}
20 changes: 20 additions & 0 deletions roles/status_server/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
- name: start modular-status container
docker_container:
name: modular_status
image: "raw1251am/modular-status:latest"
state: started
env_file: /etc/modular_status.env
restart_policy: always
published_ports:
- "8080:8080"
- name: start websockify container
docker_container:
name: websockify
image: "efrecon/websockify:latest"
command: ["80", "--token-plugin", "TokenFile", "--token-source", "/opt/websockify/config"]
state: started
restart_policy: always
published_ports:
- "3000:80"
volumes:
- /etc/websockify.config:/opt/websockify/config
3 changes: 3 additions & 0 deletions roles/status_server/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
dependencies:
- role: geerlingguy.docker
33 changes: 33 additions & 0 deletions roles/status_server/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
- name: ensure pip is installed
apt:
name: python-pip
state: latest
- name: ensure docker pip installed
pip:
name: docker
state: latest

- name: ensure modular-status env file exists
template:
src: modular_status.env.j2
dest: /etc/modular_status.env
notify: start modular-status container
- name: ensure modular-status image is latest
docker_image:
name: "raw1251am/modular-status:latest"
source: pull
force_source: yes
notify: start modular-status container

- name: ensure websockify config updated
template:
src: websockify.config.j2
dest: /etc/websockify.config
notify: start websockify container
- name: ensure websockify image is latest
docker_image:
name: "efrecon/websockify:latest"
source: pull
force_source: yes
notify: start websockify container
1 change: 1 addition & 0 deletions roles/status_server/templates/modular_status.env.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
RAW_API_KEY={{ vault_modular_status_digiplay_api_key }}
3 changes: 3 additions & 0 deletions roles/status_server/templates/websockify.config.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% for server in status_server_websockify %}
{{ server["token"] }}: {{ server["server"] }}:{{ server["port"] }}
{% endfor %}
22 changes: 22 additions & 0 deletions roles/website_server/files/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: "3"
services:
pages:
image: registry.gitlab.com/radiowarwick/raw-pages:latest
ports:
- "8000:8000"
environment:
- PLUMBUS_URL=http://plumbus:3000
env_file: /website/pages.conf
depends_on:
- plumbus
plumbus:
image: registry.gitlab.com/radiowarwick/plumbus:latest
ports:
- "3000:3000"
environment:
- REDIS_HOST=redis
env_file: /website/plumbus.conf
depends_on:
- redis
redis:
image: redis:alpine
5 changes: 5 additions & 0 deletions roles/website_server/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
- name: start website docker compose
docker_compose:
project_src: /website
pull: yes
3 changes: 3 additions & 0 deletions roles/website_server/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
dependencies:
- role: geerlingguy.docker
29 changes: 29 additions & 0 deletions roles/website_server/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
- name: ensure pip is installed
apt:
name: python-pip
state: latest
- name: ensure docker pip installed
pip:
name: docker
state: latest

- name: ensure /website exists
file:
path: /website
state: directory
- name: ensure /website/pages.conf environment file exists
template:
src: pages.conf.j2
dest: /website/pages.conf
notify: start website docker compose
- name: ensure /website/plumbus.conf environment file exists
template:
src: plumbus.conf.j2
dest: /website/plumbus.conf
notify: start website docker compose
- name: ensure /website/docker-compose.yml is in place
copy:
src: docker-compose.yml
dest: /website/docker-compose.yml
notify: start website docker compose
1 change: 1 addition & 0 deletions roles/website_server/templates/pages.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GRAPHQL_HOST={{ website_server_graphql_host }}
6 changes: 6 additions & 0 deletions roles/website_server/templates/plumbus.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
RAW_DB_STRING={{ vault_website_server_raw_db_string }}
DPS_DB_STRING={{ vault_website_server_dps_db_string }}
YOUTUBE_API_KEY={{ vault_website_server_youtube_api_key }}
LASTFM_API_KEY={{ vault_website_server_lastfm_api_key }}
RECAPTCHA_SECRET={{ vault_website_server_recaptcha_secret }}
RAW_API_KEY={{ vault_website_server_raw_api_key }}