carpenoctem

Untitled

Nov 11th, 2011
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. # Perform hardening equivalent to mysql_secure_installation command.
  2. class mysql::secure_installation {
  3. # Set root password
  4. exec { "mysql_root_password":
  5. unless => "/usr/bin/mysqladmin -uroot -p${mysql_password} status",
  6. command => "/usr/bin/mysqladmin -uroot password $mysql_password",
  7. require => Class["mysql::service"],
  8. notify => Exec["mysql_remove_remote"],
  9. }
  10. # Remove remote root
  11. exec { "mysql_remove_remote":
  12. command => "/usr/bin/mysql -uroot -p${mysql_password} -e \"DELETE FROM mysql.user WHERE User='root' AND Host!='localhost';\"",
  13. refreshonly => true,
  14. notify => Exec["mysql_remove_anonymous"],
  15. }
  16. # Remove anonymous user
  17. exec { "mysql_remove_anonymous":
  18. command => "/usr/bin/mysql -uroot -p${mysql_password} -e \"DELETE FROM mysql.user WHERE User=''\"",
  19. refreshonly => true,
  20. notify => Exec["mysql_remove_test"],
  21. }
  22. # Remove test database and associated privileges
  23. exec { "mysql_remove_test":
  24. 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\\_%'\";
  25. refreshonly => true,
  26. }
  27. }
  28.  
  29. class mysql {
  30. $mysql_password = "test"
  31. include mysql::install, mysql::config, mysql::service, mysql::secure_installation
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment