[ Agent ] [ App ] - offline installation chrony
This commit is contained in:
@@ -30,6 +30,9 @@ func (op *AgentOsOperator) Deploy(appFuncName string, funcArgs ...string) (bool,
|
|||||||
var result []string
|
var result []string
|
||||||
|
|
||||||
switch appFuncName {
|
switch appFuncName {
|
||||||
|
case "DEPLOY_CHRONY_SERVER":
|
||||||
|
resultOK, result = op.installChronyByDockerExec(funcArgs)
|
||||||
|
break
|
||||||
case "DEPLOY_RKE":
|
case "DEPLOY_RKE":
|
||||||
resultOK, result = op.deployRke(funcArgs)
|
resultOK, result = op.deployRke(funcArgs)
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -86,12 +86,6 @@ func (op *AgentOsOperator) Exec(baseFuncName string, funcArgs ...string) (bool,
|
|||||||
case "installHarbor":
|
case "installHarbor":
|
||||||
resultOk, errorLog = op.installHarborExec()
|
resultOk, errorLog = op.installHarborExec()
|
||||||
break
|
break
|
||||||
case "installChrony":
|
|
||||||
resultOk, errorLog = op.installChronyExec()
|
|
||||||
break
|
|
||||||
case "chronyToPublicNTP":
|
|
||||||
resultOk, errorLog = op.chronyToPublicNTPExec()
|
|
||||||
break
|
|
||||||
case "chronyToMaster":
|
case "chronyToMaster":
|
||||||
resultOk, errorLog = op.chronyToMasterExec(funcArgs)
|
resultOk, errorLog = op.chronyToMasterExec(funcArgs)
|
||||||
break
|
break
|
||||||
@@ -1752,10 +1746,6 @@ func (op *AgentOsOperator) installChronyExec() (bool, []string) {
|
|||||||
return false, resultLog
|
return false, resultLog
|
||||||
}
|
}
|
||||||
|
|
||||||
if !op.IsOsTypeUbuntu || !op.CanAccessInternet {
|
|
||||||
return op.installChronyByDockerExec()
|
|
||||||
}
|
|
||||||
|
|
||||||
// install chrony
|
// install chrony
|
||||||
resultOk, l := AllCommandExecutor(
|
resultOk, l := AllCommandExecutor(
|
||||||
append(
|
append(
|
||||||
@@ -1784,7 +1774,7 @@ func (op *AgentOsOperator) installChronyExec() (bool, []string) {
|
|||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (op *AgentOsOperator) installChronyByDockerExec() (bool, []string) {
|
func (op *AgentOsOperator) installChronyByDockerExec(funcArgs []string) (bool, []string) {
|
||||||
|
|
||||||
// check docker
|
// check docker
|
||||||
if !BasicCommandExistByPath("docker") {
|
if !BasicCommandExistByPath("docker") {
|
||||||
@@ -1816,29 +1806,29 @@ func (op *AgentOsOperator) installChronyByDockerExec() (bool, []string) {
|
|||||||
return false, append(resultLog, "[installChronyByDockerExec] - docker chrony run error !")
|
return false, append(resultLog, "[installChronyByDockerExec] - docker chrony run error !")
|
||||||
}
|
}
|
||||||
|
|
||||||
AllCommandExecutor([]string{
|
BasicPrettyPrint(AllCommandExecutor([]string{
|
||||||
"docker",
|
"docker",
|
||||||
"exec",
|
"exec",
|
||||||
"chrony",
|
"chrony",
|
||||||
"chronyc",
|
"chronyc",
|
||||||
"tracking",
|
"tracking",
|
||||||
})
|
}))
|
||||||
|
|
||||||
AllCommandExecutor([]string{
|
BasicPrettyPrint(AllCommandExecutor([]string{
|
||||||
"docker",
|
"docker",
|
||||||
"exec",
|
"exec",
|
||||||
"chrony",
|
"chrony",
|
||||||
"chronyc",
|
"chronyc",
|
||||||
"sources",
|
"sources",
|
||||||
})
|
}))
|
||||||
|
|
||||||
AllCommandExecutor([]string{
|
BasicPrettyPrint(AllCommandExecutor([]string{
|
||||||
"docker",
|
"docker",
|
||||||
"exec",
|
"exec",
|
||||||
"chrony",
|
"chrony",
|
||||||
"chronyc",
|
"chronyc",
|
||||||
"sourcestats",
|
"sourcestats",
|
||||||
})
|
}))
|
||||||
|
|
||||||
return true, []string{
|
return true, []string{
|
||||||
"[installChronyByDockerExec] - install success !",
|
"[installChronyByDockerExec] - install success !",
|
||||||
@@ -1891,6 +1881,44 @@ func (op *AgentOsOperator) chronyToMasterExec(args []string) (bool, []string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parseIP := net.ParseIP(args[0])
|
||||||
|
if parseIP == nil {
|
||||||
|
return false, []string{
|
||||||
|
"[chronyToMasterExec] - ip args error !",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// modify the systemd-timesync.service
|
||||||
|
ntpFile := "/etc/systemd/timesyncd.conf"
|
||||||
|
AllCommandExecutor([]string{
|
||||||
|
"sed",
|
||||||
|
"-i",
|
||||||
|
"s/#NTP=/NTP=" + args[0] + "/g",
|
||||||
|
ntpFile,
|
||||||
|
})
|
||||||
|
|
||||||
|
// todo restart
|
||||||
|
BasicPrettyPrint(AllCompleteExecutor([][]string{
|
||||||
|
{
|
||||||
|
"systemctl",
|
||||||
|
"restart",
|
||||||
|
"systemd-timesyncd.service",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sleep",
|
||||||
|
"2",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timedatectl",
|
||||||
|
"show-timesync",
|
||||||
|
"--all",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"timedatectl",
|
||||||
|
"status",
|
||||||
|
},
|
||||||
|
}))
|
||||||
|
|
||||||
return true, []string{
|
return true, []string{
|
||||||
"[chronyToMasterExec] - install success !",
|
"[chronyToMasterExec] - install success !",
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,11 @@ package io.wdd.func.auto.beans;
|
|||||||
*/
|
*/
|
||||||
public enum AppFunctionEnum {
|
public enum AppFunctionEnum {
|
||||||
|
|
||||||
|
DEPLOY_CHRONY_SERVER(
|
||||||
|
"DEPLOY_CHRONY_SERVER",
|
||||||
|
"使用docker部署chrony server"
|
||||||
|
),
|
||||||
|
|
||||||
|
|
||||||
DEPLOY_RKE(
|
DEPLOY_RKE(
|
||||||
"DEPLOY_RKE",
|
"DEPLOY_RKE",
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ public enum BaseFunctionEnum {
|
|||||||
"关闭防火墙"
|
"关闭防火墙"
|
||||||
),
|
),
|
||||||
|
|
||||||
|
|
||||||
DISABLE_SWAP(
|
DISABLE_SWAP(
|
||||||
"disableSwap",
|
"disableSwap",
|
||||||
"关闭虚拟内存"
|
"关闭虚拟内存"
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ public class AppFuncScheduler {
|
|||||||
);
|
);
|
||||||
|
|
||||||
List<AppFunctionEnum> appFunctionEnumList = List.of(
|
List<AppFunctionEnum> appFunctionEnumList = List.of(
|
||||||
|
AppFunctionEnum.DEPLOY_CHRONY_SERVER
|
||||||
// AppFunctionEnum.DEPLOY_RKE
|
// AppFunctionEnum.DEPLOY_RKE
|
||||||
// AppFunctionEnum.DEPLOY_TEST_NFS
|
// AppFunctionEnum.DEPLOY_TEST_NFS
|
||||||
// AppFunctionEnum.DEPLOY_K8S_NAMESPACE,
|
// AppFunctionEnum.DEPLOY_K8S_NAMESPACE,
|
||||||
@@ -109,7 +110,7 @@ public class AppFuncScheduler {
|
|||||||
// AppFunctionEnum.DEPLOY_INGRESS,
|
// AppFunctionEnum.DEPLOY_INGRESS,
|
||||||
// AppFunctionEnum.DEPLOY_FRONTEND
|
// AppFunctionEnum.DEPLOY_FRONTEND
|
||||||
// AppFunctionEnum.DEPLOY_BACKEND
|
// AppFunctionEnum.DEPLOY_BACKEND
|
||||||
AppFunctionEnum.DEPLOY_K8S_SRS
|
// AppFunctionEnum.DEPLOY_K8S_SRS
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user