Skip to content

Commit

Permalink
Add new custom services (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmam authored Apr 24, 2023
1 parent 3c54690 commit b713a8a
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 2 deletions.
3 changes: 3 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ slurmdbd_service_name: slurmdbd

slurm_start_services: true

#to setup custom systemd unit files
slurm_configure_systemd: false

__slurm_user_name: "{{ (slurm_user | default({})).name | default('slurm') }}"
# TODO: this could be incorrect, use the group collection from galaxyproject.galaxy
__slurm_group_name: "{{ (slurm_user | default({})).group | default(omit) }}"
Expand Down
15 changes: 15 additions & 0 deletions files/slurmctld.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Unit]
Description=Slurm controller daemon
After=network.target slurmdbd.service munge.service
ConditionPathExists=/etc/slurm/slurm.conf

[Service]
Type=simple
EnvironmentFile=-/etc/sysconfig/slurmctld
ExecStart=/opt/slurm/sbin/slurmctld $SLURMCTLD_OPTIONS
ExecReload=/bin/kill -HUP $MAINPID
PIDFile=/var/run/slurm/slurmctld.pid
RuntimeDirectory=slurm

[Install]
WantedBy=multi-user.target
23 changes: 23 additions & 0 deletions files/slurmd.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[Unit]
Description=Slurm node daemon
After=network.target munge.service
Wants=network-online.target
ConditionPathExists=/etc/slurm/slurm.conf

[Service]
Type=simple
EnvironmentFile=-/etc/default/slurmd
ExecStartPre=/bin/mkdir -p /var/run/slurm
ExecStart=/opt/slurm/sbin/slurmd -D -s $SLURMD_OPTIONS
ExecReload=/bin/kill -HUP $MAINPID
PIDFile=/var/run/slurm/slurmd.pid
KillMode=process
LimitNOFILE=131072
LimitMEMLOCK=infinity
LimitSTACK=infinity
Delegate=yes
TasksMax=20000


[Install]
WantedBy=multi-user.target
18 changes: 18 additions & 0 deletions files/slurmdbd.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[Unit]
Description=Slurm controller daemon
After=network.target munge.service mysql.service mysqld.service mariadb.service
Wants=network-online.target
ConditionPathExists=/etc/slurm/slurm.conf

[Service]
Type=simple
EnvironmentFile=-/etc/default/slurmdbd
ExecStartPre=-/usr/bin/ls /var/lib/slurm/slurmctld
ExecStart=/opt/slurm/sbin/slurmdbd -D -s $SLURMDBD_OPTIONS
ExecReload=/bin/kill -HUP $MAINPID
PIDFile=/var/run/slurm/slurmdbd.pid
LimitNOFILE=65536
RuntimeDirectory=slurm

[Install]
WantedBy=multi-user.target
19 changes: 17 additions & 2 deletions handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@
when: "slurm_start_services and ('slurmexechosts' in group_names or 'exec' in slurm_roles)"

- name: Restart slurmd
ansible.builtin.service:
ansible.builtin.systemd:
name: "{{ slurmd_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)"

- name: Reload slurmctld
Expand All @@ -23,9 +26,21 @@
when: "slurm_start_services and ('slurmservers' in group_names or 'controller' in slurm_roles)"

- name: Restart slurmctld
ansible.builtin.service:
ansible.builtin.systemd:
name: "{{ slurmctld_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: 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
Expand Down
11 changes: 11 additions & 0 deletions tasks/slurmctld.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@
state: directory
when: slurm_create_dirs and __slurm_config_merged.SlurmctldLogFile != omit

- name: Add slurmctld service
ansible.builtin.copy:
src: slurmctld.service
dest: /etc/systemd/system/slurmctld.service
owner: root
group: root
mode: 0644
when: slurm_configure_systemd
notify:
- Restart slurmctld

- name: Include config dir creation tasks
ansible.builtin.include_tasks: _inc_create_config_dir.yml
when: slurm_create_dirs
Expand Down
11 changes: 11 additions & 0 deletions tasks/slurmd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@
state: directory
when: slurm_create_dirs and __slurm_config_merged.SlurmdLogFile != omit

- name: Add slurmd service
ansible.builtin.copy:
src: slurmd.service
dest: /etc/systemd/system/slurmd.service
owner: root
group: root
mode: 0644
when: slurm_configure_systemd
notify:
- Restart slurmd

- name: Include config dir creation tasks
ansible.builtin.include_tasks: _inc_create_config_dir.yml
when: slurm_create_dirs
Expand Down
11 changes: 11 additions & 0 deletions tasks/slurmdbd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@
- name: Include config dir creation tasks
ansible.builtin.include_tasks: _inc_create_config_dir.yml
when: slurm_create_dirs

- name: Add slurmdbd service
ansible.builtin.copy:
src: slurmdbd.service
dest: /etc/systemd/system/slurmdbd.service
owner: root
group: root
mode: 0644
when: slurm_configure_systemd
notify:
- Restart slurmdbd

- name: Install slurmdbd.conf
ansible.builtin.template:
Expand Down

0 comments on commit b713a8a

Please sign in to comment.