Browse code

Merge "Use mod_version to clean-up apache version matching"

Jenkins authored on 2014/09/25 12:43:29
Showing 6 changed files
... ...
@@ -17,10 +17,16 @@
17 17
 
18 18
     <Directory %HORIZON_DIR%/>
19 19
         Options Indexes FollowSymLinks MultiViews
20
-        %HORIZON_REQUIRE%
21 20
         AllowOverride None
22
-        Order allow,deny
23
-        allow from all
21
+        # Apache 2.4 uses mod_authz_host for access control now (instead of
22
+        #  "Allow")
23
+        <IfVersion < 2.4>
24
+            Order allow,deny
25
+            Allow from all
26
+        </IfVersion>
27
+        <IfVersion >= 2.4>
28
+            Require all granted
29
+        </IfVersion>
24 30
     </Directory>
25 31
 
26 32
     ErrorLog /var/log/%APACHE_NAME%/horizon_error.log
... ...
@@ -6,7 +6,9 @@ Listen %ADMINPORT%
6 6
     WSGIProcessGroup keystone-public
7 7
     WSGIScriptAlias / %PUBLICWSGI%
8 8
     WSGIApplicationGroup %{GLOBAL}
9
-    %ERRORLOGFORMAT%
9
+    <IfVersion >= 2.4>
10
+      ErrorLogFormat "%{cu}t %M"
11
+    </IfVersion>
10 12
     ErrorLog /var/log/%APACHE_NAME%/keystone.log
11 13
     CustomLog /var/log/%APACHE_NAME%/keystone_access.log combined
12 14
 </VirtualHost>
... ...
@@ -16,7 +18,9 @@ Listen %ADMINPORT%
16 16
     WSGIProcessGroup keystone-admin
17 17
     WSGIScriptAlias / %ADMINWSGI%
18 18
     WSGIApplicationGroup %{GLOBAL}
19
-    %ERRORLOGFORMAT%
19
+    <IfVersion >= 2.4>
20
+      ErrorLogFormat "%{cu}t %M"
21
+    </IfVersion>
20 22
     ErrorLog /var/log/%APACHE_NAME%/keystone.log
21 23
     CustomLog /var/log/%APACHE_NAME%/keystone_access.log combined
22 24
 </VirtualHost>
... ...
@@ -21,18 +21,6 @@ function function_exists {
21 21
     declare -f -F $1 > /dev/null
22 22
 }
23 23
 
24
-# Checks if installed Apache is <= given version
25
-# $1 = x.y.z (version string of Apache)
26
-function check_apache_version {
27
-    local cmd="apachectl"
28
-    if ! [[ -x $(which apachectl 2>/dev/null) ]]; then
29
-        cmd="/usr/sbin/apachectl"
30
-    fi
31
-
32
-    local version=$($cmd -v | grep version | grep -Po 'Apache/\K[^ ]*')
33
-    expr "$version" '>=' $1 > /dev/null
34
-}
35
-
36 24
 
37 25
 # Cleanup anything from /tmp on unstack
38 26
 # clean_tmp
... ...
@@ -59,6 +59,11 @@ function install_apache_wsgi {
59 59
     else
60 60
         exit_distro_not_supported "apache installation"
61 61
     fi
62
+
63
+    # ensure mod_version enabled for <IfVersion ...>.  This is
64
+    # built-in statically on anything recent, but precise (2.2)
65
+    # doesn't have it enabled
66
+    sudo a2enmod version || true
62 67
 }
63 68
 
64 69
 # get_apache_version() - return the version of Apache installed
... ...
@@ -123,12 +123,6 @@ function init_horizon {
123 123
     # Create an empty directory that apache uses as docroot
124 124
     sudo mkdir -p $HORIZON_DIR/.blackhole
125 125
 
126
-    # Apache 2.4 uses mod_authz_host for access control now (instead of "Allow")
127
-    local horizon_require=''
128
-    if check_apache_version "2.4" ; then
129
-        horizon_require='Require all granted'
130
-    fi
131
-
132 126
     local horizon_conf=$(apache_site_config_for horizon)
133 127
 
134 128
     # Configure apache to run horizon
... ...
@@ -138,7 +132,6 @@ function init_horizon {
138 138
         s,%HORIZON_DIR%,$HORIZON_DIR,g;
139 139
         s,%APACHE_NAME%,$APACHE_NAME,g;
140 140
         s,%DEST%,$DEST,g;
141
-        s,%HORIZON_REQUIRE%,$horizon_require,g;
142 141
     \" $FILES/apache-horizon.template >$horizon_conf"
143 142
 
144 143
     if is_ubuntu; then
... ...
@@ -121,12 +121,6 @@ function _config_keystone_apache_wsgi {
121 121
     local keystone_apache_conf=$(apache_site_config_for keystone)
122 122
     local apache_version=$(get_apache_version)
123 123
 
124
-    if [[ ${apache_version#*\.} -ge 4 ]]; then
125
-        # Apache 2.4 supports custom error log formats
126
-        # this should mirror the original log formatting.
127
-        local errorlogformat='ErrorLogFormat "%{cu}t %M"'
128
-    fi
129
-
130 124
     # copy proxy vhost and wsgi file
131 125
     sudo cp $KEYSTONE_DIR/httpd/keystone.py $KEYSTONE_WSGI_DIR/main
132 126
     sudo cp $KEYSTONE_DIR/httpd/keystone.py $KEYSTONE_WSGI_DIR/admin
... ...
@@ -139,7 +133,6 @@ function _config_keystone_apache_wsgi {
139 139
         s|%PUBLICWSGI%|$KEYSTONE_WSGI_DIR/main|g;
140 140
         s|%ADMINWSGI%|$KEYSTONE_WSGI_DIR/admin|g;
141 141
         s|%USER%|$STACK_USER|g
142
-        s|%ERRORLOGFORMAT%|$errorlogformat|g;
143 142
     " -i $keystone_apache_conf
144 143
 }
145 144