Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F12239028
init.sls
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
init.sls
View Options
# -------------------------------------------------------------
# Salt — Database server — MySQL
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Project: Nasqueron
# Pillar: dbserver_mysql (in pillar/dbserver)
# License: Trivial work, not eligible to copyright
# If eligible, licensed under BSD-2-Clause
# -------------------------------------------------------------
{%
set
users
=
salt
[
'pillar.get'
](
"dbserver_mysql:users"
,
{})
%}
{%
set
databases
=
salt
[
'pillar.get'
](
"dbserver_mysql:databases"
,
{})
%}
# -------------------------------------------------------------
# Users
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{%
for
username
,
args
in
users.items
()
%}
dbserver_mysql_user_
{{
username
}}
:
mysql_user.present
:
-
name
:
{{
username
}}
-
host
:
{{
args
[
"host"
]
|
yaml_dquote
}}
-
password
:
{{
salt
[
"credentials.get_password"
](
args
[
"password"
])
}}
{%
endfor
%}
# -------------------------------------------------------------
# Databases
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{%
for
db_name
,
args
in
databases.items
()
%}
dbserver_mysql_db_
{{
db_name
}}
:
mysql_database.present
:
-
name
:
{{
db_name
}}
{%
if
"encoding"
in
args
%}
-
character_set
:
{{
args
[
"encoding"
]
}}
{%
endif
%}
{%
if
"collation"
in
args
%}
-
collate
:
{{
args
[
"collation"
]
}}
{%
endif
%}
{%
endfor
%}
# -------------------------------------------------------------
# Privileges
#
# Scopes supported:
# - database (alias for GRANT ALL PRIVILEGES on <db>.* TO ...)
# - table (GRANT ... on <db>.<table> TO ...)
#
# The state module mysql_grants uses the value database for the ON clause:
# `GRANT ... ON <database> TO ...`
#
# The "database" field should so be read as "priv_level"
# according https://mariadb.com/kb/en/grant/#syntax name.
#
# Please note using "database" instead or "privilege_level"
# isn't considered as a best practice. We understand to use
# directly mysql_grants simplifies the module configuration,
# and as such this may be necessary for compatibility, but
# we encourage a more precise terminology.
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{%
for
username
,
user_args
in
users.items
()
%}
{%
for
privilege
in
user_args.get
(
"privileges"
,
[])
%}
{%
set
idx
=
loop
.index
%}
{%
if
privilege
[
"scope"
]
==
"database"
%}
dbserver_mysql_user_
{{
username
}}
_privilege_
{{
idx
}}
_
{{
privilege
[
"database"
]
}}
:
mysql_grants.present
:
-
grant
:
all privileges
-
database
:
{{
privilege
[
"database"
]
}}
.*
-
user
:
{{
username
}}
-
host
:
{{
user_args
[
"host"
]
|
yaml_dquote
}}
-
require
:
-
dbserver_mysql_user_
{{
username
}}
{%
if
"%"
not
in
privilege
[
"database"
]
%}
-
dbserver_mysql_db_
{{
privilege
[
"database"
]
}}
{%
endif
%}
{%
endif
%}
{%
if
privilege
[
"scope"
]
==
"table"
%}
{%
for
table
in
privilege
[
"tables"
]
%}
dbserver_mysql_user_
{{
username
}}
_privilege_
{{
idx
}}
_
{{
table
}}
:
mysql_grants.present
:
-
grant
:
{{
privilege
[
"privileges"
]
}}
-
database
:
{{
privilege
[
"database"
]
}}
.
{{
table
}}
-
user
:
{{
username
}}
-
host
:
{{
user_args
[
"host"
]
|
yaml_dquote
}}
-
require
:
-
dbserver_mysql_user_
{{
username
}}
-
dbserver_mysql_db_
{{
privilege
[
"database"
]
}}
{%
endfor
%}
{%
endif
%}
{%
endfor
%}
{%
endfor
%}
File Metadata
Details
Attached
Mime Type
text/html
Expires
Sat, Oct 11, 20:05 (2 h, 45 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3063883
Default Alt Text
init.sls (3 KB)
Attached To
Mode
rOPS Nasqueron Operations
Attached
Detach File
Event Timeline
Log In to Comment