---
- name: Install required SLURM packages (Debain/Ubuntu)
  action: apt pkg={{item}} update_cache=yes force=yes state=latest
  with_items:
    - slurm-llnl
    - munge
  when: is_debian_or_ubuntu

- name: Install base system packages (Amazon AMIs)
  yum: name={{item}} state=latest
  with_items:
    - perl-core
    - perl-Switch
  when: is_amazon

- name: Install required SLURM packages (CentOS)
  yum: name={{item}} state=latest
  with_items:
    - munge
    - munge-devel
    - pam-devel
    - readline-devel
    - openssl-devel
    - perl-ExtUtils-MakeMaker
    - perl-DBI
    - rpm-build
    - gcc
    - mysql-devel
  when: is_centos

- name: Download SLURM source package (CentOS)
  get_url: url={{slurm_src_baseurl}}/{{slurm_src_filename}} dest=/tmp/{{slurm_src_filename}}
  when: is_centos

- name: Recompile SLURM source package (CentOS)
  shell: rpmbuild -ta /tmp/{{slurm_src_filename}} creates=/root/rpmbuild/RPMS/x86_64/{{slurm_pkg_name}}
  when: is_centos

- name: Install SLURM packages (CentOS)
  shell: rpm -i /root/rpmbuild/RPMS/x86_64/slurm-*rpm creates=/etc/slurm/slurm.conf.example
  when: is_centos

- name: Create slurm user (CentOS)
  user: name=slurm system=yes
  when: is_centos

- include: slurm.yml
- include: munge.yml
