Last active
September 17, 2015 16:35
-
-
Save marcioviegas/ea627666ffc5b9b6c57b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exec { "apt-update": | |
command => "/usr/bin/apt-get update" | |
} | |
package { "mysql-server": | |
ensure => installed, | |
require => Exec["apt-update"], | |
} | |
file { "/etc/mysql/conf.d/allow_external.cnf": | |
owner => mysql, | |
group => mysql, | |
mode => 0644, | |
content => template("/vagrant/manifests/allow_ext.cnf"), | |
require => Package["mysql-server"], | |
notify => Service["mysql"], | |
} | |
service { "mysql": | |
ensure => running, | |
enable => true, | |
hasstatus => true, | |
hasrestart => true, | |
require => Package["mysql-server"], | |
} | |
exec { "loja-schema": | |
unless => "mysql -uroot loja_schema", | |
command => "mysqladmin -uroot create loja_schema", | |
path => "/usr/bin/", | |
require => Service["mysql"], | |
} | |
exec { "remove-anonymous-user": | |
command => "mysql -uroot -e \"DELETE FROM mysql.user WHERE user=''; FLUSH PRIVILEGES\"", | |
onlyif => "mysql -u' '", | |
path => "/usr/bin/", | |
require => Service["mysql"], | |
} | |
exec { "loja-user": | |
unless => "mysql -uloja -plojasecret loja_schema", | |
command => "mysql -uroot -e \"GRANT ALL PRIVILEGES ON loja_schema.* TO 'loja'@'%' IDENTIFIED BY 'lojasecret';\"", | |
path => "/usr/bin/", | |
require => Exec["loja-schema"], | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment