---

- name: install munge from apt
  apt: name=munge update_cache=yes cache_valid_time=3600 state=present

- name: copy munge key
  copy: src=munge.key
        dest=/etc/munge/munge.key
        owner=munge group=munge mode=0400
  notify: restart munge

- name: configure munge
  copy: src=etc-default-munge
        dest=/etc/default/munge
        mode=0644 owner=root group=root
  notify: restart munge

- name: create munge directories
  file:
    path: "{{item.path}}"
    mode: "{{item.mode}}"
    owner: "{{item.owner}}"
    group: "{{item.group}}"
    state: directory
  with_items:
    - { path: /var/lib/munge/, mode: "0711", owner: munge, group: munge }
    - { path: /var/log/munge/, mode: "0700", owner: munge, group: munge }
    - { path: /var/run/munge/, mode: "0755", owner: munge, group: root }

- name: munge is started and enabled
  service: name=munge state=started enabled=yes
