From 1b0ee50d8d9da411eb4e0960b181ce1390446c4e Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Thu, 23 Nov 2017 08:39:58 +0100 Subject: [PATCH] [WIP] configure munin graphs for HAProxy --- haproxy/README.md | 3 ++- haproxy/defaults/main.yml | 6 ++++++ haproxy/tasks/main.yml | 3 +++ haproxy/tasks/munin.yml | 23 +++++++++++++++++++++++ haproxy/templates/munin/haproxy_ng.j2 | 8 ++++++++ 5 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 haproxy/tasks/munin.yml create mode 100644 haproxy/templates/munin/haproxy_ng.j2 diff --git a/haproxy/README.md b/haproxy/README.md index 9f597baa..0f2a4982 100644 --- a/haproxy/README.md +++ b/haproxy/README.md @@ -8,7 +8,8 @@ Everything is in the `tasks/main.yml` file. ## Available variables -* `haproxy_jessie_backports` : on Debian Jessie, we can prefer v1.7 from backports (default: `False`) +* `haproxy_jessie_backports` : on Debian Jessie, we can prefer v1.7 from backports (default: `False`) ; +* `haproxy_munin` : install and configure Munin for HAProxy stats (default: `False`). ## Configuration templates diff --git a/haproxy/defaults/main.yml b/haproxy/defaults/main.yml index ea4a8e38..a05c73fd 100644 --- a/haproxy/defaults/main.yml +++ b/haproxy/defaults/main.yml @@ -1,3 +1,9 @@ --- haproxy_jessie_backports: False + +haproxy_munin: False + +haproxy_status_url: "http://localhost/haproxy-status;csv;norefresh" +haproxy_status_login: Null +haproxy_status_passwd: Null diff --git a/haproxy/tasks/main.yml b/haproxy/tasks/main.yml index 054aec1a..3eba18a0 100644 --- a/haproxy/tasks/main.yml +++ b/haproxy/tasks/main.yml @@ -34,3 +34,6 @@ - config - include: nagios.yml + +- include: munin.yml + when: haproxy_munin diff --git a/haproxy/tasks/munin.yml b/haproxy/tasks/munin.yml new file mode 100644 index 00000000..dfea8631 --- /dev/null +++ b/haproxy/tasks/munin.yml @@ -0,0 +1,23 @@ +--- + +- include_role: munin + +- name: Enable haproxy_ng munin plugin + file: + src: "/usr/local/share/munin/plugins/haproxy_ng" + dest: "/etc/munin/plugins/haproxy_ng" + state: link + notify: restart munin-node + tags: + - haproxy + - munin + +- name: Copy Munin plugin conf + template: + src: munin/haproxy_ng.j2 + dest: /etc/munin/plugin-conf.d/haproxy_ng + mode: "0644" + notify: restart munin-node + tags: + - haproxy + - munin diff --git a/haproxy/templates/munin/haproxy_ng.j2 b/haproxy/templates/munin/haproxy_ng.j2 new file mode 100644 index 00000000..d74f2d8d --- /dev/null +++ b/haproxy/templates/munin/haproxy_ng.j2 @@ -0,0 +1,8 @@ +[haproxy_*] +env.url {{ haproxy_status_url }} +{% if haproxy_status_login %} +env.username {{ haproxy_status_login }} +{% endif %} +{% if haproxy_status_passwd %} +env.password {{ haproxy_status_passwd }} +{% endif %}