You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 11, 2019. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+64-18Lines changed: 64 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,20 +25,66 @@ For detailed info about the logic and usage patterns of Example42 modules read R
25
25
* Set a random password ( saved in /root/.my.cnf )
26
26
27
27
class { "mysql":
28
-
root_password => 'auto',
28
+
root_password => 'auto',
29
29
}
30
30
31
-
* Create a new grant and database. mysql_db_init_query_file is optional and will run only once.
31
+
* Create a new grant and database
32
+
33
+
### Create database and manage GRANT
34
+
35
+
The simplest way to create database is the following.
36
+
37
+
mysql::grant { 'db1':
38
+
mysql_username => 'myusername',
39
+
mysql_password => 'mypassword',
40
+
}
41
+
42
+
This will create a MySQL database named 'db1' with a MySQL grant allowing full access to user 'myusername' with 'mypassword' password on local host.
43
+
44
+
#### Customize host source
45
+
If you want to customize the host the new user can connect from you have to use the 'mysql\_host'.
46
+
47
+
mysql::grant { 'db1':
48
+
mysql_username => 'myusername',
49
+
mysql_password => 'mypassword',
50
+
mysql_host => '10.42.42.0/255.255.255.0',
51
+
}
52
+
53
+
Here the whole 10.42.42.0/24 can connect.
54
+
55
+
#### Customize privileges
56
+
For privileges customization there is the 'mysql\_privileges' parameter.
32
57
33
58
mysql::grant { 'db1':
34
-
mysql_privileges => 'ALL',
35
-
mysql_password => 'pwd',
36
-
mysql_db => 'db1',
37
-
mysql_user => 'db1',
38
-
mysql_host => 'host',
59
+
mysql_username => 'myusername',
60
+
mysql_password => 'mypassword',
61
+
mysql_privileges => 'SELECT',
62
+
}
63
+
64
+
The default grant privileges is 'ALL'.
65
+
66
+
#### Remove GRANT
67
+
Like for standard puppet resource you can use the 'ensure' parameter in order to remove a grant.
68
+
69
+
mysql::grant { 'db1':
70
+
ensure => 'absent',
71
+
mysql_username => 'myusername',
72
+
mysql_password => 'mypassword',
73
+
}
74
+
75
+
This will ensure the 'myusername@localhost' grant is absent but not the database.
76
+
77
+
#### Load initial data
78
+
The mysql\_db\_init\_query\_file is an optional parameter allowing to specify a sql file. The execution of this SQL file will be triger only once at the creation time.
0 commit comments