Ori.livneh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/108470


Change subject: Add apache::env
......................................................................

Add apache::env

The shell environment defined by /etc/apache2/envvars defines the shell
environment in which the Apache process is spawned. It can be used to define
runtime parameters that can be referenced in Apache configuration files via
<IfDefine> directives. This patch adds a call to /etc/apache2/envvars to source
all scripts in /etc/apache2/env.d, which is recursively managed by Puppet.
A custom resource, apache::env, can be used to plop shell fragments in that
directory.

Change-Id: I3b387fe6c1a7af926f0c8a91b11e6634feb3a8b6
---
A puppet/modules/apache/files/env.d-empty/README
A puppet/modules/apache/manifests/env.pp
M puppet/modules/apache/manifests/init.pp
3 files changed, 66 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/vagrant 
refs/changes/70/108470/1

diff --git a/puppet/modules/apache/files/env.d-empty/README 
b/puppet/modules/apache/files/env.d-empty/README
new file mode 100644
index 0000000..4a64985
--- /dev/null
+++ b/puppet/modules/apache/files/env.d-empty/README
@@ -0,0 +1,6 @@
+# This directory contains shell scripts that augment or modify the
+# apache2 process environment. Each file in this directory must be a
+# valid shell script.
+#
+# This directory is managed recursively by Puppet; any local
+# modifications will be clobbered on the next Puppet run.
diff --git a/puppet/modules/apache/manifests/env.pp 
b/puppet/modules/apache/manifests/env.pp
new file mode 100644
index 0000000..73e33f6
--- /dev/null
+++ b/puppet/modules/apache/manifests/env.pp
@@ -0,0 +1,45 @@
+# == Define: apache::env
+#
+# This resource provides an easy way to extend Apache's environment.
+# It will create a file in /etc/apache2/env.d that will be loaded by
+# Apache's init script and that can therefore define environment
+# variables and additional command-line arguments.
+#
+# === Parameters
+#
+# [*ensure*]
+#   If 'present', environment file will be created; if 'absent',
+#   deleted. The default is 'present'.
+#
+# [*content*]
+#   If defined, will be used as the content of the environment file.
+#   Undefined by default. Either this or 'source' must be set.
+#
+# [*source*]
+#   Path to file containing environment declarations. Undefined by
+#   default. Either this or 'content' must be set.
+#
+# === Examples
+#
+#  Creates an Apache environment file that defines a runtime parameter
+#  (via the -D command-line option). You can branch on its presence
+#  via <IfDefine> directives:
+#
+#  apache::env { 'hhvm':
+#    ensure  => present,
+#    content => 'export APACHE_ARGUMENTS="$APACHE_ARGUMENTS -D HHVM"'
+#  }
+#
+define apache::env(
+    $ensure  = present,
+    $content = undef,
+    $source  = undef,
+) {
+    file { "/etc/apache2/env.d/${title}":
+        ensure  => $ensure,
+        content => $content,
+        source  => $source,
+        require => Exec['setup apache env.d'],
+        notify  => Service['apache2'],
+    }
+}
diff --git a/puppet/modules/apache/manifests/init.pp 
b/puppet/modules/apache/manifests/init.pp
index cd96d06..74f0591 100644
--- a/puppet/modules/apache/manifests/init.pp
+++ b/puppet/modules/apache/manifests/init.pp
@@ -28,6 +28,21 @@
         require => Package['apache2'],
     }
 
+    file { '/etc/apache2/env.d':
+        ensure  => directory,
+        recurse => true,
+        purge   => true,
+        force   => true,
+        source  => 'puppet:///modules/apache/env.d-empty',
+        require => Package['apache2'],
+    }
+
+    exec { 'setup apache env.d':
+        command => 'echo \'for envfile in ${APACHE_CONFDIR}/env.d/*; do . 
$envfile; done\' >>>/etc/apache2/envvars',
+        unless  => 'grep -q env.d /etc/apache2/envvars',
+        require => File['/etc/apache2/env.d'],
+    }
+
     service { 'apache2':
         ensure     => running,
         enable     => true,

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3b387fe6c1a7af926f0c8a91b11e6634feb3a8b6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/vagrant
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <o...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to