Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
so-operation-api
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
smart-operation
so-operation-api
Commits
79150d86
Commit
79150d86
authored
Jun 27, 2023
by
魏灿
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
form yml解析
parent
ca1f3688
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
12 deletions
+7
-12
src/bean/vo/request/task_manage.go
src/bean/vo/request/task_manage.go
+4
-4
src/controller/task_manage.go
src/controller/task_manage.go
+1
-6
src/service/task_manage.go
src/service/task_manage.go
+2
-2
No files found.
src/bean/vo/request/task_manage.go
View file @
79150d86
...
...
@@ -32,8 +32,8 @@ type ListTaskManageReq struct {
}
type
ExecScriptReq
struct
{
HostGroupId
int
`
json
:"host_group_id" vd:"$>0;msg:'请输入主机分组id'"`
//主机分组id
Type
int
`
json
:"type"`
//脚本额外变量类型1yaml 2json
Value
string
`
json
:"value"`
//脚本额外变量值
Script
string
`
json
:"script"`
//执行脚本
HostGroupId
int
`
form
:"host_group_id" vd:"$>0;msg:'请输入主机分组id'"`
//主机分组id
Type
int
`
form
:"type"`
//脚本额外变量类型1yaml 2json
Value
string
`
form
:"value"`
//脚本额外变量值
Script
string
`
form
:"script"`
//执行脚本
}
src/controller/task_manage.go
View file @
79150d86
...
...
@@ -119,12 +119,7 @@ func ListTaskManage(c *gin.Context) {
func
ExecScript
(
c
*
gin
.
Context
)
{
var
req
request
.
ExecScriptReq
if
err
:=
c
.
ShouldBindJSON
(
&
req
);
err
!=
nil
{
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
WithError
(
err
),
nil
)
return
}
//参数校验
if
err
:=
util
.
ValidateSimple
(
req
,
"HostManageId"
);
err
!=
nil
{
if
err
:=
c
.
ShouldBind
(
&
req
);
err
!=
nil
{
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
WithError
(
err
),
nil
)
return
}
...
...
src/service/task_manage.go
View file @
79150d86
...
...
@@ -194,9 +194,9 @@ func (t *TaskManageSvc) ExecScript(req request.ExecScriptReq) (data interface{},
}
var
cmd
*
exec
.
Cmd
if
req
.
Value
!=
""
{
cmd
=
exec
.
Command
(
"ansible"
,
"-i"
,
"/etc/ansible/hosts"
,
"/etc/ansible/ansible.yml"
,
"--extra-vars"
,
req
.
Value
)
cmd
=
exec
.
Command
(
"ansible
-playbook
"
,
"-i"
,
"/etc/ansible/hosts"
,
"/etc/ansible/ansible.yml"
,
"--extra-vars"
,
req
.
Value
)
}
else
{
cmd
=
exec
.
Command
(
"ansible"
,
"-i"
,
"/etc/ansible/hosts"
,
"/etc/ansible/ansible.yml"
)
cmd
=
exec
.
Command
(
"ansible
-playbook
"
,
"-i"
,
"/etc/ansible/hosts"
,
"/etc/ansible/ansible.yml"
)
}
output
,
err
:=
cmd
.
Output
()
if
err
!=
nil
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment