Skip to content

Commit

Permalink
Update Vagrant Puppet provision to be more Rails-centric
Browse files Browse the repository at this point in the history
  • Loading branch information
henare committed Sep 4, 2014
1 parent 1da87c9 commit e3b0628
Showing 1 changed file with 41 additions and 38 deletions.
79 changes: 41 additions & 38 deletions manifests/development_lucid.pp
Expand Up @@ -175,11 +175,12 @@
"
}

exec { "mysql --database=$db_dev -u $db_dev --password=$db_dev_password < /vagrant/php/loader/create.sql":
refreshonly => true,
subscribe => Mysql::Db["$db_dev"],
path => ['/usr/bin', '/usr/sbin/', '/bin/']
}
## The database is created by Rails now
# exec { "mysql --database=$db_dev -u $db_dev --password=$db_dev_password < /vagrant/php/loader/create.sql":
# refreshonly => true,
# subscribe => Mysql::Db["$db_dev"],
# path => ['/usr/bin', '/usr/sbin/', '/bin/']
# }

class { 'apache':
mpm_module => 'prefork',
Expand Down Expand Up @@ -230,32 +231,40 @@
?>"
}

# Downloads a small sample of debate data from data.openaustralia.org and uses
# it to populate the database.
exec { '/vagrant/php/loader/load_openaustralia_xml.sh':
refreshonly => true,
subscribe => Exec["mysql --database=$db_dev -u $db_dev --password=$db_dev_password < /vagrant/php/loader/create.sql"],
require => [
File['/vagrant/php/loader/PublicWhip/Config.pm'],
Package['libtext-autoformat-perl'],
Package['libunicode-string-perl'],
Package['libxml-twig-perl'],
Package['php5-cli']
],
cwd => '/vagrant/php/loader',
timeout => 1200,
path => ['/usr/bin', '/usr/sbin/', '/bin/']
}

# Copy the dev database to the test database
exec { "mysqldump -u $db_dev --password=$db_dev_password $db_dev | mysql -u $db_test --password=$db_test_password --database=$db_test":
refreshonly => true,
subscribe => Exec['/vagrant/php/loader/load_openaustralia_xml.sh'],
require => Mysql::Db["$db_test"],
path => ['/usr/bin', '/usr/sbin/', '/bin/']
# Set the PHP_SERVER environment variable that the rspec tests use when testing against PHP
file { '/etc/profile.d/publichwhip_rails_tests.sh':
ensure => 'present',
content => 'export PHP_SERVER=localhost',
mode => 755
}

# Rails port configuration
## Disable data loading since Rails has database seeds for us
# # Downloads a small sample of debate data from data.openaustralia.org and uses
# # it to populate the database.
# exec { '/vagrant/php/loader/load_openaustralia_xml.sh':
# refreshonly => true,
# subscribe => Exec["mysql --database=$db_dev -u $db_dev --password=$db_dev_password < /vagrant/php/loader/create.sql"],
# require => [
# File['/vagrant/php/loader/PublicWhip/Config.pm'],
# Package['libtext-autoformat-perl'],
# Package['libunicode-string-perl'],
# Package['libxml-twig-perl'],
# Package['php5-cli']
# ],
# cwd => '/vagrant/php/loader',
# timeout => 1200,
# path => ['/usr/bin', '/usr/sbin/', '/bin/']
# }

# # Copy the dev database to the test database
# exec { "mysqldump -u $db_dev --password=$db_dev_password $db_dev | mysql -u $db_test --password=$db_test_password --database=$db_test":
# refreshonly => true,
# subscribe => Exec['/vagrant/php/loader/load_openaustralia_xml.sh'],
# require => Mysql::Db["$db_test"],
# path => ['/usr/bin', '/usr/sbin/', '/bin/']
# }

# Rails configuration

file { '/vagrant/config/database.yml':
ensure => 'present',
Expand Down Expand Up @@ -292,15 +301,8 @@
#WARNING: obviously don't use the above keys in production, generate your own using 'bundle exec rake secret'.
}
# Set the PHP_SERVER environment variable that the rspec tests use
file { '/etc/profile.d/publichwhip_rails_tests.sh':
ensure => 'present',
content => 'export PHP_SERVER=localhost',
mode => 755
}
# Migrate both the databases
exec { 'bundle exec rake db:migrate RAILS_ENV=development':
# Set up development database
exec { 'bundle exec rake db:setup':
require => [
Exec['bundle install'],
Mysql::Db["$db_dev"],
Expand All @@ -312,6 +314,7 @@
# it fails without this. Investigate.
}
# Migrate test database
exec { 'bundle exec rake db:migrate RAILS_ENV=test':
require => [
Exec['bundle install'],
Expand Down

0 comments on commit e3b0628

Please sign in to comment.