---
- name: install deps in control node
  package:
    state: installed
    name:
      - mysql
      - mysql-devel
      - MySQL-python
    become: true
  when: ansible_os_family == "RedHat"

- name: install deps in control node
  apt: name={{ item }} state=installed
  become: true
  with_items:
    - mysql-client
    - libmysqlclient-dev
    - python-mysqldb
  when: ansible_os_family == "Debian"

- name: make sure config dir exists
  file: path="{{ slurm_dir }}/etc" state=directory
  become: true

- name: create slurm group
  group: name=slurm system=yes gid=497
  become: true

- name: create slurm user # this is duplicated from slurm-common
  user:
    name: slurm
    group: slurm
    system: yes
    createhome: no
    uid: 497
  become: true

- name: install slurmdb.conf
  copy:
    src: files/slurmdbd.conf
    dest: "{{ slurm_dir }}/etc/slurmdbd.conf"
    owner: slurm
    group: slurm
    mode: u+rw,g-wx,o-rwx
  become: true
  when: slurm_dir is defined


- name: install slurmdbd.conf
  copy:
    src: slurmdbd.conf
    dest: /etc/slurm/slurmdbd.conf
    owner: slurm
    group: slurm
    mode: u+rw,g-wx,o-rwx
  become: true
  when: slurm_dir is not defined

- name: add slurm db log rotate config
  template: src=slurmdblog.j2 dest=/etc/logrotate.d/slurmdb mode=644
  become: true

