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
cb700e91
Commit
cb700e91
authored
Jul 11, 2023
by
陈子龙
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev-czl' into dev
parents
d7a1491d
083522e1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
4 deletions
+6
-4
src/service/task_manage.go
src/service/task_manage.go
+6
-4
No files found.
src/service/task_manage.go
View file @
cb700e91
...
@@ -227,24 +227,26 @@ func (t *TaskManageSvc) ExecScript(req request.ExecScriptReq, script string) (id
...
@@ -227,24 +227,26 @@ func (t *TaskManageSvc) ExecScript(req request.ExecScriptReq, script string) (id
for
_
,
v
:=
range
hostManageList
{
for
_
,
v
:=
range
hostManageList
{
hostsIp
:=
""
hostsIp
:=
""
if
v
.
VoucherType
==
0
{
if
v
.
VoucherType
==
0
{
hostsIp
=
fmt
.
Sprintf
(
"%s:%s ansible_ssh_user=
\"
%s
\"
ansible_ssh_pass=
\"
%s
\"
ansible_host_key_checking=false
\n
"
,
hostsIp
=
fmt
.
Sprintf
(
"%s:%s ansible_ssh_user=
\"
%s
\"
ansible_ssh_pass=
\"
%s
\"
ansible_host_key_checking=false"
,
v
.
Ip
,
v
.
Port
,
v
.
UserName
,
v
.
Password
)
v
.
Ip
,
v
.
Port
,
v
.
UserName
,
v
.
Password
)
}
else
{
}
else
{
hostsIp
=
fmt
.
Sprintf
(
"%s:%s ansible_ssh_user=
\"
%s
\"
ansible_ssh_private_key_file=/root/.ssh/id_rsa ansible_host_key_checking=false
\n
"
,
hostsIp
=
fmt
.
Sprintf
(
"%s:%s ansible_ssh_user=
\"
%s
\"
ansible_ssh_private_key_file=/root/.ssh/id_rsa ansible_host_key_checking=false"
,
v
.
Ip
,
v
.
Port
,
v
.
UserName
)
v
.
Ip
,
v
.
Port
,
v
.
UserName
)
}
}
hosts
=
append
(
hosts
,
hostsIp
)
hosts
=
append
(
hosts
,
hostsIp
)
}
}
//写入主机信息
//写入主机信息
hostsIp
:=
strings
.
Replace
(
strings
.
Trim
(
fmt
.
Sprint
(
hosts
),
"[]"
),
" "
,
"
\n
"
,
-
1
)
//hostsIp := strings.Replace(strings.Trim(fmt.Sprint(hosts), "[]"), " ", " ", -1)
hostsGroup
,
err
:=
os
.
Create
(
"/etc/ansible/hosts_"
+
fmt
.
Sprintf
(
"%d"
,
req
.
TaskId
))
hostsGroup
,
err
:=
os
.
Create
(
"/etc/ansible/hosts_"
+
fmt
.
Sprintf
(
"%d"
,
req
.
TaskId
))
if
err
!=
nil
{
if
err
!=
nil
{
err
=
resp
.
FileExecError
.
WithError
(
err
)
err
=
resp
.
FileExecError
.
WithError
(
err
)
return
return
}
}
defer
hostsGroup
.
Close
()
defer
hostsGroup
.
Close
()
_
,
err
=
hostsGroup
.
Write
([]
byte
(
hostsIp
))
//_, err = hostsGroup.Write([]byte(hostsIp))
_
,
err
=
hostsGroup
.
Write
([]
byte
(
strings
.
Join
(
hosts
,
"
\n
"
)))
if
err
!=
nil
{
if
err
!=
nil
{
err
=
resp
.
FileExecError
.
WithError
(
err
)
err
=
resp
.
FileExecError
.
WithError
(
err
)
return
return
...
...
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