forked from spree/deployment_service_puppet
/
init.pp
59 lines (52 loc) · 1.46 KB
/
init.pp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
class dbserver {
class { 'mysql::server':
config_hash => { 'root_password' => 'foo' }
}
mysql::server::config { 'testfile':
settings => {
'mysqld' => {
'bind-address' => db_server,
}
}
}
case $db_pass {
"": { $db_pass = "spree123"
warning("db_pass not set, using default.")
}
}
define db-for-app(){
mysql::db { "${name}":
user => $name,
password => $db_pass,
host => $app_server_ips,
}
}
db-for-app($app_name:)
# only spree app can get demo deployed,
# so the name is hardcoded on purpose
#
if $deploy_demo {
#gets notified by mysql rights above
exec { "reset database for demo":
command => "bundle exec rake db:migrate db:reset AUTO_ACCEPT=true RAILS_ENV=${rails_env}",
user => 'spree',
group => 'spree',
cwd => "/data/spree/current",
timeout => 1000,
logoutput => "true",
subscribe => File["/home/spree/demo_version"],
require => [ Exec['bundle install demo'], File["/data/spree/shared/config/database.yml"] ],
refreshonly => true
}
exec { "load sample data for demo":
command => "bundle exec rake spree_sample:load AUTO_ACCEPT=true RAILS_ENV=${rails_env}",
user => 'spree',
group => 'spree',
cwd => "/data/spree/current",
timeout => 1000,
logoutput => "true",
subscribe => Exec["reset database for demo"],
refreshonly => true
}
}
}