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
a7a23d3d
Commit
a7a23d3d
authored
Jul 06, 2023
by
陈子龙
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev-czl' into dev
parents
e0b5a313
1fd9feab
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
12 deletions
+10
-12
src/common/conf/options.go
src/common/conf/options.go
+2
-3
src/main.go
src/main.go
+4
-5
src/service/host_manage.go
src/service/host_manage.go
+4
-4
No files found.
src/common/conf/options.go
View file @
a7a23d3d
...
@@ -35,9 +35,8 @@ type Config struct {
...
@@ -35,9 +35,8 @@ type Config struct {
AccessRuleModeKey
string
AccessRuleModeKey
string
LocationUrl
string
LocationUrl
string
LocationKey
string
LocationKey
string
PrivateKeySSH
string
PrivateKeySSH
string
PublicKeySSH
string
PublicKeySSH
string
}
}
const
(
const
(
...
...
src/main.go
View file @
a7a23d3d
...
@@ -77,9 +77,8 @@ func initConfig() {
...
@@ -77,9 +77,8 @@ func initConfig() {
AccessRuleModeKey
:
"accessRuleMode"
,
AccessRuleModeKey
:
"accessRuleMode"
,
LocationUrl
:
util
.
SetEnvStr
(
"LOCATION_URL"
,
"https://apis.map.qq.com/ws/location/v1/ip"
),
LocationUrl
:
util
.
SetEnvStr
(
"LOCATION_URL"
,
"https://apis.map.qq.com/ws/location/v1/ip"
),
LocationKey
:
util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jLV4h4Hbie
\n
VwlPYP4otKHdF5meObr+2ifYiMktdv/44V1XWKhgavjGFNWx2sHgj7byb51e/bi3MAAABB
\n
AMtVxa55G0wS9Yw1WK2F4JdYZ65ZAnUuo2rbA2dMDQxsOQxgel5Ox2XmC7e0GKrO9BJKPo
\n
R2fHEOdm9KOmoB8IkAAAAWY2hlbnppbG9uZ0BleGFtcGxlLmNvbQECAwQF
\n
-----END OPENSSH PRIVATE KEY-----"
),
PublicKeySSH
:
util
.
SetEnvStr
(
"PUBLIC_KEY_SSH"
,
""
),
PublicKeySSH
:
util
.
SetEnvStr
(
"PUBLIC_KEY_SSH"
,
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQCw4WT05QHzCD19348MfJfycS1NI9Jlj62PGrZ1rU9/kWQif5TV1rqHZ6qjAX2WfK+W3u4SV51MhZBkMZZOgZgJmdGiaZJkSmj+8gj6XU/bxslUd+BYUKqbE18gFkVDgqs6n2tcqJ2at3x+WEr81Msk2qvKuGEiIOzcJPICWKxwiw== chenzilong@example.com"
),
}
}
}
}
...
@@ -151,7 +150,7 @@ func initAnsibleSSH() {
...
@@ -151,7 +150,7 @@ func initAnsibleSSH() {
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Println
(
"创建目录失败!"
)
fmt
.
Println
(
"创建目录失败!"
)
}
}
f
,
err
:=
os
.
Create
(
"/root/.ssh/
chenzilong
"
)
f
,
err
:=
os
.
Create
(
"/root/.ssh/
id_rsa
"
)
defer
f
.
Close
()
defer
f
.
Close
()
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Println
(
err
.
Error
())
fmt
.
Println
(
err
.
Error
())
...
@@ -161,7 +160,7 @@ func initAnsibleSSH() {
...
@@ -161,7 +160,7 @@ func initAnsibleSSH() {
fmt
.
Println
(
err
.
Error
())
fmt
.
Println
(
err
.
Error
())
}
}
}
}
f2
,
err
:=
os
.
Create
(
"/root/.ssh/
chenzilong
.pub"
)
f2
,
err
:=
os
.
Create
(
"/root/.ssh/
id_rsa
.pub"
)
defer
f2
.
Close
()
defer
f2
.
Close
()
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Println
(
err
.
Error
())
fmt
.
Println
(
err
.
Error
())
...
...
src/service/host_manage.go
View file @
a7a23d3d
...
@@ -122,7 +122,7 @@ func (h *HostManageSvc) AddHostManage(req request.AddHostManageReq) (err error)
...
@@ -122,7 +122,7 @@ func (h *HostManageSvc) AddHostManage(req request.AddHostManageReq) (err error)
hostsIp
=
fmt
.
Sprintf
(
"%s ansible_ssh_host=%s ansible_ssh_port=%s ansible_ssh_user=
\"
%s
\"
ansible_ssh_pass=
\"
%s
\"
"
,
hostsIp
=
fmt
.
Sprintf
(
"%s ansible_ssh_host=%s ansible_ssh_port=%s ansible_ssh_user=
\"
%s
\"
ansible_ssh_pass=
\"
%s
\"
"
,
AnsibleIp
+
fmt
.
Sprintf
(
"%d"
,
hostManageList
.
Id
),
v
.
Ip
,
v
.
Port
,
v
.
UserName
,
v
.
Password
)
AnsibleIp
+
fmt
.
Sprintf
(
"%d"
,
hostManageList
.
Id
),
v
.
Ip
,
v
.
Port
,
v
.
UserName
,
v
.
Password
)
}
else
{
}
else
{
hostsIp
=
fmt
.
Sprintf
(
"%s ansible_ssh_host=%s ansible_ssh_port=%s ansible_ssh_user=
\"
%s
\"
"
,
hostsIp
=
fmt
.
Sprintf
(
"%s ansible_ssh_host=%s ansible_ssh_port=%s ansible_ssh_user=
\"
%s
\"
ansible_ssh_private_key_file=/root/.ssh/id_rsa
"
,
AnsibleIp
+
fmt
.
Sprintf
(
"%d"
,
hostManageList
.
Id
),
v
.
Ip
,
v
.
Port
,
v
.
UserName
)
AnsibleIp
+
fmt
.
Sprintf
(
"%d"
,
hostManageList
.
Id
),
v
.
Ip
,
v
.
Port
,
v
.
UserName
)
}
}
...
@@ -231,7 +231,7 @@ func (h *HostManageSvc) EditHostManage(req request.EditHostManageReq) (err error
...
@@ -231,7 +231,7 @@ func (h *HostManageSvc) EditHostManage(req request.EditHostManageReq) (err error
hostsIp
=
fmt
.
Sprintf
(
"%s ansible_ssh_host=%s ansible_ssh_port=%s ansible_ssh_user=
\"
%s
\"
ansible_ssh_pass=
\"
%s
\"
"
,
hostsIp
=
fmt
.
Sprintf
(
"%s ansible_ssh_host=%s ansible_ssh_port=%s ansible_ssh_user=
\"
%s
\"
ansible_ssh_pass=
\"
%s
\"
"
,
AnsibleIp
+
fmt
.
Sprintf
(
"%d"
,
hostManageList
.
Id
),
v
.
Ip
,
v
.
Port
,
v
.
UserName
,
v
.
Password
)
AnsibleIp
+
fmt
.
Sprintf
(
"%d"
,
hostManageList
.
Id
),
v
.
Ip
,
v
.
Port
,
v
.
UserName
,
v
.
Password
)
}
else
{
}
else
{
hostsIp
=
fmt
.
Sprintf
(
"%s ansible_ssh_host=%s ansible_ssh_port=%s ansible_ssh_user=
\"
%s
\"
"
,
hostsIp
=
fmt
.
Sprintf
(
"%s ansible_ssh_host=%s ansible_ssh_port=%s ansible_ssh_user=
\"
%s
\"
ansible_ssh_private_key_file=/root/.ssh/id_rsa
"
,
AnsibleIp
+
fmt
.
Sprintf
(
"%d"
,
hostManageList
.
Id
),
v
.
Ip
,
v
.
Port
,
v
.
UserName
)
AnsibleIp
+
fmt
.
Sprintf
(
"%d"
,
hostManageList
.
Id
),
v
.
Ip
,
v
.
Port
,
v
.
UserName
)
}
}
...
@@ -428,7 +428,7 @@ func (h *HostManageSvc) ListStateHostManage(req request.StateHostManageReq) (err
...
@@ -428,7 +428,7 @@ func (h *HostManageSvc) ListStateHostManage(req request.StateHostManageReq) (err
hostsIp
=
fmt
.
Sprintf
(
"%s ansible_ssh_host=%s ansible_ssh_port=%s ansible_ssh_user=
\"
%s
\"
ansible_ssh_pass=
\"
%s
\"
"
,
hostsIp
=
fmt
.
Sprintf
(
"%s ansible_ssh_host=%s ansible_ssh_port=%s ansible_ssh_user=
\"
%s
\"
ansible_ssh_pass=
\"
%s
\"
"
,
AnsibleIp
+
fmt
.
Sprintf
(
"%d"
,
v
.
Id
),
v
.
Ip
,
v
.
Port
,
v
.
UserName
,
v
.
Password
)
AnsibleIp
+
fmt
.
Sprintf
(
"%d"
,
v
.
Id
),
v
.
Ip
,
v
.
Port
,
v
.
UserName
,
v
.
Password
)
}
else
{
}
else
{
hostsIp
=
fmt
.
Sprintf
(
"%s ansible_ssh_host=%s ansible_ssh_port=%s ansible_ssh_user=
\"
%s
\"
"
,
hostsIp
=
fmt
.
Sprintf
(
"%s ansible_ssh_host=%s ansible_ssh_port=%s ansible_ssh_user=
\"
%s
\"
ansible_ssh_private_key_file=/root/.ssh/id_rsa
"
,
AnsibleIp
+
fmt
.
Sprintf
(
"%d"
,
v
.
Id
),
v
.
Ip
,
v
.
Port
,
v
.
UserName
)
AnsibleIp
+
fmt
.
Sprintf
(
"%d"
,
v
.
Id
),
v
.
Ip
,
v
.
Port
,
v
.
UserName
)
}
}
...
@@ -516,7 +516,7 @@ func (h *HostManageSvc) SaveStateHostManage(hostManageList []request.HostManageL
...
@@ -516,7 +516,7 @@ func (h *HostManageSvc) SaveStateHostManage(hostManageList []request.HostManageL
hostsIp
=
fmt
.
Sprintf
(
"%s ansible_ssh_host=%s ansible_ssh_port=%s ansible_ssh_user=
\"
%s
\"
ansible_ssh_pass=
\"
%s
\"
"
,
hostsIp
=
fmt
.
Sprintf
(
"%s ansible_ssh_host=%s ansible_ssh_port=%s ansible_ssh_user=
\"
%s
\"
ansible_ssh_pass=
\"
%s
\"
"
,
AnsibleIp
+
v
.
Ip
,
v
.
Ip
,
v
.
Port
,
v
.
UserName
,
v
.
Password
)
AnsibleIp
+
v
.
Ip
,
v
.
Ip
,
v
.
Port
,
v
.
UserName
,
v
.
Password
)
}
else
{
}
else
{
hostsIp
=
fmt
.
Sprintf
(
"%s ansible_ssh_host=%s ansible_ssh_port=%s ansible_ssh_user=
\"
%s
\"
"
,
hostsIp
=
fmt
.
Sprintf
(
"%s ansible_ssh_host=%s ansible_ssh_port=%s ansible_ssh_user=
\"
%s
\"
ansible_ssh_private_key_file=/root/.ssh/id_rsa
"
,
AnsibleIp
+
v
.
Ip
,
v
.
Ip
,
v
.
Port
,
v
.
UserName
)
AnsibleIp
+
v
.
Ip
,
v
.
Ip
,
v
.
Port
,
v
.
UserName
)
}
}
flag
:=
0
flag
:=
0
...
...
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