cloud/openstack: fix os_server_action errors when wait is False (#64330)

Using os_server_action to perform start, stop and pause actions on a
server in OpenStack results in an error when 'wait' is False.

The command is successfully sent to OpenStack, however Ansible fails the
task:

  fatal: [127.0.0.1]: FAILED! => {
    "changed": false,
    "msg": "New-style module did not handle its own exit"
  }

This patch ensures that those actions always exit, whether running with
'wait' set to True or False.

As we are not waiting to confirm the result, this assumes that the
actions were successful.

Fixes #62958

Signed-off-by: Chris Smart <chris.smart@humanservices.gov.au>
This commit is contained in:
Chris Smart 2019-11-02 19:42:34 +11:00 committed by ansibot
parent 78e476eb20
commit 42b290b781

View file

@ -154,7 +154,7 @@ def main():
json={'os-stop': None}) json={'os-stop': None})
if wait: if wait:
_wait(timeout, cloud, server, action, module, sdk) _wait(timeout, cloud, server, action, module, sdk)
module.exit_json(changed=True) module.exit_json(changed=True)
if action == 'start': if action == 'start':
if not _system_state_change(action, status): if not _system_state_change(action, status):
@ -165,7 +165,7 @@ def main():
json={'os-start': None}) json={'os-start': None})
if wait: if wait:
_wait(timeout, cloud, server, action, module, sdk) _wait(timeout, cloud, server, action, module, sdk)
module.exit_json(changed=True) module.exit_json(changed=True)
if action == 'pause': if action == 'pause':
if not _system_state_change(action, status): if not _system_state_change(action, status):
@ -176,7 +176,7 @@ def main():
json={'pause': None}) json={'pause': None})
if wait: if wait:
_wait(timeout, cloud, server, action, module, sdk) _wait(timeout, cloud, server, action, module, sdk)
module.exit_json(changed=True) module.exit_json(changed=True)
elif action == 'unpause': elif action == 'unpause':
if not _system_state_change(action, status): if not _system_state_change(action, status):