Skip to content

Instantly share code, notes, and snippets.

@lae
Created October 31, 2017 17:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lae/4aed652be3bbd4a69ccad07d3cadec07 to your computer and use it in GitHub Desktop.
Save lae/4aed652be3bbd4a69ccad07d3cadec07 to your computer and use it in GitHub Desktop.
discovery bootenv diff
--- discovery.yml 2017-10-31 10:26:55.019158268 -0700
+++ labs-discovery.yml 2017-10-31 10:26:42.012188661 -0700
@@ -1,6 +1,6 @@
---
-Name: "discovery"
-Description: "The boot environment to use to have unknown machines boot to default Stage/BootEnv"
+Name: "labs-discovery"
+Description: "The boot environment to use to have unknown machines boot to Sledgehammer"
OnlyUnknown: true
OS:
Name: "sledgehammer/f5ffd3ed10ba403ffff40c3621f1e31ada0c7e15"
@@ -9,21 +9,7 @@
Kernel: "vmlinuz0"
Initrds:
- "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.api={{.ApiURL}}
- --
- {{if .ParamExists "kernel-console"}}{{.Param "kernel-console"}}{{end}}
-OptionalParams:
- - "kernel-console"
+BootParams: "rootflags=loop root=live:/sledgehammer.iso rootfstype=auto ro liveimg rd_NO_LUKS rd_NO_MD rd_NO_DM provisioner.web={{.ProvisionerURL}} rs.api={{.ApiURL}} {{if .ParamExists \"kernel-console\"}}{{.Param \"kernel-console\"}}{{end}}"
Templates:
- Name: "pxelinux"
Path: "pxelinux.cfg/default"
@@ -78,6 +64,7 @@
host_re='rs\.uuid=([^ ]+)'
api_re='rs\.api=([^ ]+)'
hostname_re='option host-name "([^"]+)'
+ fixed_ip='fixed-address ([0-9a-f.:]+)'
uuid_re='^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$'
netname_re='"network":"([^ ]+)"'
@@ -92,6 +79,13 @@
else
HOSTNAME="$dhcp_hostname"
fi
+ else
+ dhcp_ip="$(dhcp_param "$fixed_ip")"
+ lookup_1=$(getent hosts $dhcp_ip | awk '{print $2}')
+ lookup_2=$(getent hosts $dhcp_ip | awk '{print $2}')
+ if [ ! -z $lookup_1 ] && [ $lookup_1 == $lookup_2 ]; then
+ HOSTNAME=$lookup_1
+ fi
fi
export RS_ENDPOINT="$(get_param "$api_re")"
if ! [[ -x /usr/bin/drpcli ]]; then
@@ -123,7 +117,8 @@
# Add the default noderoles we will need, and
# Let the annealer do its thing.
while ! json="$(drpcli machines create "{\"Name\": \"$HOSTNAME\",
- \"Address\": \"$IP\"}")"; do
+ \"Address\": \"$IP\",
+ \"BootEnv\": \"ce-sledgehammer\"}")"; do
echo "We could not create a node for ourself, trying again."
sleep 5
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment