From b4495eb410e3ad348700f127dcf7c0562014c325 Mon Sep 17 00:00:00 2001 From: Noboru Iwamatsu Date: Wed, 2 Jul 2014 18:31:31 +0900 Subject: [PATCH] Use mod_version to clean-up apache version matching This change uses mod_version (shipped by default on everything we care about) to set-up version-specific config within apache rather than within devstack scripts. Clean up the horizon and keystone config file generation to use the internal apache matching. Since I6478db385fda2fa1c75ced12d3e886b2e1152852 the apache matching in 'functions' is actually duplicated. just leave get_apache_version in lib/apache as it is used for config-file name matching in there. Change-Id: I6478db385fda2fa1c75ced12d3e886b2e1152852 --- files/apache-horizon.template | 12 +++++++++--- files/apache-keystone.template | 8 ++++++-- functions | 12 ------------ lib/apache | 5 +++++ lib/horizon | 7 ------- lib/keystone | 7 ------- 6 files changed, 20 insertions(+), 31 deletions(-) diff --git a/files/apache-horizon.template b/files/apache-horizon.template index c1dd6934f3..bca1251bec 100644 --- a/files/apache-horizon.template +++ b/files/apache-horizon.template @@ -17,10 +17,16 @@ Options Indexes FollowSymLinks MultiViews - %HORIZON_REQUIRE% AllowOverride None - Order allow,deny - allow from all + # Apache 2.4 uses mod_authz_host for access control now (instead of + # "Allow") + + Order allow,deny + Allow from all + + = 2.4> + Require all granted + ErrorLog /var/log/%APACHE_NAME%/horizon_error.log diff --git a/files/apache-keystone.template b/files/apache-keystone.template index e7b215768c..b4bdb16f00 100644 --- a/files/apache-keystone.template +++ b/files/apache-keystone.template @@ -6,7 +6,9 @@ Listen %ADMINPORT% WSGIProcessGroup keystone-public WSGIScriptAlias / %PUBLICWSGI% WSGIApplicationGroup %{GLOBAL} - %ERRORLOGFORMAT% + = 2.4> + ErrorLogFormat "%{cu}t %M" + ErrorLog /var/log/%APACHE_NAME%/keystone.log CustomLog /var/log/%APACHE_NAME%/access.log combined @@ -16,7 +18,9 @@ Listen %ADMINPORT% WSGIProcessGroup keystone-admin WSGIScriptAlias / %ADMINWSGI% WSGIApplicationGroup %{GLOBAL} - %ERRORLOGFORMAT% + = 2.4> + ErrorLogFormat "%{cu}t %M" + ErrorLog /var/log/%APACHE_NAME%/keystone.log CustomLog /var/log/%APACHE_NAME%/access.log combined diff --git a/functions b/functions index 76f704792e..0194acf64e 100644 --- a/functions +++ b/functions @@ -21,18 +21,6 @@ function function_exists { declare -f -F $1 > /dev/null } -# Checks if installed Apache is <= given version -# $1 = x.y.z (version string of Apache) -function check_apache_version { - local cmd="apachectl" - if ! [[ -x $(which apachectl 2>/dev/null) ]]; then - cmd="/usr/sbin/apachectl" - fi - - local version=$($cmd -v | grep version | grep -Po 'Apache/\K[^ ]*') - expr "$version" '>=' $1 > /dev/null -} - # Cleanup anything from /tmp on unstack # clean_tmp diff --git a/lib/apache b/lib/apache index 6d22290c42..2c436816c3 100644 --- a/lib/apache +++ b/lib/apache @@ -59,6 +59,11 @@ function install_apache_wsgi { else exit_distro_not_supported "apache installation" fi + + # ensure mod_version enabled for . This is + # built-in statically on anything recent, but precise (2.2) + # doesn't have it enabled + sudo a2enmod version || true } # get_apache_version() - return the version of Apache installed diff --git a/lib/horizon b/lib/horizon index 614a0c86a8..19693efd96 100644 --- a/lib/horizon +++ b/lib/horizon @@ -120,12 +120,6 @@ function init_horizon { # Create an empty directory that apache uses as docroot sudo mkdir -p $HORIZON_DIR/.blackhole - # Apache 2.4 uses mod_authz_host for access control now (instead of "Allow") - local horizon_require='' - if check_apache_version "2.4" ; then - horizon_require='Require all granted' - fi - local horizon_conf=$(apache_site_config_for horizon) # Configure apache to run horizon @@ -135,7 +129,6 @@ function init_horizon { s,%HORIZON_DIR%,$HORIZON_DIR,g; s,%APACHE_NAME%,$APACHE_NAME,g; s,%DEST%,$DEST,g; - s,%HORIZON_REQUIRE%,$horizon_require,g; \" $FILES/apache-horizon.template >$horizon_conf" if is_ubuntu; then diff --git a/lib/keystone b/lib/keystone index c1b0b8786f..9e234b49d2 100644 --- a/lib/keystone +++ b/lib/keystone @@ -125,12 +125,6 @@ function _config_keystone_apache_wsgi { local keystone_apache_conf=$(apache_site_config_for keystone) local apache_version=$(get_apache_version) - if [[ ${apache_version#*\.} -ge 4 ]]; then - # Apache 2.4 supports custom error log formats - # this should mirror the original log formatting. - local errorlogformat='ErrorLogFormat "%{cu}t %M"' - fi - # copy proxy vhost and wsgi file sudo cp $KEYSTONE_DIR/httpd/keystone.py $KEYSTONE_WSGI_DIR/main sudo cp $KEYSTONE_DIR/httpd/keystone.py $KEYSTONE_WSGI_DIR/admin @@ -143,7 +137,6 @@ function _config_keystone_apache_wsgi { s|%PUBLICWSGI%|$KEYSTONE_WSGI_DIR/main|g; s|%ADMINWSGI%|$KEYSTONE_WSGI_DIR/admin|g; s|%USER%|$STACK_USER|g - s|%ERRORLOGFORMAT%|$errorlogformat|g; " -i $keystone_apache_conf enable_apache_site keystone }