Skip to content

Commit

Permalink
Add install_device option for flatcar install
Browse files Browse the repository at this point in the history
  • Loading branch information
Thor77 committed Jul 29, 2022
1 parent ad2d037 commit 3873641
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type hcloudConfig struct {
type flatcarConfig struct {
InstallScript string `toml:"install_script"`
InstallArgs string `toml:"install_args"`
InstallDevice string `toml:"install_device"`
Version string
ConfigTemplate string `toml:"config_template"`
TemplateStatic map[string]string `toml:"template_static"`
Expand Down
11 changes: 10 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,12 +381,21 @@ func main() {
log.Fatalf("error uploading ignition file: %v\n", err)
}

// build flatcar-install command
var installDeviceArg string
if cfg.Flatcar.InstallDevice == "" {
installDeviceArg = "-s"
} else {
installDeviceArg = fmt.Sprintf("-d %s", cfg.Flatcar.InstallDevice)
}
installCommand := fmt.Sprintf("%s -i %s -V %s %s %s", installScriptTarget, ignitionTarget, cfg.Flatcar.Version, installDeviceArg, cfg.Flatcar.InstallArgs)

// execute commands to finally install flatcar
commands := []string{
"apt update",
"apt install -y gawk",
fmt.Sprintf("chmod +x %s", installScriptTarget),
fmt.Sprintf("%s -s -i %s -V %s %s", installScriptTarget, ignitionTarget, cfg.Flatcar.Version, cfg.Flatcar.InstallArgs),
installCommand,
"shutdown -r now",
}
for _, command := range commands {
Expand Down

0 comments on commit 3873641

Please sign in to comment.