This repository has been archived by the owner on Sep 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
/
sledgehammer.yml
415 lines (394 loc) · 15.4 KB
/
sledgehammer.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
---
# Sledgehammer (the per machine bootenv)
# This bootenv requires the start-up.sh file to be rendered by the discovery bootenv.
# These two bootenvs are linked and should be used as a pair.
Name: "sledgehammer"
Description: "Ram-Only image loaded with tools to allow for discovery and maintenance"
Documentation: |
The Sledgehammer BootEnv is used in conjunction with Discovery to boot a
machine in to an in-memory (RAM only) operating system. The Machine will
be enrolled in the DRP Endpoint via Sledgehammer.
Many maintenance and hardware related workflows require to be run from the
Sledgehammer BootEnv.
Meta:
type: "sledgehammer"
feature-flags: "change-stage-v2"
icon: "microchip"
color: "green"
title: "Digital Rebar Community Content"
Loaders:
amd64-uefi: baad16af1d185f87450b01cce24cf2c15be40b64/shimx64.efi
OS:
Family: "redhat"
Name: "sledgehammer"
SupportedArchitectures:
amd64:
IsoFile: "sledgehammer-baad16af1d185f87450b01cce24cf2c15be40b64.amd64.tar"
IsoUrl: "http://rackn-sledgehammer.s3-website-us-west-2.amazonaws.com/sledgehammer/baad16af1d185f87450b01cce24cf2c15be40b64/sledgehammer-baad16af1d185f87450b01cce24cf2c15be40b64.amd64.tar"
Kernel: "baad16af1d185f87450b01cce24cf2c15be40b64/vmlinuz0"
Initrds:
- "baad16af1d185f87450b01cce24cf2c15be40b64/stage1.img"
BootParams: >-
rootflags=loop
root=live:/sledgehammer.iso
rootfstype=auto
ro
liveimg
rd_NO_LUKS
rd_NO_MD
rd_NO_DM
provisioner.web={{.ProvisionerURL}}
rs.uuid={{.Machine.UUID}}
{{ if .ParamExists "network-data" }}
{{ $nd := .ComposeParam "network-data" }}
{{ if hasKey $nd "prov" }}
{{ $prov := get $nd "prov" }}
{{ if and (hasKey $prov "address") (hasKey $prov "netmask") }}
provisioner.ip={{ get $prov "address" }}/{{ .NetmaskToCIDR (get $prov "netmask") }}
{{ end }}
{{ if hasKey $prov "gateway" }}
provisioner.gw={{ get $prov "gateway" }}
{{ end }}
{{ if hasKey $prov "interface" }}
provisioner.interface={{ get $prov "interface" }}
{{ end }}
{{ if hasKey $prov "vlan" }}
provisioner.vlan={{ get $prov "vlan" }}
{{ end }}
{{ if hasKey $prov "mtu" }}
provisioner.mtu={{ get $prov "mtu" }}
{{ end }}
{{ end }}
{{ end }}
{{ if .ParamExists "dns-servers" }}
provisioner.dns={{ first (.Param "dns-servers") }}
{{ end }}
{{.Param "kernel-options"}}
--
{{.Param "kernel-console"}}
arm64:
Loader: "grubarm64.efi"
IsoFile: "sledgehammer-9b5276ac5826520829aa73c149fe672fe2363656.arm64.tar"
IsoUrl: "https://s3.us-east-2.amazonaws.com/vl-hammer/sledgehammer-9b5276ac5826520829aa73c149fe672fe2363656.arm64.tar"
Kernel: "9b5276ac5826520829aa73c149fe672fe2363656/vmlinuz0"
Initrds:
- "9b5276ac5826520829aa73c149fe672fe2363656/stage1.img"
BootParams: >-
rootflags=loop
root=live:/sledgehammer.iso
rootfstype=auto
ro
liveimg
rd_NO_LUKS
rd_NO_MD
rd_NO_DM
provisioner.web={{.ProvisionerURL}}
rs.uuid={{.Machine.UUID}}
{{ if .ParamExists "network-data" }}
{{ $nd := .ComposeParam "network-data" }}
{{ if hasKey $nd "prov" }}
{{ $prov := get $nd "prov" }}
{{ if and (hasKey $prov "address") (hasKey $prov "netmask") }}
provisioner.ip={{ get $prov "address" }}/{{ .NetmaskToCIDR (get $prov "netmask") }}
{{ end }}
{{ if hasKey $prov "gateway" }}
provisioner.gw={{ get $prov "gateway" }}
{{ end }}
{{ if hasKey $prov "interface" }}
provisioner.interface={{ get $prov "interface" }}
{{ end }}
{{ if hasKey $prov "vlan" }}
provisioner.vlan={{ get $prov "vlan" }}
{{ end }}
{{ if hasKey $prov "mtu" }}
provisioner.mtu={{ get $prov "mtu" }}
{{ end }}
{{ end }}
{{ end }}
{{ if .ParamExists "dns-servers" }}
provisioner.dns={{ first (.Param "dns-servers") }}
{{ end }}
{{.Param "kernel-options"}}
--
{{.Param "kernel-console"}}
rpi4:
Loader: "grubarm64.efi"
IsoFile: "sledgehammer-d50c0910deee78591225ef5ede200021b7288b5b.rpi4.tar"
IsoUrl: "https://rackn-sledgehammer.s3-us-west-2.amazonaws.com/sledgehammer/d50c0910deee78591225ef5ede200021b7288b5b/sledgehammer-d50c0910deee78591225ef5ede200021b7288b5b.rpi4.tar"
Kernel: "rpi-5.4.35/kernel8.img"
Initrds:
- "rpi-5.4.35/stage1.img"
BootParams: >-
rootflags=loop
root=live:/sledgehammer.iso
rootfstype=auto
ro
liveimg
rd_NO_LUKS
rd_NO_MD
rd_NO_DM
provisioner.web={{.ProvisionerURL}}
rs.uuid={{.Machine.UUID}}
{{ if .ParamExists "network-data" }}
{{ $nd := .ComposeParam "network-data" }}
{{ if hasKey $nd "prov" }}
{{ $prov := get $nd "prov" }}
{{ if and (hasKey $prov "address") (hasKey $prov "netmask") }}
provisioner.ip={{ get $prov "address" }}/{{ .NetmaskToCIDR (get $prov "netmask") }}
{{ end }}
{{ if hasKey $prov "gateway" }}
provisioner.gw={{ get $prov "gateway" }}
{{ end }}
{{ if hasKey $prov "interface" }}
provisioner.interface={{ get $prov "interface" }}
{{ end }}
{{ if hasKey $prov "vlan" }}
provisioner.vlan={{ get $prov "vlan" }}
{{ end }}
{{ if hasKey $prov "mtu" }}
provisioner.mtu={{ get $prov "mtu" }}
{{ end }}
{{ end }}
{{ end }}
{{ if .ParamExists "dns-servers" }}
provisioner.dns={{ first (.Param "dns-servers") }}
{{ end }}
{{.Param "kernel-options"}}
--
{{.Param "kernel-console"}}
ppc64le:
Loader: "core.elf"
IsoFile: "sledgehammer-7d7c0bf77daa43785e2716ecb9177dfde8dcffbf.ppc64le.tar"
IsoUrl: "http://rackn-sledgehammer.s3-website-us-west-2.amazonaws.com/sledgehammer/7d7c0bf77daa43785e2716ecb9177dfde8dcffbf/sledgehammer-7d7c0bf77daa43785e2716ecb9177dfde8dcffbf.ppc64le.tar"
Kernel: "7d7c0bf77daa43785e2716ecb9177dfde8dcffbf/vmlinuz0"
Initrds:
- "7d7c0bf77daa43785e2716ecb9177dfde8dcffbf/stage1.img"
BootParams: >-
rootflags=loop
root=live:/sledgehammer.iso
rootfstype=auto
ro
liveimg
rd_NO_LUKS
rd_NO_MD
rd_NO_DM
provisioner.web={{.ProvisionerURL}}
rs.uuid={{.Machine.UUID}}
{{ if .ParamExists "network-data" }}
{{ $nd := .ComposeParam "network-data" }}
{{ if hasKey $nd "prov" }}
{{ $prov := get $nd "prov" }}
{{ if and (hasKey $prov "address") (hasKey $prov "netmask") }}
provisioner.ip={{ get $prov "address" }}/{{ .NetmaskToCIDR (get $prov "netmask") }}
{{ end }}
{{ if hasKey $prov "gateway" }}
provisioner.gw={{ get $prov "gateway" }}
{{ end }}
{{ if hasKey $prov "interface" }}
provisioner.interface={{ get $prov "interface" }}
{{ end }}
{{ if hasKey $prov "vlan" }}
provisioner.vlan={{ get $prov "vlan" }}
{{ end }}
{{ if hasKey $prov "mtu" }}
provisioner.mtu={{ get $prov "mtu" }}
{{ end }}
{{ end }}
{{ end }}
{{ if .ParamExists "dns-servers" }}
provisioner.dns={{ first (.Param "dns-servers") }}
{{ end }}
{{.Param "kernel-options"}}
--
{{.Param "kernel-console"}}
OptionalParams:
- "kernel-console"
- "kernel-options"
Templates:
- Name: start4.elf
Link: '{{.Env.PathForArch "tftp" "rpi-5.4.35/start4.elf" "rpi4"}}'
Path: '{{.Machine.MacAddr "rpi4"}}/start4.elf'
- Name: fixup4.dat
Link: '{{.Env.PathForArch "tftp" "rpi-5.4.35/fixup4.dat" "rpi4"}}'
Path: '{{.Machine.MacAddr "rpi4"}}/fixup4.dat'
- Name: bcm2711-rpi-4-b.dtb
Link: '{{.Env.PathForArch "tftp" "rpi-5.4.35/bcm2711-rpi-4-b.dtb" "rpi4"}}'
Path: '{{.Machine.MacAddr "rpi4"}}/bcm2711-rpi-4-b.dtb'
- Name: kernel8.img
Link: '{{.Env.PathForArch "tftp" "rpi-5.4.35/kernel8.img" "rpi4"}}'
Path: '{{.Machine.MacAddr "rpi4"}}/kernel8.img'
- Name: stage1.img
Link: '{{.Env.PathForArch "tftp" "rpi-5.4.35/stage1.img" "rpi4"}}'
Path: '{{.Machine.MacAddr "rpi4"}}/stage1.img'
- Name: root.squashfs
Link: '{{.Env.PathForArch "tftp" "rpi-5.4.35/root.squashfs" "rpi4"}}'
Path: '{{.Machine.MacAddr "rpi4"}}/root.squashfs'
- Name: "rpi-cmdline.txt"
Path: '{{.Machine.MacAddr "rpi4"}}/cmdline.txt'
Contents: |
snd_bcm2835.enable_hdmi=1 dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 fsck.repair=yes fsck.mode=auto elevator=deadline rootwait initrd=stage1.img rw cgroup_memory=1 cgroup_enable=memory BOOTIF=discovery provisioner.web={{.ProvisionerURL}} rs.uuid={{.Machine.UUID}}
- Name: rpi4b-config.txt
Path: '{{.Machine.MacAddr "rpi4"}}/config.txt'
Contents: |
# uncomment if you get no picture on HDMI for a default "safe" mode
hdmi_safe=1
# uncomment this if your display has a black border of unused pixels visible
# and your display can output without overscan
disable_overscan=1
# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16
# uncomment to force a console size. By default it will be display's size minus
# overscan.
#framebuffer_width=1280
#framebuffer_height=720
# uncomment if hdmi display is not detected and composite is being output
#hdmi_force_hotplug=1
# uncomment to force a specific HDMI mode (this will force VGA)
#hdmi_group=1
#hdmi_mode=1
# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
#hdmi_drive=2
# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
#config_hdmi_boost=4
# uncomment for composite PAL
#sdtv_mode=2
# Uncomment some or all of these to enable the optional hardware interfaces
#dtparam=i2c_arm=on
#dtparam=spi=on
#dtparam=i2s=on
# Uncomment this to enable infrared communication.
#dtoverlay=gpio-ir,gpio_pin=17
#dtoverlay=gpio-ir-tx,gpio_pin=18
# Enable audio (loads snd_bcm2835)
dtparam=audio=on
[pi4]
dtoverlay=vc4-fkms-v3d
max_framebuffers=2
arm_64bit=1
#device_tree_address=0x03000000
[all]
#dtoverlay=vc4-fkms-v3d
kernel kernel8.img
initramfs stage1.img
- Name: "kexec"
ID: "kexec.tmpl"
Path: "{{.Machine.Path}}/kexec"
- ID: "default-pxelinux.tmpl"
Name: "pxelinux"
Path: "pxelinux.cfg/{{.Machine.HexAddress}}"
- ID: "default-ipxe.tmpl"
Name: "ipxe"
Path: "{{.Machine.Address}}.ipxe"
- ID: "default-pxelinux.tmpl"
Name: "pxelinux-mac"
Path: 'pxelinux.cfg/{{.Machine.MacAddr "pxelinux"}}'
- ID: "default-ipxe.tmpl"
Name: "ipxe-mac"
Path: '{{.Machine.MacAddr "ipxe"}}.ipxe'
- ID: "default-grub.tmpl"
Name: "grub"
Path: "grub/{{.Machine.Address}}.cfg"
- ID: "default-grub.tmpl"
Name: "grub-mac"
Path: 'grub/{{.Machine.MacAddr "grub"}}.cfg'
- ID: "default-grub.tmpl"
Name: "grub-secure"
Path: "sledgehammer/baad16af1d185f87450b01cce24cf2c15be40b64/grub.cfg-{{.Machine.HexAddress}}"
- ID: "default-grub.tmpl"
Name: "grub-secure-mac"
Path: 'sledgehammer/baad16af1d185f87450b01cce24cf2c15be40b64/grub.cfg-{{.Machine.MacAddr "pxelinux"}}'
- ID: drp-agent-cfg.yaml.tmpl
Name: agent-cfg
Path: "{{.Machine.Path}}/agent-cfg.yml"
- Name: "control.sh"
Path: "{{.Machine.Path}}/control.sh"
Contents: |
#!/bin/bash
# Copyright 2017, RackN
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# We get the following variables from start-up.sh
# MAC BOOTDEV ADMIN_IP DOMAIN HOSTNAME HOSTNAME_MAC
shopt -s extglob
export PS4="${BASH_SOURCE}@${LINENO}(${FUNCNAME[0]}): "
cp /usr/share/zoneinfo/GMT /etc/localtime
# Set up for the agent
mkdir -p /var/lib/drp-agent/
curl -fgLko /var/lib/drp-agent/agent-cfg.yml "{{.ApiURL}}/{{.Machine.Path}}/agent-cfg.yml"
cat >/etc/sysconfig/drp-agent <<EOF
IP=$IP
EOF
drpcli agent install
# This will contain a token appropriate for the path being
# used below. Reset the token to the longer machine token.
export RS_TOKEN="{{.GenerateInfiniteToken}}"
drpcli machines set "$RS_UUID" param gohai-inventory to '{}' &>/dev/null
drpcli gohai | drpcli machines set "$RS_UUID" param gohai-inventory to - &>/dev/null
# If we do not have hardware addresses set on the machine, set them now.
get_macs() {
local maclist=""
local nic=""
for nic in /sys/class/net/*; do
[[ -f $nic/type && -f $nic/address && $(cat "$nic/type") == 1 ]] || continue
maclist="$maclist,\"$(cat "$nic/address")\""
done
printf '[%s]' "${maclist#,}"
}
mac_re='BOOTIF=([^ ]+)'
if [[ $(cat /proc/cmdline) =~ $mac_re ]]; then
drpcli machines set "$RS_UUID" param machine/PXE to true &>/dev/null
drpcli machines set "$RS_UUID" param last-boot-macaddr to "\"${BASH_REMATCH[1]}\"" &>/dev/null
mac="${BASH_REMATCH[1]}"
mac=${mac#01-}
mac=${mac//-/:}
mac=${mac,,}
bootif=""
cd /sys/class/net 2>&1 >/dev/null
for nic in *; do
[[ -f $nic/type && -f $nic/address && $(cat "$nic/type") == 1 ]] || continue
addr=$(cat "$nic/address")
if [[ "$addr" == "$mac" ]] ; then
bootif=${nic#/}
break
fi
done
cd - 2>&1 >/dev/null
if [[ "$bootif" != "" ]] ; then
drpcli machines set "$RS_UUID" param last-boot-interface to "$bootif" &>/dev/null
fi
else
drpcli machines set "$RS_UUID" param machine/PXE to false &>/dev/null
fi
json="$(drpcli machines show "$RS_UUID")"
# The machine does not have hardware addresses set, so set them
if [[ "$(jq '.HardwareAddrs | length' <<< "$json")" = 0 ]]; then
drpcli machines update "$RS_UUID" "{\"HardwareAddrs\": $(get_macs)}" &>/dev/null
fi
unset get_macs json
if [[ -d /sys/firmware/efi ]]; then
drpcli machines set "$RS_UUID" param detected-bios-mode to '"uefi"' &>/dev/null
else
drpcli machines set "$RS_UUID" param detected-bios-mode to '"legacy-bios"' &>/dev/null
fi
{{template "reset-workflow.tmpl" .}}
drpcli agent start
echo "Follow along with job logs using journalctl -u drp-agent"
# The last line in this script must always be exit 0!!
exit 0