mirror of
https://github.com/status-im/ansible-role-mongodb.git
synced 2025-01-12 06:24:14 +00:00
Merge pull request #139 from gaetanfl/disable_thp
Add a variable to disable transparent hugepages
This commit is contained in:
commit
53d39d8347
@ -43,6 +43,9 @@ mongodb_pymongo_pip_version: 3.6.1 # Choose PyMong version to inst
|
||||
mongodb_user_update_password: "on_create" # MongoDB user password update default policy
|
||||
mongodb_manage_service: true
|
||||
|
||||
# Disable transparent hugepages on systemd debian based installations
|
||||
mongodb_disable_transparent_hugepages: false
|
||||
|
||||
mongodb_user: "{{ 'mongod' if ('RedHat' == ansible_os_family) else 'mongodb' }}"
|
||||
mongodb_uid:
|
||||
mongodb_gid:
|
||||
|
@ -14,6 +14,8 @@ mongodb_pymongo_pip_version: 3.6.1
|
||||
mongodb_user_update_password: "on_create" # MongoDB user password update default policy
|
||||
mongodb_manage_service: true
|
||||
|
||||
mongodb_disable_transparent_hugepages: false
|
||||
|
||||
mongodb_user: "{{ 'mongod' if ('RedHat' == ansible_os_family) else 'mongodb' }}"
|
||||
mongodb_uid:
|
||||
mongodb_gid:
|
||||
|
10
files/disable-transparent-hugepages.init
Normal file
10
files/disable-transparent-hugepages.init
Normal file
@ -0,0 +1,10 @@
|
||||
[Unit]
|
||||
Description="Disable transparent hugepages"
|
||||
Before=mongodb.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/opt/disable-transparent-hugepages.sh
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
10
files/disable-transparent-hugepages.sh
Normal file
10
files/disable-transparent-hugepages.sh
Normal file
@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ -d /sys/kernel/mm/transparent_hugepage ]; then
|
||||
thp_path=/sys/kernel/mm/transparent_hugepage
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo 'never' > ${thp_path}/enabled
|
||||
echo 'never' > ${thp_path}/defrag
|
22
tasks/disable_transparent_hugepages.yml
Normal file
22
tasks/disable_transparent_hugepages.yml
Normal file
@ -0,0 +1,22 @@
|
||||
- name: Install disable transparent hugepages helper
|
||||
copy:
|
||||
src: disable-transparent-hugepages.sh
|
||||
dest: /opt/disable-transparent-hugepages.sh
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0700
|
||||
|
||||
- name: Create disable transparent hugepages init file
|
||||
copy:
|
||||
src: disable-transparent-hugepages.init
|
||||
dest: /etc/systemd/system/disable-transparent-hugepages.init
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
|
||||
- name: Enable init file
|
||||
systemd:
|
||||
name: disable-transparent-hugepages
|
||||
daemon-reload: yes
|
||||
enabled: yes
|
||||
state: started
|
@ -11,6 +11,12 @@
|
||||
mongodb_is_systemd: "{{ sbin_init.stat.islnk is defined and sbin_init.stat.islnk }}"
|
||||
mongodb_major_version: "{{ mongodb_version[0:3] }}"
|
||||
|
||||
- name: Disable transparent huge pages on systemd systems
|
||||
include_tasks: disable_transparent_hugepages.yml
|
||||
when:
|
||||
- mongodb_disable_transparent_hugepages
|
||||
- mongodb_is_systemd
|
||||
|
||||
- name: Add APT key
|
||||
apt_key:
|
||||
keyserver: "{{ mongodb_apt_keyserver }}"
|
||||
|
Loading…
x
Reference in New Issue
Block a user