mirror of
https://github.com/ansible-collections/community.mysql.git
synced 2025-04-17 07:51:26 -07:00
revert changes to get_grants()
This commit is contained in:
parent
3d99d94193
commit
7f2f141275
2 changed files with 8 additions and 14 deletions
|
@ -104,19 +104,13 @@ def get_tls_requires(cursor, user, host):
|
||||||
return requires or None
|
return requires or None
|
||||||
|
|
||||||
|
|
||||||
def get_grants(module, cursor, user, host):
|
def get_grants(cursor, user, host):
|
||||||
cursor.execute("SHOW GRANTS FOR %s@%s", (user, host))
|
cursor.execute("SHOW GRANTS FOR %s@%s", (user, host))
|
||||||
try:
|
grants_line = list(filter(lambda x: "ON *.*" in x[0], cursor.fetchall()))[0]
|
||||||
c = cursor.fetchall()
|
|
||||||
# grants_line = list(filter(lambda x: "ON *.*" in x[0], cursor.fetchall()))[0]
|
|
||||||
module.warn("%s" % c)
|
|
||||||
except Exception as e:
|
|
||||||
module.fail_json(msg="Error %s" % e)
|
|
||||||
|
|
||||||
# pattern = r"(?<=\bGRANT\b)(.*?)(?=(?:\bON\b))"
|
pattern = r"(?<=\bGRANT\b)(.*?)(?=(?:\bON\b))"
|
||||||
# grants = re.search(pattern, grants_line[0]).group().strip()
|
grants = re.search(pattern, grants_line[0]).group().strip()
|
||||||
# return grants.split(", ")
|
return grants.split(", ")
|
||||||
return "test"
|
|
||||||
|
|
||||||
|
|
||||||
def get_existing_authentication(cursor, user):
|
def get_existing_authentication(cursor, user):
|
||||||
|
@ -139,7 +133,7 @@ def get_existing_authentication(cursor, user):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def user_add(module, cursor, user, host, host_all, password, encrypted,
|
def user_add(cursor, user, host, host_all, password, encrypted,
|
||||||
plugin, plugin_hash_string, plugin_auth_string, new_priv,
|
plugin, plugin_hash_string, plugin_auth_string, new_priv,
|
||||||
tls_requires, check_mode, reuse_existing_password):
|
tls_requires, check_mode, reuse_existing_password):
|
||||||
# we cannot create users without a proper hostname
|
# we cannot create users without a proper hostname
|
||||||
|
@ -194,7 +188,7 @@ def user_add(module, cursor, user, host, host_all, password, encrypted,
|
||||||
for db_table, priv in iteritems(new_priv):
|
for db_table, priv in iteritems(new_priv):
|
||||||
privileges_grant(cursor, user, host, db_table, priv, tls_requires)
|
privileges_grant(cursor, user, host, db_table, priv, tls_requires)
|
||||||
if tls_requires is not None:
|
if tls_requires is not None:
|
||||||
privileges_grant(cursor, user, host, "*.*", get_grants(module, cursor, user, host), tls_requires)
|
privileges_grant(cursor, user, host, "*.*", get_grants(cursor, user, host), tls_requires)
|
||||||
return {'changed': True, 'password_changed': not used_existing_password}
|
return {'changed': True, 'password_changed': not used_existing_password}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -525,7 +525,7 @@ def main():
|
||||||
if subtract_privs:
|
if subtract_privs:
|
||||||
priv = None # avoid granting unwanted privileges
|
priv = None # avoid granting unwanted privileges
|
||||||
reuse_existing_password = update_password == 'on_new_username'
|
reuse_existing_password = update_password == 'on_new_username'
|
||||||
result = user_add(module, cursor, user, host, host_all, password, encrypted,
|
result = user_add(cursor, user, host, host_all, password, encrypted,
|
||||||
plugin, plugin_hash_string, plugin_auth_string,
|
plugin, plugin_hash_string, plugin_auth_string,
|
||||||
priv, tls_requires, module.check_mode, reuse_existing_password)
|
priv, tls_requires, module.check_mode, reuse_existing_password)
|
||||||
changed = result['changed']
|
changed = result['changed']
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue