-
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.
Add script and service to automatically update computer resources (#6)
- Loading branch information
Showing
11 changed files
with
170 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
*~ | ||
*.swp | ||
.DS_Store | ||
.vscode/ | ||
.galaxy_install_info |
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,49 @@ | ||
#!/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 | ||
} | ||
|
||
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 |
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,14 @@ | ||
#!/bin/sh | ||
|
||
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 | ||
|
||
/usr/bin/ansible-playbook /etc/slurm-llnl/update-playbook.yml $@ |
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
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,22 @@ | ||
--- | ||
# 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 | ||
become: true | ||
copy: | ||
src: "slurm-resources.sh" | ||
dest: "/etc/init.d/slurm-resources" | ||
mode: 0755 | ||
|
||
- name: enable service to set the slurm compute resources | ||
become: true | ||
command: update-rc.d slurm-resources defaults | ||
args: | ||
creates: "/etc/rc5.d/S??slurm-resources" | ||
|
||
- name: start service to set the slurm compute resources | ||
become: true | ||
service: | ||
name: slurm-resources | ||
state: started |
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,38 @@ | ||
- name: Update SLURM configuration | ||
hosts: localhost | ||
|
||
vars: | ||
slurm_hostname: "{{ slurm_hostname }}" | ||
slurm_partition_name: "{{ slurm_partition_name }}" | ||
{% raw %} | ||
slurm_conf_file: /etc/slurm-llnl/slurm.conf | ||
slurm_max_cpus: "{{ ansible_processor_vcpus }}" | ||
restart_on_change: false | ||
restart_slurm: false | ||
|
||
tasks: | ||
|
||
- debug: | ||
msg: "Run: {{ lookup('pipe', 'date +%Y-%m-%d-%H:%M:%S') }}" | ||
|
||
- name: Update SLURM configuration | ||
become: true | ||
blockinfile: | ||
path: "{{ slurm_conf_file }}" | ||
marker: "# {mark} ANSIBLE MANAGED NODES" | ||
block: | | ||
NodeName={{ slurm_hostname }} Sockets={{ ansible_processor_count }} CoresPerSocket={{ ansible_processor_cores }} ThreadsPerCore={{ ansible_processor_threads_per_core }} State=UNKNOWN | ||
PartitionName={{ slurm_partition_name }} Nodes={{ slurm_hostname }} Default=YES MaxTime=INFINITE State=UP MaxNodes=1 MaxCPUsPerNode={{ slurm_max_cpus }} | ||
backup: yes | ||
register: update | ||
|
||
- name: Restart Slurm | ||
when: (update.changed and restart_on_change | bool) or (restart_slurm | bool) | ||
become: true | ||
service: | ||
name: "{{ item }}" | ||
state: restarted | ||
with_items: | ||
- slurmctld | ||
- slurmd | ||
{% endraw %} |
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