2024-03-19 23:02:50 +01:00
|
|
|
---
|
|
|
|
- name: Setup BTRFS
|
|
|
|
block:
|
|
|
|
- name: Create btrfs filesystem in main volume
|
2024-07-11 22:20:45 +02:00
|
|
|
community.general.filesystem:
|
|
|
|
dev: "{{ install_drive }}{{ main_partition_suffix }}"
|
2024-03-19 23:02:50 +01:00
|
|
|
fstype: btrfs
|
2024-07-11 22:09:58 +02:00
|
|
|
force: true
|
2024-03-19 23:02:50 +01:00
|
|
|
|
|
|
|
- name: Prepare BTRFS Subvolume
|
2024-07-11 22:20:45 +02:00
|
|
|
ansible.posix.mount:
|
2024-03-19 23:02:50 +01:00
|
|
|
path: /mnt
|
2024-07-11 22:20:45 +02:00
|
|
|
src: "{{ install_drive }}{{ main_partition_suffix }}"
|
2024-03-19 23:02:50 +01:00
|
|
|
fstype: btrfs
|
|
|
|
opts: rw,relatime,compress=zstd:15,ssd,space_cache=v2,discard=async
|
|
|
|
state: mounted
|
|
|
|
|
|
|
|
- name: Enable quotas on Btrfs filesystem
|
2024-07-11 22:20:45 +02:00
|
|
|
ansible.builtin.command: btrfs quota enable /mnt
|
2024-10-28 19:20:05 +01:00
|
|
|
changed_when: result.rc == 0
|
|
|
|
register: result
|
2024-03-19 23:02:50 +01:00
|
|
|
|
|
|
|
- name: Make root subvolumes
|
2024-10-28 17:17:24 +01:00
|
|
|
when: cis | bool or item.subvol not in ['var_log', 'var_log_audit']
|
2024-07-11 22:20:45 +02:00
|
|
|
ansible.builtin.command: btrfs su cr /mnt/{{ '@' if item.subvol == 'root' else '@' + item.subvol }}
|
2024-10-28 19:20:05 +01:00
|
|
|
changed_when: result.rc == 0
|
|
|
|
register: result
|
2024-03-19 23:02:50 +01:00
|
|
|
loop:
|
|
|
|
- { subvol: root }
|
|
|
|
- { subvol: home }
|
|
|
|
- { subvol: var }
|
|
|
|
- { subvol: var_log }
|
|
|
|
- { subvol: var_log_audit }
|
|
|
|
|
|
|
|
- name: Set quotas for subvolumes
|
2024-10-28 17:17:24 +01:00
|
|
|
when: cis | bool or item.subvol not in ['var_log', 'var_log_audit']
|
2024-07-11 22:20:45 +02:00
|
|
|
ansible.builtin.command: btrfs qgroup limit {{ item.quota }} /mnt/{{ '@' if item.subvol == 'root' else '@' + item.subvol }}
|
2024-10-28 19:20:05 +01:00
|
|
|
changed_when: result.rc == 0
|
|
|
|
register: result
|
2024-03-19 23:02:50 +01:00
|
|
|
loop:
|
2024-07-11 22:20:45 +02:00
|
|
|
- { subvol: home, quota: 2G }
|
2024-03-19 23:02:50 +01:00
|
|
|
|
|
|
|
- name: Unmount Partition
|
2024-07-11 22:20:45 +02:00
|
|
|
ansible.posix.mount:
|
2024-03-19 23:02:50 +01:00
|
|
|
path: /mnt
|
2024-07-11 22:20:45 +02:00
|
|
|
src: "{{ install_drive }}{{ main_partition_suffix }}"
|
2024-03-19 23:02:50 +01:00
|
|
|
fstype: btrfs
|
2024-05-21 14:20:28 +02:00
|
|
|
state: unmounted
|