jenkins-bot has submitted this change and it was merged.

Change subject: Add apache::conf Puppet class
......................................................................


Add apache::conf Puppet class

Adds a Puppet class that that can be used to manage per-site Apache
configuration snippets. Snippets are stored in /etc/apache2/site.d and
are organized by site name.

Change-Id: I7786f096abaaa620f005858c3f57de8f05391d9a
---
D puppet/modules/apache/files/disable-sendfile
A puppet/modules/apache/manifests/conf.pp
M puppet/modules/apache/manifests/init.pp
M puppet/modules/apache/manifests/site.pp
A puppet/modules/apache/templates/site.conf.erb
5 files changed, 90 insertions(+), 14 deletions(-)

Approvals:
  Ori.livneh: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/puppet/modules/apache/files/disable-sendfile 
b/puppet/modules/apache/files/disable-sendfile
deleted file mode 100644
index d514368..0000000
--- a/puppet/modules/apache/files/disable-sendfile
+++ /dev/null
@@ -1,3 +0,0 @@
-# Sendfile must be disabled due to a bug in Vagrant.
-# See <https://github.com/mitchellh/vagrant/issues/351>.
-EnableSendfile Off
diff --git a/puppet/modules/apache/manifests/conf.pp 
b/puppet/modules/apache/manifests/conf.pp
new file mode 100644
index 0000000..2a51a96
--- /dev/null
+++ b/puppet/modules/apache/manifests/conf.pp
@@ -0,0 +1,51 @@
+# == Define: apache::conf
+#
+# This resource type represents a collection of Apache configuration
+# directives. Directives may be global or scoped to a particular site.
+#
+# === Parameters
+#
+# [*content*]
+#   String containing Apache configuration directives. Either this or
+#   'source' must be specified. Undefined by default.
+#
+# [*source*]
+#   Path to file containing Apache configuration directives. Either this
+#   or 'content' must be specified. Undefined by default.
+#
+# [*site*]
+#   If set, the configuration will be scoped to a particular Apache
+#   site, specified by name. If undefined (the default), configuration
+#   will apply globally.
+#
+# === Example
+#
+# Configure the default site to use UTF-8 as the default charset:
+#
+#   apache::conf { 'default charset':
+#     site    => 'default',
+#     content => 'AddDefaultCharset utf-8',
+#   }
+#
+define apache::conf(
+    $ensure   = present,
+    $site     = undef,
+    $content  = undef,
+    $source   = undef,
+) {
+    include apache
+
+    $config_dir = $site ? {
+        undef   => '/etc/apache2/conf.d',         # global
+        default => "/etc/apache2/site.d/${site}"  # site-specific
+    }
+    $config_file = inline_template('<%= @title.gsub(/\W/, "-") %>')
+
+    file { "${config_dir}/${config_file}":
+        ensure  => $ensure,
+        content => $content,
+        source  => $source,
+        require => Package['apache2'],
+        notify  => Service['apache2'],
+    }
+}
diff --git a/puppet/modules/apache/manifests/init.pp 
b/puppet/modules/apache/manifests/init.pp
index 675c470..396a11f 100644
--- a/puppet/modules/apache/manifests/init.pp
+++ b/puppet/modules/apache/manifests/init.pp
@@ -19,10 +19,12 @@
 
     # Set EnableSendfile to 'Off' to work around a bug with Vagrant.
     # See <https://github.com/mitchellh/vagrant/issues/351>.
-    file { '/etc/apache2/conf.d/disable-sendfile':
-        source  => 'puppet:///modules/apache/disable-sendfile',
-        require => Package['apache2'],
-        notify  => Service['apache2'],
+    apache::conf { 'disable sendfile':
+        content => 'EnableSendfile Off',
+    }
+
+    file { '/etc/apache2/site.d':
+        ensure => directory,
     }
 
     service { 'apache2':
@@ -33,5 +35,6 @@
     }
 
      Apache::Mod <| |>
+     Apache::Conf <| |>
      Apache::Site <| |>
 }
diff --git a/puppet/modules/apache/manifests/site.pp 
b/puppet/modules/apache/manifests/site.pp
index 0c6bca0..1a13673 100644
--- a/puppet/modules/apache/manifests/site.pp
+++ b/puppet/modules/apache/manifests/site.pp
@@ -16,6 +16,10 @@
 #   If defined, will be used as the content of the site configuration
 #   file. Undefined by default.
 #
+# [*source*]
+#   Path to file containing configuration directives. Undefined by
+#   default.
+#
 # === Examples
 #
 #  apache::site { 'wiki':
@@ -27,6 +31,7 @@
     $ensure  = 'present',
     $site    = $title,
     $content = undef,
+    $source  = undef,
 ) {
     include apache
 
@@ -38,14 +43,28 @@
 
     case $ensure {
         present: {
-            if ( $content ) {
-                file { "/etc/apache2/sites-available/${site_file}":
-                    ensure  => file,
-                    content => $content,
-                    require => Package['apache2'],
-                    before  => Exec["enable ${site}"],
-                }
+            file { "/etc/apache2/site.d/${site}":
+                ensure  => directory,
+                recurse => true,
+                purge   => true,
+                force   => true,
+                before  => File["/etc/apache2/sites-available/${site_file}"],
             }
+
+            apache::conf { $site:
+                ensure  => $ensure,
+                site    => $site,
+                content => $content,
+                source  => $source,
+            }
+
+            file { "/etc/apache2/sites-available/${site_file}":
+                ensure  => file,
+                content => template('apache/site.conf.erb'),
+                require => Package['apache2'],
+                before  => Exec["enable ${site}"],
+            }
+
             exec { "enable ${title}":
                 command => "a2ensite -qf ${site}",
                 unless  => "test -L /etc/apache2/sites-enabled/${site_file}",
diff --git a/puppet/modules/apache/templates/site.conf.erb 
b/puppet/modules/apache/templates/site.conf.erb
new file mode 100644
index 0000000..0cfeca8
--- /dev/null
+++ b/puppet/modules/apache/templates/site.conf.erb
@@ -0,0 +1,6 @@
+# vim: filetype=apache sts=4 sw=4 autoindent
+#
+# Apache site configuration for <%= @site %>
+# This file is managed by Puppet.
+#
+Include site.d/<%= @site %>

-- 
To view, visit https://gerrit.wikimedia.org/r/78401
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I7786f096abaaa620f005858c3f57de8f05391d9a
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/vagrant
Gerrit-Branch: master
Gerrit-Owner: BryanDavis <[email protected]>
Gerrit-Reviewer: BryanDavis <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to