Skip to content

Commit

Permalink
Merge pull request #8 from hellofresh/feature/systemd
Browse files Browse the repository at this point in the history
Support setting file descriptors limit on systemd systems
  • Loading branch information
zeelax authored Mar 14, 2018
2 parents 815b9e5 + cf21580 commit 0f0b436
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 16 deletions.
5 changes: 5 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,16 @@ rabbitmq_env : false
# Guest options
remove_guest_user : true

# File limits
rabbitmq_nofile_limit : 64000

# Enable cluster
rabbitmq_clustering : false

## Erlang cookie
rabbitmq_erlang_cookie_path : "/var/lib/rabbitmq/.erlang.cookie"
rabbitmq_erlang_cookie : beKSqkmoLrtvVfjOytLOQpATbGVEGbVA #test cookie, override for production

## Cluster options
rabbitmq_cluster_instance_to_join_index : 0
rabbitmq_cluster_instance_to_join : "{{ groups[rabbitmq_cluster_group][rabbitmq_cluster_instance_to_join_index].split('.')[0] }}"
Expand Down
4 changes: 4 additions & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
---
# handlers file for rabbitmq

- name: reload systemd
command: systemctl daemon-reload

- name: restart rabbitmq-server
service: name=rabbitmq-server state=restarted enabled=yes

Expand Down
48 changes: 33 additions & 15 deletions tasks/configuration.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,38 @@
---

- name: configuration | soft limits (non-systemd)
pam_limits:
domain="rabbit"
limit_type="soft"
limit_item="nofile"
value="{{ rabbitmq_nofile_limit }}"
when: ansible_service_mgr != "systemd"

- name: configuration | hard limits (non-systemd)
pam_limits:
domain="rabbit"
limit_type="hard"
limit_item="fsize"
use_max="yes"
value="{{ rabbitmq_nofile_limit }}"
when: ansible_service_mgr != "systemd"

- name: configuration | systemd unit directory
file:
path: /etc/systemd/system/rabbitmq-server.service.d
state: directory

- name: configuration | nofile limit (systemd)
template:
src="systemd_limits.conf.j2"
dest="/etc/systemd/system/rabbitmq-server.service.d/limits.conf"
owner="root"
group="root"
mode=0644
backup="yes"
notify: reload systemd
when: ansible_service_mgr == "systemd"

- name: configuration | create the ssl folder for rabbitmq
file:
path="/etc/rabbitmq/ssl/"
Expand Down Expand Up @@ -45,18 +78,3 @@
backup="yes"
notify: restart rabbitmq-server
when: rabbitmq_conf_env is defined

- name: configuration | soft limits
pam_limits:
domain="rabbit"
limit_type="soft"
limit_item="nofile"
value=64000

- name: configuration | hard limits
pam_limits:
domain="rabbit"
limit_type="hard"
limit_item="fsize"
use_max="yes"
value=64000
2 changes: 1 addition & 1 deletion tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
when: rabbitmq_clustering_resolve_names != "no"
- include: cluster/erlang_cookie.yml
- include: cluster/cluster.yml
when: rabbitmq_clustering
when: rabbitmq_clustering

0 comments on commit 0f0b436

Please sign in to comment.