Skip to content
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

Closed

Conversation

matbu
Copy link

@matbu matbu commented Mar 26, 2020

Add pacemaker_resource module for managing pacemaker cluster
resources.

SUMMARY
ISSUE TYPE
  • Bugfix Pull Request
  • Docs Pull Request
  • Feature Pull Request
  • New Module Pull Request
COMPONENT NAME
ADDITIONAL INFORMATION

Copy link
Contributor

@gundalow gundalow left a 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.

@matbu
Copy link
Author

matbu commented Mar 26, 2020

@gundalow Hi,
nop for now, I don't think we will need more pacemaker modules.
Those two allow us to mainly control the cluster and its resources.

Copy link
Contributor

@gundalow gundalow left a 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Please use key: value
  2. For new modules they need to use the FQCN (Fully Qualified Collection Name):
Suggested change
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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
version_added: "2.9"

resource:
description:
- Specify which resource you want to handle
required: false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
required: false

timeout:
description:
- Timeout when the module should considered that the action has failed
required: false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
required: false

check_mode:
description:
- Check only the status of the resource
required: false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
required: false

description:
- Wait for resource to get the required state, will failed if the
timeout is reach
required: false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
required: false

wait_for_resource:
description:
- Wait for resource to get the required state, will failed if the
timeout is reach
Copy link
Contributor

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

Suggested change
timeout is reach
I(timeout) seconds is reached.

description:
- Timeout when the module should considered that the action has failed
required: false
default: 300
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
default: 300
default: 300
type: int

---
module: pacemaker_resource
short_description: Manage a pacemaker resource
extends_documentation_fragment: openstack
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Manage a pacemaker resource from Ansible
- Manage a pacemaker resource from Ansible.

options:
state:
description:
- Indicate desired state of the cluster
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Indicate desired state of the cluster
- Indicate the desired state of the cluster.

required: true
resource:
description:
- Specify which resource you want to handle
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- 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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- "python >= 2.6"
- "python >= 2.7"

'''

RETURN = '''

Copy link
Member

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
Copy link
Member

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
Copy link
Member

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 -*-
Copy link
Member

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?

@ansibullbot ansibullbot added backport bug This issue/PR relates to a bug module module needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR new_module New module new_plugin New plugin stale_ci CI is older than 7 days, rerun before merging labels Apr 9, 2020
@ansibullbot
Copy link
Collaborator

The test ansible-test sanity --test ansible-doc [explain] failed with the error:

Output on stderr from ansible-doc is considered an error.

Command "ansible-doc -t module community.general.pacemaker_resource" returned exit status 0.
>>> Standard Error
[WARNING]: module community.general.pacemaker_resource not found in:
/dev/null:/root/ansible/lib/ansible/modules

click here for bot help

@@ -0,0 +1,153 @@
#!/usr/bin/python
Copy link
Contributor

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

@gundalow gundalow added the ci_verified Push fixes to PR branch to re-run CI label Apr 18, 2020
@gundalow
Copy link
Contributor

@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 #ansible-devel on Freenode

@gundalow gundalow added the pr_day Has been reviewed during a PR review Day. https://github.com/ansible/community/issues/407 label Jun 17, 2020
@felixfontein felixfontein changed the base branch from master to main July 6, 2020 06:54
@Andersson007
Copy link
Contributor

@matbu any updates on this?
needs_info

@ansibullbot ansibullbot added needs_info This issue requires further information. Please answer any outstanding questions new_contributor Help guide this first time contributor labels Oct 16, 2020
amenzhinsky pushed a commit to amenzhinsky/community.general that referenced this pull request Nov 13, 2020
* Update README and add CHANGELOG

* Prepare changelog for version 0.2.0
@gundalow
Copy link
Contributor

gundalow commented Dec 1, 2020

@matbu Hi, is there anything we can do to help you with this PR for adding a new pacemaker_resource Ansible module for managing cluster resources

@ansibullbot
Copy link
Collaborator

@matbu This pullrequest is waiting for your response. Please respond or the pullrequest will be closed.

click here for bot help

@felixfontein felixfontein removed the bug This issue/PR relates to a bug label Dec 20, 2020
@felixfontein
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci_verified Push fixes to PR branch to re-run CI module module needs_info This issue requires further information. Please answer any outstanding questions needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR new_contributor Help guide this first time contributor new_module New module new_plugin New plugin pr_day Has been reviewed during a PR review Day. https://github.com/ansible/community/issues/407 stale_ci CI is older than 7 days, rerun before merging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants