Guest User

Untitled

a guest
Oct 29th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. ## dbinstances.pp
  2. # Class: sites::dbinstances
  3. #
  4. #
  5. class sites::dbinstances {
  6. #include mysql::config
  7. $mysql_password = "bdfsdfsdf^a"
  8.  
  9. define db( $user, $password ) {
  10. exec { "create-${name}-db":
  11. unless => "/usr/bin/mysql -uroot ${name}",
  12. command => "/usr/bin/mysql -uroot -e \"create database ${name};\"",
  13. require => Service["mysql"],
  14. }
  15. if ($environment != "prod") {
  16. exec { "grant-${name}-db":
  17. unless => "/usr/bin/mysql -u${user} -p${password} ${name}",
  18. command => "/usr/bin/mysql -uroot -e \"grant all privileges on ${name}.* to ${user}@'stage-web%' identified by '$password';\"",
  19. require => [Service["mysql"], Exec["create-${name}-db"]]
  20. }
  21. } else {
  22. exec { "grant-${name}-db":
  23. unless => "/usr/bin/mysql -u${user} -p${password} ${name}",
  24. command => "/usr/bin/mysql -uroot -e \"grant all privileges on ${name}.* to ${user}@'prod-web%' identified by '$password';\"",
  25. require => [Service["mysql"], Exec["create-${name}-db"]]
  26. }
  27. }
  28. }
  29.  
  30. ## databases.pp
  31.  
  32. db { 'testies':
  33. user => 'testicles',
  34. password => 'pHt8UlaPiiO0paVD',
  35. }
Add Comment
Please, Sign In to add comment