Commit f5e222de authored by 陈子龙's avatar 陈子龙

Merge branch 'dev-czl' into dev

parents cf615210 c0f21773
......@@ -203,15 +203,17 @@ func (t *TaskManageSvc) ExecScript(req request.ExecScriptReq) (data map[string]i
}
req.Script = string(obj)
}
var scripts []map[string]interface{}
var script map[string]interface{}
j2, err := yaml.YAMLToJSON([]byte(req.Script))
if err != nil {
return nil, resp.YamlAnalysisError.WithError(err)
}
err = json.Unmarshal(j2, &script)
err = json.Unmarshal(j2, &scripts)
if err != nil {
return nil, resp.MarshalError.WithError(errors.New("yaml格式错误"))
}
script = scripts[0]
script["host"] = fmt.Sprintf("%s%d", AnsibleGroup, req.HostGroupId)
j, err := json.Marshal(script)
if err != nil {
......@@ -254,6 +256,8 @@ func (t *TaskManageSvc) ExecScript(req request.ExecScriptReq) (data map[string]i
}
stdout, err := cmd.StdoutPipe()
if err != nil {
fmt.Println("执行出错:", err)
fmt.Println("stdout:", stdout)
return nil, resp.CmdExecError.WithError(err)
}
outputBuf := bufio.NewReader(stdout)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment