1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
- name: Set up Homebox
hosts: lotus-land-story
vars:
version: "{{ versions.homebox }}"
tasks:
- name: Create data directory for Homebox
ansible.builtin.file:
path: /mnt/lotus-land-story/homebox
state: directory
mode: "0755"
owner: "65532"
group: "65532"
# TODO back this up using restic
- name: Back up homebox if needed
block:
- name: Get current version
ansible.builtin.command: >
docker inspect
--format '{{ '{{' }} index .Config.Labels "org.opencontainers.image.version"}}'
homebox
register: homebox_version
changed_when: false
- name: Stop and backup homebox
when: homebox_version.stdout | trim != version
block:
- name: Stop homebox
community.docker.docker_container:
name: homebox
state: stopped
- name: Backup db
ansible.builtin.copy:
src: /mnt/lotus-land-story/homebox/homebox.db
dest: /mnt/lotus-land-story/homebox/homebox.db.bak
mode: "0400"
remote_src: true
- name: Run Homebox
community.docker.docker_container:
name: homebox
image: ghcr.io/sysadminsmedia/homebox:{{ version }}
restart: true
env:
TZ: America/Los_Angeles
HBOX_OPTIONS_ALLOW_ANALYTICS: "false"
HBOX_OPTIONS_ALLOW_REGISTRATION: "false"
HBOX_MAILER_HOST: mail.smtp2go.com
HBOX_MAILER_PORT: "2525"
HBOX_MAILER_USERNAME: "{{ homebox.mailer.username }}"
HBOX_MAILER_PASSWORD: "{{ homebox.mailer.password }}"
HBOX_MAILER_FROM: homebox@kejadlen.dev
volumes:
- /mnt/lotus-land-story/homebox:/data
restart_policy: unless-stopped
networks:
- name: lotus_land_story
no_log: true
# vim: ft=yaml.ansible