Skip to content

Commit 09b0c88

Browse files
committed
PUC-314: adding clean step
1 parent 35de170 commit 09b0c88

File tree

1 file changed

+66
-20
lines changed

1 file changed

+66
-20
lines changed

workflows/argo-events/workflowtemplates/enroll-server.yaml

Lines changed: 66 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
---
22
apiVersion: argoproj.io/v1alpha1
33
metadata:
4-
name: enroll-server
4+
name: enroll-server-clean
55
annotations:
66
workflows.argoproj.io/title: Perform server discovery and update Nautobot and Ironic
77
workflows.argoproj.io/description: |
88
Defined in `workflows/argo-events/workflowtemplates/enroll-server.yaml`
99
kind: WorkflowTemplate
1010
spec:
1111
entrypoint: main
12+
serviceAccountName: workflow
1213
arguments:
1314
parameters:
1415
- name: ip_address
@@ -28,10 +29,16 @@ spec:
2829
arguments:
2930
parameters:
3031
- name: operation
31-
value: "manage"
32+
value: manage
3233
- name: device_id
3334
value: "{{steps.enroll-server.outputs.result}}"
3435
when: "{{steps.server-enroll-state.outputs.result}} == enroll"
36+
- - name: clean-server
37+
template: node-clean-cmd
38+
arguments:
39+
parameters:
40+
- name: device_id
41+
value: "{{steps.enroll-server.outputs.result}}"
3542
- - name: openstack-set-baremetal-node-raid-config
3643
template: openstack-set-baremetal-node-raid-config
3744
arguments:
@@ -49,7 +56,7 @@ spec:
4956
arguments:
5057
parameters:
5158
- name: operation
52-
value: "provide"
59+
value: provide
5360
- name: device_id
5461
value: "{{steps.enroll-server.outputs.result}}"
5562
when: "{{steps.server-manage-state.outputs.result}} == manageable"
@@ -75,18 +82,18 @@ spec:
7582
name: understack-flavors
7683
readOnly: true
7784
env:
78-
- name: WF_NS
79-
value: "{{workflow.namespace}}"
80-
- name: WF_NAME
81-
value: "{{workflow.name}}"
82-
- name: WF_UID
83-
value: "{{workflow.uid}}"
84-
- name: FLAVORS_DIR
85-
valueFrom:
86-
configMapKeyRef:
87-
name: understack-flavors
88-
key: FLAVORS_DIR
89-
optional: true
85+
- name: WF_NS
86+
value: "{{workflow.namespace}}"
87+
- name: WF_NAME
88+
value: "{{workflow.name}}"
89+
- name: WF_UID
90+
value: "{{workflow.uid}}"
91+
- name: FLAVORS_DIR
92+
valueFrom:
93+
configMapKeyRef:
94+
name: understack-flavors
95+
key: FLAVORS_DIR
96+
optional: true
9097
volumes:
9198
- name: bmc-master
9299
secret:
@@ -128,19 +135,49 @@ spec:
128135
- name: openstack-svc-acct
129136
secret:
130137
secretName: openstack-svc-acct
138+
- name: node-clean-cmd
139+
inputs:
140+
parameters:
141+
- name: device_id
142+
container:
143+
image: ghcr.io/rackerlabs/understack/openstack-client:2024.2-ubuntu_jammy
144+
command:
145+
- openstack
146+
args:
147+
- baremetal
148+
- node
149+
- clean
150+
- "{{inputs.parameters.device_id}}"
151+
- --clean-steps
152+
- '[{"interface":"bios","step":"apply_configuration","args":{"settings":[{"name":"HttpDev1EnDis","value":"Enabled"},{"name":"HttpDev1Interface","value":"NIC.Slot.1-1"},{"name":"HttpDev1TlsMode","value":"None"}]}}]'
153+
env:
154+
- name: OS_CLOUD
155+
value: understack
156+
volumeMounts:
157+
- mountPath: /etc/openstack
158+
name: openstack-svc-acct
159+
readOnly: true
160+
volumes:
161+
- name: openstack-svc-acct
162+
secret:
163+
secretName: openstack-svc-acct
131164
- name: openstack-set-baremetal-node-raid-config
132165
inputs:
133166
parameters:
134167
- name: device_id
135-
# https://rackerlabs.github.io/understack/user-guide/openstack-ironic/#setting-baremetal-node-flavor
136168
script:
137169
image: ghcr.io/rackerlabs/understack/openstack-client:2024.2-ubuntu_jammy
138-
command: [sh]
139-
source: |
170+
command:
171+
- sh
172+
source: >
140173
echo "setting RAID1 config for node: {{inputs.parameters.device_id}}"
174+
141175
# create the raid1-config.json file. I find this easier to read
176+
142177
# than passing a big json string on command line
178+
143179
cat <<'EOF' >> raid1-config.json
180+
144181
{ "logical_disks":
145182
[ { "controller": "RAID.SL.1-1",
146183
"is_root_volume": true,
@@ -153,9 +190,13 @@ spec:
153190
}
154191
]
155192
}
193+
156194
EOF
195+
157196
# create the initial clean steps which will create a raid config
197+
158198
cat <<'EOF' >> raid-clean-steps.json
199+
159200
[
160201
{
161202
"interface": "raid",
@@ -166,10 +207,15 @@ spec:
166207
"step": "create_configuration"
167208
}
168209
]
210+
169211
EOF
212+
170213
# apply the target raid config to the node
214+
171215
openstack baremetal node set {{inputs.parameters.device_id}} --target-raid-config raid1-config.json
216+
172217
# create the raid config
218+
173219
openstack baremetal node clean --wait 0 --clean-steps raid-clean-steps.json --disable-ramdisk {{inputs.parameters.device_id}}
174220
env:
175221
- name: OS_CLOUD
@@ -194,9 +240,9 @@ spec:
194240
- baremetal
195241
- node
196242
- show
197-
- "-f"
243+
- -f
198244
- value
199-
- "-c"
245+
- -c
200246
- provision_state
201247
- "{{inputs.parameters.device_id}}"
202248
env:

0 commit comments

Comments
 (0)