lang: core: embedded: provisioner: Handoff a hostname

This makes it easier to run config tools if the hostname is already set.
This commit is contained in:
James Shubin
2025-01-17 19:48:23 -05:00
parent a60148f370
commit 4a578ca40c
4 changed files with 11 additions and 1 deletions

View File

@@ -65,7 +65,7 @@ sshkey --username {{ $user }} "{{ $pubkey }}"
# --activate
# any matching devices beyond the first will also be activated
#
network --bootproto=dhcp --device=link --activate
network --bootproto=dhcp --device=link --activate{{ if .hostname }} --hostname={{ .hostname }}{{ end }}
firewall --enabled --service=mdns

View File

@@ -559,6 +559,7 @@ class base:host($name, $config) {
$handoff_type = $config->handoff || ""
$handoff_code = $config->handoff_code || ""
panic($handoff_code != "" and not strings.has_prefix($handoff_code, "/"))
$handoff_hostname = $config->handoff_hostname || ""
# This is a giant driver://user:password@host:port/whatever URL...
$bmc_uri = $config->bmc_uri || ""
@@ -799,6 +800,7 @@ class base:host($name, $config) {
# "/usr/bin/wget 'http://${router_ip}:${http_port_str}/fedora/${repouid}/updates.repo' -O /etc/yum.repos.d/updates.repo",
# "/usr/bin/dnf --enablerepo=fedora,updates install --assumeyes ${handoff_packages_string}",
#],
hostname => $handoff_hostname,
post => [
$handoff_binary, # copy over the binary
$handoff_cpcode, # copy over a bundle of code

View File

@@ -171,6 +171,10 @@ type localArgs struct {
// static code deploy bolus. This is useful for isolated, one-time runs.
HandoffCode string `arg:"--handoff-code" help:"code dir to handoff to host" func:"cli_handoff_code"` // eg: /etc/mgmt/
// HandoffHostname specifies that we want to handoff a hostname to set
// on this machine. This is useful to make initial code handoff easier.
HandoffHostname string `arg:"--handoff-hostname" help:"hostname to handoff to host" func:"cli_handoff_hostname"` // eg: server1
// BmcURI specifies the BMC connect string we want to use for this host.
// This is a giant driver://user:password@host:port/whatever URL...
BmcURI string `arg:"--bmc-uri" help:"bmc connect string to use for this host" func:"cli_bmc_uri"`
@@ -423,6 +427,9 @@ func (obj *provisioner) Customize(a interface{}) (*cli.RunArgs, error) {
obj.init.Logf("handoff: %s", obj.localArgs.HandoffCode)
}
if h := obj.localArgs.HandoffHostname; h != "" {
obj.init.Logf("handoff hostname: %s", h)
}
// Do this last to let others fail early b/c this has user interaction.
if obj.localArgs.Password == nil {

View File

@@ -79,6 +79,7 @@ include base.host("host0", struct{ # TODO: do we need a usable name anywhere?
handoff => $handoff, # alternatively some code word or querystring
#handoff_code => "/etc/mgmt/", # one way to do it
handoff_code => provisioner.cli_handoff_code(),
handoff_hostname => provisioner.cli_handoff_hostname(),
bmc_uri => provisioner.cli_bmc_uri(),
}) as host0