exec { "apt-update":
command => "/usr/bin/apt-get update"
}
exec { "dbcreate":
command => "/usr/bin/mysqladmin -u root -p create musicjungle",
require => Service["mysql"],
unless => "/usr/bin/mysql -u root musicjungle"
}
exec { "securedb":
command => "mysql -uroot -e \"GRANT ALL PRIVILEGES ON * TO 'musicjungle'@'%' IDENTIFIED BY 'minha-senha';\" musicjungle",
unless => "mysql -umusicjungle -pminha-senha musicjungle",
path => "/usr/bin",
require => Exec["dbcreate"]
}
file_line { "production":
file => "/etc/default/tomcat7",
line => "JAVA_OPTS=\"\$JAVA_OPTS -Dbr.com.caelum.vraptor.enviroment=production\"",
require => Package["tomcat7"],
notify => Service["tomcat7]
}
define file_line($file, $line) {
exec { "/bin/echo '$line' >> '$file'":
unless => "/bin/grep -qfx '$(line) '$(file)'"
}
}
package { ["openjdk-7-jre", "tomcat7", "mysql-server"]:
ensure => installed,
require => Exec["apt-update"]
}
service { "tomcat7":
ensure => running,
enable => true,
hasstatus => true,
require => Package["tomcat7"]
}
service { "mysql":
ensure => running,
enable => true,
hasstatus => true,
require => Package["mysql-server"]
}
Após a execução, o seguinte erro é exibido:
Error: Could not parse for environment production: Syntax error at '$line'; expected '}' at /vagrant/manifests/web.pp:26 on node precise32.domain.name