BBlack has uploaded a new change for review.

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

Change subject: varnish systemd service stuff
......................................................................

varnish systemd service stuff

Change-Id: I459ea096e260b49037bf934ff9d63ef7372c7120
---
M modules/varnish/manifests/instance.pp
A modules/varnish/templates/varnish.service.erb
2 files changed, 86 insertions(+), 32 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/85/186085/1

diff --git a/modules/varnish/manifests/instance.pp 
b/modules/varnish/manifests/instance.pp
index ed77ba7..e6363ad 100644
--- a/modules/varnish/manifests/instance.pp
+++ b/modules/varnish/manifests/instance.pp
@@ -47,25 +47,6 @@
         before => Service["varnish${instancesuffix}"]
     }
 
-    file { "/etc/init.d/varnish${instancesuffix}":
-        owner   => 'root',
-        group   => 'root',
-        mode    => '0555',
-        content => template("${module_name}/varnish.init.erb"),
-    }
-    file { "/etc/default/varnish${instancesuffix}":
-        owner   => 'root',
-        group   => 'root',
-        mode    => '0444',
-        content => template("${module_name}/varnish-default.erb"),
-    }
-    file { "/etc/varnish/${vcl}.inc.vcl":
-        owner   => 'root',
-        group   => 'root',
-        mode    => '0444',
-        content => template("varnish/${vcl}.inc.vcl.erb"),
-        notify  => Exec["load-new-vcl-file${instancesuffix}"],
-    }
     file { "/etc/varnish/wikimedia_${vcl}.vcl":
         owner   => 'root',
         group   => 'root',
@@ -74,19 +55,66 @@
         content => template("${module_name}/vcl/wikimedia.vcl.erb"),
     }
 
-    service { "varnish${instancesuffix}":
-        ensure    => running,
-        require   => [
-                File["/etc/default/varnish${instancesuffix}"],
-                File["/etc/init.d/varnish${instancesuffix}"],
-                File["/etc/varnish/${vcl}.inc.vcl"],
-                File["/etc/varnish/wikimedia_${vcl}.vcl"],
-                Mount['/var/lib/varnish']
-            ],
-        hasstatus => false,
-        pattern   => "/var/run/varnishd${instancesuffix}.pid",
-        subscribe => Package['varnish'],
-        tag       => 'varnish_instance'
+    file { "/etc/varnish/${vcl}.inc.vcl":
+        owner   => 'root',
+        group   => 'root',
+        mode    => '0444',
+        content => template("varnish/${vcl}.inc.vcl.erb"),
+        notify  => Exec["load-new-vcl-file${instancesuffix}"],
+    }
+
+    case $::initsystem {
+        'upstart': {
+            file { "/etc/init.d/varnish${instancesuffix}":
+                owner   => 'root',
+                group   => 'root',
+                mode    => '0555',
+                content => template("${module_name}/varnish.init.erb"),
+            }
+            file { "/etc/default/varnish${instancesuffix}":
+                owner   => 'root',
+                group   => 'root',
+                mode    => '0444',
+                content => template("${module_name}/varnish-default.erb"),
+            }
+            service { "varnish${instancesuffix}":
+                ensure    => running,
+                require   => [
+                        File["/etc/default/varnish${instancesuffix}"],
+                        File["/etc/init.d/varnish${instancesuffix}"],
+                        File["/etc/varnish/${vcl}.inc.vcl"],
+                        File["/etc/varnish/wikimedia_${vcl}.vcl"],
+                        Mount['/var/lib/varnish']
+                    ],
+                hasstatus => false,
+                pattern   => "/var/run/varnishd${instancesuffix}.pid",
+                subscribe => Package['varnish'],
+                tag       => 'varnish_instance'
+            }
+        }
+        'systemd': {
+            file { "/etc/systemd/system/varnish${instancesuffix}.service":
+                owner   => 'root',
+                group   => 'root',
+                mode    => '0444',
+                content => template("${module_name}/varnish.service.erb"),
+            }
+            service { "varnish${instancesuffix}":
+                provider => 'systemd',
+                ensure    => running,
+                require   => [
+                        
File["/etc/systemd/system/varnish${instancesuffix}.service"],
+                        File["/etc/varnish/${vcl}.inc.vcl"],
+                        File["/etc/varnish/wikimedia_${vcl}.vcl"],
+                        Mount['/var/lib/varnish']
+                    ],
+                subscribe => Package['varnish'],
+                tag       => 'varnish_instance'
+            }
+        }
+        default: {
+            fail('varnish::instance does not like your init system!')
+        }
     }
 
     # This mechanism with the touch/rm conditionals in the pair of execs
diff --git a/modules/varnish/templates/varnish.service.erb 
b/modules/varnish/templates/varnish.service.erb
new file mode 100644
index 0000000..452e851
--- /dev/null
+++ b/modules/varnish/templates/varnish.service.erb
@@ -0,0 +1,26 @@
+[Unit]
+Description=%p (Varnish HTTP Accelerator)
+
+[Service]
+Type=forking
+LimitNOFILE=500000
+LimitMEMLOCK=90000
+PidFile=%t/%p.pid
+ExecReload=/usr/share/varnish/reload-vcl <%= @extraopts %> -q
+ExecStart=/usr/sbin/varnishd \
+-P %t/%p.pid \
+-a :<%= @varnish_port -%> \
+-T 127.0.0.1:<%= @varnish_admin_port -%> \
+-f /etc/varnish/wikimedia_<%= @vcl -%>.vcl \
+-w <%= 250 -%>,<%= @processorcount.to_i * 250 -%>,120 \
+-S /etc/varnish/secret \
+<%= @varnish_storage -%> \
+-p user=varnish -p thread_pool_add_delay=1 -p thread_pool_stack=131072 \
+-p listen_depth=4096 -p session_max=200000 -p vcc_err_unref=off \
+-p nuke_limit=300 -p shm_reclen=1024 \
+<%= @runtime_params -%> \
+<%= @extraopts -%> \
+<% if @cluster_options.fetch("enable_geoiplookup", false) -%>-p 
'cc_command=\"exec cc -fpic -shared -Wl,-x -L/usr/local/lib/ -o %%o %%s 
-lGeoIP\"'<% end %>
+
+[Install]
+WantedBy=multi-user.target

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I459ea096e260b49037bf934ff9d63ef7372c7120
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: BBlack <[email protected]>

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

Reply via email to