- name: set image fact set_fact: image: gitea.chudnick.com/sam/invidious:latest - name: set other facts vars: array: "{{ image.split('/', 1) }}" set_fact: repo_tag: "{{ array.1 }}" custom_registry: "{{ docker_registry_url + '/' + docker_registry_username }}" - name: create invidious directory file: path: "{{ docker_home }}/invidious" state: directory owner: "{{ docker_username }}" group: "{{ docker_username }}" mode: '0755' - name: create postgres data directory file: path: "{{ docker_home }}/invidious/data" state: directory owner: "{{ docker_username }}" group: "{{ docker_username }}" mode: '0755' - name: clone invidious repo become: yes become_user: "{{ docker_username }}" notify: - login to docker registry - build invidious image git: repo: "{{ invidious_repo }}" dest: "{{ docker_home }}/invidious/src" version: "master" - meta: flush_handlers - name: create invidious docker network become: yes become_user: "{{ docker_username }}" docker_network: name: "{{ invidious_network_name }}" docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" driver: bridge ipam_config: - subnet: "{{ invidious_subnet }}" gateway: "{{ invidious_gateway }}" - name: create and deploy invidious db become: yes become_user: "{{ docker_username }}" environment: XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}" docker_container: name: "invidious-db" hostname: "invidious-db" image: postgres:13 docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" purge_networks: yes networks: - name: "{{ invidious_network_name }}" ipv4_address: "{{ invidious_db_ipv4 }}" volumes: - "{{ docker_home }}/invidious/data:/var/lib/postgresql/data" - "{{ docker_home }}/invidious/src/config/sql:/config/sql" - "{{ docker_home }}/invidious/src/docker/init-invidious-db.sh:/docker-entrypoint-initdb.d/init-invidious-db.sh" env: "POSTGRES_DB": "invidious" "POSTGRES_USER": "invidious" "POSTGRES_PASSWORD": "{{ invidious_postgres_password }}" state: 'started' recreate: yes restart_policy: unless-stopped - name: create and deploy invidious container become: yes become_user: "{{ docker_username }}" environment: XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}" docker_container: name: "invidious" hostname: "invidious" image: "{{ image }}" docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" purge_networks: yes env: "dbname": "invidious" "user": "invidious" "password": "{{ invidious_postgres_password }}" "host": "invidious-db" "port": "5432" "check_tables": "true" "https_only": "true" "hsts": "true" "domain": "{{ invidious_server_name }}" "dark_mode": "dark" networks: - name: "{{ invidious_network_name }}" ipv4_address: "{{ invidious_ipv4 }}" ports: - "127.0.0.1:{{ invidious_external_port }}:3000" state: 'started' recreate: yes restart_policy: unless-stopped - name: deploy nginx configuration notify: restart nginx template: src: "{{ invidious_nginx_config }}" dest: /etc/nginx/sites-available/invidious.conf owner: root group: root mode: '0644' - name: symlink site file: src: /etc/nginx/sites-available/invidious.conf dest: /etc/nginx/sites-enabled/invidious.conf owner: root group: root state: link