Skip to content

Commit

Permalink
#157 add hard and soft limits
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonio Arenzana Pulido committed Sep 5, 2022
1 parent 6ef9b8d commit d9923f5
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 28 deletions.
6 changes: 4 additions & 2 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ solr_auto_add_replicas: true
solr_os_tunning: true

# pam_limits
solr_nofile_limit: 65535
solr_nproc_limit: 65535
solr_nofile_soft_limit: 65535
solr_nofile_hard_limit: 65535
solr_nproc_soft_limit: 65535
solr_nproc_hard_limit: 65535

# network
solr_sysctl_required_packages:
Expand Down
10 changes: 5 additions & 5 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
---

- name: Solr | Install
import_tasks: install.yml
tags:
- solr_install

- name: Solr | OS Tunning
import_tasks: os-tunning.yml
tags:
- solr_tunning
when: solr_os_tunning

- name: Solr | Install
import_tasks: install.yml
tags:
- solr_install

- name: Solr | Agent config
import_tasks: agent.yml
tags:
Expand Down
50 changes: 29 additions & 21 deletions tasks/os-tunning.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---

- name: TUNNING | Install required packages
- name: Solr | Install required packages
apt:
pkg: "{{ item }}"
state: present
with_items: "{{ solr_sysctl_required_packages }}"
when: solr_sysctl_required_packages is defined

- name: TUNNING | Apply sysctl settings
- name: Solr | Apply sysctl settings
sysctl:
name: "{{ item.name }}"
value: "{{ item.value }}"
Expand All @@ -16,40 +16,48 @@
with_items: "{{ solr_sysctl_properties }}"
when: solr_sysctl_properties is defined

- name: TUNNING | Set to {{ solr_nofile_limit }} the nofile limit
- name: Solr | Set to {{ solr_nofile_soft_limit }} the nofile soft limit
pam_limits:
domain: '*'
domain: '{{ solr_user }}'
limit_type: soft
limit_item: nofile
value: "{{ solr_nofile_limit }}"
value: "{{ solr_nofile_soft_limit }}"
register: ulimit
when: solr_nofile_limit is defined
when: solr_nofile_soft_limit is defined

- name: TUNNING | Set to {{ solr_nproc_limit }} the nproc limit
- name: Solr | Set to {{ solr_nofile_hard_limit }} the nofile hard limit
pam_limits:
domain: '*'
domain: '{{ solr_user }}'
limit_type: hard
limit_item: nofile
value: "{{ solr_nofile_hard_limit }}"
register: ulimit
when: solr_nofile_hard_limit is defined

- name: Solr | Set to {{ solr_nproc_soft_limit }} the nproc soft limit
pam_limits:
domain: '{{ solr_user }}'
limit_type: soft
limit_item: nproc
value: "{{ solr_nproc_limit }}"
value: "{{ solr_nproc_soft_limit }}"
register: ulimit
when: solr_nproc_limit is defined
when: solr_nproc_soft_limit is defined

- name: TUNNING | Reboot host if ulimit changed
shell: sleep 10 && shutdown -r now
async: 1
poll: 0
ignore_errors: true
when: ulimit.changed

- name: TUNNING | Wait for connection
wait_for_connection:
- name: Solr | Set to {{ solr_nproc_hard_limit }} the nproc hard limit
pam_limits:
domain: '{{ solr_user }}'
limit_type: hard
limit_item: nproc
value: "{{ solr_nproc_hard_limit }}"
register: ulimit
when: solr_nproc_hard_limit is defined

- name: TUNNING | Disable SWAP (1/2)
- name: Solr | Disable SWAP (1/2)
shell: |
swapoff -a
when: solr_disable_swap

- name: TUNNING | Disable SWAP in fstab (2/2)
- name: Solr | Disable SWAP in fstab (2/2)
replace:
path: /etc/fstab
regexp: '^([^#].*?\sswap\s+sw\s+.*)$'
Expand Down

0 comments on commit d9923f5

Please sign in to comment.