---

- name: install required packages for munin-node
  apt:
    force_apt_get: true
    install_recommends: false
    state: latest
    name:
      - munin-node
      - ubicast-munin
  register: apt_status
  retries: 60
  until: apt_status is success or ('Failed to lock apt for exclusive operation' not in apt_status.msg and '/var/lib/dpkg/lock' not in apt_status.msg)

- name: copy munin-node configuration
  notify: restart munin-node
  template:
    src: munin-node.conf.j2
    dest: /etc/munin/munin-node.conf

- name: setup munin-node plugins link
  notify: restart munin-node
  shell:
    cmd: munin-node-configure --shell --remove-also 2>&1 | sh -x
  # sh -x print executed cmd to stderr
  register: munin_plugin_linked
  changed_when: munin_plugin_linked.stderr | length > 0

...
