calathea: add config
This commit is contained in:
parent
2cfd746c52
commit
787a63ea0d
11 changed files with 137 additions and 1 deletions
12
roles/calathea/files/calathea.data.backup.sh
Normal file
12
roles/calathea/files/calathea.data.backup.sh
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
data_dir='/mnt/data1/calathea'
|
||||
snapshot_dir="${data_dir}.snapshot"
|
||||
|
||||
# Read-only snapshot for atomic backup
|
||||
btrfs subvolume snapshot -r "$data_dir" "$snapshot_dir" || exit $?
|
||||
|
||||
/usr/local/bin/restic backup "$snapshot_dir"
|
||||
|
||||
# Always remove snapshot subvolume, even if restic fails
|
||||
btrfs subvolume delete "$snapshot_dir"
|
||||
13
roles/calathea/files/calathea.service
Normal file
13
roles/calathea/files/calathea.service
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
[Unit]
|
||||
Description=Simple plant tracker
|
||||
After=docker.service
|
||||
Requires=docker.service
|
||||
|
||||
[Service]
|
||||
Type=exec
|
||||
WorkingDirectory=/etc/calathea
|
||||
ExecStart=/usr/bin/docker compose up
|
||||
ExecStop=/usr/bin/docker compose down
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
8
roles/calathea/files/compose.yml
Normal file
8
roles/calathea/files/compose.yml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
services:
|
||||
app:
|
||||
image: 'git.rustybever.be/chewing_bever/calathea:latest'
|
||||
|
||||
ports:
|
||||
- '8013:8000'
|
||||
volumes:
|
||||
- '/mnt/data1/calathea/data:/data'
|
||||
5
roles/calathea/handlers/main.yml
Normal file
5
roles/calathea/handlers/main.yml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
- name: 'restart calathea'
|
||||
ansible.builtin.service:
|
||||
name: 'calathea'
|
||||
state: 'restarted'
|
||||
68
roles/calathea/tasks/main.yml
Normal file
68
roles/calathea/tasks/main.yml
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
---
|
||||
- name: Ensure data directory is present
|
||||
ansible.builtin.file:
|
||||
path: '/mnt/data1/calathea'
|
||||
state: directory
|
||||
mode: '0755'
|
||||
owner: 'root'
|
||||
group: 'root'
|
||||
|
||||
- name: Ensure data subvolumes are present
|
||||
community.general.btrfs_subvolume:
|
||||
name: '/calathea/{{ item }}'
|
||||
loop:
|
||||
- 'data'
|
||||
|
||||
- name: Ensure subvolume permissions are correct
|
||||
ansible.builtin.file:
|
||||
path: "/mnt/data1/calathea/{{ item }}"
|
||||
state: directory
|
||||
mode: '0755'
|
||||
owner: '82'
|
||||
group: '82'
|
||||
loop:
|
||||
- 'data'
|
||||
|
||||
- name: Ensure configuration directory is present
|
||||
ansible.builtin.file:
|
||||
path: '/etc/calathea'
|
||||
state: directory
|
||||
mode: '0755'
|
||||
|
||||
- name: Ensure compose file is present
|
||||
ansible.builtin.copy:
|
||||
src: 'compose.yml'
|
||||
dest: '/etc/calathea/compose.yml'
|
||||
mode: '0644'
|
||||
owner: 'root'
|
||||
group: 'root'
|
||||
notify: 'restart calathea'
|
||||
|
||||
- name: Ensure backup scripts are present
|
||||
ansible.builtin.copy:
|
||||
src: "calathea.{{ item }}.backup.sh"
|
||||
dest: "/etc/backups/calathea.{{ item }}.backup.sh"
|
||||
owner: 'root'
|
||||
group: 'root'
|
||||
mode: '0644'
|
||||
loop:
|
||||
- 'data'
|
||||
|
||||
- name: Ensure service file is present
|
||||
ansible.builtin.copy:
|
||||
src: 'calathea.service'
|
||||
dest: '/lib/systemd/system/calathea.service'
|
||||
owner: 'root'
|
||||
group: 'root'
|
||||
mode: '0644'
|
||||
register: res
|
||||
|
||||
- name: systemd-reload
|
||||
ansible.builtin.systemd_service:
|
||||
daemon_reload: true
|
||||
when: 'res.changed'
|
||||
|
||||
- name: Ensure calathea service is enabled
|
||||
ansible.builtin.service:
|
||||
name: 'calathea'
|
||||
enabled: true
|
||||
Loading…
Add table
Add a link
Reference in a new issue