wip
This commit is contained in:
parent
d6b109da01
commit
695bfb5dde
1 changed files with 11 additions and 2 deletions
|
@ -1,7 +1,8 @@
|
||||||
from shlex import quote
|
from shlex import quote
|
||||||
|
|
||||||
def mariadb(sql):
|
def mariadb(sql, **kwargs):
|
||||||
return f"mariadb -Bsr --execute {quote(sql)}"
|
kwargs_string = ''.join(f" --{k} {v}" for k, v in kwargs.items())
|
||||||
|
return f"mariadb{kwargs_string} -Bsr --execute {quote(sql)}"
|
||||||
|
|
||||||
directories = {
|
directories = {
|
||||||
'/var/lib/mysql': {
|
'/var/lib/mysql': {
|
||||||
|
@ -56,3 +57,11 @@ for db, conf in node.metadata.get('mariadb/databases', {}).items():
|
||||||
f'action:mariadb_user_{db}_create',
|
f'action:mariadb_user_{db}_create',
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
print(mariadb(f"SHOW GRANTS FOR {db}") + f"grep -q '^GRANT ALL PRIVILEGES'")
|
||||||
|
actions[f'mariadb_grant_privileges_to_{db}'] = {
|
||||||
|
'command': mariadb(f"GRANT ALL PRIVILEGES ON *.* TO '{db}'", database=db),
|
||||||
|
'unless': mariadb(f"SHOW GRANTS FOR {db}") + f" | grep -q '^GRANT USAGE ON *.* TO `{db}`'",
|
||||||
|
'needs': [
|
||||||
|
f'action:mariadb_user_{db}_create',
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue