diff --git a/lang/core/embedded/provisioner/files/kickstart.ks.tmpl b/lang/core/embedded/provisioner/files/kickstart.ks.tmpl index 4e8d541f..ce2191bb 100644 --- a/lang/core/embedded/provisioner/files/kickstart.ks.tmpl +++ b/lang/core/embedded/provisioner/files/kickstart.ks.tmpl @@ -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 diff --git a/lang/core/embedded/provisioner/main.mcl b/lang/core/embedded/provisioner/main.mcl index 3de3f765..70b1cf8b 100644 --- a/lang/core/embedded/provisioner/main.mcl +++ b/lang/core/embedded/provisioner/main.mcl @@ -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 diff --git a/lang/core/embedded/provisioner/provisioner.go b/lang/core/embedded/provisioner/provisioner.go index 8499d163..3e6d8501 100644 --- a/lang/core/embedded/provisioner/provisioner.go +++ b/lang/core/embedded/provisioner/provisioner.go @@ -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 { diff --git a/lang/core/embedded/provisioner/top.mcl b/lang/core/embedded/provisioner/top.mcl index 0ccca908..9a1b6f15 100644 --- a/lang/core/embedded/provisioner/top.mcl +++ b/lang/core/embedded/provisioner/top.mcl @@ -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