From 8f1c29b847defa500362a8af6e4426cca485817e Mon Sep 17 00:00:00 2001 From: Zach Wayer Date: Thu, 4 Jul 2024 22:43:34 -0500 Subject: [PATCH] Rework repo - move files around and update play Updating repo and files to look a bit more on par with the style of ansible I'm used to writing. Removing inventory as it can easily go stale and the homelab env needs to be a bit more dynamic anyway. need to find a good way to manage this but for now, no inventory is better than outdated inv. --- .../docker-compose.yaml | 53 +++++++++---------- inventory.yml | 6 --- media-buildout.yml | 46 +++++++++------- 3 files changed, 53 insertions(+), 52 deletions(-) rename docker-compose.yml => files/docker-compose.yaml (83%) delete mode 100644 inventory.yml diff --git a/docker-compose.yml b/files/docker-compose.yaml similarity index 83% rename from docker-compose.yml rename to files/docker-compose.yaml index 1f17483..570b003 100644 --- a/docker-compose.yml +++ b/files/docker-compose.yaml @@ -1,6 +1,6 @@ --- version: '3.4' -x-function: &function +x-function: &traefik-config networks: - traefik_proxy1 labels: @@ -19,13 +19,12 @@ x-function: &function environment: - PUID=${PUID} - PGID=${PGID} - - TZ=${TZ} + - TZ=${TZ} # Media Server services: -#Grabber, manage TV shows - + # Grabber, manage TV shows sonarr: - <<: *function + <<: *traefik-config image: linuxserver/sonarr:latest container_name: sonarr volumes: @@ -41,9 +40,9 @@ services: - "traefik.frontend.rule=Host:sonarr.${DOMAINNAME}" - "docker.group=external" -#Indexer, Used by managers to query sites for content + # Indexer, Used by managers to query sites for content jackett: - <<: *function + <<: *traefik-config image: linuxserver/jackett:latest container_name: jackett volumes: @@ -53,12 +52,12 @@ services: - 9117:9117 labels: - "traefik.backend=jackett" - - "traefik.frontend.rule=Host:jackett.${DOMAINNAME}" + - "traefik.frontend.rule=Host:jackett.${DOMAINNAME}" - "traefik.port=9117" - "docker.group=internal" -#Reverse Proxy, Used to route applications to domain + # Reverse Proxy, Used to route applications to domain traefik: - <<: *function + <<: *traefik-config hostname: traefik image: traefik:v1.7 container_name: traefik @@ -73,7 +72,7 @@ services: labels: - "traefik.enable=true" - "traefik.backend=traefik" - - "traefik.frontend.rule=Host:traefik.${DOMAINNAME}" + - "traefik.frontend.rule=Host:traefik.${DOMAINNAME}" - "traefik.port=80" - "traefik.frontend.auth.basic.users=${HTTP_USERNAME}:${HTTP_PASSWORD}" - "docker.group=internal" @@ -82,17 +81,17 @@ services: - /home/dockeruser/traefik:/etc/traefik - /opt/appdata/shared:/shared - /opt/appdata/traefik:/var/log - - /opt/appdata/traefik/tmp:/tmp -#Downloader, pull in content from torrents & hide traffic behind VPN + - /opt/appdata/traefik/tmp:/tmp + # Downloader, pull in content from torrents & hide traffic behind VPN arch-deluge: - <<: *function + <<: *traefik-config image: binhex/arch-delugevpn:latest container_name: arch-deluge ports: - - 8112:8112 - - 8118:8118 - - 58846:58846 - - 58946:58946 + - 8112:8112 + - 8118:8118 + - 58846:58846 + - 58946:58946 cap_add: - NET_ADMIN volumes: @@ -104,7 +103,7 @@ services: environment: - PUID=${PUID} - PGID=${PGID} - - TZ=${TZ} + - TZ=${TZ} - VPN_ENABLED=yes - VPN_USER=${VPN_USER} - VPN_PASS=${VPN_PASS} @@ -123,16 +122,16 @@ services: - "traefik.port=8112" - "docker.group=external" privileged: true -#updated version of plex requests + # User Request, auto add to searchers ombi: - <<: *function + <<: *traefik-config image: linuxserver/ombi container_name: ombi environment: - PUID=${PUID} - PGID=${PGID} - TZ=${TZ} - - BASE_URL=/ombi #optional + - BASE_URL=/ombi # optional volumes: - /opt/appdata/ombi:/config - /opt/appdata/shared:/shared @@ -146,9 +145,9 @@ services: - "docker.group=external" ports: - 3579:3579 -#NZBGet - usenet downloader + # NZBGet - usenet downloader nzbget: - <<: *function + <<: *traefik-config image: linuxserver/nzbget:latest container_name: nzbget volumes: @@ -165,10 +164,8 @@ services: - "traefik.frontend.rule=Host:nzbget.${DOMAINNAME}" # - "traefik.port=6789" - "docker.group=external" -#Networks, Needed for Traefik +# Networks, Needed for Traefik networks: traefik_proxy1: - # external: true default: - driver: bridge - + driver: bridge diff --git a/inventory.yml b/inventory.yml deleted file mode 100644 index 41ee614..0000000 --- a/inventory.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -all: - hosts: - tower: - ansible_host: 192.168.0.62 - vars: diff --git a/media-buildout.yml b/media-buildout.yml index 88e6f69..b8b310a 100644 --- a/media-buildout.yml +++ b/media-buildout.yml @@ -1,11 +1,15 @@ -- hosts: all +--- +- name: Install and setup Server for media acqusition + hosts: all become: true + become_user: root vars: pip_install_packages: - name: Docker nfs_host: 192.168.0.109 - nfs_options: "auto,nofail,noatime,nolock,intr,tcp,actimeo=1800" + nfs_options: + "auto,nofail,noatime,nolock,intr,tcp,actimeo=1800,x-systemd.automount" nfs_mounts: - remote_path: /export/Movies local_path: /mnt/storage/movies @@ -18,7 +22,7 @@ - geerlingguy.pip - geerlingguy.docker tasks: - - name: Install docker tools + - name: Install system packages ansible.builtin.package: name: "{{ item }}" state: present @@ -54,24 +58,30 @@ shell: "{{ item.shell }}" groups: "{{ item.groups }}" loop: - - { user: "zware", shell: "/bin/zsh", groups: "sudo,docker" } - - { user: "dockeruser", shell: "/bin/bash", groups: "docker" } + - {user: "dockeruser", + shell: "/bin/bash", + groups: "docker"} + # zware user should already exist when this is run, + # most likely needs ot happen in a cloud init step + # - {user: "zware", + # shell: "/bin/zsh", + # groups: "sudo,docker"} - name: Copy docker-compose ansible.builtin.copy: - src: docker-compose.yml - dest: /opt/docker-compose.yml - owner: root - group: root - mode: "0644" - - - name: Copy env file - ansible.builtin.copy: - src: environment - dest: /opt/environment - owner: zware - group: zware - mode: "0600" + src: "{{ item.src }}" + dest: "{{ item.dest }}" + owner: dockeruser + group: dockeruser + mode: "{{ item.mode }}" + backup: true + loop: + - {src: "files/docker-compose.yaml", + dest: "/opt/docker-compose.yaml", + mode: "0644"} + - {src: "files/environmnet", + dest: "/opt/.env", + mode: "0600"} - name: Start containers community.docker.docker_compose: