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
377d6b11
Commit
377d6b11
authored
Jun 27, 2023
by
魏灿
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
文件权限写入fix
parent
499711b4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
2 deletions
+7
-2
src/service/task_manage.go
src/service/task_manage.go
+7
-2
No files found.
src/service/task_manage.go
View file @
377d6b11
...
...
@@ -156,7 +156,7 @@ func (t *TaskManageSvc) ExecScript(req request.ExecScriptReq) (data interface{},
return
nil
,
resp
.
DbSelectError
.
WithError
(
err
)
}
//写入主机组ip
f
,
err
:=
os
.
Open
(
"/etc/ansible/hosts"
)
f
,
err
:=
os
.
Open
File
(
"/etc/ansible/hosts"
,
os
.
O_APPEND
|
os
.
O_CREATE
|
os
.
O_RDWR
|
os
.
O_TRUNC
,
0777
)
if
err
!=
nil
{
err
=
resp
.
FileExecError
.
WithError
(
err
)
return
...
...
@@ -192,7 +192,12 @@ func (t *TaskManageSvc) ExecScript(req request.ExecScriptReq) (data interface{},
}
req
.
Value
=
fmt
.
Sprintf
(
"@/etc/ansible/ansible_extra.yml"
)
}
cmd
:=
exec
.
Command
(
"ansible"
,
"-i"
,
"/etc/ansible/hosts"
,
"/etc/ansible/ansible.yml"
,
"--extra-vars"
,
req
.
Value
)
var
cmd
*
exec
.
Cmd
if
req
.
Value
!=
""
{
cmd
=
exec
.
Command
(
"ansible"
,
"-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"
)
}
output
,
err
:=
cmd
.
Output
()
if
err
!=
nil
{
err
=
resp
.
CmdExecError
.
WithError
(
err
)
...
...
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