Skip to content

Instantly share code, notes, and snippets.

@visualskyrim
Last active August 18, 2022 09:27
Show Gist options
  • Save visualskyrim/8d93a8be0a3ef6dd6598ec8550f6eadd to your computer and use it in GitHub Desktop.
Save visualskyrim/8d93a8be0a3ef6dd6598ec8550f6eadd to your computer and use it in GitHub Desktop.
A ansible playbook to modify ulimit
- hosts: all
become: true
tasks:
- name: configure system settings, file descriptors and number of threads
pam_limits:
domain: <--your-username-->
limit_type: "{{item.limit_type}}"
limit_item: "{{item.limit_item}}"
value: "{{item.value}}"
with_items:
- { limit_type: '-', limit_item: 'nofile', value: 65536 }
- { limit_type: '-', limit_item: 'nproc', value: 65536 }
- { limit_type: 'soft', limit_item: 'memlock', value: unlimited }
- { limit_type: 'hard', limit_item: 'memlock', value: unlimited }
- name: reload settings from all system configuration files
shell: sysctl --system
@sdvcrx
Copy link

sdvcrx commented Nov 29, 2018

@wabmca It append to /etc/security/limits.conf

@wabmca
Copy link

wabmca commented Dec 3, 2018

Thanks again.
Is it compulsory to do sysctl --system?

@Shahbazaslam
Copy link

Thanks again.
Is it compulsory to do sysctl --system?

I think yes, else you need to login again

@netxillon
Copy link

Thanks for the nice write-up. one correction: sysctl --system is not related to config files under /etc/security/, it is more for sysctl conf files under /etc/sysctl.d/; /run/sysctl.d; etc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment