New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add pacemaker_resource module for managing cluster resources #53
Conversation
Add pacemaker_resource module for managing pacemaker cluster resources.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,
Thank you for this PR and the other one.
Do you expect there will be other pacemaker PRs? I'm wondering if it would be better for them to be in their own pacemaker collection.
@gundalow Hi, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know anything about pacemaker, though here are some general comments on the module format.
gather_facts: no | ||
tasks: | ||
- name: enable haproxy | ||
pacemaker_resource: state=enable resource=haproxy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Please use
key: value
- For new modules they need to use the FQCN (Fully Qualified Collection Name):
pacemaker_resource: state=enable resource=haproxy | |
community.general.pacemaker_resource: | |
state: enable | |
resource: haproxy |
module: pacemaker_resource | ||
short_description: Manage a pacemaker resource | ||
extends_documentation_fragment: openstack | ||
version_added: "2.9" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
version_added: "2.9" |
resource: | ||
description: | ||
- Specify which resource you want to handle | ||
required: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
required: false |
timeout: | ||
description: | ||
- Timeout when the module should considered that the action has failed | ||
required: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
required: false |
check_mode: | ||
description: | ||
- Check only the status of the resource | ||
required: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
required: false |
description: | ||
- Wait for resource to get the required state, will failed if the | ||
timeout is reach | ||
required: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
required: false |
wait_for_resource: | ||
description: | ||
- Wait for resource to get the required state, will failed if the | ||
timeout is reach |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I(...)
is how we use Italics to refer to another paramater
timeout is reach | |
I(timeout) seconds is reached. |
description: | ||
- Timeout when the module should considered that the action has failed | ||
required: false | ||
default: 300 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default: 300 | |
default: 300 | |
type: int |
--- | ||
module: pacemaker_resource | ||
short_description: Manage a pacemaker resource | ||
extends_documentation_fragment: openstack |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You want to change this as well to match openstack documentation fragment.
version_added: "2.9" | ||
author: "Mathieu Bultel (matbu)" | ||
description: | ||
- Manage a pacemaker resource from Ansible |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Manage a pacemaker resource from Ansible | |
- Manage a pacemaker resource from Ansible. |
options: | ||
state: | ||
description: | ||
- Indicate desired state of the cluster |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Indicate desired state of the cluster | |
- Indicate the desired state of the cluster. |
required: true | ||
resource: | ||
description: | ||
- Specify which resource you want to handle |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Specify which resource you want to handle | |
- Specify which resource user wants to handle. |
default: None | ||
timeout: | ||
description: | ||
- Timeout when the module should considered that the action has failed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Timeout when the module should considered that the action has failed | |
- Timeout when the module should be considered that the action has failed. |
required: false | ||
default: false | ||
requirements: | ||
- "python >= 2.6" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- "python >= 2.6" | |
- "python >= 2.7" |
''' | ||
|
||
RETURN = ''' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a RETURN block. This will help users to understand the return of the module without running the module actually. Gives a good UI/UX to the module.
|
||
def check_resource_state(module, resource, state): | ||
# get resources | ||
cmd = "bash -c 'pcs status --full | grep -w \"%s[ \t]\"'" % resource |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please parse output in Python. This will lead to security vulnerability since resource
is governed by user input.
Also, don't assume bash will be available on the given machine.
|
||
|
||
def get_resource(module, resource): | ||
cmd = "pcs resource show %s" % resource |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any check to sanitize resource
?
@@ -0,0 +1,153 @@ | |||
#!/usr/bin/python | |||
# -*- coding: utf-8 -*- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add a unit test for this module?
The test
|
@@ -0,0 +1,153 @@ | |||
#!/usr/bin/python |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a symlink to this file in plugins/modules
@matbu Hi, anything we can do to help you with this, please feel free to ask here. Or if you are used to IRC feel free to join in |
@matbu any updates on this? |
* Update README and add CHANGELOG * Prepare changelog for version 0.2.0
@matbu Hi, is there anything we can do to help you with this PR for adding a new |
@matbu This pullrequest is waiting for your response. Please respond or the pullrequest will be closed. |
Closing since there was no more reaction. @matbu if you're interested again in working on this, please ping me. If someone else is interested in continuing this PR, please also write it here so we can coordinate. |
Add pacemaker_resource module for managing pacemaker cluster
resources.
SUMMARY
ISSUE TYPE
COMPONENT NAME
ADDITIONAL INFORMATION