From f226d342e19ba88da35b4753022af2368d655b4e Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Tue, 12 May 2020 10:33:43 +0800 Subject: [PATCH] region: lbagent: undeploy: make it idempotent Both the following three can result in the same error message "Could not find the requested service yunion-xx: host" -m systemd -a 'name=yunion-xx enabled=no state=stopped daemon_reload=yes' -m systemd -a 'name=yunion-xx enabled=no state=stopped daemon_reload=yes force=yes' -m service -a 'name=yunion-xx enabled=no state=stopped' Use of ansibleplaybookv2 is overkill and can break console expectation. Just turn to shell module for now --- pkg/compute/models/loadbalanceragents_deploy.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pkg/compute/models/loadbalanceragents_deploy.go b/pkg/compute/models/loadbalanceragents_deploy.go index 8b42998870..bce77414a6 100644 --- a/pkg/compute/models/loadbalanceragents_deploy.go +++ b/pkg/compute/models/loadbalanceragents_deploy.go @@ -216,12 +216,9 @@ func (lbagent *SLoadbalancerAgent) undeploy(ctx context.Context, userCred mcclie }, Modules: []ansible.Module{ { - Name: "systemd", + Name: "shell", Args: []string{ - "name=yunion-lbagent", - "enabled=no", - "state=stopped", - "daemon_reload=yes", + "systemctl disable --now yunion-lbagent; true", }, }, {