修复ansible执行错误

pull/21/merge
ouqiang 8 years ago
parent f50100fd2b
commit 2450d193f3

@ -14,7 +14,6 @@ import (
"os/exec"
"syscall"
"github.com/ouqiang/gocron/modules/logger"
"fmt"
)
// 1号进程id

@ -32,7 +32,6 @@ func ExecCommand(hosts string, hostFile string, module string, args ...string) (
if len(args) > 0 {
commandArgs = append(commandArgs, args...)
}
logger.Info(commandArgs)
output, err = utils.ExecShell("ansible", commandArgs...)
return

@ -5,6 +5,7 @@ import (
"github.com/ouqiang/gocron/models"
"github.com/ouqiang/gocron/modules/utils"
"github.com/ouqiang/gocron/modules/logger"
"github.com/ouqiang/gocron/modules/ansible"
)
func Create(ctx *macaron.Context) {
@ -38,5 +39,7 @@ func Store(ctx *macaron.Context, form HostForm) string {
return json.Failure(utils.ResponseFailure, "保存失败")
}
ansible.DefaultHosts.Write()
return json.Success("保存成功", nil)
}

@ -105,7 +105,7 @@ func (ssh *SSHScriptHandler) Run(taskModel models.Task) (string, error) {
// SSH任务
func execSSHHandler(module string, taskModel models.Task) (string, error) {
var args []string = []string{"-a", "'" + taskModel.Command + "'"}
var args []string = []string{"-a", taskModel.Command}
if taskModel.Timeout > 0 {
// -B 异步执行超时时间, -P 轮询时间
args = append(args, "-B", strconv.Itoa(taskModel.Timeout), "-P", "10")

@ -64,7 +64,7 @@
{{{range $i, $v := .Hosts}}}
<div class="field">
<div class="ui checkbox">
<input type="checkbox" name="hosts[]" tabindex="0" class="hidden" value="{{{.Alias}}}">
<input type="checkbox" name="hosts[]" tabindex="0" class="hidden" value="{{{.Id}}}">
<label>{{{.Alias}}}-{{{.Name}}}</label>
</div>
</div>

Loading…
Cancel
Save