Skip to content

Commit 604ae24

Browse files
Merge pull request openshift#7649 from honza/terraform-poc
METAL-871: Remove terraform-provider-ironic
2 parents 8885e01 + 5b77a4f commit 604ae24

File tree

3,994 files changed

+179
-1248843
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,994 files changed

+179
-1248843
lines changed

data/data/baremetal/bootstrap/main.tf

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,6 @@ provider "libvirt" {
22
uri = var.libvirt_uri
33
}
44

5-
provider "ironic" {
6-
url = var.ironic_uri
7-
inspector = var.inspector_uri
8-
microversion = "1.56"
9-
timeout = 900
10-
auth_strategy = "http_basic"
11-
ironic_username = var.ironic_username
12-
ironic_password = var.ironic_password
13-
inspector_username = var.ironic_username
14-
inspector_password = var.ironic_password
15-
}
16-
175
resource "libvirt_pool" "bootstrap" {
186
name = "${var.cluster_id}-bootstrap"
197
type = "dir"

data/data/bootstrap/baremetal/files/etc/containers/systemd/image-customization.container

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,29 @@ After=network-online.target ironic-volume.service build-ironic-env.service extra
99
[Container]
1010
ContainerName=image-customization
1111
Image=$CUSTOMIZATION_IMAGE
12-
Exec=/image-customization-server --nmstate-dir=${NMSTATE_DIR} --images-publish-addr=http://0.0.0.0:8084
12+
Exec=/image-customization-controller --namespace=openshift-machine-api --images-publish-addr=http://0.0.0.0:8084 --metrics-addr=0.0.0.0:7373
1313
Network=host
1414
PodmanArgs=--secret pull-secret,mode=400
15-
Volume=${NMSTATE_DIR}/:${NMSTATE_DIR}/:z,ro
1615
Volume=ironic.volume:/shared:z
1716
Volume=/etc/containers:/tmp/containers:z
17+
Volume=${AUTH_DIR}:/auth:z,ro
18+
Volume=/opt/openshift:/opt/openshift:z,ro
1819
Environment="DEPLOY_ISO=/shared/html/images/ironic-python-agent.iso"
1920
Environment="DEPLOY_INITRD=/shared/html/images/ironic-python-agent.initramfs"
2021
Environment="IRONIC_BASE_URL=${IRONIC_BASE_URL}"
22+
Environment="IRONIC_INSPECTOR_BASE_URL=${IRONIC_BASE_URL}"
2123
Environment="IRONIC_RAMDISK_SSH_KEY=${IRONIC_RAMDISK_SSH_KEY}"
2224
Environment="IRONIC_AGENT_IMAGE=${IRONIC_AGENT_IMAGE}"
2325
Environment="IP_OPTIONS=${EXTERNAL_IP_OPTIONS}"
2426
Environment="REGISTRIES_CONF_PATH=/tmp/containers/registries.conf"
27+
Environment="KUBECONFIG=/opt/openshift/auth/kubeconfig-loopback"
2528

2629
[Service]
2730
EnvironmentFile=/etc/ironic.env
28-
Environment="NMSTATE_DIR=/tmp/nmstate"
31+
Restart=always
2932
ExecStartPre=/usr/local/bin/setup-image-data.sh
3033
TimeoutStartSec=600
3134
ExecStopPost=podman secret rm pull-secret
32-
ExecStopPost=-rm -rf ${NMSTATE_DIR}
33-
Restart=on-abnormal
3435

3536
[Install]
3637
WantedBy=multi-user.target

data/data/bootstrap/baremetal/files/etc/containers/systemd/ironic.container.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Environment="IRONIC_HTPASSWD=${IRONIC_HTPASSWD}"
2525
Environment="INSPECTOR_HTPASSWD=${IRONIC_HTPASSWD}"
2626
Environment="IRONIC_KERNEL_PARAMS=${IRONIC_KERNEL_PARAMS}"
2727
Environment="HTTP_PORT=${HTTP_PORT}"
28+
Environment="OS_DEFAULT__FORCE_RAW_IMAGES=False"
2829

2930
[Service]
3031
EnvironmentFile=/etc/ironic.env
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
[Unit]
2+
Description=Metal3 deployment service
3+
BindsTo=ironic-volume.service
4+
Requires=build-metal3-env.service wait-iptables-init.service image-customization.service build-ironic-env.service
5+
Wants=network-online.target ironic-httpd.service ironic-ramdisk-logs.service
6+
After=network-online.target ironic-volume.service build-ironic-env.service image-customization.service build-metal3-env.service
7+
8+
[Container]
9+
ContainerName=baremetal-operator
10+
Image=$METAL3_BAREMETAL_OPERATOR_IMAGE
11+
Exec=/baremetal-operator -build-preprov-image
12+
Network=host
13+
Volume=${AUTH_DIR}:/auth:z,ro
14+
Volume=/opt/openshift:/opt/openshift:z,ro
15+
Environment="XDG_RUNTIME_DIR=/run/user/${UID}"
16+
Environment="KUBECONFIG=/opt/openshift/auth/kubeconfig-loopback"
17+
Environment="DEPLOY_KERNEL_URL=file:///shared/html/images/ironic-python-agent.kernel"
18+
Environment="IRONIC_HTPASSWD=${IRONIC_HTPASSWD}"
19+
Environment="INSPECTOR_HTPASSWD=${IRONIC_HTPASSWD}"
20+
Environment="IRONIC_KERNEL_PARAMS=${IRONIC_KERNEL_PARAMS}"
21+
Environment="HTTP_PORT=${HTTP_PORT}"
22+
Environment="IRONIC_ENDPOINT=${IRONIC_ENDPOINT}"
23+
Environment="IRONIC_EXTERNAL_URL_V6=${IRONIC_EXTERNAL_URL_V6}"
24+
25+
[Service]
26+
EnvironmentFile=/etc/metal3.env
27+
Restart=always
28+
RestartSec=10
29+
30+
[Install]
31+
WantedBy=multi-user.target
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
AUTH_DIR=/opt/metal3/auth
2+
IRONIC_ENDPOINT="http://{{.PlatformData.BareMetal.IronicUsername}}:{{.PlatformData.BareMetal.IronicPassword}}@localhost:6385/v1"
3+
IRONIC_EXTERNAL_URL_V6="{{.PlatformData.BareMetal.ExternalURLv6}}"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env sh
2+
3+
set -euo pipefail
4+
5+
# shellcheck disable=SC1091
6+
. /usr/local/bin/release-image.sh
7+
8+
export KUBECONFIG=/opt/openshift/auth/kubeconfig-loopback
9+
10+
build_metal3_env() {
11+
printf 'METAL3_BAREMETAL_OPERATOR_IMAGE="%s"\n' "$(image_for baremetal-operator)"
12+
}
13+
14+
build_metal3_env | tee -a /etc/metal3.env

data/data/bootstrap/baremetal/files/usr/local/bin/master-bmh-update.sh

Lines changed: 13 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,57 +2,32 @@
22

33
set -euo pipefail
44

5-
# shellcheck disable=SC1091
6-
. /usr/local/bin/release-image.sh
7-
85
export KUBECONFIG=/opt/openshift/auth/kubeconfig-loopback
96

107
# Wait till the baremetalhosts are populated
118
until oc get baremetalhosts -n openshift-machine-api; do
12-
echo Waiting for BareMetalHosts to appear...
9+
echo Waiting for BareMetalHosts CRD to appear...
1310
sleep 20
1411
done
1512

16-
AUTH_DIR=/opt/metal3/auth
17-
set +x
18-
ironic_url="$(printf 'http://%s:%s@localhost:6385/v1' "$(cat "${AUTH_DIR}/ironic/username")" "$(cat "${AUTH_DIR}/ironic/password")")"
19-
inspector_url="$(printf 'http://%s:%s@localhost:5050/v1' "$(cat "${AUTH_DIR}/ironic-inspector/username")" "$(cat "${AUTH_DIR}/ironic-inspector/password")")"
20-
21-
# Wait for a master to appear.
22-
while [ "$(curl -s "${ironic_url}/nodes" | jq '.nodes[] | .uuid' | wc -l)" -lt 1 ]; do
23-
echo waiting for a master node to show up
13+
while [ "$(oc get bmh -n openshift-machine-api -o name | wc -l)" -lt 1 ]; do
14+
echo "Waiting for bmh"
2415
sleep 20
2516
done
2617

27-
# Wait for the nodes to become active after introspection.
28-
# Probably don't need this but I want to be 100% sure.
29-
while curl -s "${ironic_url}/nodes" | jq '.nodes[] | .provision_state' | grep -v active; do
30-
echo Waiting for nodes to become active
18+
while [ "$(oc get bmh -n openshift-machine-api -l installer.openshift.io/role=master -o json | jq '.items[].status.provisioning.state' | grep -v provisioned -c)" -gt 0 ]; do
19+
echo "Waiting for masters to become provisioned"
20+
oc get bmh -A
3121
sleep 20
3222
done
3323

34-
echo Nodes are all active
35-
36-
BAREMETAL_OPERATOR_IMAGE=$(image_for baremetal-operator)
37-
38-
for node in $(curl -s "${ironic_url}/nodes" | jq -r '.nodes[] | .uuid'); do
39-
name=$(curl -H "X-OpenStack-Ironic-API-Version: 1.9" -s "${ironic_url}/nodes/${node}" | jq -r .name)
40-
echo "Host $name, UUID: $node"
41-
# And use the baremetal operator tool to load the introspection data into
42-
# the BareMetalHost CRs as annotations, which BMO then picks up.
43-
HARDWARE_DETAILS=$(podman run --quiet --net=host \
44-
--rm \
45-
--entrypoint /get-hardware-details \
46-
"${BAREMETAL_OPERATOR_IMAGE}" \
47-
"${inspector_url}" "$node" | jq '{hardware: .}')
48-
49-
oc annotate --overwrite -n openshift-machine-api baremetalhosts "$name" 'baremetalhost.metal3.io/status'="$HARDWARE_DETAILS" 'baremetalhost.metal3.io/paused-'
50-
done
51-
52-
# This delay is needed to ensure that Terraform sees that the hosts are
53-
# deployed before we stop ironic. Terraform is polling every 10s.
54-
sleep 30
5524
# Shut down ironic containers so that the API VIP can fail over to the control
5625
# plane.
5726
echo "Stopping provisioning services..."
58-
systemctl stop ironic.service
27+
systemctl --no-block stop ironic.service
28+
while systemctl is-active metal3-baremetal-operator.service; do
29+
sleep 10
30+
done
31+
32+
echo "Unpause all baremetal hosts"
33+
oc annotate --overwrite -n openshift-machine-api baremetalhosts --all "baremetalhost.metal3.io/paused-"

data/data/bootstrap/baremetal/files/usr/local/bin/setup-image-data.sh.template

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,5 @@ set -euo pipefail
44

55
export KUBECONFIG=/opt/openshift/auth/kubeconfig-loopback
66

7-
mkdir -p "${NMSTATE_DIR}"
8-
9-
get_nmstate() {
10-
local host="$1"
11-
until oc get -n openshift-machine-api baremetalhost "${host}" >/dev/null; do
12-
echo "Waiting for Host ${host} to appear..." >&2
13-
sleep 10
14-
done
15-
16-
local secret_name
17-
secret_name="$(oc get -n openshift-machine-api baremetalhost "${host}" -o jsonpath="{.spec.preprovisioningNetworkDataName}")"
18-
if [ -n "${secret_name}" ]; then
19-
until oc get -n openshift-machine-api secret "${secret_name}" >/dev/null; do
20-
echo "Waiting for Secret ${secret_name} to appear..." >&2
21-
sleep 10
22-
done
23-
oc get -n openshift-machine-api secret "${secret_name}" -o jsonpath="{.data.nmstate}" | base64 -d >"${NMSTATE_DIR}/${host}.yaml"
24-
else
25-
touch "${NMSTATE_DIR}/${host}.yaml"
26-
fi
27-
}
28-
29-
{{range .PlatformData.BareMetal.Hosts}}
30-
get_nmstate "{{.Name}}"
31-
{{end}}
32-
337
# Create a podman secret for the image-customization-server
348
base64 -w 0 /root/.docker/config.json | podman secret create pull-secret -

data/data/bootstrap/baremetal/systemd/units/build-ironic-env.service.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ After=network-online.target crio.service release-image.service
88
EnvironmentFile=/etc/ironic-network.env
99
Environment="PROVISIONING_MAC={{.PlatformData.BareMetal.ProvisioningInterfaceMAC}}"
1010
Environment="PROVISIONING_NETWORK_TYPE={{.PlatformData.BareMetal.ProvisioningNetwork}}"
11-
Environment="IRONIC_IP={{.PlatformData.BareMetal.APIVIP}}"
11+
Environment="IRONIC_IP={{index .PlatformData.BareMetal.APIVIPs 0}}"
1212
Environment="IRONIC_USERNAME={{.PlatformData.BareMetal.IronicUsername}}"
1313
ExecStart=/usr/local/bin/build-ironic-env.sh
1414
Type=oneshot
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[Unit]
2+
Description=Build Metal3 environment
3+
Requires=release-image.service
4+
Wants=network-online.target crio.service
5+
After=network-online.target crio.service release-image.service
6+
7+
[Service]
8+
ExecStart=/usr/local/bin/build-metal3-env.sh
9+
Type=oneshot
10+
RemainAfterExit=true
11+
12+
[Install]
13+
WantedBy=multi-user.target

0 commit comments

Comments
 (0)