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/navidrome/handlers/main.yml | 4 + roles/services/containers/navidrome/tasks/main.yml | 117 +++++++++++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 roles/services/containers/navidrome/handlers/main.yml create mode 100644 roles/services/containers/navidrome/tasks/main.yml (limited to 'roles/services/containers/navidrome') diff --git a/roles/services/containers/navidrome/handlers/main.yml b/roles/services/containers/navidrome/handlers/main.yml new file mode 100644 index 0000000..5463835 --- /dev/null +++ b/roles/services/containers/navidrome/handlers/main.yml @@ -0,0 +1,4 @@ +- name: restart nginx + service: + name: nginx + state: restarted diff --git a/roles/services/containers/navidrome/tasks/main.yml b/roles/services/containers/navidrome/tasks/main.yml new file mode 100644 index 0000000..e95e849 --- /dev/null +++ b/roles/services/containers/navidrome/tasks/main.yml @@ -0,0 +1,117 @@ +- name: set image fact + set_fact: + image: deluan/navidrome:0.49.2 + +- 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 navidrome directory + file: + path: "{{ docker_home }}/navidrome" + state: directory + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0755' + +- name: create navidrome data directory + file: + path: "{{ docker_home }}/navidrome/data" + state: directory + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0755' + +- name: create navidrome music directory + file: + path: "{{ docker_home }}/navidrome/music" + 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 navidrome image + become: yes + become_user: "{{ docker_username }}" + environment: + XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}" + docker_image: + name: "{{ image }}" + repository: "{{ custom_registry }}/{{ repo_tag }}" + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + source: pull + force_source: yes + push: yes + +- name: create navidrome docker network + docker_network: + name: "{{ navidrome_network_name }}" + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + driver: bridge + ipam_config: + - subnet: "{{ navidrome_subnet }}" + gateway: "{{ navidrome_gateway }}" + +- name: create and deploy navidrome container + become: yes + become_user: "{{ docker_username }}" + environment: + XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}" + docker_container: + name: "navidrome" + hostname: "navidrome" + image: "{{ custom_registry }}/{{ repo_tag }}" + pull: yes + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + purge_networks: yes + networks: + - name: "{{ navidrome_network_name }}" + ipv4_address: "{{ navidrome_ipv4 }}" + ports: + - "127.0.0.1:4533:4533" + state: 'started' + recreate: yes + restart_policy: unless-stopped + env: + "ND_AUTHREQUEST_LIMIT": "2" + "ND_PASSWORDENCRYPTIONKEY": "{{ navidrome_encryptionkey }}" + "ND_LASTFM_ENABLED": "false" + "ND_PROMETHEUS_ENABLED": "true" + "ND_PROMETHEUS_METRICSPATH": "/metrics" + "ND_REVERSEPROXYWHITELIST": "172.25.5.0/24" + "ND_LOGLEVEL": "debug" + volumes: + - "{{ docker_home }}/navidrome/data:/data" + - "{{ docker_home }}/arr/data/media/music:/music:ro" + +- name: deploy nginx configuration + notify: restart nginx + register: nginx_config + copy: + src: "{{ navidrome_nginx_config }}" + dest: /etc/nginx/sites-available/navidrome.conf + owner: root + group: root + mode: '0644' + +- name: symlink site + file: + src: /etc/nginx/sites-available/navidrome.conf + dest: /etc/nginx/sites-enabled/navidrome.conf + owner: root + group: root + state: link -- cgit v1.2.3