aboutsummaryrefslogtreecommitdiffstats
path: root/ansible/roles/munin-node/tasks/main.yml
blob: bbc1671c6cfe9927213a7f222e373adb612097a6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
---
- name: Install munin-node & plugin packages
  package:
    name: "{{ ['munin-node'] + munin_node__plugin_packages }}"
    state: present
  tags:
    - role::munin-node

- name: Create firewall rule for Rocky Linux Munin nodes
  ansible.posix.firewalld:
    service: "munin-node"
    permanent: true
    zone: wireguard
    state: enabled
  tags:
    - role::munin-node
  when: ansible_distribution == "Rocky"
  notify:
    - Reload the firewall

- 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