homelab/roles/photoview/tasks/main.yml

70 lines
1.5 KiB
YAML
Raw Normal View History

2024-10-01 14:28:28 +02:00
---
- name: Ensure data directory is present
ansible.builtin.file:
path: '/mnt/data1/photoview'
state: directory
mode: '0755'
owner: 'root'
group: 'root'
- name: Ensure data subvolumes are present
community.general.btrfs_subvolume:
name: '/photoview/{{ item }}'
loop:
- 'postgres'
- 'cache'
- name: Ensure subvolume permissions are correct
ansible.builtin.file:
path: "/mnt/data1/photoview/{{ item }}"
state: directory
mode: '0755'
owner: '999'
group: '999'
loop:
- 'cache'
- name: Ensure configuration directory is present
ansible.builtin.file:
path: '/etc/photoview'
state: directory
mode: '0755'
- name: Ensure compose file is present
ansible.builtin.copy:
src: 'compose.yml'
dest: '/etc/photoview/compose.yml'
mode: '0644'
owner: 'root'
group: 'root'
notify: 'restart photoview'
- name: Ensure backup scripts are present
ansible.builtin.copy:
src: "photoview.{{ item }}.backup.sh"
dest: "/etc/backups/photoview.{{ item }}.backup.sh"
owner: 'root'
group: 'root'
mode: '0644'
loop:
- 'postgres'
- name: Ensure service file is present
ansible.builtin.copy:
src: 'photoview.service'
dest: '/lib/systemd/system/photoview.service'
owner: 'root'
group: 'root'
mode: '0644'
register: res
- name: systemd-reload
ansible.builtin.systemd_service:
daemon_reload: true
when: 'res.changed'
- name: Ensure photoview service is enabled
ansible.builtin.service:
name: 'photoview'
enabled: true