homelab/roles/nefarious/tasks/main.yml

57 lines
1.3 KiB
YAML

---
- name: Ensure data directory is present
ansible.builtin.file:
path: '/mnt/data1/nefarious'
state: directory
mode: '0755'
owner: 'root'
group: 'root'
- name: Ensure data subvolumes are present
community.general.btrfs_subvolume:
name: '/nefarious/{{ item }}'
with_items:
- 'jackett'
- 'nefarious'
- name: Ensure subvolume permissions are correct
ansible.builtin.file:
path: "/mnt/data1/nefarious/{{ item.dir }}"
state: directory
mode: '0755'
owner: "{{ item.owner }}"
group: "{{ item.group }}"
loop:
- dir: 'nefarious'
owner: 1000
group: 1000
- name: Ensure configuration directory is present
ansible.builtin.file:
path: '/etc/nefarious'
state: directory
mode: '0755'
- name: Ensure Transmission config file is present
ansible.builtin.copy:
src: 'transmission-settings.json'
dest: '/etc/nefarious/transmission-settings.json'
owner: 'root'
group: 'root'
mode: '0644'
- name: Ensure compose file is present
ansible.builtin.template:
src: 'compose.yml.j2'
dest: '/etc/nefarious/compose.yml'
mode: '0644'
owner: 'root'
group: 'root'
register: res
- name: Ensure stack is deployed
ansible.builtin.shell:
chdir: '/etc/nefarious'
cmd: 'docker compose up -d --remove-orphans'
when: 'res.changed'