Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to increase limit for open processes and files using ansible

I am setting up a MySQL server, and I was told to increase the ulimit for the number of open processes.

I ran

- name: "increase limit for the number of open files"
  shell: "ulimit -n 64000"
- name: "increase limit for the number of open processes"
  shell: "ulimit -u 64000"

on the ansible-playbook, but not only does it throw error "Illegal option -u", but also open files limit (-n) doesn't seem to get modified. (I ran ulimit -n on the server but it stays the same)

What is the recommended way of increasing these limits, and how should I do it in Ansible?

I saw pam_limits module. Should I use this module to modify nproc and nofile? If so, which domain?

Thank you.

like image 463
Eric Na Avatar asked Jul 01 '16 23:07

Eric Na


People also ask

Should I run Ansible as root?

Note: Ansible does not require root access; however, if you choose to use a non-root user, you must configure the appropriate sudo permissions for the tasks you want to accomplish. You will be prompted for the root password for servera, which will allow your SSH key to be installed on the remote host.

Which Ansible modules can be used to modify a file's content?

Ansible ini_file module This module is a life-saver when modifying ini type files with many changes.

Is Ansible slow?

You are right that Ansible is slow (as a hell). It is by design. They decided to copy python code through ssh to remote hosts to perform operations: code need to be base64 encoded/decoded - CPU load/time/bloated network.


1 Answers

Since Ansible 2.0.0, a new official module supports configuring PAM.

# Add or modify nofile soft limit for the user joe
- pam_limits:
    domain: joe
    limit_type: soft
    limit_item: nofile
    value: 64000
like image 124
Ezequiel Moreno Avatar answered Oct 28 '22 23:10

Ezequiel Moreno