| Server IP : 85.214.239.14 / Your IP : 216.73.216.60 Web Server : Apache/2.4.65 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Mon Sep 30 15:36:27 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 8.2.29 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /lib/python3/dist-packages/ansible_collections/community/mongodb/roles/mongodb_linux/tasks/ |
Upload File : |
---
# tasks file for mongodb_linux
- name: Include OS-specific vars
include_vars:
file: "{{ lookup('first_found', params) }}"
vars:
params:
paths:
- "vars"
files:
- "{{ ansible_facts.distribution }}-{{ ansible_facts.distribution_version }}.yml"
- "{{ ansible_facts.os_family }}-{{ ansible_facts.distribution_major_version }}.yml"
- "{{ ansible_facts.distribution }}.yml"
- "{{ ansible_facts.os_family }}.yml"
- default.yml
tags:
- "vars"
- name: See if we are in docker
when:
- "ansible_facts.virtualization_role == 'guest'"
- not in_docker # defined in vars
block:
- name: Check if we are in docker (based on /.dockerenv file)
stat:
path: /.dockerenv
register: dockerenv_file
tags:
- "ci"
- name: Update in_docker var
set_fact:
in_docker: "{{ dockerenv_file.stat.exists }}"
tags:
- "ci"
# Tasks based on: https://docs.mongodb.com/manual/administration/production-notes/
- name: Set swappiness
ansible.posix.sysctl:
name: vm.swappiness
value: "{{ swappiness }}"
state: present
tags:
- "linux"
- "setup"
- name: Ensure ntp service is installed
package:
name: "{{ ntp_package }}"
state: present
register: _pkg
until: _pkg is succeeded
retries: 5
tags:
- "linux"
- "setup"
- "pkg"
- name: Update perms on chrony pid dir on RedHat 8
file:
path: /run/chrony/
owner: root
group: root
state: directory
when:
- ansible_facts.os_family == "RedHat"
- ansible_facts.distribution_major_version|int >= 8
tags:
- "linux"
- "setup"
- "redhat"
- name: Ensure ntp service is configured
service:
name: "{{ ntp_service }}"
state: started
enabled: yes
tags:
- "linux"
- "setup"
- "service"
- name: Ensure GNU C Library is the latest
package:
name: "{{ gnu_c_lib }}"
state: latest
register: _pkg
until: _pkg is succeeded
retries: 5
tags:
- "linux"
- "setup"
- "pkg"
- name: Ensure NUMA zone reclaim is disabled
ansible.posix.sysctl:
name: vm.zone_reclaim_mode
value: "0"
state: present
reload: yes
when: not in_docker|bool
tags:
- "linux"
- "setup"
# https://docs.mongodb.com/manual/tutorial/transparent-huge-pages/
- name: Ensure thp-disable service exists
copy:
src: thp-disable.service
dest: /etc/systemd/system/disable-transparent-huge-pages.service
owner: root
group: root
register: thp
tags:
- "linux"
- "setup"
- name: Reload systemd
systemd:
daemon_reexec: yes
when: thp is changed
tags:
- "linux"
- "setup"
- "service"
- name: Check if disable-transparent-huge-pages service is already run
shell: cat /sys/kernel/mm/transparent_hugepage/enabled | grep -o '[never]'
register: _huge_page_status
ignore_errors: yes
changed_when: _huge_page_status.stdout == ""
tags:
- "linux"
- "service"
- "setup"
- name: Enable disable-transparent-huge-pages service
service:
name: disable-transparent-huge-pages
state: started
enabled: yes
when: (not in_docker|bool) and (_huge_page_status.stdout == "")
tags:
- "linux"
- "service"
- "setup"
# Tasks based on: https://docs.mongodb.com/manual/reference/ulimit/
- name: Set pam limits (nproc and nofile)
community.general.pam_limits:
domain: "{{ item[0] }}"
limit_type: "{{ item[1] }}"
limit_item: "{{ item[2] }}"
value: "{{ item[3] }}"
with_nested:
- ["root", "mongodb"]
- ["hard", "soft"]
- ["nproc", "nofile"]
- ["{{ nproc_and_nofile_limit }}"]
tags:
- "linux"
- "setup"
- name: Set pam limits (memlock)
community.general.pam_limits:
domain: "{{ item[0] }}"
limit_type: "{{ item[1] }}"
limit_item: "{{ item[2] }}"
value: "{{ item[3] }}"
with_nested:
- ["root", "mongodb"]
- ["hard", "soft"]
- ["memlock"]
- ["{{ memlock_limit }}"]
tags:
- "linux"
- "setup"
# Other tuning settings
- name: Set sysctl values
ansible.posix.sysctl:
name: "{{ item['name'] }}"
value: "{{ item['value'] }}"
state: present
loop:
# TODO: These may need to be configurable for different usage patterns.
- { "name": "vm.dirty_ratio", "value": "15" }
- { "name": "vm.dirty_background_ratio", "value": "5" }
- { "name": "net.core.somaxconn ", "value": "4096" }
- { "name": "net.ipv4.tcp_fin_timeout", "value": "30" }
- { "name": "net.ipv4.tcp_keepalive_intvl", "value": "30" }
- { "name": "net.ipv4.tcp_keepalive_time", "value": "120" }
- { "name": "net.ipv4.tcp_max_syn_backlog ", "value": "4096" }
tags:
- "linux"
- "setup"