commit baae605f91a0d5d721651a7647caa13f55a49dbc Author: Yohann Dedy Date: Fri Apr 17 01:29:15 2020 +0200 first commit diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..4254575 --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,6 @@ +--- +# defaults file for munin-node +munin_node_host_name: "{{ inventory_hostname }}" + +munin_node_ip_bind: "*" +munin_node_port: "4949" diff --git a/handlers/main.yml b/handlers/main.yml new file mode 100644 index 0000000..6ea64ed --- /dev/null +++ b/handlers/main.yml @@ -0,0 +1,5 @@ +--- +# handlers file for munin-node +- name: restart munin-node + action: service name=munin-node state=restarted daemon_reload=yes + listen: "restart services" diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..c7b822f --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,31 @@ +--- +# tasks file for munin-node +- name: Installation munin-node + apt: + pkg: + - munin-node + ignore_errors: yes + +- name: fix munin-node.service for LXC + template: + src: munin-node.service.j2 + dest: /lib/systemd/system/munin-node.service + mode: '0777' + backup: yes + when: + - "ansible_facts['virtualization_type'] == 'lxc'" + - "ansible_facts['distribution'] == 'Debian'" + - "ansible_facts['distribution_release'] == 'buster'" + +- name: copy munin-node.conf + template: + src: munin-node.conf.j2 + dest: /etc/munin/munin-node.conf + backup: yes + notify: restart munin-node + +- name: enable munin-node service + systemd: + name: munin-node + enabled: yes + diff --git a/templates/munin-node.conf.j2 b/templates/munin-node.conf.j2 new file mode 100644 index 0000000..e66d79e --- /dev/null +++ b/templates/munin-node.conf.j2 @@ -0,0 +1,29 @@ +log_level 4 +log_file /var/log/munin/munin-node.log +pid_file /var/run/munin/munin-node.pid + +background 1 +setsid 1 + +user root +group root + +ignore_file [\#~]$ +ignore_file DEADJOE$ +ignore_file \.bak$ +ignore_file %$ +ignore_file \.dpkg-(tmp|new|old|dist)$ +ignore_file \.rpm(save|new)$ +ignore_file \.pod$ + +{% for ip in munin_servers %} +allow ^{{ ip | regex_replace('\.', '\\\.') }}$ +{% endfor %} +allow ^127\.0\.0\.1$ +allow ^::1$ + +host_name {{ munin_node_host_name }} + +host {{ munin_node_ip_bind }} +port {{ munin_node_port }} + diff --git a/templates/munin-node.service.j2 b/templates/munin-node.service.j2 new file mode 100644 index 0000000..78f00d4 --- /dev/null +++ b/templates/munin-node.service.j2 @@ -0,0 +1,21 @@ +[Unit] +Description=Munin Node +Documentation=man:munin-node(1) http://munin.readthedocs.org/en/stable-2.0/reference/munin-node.html +After=network-online.target + +[Service] +EnvironmentFile=-/etc/default/munin-node +Type=forking +Restart=always +ExecStart=/usr/sbin/munin-node $DAEMON_ARGS +PIDFile=/run/munin/munin-node.pid + + +PrivateDevices=false +PrivateTmp=false +ProtectHome=false +ProtectSystem=false + +[Install] +WantedBy=multi-user.target +