2015-01-05 20:21:10 +02:00
|
|
|
# We need to order provision commands [ https://docs.puppetlabs.com/learning/ordering.html ]
|
|
|
|
Exec['update_pkgs_index']->
|
|
|
|
Package['curl'] ->
|
|
|
|
Package['postgresql-9.3'] ->
|
|
|
|
Package['libexpat1-dev'] ->
|
|
|
|
Package['libpq-dev'] ->
|
|
|
|
Exec['install_cpanm']->
|
|
|
|
Exec['install_cpanm_dbi']->
|
|
|
|
Exec['install_cpanm_dbd_pg']->
|
|
|
|
Exec['install_cpanm_date_simple']->
|
|
|
|
Exec['install_cpanm_mail_sender']->
|
|
|
|
Exec['install_cpanm_email_valid']->
|
|
|
|
Exec['install_cpanm_pg_explain']->
|
|
|
|
Exec['install_cpanm_mojolicious']->
|
|
|
|
Exec['createuser']->
|
|
|
|
Exec['createdb']->
|
|
|
|
Exec['psql_create']->
|
2015-01-06 09:34:11 +02:00
|
|
|
Exec['psql_apply_patches']->
|
2015-01-05 20:21:10 +02:00
|
|
|
Exec['psql_grant']->
|
|
|
|
Exec['run_daemon']
|
|
|
|
|
|
|
|
|
|
|
|
package { 'curl': # required by cpanminus installation
|
|
|
|
ensure => installed
|
|
|
|
}
|
|
|
|
|
|
|
|
package { 'postgresql-9.3':
|
|
|
|
ensure => installed
|
|
|
|
}
|
|
|
|
|
|
|
|
package { 'libexpat1-dev': # required by XML::Parser
|
|
|
|
ensure => installed
|
|
|
|
}
|
|
|
|
|
|
|
|
package { 'libpq-dev': # required by DBD::Pg
|
|
|
|
ensure => installed
|
|
|
|
}
|
|
|
|
|
|
|
|
Exec {
|
|
|
|
path => [
|
|
|
|
'/usr/local/bin',
|
|
|
|
'/usr/bin',
|
|
|
|
'/bin'],
|
|
|
|
logoutput => true,
|
|
|
|
}
|
|
|
|
|
|
|
|
# FIXME: only debian-based systems are supported.
|
2015-01-06 06:56:57 +02:00
|
|
|
exec { 'update_pkgs_index': command => 'apt-get update' }
|
2015-01-05 20:21:10 +02:00
|
|
|
|
2015-01-06 06:56:57 +02:00
|
|
|
exec { 'install_cpanm': command => 'curl -L http://cpanmin.us | perl - --self-upgrade' }
|
|
|
|
exec { 'install_cpanm_dbi': command => 'cpanm --notest DBI' }
|
|
|
|
exec { 'install_cpanm_dbd_pg': command => 'cpanm --notest DBD::Pg' }
|
|
|
|
exec { 'install_cpanm_date_simple': command => 'cpanm --notest Date::Simple' }
|
|
|
|
exec { 'install_cpanm_mail_sender': command => 'cpanm --notest Mail::Sender' }
|
|
|
|
exec { 'install_cpanm_email_valid': command => 'cpanm --notest Email::Valid' }
|
2015-01-06 09:34:46 +02:00
|
|
|
exec { 'install_cpanm_pg_explain': command => 'cpanm --notest Pg::Explain', timeout => 600 } # Takes about 450-500 secs.
|
2015-01-06 06:56:57 +02:00
|
|
|
exec { 'install_cpanm_mojolicious': command => 'cpanm --notest Mojolicious' }
|
2015-01-05 20:21:10 +02:00
|
|
|
|
2015-01-06 06:56:57 +02:00
|
|
|
exec { 'createuser': command => 'sudo -u postgres psql -c "create role explaind with login password \'explaind\'"' }
|
2015-01-05 20:21:10 +02:00
|
|
|
exec { 'createdb': command => 'sudo -u postgres createdb -E utf8 -O explaind explaind' }
|
|
|
|
|
|
|
|
# FIXME: path to sql-files should be relative or parameter-based.
|
2015-01-06 09:34:11 +02:00
|
|
|
exec { 'psql_create':
|
|
|
|
command => 'sudo -u postgres psql -d explaind < /vagrant/sql/create.sql'
|
|
|
|
}
|
|
|
|
exec { 'psql_apply_patches':
|
|
|
|
command => 'ls -1 /vagrant/sql/patch-???.sql | sort | xargs -n1 sudo -u postgres psql -d explaind -q -f'
|
|
|
|
}
|
|
|
|
exec { 'psql_grant':
|
|
|
|
command => 'sudo -u postgres psql -d explaind -c "grant all on plans, users to explaind;"'
|
|
|
|
}
|
2015-01-05 20:21:10 +02:00
|
|
|
|
2015-01-06 09:12:23 +02:00
|
|
|
exec { 'run_daemon': command => 'hypnotoad /vagrant/explain.pl > /dev/null 2> /dev/null &' }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
package { 'nginx':
|
|
|
|
ensure => installed
|
|
|
|
}
|
|
|
|
|
|
|
|
file { '/etc/nginx/conf.d/explaind.conf':
|
|
|
|
owner => 'root',
|
|
|
|
group => 'root',
|
|
|
|
content => '
|
|
|
|
server {
|
|
|
|
listen 80;
|
|
|
|
server_name explain.depesz.loc;
|
|
|
|
|
|
|
|
location / {
|
|
|
|
proxy_pass http://127.0.0.1:12004;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
',
|
|
|
|
notify => Service['nginx'],
|
|
|
|
require => Package['nginx'],
|
|
|
|
}
|
|
|
|
|
|
|
|
service { 'nginx':
|
|
|
|
ensure => running,
|
|
|
|
enable => true,
|
|
|
|
hasstatus => true,
|
|
|
|
hasrestart => true,
|
|
|
|
}
|