From f3f30858d02c3197931d703ee18db4d6b1c09ec8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ne=C4=8Das?= Date: Fri, 2 Sep 2022 09:11:29 +0200 Subject: [PATCH] ovirt_host: reinstalled - honor activate and reboot_after_installation when false (#587) * ovirt_host: reinstalled - Allow to set activate and reboot_after_installation to false * Add changelog --- ...irt_host-honor-activate-and-reboot-params.yml | 3 +++ plugins/modules/ovirt_host.py | 16 +++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) create mode 100644 changelogs/fragments/587-ovirt_host-honor-activate-and-reboot-params.yml diff --git a/changelogs/fragments/587-ovirt_host-honor-activate-and-reboot-params.yml b/changelogs/fragments/587-ovirt_host-honor-activate-and-reboot-params.yml new file mode 100644 index 00000000..5c36e77c --- /dev/null +++ b/changelogs/fragments/587-ovirt_host-honor-activate-and-reboot-params.yml @@ -0,0 +1,3 @@ +--- +bugfixes: + - ovirt_host - Honor activate and reboot_after_installation when they are set to false with reinstalled host state (https://github.com/oVirt/ovirt-ansible-collection/pull/587). diff --git a/plugins/modules/ovirt_host.py b/plugins/modules/ovirt_host.py index d3d2b094..41a7725a 100644 --- a/plugins/modules/ovirt_host.py +++ b/plugins/modules/ovirt_host.py @@ -719,10 +719,11 @@ def main(): ) # Reinstall host: - hosts_module.action( + ret = hosts_module.action( action='install', action_condition=lambda h: h.status == hoststate.MAINTENANCE, post_action=hosts_module.post_reinstall, + reboot=module.params.get('reboot_after_installation'), wait_condition=lambda h: h.status == hoststate.MAINTENANCE, fail_condition=hosts_module.failed_state_after_reinstall, host=otypes.Host( @@ -741,12 +742,13 @@ def main(): ) # Activate host after reinstall: - ret = hosts_module.action( - action='activate', - action_condition=lambda h: h.status == hoststate.MAINTENANCE, - wait_condition=lambda h: h.status == hoststate.UP, - fail_condition=failed_state, - ) + if module.params['activate']: + ret = hosts_module.action( + action='activate', + action_condition=lambda h: h.status == hoststate.MAINTENANCE, + wait_condition=lambda h: h.status == hoststate.UP, + fail_condition=failed_state, + ) module.exit_json(**ret) except Exception as e: module.fail_json(msg=str(e), exception=traceback.format_exc())