32 lines
951 B
YAML
32 lines
951 B
YAML
- name: Setup scrub units
|
|
ansible.builtin.copy:
|
|
src: "{{ item }}"
|
|
dest: /etc/systemd/system/
|
|
mode: "0644"
|
|
owner: root
|
|
group: root
|
|
with_items:
|
|
- 'btrfs-scrub@.service'
|
|
- 'btrfs-scrub@.timer'
|
|
notify: daemon_reload
|
|
become: true
|
|
|
|
- name: Run pending handlers
|
|
ansible.builtin.meta: flush_handlers
|
|
|
|
- name: Determine btrfs mounts
|
|
ansible.builtin.set_fact:
|
|
btrfs_mounts: "{{ ansible_facts['mounts'] | selectattr('fstype', 'equalto', 'btrfs') | map(attribute='mount') | list }}"
|
|
|
|
- name: Determine systemd-friendly refs for BTRFS mount points
|
|
ansible.builtin.command: "systemd-escape -p -- {{ item }}"
|
|
register: sanitized_mounts
|
|
loop: "{{ btrfs_mounts }}"
|
|
changed_when: false
|
|
|
|
- name: Ensure the scrub timer is enabled for discovered BTRFS filesystems
|
|
ansible.builtin.systemd:
|
|
name: "btrfs-scrub@{{ item.stdout }}.timer"
|
|
enabled: true
|
|
with_items: "{{ sanitized_mounts.results }}"
|
|
become: true
|