infra/roles/audiobookshelf/tasks/audiobookshelf.yml

157 lines
3.7 KiB
YAML

---
- name: create dir structure
file:
path: "{{ audiobookshelf_path }}/{{ item.name }}"
mode: "{{ item.mode | default('0750') }}"
owner: "{{ audiobookshelf_user.uid }}"
group: "{{ audiobookshelf_group.gid }}"
state: directory
tags:
- audiobookshelf-dirs
- abs-dirs
loop_control:
label: "{{ item.name }}"
with_items:
- name: ''
- name: config
mode: "0755"
- name: metadata
- name: backups
- name: ensure podcast and audiobooks dirs exists in {{ deadspace_root }}
file:
path: "{{ deadspace_root }}/{{ item }}"
mode: 0750
owner: "{{ audiobookshelf_user.uid }}"
group: "{{ audiobookshelf_group.gid }}"
tags:
- audiobookshelf-dirs
- abs-dirs
loop_control:
label: "{{ deadspace_root }}/{{ item }}"
with_items:
- audiobooks
- podcasts
- name: install certs
copy:
src: "/usr/local/etc/letsencrypt/live/{{ item }}"
dest: "/usr/local/etc/certs/"
owner: root
group: root
mode: 0755
tags:
- letsencrypt-certs
- audiobookshelf-certs
notify: reload nginx
vars:
prediff_cmd: echo
with_items:
- "{{ audiobookshelf_url }}"
- "{{ audiobookshelf_url_short }}"
- name: template nginx vhost
template:
src: 02-audiobookshelf.conf.j2
dest: /etc/nginx/sites-enabled/02-audiobookshelf.conf
owner: root
group: root
mode: 0644
tags:
- nginx
- audiobookshelf-nginx
- abs-nginx
notify: reload nginx
- name: start audiobookshelf container
docker_container:
name: audiobookshelf
auto_remove: false
image: ghcr.io/advplyr/audiobookshelf:latest
detach: true
pull: true
restart_policy: "unless-stopped"
state: started
#container_default_behavior: compatibility
#networks_cli_compatible: false
network_mode: bridgewithdns
networks:
- name: bridgewithdns
ipv4_address: "{{ bridgewithdns.audiobookshelf }}"
env:
AUDIOBOOKSHELF_UID: "{{ audiobookshelf_user.uid }}"
AUDIOBOOKSHELF_GID: "{{ audiobookshelf_group.gid }}"
user: "{{ audiobookshelf_user.uid }}:{{ audiobookshelf_group.gid }}"
mounts:
- type: bind
source: "{{ deadspace_root }}/audiobooks"
target: /audiobooks
- type: bind
source: "{{ deadspace_root }}/podcasts"
target: /podcasts
- type: bind
source: "{{ audiobookshelf_path }}/config"
target: /config
- type: bind
source: "{{ audiobookshelf_path }}/metadata"
target: /metadata
- type: bind
source: "{{ audiobookshelf_path }}/backups"
target: /backups
tags:
- audiobookshelf-container
- abs-container
- docker-containers
- name: install python utilies for mp3 metadata
apt:
name:
- eyed3
- python3-mutagen
state: present
tags:
- packages
- audiobookshelf-scripts
- name: config file for podcast tools
copy:
dest: /usr/local/bin/podcasts.json
owner: root
group: "{{ audiobookshelf_group.gid }}"
mode: 0750
content: "{{ podcast_tools_config | to_nice_json }}"
tags:
- abs-scripts
- audiobookshelf-scripts
- podcast-tools
- name: copy abs scripts
copy:
src: "{{ item }}"
dest: "/usr/local/bin/{{ item }}"
owner: "{{ audiobookshelf_user.uid }}"
group: "{{ audiobookshelf_group.gid }}"
mode: 0755
with_items:
- fix-podcast-date.py
tags:
- abs-scripts
- audiobookshelf-scripts
- podcast-tools
- name: cron file
template:
src: audiobookshelf-cron.j2
dest: /etc/cron.d/audiobookshelf
owner: root
group: root
mode: 0600
tags:
- cron
- abs-cron
- audiobookshelf-cron
- abs-scripts
- audiobookshelf-scripts
- podcast-tools