---
- name: copy rpms
  copy: src=/tmp/rpmbuild dest=/tmp
  sudo: true

- name: install munge rpms
  shell: "rpm --install /tmp/rpmbuild/RPMS/x86_64/munge*{{ munge_version }}*rpm"
  sudo: true
  ignore_errors: true

- name: install perl
  yum: name={{ item }} state=latest
  with_items:
    - perl
    - perl-DBI
  sudo: true

- name: create slurm group
  group: name=slurm system=yes
  sudo: true

- name: create slurm user
  user: name=slurm group=slurm system=yes createhome=no
  sudo: true

- name: install slurm rpms
  shell: "rpm --install /tmp/rpmbuild/RPMS/x86_64/slurm*{{ slurm_version }}*rpm"
  sudo: true
  ignore_errors: true

- name: install munge key
  template: src=munge_key.j2 dest=/etc/munge/munge.key
  sudo: true
  notify: restart munge

- name: start munge
  service: name=munge state=started
  sudo: true

- name: install slurm.conf
  template: src=slurm.conf.j2 dest=/etc/slurm/slurm.conf
  sudo: true
  notify: restart slurm
  when: slurm_use_vpn==False

- name: install slurm.conf
  template: src=slurm-vpn.conf.j2 dest=/etc/slurm/slurm.conf
  sudo: true
  notify: restart slurm
  when: slurm_use_vpn==True

- name: create data directory
  file: path="{{ slurmdatadir }}" state=directory owner=slurm group=slurm mode=755 
  sudo: true

- name: create log directory
  shell: mkdir -p {{ slurmddebug.log | dirname }}; chown slurm:slurm {{ slurmddebug.log | dirname }} 
  args:
    creates: "{{ slurmddebug.log | dirname }}"
  sudo: true
  when: slurmddebug is defined and slurmddebug.log

- name: start slurm
  service: name=slurm state=started
  sudo: true
