add 'btrfs' role, move vars to host_vars
This commit is contained in:
parent
13da397c76
commit
55d37e10ac
7 changed files with 127 additions and 45 deletions
32
roles/btrfs/tasks/main.yml
Normal file
32
roles/btrfs/tasks/main.yml
Normal file
|
@ -0,0 +1,32 @@
|
|||
- 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
|
Loading…
Add table
Add a link
Reference in a new issue