66 lines
2.1 KiB
YAML
66 lines
2.1 KiB
YAML
---
|
|
- name: Setup BTRFS
|
|
block:
|
|
- name: Create btrfs filesystem in main volume
|
|
community.general.filesystem:
|
|
dev: "{{ partitioning_root_device }}"
|
|
fstype: btrfs
|
|
force: true
|
|
opts: >-
|
|
{{
|
|
'-K'
|
|
if (partitioning_luks_enabled | bool)
|
|
and not ('discard' in (partitioning_luks_options | lower))
|
|
else omit
|
|
}}
|
|
|
|
- name: Prepare BTRFS Subvolume
|
|
ansible.posix.mount:
|
|
path: /mnt
|
|
src: "{{ partitioning_root_device }}"
|
|
fstype: btrfs
|
|
opts: rw,relatime,compress=zstd:15,ssd,space_cache=v2,discard=async
|
|
state: mounted
|
|
|
|
- name: Enable quotas on Btrfs filesystem
|
|
ansible.builtin.command: btrfs quota enable /mnt
|
|
register: partitioning_btrfs_quota_result
|
|
changed_when: false
|
|
|
|
- name: Make root subvolumes
|
|
when: cis | bool or item.subvol not in ['var_log_audit']
|
|
ansible.builtin.command: btrfs su cr /mnt/{{ '@' if item.subvol == 'root' else '@' + item.subvol }}
|
|
args:
|
|
creates: /mnt/{{ '@' if item.subvol == 'root' else '@' + item.subvol }}
|
|
loop:
|
|
- {subvol: root}
|
|
- {subvol: swap}
|
|
- {subvol: home}
|
|
- {subvol: var}
|
|
- {subvol: pkg}
|
|
- {subvol: var_log}
|
|
- {subvol: var_log_audit}
|
|
register: partitioning_btrfs_subvol_result
|
|
|
|
- name: Set quotas for subvolumes
|
|
when: cis | bool
|
|
ansible.builtin.command: btrfs qgroup limit {{ item.quota }} /mnt/{{ '@' if item.subvol == 'root' else '@' + item.subvol }}
|
|
loop:
|
|
- {subvol: home, quota: 2G}
|
|
register: partitioning_btrfs_qgroup_result
|
|
changed_when: false
|
|
|
|
- name: Create a Btrfs swap file
|
|
ansible.builtin.command: >-
|
|
btrfs filesystem mkswapfile --size {{ partitioning_swap_size_gb }}g --uuid clear /mnt/@swap/swapfile
|
|
args:
|
|
creates: /mnt/@swap/swapfile
|
|
register: partitioning_btrfs_swap_result
|
|
|
|
- name: Unmount Partition
|
|
ansible.posix.mount:
|
|
path: /mnt
|
|
src: "{{ partitioning_root_device }}"
|
|
fstype: btrfs
|
|
state: unmounted
|