Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
=================
ansible-pacemaker
=================

Expand Down
15 changes: 15 additions & 0 deletions modules/pacemaker_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@

'''

_PCS_CLUSTER_DOWN="Error: cluster is not currently running on this node"

def get_cluster_status(module):
cmd = "pcs cluster status"
rc, out, err = module.run_command(cmd)
if out in _PCS_CLUSTER_DOWN:
return 'offline'
else:
return 'online'

def check_resource_state(module, resource, state):
# get resources
Expand Down Expand Up @@ -120,6 +129,12 @@ def main():
check_mode = module.params['check_mode']
wait_for_resource = module.params['wait_for_resource']

# First, check if the cluster is running
# Exit if the cluster is down
cluster_state = get_cluster_status(module)
if cluster_state == 'offline':
module.fail_json(msg="The cluster is either offline or not started on the node")

if check_mode:
if check_resource_state(module, resource, state):
module.exit_json(changed=False,
Expand Down