mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-11-30 18:58:02 +08:00
fix bugs, user ansibleHostGroup.Name split all and etcd and other;get configpath and hostspath from environment
This commit is contained in:
parent
32b7f10128
commit
eb2d2e6b46
@ -134,8 +134,16 @@ func (n *NodeService) writeHostsFile() error {
|
||||
if err != nil {
|
||||
return err.Err
|
||||
}
|
||||
// use default hosts file path and default install config file path
|
||||
erro := ansibleUtil.WriteHostsFile("/opt/rainbond/rainbond-ansible/inventory/hosts", "/opt/rainbond/rainbond-ansible/scripts/installer/global.sh", hosts)
|
||||
// use the value of environment if it is empty use default value
|
||||
hostsFilePath := os.Getenv("HOSTS_FILE_PATH")
|
||||
if hostsFilePath == "" {
|
||||
hostsFilePath = "/opt/rainbond/rainbond-ansible/inventory/hosts"
|
||||
}
|
||||
installConfPath := os.Getenv("INSTALL_CONF_PATH")
|
||||
if installConfPath == "" {
|
||||
installConfPath = "/opt/rainbond/rainbond-ansible/scripts/installer/global.sh"
|
||||
}
|
||||
erro := ansibleUtil.WriteHostsFile(hostsFilePath, installConfPath, hosts)
|
||||
if erro != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -37,13 +37,7 @@ type AnsibleHost struct {
|
||||
}
|
||||
|
||||
func (a *AnsibleHost) String() string {
|
||||
if a.Role.HasRule("all") {
|
||||
return fmt.Sprintf("%s ansible_host=%s ansible_port=%d ip=%s port=%d role=%s", a.HostID, a.AnsibleHostIP, a.AnsibleHostPort, a.AnsibleHostIP, a.AnsibleHostPort, a.Role)
|
||||
} else if a.Role.HasRule("etcd") {
|
||||
return fmt.Sprintf("%s ansible_host=%s NODE_NAME=etcd1", a.HostID, a.AnsibleHostIP)
|
||||
} else {
|
||||
return fmt.Sprintf("%s ansible_host=%s", a.HostID, a.AnsibleHostIP)
|
||||
}
|
||||
return fmt.Sprintf("%s ansible_host=%s ansible_port=%d ip=%s port=%d role=%s", a.HostID, a.AnsibleHostIP, a.AnsibleHostPort, a.AnsibleHostIP, a.AnsibleHostPort, a.Role)
|
||||
}
|
||||
|
||||
type HostsList []*AnsibleHost
|
||||
@ -82,6 +76,8 @@ func (a *AnsibleHostGroup) String() string {
|
||||
for i := range a.HostList {
|
||||
if a.Name == "all" {
|
||||
rebuffer.WriteString(a.HostList[i].String() + "\n")
|
||||
} else if a.Name == "etcd" {
|
||||
rebuffer.WriteString(a.HostList[i].HostID + " NODE_NAME=etcd1" + "\n")
|
||||
} else {
|
||||
rebuffer.WriteString(a.HostList[i].HostID + "\n")
|
||||
}
|
||||
@ -108,6 +104,7 @@ func GetAnsibleHostConfig(name string) *AnsibleHostConfig {
|
||||
"new-gateway": &AnsibleHostGroup{Name: "new-gateway"},
|
||||
"compute": &AnsibleHostGroup{Name: "compute"},
|
||||
"new-compute": &AnsibleHostGroup{Name: "new-compute"},
|
||||
"etcd": &AnsibleHostGroup{Name: "etcd"},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user