---
- name: make sure slurm conf dir exists
  file: dest={{ slurm_dir }}/etc state=directory
  sudo: true

- name: make sure slurm lock dir exists
  file: dest=/var/lock/subsys state=directory owner=root group=root mode=755
  sudo: true

- name: create data directory
  file: path={{ slurmdatadir }} state=directory owner=slurm group=slurm mode=755
  sudo: true
  when: slurmdatadir is defined 
      
- name: stat run directory
  stat: path={{ slurmpiddir }} 
  become_user: root
  become: True
  register: runstat
  when: slurmpiddir is defined

- name: create run directory
  file: path={{ slurmpiddir }} state=directory owner=slurm group=slurm mode=755
  sudo: true
  when: slurmpiddir is defined and not runstat.stat.exists

- name: create shared state directory
  file: path={{slurmsharedstatedir }} state=directory owner=slurm group=slurm mode=750
  sudo: true
  run_once: true
  when: usesharedstatedir is defined and usesharedstatedir

- name: symlink shared state dir
  file: path={{ slurmstatedir }} src={{ slurmsharedstatedir }} state=link
  sudo: true
  when: usesharedstatedir is defined and usesharedstatedir

- name: create state directory
  file: path={{ slurmstatedir }} state=directory owner=slurm group=slurm mode=750
  sudo: true
  when: slurmstatedir is defined  and not usesharedstatedir

- name: create log directory
  file: path={{ slurmlogdir }} state=directory owner=slurm group=slurm mode=750
  sudo: true
  when: slurmlogdir is defined 

- name: make sure slurm conf dir exists
  file: dest={{ slurm_dir }}/etc state=directory
  sudo: true

- name: create greps directory
  file: path={{ slurm_dir }}/etc/gres state=directory owner=slurm group=slurm mode=755
  sudo: true

