From 7799f2a4feb8ac62ee44e25bd86cd9b8abf2852e Mon Sep 17 00:00:00 2001 From: mg Date: Mon, 13 Sep 2021 19:26:31 +0200 Subject: [PATCH] munin 2.0: you can (not) rebuild (#202) Co-authored-by: Michael Grote Reviewed-on: https://git.mgrote.net/mg/ansible/pulls/202 Co-authored-by: mg Co-committed-by: mg --- group_vars/acng.yml | 14 ++-- group_vars/all.yml | 29 ++----- group_vars/docker.yml | 37 +++++++++ group_vars/fileserver.yml | 32 ++------ group_vars/proxmox.yml | 40 +++++----- host_vars/docker2.grote.lan.yml | 1 - host_vars/docker3.grote.lan.yml | 1 - host_vars/docker4.grote.lan.yml | 1 - host_vars/pve2.grote.lan.yml | 44 ----------- playbooks/on-off/remove_munin_node.yml | 2 +- roles/mgrote.munin-node/defaults/main.yml | 26 +++---- roles/mgrote.munin-node/tasks/additional.yml | 29 +++++++ roles/mgrote.munin-node/tasks/install.yml | 36 +++++++++ roles/mgrote.munin-node/tasks/main.yml | 78 ++----------------- roles/mgrote.munin-node/tasks/remove.yml | 16 ++++ .../templates/munin-node.conf.j2 | 3 +- .../templates/plugin-conf.j2 | 8 -- 17 files changed, 181 insertions(+), 216 deletions(-) create mode 100644 roles/mgrote.munin-node/tasks/additional.yml create mode 100644 roles/mgrote.munin-node/tasks/install.yml create mode 100644 roles/mgrote.munin-node/tasks/remove.yml delete mode 100644 roles/mgrote.munin-node/templates/plugin-conf.j2 diff --git a/group_vars/acng.yml b/group_vars/acng.yml index d8105299..f9588e6f 100644 --- a/group_vars/acng.yml +++ b/group_vars/acng.yml @@ -21,15 +21,17 @@ acng_server_auth_user: acngadmin acng_server_auth_pass: "{{ lookup('keepass', 'acng_webinterface', 'password') }}" ### geerlingguy.munin-node - munin_node_additional_plugins: + munin_node_plugins: - name: chrony src: https://git.mgrote.net/mg/munin-plugins/raw/branch/master/chrony - name: systemd_status src: https://git.mgrote.net/mg/munin-plugins/raw/branch/master/systemd_status + - name: lvm_ + src: https://git.mgrote.net/mg/munin-plugins/raw/branch/master/lvm_ + config: | + [lvm_*] + user root - name: acng src: https://git.mgrote.net/mg/munin-plugins/raw/branch/master/acng - munin_node_config: { - "acng": { - "env.logfile /var/log/apt-cacher-ng/apt-cacher.log" - } - } + config: | + env.logfile /var/log/apt-cacher-ng/apt-cacher.log diff --git a/group_vars/all.yml b/group_vars/all.yml index e1b9ad5e..af255844 100644 --- a/group_vars/all.yml +++ b/group_vars/all.yml @@ -12,35 +12,20 @@ munin_node_disabled_plugins: - name: meminfo # zu hohe last - name: hddtemp2 # ersetzt durch hddtemp_smartctl - - name: squid_cache - - name: squid_objectsize - - name: squid_requests - - name: squid_traffic - - name: nfsd - - name: samba - - name: nfsd4 - name: ntp # verursacht zu viele dns ptr request - - name: cronjobs - name: hddtempd # ersetzt durch hddtemp_smartctl - name: ipmi_power # für pve2, leeres diagramm - - name: fail2ban - - name: fail2ban_ - - name: apcupsd_pct - - name: kvm_io - - name: kvm_cpu - - name: docker_mem - - name: docker_cpu - - name: lvm_ - munin_node_additional_plugins: + munin_node_plugins: - name: chrony src: https://git.mgrote.net/mg/munin-plugins/raw/branch/master/chrony - name: systemd_status src: https://git.mgrote.net/mg/munin-plugins/raw/branch/master/systemd_status - munin_node_config: { - "lvm_": { - "user munin" - } - } + - name: lvm_ + src: https://git.mgrote.net/mg/munin-plugins/raw/branch/master/lvm_ + config: | + [lvm_*] + user root + ### mgrote.dotfiles dotfiles_repo_url: https://git.mgrote.net/mg/dotfiles diff --git a/group_vars/docker.yml b/group_vars/docker.yml index 98bdac50..216150bc 100644 --- a/group_vars/docker.yml +++ b/group_vars/docker.yml @@ -2,6 +2,10 @@ ### geerlingguy.docker docker_users: - mg + ### geerlingguy.pip + pip_package: python3-pip + pip_install_packages: + - name: docker # für munin-plugin docker_ ### mgrote.restic restic_folders_to_backup: /usr/local /etc /root /home /var/lib/docker restic_cron_hours: "*/4" @@ -17,3 +21,36 @@ /var/lib/docker/volumes/docker-photoprism_pp_smb_bilder***/** # https://github.com/restic/restic/issues/1005 # https://forum.restic.net/t/exclude-syntax-confusion/1531/12 + + ### geerlingguy.munin-node + munin_node_plugins: + - name: chrony + src: https://git.mgrote.net/mg/munin-plugins/raw/branch/master/chrony + - name: systemd_status + src: https://git.mgrote.net/mg/munin-plugins/raw/branch/master/systemd_status + - name: lvm_ + src: https://git.mgrote.net/mg/munin-plugins/raw/branch/master/lvm_ + config: | + [lvm_*] + user root + - name: docker_containers + src: https://git.mgrote.net/mg/munin-plugins/raw/branch/master/docker_ + config: | + [docker_*] + user root + env.DOCKER_HOST unix://run/docker.sock + - name: docker_cpu + src: https://git.mgrote.net/mg/munin-plugins/raw/branch/master/docker_ + - name: docker_images + src: https://git.mgrote.net/mg/munin-plugins/raw/branch/master/docker_ + - name: docker_memory + src: https://git.mgrote.net/mg/munin-plugins/raw/branch/master/docker_ + - name: docker_network + src: https://git.mgrote.net/mg/munin-plugins/raw/branch/master/docker_ + - name: docker_status + src: https://git.mgrote.net/mg/munin-plugins/raw/branch/master/docker_ + - name: docker_volumes + src: https://git.mgrote.net/mg/munin-plugins/raw/branch/master/docker_ + + ### mgrote.docker-compose-deploy + docker_compose_base_dir: /home/mg/docker diff --git a/group_vars/fileserver.yml b/group_vars/fileserver.yml index 49056a75..51e04d3a 100644 --- a/group_vars/fileserver.yml +++ b/group_vars/fileserver.yml @@ -115,7 +115,14 @@ from_ip: 192.168.2.144/24 ### geerlingguy.munin-node - munin_node_additional_plugins: + munin_node_disabled_plugins: + - name: meminfo # zu hohe last + - name: hddtemp2 # ersetzt durch hddtemp_smartctl + - name: ntp # verursacht zu viele dns ptr request + - name: hddtempd # ersetzt durch hddtemp_smartctl + - name: ipmi_power # für pve2, leeres diagramm + - name: lvm_ + munin_node_plugins: - name: chrony src: https://git.mgrote.net/mg/munin-plugins/raw/branch/master/chrony - name: systemd_status @@ -124,26 +131,3 @@ src: https://git.mgrote.net/mg/munin-plugins/raw/branch/master/samba_users - name: samba_locked src: https://git.mgrote.net/mg/munin-plugins/raw/branch/master/samba_locked - munin_node_disabled_plugins: - - name: meminfo # zu hohe last - - name: hddtemp2 # ersetzt durch hddtemp_smartctl - - name: squid_cache - - name: squid_objectsize - - name: squid_requests - - name: squid_traffic - - name: nfsd - - name: samba - - name: nfsd4 - - name: ntp # verursacht zu viele dns ptr request - - name: cronjobs - - name: hddtempd # ersetzt durch hddtemp_smartctl - - name: ipmi_power # für pve2, leeres diagramm - - name: fail2ban - - name: fail2ban_ - - name: apcupsd_pct - - name: kvm_io - - name: kvm_cpu - - name: docker_mem - - name: cpuspeed - - name: acpi - - name: lvm_ diff --git a/group_vars/proxmox.yml b/group_vars/proxmox.yml index f697b4f5..7f4ea150 100644 --- a/group_vars/proxmox.yml +++ b/group_vars/proxmox.yml @@ -10,11 +10,27 @@ ### mgrote.zfs_extra # Variablen für mgrote.zfs_health/trim/scrub/zed/arc_mem/ sind zusammengefasst unter zfs_extra_* zfs_extra_max_usage_health: "80" ### geerlingguy.munin-node - munin_node_additional_plugins: + munin_node_disabled_plugins: + - name: meminfo # zu hohe last + - name: hddtemp2 # ersetzt durch hddtemp_smartctl + - name: ntp # verursacht zu viele dns ptr request + - name: hddtempd # ersetzt durch hddtemp_smartctl + - name: ipmi_power # für pve2, leeres diagramm + - name: squid_cache + - name: squid_objectsize + - name: squid_requests + - name: squid_traffic + - name: nfsd4 + munin_node_plugins: - name: chrony src: https://git.mgrote.net/mg/munin-plugins/raw/branch/master/chrony - name: systemd_status src: https://git.mgrote.net/mg/munin-plugins/raw/branch/master/systemd_status + - name: lvm_ + src: https://git.mgrote.net/mg/munin-plugins/raw/branch/master/lvm_ + config: | + [lvm_*] + user root - name: zfs_arcstats src: https://git.mgrote.net/mg/munin-plugins/raw/branch/master/zfs_arcstats - name: zfsonlinux_stats_ @@ -29,28 +45,8 @@ src: https://git.mgrote.net/mg/munin-plugins/raw/branch/master/kvm_mem - name: kvm_net src: https://git.mgrote.net/mg/munin-plugins/raw/branch/master/kvm_net - munin_node_disabled_plugins: - - name: meminfo # zu hohe last - - name: hddtemp2 # ersetzt durch hddtemp_smartctl - - name: squid_cache - - name: squid_objectsize - - name: squid_requests - - name: squid_traffic - - name: nfsd - - name: samba - - name: nfsd4 - - name: ntp # verursacht zu viele dns ptr request - - name: cronjobs - - name: hddtempd # ersetzt durch hddtemp_smartctl - - name: ipmi_power # für pve2, leeres diagramm - - name: fail2ban - - name: fail2ban_ - - name: apcupsd_pct - - name: kvm_io - name: kvm_cpu - - name: docker_mem - - name: apc_nis - - name: lvm_ + src: https://git.mgrote.net/mg/munin-plugins/raw/branch/master/kvm_cpu # Ansible Variablen ### sudo diff --git a/host_vars/docker2.grote.lan.yml b/host_vars/docker2.grote.lan.yml index 25830f6a..5f9a1f73 100644 --- a/host_vars/docker2.grote.lan.yml +++ b/host_vars/docker2.grote.lan.yml @@ -1,6 +1,5 @@ --- ### mgrote.docker-compose-deploy - docker_compose_base_dir: /home/mg/docker docker_compose_projects: - name: munin-master dir_name: docker-munin-master diff --git a/host_vars/docker3.grote.lan.yml b/host_vars/docker3.grote.lan.yml index 83eae920..ce115d1c 100644 --- a/host_vars/docker3.grote.lan.yml +++ b/host_vars/docker3.grote.lan.yml @@ -1,6 +1,5 @@ --- ### mgrote.docker-compose-deploy - docker_compose_base_dir: /home/mg/docker docker_compose_projects: - name: miniflux dir_name: docker-miniflux diff --git a/host_vars/docker4.grote.lan.yml b/host_vars/docker4.grote.lan.yml index 6f75cbe6..3969c384 100644 --- a/host_vars/docker4.grote.lan.yml +++ b/host_vars/docker4.grote.lan.yml @@ -1,6 +1,5 @@ --- ### mgrote.docker-compose-deploy - docker_compose_base_dir: /home/mg/docker docker_compose_projects: - name: watchtower dir_name: docker-watchtower diff --git a/host_vars/pve2.grote.lan.yml b/host_vars/pve2.grote.lan.yml index bed46548..cfd23450 100644 --- a/host_vars/pve2.grote.lan.yml +++ b/host_vars/pve2.grote.lan.yml @@ -170,7 +170,6 @@ cron_day_of_week_zfs_scrub: "*" cron_month_zfs_scrub: "*/2" - ### mgrote.zfs_sanoid sanoid_datasets: - path: 'hdd_data_raidz/data_crypt' @@ -243,46 +242,3 @@ cv4pve_vmid: all,-127,-158,-112,-100 cv4pve_keep_snapshots: 1 cv4pve_dl_link: "https://github.com/Corsinvest/cv4pve-autosnap/releases/download/v1.10.0/cv4pve-autosnap-linux-x64.zip" - - ### geerlingguy.munin-node - munin_node_additional_plugins: - - name: chrony - src: https://git.mgrote.net/mg/munin-plugins/raw/branch/master/chrony - - name: systemd_status - src: https://git.mgrote.net/mg/munin-plugins/raw/branch/master/systemd_status - - name: zfs_arcstats - src: https://git.mgrote.net/mg/munin-plugins/raw/branch/master/zfs_arcstats - - name: zfsonlinux_stats_ - src: https://git.mgrote.net/mg/munin-plugins/raw/branch/master/zfsonlinux_stats_ - - name: zpool_iostat - src: https://git.mgrote.net/mg/munin-plugins/raw/branch/master/zpool_iostat - - name: zfs_list - src: https://git.mgrote.net/mg/munin-plugins/raw/branch/master/zfs_list - - name: zpool_capacity - src: https://git.mgrote.net/mg/munin-plugins/raw/branch/master/zpool_capacity - - name: kvm_mem - src: https://git.mgrote.net/mg/munin-plugins/raw/branch/master/kvm_mem - - name: kvm_net - src: https://git.mgrote.net/mg/munin-plugins/raw/branch/master/kvm_net - munin_node_disabled_plugins: - - name: meminfo # zu hohe last - - name: hddtemp2 # ersetzt durch hddtemp_smartctl - - name: squid_cache - - name: squid_objectsize - - name: squid_requests - - name: squid_traffic - - name: nfsd - - name: samba - - name: nfsd4 - - name: ntp # verursacht zu viele dns ptr request - - name: cronjobs - - name: hddtempd # ersetzt durch hddtemp_smartctl - - name: ipmi_power # für pve2, leeres diagramm - - name: fail2ban - - name: fail2ban_ - - name: apcupsd_pct - - name: apc_nis - - name: kvm_io - - name: kvm_cpu - - name: docker_mem - - name: lvm_ diff --git a/playbooks/on-off/remove_munin_node.yml b/playbooks/on-off/remove_munin_node.yml index 2976910f..9a6529ad 100644 --- a/playbooks/on-off/remove_munin_node.yml +++ b/playbooks/on-off/remove_munin_node.yml @@ -1,5 +1,5 @@ --- -- hosts: all,!proxmox +- hosts: all become: yes tasks: diff --git a/roles/mgrote.munin-node/defaults/main.yml b/roles/mgrote.munin-node/defaults/main.yml index d88bb7ee..88ab1dc0 100644 --- a/roles/mgrote.munin-node/defaults/main.yml +++ b/roles/mgrote.munin-node/defaults/main.yml @@ -11,24 +11,22 @@ munin_node_denied_cidrs: [] # a list of addresses that are not allowed to connect munin_node_bind_host: "0.0.0.0" # bind to interface munin_node_bind_port: "4949" # bind to port + munin_node_log_level: 4 # Loglevel # Plugin configuration options (the key is the plugin heading, items within will # be options for the plugin). - munin_node_config: { - # "ps_test": { - # "env.regex": "bash", - # "env.name": "bash" - # } - } # Source and destination of munin plugins. munin_plugin_src_path: /usr/share/munin/plugins/ munin_plugin_dest_path: /etc/munin/plugins/ - munin_node_additional_plugins: # must be a textfile - # - name: chrony - # src: https://git.mgrote.net/mg/munin-plugins/raw/branch/master/chrony - # oder - # - name: apc_nis # wenn das plugin schon lokal vorhanden ist - munin_node_disabled_plugins: - # - name: meminfo # zu hohe last + munin_plugin_conf_dest_path: /etc/munin/plugin-conf.d/ +# munin_node_plugins: #plugins to install +# - name: docker_volumes # name +# src: https://git.mgrote.net/mg/munin-plugins/raw/branch/master/docker_ #src +# config_file_name: /etc/munin/plugin-conf.d/docker # where to put plugin config + # content of config +# config: | +# user root +# env.DOCKER_HOST unix://run/docker.sock - #aufräum task der plguins einmal leer macht(beide src und dest) +# munin_node_disabled_plugins: # remove plugins from running config +# - name: meminfo diff --git a/roles/mgrote.munin-node/tasks/additional.yml b/roles/mgrote.munin-node/tasks/additional.yml new file mode 100644 index 00000000..5386d726 --- /dev/null +++ b/roles/mgrote.munin-node/tasks/additional.yml @@ -0,0 +1,29 @@ +--- + - name: download additional plugins + get_url: + url: "{{ item.src }}" + dest: "{{ munin_plugin_src_path }}{{ item.name }}" + mode: '0755' + loop: "{{ munin_node_plugins }}" + + - name: enable additional plugins + file: + src: "{{ munin_plugin_src_path }}{{ item.name }}" + dest: "{{ munin_plugin_dest_path }}{{ item.name }}" + state: link + notify: restart munin-node + loop: "{{ munin_node_plugins }}" + + - name: copy additional plugin-config + copy: + content: "{{ item.config }}" + dest: "{{ munin_plugin_conf_dest_path }}{{ item.name }}" + notify: restart munin-node + loop: "{{ munin_node_plugins }}" + when: item.config is defined + + - name: Ensure munin-node is running. + service: + name: munin-node + state: started + enabled: yes diff --git a/roles/mgrote.munin-node/tasks/install.yml b/roles/mgrote.munin-node/tasks/install.yml new file mode 100644 index 00000000..0efd0fa0 --- /dev/null +++ b/roles/mgrote.munin-node/tasks/install.yml @@ -0,0 +1,36 @@ +--- + - name: install packages + apt: + name: munin-node + state: present + register: install + + - name: create directories + file: + path: "{{ item }}" + state: directory + loop: + - /etc/munin + - /etc/munin/plugin-conf.d + - /etc/munin/plugins + + - name: Copy munin-node configuration. + template: + src: munin-node.conf.j2 + dest: /etc/munin/munin-node.conf + owner: root + group: root + mode: 0644 + notify: restart munin-node + + - name: munin-node-configure --shell + ansible.builtin.shell: munin-node-configure --shell + register: output_conf + changed_when: "output_conf.rc != 0" + ignore_errors: yes # ignoriere fehler + when: install.changed + + - name: munin-node-configure --shell - 2 + ansible.builtin.shell: munin-node-configure --shell --families=contrib,auto | sh -x + ignore_errors: yes # ignoriere fehler + when: install.changed diff --git a/roles/mgrote.munin-node/tasks/main.yml b/roles/mgrote.munin-node/tasks/main.yml index bbf1f72a..a6b26c06 100644 --- a/roles/mgrote.munin-node/tasks/main.yml +++ b/roles/mgrote.munin-node/tasks/main.yml @@ -1,71 +1,9 @@ --- - - name: install packages - apt: - name: munin-node - state: present - register: install - - - name: create directories - file: - path: "{{ item }}" - state: directory - loop: - - /etc/munin - - /etc/munin/plugin-conf.d - - /etc/munin/plugins - - - name: Copy munin-node configuration. - template: - src: munin-node.conf.j2 - dest: /etc/munin/munin-node.conf - owner: root - group: root - mode: 0644 - notify: restart munin-node - - - name: Generate plugin configuration. - template: - src: plugin-conf.j2 - dest: /etc/munin/plugin-conf.d/ansible.conf - owner: root - group: root - mode: 0644 - notify: restart munin-node - - - name: munin-node-configure --shell - ansible.builtin.shell: munin-node-configure --shell - register: output_conf - changed_when: "output_conf.rc != 0" - ignore_errors: yes # ignoriere fehler - when: install.changed - - - name: Install additional plugins. - get_url: - url: "{{ item.src }}" - dest: "{{ munin_plugin_src_path }}{{ item.name }}" - mode: '0755' - loop: "{{ munin_node_additional_plugins }}" - when: (item.src is defined) and (item.name is defined) - - - name: Enable additional plugins. - file: - src: "{{ munin_plugin_src_path }}{{ item.name }}" - dest: "{{ munin_plugin_dest_path }}{{ item.name }}" - state: link - loop: "{{ munin_node_additional_plugins }}" - notify: restart munin-node - when: item.name is defined - - - name: disable unwanted plugins - file: - path: "{{ munin_plugin_dest_path }}{{ item.name }}" - state: absent - loop: "{{ munin_node_disabled_plugins }}" - notify: restart munin-node - when: item.name is defined - - - name: Ensure munin-node is running. - service: - name: munin-node - state: started - enabled: yes + - name: include install-tasks + include_tasks: install.yml + - name: include plugin-tasks + include_tasks: additional.yml + when: munin_node_plugins is defined + - name: include remove-tasks + include_tasks: remove.yml + when: munin_node_disabled_plugins is defined diff --git a/roles/mgrote.munin-node/tasks/remove.yml b/roles/mgrote.munin-node/tasks/remove.yml new file mode 100644 index 00000000..356a1ce0 --- /dev/null +++ b/roles/mgrote.munin-node/tasks/remove.yml @@ -0,0 +1,16 @@ +--- + - name: remove unwanted plugins + file: + path: "{{ munin_plugin_dest_path }}{{ item.name }}" + state: absent + loop: "{{ munin_node_disabled_plugins }}" + notify: restart munin-node + when: munin_node_disabled_plugins is defined + + - name: remove additional plugin-config + file: + state: absent + dest: "{{ munin_plugin_conf_dest_path }}{{ item.name }}" + notify: restart munin-node + loop: "{{ munin_node_disabled_plugins }}" + when: munin_node_disabled_plugins is defined diff --git a/roles/mgrote.munin-node/templates/munin-node.conf.j2 b/roles/mgrote.munin-node/templates/munin-node.conf.j2 index 68cc60df..ac2aeabb 100644 --- a/roles/mgrote.munin-node/templates/munin-node.conf.j2 +++ b/roles/mgrote.munin-node/templates/munin-node.conf.j2 @@ -1,7 +1,6 @@ {{ file_header | default () }} -# -log_level 4 +log_level {{ munin_node_log_level }} log_file {{ munin_node_log }} pid_file {{ munin_node_pid }} diff --git a/roles/mgrote.munin-node/templates/plugin-conf.j2 b/roles/mgrote.munin-node/templates/plugin-conf.j2 deleted file mode 100644 index 7bd8b2f4..00000000 --- a/roles/mgrote.munin-node/templates/plugin-conf.j2 +++ /dev/null @@ -1,8 +0,0 @@ -{{ file_header | default () }} -{% for section,directives in munin_node_config.items() | list %} -[{{section}}] -{% for name,val in directives.items() | list %} -{{ name }} {{ val }} -{% endfor %} - -{% endfor %}