summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2020-01-22 02:06:21 +0100
committerGuilhem Moulin <guilhem@fripost.org>2020-01-22 02:06:23 +0100
commiteb0a0a822328e8563ed8af67e4e9cd573d93b31a (patch)
treeabfdb08e8ac9ec4d1af64b25c095b6a48eecd7a4
parentdfc1467c9ccb0e8427c647faa50ca92a01f5d6d6 (diff)
mysql_user2: Explicitly set type to Bool.
This avoids the [WARNING]: The value False (type bool) in a string field was converted to u'False' (type string). If this does not look like what you expect, quote the entire value to ensure it does not change.
-rw-r--r--lib/modules/mysql_user25
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/modules/mysql_user2 b/lib/modules/mysql_user2
index 20742fe..dc9a69e 100644
--- a/lib/modules/mysql_user2
+++ b/lib/modules/mysql_user2
@@ -74,41 +74,42 @@ options:
default: null
append_privs:
description:
- Append the privileges defined by priv to the existing ones for this
user instead of overwriting existing ones.
required: false
choices: [ "yes", "no" ]
default: "no"
version_added: "1.4"
state:
description:
- Whether the user should exist. When C(absent), removes
the user.
required: false
default: present
choices: [ "present", "absent" ]
check_implicit_admin:
description:
- Check if mysql allows login as root/nopassword before trying supplied credentials.
required: false
- default: false
+ type: bool
+ default: no
version_added: "1.3"
notes:
- Requires the MySQLdb Python package on the remote host. For Ubuntu, this
is as easy as apt-get install python-mysqldb.
- Both C(login_password) and C(login_username) are required when you are
passing credentials. If none are present, the module will attempt to read
the credentials from C(~/.my.cnf), and finally fall back to using the MySQL
default login of 'root' with no password.
- "MySQL server installs with default login_user of 'root' and no password. To secure this user
as part of an idempotent playbook, you must create at least two tasks: the first must change the root user's password,
without providing any login_user/login_password details. The second must drop a ~/.my.cnf file containing
the new root credentials. Subsequent runs of the playbook will then succeed by reading the new credentials from
the file."
requirements: [ "ConfigParser", "MySQLdb" ]
author: Mark Theunissen
'''
EXAMPLES = """
# Create database user with name 'bob' and password '12345' with all database privileges
@@ -405,41 +406,41 @@ def connect(module, login_user, login_password):
return db_connection.cursor()
# ===========================================
# Module execution.
#
def main():
module = AnsibleModule(
argument_spec = dict(
login_user=dict(default=None),
login_password=dict(default=None, no_log=True),
login_host=dict(default="localhost"),
login_port=dict(default=3306, type='int'),
login_unix_socket=dict(default=None),
user=dict(required=True, aliases=['name']),
password=dict(default=None, no_log=True, type='str'),
host=dict(default="localhost"),
state=dict(default="present", choices=["absent", "present"]),
priv=dict(default=None),
append_privs=dict(default=False, type="bool"),
- check_implicit_admin=dict(default=False),
+ check_implicit_admin=dict(default=False, type="bool"),
auth_plugin=dict(default=None),
soname=dict(default=None)
)
)
user = module.params["user"]
password = module.params["password"]
host = module.params["host"]
state = module.params["state"]
priv = module.params["priv"]
check_implicit_admin = module.params['check_implicit_admin']
append_privs = module.boolean(module.params["append_privs"])
auth_plugin = module.params['auth_plugin']
soname = module.params['soname']
if not mysqldb_found:
module.fail_json(msg="the python mysqldb module is required")
if priv is not None:
try:
priv = privileges_unpack(priv)