mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #9584 from rainzm/ansibleserver/role
more convenient debugging and role isolation
This commit is contained in:
@@ -26,6 +26,7 @@ import (
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/sqlchemy"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/ansibleserver/options"
|
||||
"yunion.io/x/onecloud/pkg/apis"
|
||||
api "yunion.io/x/onecloud/pkg/apis/ansible"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
||||
@@ -199,7 +200,8 @@ func (apb *SAnsiblePlaybookV2) runPlaybook(ctx context.Context, userCred mcclien
|
||||
PrivateKey(privateKey).
|
||||
Requirements(apb.Requirements).
|
||||
Files(files).
|
||||
OutputWriter(&ansiblePlaybookOutputWriter{apb})
|
||||
OutputWriter(&ansiblePlaybookOutputWriter{apb}).
|
||||
KeepTmpdir(options.Options.KeepTmpdir)
|
||||
man.sessions.Add(apb.Id, sess)
|
||||
|
||||
// NOTE host state check? run only on online hosts and running guests, skip others
|
||||
|
||||
@@ -19,6 +19,7 @@ import common_options "yunion.io/x/onecloud/pkg/cloudcommon/options"
|
||||
type AnsibleServerOptions struct {
|
||||
common_options.CommonOptions
|
||||
common_options.DBOptions
|
||||
KeepTmpdir bool `help:"Whether to save the tmp directory" json:"keep_tmpdir"`
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
@@ -90,6 +90,11 @@ func (sess *Session) OutputWriter(w io.Writer) *Session {
|
||||
return sess
|
||||
}
|
||||
|
||||
func (sess *Session) KeepTmpdir(keep bool) *Session {
|
||||
sess.keepTmpdir = keep
|
||||
return sess
|
||||
}
|
||||
|
||||
func (sess *Session) Run(ctx context.Context) (err error) {
|
||||
var (
|
||||
tmpdir string
|
||||
@@ -187,7 +192,7 @@ func (sess *Session) Run(ctx context.Context) (err error) {
|
||||
// install required roles
|
||||
if len(requirements) > 0 {
|
||||
args := []string{
|
||||
"install", "-r", requirements,
|
||||
"install", "-r", requirements, "-p", tmpdir,
|
||||
}
|
||||
cmd := exec.CommandContext(ctx, "ansible-galaxy", args...)
|
||||
stdout, _ := cmd.StdoutPipe()
|
||||
|
||||
Reference in New Issue
Block a user