mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-07-01 04:24:24 +08:00
Merge pull request #11693 from rainzm/agent/baremetal
feat: support install monitor agent in baremetal
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
FROM registry.cn-beijing.aliyuncs.com/yunionio/ansibleserver-base:v1.0.3
|
||||
|
||||
# install playbook and telegraf install pkg
|
||||
COPY --from=registry.cn-beijing.aliyuncs.com/yunionio/file-repo:v0.2.0 /opt/yunion/playbook /opt/yunion/playbook
|
||||
COPY --from=registry.cn-beijing.aliyuncs.com/yunionio/file-repo:v0.2.0 /opt/yunion/ansible-install-pkg /opt/yunion/ansible-install-pkg
|
||||
COPY --from=registry.cn-beijing.aliyuncs.com/yunionio/file-repo:v0.2.1 /opt/yunion/playbook /opt/yunion/playbook
|
||||
COPY --from=registry.cn-beijing.aliyuncs.com/yunionio/file-repo:v0.2.1 /opt/yunion/ansible-install-pkg /opt/yunion/ansible-install-pkg
|
||||
|
||||
ADD ./_output/alpine-build/bin/ansibleserver /opt/yunion/bin/ansibleserver
|
||||
|
||||
@@ -251,14 +251,13 @@ type sSSHable struct {
|
||||
port int
|
||||
}
|
||||
|
||||
// func (self *ApplyScriptTask) ansibleHost(session modules.SS)
|
||||
func (self *ApplyScriptTask) checkSshableForYunionCloud(session *mcclient.ClientSession, serverDetail *comapi.ServerDetails) (sSSHable, error) {
|
||||
if serverDetail.IPs == "" {
|
||||
return sSSHable{}, fmt.Errorf("empty ips for server %s", serverDetail.Id)
|
||||
}
|
||||
ips := strings.Split(serverDetail.IPs, ",")
|
||||
ip := strings.TrimSpace(ips[0])
|
||||
if serverDetail.VpcId == "" || serverDetail.VpcId == comapi.DEFAULT_VPC_ID {
|
||||
if serverDetail.Hypervisor == comapi.HYPERVISOR_BAREMETAL || serverDetail.VpcId == "" || serverDetail.VpcId == comapi.DEFAULT_VPC_ID {
|
||||
return sSSHable{
|
||||
ok: true,
|
||||
user: "cloudroot",
|
||||
@@ -319,7 +318,7 @@ func (self *ApplyScriptTask) checkSshableForYunionCloud(session *mcclient.Client
|
||||
}
|
||||
|
||||
func (self *ApplyScriptTask) checkSshable(session *mcclient.ClientSession, serverDetail *comapi.ServerDetails) (sSSHable, error) {
|
||||
if serverDetail.Hypervisor == comapi.HYPERVISOR_KVM {
|
||||
if serverDetail.Hypervisor == comapi.HYPERVISOR_KVM || serverDetail.Hypervisor == comapi.HYPERVISOR_BAREMETAL {
|
||||
return self.checkSshableForYunionCloud(session, serverDetail)
|
||||
}
|
||||
return self.checkSshableForOtherCloud(session, serverDetail.Id)
|
||||
@@ -422,19 +421,13 @@ func (self *ApplyScriptTask) OnAnsiblePlaybookComplete(ctx context.Context, obj
|
||||
}
|
||||
|
||||
func (self *ApplyScriptTask) OnAnsiblePlaybookCompleteFailed(ctx context.Context, obj db.IStandaloneModel, body jsonutils.JSONObject) {
|
||||
// try to delete local forward
|
||||
session := auth.GetAdminSession(ctx, "", "")
|
||||
forwardId, _ := self.Params.GetString("proxy_forward_id")
|
||||
_, err := cloudproxy.Forwards.Delete(session, forwardId, nil)
|
||||
if err != nil {
|
||||
log.Errorf("unable to delete proxy forward %s: %v", forwardId, err)
|
||||
}
|
||||
sa := obj.(*models.SScriptApply)
|
||||
sarId, _ := self.Params.GetString("script_apply_record_id")
|
||||
osar, err := models.ScriptApplyRecordManager.FetchById(sarId)
|
||||
if err != nil {
|
||||
log.Errorf("unable to fetch script apply record %s: %v", sarId, err)
|
||||
self.taskSuccess(ctx, sa, nil)
|
||||
self.taskFailed(ctx, sa, nil, errors.Error(body.String()))
|
||||
} else {
|
||||
self.taskFailed(ctx, sa, osar.(*models.SScriptApplyRecord), errors.Error(body.String()))
|
||||
}
|
||||
self.taskFailed(ctx, sa, osar.(*models.SScriptApplyRecord), errors.Error(body.String()))
|
||||
}
|
||||
|
||||
@@ -262,7 +262,7 @@ func influxdbUrlDirect(ctx context.Context, influxdbUrl, proxyEndpointId string,
|
||||
|
||||
func findValidInfluxdbUrl(ctx context.Context, influxdbUrl, proxyEndpointId string, info sServerInfo, host *ansible_api.AnsibleHost) (string, error) {
|
||||
findFuncs := []func(ctx context.Context, influxdbUrl, proxyEndpointId string, info sServerInfo, host *ansible_api.AnsibleHost) (string, error){}
|
||||
if info.serverDetails.Hypervisor == comapi.HYPERVISOR_KVM {
|
||||
if info.serverDetails.Hypervisor == comapi.HYPERVISOR_KVM || info.serverDetails.Hypervisor == comapi.HYPERVISOR_BAREMETAL {
|
||||
findFuncs = append(findFuncs, influxdbUrlDirect, influxdbUrlViaProxyEndpoint)
|
||||
} else {
|
||||
findFuncs = append(findFuncs, influxdbUrlViaProxyEndpoint, influxdbUrlDirect)
|
||||
@@ -420,5 +420,8 @@ func GetArgs(ctx context.Context, serverId, proxyEndpointId string, others inter
|
||||
"influxdb_name": "telegraf",
|
||||
"telegraf_global_tags": telegrafTags,
|
||||
}
|
||||
if info.serverDetails.Hypervisor == comapi.HYPERVISOR_BAREMETAL {
|
||||
ret["server_type"] = "baremetal"
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user