Skip to content

Commit

Permalink
Merge upstream and cherry-pick fixes (#3)
Browse files Browse the repository at this point in the history
* Added cluster creation to slurmdb install

* Refactored order in which cluster is created

* review order of restarting service

should follow this order when restarting :
- slurmdbd
- slurmctld
- slurmd

* Fix syntax error in handlers

* Fix typo in handler name

(cherry picked from commit 712cf32)

* Remove key 'SlurmctldPidFile' from __slurmdbd_config_default

(cherry picked from commit 936e64a)

---------

Co-authored-by: slugger70 <[email protected]>
Co-authored-by: Christian IUGA <[email protected]>
Co-authored-by: Nate Coraor <[email protected]>
Co-authored-by: Nuwan Goonasekera <[email protected]>
Co-authored-by: Christopher Lilienthal <[email protected]>
Co-authored-by: cat-bro <[email protected]>
  • Loading branch information
7 people authored Sep 29, 2023
1 parent 68c88a2 commit ccc9351
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 20 deletions.
7 changes: 5 additions & 2 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ slurmd_service_name: slurmd
slurmctld_service_name: slurmctld
slurmdbd_service_name: slurmdbd

#Cluster name for slurm config. This is required to correctly setup slurmdbd and attune it to the slurm config.
__slurm_cluster_name: cluster
__cluster_not_setup: true #Default value. Is modified if cluster already exists.

slurm_start_services: true


Expand Down Expand Up @@ -48,7 +52,7 @@ __slurm_config_default:
AuthType: auth/munge
CryptoType: crypto/munge
SlurmUser: "{{ __slurm_user_name }}"
ClusterName: cluster
ClusterName: "{{ __slurm_cluster_name }}"
# default is proctrack/cgroup which is the best but also less than 100% chance of working e.g. in docker
ProctrackType: proctrack/pgid
# slurmctld options
Expand Down Expand Up @@ -93,6 +97,5 @@ __slurmdbd_config_default:
AuthType: auth/munge
DbdPort: 6819
SlurmUser: "{{ __slurm_user_name }}"
SlurmctldPidFile: "{{ __slurm_run_dir ~ '/slurmdbd.pid' if __slurm_debian else omit }}"
LogFile: "{{ __slurm_log_dir ~ '/slurmdbd.log' if __slurm_debian else omit }}"
__slurmdbd_config_merged: "{{ __slurmdbd_config_default | combine(slurmdbd_config | default({})) }}"
33 changes: 15 additions & 18 deletions handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
name: munge
state: restarted

- name: Reload slurmd
- name: Reload slurmdbd
ansible.builtin.service:
name: "{{ slurmd_service_name }}"
name: "{{ slurmdbd_service_name }}"
state: reloaded
when: "slurm_start_services and ('slurmexechosts' in group_names or 'exec' in slurm_roles)"
when: "slurm_start_services and ('slurmdbdservers' in group_names or 'dbd' in slurm_roles)"

- name: Restart slurmd
- name: Restart slurmdbd
ansible.builtin.systemd:
name: "{{ slurmd_service_name }}"
name: "{{ slurmdbd_service_name }}"
state: restarted
masked: no
enabled: yes
daemon_reload: yes
when: "slurm_start_services and ('slurmexechosts' in group_names or 'exec' in slurm_roles)"
when: "slurm_start_services and ('slurmservers' in group_names or 'controller' in slurm_roles)"

- name: Reload slurmctld
ansible.builtin.service:
Expand All @@ -34,17 +34,14 @@
daemon_reload: yes
when: "slurm_start_services and ('slurmservers' in group_names or 'controller' in slurm_roles)"

- name: Restart slurmdbd
ansible.builtin.systemd:
name: "{{ slurmdbd_service_name }}"
state: restarted
masked: no
enabled: yes
daemon_reload: yes
when: "slurm_start_services and ('slurmservers' in group_names or 'controller' in slurm_roles)"

- name: Reload slurmdbd
- name: Reload slurmd
ansible.builtin.service:
name: "{{ slurmdbd_service_name }}"
name: "{{ slurmd_service_name }}"
state: reloaded
when: "slurm_start_services and ('slurmdbdservers' in group_names or 'dbd' in slurm_roles)"
when: "slurm_start_services and ('slurmexechosts' in group_names or 'exec' in slurm_roles)"

- name: Restart slurmd
ansible.builtin.service:
name: "{{ slurmd_service_name }}"
state: restarted
when: "slurm_start_services and ('slurmexechosts' in group_names or 'exec' in slurm_roles)"
4 changes: 4 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,7 @@
enabled: true
state: started
when: "slurm_start_services and ('slurmexechosts' in group_names or 'exec' in slurm_roles)"

- name: Setup cluster on slurmdb
include_tasks: slurmdbd_cluster.yml
when: "slurm_start_services and ('slurmdbdservers' in group_names or 'dbd' in slurm_roles)"
20 changes: 20 additions & 0 deletions tasks/slurmdbd_cluster.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---

- name: Check for existence of cluster in db.
register: cluster_check
shell: "sacctmgr -n list cluster | cut -f 4 -d ' '"
become: yes
become_user: root

- name: set cluster_check_boolean
set_fact:
__cluster_not_setup: false
when: cluster_check.stdout == "cluster"

- name: Create the slurmdbd cluster
command: sacctmgr -i -n add cluster {{ __slurm_cluster_name }}
become: yes
become_user: root
notify:
- Reload slurmdbd
when: __cluster_not_setup

0 comments on commit ccc9351

Please sign in to comment.