From e27a4b28516a112a1203f2328041b6f49dab0d67 Mon Sep 17 00:00:00 2001 From: Major Hayden Date: Fri, 18 Aug 2017 08:50:19 -0500 Subject: [PATCH] Add automatic restart for RabbitMQ This patch ensures that systemd will restart RabbitMQ in case of failure or if the process is manually killed. Closes-Bug: 1659954 Change-Id: Id8dbdccfe445f4a25902054eb6809d42a92d5f5d --- tasks/rabbitmq_post_install.yml | 15 +++++++++++++-- templates/systemd-restart-on-failure.conf.j2 | 4 ++++ 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 templates/systemd-restart-on-failure.conf.j2 diff --git a/tasks/rabbitmq_post_install.yml b/tasks/rabbitmq_post_install.yml index 486268d1..2f0ed832 100644 --- a/tasks/rabbitmq_post_install.yml +++ b/tasks/rabbitmq_post_install.yml @@ -60,10 +60,20 @@ - rabbitmq-config - name: Apply resource limits (systemd) - register: rabbit_resource_limit_changed template: src: "limits.conf.j2" dest: "/etc/systemd/system/rabbitmq-server.service.d/limits.conf" + register: rabbit_resource_limit + when: + - ansible_service_mgr == 'systemd' + tags: + - rabbitmq-config + +- name: Add automatic restart on failure + template: + src: systemd-restart-on-failure.conf.j2 + dest: "/etc/systemd/system/rabbitmq-server.service.d/systemd-restart-on-failure.conf" + register: rabbit_restart_on_failure when: - ansible_service_mgr == 'systemd' tags: @@ -73,7 +83,8 @@ command: "systemctl daemon-reload" when: - ansible_service_mgr == 'systemd' - - rabbit_resource_limit_changed|changed + - rabbit_resource_limit | changed + - rabbit_restart_on_failure | changed tags: - rabbitmq-config # don't trigger ANSIBLE0016 diff --git a/templates/systemd-restart-on-failure.conf.j2 b/templates/systemd-restart-on-failure.conf.j2 new file mode 100644 index 00000000..8acdc0f3 --- /dev/null +++ b/templates/systemd-restart-on-failure.conf.j2 @@ -0,0 +1,4 @@ +# {{ ansible_managed }} +[Service] +Restart=on-failure +RestartSec=2