feat: add keep_tmpdir options

Setting 'keep_tmpdir' as true will keep tmpdir as used by executing
ansible playbook for debugging
This commit is contained in:
rainzm
2020-12-22 20:14:48 +08:00
parent 31a0fb76fd
commit cfa426bc18
3 changed files with 9 additions and 1 deletions
@@ -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
+1
View File
@@ -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 (
+5
View File
@@ -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