fix(ansible): optimize root trim policy
Co-authored-by: Junie <junie@jetbrains.com>
This commit is contained in:
@@ -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 }}"
|
||||
|
||||
Reference in New Issue
Block a user