Skip to content

Commit cf21580

Browse files
committed
Support setting file descriptors limit on systemd systems
1 parent 815b9e5 commit cf21580

File tree

4 files changed

+43
-16
lines changed

4 files changed

+43
-16
lines changed

defaults/main.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,16 @@ rabbitmq_env : false
5858
# Guest options
5959
remove_guest_user : true
6060

61+
# File limits
62+
rabbitmq_nofile_limit : 64000
63+
6164
# Enable cluster
6265
rabbitmq_clustering : false
66+
6367
## Erlang cookie
6468
rabbitmq_erlang_cookie_path : "/var/lib/rabbitmq/.erlang.cookie"
6569
rabbitmq_erlang_cookie : beKSqkmoLrtvVfjOytLOQpATbGVEGbVA #test cookie, override for production
70+
6671
## Cluster options
6772
rabbitmq_cluster_instance_to_join_index : 0
6873
rabbitmq_cluster_instance_to_join : "{{ groups[rabbitmq_cluster_group][rabbitmq_cluster_instance_to_join_index].split('.')[0] }}"

handlers/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
---
22
# handlers file for rabbitmq
3+
4+
- name: reload systemd
5+
command: systemctl daemon-reload
6+
37
- name: restart rabbitmq-server
48
service: name=rabbitmq-server state=restarted enabled=yes
59

tasks/configuration.yml

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,38 @@
11
---
22

3+
- name: configuration | soft limits (non-systemd)
4+
pam_limits:
5+
domain="rabbit"
6+
limit_type="soft"
7+
limit_item="nofile"
8+
value="{{ rabbitmq_nofile_limit }}"
9+
when: ansible_service_mgr != "systemd"
10+
11+
- name: configuration | hard limits (non-systemd)
12+
pam_limits:
13+
domain="rabbit"
14+
limit_type="hard"
15+
limit_item="fsize"
16+
use_max="yes"
17+
value="{{ rabbitmq_nofile_limit }}"
18+
when: ansible_service_mgr != "systemd"
19+
20+
- name: configuration | systemd unit directory
21+
file:
22+
path: /etc/systemd/system/rabbitmq-server.service.d
23+
state: directory
24+
25+
- name: configuration | nofile limit (systemd)
26+
template:
27+
src="systemd_limits.conf.j2"
28+
dest="/etc/systemd/system/rabbitmq-server.service.d/limits.conf"
29+
owner="root"
30+
group="root"
31+
mode=0644
32+
backup="yes"
33+
notify: reload systemd
34+
when: ansible_service_mgr == "systemd"
35+
336
- name: configuration | create the ssl folder for rabbitmq
437
file:
538
path="/etc/rabbitmq/ssl/"
@@ -45,18 +78,3 @@
4578
backup="yes"
4679
notify: restart rabbitmq-server
4780
when: rabbitmq_conf_env is defined
48-
49-
- name: configuration | soft limits
50-
pam_limits:
51-
domain="rabbit"
52-
limit_type="soft"
53-
limit_item="nofile"
54-
value=64000
55-
56-
- name: configuration | hard limits
57-
pam_limits:
58-
domain="rabbit"
59-
limit_type="hard"
60-
limit_item="fsize"
61-
use_max="yes"
62-
value=64000

tasks/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@
2222
when: rabbitmq_clustering_resolve_names != "no"
2323
- include: cluster/erlang_cookie.yml
2424
- include: cluster/cluster.yml
25-
when: rabbitmq_clustering
25+
when: rabbitmq_clustering

0 commit comments

Comments
 (0)