Skip to content

Commit bbee1cc

Browse files
committed
Add user tls_options and grant options to mysql::db
1 parent 346f70e commit bbee1cc

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,12 @@ The user for the database you're creating.
10111011

10121012
The password for $user for the database you're creating.
10131013

1014+
##### `tls_options`
1015+
1016+
The tls_options for $user for the database you're creating.
1017+
1018+
Defaults to `undef`.
1019+
10141020
##### `dbname`
10151021

10161022
The name of the database to create.
@@ -1041,6 +1047,12 @@ The privileges to be granted for user@host on the database.
10411047

10421048
Defaults to 'ALL'.
10431049

1050+
##### `grant_options`
1051+
1052+
The grant_options for the grant for user@host on the database.
1053+
1054+
Defaults to `undef`.
1055+
10441056
##### `sql`
10451057

10461058
The path to the sqlfile you want to execute. This can be single file specified as string, or it can be an array of strings.

manifests/db.pp

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,20 @@
22
define mysql::db (
33
$user,
44
$password,
5+
$tls_options = undef,
56
$dbname = $name,
67
$charset = 'utf8',
78
$collate = 'utf8_general_ci',
89
$host = 'localhost',
910
$grant = 'ALL',
11+
$grant_options = undef,
1012
Optional[Variant[Array, Hash, String]] $sql = undef,
1113
$enforce_sql = false,
1214
Enum['absent', 'present'] $ensure = 'present',
1315
$import_timeout = 300,
1416
$import_cat_cmd = 'cat',
1517
) {
16-
#input validation
18+
1719
$table = "${dbname}.*"
1820

1921
$sql_inputs = join([$sql], ' ')
@@ -32,6 +34,7 @@
3234
$user_resource = {
3335
ensure => $ensure,
3436
password_hash => mysql_password($password),
37+
tls_options => $tls_options,
3538
}
3639
ensure_resource('mysql_user', "${user}@${host}", $user_resource)
3740

@@ -41,6 +44,7 @@
4144
provider => 'mysql',
4245
user => "${user}@${host}",
4346
table => $table,
47+
options => $grant_options,
4448
require => [
4549
Mysql_database[$dbname],
4650
Mysql_user["${user}@${host}"],

spec/defines/mysql_db_spec.rb

+10
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,16 @@
7070
params['dbname'] = 'real_db'
7171
is_expected.to contain_mysql_database('real_db')
7272
end
73+
74+
it 'uses tls_options for user when set' do
75+
params['tls_options'] = ['SSL']
76+
is_expected.to contain_mysql_user('testuser@localhost').with_tls_options(['SSL'])
77+
end
78+
79+
it 'uses grant_options for grant when set' do
80+
params['grant_options'] = ['GRANT']
81+
is_expected.to contain_mysql_grant('testuser@localhost/test_db.*').with_grant_options(['GRANT'])
82+
end
7383
end
7484
end
7585
end

0 commit comments

Comments
 (0)