Skip to content

Commit 05cecbb

Browse files
authored
feat(ansible): add fs.file-max and fs.aio-max-nr to tuned profile (#2228)
* feat(ansible): add fs.file-max and fs.aio-max-nr to tuned profile This update includes the addition of two key sysctl options to the PostgreSQL tuned profile: - fs.file-max: increased to 312139770 - fs.aio-max-nr: increased to 1048576 These changes are aimed at improving system-level performance and resource availability for PostgreSQL. Minor formatting and linting adjustments are also included to align with project standards. * ci: trigger CI workflow with empty commit
1 parent af89221 commit 05cecbb

1 file changed

Lines changed: 57 additions & 42 deletions

File tree

ansible/tasks/setup-tuned.yml

Lines changed: 57 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
- name: tuned - Install and configure tuned
1+
- name: 'tuned - Install and configure tuned' # noqa: name[casing]
22
when:
33
- (stage2_nix or nixpkg_mode or debpkg_mode)
44
block:
5-
- name: tuned - Install tuned
5+
- name: 'tuned - Install tuned' # noqa: name[casing]
66
ansible.builtin.apt:
77
force_apt_get: true
88
name: 'tuned'
@@ -11,7 +11,7 @@
1111
update_cache: true
1212
become: true
1313

14-
- name: tuned - Create a tuned profile directory
14+
- name: 'tuned - Create a tuned profile directory' # noqa: name[casing]
1515
ansible.builtin.file:
1616
group: 'root'
1717
mode: '0755'
@@ -20,7 +20,7 @@
2020
state: 'directory'
2121
become: true
2222

23-
- name: tuned - Create a profile symlink for older tuned versions
23+
- name: 'tuned - Create a profile symlink for older tuned versions' # noqa: name[casing]
2424
ansible.builtin.file:
2525
force: true
2626
group: 'root'
@@ -31,8 +31,8 @@
3131
state: 'link'
3232
become: true
3333

34-
- name: tuned - Create a tuned profile
35-
ansible.builtin.ini_file:
34+
- name: 'tuned - Create a tuned profile' # noqa: name[casing]
35+
community.general.ini_file:
3636
create: true
3737
group: 'root'
3838
mode: '0644'
@@ -44,8 +44,8 @@
4444
value: 'Tuned profile for PostgreSQL'
4545
become: true
4646

47-
- name: tuned - Disable Transparent Huge Pages (THP)
48-
ansible.builtin.ini_file:
47+
- name: 'tuned - Disable Transparent Huge Pages (THP)' # noqa: name[casing]
48+
community.general.ini_file:
4949
create: true
5050
group: 'root'
5151
mode: '0644'
@@ -57,25 +57,21 @@
5757
value: 'never'
5858
become: true
5959

60-
- name: tuned - Configure performance
61-
ansible.builtin.ini_file:
60+
- name: 'tuned - Configure performance' # noqa: name[casing]
61+
community.general.ini_file:
6262
create: true
6363
group: 'root'
6464
mode: '0644'
6565
no_extra_spaces: true
66-
option: "{{ perf_item['option'] }}"
66+
option: 'governor'
6767
path: '/etc/tuned/profiles/postgresql/tuned.conf'
68-
section: "{{ perf_item['section'] }}"
68+
section: 'cpu'
6969
state: 'present'
70-
value: "{{ perf_item['value'] }}"
70+
value: 'performance'
7171
become: true
72-
loop:
73-
- { option: 'governor', section: 'cpu', value: 'performance' }
74-
loop_control:
75-
loop_var: 'perf_item'
7672

77-
- name: tuned - Configure Intel CPUs for maximum performance
78-
ansible.builtin.ini_file:
73+
- name: 'tuned - Configure Intel CPUs for maximum performance' # noqa: name[casing]
74+
community.general.ini_file:
7975
create: true
8076
group: 'root'
8177
mode: '0644'
@@ -87,15 +83,19 @@
8783
value: "{{ intel_item['value'] }}"
8884
become: true
8985
loop:
90-
- { option: 'energy_perf_bias', section: 'cpu', value: 'performance' }
91-
- { option: 'min_perf_pct', section: 'cpu', value: '100' }
86+
- option: 'energy_perf_bias'
87+
section: 'cpu'
88+
value: 'performance'
89+
- option: 'min_perf_pct'
90+
section: 'cpu'
91+
value: '100'
9292
loop_control:
9393
loop_var: 'intel_item'
9494
when:
9595
- ansible_facts['processor'][0] is search('GenuineIntel', ignorecase=True)
9696

97-
- name: tuned - Set sysctl parameters
98-
ansible.builtin.ini_file:
97+
- name: 'tuned - Set sysctl parameters' # noqa: name[casing]
98+
community.general.ini_file:
9999
create: true
100100
group: 'root'
101101
mode: '0644'
@@ -107,17 +107,27 @@
107107
value: "{{ sysctl_item['value'] }}"
108108
become: true
109109
loop:
110-
- { option: 'net.ipv4.tcp_keepalive_intvl', value: '60' }
111-
- { option: 'net.ipv4.tcp_keepalive_time', value: '1800' }
112-
- { option: 'net.ipv4.ip_local_reserved_ports', value: '3000,3001,8085,9122,9187,9999' }
113-
- { option: 'net.ipv4.ip_local_port_range', value: '1025 65000' }
114-
- { option: 'vm.panic_on_oom', value: '1' }
115-
- { option: 'net.core.somaxconn', value: '16834' }
110+
- option: 'fs.aio-max-nr'
111+
value: '1048576'
112+
- option: 'fs.file-max'
113+
value: '312139770'
114+
- option: 'net.core.somaxconn'
115+
value: '16834'
116+
- option: 'net.ipv4.ip_local_port_range'
117+
value: '1025 65000'
118+
- option: 'net.ipv4.ip_local_reserved_ports'
119+
value: '3000,3001,8085,9122,9187,9999'
120+
- option: 'net.ipv4.tcp_keepalive_intvl'
121+
value: '60'
122+
- option: 'net.ipv4.tcp_keepalive_time'
123+
value: '1800'
124+
- option: 'vm.panic_on_oom'
125+
value: '1'
116126
loop_control:
117127
loop_var: 'sysctl_item'
118128

119-
- name: tuned - Set kernel.panic=10
120-
ansible.builtin.ini_file:
129+
- name: 'tuned - Set kernel.panic=10' # noqa: name[casing]
130+
community.general.ini_file:
121131
create: true
122132
group: 'root'
123133
mode: '0644'
@@ -131,12 +141,12 @@
131141
when:
132142
- (debpkg_mode or nixpkg_mode)
133143

134-
- name: tuned - Enable zswap if swap is present
144+
- name: 'tuned - Enable zswap if swap is present' # noqa: name[casing]
135145
when:
136146
- ansible_facts['swaptotal_mb'] > 0
137147
block:
138-
- name: tuned - Decrease the kernel swappiness
139-
ansible.builtin.ini_file:
148+
- name: 'tuned - Decrease the kernel swappiness' # noqa: name[casing]
149+
community.general.ini_file:
140150
create: true
141151
group: 'root'
142152
mode: '0644'
@@ -148,33 +158,38 @@
148158
value: '10'
149159
become: true
150160

151-
- name: tuned - Load zstd compressor module
161+
- name: 'tuned - Load zstd compressor module' # noqa: name[casing]
152162
community.general.modprobe:
153163
name: 'zstd'
154164
persistent: 'present'
155165
state: 'present'
156166
become: true
157167

158-
- name: tuned - Configure and enable zswap
168+
- name: 'tuned - Configure and enable zswap' # noqa: name[casing]
159169
ansible.builtin.shell:
160170
cmd: "echo {{ zswap_item['value'] }} > /sys/module/zswap/parameters/{{ zswap_item['param'] }}"
171+
changed_when: true
161172
loop:
162-
- { param: 'compressor', value: 'zstd' }
163-
- { param: 'max_pool_percent', value: '10' }
164-
- { param: 'zpool', value: 'zsmalloc' }
165-
- { param: 'enabled', value: 'Y' }
173+
- param: 'compressor'
174+
value: 'zstd'
175+
- param: 'max_pool_percent'
176+
value: '10'
177+
- param: 'zpool'
178+
value: 'zsmalloc'
179+
- param: 'enabled'
180+
value: 'Y'
166181
loop_control:
167182
loop_var: 'zswap_item'
168183

169-
- name: tuned - Activate the tuned service
184+
- name: 'tuned - Activate the tuned service' # noqa: name[casing]
170185
ansible.builtin.systemd_service:
171186
daemon_reload: true
172187
enabled: true
173188
name: 'tuned'
174189
state: "{{ 'restarted' if stage2_nix else 'stopped' }}"
175190
become: true
176191

177-
- name: tuned - Activate the PostgreSQL tuned profile
192+
- name: 'tuned - Activate the PostgreSQL tuned profile' # noqa: name[casing]
178193
ansible.builtin.command:
179194
cmd: 'tuned-adm profile postgresql'
180195
become: true

0 commit comments

Comments
 (0)