Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 1 commit
  • 2 files changed
  • 0 comments
  • 1 contributor
May 11, 2012
Hendy Irawan Static site 42a4a1d
47  manifests/static.pp
... ...
@@ -0,0 +1,47 @@
  1
+# Define: nginx::static
  2
+#
  3
+# Create a static site config from template using parameters.
  4
+#
  5
+# Parameters :
  6
+# * ensure: typically set to "present" or "absent". Defaults to "present"
  7
+# * server_name : server_name directive (an array)
  8
+# * root : filesystem path to document root
  9
+# * listen : address/port the server listen to. Defaults to 80.
  10
+# * access_log : custom acces logs. Defaults to /var/log/nginx/$name_access.log
  11
+#
  12
+# Templates :
  13
+# * nginx/static.erb
  14
+#
  15
+# Sample Usage :
  16
+#  nginx::static { 'www.kreasiindonesia.com':
  17
+#  	 server_name  => ['www.kreasiindonesia.com', 'kreasiindonesia.com',
  18
+#                     'm.kreasiindonesia.com', 'www.m.kreasiindonesia.com',
  19
+#                     'skin.kreasiindonesia.com', 'media.kreasiindonesia.com',
  20
+#                     'js.kreasiindonesia.com',
  21
+#                     'plus.kreasiindonesia.com', 'www.plus.kreasiindonesia.com'],
  22
+#    root         => '/home/magento/www_maintenance',
  23
+#  }
  24
+define nginx::static(
  25
+  $root,
  26
+  $ensure              = 'present',
  27
+  $listen              = '80',
  28
+  $server_name         = undef,
  29
+  $access_log          = undef,
  30
+  $status              = 'redirect') {
  31
+
  32
+  $real_server_name = $server_name ? {
  33
+    undef   => $name,
  34
+    default => $server_name,
  35
+  }
  36
+
  37
+  $real_access_log = $access_log ? {
  38
+    undef   => "/var/log/nginx/${name}_access.log",
  39
+    default => $access_log,
  40
+  }
  41
+
  42
+  nginx::site { $name:
  43
+    ensure  => $ensure,
  44
+    content => template('nginx/static.erb'),
  45
+  }
  46
+}
  47
+
6  templates/static.erb
... ...
@@ -0,0 +1,6 @@
  1
+server {
  2
+    listen      <%= listen %>;
  3
+    server_name <%= real_server_name.join(' ') %>;
  4
+    access_log  <%= real_access_log %>;
  5
+    root        <%= root %>;
  6
+}

No commit comments for this range

Something went wrong with that request. Please try again.