You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ansible-homelab/roles/setup_mergerfs/tasks/main.yml

54 lines
1.4 KiB
YAML

---
- name: Mount Volumes
ansible.builtin.mount:
path: '{{ item.path }}'
src: UUID={{ item.uuid }}
fstype: ext4
state: mounted
opts: defaults,nofail
loop: '{{ devices }}'
register: volume_out
- name: Display volumes.
ansible.builtin.debug:
var: "{{ volume_out }}"
verbosity: 3
# tasks file for setup_mergerfs
- name: Create Mergerfs directory
ansible.builtin.file:
path: /mnt/mergerfs
state: directory
owner: cianhatton
group: cianhatton
mode: 0775
register: directory_creation
# Ensure the actual folder can't be written to only when it has just been created.
- name: Make /mnt/mergerfs immutable
ansible.builtin.command: chattr +i /mnt/mergerfs
when: directory_creation.diff.after.path != directory_creation.diff.before.path
- name: Create Mergerfs pool
ansible.builtin.include_role:
name: sprat.mergerfs
vars:
mergerfs_mounts: '{{ mounts }}'
- name: Download mergerfs balance tool.
ansible.builtin.get_url:
url: https://raw.githubusercontent.com/trapexit/mergerfs-tools/master/src/mergerfs.balance
dest: /usr/local/bin/mergerfs.balance
mode: 0755
- name: Add a cron job to balance mergerfs.
ansible.builtin.cron:
name: Balance mergerfs media.
user: "{{ homelab_user }}"
minute: 0
hour: 5
weekday: 0
job: /usr/local/bin/mergerfs.balance /mnt/mergerfs
state: present
cron_file: balance_mergerfs