- name: get munge
  shell: wget https://munge.googlecode.com/files/munge-{{ munge_version }}.tar.bz2
  args:
    chdir: /tmp
    creates: /tmp/munge-{{ munge_version }}.tar.bz2

- name: untar munge
  shell: tar jxf munge-{{ munge_version }}.tar.bz2
  args:
    chdir: /tmp
    creates: /tmp/munge-{{ munge_version }}

- name: build munge
  shell: ./configure --prefix={{ munge_dir }} && make
  args:
    chdir: /tmp/munge-{{ munge_version }}
    creates: /tmp/munge-{{ munge_version }}/src/munge/munge

- name: install munge
  shell: make install
  sudo: true
  args:
    chdir: /tmp/munge-{{ munge_version }}
    creates: "{{ munge_dir }}/bin/munge"

- name: copy init script
  template: dest=/etc/init.d/munge src=munge.initd.j2 mode=755
  sudo: true

- name: start on boot
  shell: update-rc.d munge defaults
  sudo: true
  when: ansible_distribution == "Ubuntu"
