Add couchdb_user module #222

Open
wants to merge 14 commits into
from

Projects

None yet

8 participants

@mmoya
Contributor
mmoya commented Jan 23, 2015

Add module for handling CouchDB users.

@bcoca bcoca added this to the next milestone Feb 26, 2015
@jimi-c jimi-c added P2 and removed P3 labels Mar 6, 2015
@bcoca bcoca removed this from the next milestone Mar 19, 2015
@bcoca bcoca removed the P2 label Mar 19, 2015
@gregdek
Contributor
gregdek commented Jun 17, 2015

Thanks for submitting this module to Ansible Extras. Apologies that it’s taken a while to get your module reviewed.

To help facilitate reviews, we’ve broadened the number of people who can approve modules for inclusion into the Extras repository. The list of official reviewers can be found here:

https://github.com/ansible/ansible-modules-extras/blob/devel/REVIEWERS.md

Our new policy is that if a new module is reviewed and approved by at least two official module reviewers, the module will be approved for inclusion. We will be asking the community of reviewers to take a look at these modules on a regular basis.

To ensure that your module has the best chance of being approved, please double-check that you adhere to the Ansible module guidelines: http://docs.ansible.com/developing_modules.html#module-checklist

@robynbergeron
Contributor

Adding new process. We will be evaluating all new module PRs according to this process, effective immediately.

Thanks for submitting this new module to Ansible Extras! This module is now in community review, a process that is open to all Ansible users. In order for this module to be approved, it must gain the following votes:

“works_for_me”: If you have tested the module thoroughly, including testing of all of the module’s options, and if the module works for you, please add “works_for_me” in the comments.

“passes_guidelines”: If you have gone through the module guidelines and the module meets all of the requirements, please add “passes_guidelines” in the comments. Guidelines are available here: http://docs.ansible.com/developing_modules.html#module-checklist

“needs_revision”: If the module fails to work for you, or if it doesn’t meet guidelines, please add “needs_revision” in the comments with details about what needs to be fixed.

When a module has both “works_for_me” and “passes_guidelines” tags, we will promote the module for inclusion in Ansible Extras. At this point, you will be expected to maintain the module by fixing bugs and evaluating pull requests in a timely manner.

Thanks again for submitting your Ansible module!

@resmo resmo commented on an outdated diff Mar 18, 2016
database/misc/couchdb_user
+
+# ===========================================
+# Module execution.
+#
+
+
+def main():
+ module = AnsibleModule(
+ argument_spec=dict(
+ login_user=dict(default=None),
+ login_password=dict(default=None),
+ login_host=dict(default="localhost"),
+ login_port=dict(default="5984"),
+
+ name=dict(required=True, aliases=['username']),
+ password=dict(required=False),
@resmo
resmo Mar 18, 2016 Contributor

please add no_log=True to secrets to make sure they won't be logged.

@resmo resmo commented on an outdated diff Mar 18, 2016
database/misc/couchdb_user
+ if type(salt) == unicode:
+ salt = salt.encode('utf-8')
+ hashed = pbkdf2(plaintext, salt, rounds)
+ return hexlify(hashed) == hash_
+
+
+# ===========================================
+# Module execution.
+#
+
+
+def main():
+ module = AnsibleModule(
+ argument_spec=dict(
+ login_user=dict(default=None),
+ login_password=dict(default=None),
@resmo
resmo Mar 18, 2016 Contributor

please add no_log=True to secrets to make sure they won't be logged.

@resmo resmo commented on an outdated diff Mar 18, 2016
database/misc/couchdb_user
+ them.
+requirements: [ passlib, requests ]
+author: Maykel Moya
+'''
+
+
+EXAMPLES = '''
+# Create a new user with name 'bob'
+- couchdb_user: name=bob password=bar state=present
+
+'''
+
+
+from binascii import hexlify
+from passlib.utils.pbkdf2 import pbkdf2
+import requests
@resmo
resmo Mar 18, 2016 Contributor

There is a fetch_url helper for interaction with URL which doesn't depend on request (also for other methods as GET). https://github.com/ansible/ansible/blob/devel/lib/ansible/module_utils/urls.py.

If this is an option for you, since users may don't have requests installed.

@resmo resmo commented on an outdated diff Mar 18, 2016
database/misc/couchdb_user
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+
+DOCUMENTATION = '''
+---
+module: couchdb_user
+short_description: Add or remove CouchDB users.
+description:
+ - Add or remove CouchDB users from a remote host.
+version_added: "0.x"
@resmo
resmo Mar 18, 2016 Contributor

you can set it to "2.1" for now, if you work with me, we will be able to merge it :)

@resmo resmo commented on an outdated diff Mar 18, 2016
database/misc/couchdb_user
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+
+DOCUMENTATION = '''
+---
+module: couchdb_user
+short_description: Add or remove CouchDB users.
+description:
+ - Add or remove CouchDB users from a remote host.
+version_added: "0.x"
+options:
+ name:
+ description:
+ - name of the user to add or remove
+ required: true
+ default: null
@resmo
resmo Mar 18, 2016 Contributor

default: null should be removed if required: true (since you want user input, so there is no default)

@resmo resmo commented on an outdated diff Mar 18, 2016
database/misc/couchdb_user
+DOCUMENTATION = '''
+---
+module: couchdb_user
+short_description: Add or remove CouchDB users.
+description:
+ - Add or remove CouchDB users from a remote host.
+version_added: "0.x"
+options:
+ name:
+ description:
+ - name of the user to add or remove
+ required: true
+ default: null
+ password:
+ description:
+ - password of the user
@resmo
resmo Mar 18, 2016 Contributor

always add required: <true|false> if its false, also add a default e.g. default: null

@resmo resmo commented on an outdated diff Mar 18, 2016
database/misc/couchdb_user
+short_description: Add or remove CouchDB users.
+description:
+ - Add or remove CouchDB users from a remote host.
+version_added: "0.x"
+options:
+ name:
+ description:
+ - name of the user to add or remove
+ required: true
+ default: null
+ password:
+ description:
+ - password of the user
+ roles:
+ description
+ - list of roles of the user
@resmo
resmo Mar 18, 2016 Contributor

always add required: <true|false> if its false, also add a default e.g. default: null

@resmo resmo commented on an outdated diff Mar 18, 2016
database/misc/couchdb_user
+
+ login_password = module.params['login_password']
+ login_user = module.params['login_user']
+
+ host = (
+ module.params['login_host'],
+ module.params['login_port']
+ )
+
+ credentials = (
+ login_user,
+ login_password
+ )
+
+ if any(credentials):
+ if not all(credentials):
@resmo
resmo Mar 18, 2016 Contributor

Its ok but I wanted to let you know there is a helper for arguments required together here https://github.com/ansible/ansible/blob/devel/lib/ansible/module_utils/basic.py#L512 e.g. look for required_together= in other modules how to use it if you like

@resmo resmo commented on an outdated diff Mar 18, 2016
database/misc/couchdb_user
+ hashed = pbkdf2(plaintext, salt, rounds)
+ return hexlify(hashed) == hash_
+
+
+# ===========================================
+# Module execution.
+#
+
+
+def main():
+ module = AnsibleModule(
+ argument_spec=dict(
+ login_user=dict(default=None),
+ login_password=dict(default=None),
+ login_host=dict(default="localhost"),
+ login_port=dict(default="5984"),
@resmo
resmo Mar 18, 2016 Contributor

considering type='int' and default=5984

@sivel
Member
sivel commented Mar 18, 2016
============================================================================
couchdb_user
============================================================================
ERROR: Official Ansible modules must have a .py extension for python modules or a .ps1 for powershell modules
ERROR: DOCUMENTATION.options.roles: expected a dictionary
ERROR: version_added is not a valid version number: '0.x'
ERROR: No RETURN documentation provided
ERROR: requests import found, should use ansible.module_utils.urls instead
@gregdek
Contributor
gregdek commented Mar 21, 2016

@mmoya A friendly reminder: this pull request has been marked as needing your action. If you still believe that this PR applies, and you intend to address the issues with this PR, just let us know in the PR itself and we will keep it open pending your changes.

@mmoya
Contributor
mmoya commented Mar 31, 2016

Thanks everybody for the review. I'll address all the issues.

@gregdek
Contributor
gregdek commented Apr 6, 2016

@mmoya Another friendly reminder: this pull request has been marked as needing your action. If you still believe that this PR applies, and you intend to address the issues with this PR, just let us know in the PR itself and we will keep it open. If we don't hear from you within another 14 days, we will close this pull request.

[This message brought to you by your friendly Ansibull-bot.]

@gregdek
Contributor
gregdek commented Apr 21, 2016

@mmoya A friendly reminder: this pull request has been marked as needing your action. If you still believe that this PR applies, and you intend to address the issues with this PR, just let us know in the PR itself and we will keep it open pending your changes. When you do address the issues, please respond with ready_for_review in your comment, so that we can notify the maintainer.

[This message brought to you by your friendly Ansibull-bot.]

@gregdek
Contributor
gregdek commented May 7, 2016

@mmoya Another friendly reminder: this pull request has been marked as needing your action. If you still believe that this PR applies, and you intend to address the issues with this PR, just let us know in the PR itself and we will keep it open. If you have addressed the issues and believe it's ready for review, please comment with the text "ready_for_review". If we don't hear from you within another 14 days, we will close this pull request.

[This message brought to you by your friendly Ansibull-bot.]

@gregdek
Contributor
gregdek commented May 22, 2016

@mmoya A friendly reminder: this pull request has been marked as needing your action. If you still believe that this PR applies, and you intend to address the issues with this PR, just let us know in the PR itself and we will keep it open pending your changes. When you do address the issues, please respond with ready_for_review in your comment, so that we can notify the maintainer.

[This message brought to you by your friendly Ansibull-bot.]

@mmoya
Contributor
mmoya commented May 24, 2016

Slowly progressing on this.

@mmoya
Contributor
mmoya commented May 26, 2016

I added a lot of commit on top of the original commit for easing review. If this gets merge ready I'll squash everything.

@resmo and @sivel, thanks a lot for the previous review. Ansible has changed a lot since last time I wrote a module.

+ready_for_review

@gregdek
Contributor
gregdek commented May 26, 2016

Thanks @mmoya for this new module. When this module receives 'shipit' comments from two community members and any 'needs_revision' comments have been resolved, we will mark for inclusion.

[This message brought to you by your friendly Ansibull-bot.]

@gregdek gregdek removed the pending_action label Aug 15, 2016
@ansibot
ansibot commented Dec 7, 2016

This repository has been locked. All new issues and pull requests should be filed in https://github.com/ansible/ansible

Please read through the repomerge page in the dev guide. The guide contains links to tools which automatically move your issue or pull request to the ansible/ansible repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment