Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Perform hardening equivalent to mysql_secure_installation command.
- class mysql::secure_installation {
- # Set root password
- exec { "mysql_root_password":
- unless => "/usr/bin/mysqladmin -uroot -p${mysql_password} status",
- command => "/usr/bin/mysqladmin -uroot password $mysql_password",
- require => Class["mysql::service"],
- notify => Exec["mysql_remove_remote"],
- }
- # Remove remote root
- exec { "mysql_remove_remote":
- command => "/usr/bin/mysql -uroot -p${mysql_password} -e \"DELETE FROM mysql.user WHERE User='root' AND Host!='localhost';\"",
- refreshonly => true,
- notify => Exec["mysql_remove_anonymous"],
- }
- # Remove anonymous user
- exec { "mysql_remove_anonymous":
- command => "/usr/bin/mysql -uroot -p${mysql_password} -e \"DELETE FROM mysql.user WHERE User=''\"",
- refreshonly => true,
- notify => Exec["mysql_remove_test"],
- }
- # Remove test database and associated privileges
- exec { "mysql_remove_test":
- command => "/usr/bin/mysql -uroot -p${mysql_password} -e \"DROP DATABASE test\"; /usr/bin/mysql -uroot -p${mysql_password} -e \"DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%'\";
- refreshonly => true,
- }
- }
- class mysql {
- $mysql_password = "test"
- include mysql::install, mysql::config, mysql::service, mysql::secure_installation
- }
Advertisement
Add Comment
Please, Sign In to add comment