mongodb_user: fix doc formatting (#67763)

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
pull/67852/head
Abhijeet Kasurde 6 years ago committed by GitHub
parent 0cd22abe8c
commit b6c2056ea2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -18,76 +18,94 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
DOCUMENTATION = ''' DOCUMENTATION = '''
--- ---
module: mongodb_user module: mongodb_user
short_description: Adds or removes a user from a MongoDB database. short_description: Adds or removes a user from a MongoDB database
description: description:
- Adds or removes a user from a MongoDB database. - Adds or removes a user from a MongoDB database.
version_added: "1.1" version_added: "1.1"
options: options:
login_user: login_user:
description: description:
- The username used to authenticate with - The MongoDB username used to authenticate with.
type: str
login_password: login_password:
description: description:
- The password used to authenticate with - The login user's password used to authenticate with.
type: str
login_host: login_host:
description: description:
- The host running the database - The host running the database.
default: localhost default: localhost
type: str
login_port: login_port:
description: description:
- The port to connect to - The MongoDB port to connect to.
default: 27017 default: '27017'
type: str
login_database: login_database:
version_added: "2.0" version_added: "2.0"
description: description:
- The database where login credentials are stored - The database where login credentials are stored.
type: str
replica_set: replica_set:
version_added: "1.6" version_added: "1.6"
description: description:
- Replica set to connect to (automatically connects to primary for writes) - Replica set to connect to (automatically connects to primary for writes).
type: str
database: database:
description: description:
- The name of the database to add/remove the user from - The name of the database to add/remove the user from.
required: true required: true
type: str
aliases: [db]
name: name:
description: description:
- The name of the user to add or remove - The name of the user to add or remove.
required: true required: true
aliases: [ 'user' ] aliases: [user]
type: str
password: password:
description: description:
- The password to use for the user - The password to use for the user.
type: str
aliases: [pass]
ssl: ssl:
version_added: "1.8" version_added: "1.8"
description: description:
- Whether to use an SSL connection when connecting to the database - Whether to use an SSL connection when connecting to the database.
type: bool type: bool
ssl_cert_reqs: ssl_cert_reqs:
version_added: "2.2" version_added: "2.2"
description: description:
- Specifies whether a certificate is required from the other side of the connection, and whether it will be validated if provided. - Specifies whether a certificate is required from the other side of the connection,
default: "CERT_REQUIRED" and whether it will be validated if provided.
choices: ["CERT_REQUIRED", "CERT_OPTIONAL", "CERT_NONE"] default: CERT_REQUIRED
choices: [CERT_NONE, CERT_OPTIONAL, CERT_REQUIRED]
type: str
roles: roles:
version_added: "1.3" version_added: "1.3"
type: list
elements: raw
description: description:
- > - >
The database user roles valid values could either be one or more of the following strings: The database user roles valid values could either be one or more of the following strings:
'read', 'readWrite', 'dbAdmin', 'userAdmin', 'clusterAdmin', 'readAnyDatabase', 'readWriteAnyDatabase', 'userAdminAnyDatabase', 'read', 'readWrite', 'dbAdmin', 'userAdmin', 'clusterAdmin', 'readAnyDatabase', 'readWriteAnyDatabase', 'userAdminAnyDatabase',
'dbAdminAnyDatabase' 'dbAdminAnyDatabase'
- "Or the following dictionary '{ db: DATABASE_NAME, role: ROLE_NAME }'." - "Or the following dictionary '{ db: DATABASE_NAME, role: ROLE_NAME }'."
- "This param requires pymongo 2.5+. If it is a string, mongodb 2.4+ is also required. If it is a dictionary, mongo 2.6+ is required." - "This param requires pymongo 2.5+. If it is a string, mongodb 2.4+ is also required. If it is a dictionary, mongo 2.6+ is required."
state: state:
description: description:
- The database user state - The database user state.
default: present default: present
choices: [ "present", "absent" ] choices: [absent, present]
type: str
update_password: update_password:
default: always default: always
choices: ['always', 'on_create'] choices: [always, on_create]
version_added: "2.1" version_added: "2.1"
description: description:
- C(always) will update passwords if they differ. C(on_create) will only set the password for newly created users. - C(always) will update passwords if they differ.
- C(on_create) will only set the password for newly created users.
type: str
notes: notes:
- Requires the pymongo Python package on the remote host, version 2.4.2+. This - Requires the pymongo Python package on the remote host, version 2.4.2+. This
@ -99,49 +117,53 @@ author:
''' '''
EXAMPLES = ''' EXAMPLES = '''
# Create 'burgers' database user with name 'bob' and password '12345'. - name: Create 'burgers' database user with name 'bob' and password '12345'.
- mongodb_user: mongodb_user:
database: burgers database: burgers
name: bob name: bob
password: 12345 password: 12345
state: present state: present
# Create a database user via SSL (MongoDB must be compiled with the SSL option and configured properly) - name: Create a database user via SSL (MongoDB must be compiled with the SSL option and configured properly)
- mongodb_user: mongodb_user:
database: burgers database: burgers
name: bob name: bob
password: 12345 password: 12345
state: present state: present
ssl: True ssl: True
# Delete 'burgers' database user with name 'bob'. - name: Delete 'burgers' database user with name 'bob'.
- mongodb_user: mongodb_user:
database: burgers database: burgers
name: bob name: bob
state: absent state: absent
# Define more users with various specific roles (if not defined, no roles is assigned, and the user will be added via pre mongo 2.2 style) - name: Define more users with various specific roles (if not defined, no roles is assigned, and the user will be added via pre mongo 2.2 style)
- mongodb_user: mongodb_user:
database: burgers database: burgers
name: ben name: ben
password: 12345 password: 12345
roles: read roles: read
state: present state: present
- mongodb_user:
- name: Define roles
mongodb_user:
database: burgers database: burgers
name: jim name: jim
password: 12345 password: 12345
roles: readWrite,dbAdmin,userAdmin roles: readWrite,dbAdmin,userAdmin
state: present state: present
- mongodb_user:
- name: Define roles
mongodb_user:
database: burgers database: burgers
name: joe name: joe
password: 12345 password: 12345
roles: readWriteAnyDatabase roles: readWriteAnyDatabase
state: present state: present
# add a user to database in a replica set, the primary server is automatically discovered and written to - name: Add a user to database in a replica set, the primary server is automatically discovered and written to
- mongodb_user: mongodb_user:
database: burgers database: burgers
name: bob name: bob
replica_set: belcher replica_set: belcher
@ -153,7 +175,8 @@ EXAMPLES = '''
# please notice the credentials must be added to the 'admin' database because the 'local' database is not synchronized and can't receive user credentials # please notice the credentials must be added to the 'admin' database because the 'local' database is not synchronized and can't receive user credentials
# To login with such user, the connection string should be MONGO_OPLOG_URL="mongodb://oplog_reader:oplog_reader_password@server1,server2/local?authSource=admin" # To login with such user, the connection string should be MONGO_OPLOG_URL="mongodb://oplog_reader:oplog_reader_password@server1,server2/local?authSource=admin"
# This syntax requires mongodb 2.6+ and pymongo 2.5+ # This syntax requires mongodb 2.6+ and pymongo 2.5+
- mongodb_user: - name: Roles as a dictionary
mongodb_user:
login_user: root login_user: root
login_password: root_password login_password: root_password
database: admin database: admin
@ -342,7 +365,7 @@ def main():
name=dict(required=True, aliases=['user']), name=dict(required=True, aliases=['user']),
password=dict(aliases=['pass'], no_log=True), password=dict(aliases=['pass'], no_log=True),
ssl=dict(default=False, type='bool'), ssl=dict(default=False, type='bool'),
roles=dict(default=None, type='list'), roles=dict(default=None, type='list', elements='raw'),
state=dict(default='present', choices=['absent', 'present']), state=dict(default='present', choices=['absent', 'present']),
update_password=dict(default="always", choices=["always", "on_create"]), update_password=dict(default="always", choices=["always", "on_create"]),
ssl_cert_reqs=dict(default='CERT_REQUIRED', choices=['CERT_NONE', 'CERT_OPTIONAL', 'CERT_REQUIRED']), ssl_cert_reqs=dict(default='CERT_REQUIRED', choices=['CERT_NONE', 'CERT_OPTIONAL', 'CERT_REQUIRED']),

@ -1625,7 +1625,7 @@ class ModuleValidator(Validator):
msg = "Argument '%s' in argument_spec" % arg msg = "Argument '%s' in argument_spec" % arg
if context: if context:
msg += " found in %s" % " -> ".join(context) msg += " found in %s" % " -> ".join(context)
msg += "implies type as 'str' but documentation defines as %r" % doc_type msg += " implies type as 'str' but documentation defines as %r" % doc_type
self.reporter.error( self.reporter.error(
path=self.object_path, path=self.object_path,
code='implied-parameter-type-mismatch', code='implied-parameter-type-mismatch',

@ -2804,10 +2804,6 @@ lib/ansible/modules/database/mongodb/mongodb_parameter.py use-argspec-type-path
lib/ansible/modules/database/mongodb/mongodb_replicaset.py use-argspec-type-path lib/ansible/modules/database/mongodb/mongodb_replicaset.py use-argspec-type-path
lib/ansible/modules/database/mongodb/mongodb_shard.py use-argspec-type-path lib/ansible/modules/database/mongodb/mongodb_shard.py use-argspec-type-path
lib/ansible/modules/database/mongodb/mongodb_user.py use-argspec-type-path lib/ansible/modules/database/mongodb/mongodb_user.py use-argspec-type-path
lib/ansible/modules/database/mongodb/mongodb_user.py validate-modules:doc-missing-type
lib/ansible/modules/database/mongodb/mongodb_user.py validate-modules:parameter-list-no-elements
lib/ansible/modules/database/mongodb/mongodb_user.py validate-modules:parameter-type-not-in-doc
lib/ansible/modules/database/mongodb/mongodb_user.py validate-modules:undocumented-parameter
lib/ansible/modules/database/mssql/mssql_db.py validate-modules:doc-missing-type lib/ansible/modules/database/mssql/mssql_db.py validate-modules:doc-missing-type
lib/ansible/modules/database/mssql/mssql_db.py validate-modules:doc-required-mismatch lib/ansible/modules/database/mssql/mssql_db.py validate-modules:doc-required-mismatch
lib/ansible/modules/database/mysql/mysql_db.py validate-modules:doc-elements-mismatch lib/ansible/modules/database/mysql/mysql_db.py validate-modules:doc-elements-mismatch

Loading…
Cancel
Save