File tree Expand file tree Collapse file tree 11 files changed +78
-85
lines changed
testohpc-compute-0/etc/munge Expand file tree Collapse file tree 11 files changed +78
-85
lines changed Original file line number Diff line number Diff line change @@ -53,15 +53,17 @@ jobs:
53
53
- test4
54
54
- test5
55
55
- test6
56
- - test7
57
56
- test8
58
57
- test9
59
58
- test10
60
59
- test11
61
60
- test12
62
61
- test13
63
62
- test14
64
- exclude : []
63
+ exclude :
64
+ # mariadb package provides /usr/bin/mysql on RL8 which doesn't work with geerlingguy/mysql role
65
+ - scenario : test4
66
+ image : ' rockylinux:8.9'
65
67
66
68
steps :
67
69
- name : Check out the codebase.
Original file line number Diff line number Diff line change @@ -136,6 +136,14 @@ You will need to configure these variables if you have set `openhpc_enable.datab
136
136
137
137
` openhpc_slurmdbd_mysql_username ` : Username for authenticating with the database, defaults to ` slurm ` .
138
138
139
+ ## Facts
140
+
141
+ This role creates local facts from the live Slurm configuration, which can be
142
+ accessed (with facts gathering enabled) using ` ansible_local.slurm ` . As per the
143
+ ` scontrol show config ` man page, uppercase keys are derived parameters and keys
144
+ in mixed case are from from config files. Note the facts are only refreshed
145
+ when this role is run.
146
+
139
147
## Example Inventory
140
148
141
149
And an Ansible inventory as this:
Original file line number Diff line number Diff line change @@ -91,11 +91,46 @@ def dict2parameters(d):
91
91
parts = ['%s=%s' % (k , v ) for k , v in d .items ()]
92
92
return ' ' .join (parts )
93
93
94
+ def config2dict (lines ):
95
+ """ Convert a sequence of output lines from `scontrol show config` to a dict.
96
+
97
+ As per man page uppercase keys are derived parameters, mixed case are from
98
+ from config files.
99
+
100
+ The following case-insensitive conversions of values are carried out:
101
+ - '(null)' and 'n/a' are converted to None.
102
+ - yes and no are converted to True and False respectively
103
+
104
+ Except for these, values are always strings.
105
+ """
106
+ cfg = {}
107
+ for line in lines :
108
+ if '=' not in line : # ditch blank/info lines
109
+ continue
110
+ else :
111
+ parts = [x .strip () for x in line .split ('=' , maxsplit = 1 )] # maxplit handles '=' in values
112
+ if len (parts ) != 2 :
113
+ raise errors .AnsibleFilterError (f'line { line } cannot be split into key=value' )
114
+ k , v = parts
115
+ small_v = v .lower ()
116
+ if small_v == '(null)' :
117
+ v = None
118
+ elif small_v == 'n/a' :
119
+ v = None
120
+ elif small_v == 'no' :
121
+ v = False
122
+ elif small_v == 'yes' :
123
+ v = True
124
+ cfg [k ] = v
125
+ return cfg
126
+
127
+
94
128
class FilterModule (object ):
95
129
96
130
def filters (self ):
97
131
return {
98
132
'hostlist_expression' : hostlist_expression ,
99
133
'error' : error ,
100
134
'dict2parameters' : dict2parameters ,
135
+ 'config2dict' : config2dict ,
101
136
}
Original file line number Diff line number Diff line change 66
66
- openhpc_slurm_service_started | bool
67
67
- openhpc_enable.batch | default(false) | bool
68
68
# 2nd condition required as notification happens on controller, which isn't necessarily a compute note
69
+
70
+ - name : Reload facts
71
+ ansible.builtin.setup :
72
+ filter : ansible_local
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ test3 | 1 | Y | -
14
14
test4 | 1 | N | 2x compute node, accounting enabled
15
15
test5 | 1 | N | As for #1 but configless
16
16
test6 | 1 | N | 0x compute nodes, configless
17
- test7 | 1 | N | 1x compute node, no login node so specified munge key, configless (checks image build should work)
17
+ test7 | 1 | N | [ removed, image build should just run install.yml task, this is not expected to work]
18
18
test8 | 1 | N | 2x compute node, 2x login-only nodes, configless
19
19
test9 | 1 | N | As test8 but uses ` --limit=testohpc-control,testohpc-compute-0 ` and checks login nodes still end up in slurm.conf
20
20
test10 | 1 | N | As for #5 but then tries to add an additional node
Load Diff This file was deleted.
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ - name : Capture configuration from scontrol
2
+ # this includes any dynamically-generated config, not just what is set in
3
+ # slurm.conf
4
+ ansible.builtin.command : scontrol show config
5
+ changed_when : false
6
+ register : _scontrol_config
7
+
8
+ - name : Create facts directory
9
+ ansible.builtin.file :
10
+ path : /etc/ansible/facts.d/
11
+ state : directory
12
+ owner : root
13
+ group : root
14
+ mode : ugo=rwX
15
+
16
+ - name : Template slurm configuration facts
17
+ copy :
18
+ dest : /etc/ansible/facts.d/slurm.fact
19
+ content : " {{ _scontrol_config.stdout_lines | config2dict | to_nice_json }}"
20
+ owner : slurm
21
+ group : slurm
22
+ mode : ug=rw,o=r # any user can run scontrol show config anyway
23
+ register : _template_facts
24
+ notify : Reload facts
Original file line number Diff line number Diff line change 216
216
enabled : " {{ openhpc_slurm_service_enabled | bool }}"
217
217
state : " {{ 'started' if openhpc_slurm_service_started | bool else 'stopped' }}"
218
218
when : openhpc_enable.batch | default(false) | bool
219
+
220
+ - import_tasks : facts.yml
You can’t perform that action at this time.
0 commit comments