1
0
mirror of https://github.com/rancher/os.git synced 2025-09-24 20:09:21 +00:00

Include Harvester changes

This commit is contained in:
Darren Shepherd
2021-10-02 22:27:31 -07:00
parent 3040e886dc
commit 5e4cfa19ab
15 changed files with 169 additions and 108 deletions

View File

@@ -10,7 +10,7 @@ import (
)
func Ask(cfg *config.Config) error {
if cfg.Elemental.Install.Silent {
if cfg.Rancher.Install.Silent {
return nil
}
@@ -22,7 +22,7 @@ func Ask(cfg *config.Config) error {
return err
}
if cfg.Elemental.Install.ConfigURL == "" {
if cfg.Rancher.Install.ConfigURL == "" {
if err := AskGithub(cfg); err != nil {
return err
}
@@ -40,7 +40,7 @@ func Ask(cfg *config.Config) error {
}
func AskInstallDevice(cfg *config.Config) error {
if cfg.Elemental.Install.Device != "" {
if cfg.Rancher.Install.Device != "" {
return nil
}
@@ -54,7 +54,7 @@ func AskInstallDevice(cfg *config.Config) error {
return err
}
cfg.Elemental.Install.Device = "/dev/" + fields[i]
cfg.Rancher.Install.Device = "/dev/" + fields[i]
return nil
}
@@ -64,7 +64,7 @@ func AskToken(cfg *config.Config, server bool) error {
err error
)
if cfg.Elemental.Install.Token != "" {
if cfg.Rancher.Install.Token != "" {
return nil
}
@@ -77,7 +77,7 @@ func AskToken(cfg *config.Config, server bool) error {
} else {
token, err = questions.Prompt(msg+": ", "")
}
cfg.Elemental.Install.Token = token
cfg.Rancher.Install.Token = token
return err
}
@@ -93,7 +93,7 @@ func isServer(cfg *config.Config) (bool, error) {
}
func AskServerAgent(cfg *config.Config) error {
if cfg.Elemental.Install.ServerURL != "" {
if cfg.Rancher.Install.ServerURL != "" {
return nil
}
@@ -110,13 +110,13 @@ func AskServerAgent(cfg *config.Config) error {
if err != nil {
return err
}
cfg.Elemental.Install.ServerURL = url
cfg.Rancher.Install.ServerURL = url
return AskToken(cfg, false)
}
func AskPassword(cfg *config.Config) error {
if cfg.Elemental.Install.Silent || cfg.Elemental.Install.Password != "" {
if cfg.Rancher.Install.Silent || cfg.Rancher.Install.Password != "" {
return nil
}
@@ -140,12 +140,12 @@ func AskPassword(cfg *config.Config) error {
}
}
cfg.Elemental.Install.Password = pass
cfg.Rancher.Install.Password = pass
return nil
}
func AskGithub(cfg *config.Config) error {
if len(cfg.SSHAuthorizedKeys) > 0 || cfg.Elemental.Install.Password != "" {
if len(cfg.SSHAuthorizedKeys) > 0 || cfg.Rancher.Install.Password != "" {
return nil
}
@@ -167,11 +167,11 @@ func AskGithub(cfg *config.Config) error {
}
func AskConfigURL(cfg *config.Config) error {
if cfg.Elemental.Install.ConfigURL != "" {
if cfg.Rancher.Install.ConfigURL != "" {
return nil
}
ok, err := questions.PromptBool("Configure system using an Elemental config file?", false)
ok, err := questions.PromptBool("Configure system using an cloud-config file?", false)
if err != nil {
return err
}
@@ -180,11 +180,11 @@ func AskConfigURL(cfg *config.Config) error {
return nil
}
str, err := questions.Prompt("Elemental config file location (file path or http URL): ", "")
str, err := questions.Prompt("cloud-config file location (file path or http URL): ", "")
if err != nil {
return err
}
cfg.Elemental.Install.ConfigURL = str
cfg.Rancher.Install.ConfigURL = str
return nil
}

View File

@@ -16,10 +16,10 @@ func Run(automatic bool) error {
return err
}
if automatic && !cfg.Elemental.Install.Automatic {
if automatic && !cfg.Rancher.Install.Automatic {
return nil
} else if automatic {
cfg.Elemental.Install.Silent = true
cfg.Rancher.Install.Silent = true
}
err = Ask(&cfg)
@@ -27,7 +27,7 @@ func Run(automatic bool) error {
return err
}
tempFile, err := ioutil.TempFile("", "elemental-install")
tempFile, err := ioutil.TempFile("", "ros-install")
if err != nil {
return err
}
@@ -44,7 +44,7 @@ func runInstall(cfg config.Config, output string) error {
return err
}
if !cfg.Elemental.Install.Silent {
if !cfg.Rancher.Install.Silent {
val, err := questions.PromptBool("\nConfiguration\n"+"-------------\n\n"+
string(installBytes)+
"\nYour disk will be formatted and installed with the above configuration.\nContinue?", false)
@@ -53,30 +53,30 @@ func runInstall(cfg config.Config, output string) error {
}
}
if cfg.Elemental.Install.ConfigURL == "" {
if cfg.Rancher.Install.ConfigURL == "" {
yip := config.YipConfig{
Rancherd: config.Rancherd{
Server: cfg.Elemental.Install.ServerURL,
Token: cfg.Elemental.Install.Token,
Server: cfg.Rancher.Install.ServerURL,
Token: cfg.Rancher.Install.Token,
},
}
if cfg.Elemental.Install.ServerURL == "" {
if cfg.Rancher.Install.ServerURL == "" {
yip.Rancherd.Role = "cluster-init"
} else {
yip.Rancherd.Role = "agent"
}
if cfg.Elemental.Install.Password != "" || len(cfg.SSHAuthorizedKeys) > 0 {
if cfg.Rancher.Install.Password != "" || len(cfg.SSHAuthorizedKeys) > 0 {
yip.Stages = map[string][]config.Stage{
"initramfs": {{
"network": {{
Users: map[string]config.User{
"root": {
Name: "root",
PasswordHash: cfg.Elemental.Install.Password,
PasswordHash: cfg.Rancher.Install.Password,
SSHAuthorizedKeys: cfg.SSHAuthorizedKeys,
},
}},
}}
cfg.Elemental.Install.Password = ""
cfg.Rancher.Install.Password = ""
}
data, err := yaml.Marshal(yip)
@@ -87,7 +87,7 @@ func runInstall(cfg config.Config, output string) error {
if err := ioutil.WriteFile(output+".yip", data, 0600); err != nil {
return err
}
cfg.Elemental.Install.ConfigURL = output + ".yip"
cfg.Rancher.Install.ConfigURL = output + ".yip"
}
ev, err := config.ToEnv(cfg)