engine: resources: Add a virt builder password selector

This is very helpful for debugging, particularly with broken Debian
installs.
This commit is contained in:
James Shubin
2025-01-30 22:56:24 -05:00
parent 3c61d088ab
commit 5044ef4e8a

View File

@@ -136,6 +136,10 @@ type VirtBuilderRes struct {
// If one is not present, then nothing is done. This defaults to true. // If one is not present, then nothing is done. This defaults to true.
RootSSHInject bool `lang:"root_ssh_inject" yaml:"root_ssh_inject"` RootSSHInject bool `lang:"root_ssh_inject" yaml:"root_ssh_inject"`
// RootPasswordSelector is a string in the virt-builder format. See the
// manual page "USERS AND PASSWORDS" section for more information.
RootPasswordSelector string `lang:"root_password_selector" yaml:"root_password_selector"`
// Bootstrap can be set to false to disable any automatic bootstrapping // Bootstrap can be set to false to disable any automatic bootstrapping
// of running the mgmt binary on first boot. If this is set, we will // of running the mgmt binary on first boot. If this is set, we will
// attempt to copy the mgmt binary in, and then run it. This also adds // attempt to copy the mgmt binary in, and then run it. This also adds
@@ -253,6 +257,7 @@ func (obj *VirtBuilderRes) Default() engine.Res {
Update: true, Update: true,
SelinuxRelabel: true, SelinuxRelabel: true,
RootSSHInject: true, RootSSHInject: true,
RootPasswordSelector: "disabled",
Bootstrap: true, Bootstrap: true,
LogOutput: true, LogOutput: true,
Tweaks: true, Tweaks: true,
@@ -481,8 +486,10 @@ func (obj *VirtBuilderRes) CheckApply(ctx context.Context, apply bool) (bool, er
} }
// TODO: consider changing this behaviour to get password from send/recv // TODO: consider changing this behaviour to get password from send/recv
passwordArgs := []string{"--root-password", "disabled"} if obj.RootPasswordSelector != "" {
passwordArgs := []string{"--root-password", obj.RootPasswordSelector}
cmdArgs = append(cmdArgs, passwordArgs...) cmdArgs = append(cmdArgs, passwordArgs...)
}
if obj.Bootstrap { if obj.Bootstrap {
p, err := obj.getBinaryPath() p, err := obj.getBinaryPath()
@@ -630,6 +637,9 @@ func (obj *VirtBuilderRes) Cmp(r engine.Res) error {
if obj.RootSSHInject != res.RootSSHInject { if obj.RootSSHInject != res.RootSSHInject {
return fmt.Errorf("the RootSSHInject value differs") return fmt.Errorf("the RootSSHInject value differs")
} }
if obj.RootPasswordSelector != res.RootPasswordSelector {
return fmt.Errorf("the RootPasswordSelector value differs")
}
if obj.Bootstrap != res.Bootstrap { if obj.Bootstrap != res.Bootstrap {
return fmt.Errorf("the Bootstrap value differs") return fmt.Errorf("the Bootstrap value differs")
} }