From 5a6f5084ddb918c755f86a8ac0fe2e544a484252 Mon Sep 17 00:00:00 2001 From: Gavin Chappell Date: Thu, 10 Apr 2025 10:50:05 +0100 Subject: [PATCH] Don't compare current state for `reboot_*` actions When performing these actions a server will start `ACTIVE` and end `ACTIVE` meaning that the Ansible module skips over the host you are trying to reboot because it looks like the action was already taken. Tests are updated to reflect `changed=True` with the end state remaining as `ACTIVE` Closes-Bug: 2046429 Change-Id: I8828f05bb5402fd2ba2c26b67c727abfbcc43202 --- ci/roles/server_action/tasks/main.yml | 4 ++-- plugins/modules/server_action.py | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ci/roles/server_action/tasks/main.yml b/ci/roles/server_action/tasks/main.yml index e3b78c8b..bbb32237 100644 --- a/ci/roles/server_action/tasks/main.yml +++ b/ci/roles/server_action/tasks/main.yml @@ -553,7 +553,7 @@ assert: that: - servers.servers.0.status == 'ACTIVE' - - server is not changed + - server is changed - name: Reboot server (HARD) openstack.cloud.server_action: @@ -573,7 +573,7 @@ assert: that: - servers.servers.0.status == 'ACTIVE' - - server is not changed + - server is changed - name: Delete server openstack.cloud.server: diff --git a/plugins/modules/server_action.py b/plugins/modules/server_action.py index 4b1a0fc4..9af103c0 100644 --- a/plugins/modules/server_action.py +++ b/plugins/modules/server_action.py @@ -136,6 +136,9 @@ class ServerActionModule(OpenStackModule): # rebuild does not depend on state will_change = ( (action == 'rebuild') + # `reboot_*` actions do not change state, servers remain `ACTIVE` + or (action == 'reboot_hard') + or (action == 'reboot_soft') or (action == 'lock' and not server['is_locked']) or (action == 'unlock' and server['is_locked']) or server.status.lower() not in [a.lower()