Skip to content

Commit 0d372fb

Browse files
committed
make backup optional
1 parent 5c784c5 commit 0d372fb

File tree

4 files changed

+36
-8
lines changed

4 files changed

+36
-8
lines changed

README.md

+26-3
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,12 @@ accounting data such as start and end times. By default no job accounting is con
121121
`openhpc_slurm_job_comp_loc`: Location to store the job accounting records. Depends on value of
122122
`openhpc_slurm_job_comp_type`, e.g for `jobcomp/filetxt` represents a path on disk.
123123

124-
### slurmdbd.conf
124+
### slurmdbd
125125

126-
The following options affect `slurmdbd.conf`. Please see the slurm [documentation](https://slurm.schedmd.com/slurmdbd.conf.html) for more details.
127-
You will need to configure these variables if you have set `openhpc_enable.database` to `true`.
126+
When the slurm database daemon (`slurmdbd`) is enabled by setting
127+
`openhpc_enable.database` to `true` the following options must be configured.
128+
See documentation for [slurmdbd.conf](https://slurm.schedmd.com/slurmdbd.conf.html)
129+
for more details.
128130

129131
`openhpc_slurmdbd_port`: Port for slurmdb to listen on, defaults to `6819`.
130132

@@ -136,6 +138,27 @@ You will need to configure these variables if you have set `openhpc_enable.datab
136138

137139
`openhpc_slurmdbd_mysql_username`: Username for authenticating with the database, defaults to `slurm`.
138140

141+
Before starting `slurmdbd`, the role will check if a database upgrade is
142+
required to due to a a Slurm major version upgrade and carry it out if so.
143+
Slurm versions before 24.11 do not support this check and so no upgrade will
144+
occur. The following variables control behaviour during this upgrade:
145+
146+
`openhpc_slurm_accounting_storage_backup_cmd`: Optional. String (possibly
147+
multi-line) giving a command for `ansible.builtin.shell` to run a backup of the
148+
Slurm database before performing the databse upgrade. Default is the empty
149+
string which performs no backup.
150+
151+
`openhpc_slurm_accounting_storage_backup_host`: Optional. Inventory hostname
152+
defining host to run the backup command. Default is `openhpc_slurm_accounting_storage_host`.
153+
154+
`openhpc_slurm_accounting_storage_backup_become`: Optional. Whether to run the
155+
backup command as root. Default `true`.
156+
157+
`openhpc_slurm_accounting_storage_service`: Optional. Name of systemd service
158+
for the accounting storage database, e.g. `mysql`. If this is defined this
159+
service is stopped before the backup and restarted after, to allow for physical
160+
backups. Default is the empty string, which does not stop/restart any service.
161+
139162
## Facts
140163

141164
This role creates local facts from the live Slurm configuration, which can be

defaults/main.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,6 @@ openhpc_ram_multiplier: 0.95
105105

106106
# Database upgrade
107107
openhpc_slurm_accounting_storage_service: ''
108-
openhpc_slurm_accounting_storage_backup_cmd: "{{ undef(hint='openhpc_slurm_accounting_storage_backup_cmd must be defined if openhpc_slurm_accounting_storage_service is set') }}"
108+
openhpc_slurm_accounting_storage_backup_cmd: ''
109109
openhpc_slurm_accounting_storage_backup_host: "{{ openhpc_slurm_accounting_storage_host }}"
110110
openhpc_slurm_accounting_storage_backup_become: true

tasks/runtime.yml

-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@
175175
when:
176176
- "_openhpc_slurmdbd_state.stdout == 'inactive'"
177177
- openhpc_enable.database | default(false)
178-
- openhpc_slurm_accounting_storage_service != ''
179178

180179
- name: Notify handler for slurmd restart
181180
debug:

tasks/upgrade.yml

+9-3
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,27 @@
4242
name: "{{ openhpc_slurm_accounting_storage_service }}"
4343
state: stopped
4444
register: _openhpc_slurmdb_state
45-
when: _openhpc_slurmdb_upgrade
45+
when:
46+
- _openhpc_slurmdb_upgrade
47+
- openhpc_slurm_accounting_storage_service != ''
4648

4749
- name: Backup Slurm database
4850
ansible.builtin.shell:
4951
cmd: "{{ openhpc_slurm_accounting_storage_backup_cmd }}"
5052
delegate_to: "{{ openhpc_slurm_accounting_storage_backup_host }}"
5153
become: "{{ openhpc_slurm_accounting_storage_backup_become }}"
5254
run_once: true
53-
when: _openhpc_slurmdb_upgrade
55+
when:
56+
- _openhpc_slurmdb_upgrade
57+
- openhpc_slurm_accounting_storage_backup_cmd != ''
5458

5559
- name: Ensure Slurm database service started
5660
ansible.builtin.systemd:
5761
name: "{{ openhpc_slurm_accounting_storage_service }}"
5862
state: started
59-
when: _openhpc_slurmdb_state.changed | default(false)
63+
when:
64+
- openhpc_slurm_accounting_storage_service != ''
65+
- _openhpc_slurmdb_state.changed | default(false)
6066

6167
- name: Run slurmdbd in foreground for upgrade
6268
ansible.builtin.expect:

0 commit comments

Comments
 (0)