Skip to content

Commit

Permalink
Add standalone munin-node role
Browse files Browse the repository at this point in the history
  • Loading branch information
jchristgit committed Aug 30, 2024
1 parent e4346fe commit c1be859
Show file tree
Hide file tree
Showing 11 changed files with 105 additions and 90 deletions.
25 changes: 25 additions & 0 deletions ansible/host_vars/lovelace/munin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
munin_node__plugins:
# SpamAssassin
- src: spamstats
# Nginx
- src: nginx_request
- src: nginx_status
# Postfix
- src: postfix_mailstats
- src: postfix_mailqueue
- src: postfix_mailvolume
# PostgreSQL
- src: postgres_size_
dest: postgres_size_metricity
- src: postgres_size_
dest: postgres_size_site
- src: postgres_size_
dest: postgres_size_ALL
- src: postgres_xlog
- src: postgres_autovacuum
- src: postgres_bgwriter
- src: postgres_checkpoints
- src: postgres_connections_db
- src: postgres_users
- src: postgres_xlog
1 change: 1 addition & 0 deletions ansible/playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- common
- pydis-mtls
- wireguard
- munin-node

- name: Deploy services to Netcup nodes
hosts: netcup
Expand Down
3 changes: 3 additions & 0 deletions ansible/roles/munin-node/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
munin_node__plugin_packages: "{{ ('databases' in group_names) | ternary(['libdbd-pg-perl'], []) }}"
munin_node__plugins: []
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
service:
name: munin-node
state: restarted
tags:
- role::munin-node
74 changes: 74 additions & 0 deletions ansible/roles/munin-node/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
- name: Install munin-node & plugin packages
package:
name: "{{ ['munin-node'] + munin_node__plugin_packages }}"
state: present
tags:
- role::munin-node

- name: Template munin-node configuration file
template:
src: munin-node.conf.j2
dest: /etc/munin/munin-node.conf
owner: root
group: root
mode: "0444"
tags:
- role::munin-node
notify:
- Restart munin-node service

- name: Template munin plugin configuration file
template:
src: plugin.conf.j2
dest: /etc/munin/plugin-conf.d/custom
owner: root
group: root
mode: "0444"
tags:
- role::munin-node
notify:
- Restart munin-node service

- name: Enable non-default munin plugins
file:
src: "/usr/share/munin/plugins/{{ item.src }}"
dest: "/etc/munin/plugins/{{ item.dest | default(item.src) }}"
state: link
loop: "{{ munin_node__plugins }}"
tags:
- role::munin-node
notify:
- Restart munin-node service

- name: Copy custom munin plugins
template:
src: "{{ item }}"
# Split two levels of file extensions
dest: "/etc/munin/plugins/{{ item | basename | splitext | first | splitext | first }}"
owner: root
group: root
mode: "0555"
loop_control:
# I love representing data modification logic in YAML!
label: "{{ item | basename | splitext | first | splitext | first }}"
with_fileglob: "../templates/plugins/{{ ansible_hostname }}/*"
tags:
- role::munin-node

- name: Disable some unneeded plugins
file:
path: "/etc/munin/plugins/{{ item }}"
state: absent
loop:
- squeezebox_albums
- squeezebox_artists
- squeezebox_genres
- squeezebox_signalstrength
- squeezebox_songs
- squeezebox_volume
- squeezebox_years
tags:
- role::munin-node
notify:
- Restart munin-node service
Empty file.
90 changes: 0 additions & 90 deletions ansible/roles/munin/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,93 +20,3 @@
mode: "0444"
tags:
- role::munin

- name: Template munin-node configuration file
template:
src: munin-node.conf.j2
dest: /etc/munin/munin-node.conf
owner: root
group: root
mode: "0444"
tags:
- role::munin
notify:
- Restart munin-node service

- name: Template munin plugin configuration file
template:
src: plugin.conf.j2
dest: /etc/munin/plugin-conf.d/custom
owner: root
group: root
mode: "0444"
tags:
- role::munin
notify:
- Restart munin-node service

- name: Enable non-default munin plugins
file:
src: "/usr/share/munin/plugins/{{ item.src }}"
dest: "/etc/munin/plugins/{{ item.dest | default(item.src) }}"
state: link
loop:
# SpamAssassin
- src: spamstats
# Nginx
- src: nginx_request
- src: nginx_status
# Postfix
- src: postfix_mailstats
- src: postfix_mailqueue
- src: postfix_mailvolume
# PostgreSQL
- src: postgres_size_
dest: postgres_size_metricity
- src: postgres_size_
dest: postgres_size_site
- src: postgres_size_
dest: postgres_size_ALL
- src: postgres_xlog
- src: postgres_autovacuum
- src: postgres_bgwriter
- src: postgres_checkpoints
- src: postgres_connections_db
- src: postgres_users
- src: postgres_xlog
tags:
- role::munin
notify:
- Restart munin-node service

- name: Copy custom munin plugins
template:
src: "{{ item }}"
# Split two levels of file extensions
dest: "/etc/munin/plugins/{{ item | basename | splitext | first | splitext | first }}"
owner: root
group: root
mode: "0555"
loop_control:
# I love representing data modification logic in YAML!
label: "{{ item | basename | splitext | first | splitext | first }}"
with_fileglob: "../templates/plugins/*"
tags:
- role::munin

- name: Disable some unneeded plugins
file:
path: "/etc/munin/plugins/{{ item }}"
state: absent
loop:
- squeezebox_albums
- squeezebox_artists
- squeezebox_genres
- squeezebox_signalstrength
- squeezebox_songs
- squeezebox_volume
- squeezebox_years
tags:
- role::munin
notify:
- Restart munin-node service

0 comments on commit c1be859

Please sign in to comment.