Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions ansible/tasks/setup-postgres.yml
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,29 @@


# Reload
- name: Create a SystemD override dir for PostgreSQL
ansible.builtin.file:
group: 'root'
mode: '0755'
owner: 'root'
path: '/etc/systemd/system/postgresql.service.d'
state: 'directory'
become: true

- name: Ensure PostgrfeSQL starts after tuned
become: true
community.general.ini_file:
create: true
group: 'root'
mode: '0644'
no_extra_spaces: true
option: 'After'
owner: 'root'
path: '/etc/systemd/system/postgresql.service.d/overrides.conf'
section: 'Unit'
state: 'present'
value: 'tuned.service'

- name: System - systemd reload
ansible.builtin.systemd_service:
daemon_reload: true
Expand Down
71 changes: 63 additions & 8 deletions ansible/tasks/setup-tuned.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,65 @@
- name: Install tuned
ansible.builtin.apt:
force_apt_get: true
name: tuned
policy_rc_d: 101
state: 'present'
update_cache: true
become: true
- name: INstall and configure tuned when stage2_nix
when:
- stage2_nix
block:
- name: Install tuned
ansible.builtin.apt:
force_apt_get: true
name: 'tuned'
policy_rc_d: 101
state: 'present'
update_cache: true
become: true

- name: Create a tuned profile directory
ansible.builtin.file:
group: 'root'
mode: '0755'
owner: 'root'
path: '/etc/tuned/postgresql'
state: 'directory'
become: true

- name: Create a tuned profile
community.general.ini_file:
create: true
group: 'root'
mode: '0644'
no_extra_spaces: true
option: 'summary'
path: '/etc/tuned/postgresql/tuned.conf'
section: 'main'
state: 'present'
value: 'Tuned profile for PostgreSQL'
become: true

- name: Disable Transparent Huge Pages (THP)
community.general.ini_file:
create: true
group: 'root'
mode: '0644'
no_extra_spaces: true
option: "{{ thp_item['option'] }}"
path: '/etc/tuned/postgresql/tuned.conf'
section: "{{ thp_item['section'] }}"
state: 'present'
value: "{{ thp_item['value'] }}"
become: true
loop:
- { section: 'bootloader', option: 'cmdline', value: 'transparent_hugepages=never' }
- { section: 'vm', option: 'transparent_hugepages', value: 'never' }
loop_control:
loop_var: 'thp_item'

- name: Activate the tuned service
ansible.builtin.systemd_service:
daemon_reload: true
enabled: true
name: 'tuned'
state: 'restarted'
become: true

- name: Activate the PostgreSQL tuned profile
ansible.builtin.command:
cmd: tuned-adm profile postgresql
become: true
Loading