commit f4310c2e7d390f8feb6e8b63994e92ad2b88bf47 Author: Lukáš Kucharczyk Date: Fri Apr 23 01:04:44 2021 +0200 Initial commit with working nginx and jellyfin diff --git a/group_vars/all b/group_vars/all new file mode 100644 index 0000000..bef60dc --- /dev/null +++ b/group_vars/all @@ -0,0 +1,9 @@ +base_domain: "homelab.cz" +data_folder: "{{ playbook_dir }}/docker-data" +nginx_confd_folder: "{{ data_folder }}/nginx/conf.d" +puid: "1000" +pgid: "1000" +tz: "Europe/Prague" +media: + tv: "{{ data_folder }}/media/tv" + movies: "{{ data_folder }}/media/movies" \ No newline at end of file diff --git a/hosts.localhost b/hosts.localhost new file mode 100644 index 0000000..9b420ce --- /dev/null +++ b/hosts.localhost @@ -0,0 +1 @@ +localhost ansible_conection=local diff --git a/playbook.yml b/playbook.yml new file mode 100644 index 0000000..725594f --- /dev/null +++ b/playbook.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + roles: + - nginx + - jellyfin diff --git a/roles/jellyfin/tasks/main.yml b/roles/jellyfin/tasks/main.yml new file mode 100644 index 0000000..134ed27 --- /dev/null +++ b/roles/jellyfin/tasks/main.yml @@ -0,0 +1,25 @@ +- name: run jellyfin container + docker_container: + name: 'jellyfin' + image: linuxserver/jellyfin + volumes: + - "{{ data_folder }}/jellyfin:/config" + - "{{ media.tv }}:/data/tvshows" + - "{{ media.movies }}:/data/movies" + ports: + - "8096:8096" + - "8920:8920" + - "7359:7359/udp" + - "1900:1900/udp" + env: + PUID={{ puid }} + PGID={{ pgid }} + TZ={{ tz }} + devices: + - /dev/dri:/dev/dri + state: started +- name: copy jellyfin config to nginx + template: + src: jellyfin.conf + dest: "{{ nginx_confd_folder }}" + notify: reload nginx \ No newline at end of file diff --git a/roles/jellyfin/templates/jellyfin.conf b/roles/jellyfin/templates/jellyfin.conf new file mode 100644 index 0000000..acbd4e5 --- /dev/null +++ b/roles/jellyfin/templates/jellyfin.conf @@ -0,0 +1,11 @@ +server { + listen 80; + server_name "jellyfin.{{ base_domain }}"; + set $jellyfin 192.168.0.107; + #resolver 127.0.0.1 valid=30; + + location / { + proxy_pass http://$jellyfin:8096; + proxy_set_header Host $host; + } +} \ No newline at end of file diff --git a/roles/nginx/handlers/main.yml b/roles/nginx/handlers/main.yml new file mode 100644 index 0000000..6dafd34 --- /dev/null +++ b/roles/nginx/handlers/main.yml @@ -0,0 +1,2 @@ +- name: reload nginx + command: docker restart nginx \ No newline at end of file diff --git a/roles/nginx/tasks/main.yml b/roles/nginx/tasks/main.yml new file mode 100644 index 0000000..219470c --- /dev/null +++ b/roles/nginx/tasks/main.yml @@ -0,0 +1,12 @@ +- name: run nginx container + docker_container: + name: 'nginx' + image: nginx + volumes: + - "{{ nginx_confd_folder }}:/etc/nginx/conf.d" + ports: + - "80:80" + env: + NGINX_HOST: "{{ base_domain }}" + NGINX_PORT: '80' + state: started