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
This commit is contained in:
Yousong Zhou
2020-05-12 10:38:33 +08:00
parent 51556009fa
commit f226d342e1
@@ -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",
},
},
{