---
# ansible-playbook -l app1 02_PRO_UlimitApp.yml
# It works with new version openssh. openssh-5.3 has lots of bugs.
- name: create user and ulimit [0.0.2]
hosts: all
gather_facts: no
vars:
uuser: nginx
tasks:
- name: create user
shell: useradd {{ uuser }}
ignore_errors: true
- name: passwd lock user
shell: passwd -l {{ uuser }}
ignore_errors: true
- name: modify /etc/security/limit.conf
pam_limits: domain={{ item.domain }} limit_type={{ item.type }} limit_item={{ item.item }} value={{ item.value }}
ignore_errors: True
with_items:
- { domain: '{{uuser}}', type: 'soft', item: 'nofile', value: '63536' }
- { domain: '{{uuser}}', type: 'hard', item: 'nofile', value: '63536' }
- { domain: '{{uuser}}', type: 'soft', item: 'nproc', value: '63536' }
- { domain: '{{uuser}}', type: 'hard', item: 'nproc', value: '63536' }
- name: show process
shell: ulimit -a
become_user: "{{ uuser }}"
with_items:
- "{{ uuser }}"
ignore_errors: True
register: ulimitOut
- debug: msg="ulimit -a ~> {{ ulimitOut }}"