Puppet script upgrade to LV 5.X

In order to allow IDP upgrade from
LV 4.x to LV 5.X
(https://review.openstack.org/#/c/305521/)
puppet and shell scripts
were update to support diferent versions
or laravel through config variable $laravel_version
( default value to version 4 so production would not
get affected ).

Change-Id: I76a7093f3c88c72256f638d5c56cc8799643b69d
This commit is contained in:
Sebastian Marcet 2016-11-17 18:28:08 -03:00
parent 274521cca5
commit 75c6ce708b
11 changed files with 265 additions and 119 deletions

View File

@ -51,26 +51,42 @@ function site_init {
chown -R $FILE_OWNER:$FILE_GROUP $target_dir
umask 0022
# link configuration files managed by puppet
ln -sf /etc/openstackid/environment.php $target_dir/bootstrap/environment.php
ln -sf /etc/openstackid/recaptcha.php $target_dir/app/config/packages/greggilbert/recaptcha/$LARAVEL_ENV/config.php
ln -sf /etc/openstackid/database.php $target_dir/app/config/$LARAVEL_ENV/database.php
ln -sf /etc/openstackid/app.php $target_dir/app/config/$LARAVEL_ENV/app.php
ln -sf /etc/openstackid/log.php $target_dir/app/config/$LARAVEL_ENV/log.php
ln -sf /etc/openstackid/server.php $target_dir/app/config/$LARAVEL_ENV/server.php
ln -sf /etc/openstackid/mail.php $target_dir/app/config/$LARAVEL_ENV/mail.php
# convert app/storage into symlink and set permissions
mv $target_dir/app/storage $SITE_ROOT/
chmod 02770 $SITE_ROOT/storage
find $SITE_ROOT/storage/ -type d -exec chmod 0775 {} \;
find $SITE_ROOT/storage/ -type f -exec chmod 0664 {} \;
rm -rf $target_dir/app/storage
ln -s $SITE_ROOT/storage $target_dir/app
if [[ $LARAVEL_VERSION -eq 4 ]]; then
ln -sf /etc/openstackid/environment.php $target_dir/bootstrap/environment.php
ln -sf /etc/openstackid/recaptcha.php $target_dir/app/config/packages/greggilbert/recaptcha/$LARAVEL_ENV/config.php
ln -sf /etc/openstackid/database.php $target_dir/app/config/$LARAVEL_ENV/database.php
ln -sf /etc/openstackid/app.php $target_dir/app/config/$LARAVEL_ENV/app.php
ln -sf /etc/openstackid/log.php $target_dir/app/config/$LARAVEL_ENV/log.php
ln -sf /etc/openstackid/server.php $target_dir/app/config/$LARAVEL_ENV/server.php
ln -sf /etc/openstackid/mail.php $target_dir/app/config/$LARAVEL_ENV/mail.php
# convert app/storage into symlink and set permissions
mv $target_dir/app/storage $SITE_ROOT/
chmod 02770 $SITE_ROOT/storage
find $SITE_ROOT/storage/ -type d -exec chmod 0775 {} \;
find $SITE_ROOT/storage/ -type f -exec chmod 0664 {} \;
rm -rf $target_dir/app/storage
ln -s $SITE_ROOT/storage $target_dir/app
fi
if [[ $LARAVEL_VERSION -eq 5 ]]; then
ln -sf /etc/openstackid/.env $target_dir/.env
# convert app/storage into symlink and set permissions
mv $target_dir/storage $SITE_ROOT/
chmod 02770 $SITE_ROOT/storage
find $SITE_ROOT/storage/ -type d -exec chmod 0775 {} \;
find $SITE_ROOT/storage/ -type f -exec chmod 0664 {} \;
rm -rf $target_dir/storage
ln -s $SITE_ROOT/storage $target_dir
fi
# populate application database
cd $target_dir
php artisan migrate --env=$LARAVEL_ENV
if [[ $USE_DB_SEEDING -eq 1 ]]; then
php artisan db:seed --env=$LARAVEL_ENV
fi
update_node
install_bower
# activate site
@ -181,17 +197,28 @@ function site_update {
fi
chown -R $FILE_OWNER:$FILE_GROUP $target_dir
umask 0022
# link configuration files managed by puppet
ln -sf /etc/openstackid/environment.php $target_dir/bootstrap/environment.php
ln -sf /etc/openstackid/recaptcha.php $target_dir/app/config/packages/greggilbert/recaptcha/$LARAVEL_ENV/config.php
ln -sf /etc/openstackid/database.php $target_dir/app/config/$LARAVEL_ENV/database.php
ln -sf /etc/openstackid/app.php $target_dir/app/config/$LARAVEL_ENV/app.php
ln -sf /etc/openstackid/log.php $target_dir/app/config/$LARAVEL_ENV/log.php
ln -sf /etc/openstackid/server.php $target_dir/app/config/$LARAVEL_ENV/server.php
ln -sf /etc/openstackid/mail.php $target_dir/app/config/$LARAVEL_ENV/mail.php
# link shared app/storage directory
rm -rf $target_dir/app/storage
ln -s $SITE_ROOT/storage $target_dir/app
if [[ $LARAVEL_VERSION -eq 4 ]]; then
ln -sf /etc/openstackid/environment.php $target_dir/bootstrap/environment.php
ln -sf /etc/openstackid/recaptcha.php $target_dir/app/config/packages/greggilbert/recaptcha/$LARAVEL_ENV/config.php
ln -sf /etc/openstackid/database.php $target_dir/app/config/$LARAVEL_ENV/database.php
ln -sf /etc/openstackid/app.php $target_dir/app/config/$LARAVEL_ENV/app.php
ln -sf /etc/openstackid/log.php $target_dir/app/config/$LARAVEL_ENV/log.php
ln -sf /etc/openstackid/server.php $target_dir/app/config/$LARAVEL_ENV/server.php
ln -sf /etc/openstackid/mail.php $target_dir/app/config/$LARAVEL_ENV/mail.php
# link shared app/storage directory
rm -rf $target_dir/app/storage
ln -s $SITE_ROOT/storage $target_dir/app
fi
if [[ $LARAVEL_VERSION -eq 5 ]]; then
ln -sf /etc/openstackid/.env $target_dir/.env
# link shared app/storage directory
rm -rf $target_dir/storage
ln -s $SITE_ROOT/storage $target_dir
fi
# populate application database
cd $target_dir
php artisan migrate --env=$LARAVEL_ENV

View File

@ -29,6 +29,7 @@ class openstackid (
$ss_db_name = '',
$redis_port = '',
$redis_host = '',
$redis_db = 0,
$redis_password = '',
$vhost_name = $::fqdn,
$robots_txt_source = '',
@ -62,19 +63,33 @@ class openstackid (
$email_smtp_server_password = '',
$use_db_seeding = false,
$docroot = '/srv/openstackid/w/public',
$laravel_version = 4,
$app_log_level = 'error',
$app_log_email_level = 'error',
$db_log_enabled = false,
$banning_enabled = true,
$app_debug = false,
$app_locale = 'en',
$curl_verify_ssl_cert = true,
$curl_allow_redirect = false,
$curl_timeout = 60,
$assets_base_url = 'https://www.openstack.org/',
$cache_driver = 'redis',
$session_driver = 'redis',
$session_cookie_secure = false,
) {
# php packages needed for openid server
$php5_packages = [
'php5-common',
'php5-curl',
'php5-cli',
'php5-mcrypt',
'php5-mysqlnd',
'php5-fpm',
'php5-json',
'php5-gmp',
]
'php5-common',
'php5-curl',
'php5-cli',
'php5-mcrypt',
'php5-mysqlnd',
'php5-fpm',
'php5-json',
'php5-gmp',
]
package { $php5_packages:
ensure => present,
@ -138,81 +153,99 @@ class openstackid (
mode => '0755',
}
file { '/etc/openstackid/database.php':
ensure => present,
content => template('openstackid/database.php.erb'),
owner => 'root',
group => 'www-data',
mode => '0640',
require => [
File['/etc/openstackid'],
]
}
if($laravel_version == 4 ){
file { '/etc/openstackid/app.php':
ensure => present,
content => template('openstackid/app.php.erb'),
owner => 'root',
group => 'www-data',
mode => '0640',
require => [
File['/etc/openstackid'],
]
}
file { '/etc/openstackid/log.php':
ensure => present,
content => template('openstackid/log.php.erb'),
owner => 'root',
group => 'www-data',
mode => '0640',
require => [
File['/etc/openstackid'],
]
}
file { '/etc/openstackid/environment.php':
ensure => present,
content => template('openstackid/environment.php.erb'),
owner => 'root',
group => 'www-data',
mode => '0640',
require => [
File['/etc/openstackid'],
]
}
file { '/etc/openstackid/recaptcha.php':
# laravel 4.X configuration files
file { '/etc/openstackid/database.php':
ensure => present,
content => template('openstackid/recaptcha.php.erb'),
content => template('openstackid/lv4/database.php.erb'),
owner => 'root',
group => 'www-data',
mode => '0640',
require => [
File['/etc/openstackid'],
]
}
}
file { '/etc/openstackid/server.php':
file { '/etc/openstackid/app.php':
ensure => present,
content => template('openstackid/server.php.erb'),
content => template('openstackid/lv4/app.php.erb'),
owner => 'root',
group => 'www-data',
mode => '0640',
require => [
File['/etc/openstackid'],
]
}
}
file { '/etc/openstackid/mail.php':
ensure => present,
content => template('openstackid/mail.php.erb'),
owner => 'root',
group => 'www-data',
mode => '0640',
require => [
File['/etc/openstackid'],
]
file { '/etc/openstackid/log.php':
ensure => present,
content => template('openstackid/lv4/log.php.erb'),
owner => 'root',
group => 'www-data',
mode => '0640',
require => [
File['/etc/openstackid'],
]
}
file { '/etc/openstackid/environment.php':
ensure => present,
content => template('openstackid/lv4/environment.php.erb'),
owner => 'root',
group => 'www-data',
mode => '0640',
require => [
File['/etc/openstackid'],
]
}
file { '/etc/openstackid/recaptcha.php':
ensure => present,
content => template('openstackid/lv4/recaptcha.php.erb'),
owner => 'root',
group => 'www-data',
mode => '0640',
require => [
File['/etc/openstackid'],
]
}
file { '/etc/openstackid/server.php':
ensure => present,
content => template('openstackid/lv4/server.php.erb'),
owner => 'root',
group => 'www-data',
mode => '0640',
require => [
File['/etc/openstackid'],
]
}
file { '/etc/openstackid/mail.php':
ensure => present,
content => template('openstackid/lv4/mail.php.erb'),
owner => 'root',
group => 'www-data',
mode => '0640',
require => [
File['/etc/openstackid'],
]
}
}
else
{
file { '/etc/openstackid/.env':
ensure => present,
content => template('openstackid/lv5/.env.erb'),
owner => 'root',
group => 'www-data',
mode => '0640',
require => [
File['/etc/openstackid'],
]
}
}
$docroot_dirs = [ '/srv/openstackid' ]
@ -229,7 +262,7 @@ class openstackid (
mpm_module => false,
}
# apache mpm event connectio tweaking
# apache mpm event connection tweaking
class {'::apache::mod::event':
serverlimit => 128,
startservers => 3,
@ -314,24 +347,60 @@ class openstackid (
require => Deploy['deploytool'],
}
if($laravel_version == 4 ){
$deploy_site_requires = [
File['/opt/deploy/conf.d/openstackid.conf'],
Apache::Vhost::Custom[$vhost_name],
File['/etc/openstackid/recaptcha.php'],
File['/etc/openstackid/database.php'],
File['/etc/openstackid/log.php'],
File['/etc/openstackid/environment.php'],
File['/etc/openstackid/server.php'],
File['/etc/openstackid/app.php'],
Package['curl'],
Package[$php5_packages] ,
Class['::nodejs'],
]
$update_site_requires = [
File['/opt/deploy/conf.d/openstackid.conf'],
Apache::Vhost::Custom[$vhost_name],
File['/etc/openstackid/recaptcha.php'],
File['/etc/openstackid/database.php'],
File['/etc/openstackid/app.php'],
File['/etc/openstackid/log.php'],
File['/etc/openstackid/environment.php'],
File['/etc/openstackid/server.php'],
Package[$php5_packages] ,
Class['::nodejs'],
]
}
else{
$deploy_site_requires = [
File['/opt/deploy/conf.d/openstackid.conf'],
Apache::Vhost::Custom[$vhost_name],
File['/etc/openstackid/.env'],
Package['curl'],
Package[$php5_packages] ,
Class['::nodejs'],
]
$update_site_requires = [
File['/opt/deploy/conf.d/openstackid.conf'],
Apache::Vhost::Custom[$vhost_name],
File['/etc/openstackid/.env'],
Package[$php5_packages] ,
Class['::nodejs'],
]
}
exec { 'deploy-site':
path => '/usr/local/bin:/usr/bin:/bin',
command => '/opt/deploy/deploy.sh init openstackid',
onlyif => '/opt/deploy/deploy.sh status openstackid | grep N/A',
logoutput => on_failure,
require => [
File['/opt/deploy/conf.d/openstackid.conf'],
Apache::Vhost::Custom[$vhost_name],
File['/etc/openstackid/recaptcha.php'],
File['/etc/openstackid/database.php'],
File['/etc/openstackid/log.php'],
File['/etc/openstackid/environment.php'],
File['/etc/openstackid/server.php'],
File['/etc/openstackid/app.php'],
Package['curl'],
Package[$php5_packages] ,
Class['::nodejs'],
],
require => $deploy_site_requires,
}
exec { 'update-site':
@ -339,18 +408,7 @@ class openstackid (
command => '/opt/deploy/deploy.sh update openstackid',
onlyif => '/opt/deploy/deploy.sh status openstackid | grep UPDATE',
logoutput => on_failure,
require => [
File['/opt/deploy/conf.d/openstackid.conf'],
Apache::Vhost::Custom[$vhost_name],
File['/etc/openstackid/recaptcha.php'],
File['/etc/openstackid/database.php'],
File['/etc/openstackid/app.php'],
File['/etc/openstackid/log.php'],
File['/etc/openstackid/environment.php'],
File['/etc/openstackid/server.php'],
Package[$php5_packages] ,
Class['::nodejs'],
],
require => $update_site_requires,
}
# system configuration tweaking

View File

@ -87,7 +87,7 @@ return array(
'default' => array(
'host' => '<%= @redis_host %>',
'port' => <%= @redis_port %>,
'database' => 0,
'database' => <%= @redis_db %>,
'password' => '<%= @redis_password %>'
),
),

60
templates/lv5/.env.erb Normal file
View File

@ -0,0 +1,60 @@
APP_ENV="<%= @id_environment %>"
APP_DEBUG=<%= @app_debug %>
APP_KEY="<%= @app_key %>"
APP_URL="<%= @app_url %>"
APP_LOG=daily
APP_TIMEZONE="<%= @app_timezone %>"
APP_LOCALE="<%= @app_locale %>"
APP_VERSION="<%= @app_version %>"
DB_HOST="<%= @id_mysql_host %>"
DB_DATABASE="<%= @id_db_name %>"
DB_USERNAME="<%= @id_mysql_user %>"
DB_PASSWORD="<%= @id_mysql_password %>"
SS_DB_DRIVER=mysql
SS_DB_HOST="<%= @ss_mysql_host %>"
SS_DATABASE="<%= @ss_db_name %>"
SS_DB_USERNAME="<%= @ss_mysql_user %>"
SS_DB_PASSWORD="<%= @ss_mysql_password %>"
REDIS_HOST="<%= @redis_host %>"
REDIS_PORT=<%= @redis_port %>
REDIS_DB=<%= @redis_db %>
REDIS_PASSWORD="<%= @redis_password %>"
CACHE_DRIVER="<%= @cache_driver %>"
SESSION_DRIVER="<%= @session_driver %>"
SESSION_COOKIE_SECURE=<%= @session_cookie_secure %>
MAIL_DRIVER=<%= @email_driver %>
MAIL_HOST=<%= @email_smtp_server %>
MAIL_PORT=<%= @email_smtp_server_port %>
MAIL_USERNAME="<%= @email_smtp_server_user %>"
MAIL_PASSWORD="<%= @email_smtp_server_password %>"
CORS_ALLOWED_HEADERS="origin, content-type, accept, authorization, x-requested-with"
CORS_ALLOWED_METHODS="GET, POST, OPTIONS, PUT, DELETE"
CORS_USE_PRE_FLIGHT_CACHING=false
CORS_MAX_AGE=3200
CORS_EXPOSED_HEADERS=
CURL_TIMEOUT=<%= @curl_timeout %>
CURL_ALLOWS_REDIRECT=<%= @curl_allow_redirect %>
CURL_VERIFY_SSL_CERT=<%= @curl_verify_ssl_cert %>
ASSETS_BASE_URL="<%= @assets_base_url %>"
SSL_ENABLED=<%= @ssl_enable %>
DB_LOG_ENABLED=<%= @db_log_enabled %>
BANNING_ENABLE=<%= @banning_enabled %>
LOG_EMAIL_TO="<%= @id_log_error_to_email %>"
LOG_EMAIL_FROM="<%= @id_log_error_from_email %>"
LOG_LEVEL="<%= @app_log_level %>"
LOG_EMAIL_LEVEL="<%= @app_log_email_level %>"
RECAPTCHA_PUBLIC_KEY="<%= @id_recaptcha_public_key %>"
RECAPTCHA_PRIVATE_KEY="<%= @id_recaptcha_private_key %>"
RECAPTCHA_TEMPLATE="<%= @id_recaptcha_template %>"

View File

@ -3,4 +3,5 @@ SOURCE_TARBALL=http://tarballs.openstack.org/openstackid/openstackid-<%= @openst
LARAVEL_ENV=<%= @id_environment %>
RELEASE_NAME=openstackid-<%= @openstackid_release %>.tar.gz
SOURCE_ROOT=http://tarballs.openstack.org/openstackid/
USE_DB_SEEDING=<%= @use_db_seeding?1:0 %>
USE_DB_SEEDING=<%= @use_db_seeding?1:0 %>
LARAVEL_VERSION=<%= @laravel_version %>