[PATCH Configure] Configure apache to use dropfiles

gblomqui at redhat.com gblomqui at redhat.com
Mon Jun 4 18:54:08 UTC 2012


From: Greg Blomquist <gblomqui at redhat.com>

This patch modifies the Conductor apache configurations to be able to read
additional configurations from a dropfile location.  The dropfile location is
added by invoking the apache::site define.
---
 recipes/aeolus/files/aggregator-httpd-ssl.conf     |   53 -------------------
 recipes/aeolus/files/aggregator-httpd.conf         |   41 ---------------
 recipes/aeolus/manifests/conductor.pp              |    4 +-
 recipes/aeolus/templates/aggregator-httpd-ssl.conf |   54 ++++++++++++++++++++
 recipes/aeolus/templates/aggregator-httpd.conf     |   42 +++++++++++++++
 recipes/apache/manifests/init.pp                   |    2 -
 recipes/apache/manifests/site.pp                   |   32 ++++++++----
 7 files changed, 120 insertions(+), 108 deletions(-)
 delete mode 100644 recipes/aeolus/files/aggregator-httpd-ssl.conf
 delete mode 100644 recipes/aeolus/files/aggregator-httpd.conf
 create mode 100644 recipes/aeolus/templates/aggregator-httpd-ssl.conf
 create mode 100644 recipes/aeolus/templates/aggregator-httpd.conf

diff --git a/recipes/aeolus/files/aggregator-httpd-ssl.conf b/recipes/aeolus/files/aggregator-httpd-ssl.conf
deleted file mode 100644
index b739317..0000000
--- a/recipes/aeolus/files/aggregator-httpd-ssl.conf
+++ /dev/null
@@ -1,53 +0,0 @@
-NameVirtualHost *:443
-<VirtualHost *:443>
-
-  ErrorLog /etc/httpd/logs/error_log
-  TransferLog /etc/httpd/logs/access_log
-  LogLevel debug
-
-  KeepAlive On
-  ProxyRequests Off
-  RewriteEngine On
-  SSLEngine On
-  SSLCertificateFile /etc/pki/tls/certs/localhost.crt
-  SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
-  ProxyPreserveHost Off
-  RequestHeader set X_FORWARDED_PROTO 'https'
-
-  Timeout 5400
-  ProxyTimeout 5400
-
-Alias /conductor/stylesheets "/usr/share/aeolus-conductor/public/stylesheets"
-Alias /conductor/graphics "/usr/share/aeolus-conductor/public/images"
-Alias /conductor/errors "/usr/share/aeolus-conductor/public/errors"
-Alias /conductor/javascripts "/usr/share/aeolus-conductor/public/javascripts"
-Alias /fonts "/usr/share/aeolus-conductor/public/fonts"
-
-RewriteRule ^/conductor/images/(.*).(png|jpg|gif|svg)$ /conductor/graphics/$1.$2 [R]
-
-ExpiresActive on
-ExpiresByType text/css "access plus 1 year"
-ExpiresByType text/javascript "access plus 1 year"
-ExpiresByType application/javascript "access plus 1 year"
-ExpiresByType image/png "access plus 1 year"
-
-ProxyPass /conductor/graphics !
-ProxyPass /conductor/stylesheets !
-ProxyPass /conductor/errors !
-ProxyPass /conductor/javascripts !
-ProxyPass /conductor http://localhost:3000/conductor
-ProxyPassReverse /conductor http://localhost:3000/conductor
-ProxyPassReverse /conductor/graphics !
-ProxyPassReverse /conductor/stylesheets !
-ProxyPassReverse /conductor/errors !
-ProxyPassReverse /conductor/javascripts !
-
-</VirtualHost>
-
-NameVirtualHost *:80
-<VirtualHost *:80>
-  RewriteEngine On
-  RewriteCond %{HTTPS} off
-  RewriteRule /conductor(.*) https://%{HTTP_HOST}%{REQUEST_URI}
-</VirtualHost>
-
diff --git a/recipes/aeolus/files/aggregator-httpd.conf b/recipes/aeolus/files/aggregator-httpd.conf
deleted file mode 100644
index 36accad..0000000
--- a/recipes/aeolus/files/aggregator-httpd.conf
+++ /dev/null
@@ -1,41 +0,0 @@
-NameVirtualHost *:80
-<VirtualHost *:80>
-
-  ErrorLog /etc/httpd/logs/error_log
-  TransferLog /etc/httpd/logs/access_log
-  LogLevel warn
-
-  KeepAlive On
-  ProxyRequests Off
-  RewriteEngine On
-
-  Timeout 5400
-  ProxyTimeout 5400
-
-Alias /conductor/stylesheets "/usr/share/aeolus-conductor/public/stylesheets"
-Alias /conductor/graphics "/usr/share/aeolus-conductor/public/images"
-Alias /conductor/errors "/usr/share/aeolus-conductor/public/errors"
-Alias /conductor/javascripts "/usr/share/aeolus-conductor/public/javascripts"
-Alias /fonts "/usr/share/aeolus-conductor/public/fonts"
-
-RewriteRule ^/conductor/images/(.*).(png|jpg|gif|svg)$ /conductor/graphics/$1.$2 [R]
-
-ExpiresActive on
-ExpiresByType text/css "access plus 1 year"
-ExpiresByType text/javascript "access plus 1 year"
-ExpiresByType application/javascript "access plus 1 year"
-ExpiresByType image/png "access plus 1 year"
-
-ProxyPass /conductor/graphics !
-ProxyPass /conductor/stylesheets !
-ProxyPass /conductor/errors !
-ProxyPass /conductor/javascripts !
-ProxyPass /conductor http://localhost:3000/conductor
-ProxyPassReverse /conductor http://localhost:3000/conductor
-ProxyPassReverse /conductor/graphics !
-ProxyPassReverse /conductor/stylesheets !
-ProxyPassReverse /conductor/errors !
-ProxyPassReverse /conductor/javascripts !
-
-</VirtualHost>
-
diff --git a/recipes/aeolus/manifests/conductor.pp b/recipes/aeolus/manifests/conductor.pp
index 20fdfb2..5733f2d 100644
--- a/recipes/aeolus/manifests/conductor.pp
+++ b/recipes/aeolus/manifests/conductor.pp
@@ -56,9 +56,9 @@ class aeolus::conductor inherits aeolus {
   ### Setup apache for deltacloud
     include apache
     if $enable_https {
-      apache::site{"aeolus-conductor": source => 'puppet:///modules/aeolus/aggregator-httpd-ssl.conf'}
+      apache::site {"aeolus-conductor": source => 'aeolus/aggregator-httpd-ssl.conf'}
     } else{
-      apache::site{"aeolus-conductor": source => 'puppet:///modules/aeolus/aggregator-httpd.conf'}
+      apache::site {"aeolus-conductor": source => 'aeolus/aggregator-httpd.conf'}
     }
 
     service { ['aeolus-conductor',
diff --git a/recipes/aeolus/templates/aggregator-httpd-ssl.conf b/recipes/aeolus/templates/aggregator-httpd-ssl.conf
new file mode 100644
index 0000000..403f94b
--- /dev/null
+++ b/recipes/aeolus/templates/aggregator-httpd-ssl.conf
@@ -0,0 +1,54 @@
+NameVirtualHost *:443
+<VirtualHost *:443>
+
+  ErrorLog /etc/httpd/logs/error_log
+  TransferLog /etc/httpd/logs/access_log
+  LogLevel debug
+
+  KeepAlive On
+  ProxyRequests Off
+  RewriteEngine On
+  SSLEngine On
+  SSLCertificateFile /etc/pki/tls/certs/localhost.crt
+  SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
+  ProxyPreserveHost Off
+  RequestHeader set X_FORWARDED_PROTO 'https'
+
+  Timeout 5400
+  ProxyTimeout 5400
+
+Alias /conductor/stylesheets "/usr/share/aeolus-conductor/public/stylesheets"
+Alias /conductor/graphics "/usr/share/aeolus-conductor/public/images"
+Alias /conductor/errors "/usr/share/aeolus-conductor/public/errors"
+Alias /conductor/javascripts "/usr/share/aeolus-conductor/public/javascripts"
+Alias /fonts "/usr/share/aeolus-conductor/public/fonts"
+
+RewriteRule ^/conductor/images/(.*).(png|jpg|gif|svg)$ /conductor/graphics/$1.$2 [R]
+
+ExpiresActive on
+ExpiresByType text/css "access plus 1 year"
+ExpiresByType text/javascript "access plus 1 year"
+ExpiresByType application/javascript "access plus 1 year"
+ExpiresByType image/png "access plus 1 year"
+
+ProxyPass /conductor/graphics !
+ProxyPass /conductor/stylesheets !
+ProxyPass /conductor/errors !
+ProxyPass /conductor/javascripts !
+ProxyPass /conductor http://localhost:3000/conductor
+ProxyPassReverse /conductor http://localhost:3000/conductor
+ProxyPassReverse /conductor/graphics !
+ProxyPassReverse /conductor/stylesheets !
+ProxyPassReverse /conductor/errors !
+ProxyPassReverse /conductor/javascripts !
+
+Include <%= dropdir %>/*.conf
+
+</VirtualHost>
+
+NameVirtualHost *:80
+<VirtualHost *:80>
+  RewriteEngine On
+  RewriteCond %{HTTPS} off
+  RewriteRule /conductor(.*) https://%{HTTP_HOST}%{REQUEST_URI}
+</VirtualHost>
diff --git a/recipes/aeolus/templates/aggregator-httpd.conf b/recipes/aeolus/templates/aggregator-httpd.conf
new file mode 100644
index 0000000..4560771
--- /dev/null
+++ b/recipes/aeolus/templates/aggregator-httpd.conf
@@ -0,0 +1,42 @@
+NameVirtualHost *:80
+<VirtualHost *:80>
+
+  ErrorLog /etc/httpd/logs/error_log
+  TransferLog /etc/httpd/logs/access_log
+  LogLevel warn
+
+  KeepAlive On
+  ProxyRequests Off
+  RewriteEngine On
+
+  Timeout 5400
+  ProxyTimeout 5400
+
+Alias /conductor/stylesheets "/usr/share/aeolus-conductor/public/stylesheets"
+Alias /conductor/graphics "/usr/share/aeolus-conductor/public/images"
+Alias /conductor/errors "/usr/share/aeolus-conductor/public/errors"
+Alias /conductor/javascripts "/usr/share/aeolus-conductor/public/javascripts"
+Alias /fonts "/usr/share/aeolus-conductor/public/fonts"
+
+RewriteRule ^/conductor/images/(.*).(png|jpg|gif|svg)$ /conductor/graphics/$1.$2 [R]
+
+ExpiresActive on
+ExpiresByType text/css "access plus 1 year"
+ExpiresByType text/javascript "access plus 1 year"
+ExpiresByType application/javascript "access plus 1 year"
+ExpiresByType image/png "access plus 1 year"
+
+ProxyPass /conductor/graphics !
+ProxyPass /conductor/stylesheets !
+ProxyPass /conductor/errors !
+ProxyPass /conductor/javascripts !
+ProxyPass /conductor http://localhost:3000/conductor
+ProxyPassReverse /conductor http://localhost:3000/conductor
+ProxyPassReverse /conductor/graphics !
+ProxyPassReverse /conductor/stylesheets !
+ProxyPassReverse /conductor/errors !
+ProxyPassReverse /conductor/javascripts !
+
+Include <%= dropdir %>/*.conf
+
+</VirtualHost>
diff --git a/recipes/apache/manifests/init.pp b/recipes/apache/manifests/init.pp
index 91f12a4..7aaa380 100644
--- a/recipes/apache/manifests/init.pp
+++ b/recipes/apache/manifests/init.pp
@@ -45,5 +45,3 @@ class apache {
 	  refreshonly => true,
   }
 }
-
-
diff --git a/recipes/apache/manifests/site.pp b/recipes/apache/manifests/site.pp
index ca534e1..1df7b97 100644
--- a/recipes/apache/manifests/site.pp
+++ b/recipes/apache/manifests/site.pp
@@ -1,13 +1,25 @@
-define apache::site ( $ensure = 'present', $source = '') {
-  $apache_dir          = "/etc/httpd"
-  $apache_conf_dir     = "${apache_dir}/conf.d"
+## Creates apache configs with optional drop files
+define apache::site ($ensure = 'present', $source = '') {
+    $apache_dir          = "/etc/httpd"
+    $apache_conf_dir     = "${apache_dir}/conf.d"
+    $site                = "${apache_conf_dir}/${name}"
+    $dropdir             = "${site}.d"
 
-	$site_file = "${apache_conf_dir}/${name}.conf"
-	file {
-		$site_file:
-			ensure  => $ensure,
-			source  => $source,
-			notify  => Exec["reload-apache"],
-      require => Service['httpd']
+    $drop_dir_ensure = $ensure ? {
+        "absent"    => "absent",
+        default     => directory
+    }
+    file { $dropdir:
+        ensure => $drop_dir_ensure,
+        notify => Exec["reload-apache"],
+    }
+
+    # create the apache configuration with references to the created dropfiles
+	$site_file = "${site}.conf"
+	file { $site_file:
+        ensure  => $ensure,
+        content => template($source),
+        notify  => Exec["reload-apache"],
+        require => [ Service['httpd'], File[$dropdir] ]
 	}
 }
-- 
1.7.7.4




More information about the aeolus-devel mailing list