1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

pacemaker_cluster: implement check mode (#8081)

* Implement check mode for pacemaker_cluster.

* Fix restart code.

Co-authored-by: Mario Lenz <m@riolenz.de>

---------

Co-authored-by: Mario Lenz <m@riolenz.de>
This commit is contained in:
Felix Fontein 2024-03-14 22:11:13 +01:00 committed by GitHub
parent 6fab46710a
commit 17e275bc0b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 0 deletions

View file

@ -0,0 +1,3 @@
bugfixes:
- "pacemaker_cluster - actually implement check mode, which the module claims to support. This means that until now the module
also did changes in check mode (https://github.com/ansible-collections/community.general/pull/8081)."

View file

@ -188,6 +188,8 @@ def main():
if cluster_state == state: if cluster_state == state:
module.exit_json(changed=changed, out=cluster_state) module.exit_json(changed=changed, out=cluster_state)
else: else:
if module.check_mode:
module.exit_json(changed=True)
set_cluster(module, state, timeout, force) set_cluster(module, state, timeout, force)
cluster_state = get_cluster_status(module) cluster_state = get_cluster_status(module)
if cluster_state == state: if cluster_state == state:
@ -201,12 +203,16 @@ def main():
if node_state[1].strip().lower() == state: if node_state[1].strip().lower() == state:
module.exit_json(changed=changed, out=cluster_state) module.exit_json(changed=changed, out=cluster_state)
else: else:
if module.check_mode:
module.exit_json(changed=True)
# Set cluster status if needed # Set cluster status if needed
set_cluster(module, state, timeout, force) set_cluster(module, state, timeout, force)
cluster_state = get_node_status(module, node) cluster_state = get_node_status(module, node)
module.exit_json(changed=True, out=cluster_state) module.exit_json(changed=True, out=cluster_state)
if state in ['restart']: if state in ['restart']:
if module.check_mode:
module.exit_json(changed=True)
set_cluster(module, 'offline', timeout, force) set_cluster(module, 'offline', timeout, force)
cluster_state = get_cluster_status(module) cluster_state = get_cluster_status(module)
if cluster_state == 'offline': if cluster_state == 'offline':
@ -220,6 +226,8 @@ def main():
module.fail_json(msg="Failed during the restart of the cluster, the cluster can't be stopped") module.fail_json(msg="Failed during the restart of the cluster, the cluster can't be stopped")
if state in ['cleanup']: if state in ['cleanup']:
if module.check_mode:
module.exit_json(changed=True)
clean_cluster(module, timeout) clean_cluster(module, timeout)
cluster_state = get_cluster_status(module) cluster_state = get_cluster_status(module)
module.exit_json(changed=True, module.exit_json(changed=True,