From afd3a73a2e66d97b0c71839d83d1770674894901 Mon Sep 17 00:00:00 2001 From: Ivan Reshetnikov Date: Mon, 21 Oct 2024 23:02:30 +0500 Subject: [PATCH] Use redis role for peertube --- roles/peertube/files/redis.conf | 1 - roles/peertube/tasks/main.yml | 55 +++++++++++++++++++++++++++++-- roles/peertube/tasks/peertube.yml | 41 ----------------------- roles/peertube/tasks/redis.yml | 34 ------------------- 4 files changed, 53 insertions(+), 78 deletions(-) delete mode 100644 roles/peertube/files/redis.conf delete mode 100644 roles/peertube/tasks/peertube.yml delete mode 100644 roles/peertube/tasks/redis.yml diff --git a/roles/peertube/files/redis.conf b/roles/peertube/files/redis.conf deleted file mode 100644 index 3628768..0000000 --- a/roles/peertube/files/redis.conf +++ /dev/null @@ -1 +0,0 @@ -save 60 1000 diff --git a/roles/peertube/tasks/main.yml b/roles/peertube/tasks/main.yml index c8990dc..fa0ef9b 100644 --- a/roles/peertube/tasks/main.yml +++ b/roles/peertube/tasks/main.yml @@ -1,3 +1,54 @@ --- -- import_tasks: redis.yml -- import_tasks: peertube.yml +- name: Create peertube network + become: true + community.docker.docker_network: + name: peertube +- name: Create redis container + include_role: + name: redis + vars: + preset: persistent + container_name: peertube-redis + docker_networks: + - name: peertube + docker_volume: peertube-redis +- name: Create peertube config dir + become: true + ansible.builtin.file: + path: /etc/peertube + state: directory + mode: '1700' + owner: root + group: root +- name: Copy default config + become: true + ansible.builtin.copy: + src: default.yaml + dest: /etc/peertube/default.yaml +- name: Copy production config + become: true + ansible.builtin.template: + src: production.yaml.j2 + dest: /etc/peertube/production.yaml + register: cfg +- name: Create peertube-data volume + become: true + community.docker.docker_volume: + name: peertube-data +- name: Run peertube container + become: true + community.docker.docker_container: + name: peertube + image: chocobozzz/peertube:v6.3.2-bookworm + networks: + - name: peertube + - name: haproxy + - name: postgresql + volumes: + - /mnt/hdd/peertube:/data + - /etc/peertube:/config + mounts: + - type: tmpfs + target: /data/tmp + tmpfs_size: "4G" + recreate: "{{ cfg.changed }}" diff --git a/roles/peertube/tasks/peertube.yml b/roles/peertube/tasks/peertube.yml deleted file mode 100644 index f31aa97..0000000 --- a/roles/peertube/tasks/peertube.yml +++ /dev/null @@ -1,41 +0,0 @@ ---- -- name: Create peertube config dir - become: true - ansible.builtin.file: - path: /etc/peertube - state: directory - mode: '1700' - owner: root - group: root -- name: Copy default config - become: true - ansible.builtin.copy: - src: default.yaml - dest: /etc/peertube/default.yaml -- name: Copy production config - become: true - ansible.builtin.template: - src: production.yaml.j2 - dest: /etc/peertube/production.yaml - register: cfg -- name: Create peertube-data volume - become: true - community.docker.docker_volume: - name: peertube-data -- name: Run peertube container - become: true - community.docker.docker_container: - name: peertube - image: chocobozzz/peertube:v6.3.2-bookworm - networks: - - name: peertube - - name: haproxy - - name: postgresql - volumes: - - /mnt/hdd/peertube:/data - - /etc/peertube:/config - mounts: - - type: tmpfs - target: /data/tmp - tmpfs_size: "4G" - recreate: "{{ cfg.changed }}" diff --git a/roles/peertube/tasks/redis.yml b/roles/peertube/tasks/redis.yml deleted file mode 100644 index b931c69..0000000 --- a/roles/peertube/tasks/redis.yml +++ /dev/null @@ -1,34 +0,0 @@ ---- -- name: Create peertube network - become: true - community.docker.docker_network: - name: peertube -- name: Create peertube-redis docker volume - become: true - community.docker.docker_volume: - name: peertube-redis -- name: Create /etc/redis/peertube dir - become: true - ansible.builtin.file: - path: /etc/redis/peertube - state: directory - mode: '1755' - owner: root - group: root -- name: Copy redis config - become: true - ansible.builtin.copy: - src: redis.conf - dest: /etc/redis/peertube/redis.conf -- name: Run peertube-redis container - become: true - community.docker.docker_container: - name: peertube-redis - image: redis:7.4-bookworm - command: ["redis-server", "/etc/redis/redis.conf"] - networks: - - name: peertube - volumes: - - peertube-redis:/data - - /etc/redis/peertube:/etc/redis:ro - restart_policy: unless-stopped