---

- name: install packages for slurm
  yum: 
    name:
      - munge
      - mariadb
      - mariadb-devel
      - python3
    state: present
  tags: install

- name: create munge key
  command: /usr/sbin/create-munge-key -f
  tags: install

- name: Copy munge key
  copy:
    src: munge.key
    dest: /etc/munge
    owner: munge
    group: munge
    mode: 0400
  tags: install

- name: Copy example Slurm Configuration - slurm.conf
  copy:
    src: slurm.conf
    dest: /etc/slurm/
    mode: 0644
  tags: install


- name: create SLURM Group
  group: 
    name: slurm 
    state: present
  tags: install

- name: Add the user 'slurm' with uid 6001 and a primary group of 'slurm'
  user:
    name: slurm
    comment: Slurm User Account
    uid: 6001
    group: slurm
  tags: install

- name: create SLURM log directory
  file:
    path: /var/log/slurm
    state: directory
    owner: slurm
    group: slurm
    mode: 0755
    recurse: yes
  tags: install

- name: give slurm user permission to spool
  file: 
    path: /var/spool/slurm
    owner: slurm
    group: slurm
    state: directory
    mode: 0755
    recurse: yes

- name: give slurm user permission to slurmctld
  file: 
    path: /var/run/slurmctld.pid
    owner: slurm
    group: slurm
    mode: 0755
    state: touch

- name: give slurm user permission to slurmd
  file: 
    path: /var/run/slurmd.pid
    owner: slurm
    group: slurm
    mode: 0755
    state: touch

- name: start munge service
  service:
    name: munge 
    state: restarted
    enabled: yes
  tags: install



