fix(ansible): optimize root trim policy

Co-authored-by: Junie <junie@jetbrains.com>
This commit is contained in:
ja
2026-04-02 16:15:32 +02:00
co-authored by Junie
parent bbdcd43e01
commit 6ff790fd4b
3 changed files with 116 additions and 0 deletions
+39
View File
@@ -57,6 +57,45 @@
become: yes
tags: [swap, optimization]
- name: Check current root mount options
command:
argv:
- findmnt
- -no
- OPTIONS
- /
register: root_mount_options
changed_when: false
tags: [filesystem, optimization, trim]
- name: Ensure root filesystem uses periodic TRIM settings in fstab
mount:
path: /
src: "UUID={{ root_filesystem_uuid }}"
fstype: ext4
opts: "{{ root_filesystem_mount_opts }}"
passno: 1
dump: 0
state: present
become: yes
tags: [filesystem, optimization, trim]
- name: Reload systemd after fstab updates
systemd:
daemon_reload: yes
changed_when: false
become: yes
tags: [filesystem, optimization, trim]
- name: Remount root filesystem without continuous discard
mount:
path: /
opts: "{{ root_filesystem_mount_opts }},nodiscard"
state: remounted
when: "'discard' in (root_mount_options.stdout.split(','))"
become: yes
tags: [filesystem, optimization, trim]
- name: Optimize kernel parameters
sysctl:
name: "{{ item.name }}"