diff --git a/CHANGELOG.md b/CHANGELOG.md index 31ff6564..da9acdf7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ The **patch** part changes incrementally at each release. ### Added * evomaintenance: database variables must be set or the task fails +* redis: Configure munin when working in instance mode ### Changed diff --git a/redis/tasks/main.yml b/redis/tasks/main.yml index c2d57d62..65b065df 100644 --- a/redis/tasks/main.yml +++ b/redis/tasks/main.yml @@ -55,7 +55,19 @@ - munin - include: munin.yml - when: _munin_installed.stat.exists and _munin_installed.stat.isdir + when: + - _munin_installed.stat.exists + - _munin_installed.stat.isdir + - redis_instance_name is not defined + tags: + - redis + - munin + +- include: munin-instances.yml + when: + - _munin_installed.stat.exists + - _munin_installed.stat.isdir + - redis_instance_name is defined tags: - redis - munin diff --git a/redis/tasks/munin-instances.yml b/redis/tasks/munin-instances.yml new file mode 100644 index 00000000..c8d7cefe --- /dev/null +++ b/redis/tasks/munin-instances.yml @@ -0,0 +1,61 @@ +--- +- name: Install munin check dependencies + apt: + name: libswitch-perl + state: present + tags: + - redis + +- include_role: + name: remount-usr + tags: + - redis + +- name: Create plugin directory + file: + name: /usr/local/share/munin/ + state: directory + mode: "0755" + tags: + - redis + +- name: Create plugin directory + file: + name: /usr/local/share/munin/plugins/ + state: directory + mode: "0755" + tags: + - redis + +- name: Copy redis munin plugin + copy: + src: munin_redis + dest: /usr/local/share/munin/plugins/redis_ + mode: "0755" + notify: restart munin-node + tags: + - redis + +- name: Enable redis munin plugin + file: + src: /usr/local/share/munin/plugins/redis_ + dest: "/etc/munin/plugins/{{ redis_instance_name }}_redis_{{item}}" + state: link + with_items: + - connected_clients + - key_ratio + - keys_per_sec + - per_sec + - used_keys + - used_memory + notify: restart munin-node + tags: + - redis + +- name: Configure redis plugin for munin + template: + src: templates/munin-plugin-instances.conf.j2 + dest: '/etc/munin/plugin-conf.d/evolinux.redis_{{ redis_instance_name }}' + mode: 0740 + notify: restart munin-node + tags: redis diff --git a/redis/templates/munin-plugin-instances.conf.j2 b/redis/templates/munin-plugin-instances.conf.j2 new file mode 100644 index 00000000..7e6a00ac --- /dev/null +++ b/redis/templates/munin-plugin-instances.conf.j2 @@ -0,0 +1,8 @@ +# Ansible managed + +[{{ redis_instance_name }}_redis_*] +env.title_prefix Instance {{ redis_instance_name }} +env.port {{ redis_port }} +{% if redis_password %} +env.password {{ redis_password }} +{% endif %}