ansible_slurm/tasks/main.yml
Nate Coraor bfe0907a59 Slurm role improvements:
- Have it create its own user account if so configured, since relying on the
  users common role tramples other group_users configs.
- Don't have it set up its own yum repo since the same yum repo is used by
  other things and was being used multiple times.
2017-04-04 11:32:23 -04:00

172 lines
4.0 KiB
YAML

---
- name: Include OS vars
include_vars: "{{ ansible_os_family | lower }}.yml"
- name: Create slurm group
group:
name: "{{ slurm_user.name | default('slurm') }}"
gid: "{{ slurm_user.gid | default(omit) }}"
system: "{{ slurm_user.system | default('yes') }}"
when: slurm_user is defined
- name: Create slurm user
user:
name: "{{ slurm_user.name | default('slurm') }}"
comment: "{{ slurm_user.comment | default(omit) }}"
uid: "{{ slurm_user.uid | default(omit) }}"
group: "{{ slurm_user.group | default(slurm_user.name | default('slurm')) }}"
groups: "{{ slurm_user.groups | default(omit) }}"
home: "{{ slurm_user.home | default(omit) }}"
shell: "{{ slurm_user.shell | default(omit) }}"
system: "{{ slurm_user.system | default('yes') }}"
when: slurm_user is defined
- name: Install Slurm (apt)
apt:
pkg: slurm-llnl
when: ansible_os_family == "Debian"
- name: Install Slurm (yum)
yum:
name: "{{ item }}"
with_items:
- munge
- munge-libs
- slurm-plugins
- slurm
- slurm-devel
- slurm-munge
- slurm-pam_slurm
#- slurm-perlapi
- slurm-sjobexit
- slurm-sjstat
- slurm-slurmdb-direct
- slurm-slurmdbd
#- slurm-sql
#- slurm-torque
when: ansible_os_family == "RedHat"
# FIXME: this task will fail if slurmservers[0] has not already completed the slurm.conf task that follows it
- name: Acquire hostlist
command: scontrol show hostlist {{ groups[item.inventory_group] | join(",") }}
with_items: "{{ slurm_nodes | default([]) }}"
delegate_to: "{{ groups['slurmservers'][0] }}"
run_once: true
register: slurm_hostlists
- name: Install slurm.conf
template:
src: "{{ slurm_conf_src | default( 'templates/slurm/slurm.conf.j2' ) }}"
dest: "{{ slurm_conf_dir }}/slurm.conf"
owner: root
group: root
mode: 0444
notify:
- restart slurmd
- restart slurmctld
- name: Install slurmdbd.conf
template:
src: slurmdbd.conf.j2
dest: "{{ slurm_conf_dir }}/slurmdbd.conf"
owner: slurm
group: root
mode: 0400
notify:
- reload slurmdbd
when: "'slurmdbdservers' in group_names"
- name: Create slurm spool directory
file:
path: "{{ slurmd_spool_dir }}"
owner: root
group: root
mode: 0755
state: directory
notify:
- reload slurmd
- name: Create slurm state directory
file:
path: "{{ slurmctld_state_dir }}"
owner: slurm
group: slurm
mode: 0700
state: directory
when: "'slurmservers' in group_names"
notify:
- reload slurmctld
- name: Create slurm log directory
file:
path: "/var/log/{{ slurm_log_dir_name }}"
owner: slurm
group: slurm
mode: 0755
state: directory
when: "'slurmservers' in group_names"
- name: Check munge dir
file:
path: /etc/munge
owner: munge
group: munge
mode: 0700
state: directory
- name: Install munge key
action:
module: decode
args:
content: "{{ munge_key }}"
dest: /etc/munge/munge.key
filter: base64
owner: munge
group: munge
mode: 0400
# /var/log on Ubuntu 14.04+ is group writable, which causes munge to refuse to start
# NOTE: This is fixed in munge 0.5.12
- name: Check /var/log permissions
stat:
path: /var/log
register: stat_var_log
- name: Force munge to start with "insecure" /var/log permissions
lineinfile:
dest: /etc/default/munge
line: 'OPTIONS="--force"'
regexp: ^OPTIONS=
when: stat_var_log.stat.wgrp
- name: Ensure Munge is running
service:
name: munge
enabled: yes
state: started
- name: Ensure slurmd is running
service:
name: "{{ slurmd_service_name }}"
enabled: yes
state: started
when: "'slurmexechosts' in group_names"
- name: Ensure slurmctld is running
service:
name: "{{ slurmctld_service_name }}"
enabled: yes
state: started
when: "'slurmservers' in group_names"
- name: Ensure slurmdbd is running
service:
name: "{{ slurmdbd_service_name }}"
enabled: yes
state: started
when: "'slurmdbdservers' in group_names"
- include: elastic.yml
when: "'slurmelasticservers' in group_names"