From 95b73daa36b23565a8566f71f9b202d3459b685f Mon Sep 17 00:00:00 2001 From: Sam Chudnick Date: Sun, 25 Jun 2023 09:52:36 -0400 Subject: Initial Commit --- .../containers/arr_stack/handlers/main.yml | 4 + .../containers/arr_stack/tasks/gluetun.yml | 105 +++++++++++++++++ .../services/containers/arr_stack/tasks/lidarr.yml | 93 +++++++++++++++ roles/services/containers/arr_stack/tasks/main.yml | 130 +++++++++++++++++++++ .../containers/arr_stack/tasks/prowlarr.yml | 92 +++++++++++++++ .../containers/arr_stack/tasks/qbittorrent.yml | 94 +++++++++++++++ .../services/containers/arr_stack/tasks/radarr.yml | 93 +++++++++++++++ .../containers/arr_stack/tasks/readarr.yml | 93 +++++++++++++++ .../services/containers/arr_stack/tasks/sonarr.yml | 93 +++++++++++++++ 9 files changed, 797 insertions(+) create mode 100644 roles/services/containers/arr_stack/handlers/main.yml create mode 100644 roles/services/containers/arr_stack/tasks/gluetun.yml create mode 100644 roles/services/containers/arr_stack/tasks/lidarr.yml create mode 100644 roles/services/containers/arr_stack/tasks/main.yml create mode 100644 roles/services/containers/arr_stack/tasks/prowlarr.yml create mode 100644 roles/services/containers/arr_stack/tasks/qbittorrent.yml create mode 100644 roles/services/containers/arr_stack/tasks/radarr.yml create mode 100644 roles/services/containers/arr_stack/tasks/readarr.yml create mode 100644 roles/services/containers/arr_stack/tasks/sonarr.yml (limited to 'roles/services/containers/arr_stack') diff --git a/roles/services/containers/arr_stack/handlers/main.yml b/roles/services/containers/arr_stack/handlers/main.yml new file mode 100644 index 0000000..5463835 --- /dev/null +++ b/roles/services/containers/arr_stack/handlers/main.yml @@ -0,0 +1,4 @@ +- name: restart nginx + service: + name: nginx + state: restarted diff --git a/roles/services/containers/arr_stack/tasks/gluetun.yml b/roles/services/containers/arr_stack/tasks/gluetun.yml new file mode 100644 index 0000000..e47d55a --- /dev/null +++ b/roles/services/containers/arr_stack/tasks/gluetun.yml @@ -0,0 +1,105 @@ +- name: set image fact + set_fact: + image: qmcgaw/gluetun:v3.34.3 + +- 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 gluetun directory + file: + path: "{{ docker_home }}/gluetun" + state: directory + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0755' + +- name: create gluetun data directory + file: + path: "{{ docker_home }}/gluetun/data" + state: directory + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0755' + +- name: login to docker registry + become: yes + become_user: "{{ docker_username }}" + environment: + XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}" + docker_login: + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + registry_url: "{{ docker_registry_url }}" + username: "{{ docker_registry_username }}" + password: "{{ docker_registry_password }}" + +- name: pull and push gluetun image + become: yes + become_user: "{{ docker_username }}" + environment: + XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}" + docker_image: + name: "{{ image }}" + repository: "{{ custom_registry }}/{{ repo_tag }}" + push: yes + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + source: pull + force_source: yes + +- name: create gluetun docker network + docker_network: + name: "{{ gluetun_network_name }}" + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + driver: bridge + ipam_config: + - subnet: "{{ gluetun_subnet }}" + gateway: "{{ gluetun_gateway }}" + +- name: create and deploy gluetun container + become: yes + become_user: "{{ docker_username }}" + environment: + XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}" + docker_container: + name: "gluetun" + hostname: "gluetun" + image: "{{ custom_registry }}/{{ repo_tag }}" + recreate: yes + pull: yes + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + capabilities: + - net_admin + devices: + - "/dev/net/tun:/dev/net/tun" + purge_networks: yes + networks: + - name: "{{ gluetun_network_name }}" + ipv4_address: "{{ gluetun_ipv4 }}" + ports: + - "127.0.0.1:{{ qbittorrent_external_port }}:{{ qbittorrent_external_port }}" + - "127.0.0.1:{{ sonarr_external_port }}:8989" + - "127.0.0.1:{{ radarr_external_port }}:7878" + - "127.0.0.1:{{ lidarr_external_port }}:8686" + - "127.0.0.1:{{ readarr_external_port }}:8787" + - "127.0.0.1:{{ prowlarr_external_port }}:9696" + state: 'started' + comparisons: + '*': strict + restart_policy: unless-stopped + env: + "TZ": "{{ timezone }}" + "VPN_SERVICE_PROVIDER": "mullvad" + "VPN_TYPE": "wireguard" + "WIREGUARD_PRIVATE_KEY": "{{ wireguard_privkey }}" + "WIREGUARD_ADDRESSES": "{{ wireguard_addrs }}" + "SERVER_CITIES": "{{ gluetun_cities }}" + "DOT_PROVIDERS": "quad9" + "BLOCK_MALICIOUS": "on" + "BLOCK_SURVEILLANCE": "on" + "BLOCK_ADS": "on" + "HEALTH_TARGET_ADDRESS": "www.debian.org:443" + volumes: + - "{{ docker_home }}/gluetun/data:/gluetun" diff --git a/roles/services/containers/arr_stack/tasks/lidarr.yml b/roles/services/containers/arr_stack/tasks/lidarr.yml new file mode 100644 index 0000000..1f70437 --- /dev/null +++ b/roles/services/containers/arr_stack/tasks/lidarr.yml @@ -0,0 +1,93 @@ +- name: set image fact + set_fact: + image: linuxserver/lidarr:1.2.6-nightly + +- 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 lidarr directory + file: + path: "{{ docker_home }}/lidarr" + state: directory + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0755' + +- name: create lidarr config directory + file: + path: "{{ docker_home }}/lidarr/config" + state: directory + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0755' + +- name: login to docker registry + become: yes + become_user: "{{ docker_username }}" + environment: + xdg_runtime_dir: "/run/user/{{ docker_uid }}" + docker_login: + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + registry_url: "{{ docker_registry_url }}" + username: "{{ docker_registry_username }}" + password: "{{ docker_registry_password }}" + +- name: pull and push lidarr image + become: yes + become_user: "{{ docker_username }}" + environment: + xdg_runtime_dir: "/run/user/{{ docker_uid }}" + docker_image: + name: "{{ image }}" + repository: "{{ custom_registry }}/{{ repo_tag }}" + push: yes + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + source: pull + force_source: yes + +- name: create and deploy lidarr container + become: yes + become_user: "{{ docker_username }}" + environment: + xdg_runtime_dir: "/run/user/{{ docker_uid }}" + docker_container: + name: "lidarr" + image: "{{ custom_registry }}/{{ repo_tag }}" + recreate: yes + pull: yes + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + purge_networks: yes + network_mode: "container:gluetun" + state: 'started' + comparisons: + '*': strict + restart_policy: unless-stopped + env: + "tz": "{{ timezone }}" + "PUID": "0" + "PGID": "0" + volumes: + - "{{ docker_home }}/lidarr/config:/config" + - "{{ docker_home }}/arr/data:/data" + +- name: deploy nginx configuration + notify: restart nginx + register: nginx_config + template: + src: "{{ lidarr_nginx_config }}" + dest: /etc/nginx/sites-available/lidarr.conf + owner: root + group: root + mode: '0644' + +- name: symlink site + file: + src: /etc/nginx/sites-available/lidarr.conf + dest: /etc/nginx/sites-enabled/lidarr.conf + owner: root + group: root + state: link diff --git a/roles/services/containers/arr_stack/tasks/main.yml b/roles/services/containers/arr_stack/tasks/main.yml new file mode 100644 index 0000000..ee27384 --- /dev/null +++ b/roles/services/containers/arr_stack/tasks/main.yml @@ -0,0 +1,130 @@ +- name: create arr directory structure + file: + path: "{{ docker_home }}/arr" + state: directory + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0775' +- name: create arr directory structure + file: + path: "{{ docker_home }}/arr/data" + state: directory + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0775' + +- name: create arr/data directory structure + file: + path: "{{ docker_home }}/arr/data/torrents" + state: directory + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0775' +- name: create arr/data directory structure + file: + path: "{{ docker_home }}/arr/data/torrents/movies" + state: directory + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0775' +- name: create arr/data directory structure + file: + path: "{{ docker_home }}/arr/data/torrents/music" + state: directory + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0775' +- name: create arr/data directory structure + file: + path: "{{ docker_home }}/arr/data/torrents/books" + state: directory + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0775' +- name: create arr/data directory structure + file: + path: "{{ docker_home }}/arr/data/torrents/tv" + state: directory + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0775' + +- name: create arr/data directory structure + file: + path: "{{ docker_home }}/arr/data/usenet" + state: directory + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0775' +- name: create arr/data directory structure + file: + path: "{{ docker_home }}/arr/data/usenet/movies" + state: directory + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0775' +- name: create arr/data directory structure + file: + path: "{{ docker_home }}/arr/data/usenet/music" + state: directory + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0775' +- name: create arr/data directory structure + file: + path: "{{ docker_home }}/arr/data/usenet/books" + state: directory + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0775' +- name: create arr/data directory structure + file: + path: "{{ docker_home }}/arr/data/usenet/tv" + state: directory + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0775' + +- name: create arr/data directory structure + file: + path: "{{ docker_home }}/arr/data/media" + state: directory + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0775' +- name: create arr/data directory structure + file: + path: "{{ docker_home }}/arr/data/media/movies" + state: directory + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0775' +- name: create arr/data directory structure + file: + path: "{{ docker_home }}/arr/data/media/music" + state: directory + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0775' +- name: create arr/data directory structure + file: + path: "{{ docker_home }}/arr/data/media/books" + state: directory + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0775' +- name: create arr/data directory structure + file: + path: "{{ docker_home }}/arr/data/media/tv" + state: directory + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0775' + +- include_tasks: gluetun.yml +- include_tasks: qbittorrent.yml +- include_tasks: sonarr.yml +- include_tasks: radarr.yml +- include_tasks: lidarr.yml +- include_tasks: readarr.yml +- include_tasks: prowlarr.yml diff --git a/roles/services/containers/arr_stack/tasks/prowlarr.yml b/roles/services/containers/arr_stack/tasks/prowlarr.yml new file mode 100644 index 0000000..53f1a45 --- /dev/null +++ b/roles/services/containers/arr_stack/tasks/prowlarr.yml @@ -0,0 +1,92 @@ +- name: set image fact + set_fact: + image: linuxserver/prowlarr:1.6.2-nightly + +- 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 prowlarr directory + file: + path: "{{ docker_home }}/prowlarr" + state: directory + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0755' + +- name: create prowlarr config directory + file: + path: "{{ docker_home }}/prowlarr/config" + state: directory + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0755' + +- name: login to docker registry + become: yes + become_user: "{{ docker_username }}" + environment: + XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}" + docker_login: + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + registry_url: "{{ docker_registry_url }}" + username: "{{ docker_registry_username }}" + password: "{{ docker_registry_password }}" + +- name: pull and push prowlarr image + become: yes + become_user: "{{ docker_username }}" + environment: + XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}" + docker_image: + name: "{{ image }}" + repository: "{{ custom_registry }}/{{ repo_tag }}" + push: yes + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + source: pull + force_source: yes + +- name: create and deploy prowlarr container + become: yes + become_user: "{{ docker_username }}" + environment: + XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}" + docker_container: + name: "prowlarr" + image: "{{ custom_registry }}/{{ repo_tag }}" + recreate: yes + pull: yes + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + purge_networks: yes + network_mode: "container:gluetun" + state: 'started' + comparisons: + '*': strict + restart_policy: unless-stopped + env: + "TZ": "{{ timezone }}" + "PUID": "0" + "PGID": "0" + volumes: + - "{{ docker_home }}/prowlarr/config:/config" + +- name: deploy nginx configuration + notify: restart nginx + register: nginx_config + template: + src: "{{ prowlarr_nginx_config }}" + dest: /etc/nginx/sites-available/prowlarr.conf + owner: root + group: root + mode: '0644' + +- name: symlink site + file: + src: /etc/nginx/sites-available/prowlarr.conf + dest: /etc/nginx/sites-enabled/prowlarr.conf + owner: root + group: root + state: link diff --git a/roles/services/containers/arr_stack/tasks/qbittorrent.yml b/roles/services/containers/arr_stack/tasks/qbittorrent.yml new file mode 100644 index 0000000..25e554f --- /dev/null +++ b/roles/services/containers/arr_stack/tasks/qbittorrent.yml @@ -0,0 +1,94 @@ +- name: set image fact + set_fact: + image: linuxserver/qbittorrent:4.5.4 + +- 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 qbittorrent directory + file: + path: "{{ docker_home }}/qbittorrent" + state: directory + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0755' + +- name: create qbittorrent config directory + file: + path: "{{ docker_home }}/qbittorrent/config" + state: directory + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0755' + +- name: login to docker registry + become: yes + become_user: "{{ docker_username }}" + environment: + XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}" + docker_login: + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + registry_url: "{{ docker_registry_url }}" + username: "{{ docker_registry_username }}" + password: "{{ docker_registry_password }}" + +- name: pull and push qbittorrent image + become: yes + become_user: "{{ docker_username }}" + environment: + XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}" + docker_image: + name: "{{ image }}" + repository: "{{ custom_registry }}/{{ repo_tag }}" + push: yes + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + source: pull + force_source: yes + +- name: create and deploy qbittorrent container + become: yes + become_user: "{{ docker_username }}" + environment: + XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}" + docker_container: + name: "qbittorrent" + image: "{{ custom_registry }}/{{ repo_tag }}" + recreate: yes + pull: yes + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + purge_networks: yes + network_mode: "container:gluetun" + state: 'started' + comparisons: + '*': strict + restart_policy: unless-stopped + env: + "TZ": "{{ timezone }}" + "WEBUI_PORT": "{{ qbittorrent_external_port }}" + "PUID": "0" + "PGID": "0" + volumes: + - "{{ docker_home }}/qbittorrent/config:/config" + - "{{ docker_home }}/arr/data:/data" + +- name: deploy nginx configuration + notify: restart nginx + register: nginx_config + template: + src: "{{ qbittorrent_nginx_config }}" + dest: /etc/nginx/sites-available/qbittorrent.conf + owner: root + group: root + mode: '0644' + +- name: symlink site + file: + src: /etc/nginx/sites-available/qbittorrent.conf + dest: /etc/nginx/sites-enabled/qbittorrent.conf + owner: root + group: root + state: link diff --git a/roles/services/containers/arr_stack/tasks/radarr.yml b/roles/services/containers/arr_stack/tasks/radarr.yml new file mode 100644 index 0000000..2e98c47 --- /dev/null +++ b/roles/services/containers/arr_stack/tasks/radarr.yml @@ -0,0 +1,93 @@ +- name: set image fact + set_fact: + image: linuxserver/radarr:4.6.4-nightly + +- 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 radarr directory + file: + path: "{{ docker_home }}/radarr" + state: directory + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0755' + +- name: create radarr config directory + file: + path: "{{ docker_home }}/radarr/config" + state: directory + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0755' + +- name: login to docker registry + become: yes + become_user: "{{ docker_username }}" + environment: + xdg_runtime_dir: "/run/user/{{ docker_uid }}" + docker_login: + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + registry_url: "{{ docker_registry_url }}" + username: "{{ docker_registry_username }}" + password: "{{ docker_registry_password }}" + +- name: pull and push radarr image + become: yes + become_user: "{{ docker_username }}" + environment: + xdg_runtime_dir: "/run/user/{{ docker_uid }}" + docker_image: + name: "{{ image }}" + repository: "{{ custom_registry }}/{{ repo_tag }}" + push: yes + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + source: pull + force_source: yes + +- name: create and deploy radarr container + become: yes + become_user: "{{ docker_username }}" + environment: + xdg_runtime_dir: "/run/user/{{ docker_uid }}" + docker_container: + name: "radarr" + image: "{{ custom_registry }}/{{ repo_tag }}" + recreate: yes + pull: yes + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + purge_networks: yes + network_mode: "container:gluetun" + state: 'started' + comparisons: + '*': strict + restart_policy: unless-stopped + env: + "tz": "{{ timezone }}" + "PUID": "0" + "PGID": "0" + volumes: + - "{{ docker_home }}/radarr/config:/config" + - "{{ docker_home }}/arr/data:/data" + +- name: deploy nginx configuration + notify: restart nginx + register: nginx_config + template: + src: "{{ radarr_nginx_config }}" + dest: /etc/nginx/sites-available/radarr.conf + owner: root + group: root + mode: '0644' + +- name: symlink site + file: + src: /etc/nginx/sites-available/radarr.conf + dest: /etc/nginx/sites-enabled/radarr.conf + owner: root + group: root + state: link diff --git a/roles/services/containers/arr_stack/tasks/readarr.yml b/roles/services/containers/arr_stack/tasks/readarr.yml new file mode 100644 index 0000000..bd8b2ec --- /dev/null +++ b/roles/services/containers/arr_stack/tasks/readarr.yml @@ -0,0 +1,93 @@ +- name: set image fact + set_fact: + image: linuxserver/readarr:0.2.0-nightly + +- 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 readarr directory + file: + path: "{{ docker_home }}/readarr" + state: directory + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0755' + +- name: create readarr config directory + file: + path: "{{ docker_home }}/readarr/config" + state: directory + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0755' + +- name: login to docker registry + become: yes + become_user: "{{ docker_username }}" + environment: + XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}" + docker_login: + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + registry_url: "{{ docker_registry_url }}" + username: "{{ docker_registry_username }}" + password: "{{ docker_registry_password }}" + +- name: pull and push readarr image + become: yes + become_user: "{{ docker_username }}" + environment: + XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}" + docker_image: + name: "{{ image }}" + repository: "{{ custom_registry }}/{{ repo_tag }}" + push: yes + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + source: pull + force_source: yes + +- name: create and deploy readarr container + become: yes + become_user: "{{ docker_username }}" + environment: + XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}" + docker_container: + name: "readarr" + image: "{{ custom_registry }}/{{ repo_tag }}" + recreate: yes + pull: yes + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + purge_networks: yes + network_mode: "container:gluetun" + state: 'started' + comparisons: + '*': strict + restart_policy: unless-stopped + env: + "TZ": "{{ timezone }}" + "PUID": "0" + "PGID": "0" + volumes: + - "{{ docker_home }}/readarr/config:/config" + - "{{ docker_home }}/arr/data:/data" + +- name: deploy nginx configuration + notify: restart nginx + register: nginx_config + template: + src: "{{ readarr_nginx_config }}" + dest: /etc/nginx/sites-available/readarr.conf + owner: root + group: root + mode: '0644' + +- name: symlink site + file: + src: /etc/nginx/sites-available/readarr.conf + dest: /etc/nginx/sites-enabled/readarr.conf + owner: root + group: root + state: link diff --git a/roles/services/containers/arr_stack/tasks/sonarr.yml b/roles/services/containers/arr_stack/tasks/sonarr.yml new file mode 100644 index 0000000..ac712ba --- /dev/null +++ b/roles/services/containers/arr_stack/tasks/sonarr.yml @@ -0,0 +1,93 @@ +- name: set image fact + set_fact: + image: linuxserver/sonarr:develop-version-4.0.0.433 + +- 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 sonarr directory + file: + path: "{{ docker_home }}/sonarr" + state: directory + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0755' + +- name: create sonarr config directory + file: + path: "{{ docker_home }}/sonarr/config" + state: directory + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0755' + +- name: login to docker registry + become: yes + become_user: "{{ docker_username }}" + environment: + XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}" + docker_login: + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + registry_url: "{{ docker_registry_url }}" + username: "{{ docker_registry_username }}" + password: "{{ docker_registry_password }}" + +- name: pull and push sonarr image + become: yes + become_user: "{{ docker_username }}" + environment: + XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}" + docker_image: + name: "{{ image }}" + repository: "{{ custom_registry }}/{{ repo_tag }}" + push: yes + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + source: pull + force_source: yes + +- name: create and deploy sonarr container + become: yes + become_user: "{{ docker_username }}" + environment: + XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}" + docker_container: + name: "sonarr" + image: "{{ custom_registry }}/{{ repo_tag }}" + recreate: yes + pull: yes + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + purge_networks: yes + network_mode: "container:gluetun" + state: 'started' + comparisons: + '*': strict + restart_policy: unless-stopped + env: + "TZ": "{{ timezone }}" + "PUID": "0" + "PGID": "0" + volumes: + - "{{ docker_home }}/sonarr/config:/config" + - "{{ docker_home }}/arr/data:/data" + +- name: deploy nginx configuration + notify: restart nginx + register: nginx_config + template: + src: "{{ sonarr_nginx_config }}" + dest: /etc/nginx/sites-available/sonarr.conf + owner: root + group: root + mode: '0644' + +- name: symlink site + file: + src: /etc/nginx/sites-available/sonarr.conf + dest: /etc/nginx/sites-enabled/sonarr.conf + owner: root + group: root + state: link -- cgit v1.2.3