From b7360b06fc6e818047c6e91a95074b5c5e008499 Mon Sep 17 00:00:00 2001 From: Will Hall Date: Wed, 1 Apr 2020 19:22:42 +0100 Subject: [PATCH] Added media-server deployment --- group_vars/media/vars | 2 ++ hosts.yml | 3 +++ playbook.yml | 3 +++ roles/media_server/handlers/main.yml | 11 ++++++++ roles/media_server/meta/main.yml | 3 +++ roles/media_server/tasks/main.yml | 26 +++++++++++++++++++ .../templates/media_server.env.j2 | 3 +++ 7 files changed, 51 insertions(+) create mode 100644 group_vars/media/vars create mode 100644 roles/media_server/handlers/main.yml create mode 100644 roles/media_server/meta/main.yml create mode 100644 roles/media_server/tasks/main.yml create mode 100644 roles/media_server/templates/media_server.env.j2 diff --git a/group_vars/media/vars b/group_vars/media/vars new file mode 100644 index 0000000..2d68e8f --- /dev/null +++ b/group_vars/media/vars @@ -0,0 +1,2 @@ +--- +upload_user: upload_user \ No newline at end of file diff --git a/hosts.yml b/hosts.yml index 5ca616a..3bc69dc 100644 --- a/hosts.yml +++ b/hosts.yml @@ -28,3 +28,6 @@ all: screen2.medianet: screen3.medianet: screen4.medianet: + media: + hosts: + media2.medianet: diff --git a/playbook.yml b/playbook.yml index f53d4d6..fe58c90 100644 --- a/playbook.yml +++ b/playbook.yml @@ -11,6 +11,9 @@ - hosts: modular_status roles: - status_server +- hosts: media + roles: + - media_server - hosts: all roles: - common diff --git a/roles/media_server/handlers/main.yml b/roles/media_server/handlers/main.yml new file mode 100644 index 0000000..ef94753 --- /dev/null +++ b/roles/media_server/handlers/main.yml @@ -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/www/media-server/media/static,target=/www/media/static" diff --git a/roles/media_server/meta/main.yml b/roles/media_server/meta/main.yml new file mode 100644 index 0000000..f161d0d --- /dev/null +++ b/roles/media_server/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - role: geerlingguy.docker diff --git a/roles/media_server/tasks/main.yml b/roles/media_server/tasks/main.yml new file mode 100644 index 0000000..1826a91 --- /dev/null +++ b/roles/media_server/tasks/main.yml @@ -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/www/media-server/media/static + state: directory + +- 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 diff --git a/roles/media_server/templates/media_server.env.j2 b/roles/media_server/templates/media_server.env.j2 new file mode 100644 index 0000000..fe61217 --- /dev/null +++ b/roles/media_server/templates/media_server.env.j2 @@ -0,0 +1,3 @@ +UPLOAD_USER={{ upload_user }} +UPLOAD_PASSWORD={{ vault_upload_password }} +DISCOGS_API_KEY={{ vault_discogs_api_key}} \ No newline at end of file