diff options
author | Guilhem Moulin <guilhem@fripost.org> | 2017-07-29 13:45:26 +0200 |
---|---|---|
committer | Guilhem Moulin <guilhem@fripost.org> | 2017-07-29 13:45:32 +0200 |
commit | d8d07afe49e69114f8deb807031bec71a327d3ae (patch) | |
tree | f607b4446a7a8d68dc7137230ca9a515a1bac519 /lib/modules/mysql_user2 | |
parent | d0294df197362ee61a65f0b5931b4e760c1efc2c (diff) |
Use MariaDB as default MySQL flavor.
Diffstat (limited to 'lib/modules/mysql_user2')
-rw-r--r-- | lib/modules/mysql_user2 | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/lib/modules/mysql_user2 b/lib/modules/mysql_user2 index d10e3e0..4188e8c 100644 --- a/lib/modules/mysql_user2 +++ b/lib/modules/mysql_user2 @@ -151,17 +151,18 @@ def user_exists(cursor, user, host): count = cursor.fetchone() return count[0] > 0 -def load_plugin(cursor, plugin): - cursor.execute("SELECT count(*) FROM information_schema.plugins WHERE name = %s", plugin) +def load_plugin(cursor, plugin, soname): + cursor.execute("SELECT count(*) FROM information_schema.plugins WHERE plugin_name = %s", plugin) count = cursor.fetchone() if count[0] == 0: - so = "%s.so" % plugin - cursor.execute("INSTALL PLUGIN %s SONAME %s", (plugin, so)) + if soname is None: + module.fail_json(msg="missing plugin 'soname' parameter") + cursor.execute("INSTALL PLUGIN %s SONAME %s", (plugin, soname)) -def user_add(cursor, user, host, password, new_priv, auth_plugin): +def user_add(cursor, user, host, password, new_priv, auth_plugin, soname): if password is None: # Automatically loaded on first first use. - load_plugin(cursor, auth_plugin) + load_plugin(cursor, auth_plugin, soname) cursor.execute("CREATE USER %s@%s IDENTIFIED WITH %s", (user,host,auth_plugin)) else: cursor.execute("CREATE USER %s@%s IDENTIFIED BY %s", (user,host,password)) @@ -422,7 +423,8 @@ def main(): priv=dict(default=None), append_privs=dict(type="bool", default="no"), check_implicit_admin=dict(default=False), - auth_plugin=dict(default=None) + auth_plugin=dict(default=None), + soname=dict(default=None) ) ) user = module.params["user"] @@ -433,6 +435,7 @@ def main(): 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") @@ -478,7 +481,7 @@ def main(): else: if (password is None and auth_plugin is None) or (password is not None and auth_plugin is not None): module.fail_json(msg="password xor auth_plugin is required when adding a user") - changed = user_add(cursor, user, host, password, priv, auth_plugin) + changed = user_add(cursor, user, host, password, priv, auth_plugin, soname) elif state == "absent": if user_exists(cursor, user, host): changed = user_delete(cursor, user, host) |