---
# tasiks to enable munin stats on client node
- name: install munin client packages
  apt:
      name: "{{ item }}"
      state: present
  with_items:
      - "munin-node"
      - "munin-common"
      - "munin-plugins-core"
      - "munin-plugins-extra"

- name: enable remote host ipv4
  lineinfile:
      dest: "/etc/munin/munin-node.conf"
      regexp: "^allow \\^{{ munin_server_ipv4 }}\\$"
      insertafter: "^allow .*"
      line: "allow ^{{ munin_server_ipv4 }}$"
      backup: yes
      state: present

- name: enable remote host ipv6
  lineinfile:
      dest: "/etc/munin/munin-node.conf"
      regexp: "^allow \\^{{ munin_server_ipv6 }}\\$"
      insertafter: "^allow .*"
      line: "allow ^{{ munin_server_ipv6 }}$"
      state: present

- name: set host name in conf
  lineinfile:
      dest: "/etc/munin/munin-node.conf"
      regexp: "^host_name"
      insertafter: "^#host_name .*"
      line: "host_name {{ inventory_hostname }}"
      state: present
