From 96d1a8ab3785cc2fe634e679fbaf4c4a8e1d15b2 Mon Sep 17 00:00:00 2001 From: Logan V Date: Wed, 16 Aug 2017 14:37:10 -0500 Subject: [PATCH] Use reloads instead of restarts In cases of configuration change, haproxy init scripts support a HUP reload instead of a full restart, allowing existing sessions to end gracefully without a forceful restart. --- defaults/main.yml | 6 ++++++ handlers/main.yml | 4 ++-- tasks/main.yml | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 33c2547b..7c38bb49 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -7,6 +7,12 @@ haproxy_dependencies: state: latest haproxy_install: [] +# Some haproxy features will not work well with reload and require a hard +# restart instead. By default we will use the reloaded state and users can +# change the handler to perform a hard-restart when configuration change +# occurs by setting this to "restarted" +haproxy_reload_mode: reloaded + # global section haproxy_global_log: - address: /dev/log diff --git a/handlers/main.yml b/handlers/main.yml index 888e352d..70753fd4 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,6 +1,6 @@ # handlers file for haproxy --- -- name: restart haproxy +- name: reload haproxy service: name: haproxy - state: restarted + state: "{{ haproxy_reload_mode }}" diff --git a/tasks/main.yml b/tasks/main.yml index 56fd5700..92bfe5cb 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -60,7 +60,7 @@ group: "{{ item.group | default('root') }}" mode: "{{ item.mode | default('0640') }}" with_items: "{{ haproxy_ssl_map }}" - notify: restart haproxy + notify: reload haproxy tags: - configuration - haproxy @@ -75,7 +75,7 @@ group: root mode: 0640 validate: 'haproxy -f %s -c' - notify: restart haproxy + notify: reload haproxy tags: - configuration - haproxy