aboutsummaryrefslogtreecommitdiff
path: root/roles/services/containers/invidious
diff options
context:
space:
mode:
Diffstat (limited to 'roles/services/containers/invidious')
-rw-r--r--roles/services/containers/invidious/handlers/main.yml29
-rw-r--r--roles/services/containers/invidious/tasks/main.yml124
2 files changed, 153 insertions, 0 deletions
diff --git a/roles/services/containers/invidious/handlers/main.yml b/roles/services/containers/invidious/handlers/main.yml
new file mode 100644
index 0000000..a3a5d0b
--- /dev/null
+++ b/roles/services/containers/invidious/handlers/main.yml
@@ -0,0 +1,29 @@
1- name: login to docker registry
2 become: yes
3 become_user: "{{ docker_username }}"
4 environment:
5 XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}"
6 docker_login:
7 docker_host: "unix://run/user/{{ docker_uid }}/docker.sock"
8 registry_url: "{{ docker_registry_url }}"
9 username: "{{ docker_registry_username }}"
10 password: "{{ docker_registry_password }}"
11
12- name: build invidious image
13 become: yes
14 become_user: "{{ docker_username }}"
15 environment:
16 XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}"
17 docker_image:
18 name: "{{ docker_registry_url }}/{{ docker_registry_username }}/invidious:latest"
19 docker_host: "unix://run/user/{{ docker_uid }}/docker.sock"
20 build:
21 path: /srv/docker/invidious/src
22 dockerfile: docker/Dockerfile
23 source: build
24 push: yes
25
26- name: restart nginx
27 service:
28 name: nginx
29 state: restarted
diff --git a/roles/services/containers/invidious/tasks/main.yml b/roles/services/containers/invidious/tasks/main.yml
new file mode 100644
index 0000000..6bff0e2
--- /dev/null
+++ b/roles/services/containers/invidious/tasks/main.yml
@@ -0,0 +1,124 @@
1- name: set image fact
2 set_fact:
3 image: gitea.chudnick.com/sam/invidious:latest
4
5- name: set other facts
6 vars:
7 array: "{{ image.split('/', 1) }}"
8 set_fact:
9 repo_tag: "{{ array.1 }}"
10 custom_registry: "{{ docker_registry_url + '/' + docker_registry_username }}"
11
12- name: create invidious directory
13 file:
14 path: "{{ docker_home }}/invidious"
15 state: directory
16 owner: "{{ docker_username }}"
17 group: "{{ docker_username }}"
18 mode: '0755'
19
20- name: create postgres data directory
21 file:
22 path: "{{ docker_home }}/invidious/data"
23 state: directory
24 owner: "{{ docker_username }}"
25 group: "{{ docker_username }}"
26 mode: '0755'
27
28- name: clone invidious repo
29 become: yes
30 become_user: "{{ docker_username }}"
31 notify:
32 - login to docker registry
33 - build invidious image
34 git:
35 repo: "{{ invidious_repo }}"
36 dest: "{{ docker_home }}/invidious/src"
37 version: "master"
38
39- meta: flush_handlers
40
41- name: create invidious docker network
42 become: yes
43 become_user: "{{ docker_username }}"
44 docker_network:
45 name: "{{ invidious_network_name }}"
46 docker_host: "unix://run/user/{{ docker_uid }}/docker.sock"
47 driver: bridge
48 ipam_config:
49 - subnet: "{{ invidious_subnet }}"
50 gateway: "{{ invidious_gateway }}"
51
52- name: create and deploy invidious db
53 become: yes
54 become_user: "{{ docker_username }}"
55 environment:
56 XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}"
57 docker_container:
58 name: "invidious-db"
59 hostname: "invidious-db"
60 image: postgres:13
61 docker_host: "unix://run/user/{{ docker_uid }}/docker.sock"
62 purge_networks: yes
63 networks:
64 - name: "{{ invidious_network_name }}"
65 ipv4_address: "{{ invidious_db_ipv4 }}"
66 volumes:
67 - "{{ docker_home }}/invidious/data:/var/lib/postgresql/data"
68 - "{{ docker_home }}/invidious/src/config/sql:/config/sql"
69 - "{{ docker_home }}/invidious/src/docker/init-invidious-db.sh:/docker-entrypoint-initdb.d/init-invidious-db.sh"
70 env:
71 "POSTGRES_DB": "invidious"
72 "POSTGRES_USER": "invidious"
73 "POSTGRES_PASSWORD": "{{ invidious_postgres_password }}"
74 state: 'started'
75 recreate: yes
76 restart_policy: unless-stopped
77
78- name: create and deploy invidious container
79 become: yes
80 become_user: "{{ docker_username }}"
81 environment:
82 XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}"
83 docker_container:
84 name: "invidious"
85 hostname: "invidious"
86 image: "{{ image }}"
87 docker_host: "unix://run/user/{{ docker_uid }}/docker.sock"
88 purge_networks: yes
89 env:
90 "dbname": "invidious"
91 "user": "invidious"
92 "password": "{{ invidious_postgres_password }}"
93 "host": "invidious-db"
94 "port": "5432"
95 "check_tables": "true"
96 "https_only": "true"
97 "hsts": "true"
98 "domain": "{{ invidious_server_name }}"
99 "dark_mode": "dark"
100 networks:
101 - name: "{{ invidious_network_name }}"
102 ipv4_address: "{{ invidious_ipv4 }}"
103 ports:
104 - "127.0.0.1:{{ invidious_external_port }}:3000"
105 state: 'started'
106 recreate: yes
107 restart_policy: unless-stopped
108
109- name: deploy nginx configuration
110 notify: restart nginx
111 template:
112 src: "{{ invidious_nginx_config }}"
113 dest: /etc/nginx/sites-available/invidious.conf
114 owner: root
115 group: root
116 mode: '0644'
117
118- name: symlink site
119 file:
120 src: /etc/nginx/sites-available/invidious.conf
121 dest: /etc/nginx/sites-enabled/invidious.conf
122 owner: root
123 group: root
124 state: link