BryanDavis has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/404908 )

Change subject: service::node: Use epp template for systemd service
......................................................................

service::node: Use epp template for systemd service

Pass epp_template => true to systemd::service along with a collection of
template_variables so that local scope data can propagate to the final
systemd unit.

Bug: T185113
Change-Id: Ic610df4fe05f3cb832fd66bcc398d0b48917b919
---
M puppet/modules/service/manifests/node.pp
A puppet/modules/service/templates/systemd/node.epp
D puppet/modules/service/templates/systemd/node.erb
3 files changed, 34 insertions(+), 26 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/vagrant 
refs/changes/08/404908/1

diff --git a/puppet/modules/service/manifests/node.pp 
b/puppet/modules/service/manifests/node.pp
index 7c95493..2658f2a 100644
--- a/puppet/modules/service/manifests/node.pp
+++ b/puppet/modules/service/manifests/node.pp
@@ -152,13 +152,21 @@
 
     # the service definition
     systemd::service { $title:
-        template_name  => 'node',
-        service_params => {
+        template_name      => 'node',
+        service_params     => {
             subscribe => [
                 File["${title}_config_yaml"],
                 Npm::Install[$dir],
             ],
         },
-        require        => Git::Clone[$title],
+        epp_template       => true,
+        template_variables => {
+            title   => $title,
+            uptitle => inline_template('<%= @title.gsub(/[^a-zA-Z0-9_]/, 
"_").upcase %>'),
+            dir     => $dir,
+            port    => $port,
+            script  => $script,
+        },
+        require            => Git::Clone[$title],
     }
 }
diff --git a/puppet/modules/service/templates/systemd/node.epp 
b/puppet/modules/service/templates/systemd/node.epp
new file mode 100644
index 0000000..f210308
--- /dev/null
+++ b/puppet/modules/service/templates/systemd/node.epp
@@ -0,0 +1,23 @@
+# NOTE: This file is managed by Puppet
+# Systemd unit for <%= $title %>
+[Unit]
+Description="<%= $title %> service"
+After=network.target
+
+[Service]
+# up ulimit -n a bit
+LimitNOFILE=10000
+User=www-data
+Group=www-data
+Environment="NODE_PATH=<%= $dir %>/node_modules"
+Environment="<%= $uptitle %>_PORT=<%= $port %>"
+Restart=always
+RestartSec=2s
+# wait 60 seconds for a graceful restart before killing the master
+TimeoutStopSec=60
+WorkingDirectory=<%= $dir %>
+ExecStart=/usr/bin/nodejs <%= $script %> -c <%= $dir %>/config.vagrant.yaml
+
+[Install]
+WantedBy=multi-user.target
+
diff --git a/puppet/modules/service/templates/systemd/node.erb 
b/puppet/modules/service/templates/systemd/node.erb
deleted file mode 100644
index 009a85b..0000000
--- a/puppet/modules/service/templates/systemd/node.erb
+++ /dev/null
@@ -1,23 +0,0 @@
-# NOTE: This file is managed by Puppet
-# Systemd unit for <%= @title %>
-[Unit]
-Description="<%= @title %> service"
-After=network.target
-
-[Service]
-# up ulimit -n a bit
-LimitNOFILE=10000
-User=www-data
-Group=www-data
-Environment="NODE_PATH=<%= @dir %>/node_modules"
-Environment="<%= @title.gsub(/[^a-zA-Z0-9_]/, '_').upcase %>_PORT=<%= @port %>"
-Restart=always
-RestartSec=2s
-# wait 60 seconds for a graceful restart before killing the master
-TimeoutStopSec=60
-WorkingDirectory=<%= @dir %>
-ExecStart=/usr/bin/nodejs <%= @script %> -c <%= @dir %>/config.vagrant.yaml
-
-[Install]
-WantedBy=multi-user.target
-

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic610df4fe05f3cb832fd66bcc398d0b48917b919
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/vagrant
Gerrit-Branch: master
Gerrit-Owner: BryanDavis <bda...@wikimedia.org>

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

Reply via email to