1
0
mirror of https://gitlab.com/depesz/explain.depesz.com.git synced 2024-11-24 08:42:27 +02:00
explain.depesz.com/explain.pp

112 lines
3.1 KiB
ObjectPascal
Raw Normal View History

2015-01-06 17:17:29 +02:00
# Unfortunately there is no way to automatically detect current project directory
if $use_vagrant {
$PROJECT_DIR = '/vagrant'
} else {
fail('Replace this line with correct $PROJECT_DIR value assignment.')
}
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']
Exec {
path => [
'/usr/local/bin',
'/usr/bin',
'/bin'],
logoutput => true,
}
2015-01-06 09:38:14 +02:00
exec { 'update_pkgs_index': command => 'apt-get update' }
2015-01-05 20:21:10 +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.
exec { 'install_cpanm_mojolicious': command => 'cpanm --notest Mojolicious' }
2015-01-05 20:21:10 +02:00
exec { 'createuser': command => 'sudo -u postgres psql -c "create role explain with login password \'explain\'"' }
exec { 'createdb': command => 'sudo -u postgres createdb -E utf8 -O explain explain' }
2015-01-05 20:21:10 +02:00
2015-01-06 09:34:11 +02:00
exec { 'psql_create':
command => sprintf("sudo -u postgres psql -d explain < %s/sql/create.sql", $PROJECT_DIR)
2015-01-06 09:34:11 +02:00
}
exec { 'psql_apply_patches':
command => sprintf("ls -1 %s/sql/patch-???.sql | sort | xargs -n1 sudo -u postgres psql -d explain -q -f", $PROJECT_DIR)
2015-01-06 09:34:11 +02:00
}
exec { 'psql_grant':
command => 'sudo -u postgres psql -d explain -c "grant all on plans, users to explain;"'
2015-01-06 09:34:11 +02:00
}
2015-01-05 20:21:10 +02:00
2015-01-06 17:17:29 +02:00
exec { 'run_daemon': command => sprintf("hypnotoad %s/explain.pl > /dev/null 2> /dev/null &", $PROJECT_DIR) }
2015-01-06 09:12:23 +02:00
2015-01-06 09:38:14 +02:00
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
}
2015-01-06 09:12:23 +02:00
package { 'nginx':
ensure => installed
}
2015-01-06 09:38:14 +02:00
file { '/etc/nginx/conf.d/explain.conf':
2015-01-06 09:12:23 +02:00
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'],
}
2015-01-06 09:38:14 +02:00
2015-01-06 09:12:23 +02:00
service { 'nginx':
ensure => running,
enable => true,
hasstatus => true,
hasrestart => true,
}