-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
👌 IMPROVE: Move resource service to systemd
- Loading branch information
1 parent
1cb6dd5
commit d1b9a2f
Showing
12 changed files
with
93 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[Unit] | ||
Description=Set SLURM compute resources | ||
Before=slurmctld.target slurmd.target | ||
ConditionPathExists=/etc/slurm-llnl/update-playbook.yml | ||
|
||
[Service] | ||
Type=oneshot | ||
Environment=ANSIBLE_LOCAL_TEMP=%h/.ansible/tmp | ||
Environment=ANSIBLE_REMOTE_TEMP=%h/.ansible/tmp | ||
ExecStart=/usr/bin/ansible-playbook /etc/slurm-llnl/update-playbook.yml -v | ||
TimeoutStartSec=60 | ||
|
||
StandardOutput=syslog | ||
StandardError=syslog | ||
SyslogIdentifier=slurm-resources | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,14 @@ | ||
#!/bin/sh | ||
### BEGIN INIT INFO | ||
# Provides: set-resources | ||
# Required-Start: $remote_fs $syslog | ||
# Required-Stop: $remote_fs $syslog | ||
# X-Start-Before: slurmctld slurmd | ||
# Default-Start: 2 3 4 5 | ||
# Default-Stop: 0 1 6 | ||
# Short-Description: Set SLURM compute resources | ||
# Description: Set SLURM compute resources | ||
### END INIT INFO | ||
|
||
run_update () | ||
{ | ||
# TODO ideally we would also output stderr to the log file | ||
# but for some reason 2>&1 makes $* in slurm-update-resources also read the log path as a variable | ||
export ANSIBLE_LOCAL_TEMP=$HOME/.ansible/tmp | ||
export ANSIBLE_REMOTE_TEMP=$HOME/.ansible/tmp | ||
/usr/bin/slurm-update-resources -v | ||
} | ||
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then | ||
echo "This script calls ansible-playbook to update the slurm configuration" | ||
echo "You can add options such as:" | ||
echo "" | ||
echo "- Restart SLURM (for changes to take affect): -e restart_slurm=true" | ||
echo "- Restart SLURM only on changes: -e restart_on_change=true" | ||
echo "- Change the maximum cpus allowed: -e slurm_max_cpus=2" | ||
echo "- Change the verbosity with: -vv" | ||
exit 0 | ||
fi | ||
|
||
case "$1" in | ||
start) | ||
run_update | ||
;; | ||
stop) | ||
echo "stopped" | ||
;; | ||
restart) | ||
run_update | ||
;; | ||
try-restart|condrestart) | ||
run_update | ||
;; | ||
reload) | ||
run_update | ||
;; | ||
force-reload) | ||
run_update | ||
;; | ||
status) | ||
echo "no status to report" | ||
;; | ||
*) | ||
COMMANDS="start|stop|restart|try-restart|reload|force-reload|status" | ||
echo "Usage: `basename \"$0\"` ($COMMANDS)" >&2 | ||
exit 2 # invalid or excess argument(s) | ||
;; | ||
esac | ||
/usr/bin/ansible-playbook /etc/slurm-llnl/update-playbook.yml $@ |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,9 @@ | ||
- hosts: all | ||
|
||
pre_tasks: | ||
|
||
- name: Update apt cache. | ||
become: true | ||
apt: | ||
update_cache: yes | ||
cache_valid_time: 600 | ||
when: ansible_os_family == 'Debian' | ||
|
||
vars: | ||
- run_tests: true | ||
- cloud_platform: docker | ||
- slurm_hostname_service: true | ||
- slurm_resources_service: true | ||
|
||
roles: | ||
- role: marvel-nccr.slurm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
- hosts: all | ||
|
||
tasks: | ||
# normally only started on init | ||
- name: check starting slurm-resources | ||
become: true | ||
systemd: | ||
name: slurm-resources.service | ||
state: started | ||
|
||
- name: check running slurm-resources script | ||
command: slurm-resources -e restart_slurm=true -e slurm_max_cpus=2 | ||
changed_when: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,32 @@ | ||
# Adds a system service that re-configures the slurm compute resources on startup | ||
# Note: This is necessary when preparing image that can start on a different hardware than it was built on | ||
|
||
- name: copy init.d template | ||
- name: create configuration update playbook | ||
become: true | ||
template: | ||
src: config-playbook.yml.j2 | ||
dest: /etc/slurm-llnl/update-playbook.yml | ||
|
||
- name: copy confinguration update executable | ||
become: true | ||
copy: | ||
src: "slurm-resources.sh" | ||
dest: "/etc/init.d/slurm-resources" | ||
mode: 0755 | ||
src: slurm-resources.sh | ||
dest: /usr/bin/slurm-resources | ||
mode: u=rwx,g=rx,o=rx | ||
|
||
- name: enable service to set the slurm compute resources | ||
- name: Add slurm-resources as system service | ||
become: true | ||
command: update-rc.d slurm-resources defaults | ||
args: | ||
creates: "/etc/rc5.d/S??slurm-resources" | ||
copy: | ||
src: slurm-resources.service | ||
dest: /etc/systemd/system | ||
owner: "{{ root_user | default('root') }}" | ||
group: "{{ root_user | default('root') }}" | ||
mode: 0644 | ||
when: ansible_service_mgr == "systemd" | ||
|
||
- name: start service to set the slurm compute resources | ||
- name: Setup slurm-resources system service (systemd) | ||
become: true | ||
service: | ||
name: slurm-resources | ||
state: started | ||
systemd: | ||
name: slurm-resources.service | ||
enabled: "{{ slurm_resources_service_enabled }}" | ||
when: ansible_service_mgr == "systemd" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters