20after4 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/345617 )

Change subject: Phab: User base:service_unit for aphlict
......................................................................

Phab: User base:service_unit for aphlict

This should be nearly ready run in production.

Bug: T112765
Change-Id: Idf788704f4bf083fab5834563ef329b973dc74fe
---
M modules/phabricator/manifests/aphlict.pp
D modules/phabricator/templates/aphlict-upstart.conf.erb
D modules/phabricator/templates/aphlict.service.erb
A modules/phabricator/templates/initscripts/aphlict.systemd.erb
A modules/phabricator/templates/initscripts/aphlict.upstart.erb
5 files changed, 50 insertions(+), 65 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/17/345617/1

diff --git a/modules/phabricator/manifests/aphlict.pp 
b/modules/phabricator/manifests/aphlict.pp
index c5ac86a..881db01 100644
--- a/modules/phabricator/manifests/aphlict.pp
+++ b/modules/phabricator/manifests/aphlict.pp
@@ -26,11 +26,11 @@
     File[$node_modules] ~> Service['aphlict']
 
     if $ensure == 'present' {
-        $link = 'link'
         $directory = 'directory'
+        $service_ensure = 'running'
     } else {
-        $link = 'absent'
         $directory = 'absent'
+        $service_ensure = 'stopped'
     }
 
 
@@ -46,34 +46,6 @@
         owner   => $user,
         group   => $group,
         mode    => '0644',
-    }
-
-    if $::initsystem == 'upstart' {
-        # upstart init conf file
-        $init_file = '/etc/init/aphlict.conf'
-        $init_source = 'aphlict-upstart.conf.erb'
-    } else {
-        # systemd service unit
-        $init_file = '/etc/systemd/system/aphlict.service'
-        $init_source = 'aphlict.service.erb'
-    }
-
-    file { '/etc/init.d/aphlict':
-        ensure => $link,
-        target => "${phabdir}/bin/aphlict",
-    }
-
-    file { $init_file:
-        content => template("phabricator/${init_source}"),
-        mode    => '0644',
-        owner   => 'root',
-        group   => 'root',
-    }
-
-    service { 'aphlict':
-        ensure     => running,
-        provider   => $::initsystem,
-        hasrestart => true,
     }
 
     file { '/var/run/aphlict/':
@@ -101,10 +73,23 @@
     }
 
     user { $user:
-        gid    => 'aphlict',
+        gid    => $group,
         shell  => '/bin/false',
         home   => '/var/run/aphlict',
         system => true,
     }
 
+    base::service_unit { 'aphlict':
+        ensure         => $ensure,
+        systemd        => true,
+        upstart        => true,
+        sysvinit       => false,
+        require        => User[$user],
+        service_params => {
+            ensure     => $service_ensure,
+            provider   => $::initsystem,
+            hasrestart => false,
+        },
+    }
+
 }
diff --git a/modules/phabricator/templates/aphlict-upstart.conf.erb 
b/modules/phabricator/templates/aphlict-upstart.conf.erb
deleted file mode 100644
index aabd55b..0000000
--- a/modules/phabricator/templates/aphlict-upstart.conf.erb
+++ /dev/null
@@ -1,19 +0,0 @@
-# aphlict - Phabricator notification server
-#
-# Routes real-time notifications to websocket clients
-
-description "Phabricator notification websocket server"
-
-setuid <%= @user %>
-setgid <%= @group %>
-
-start on runlevel [2345]
-stop on runlevel [!2345]
-
-respawn
-respawn limit 10 5
-umask 022
-
-expect stop
-
-exec <%= @aphlict_cmd %>
diff --git a/modules/phabricator/templates/aphlict.service.erb 
b/modules/phabricator/templates/aphlict.service.erb
deleted file mode 100644
index b02dbbc..0000000
--- a/modules/phabricator/templates/aphlict.service.erb
+++ /dev/null
@@ -1,15 +0,0 @@
-[Unit]
-Description=Aphlict - Phabricator notification service
-After=network.target auditd.service
-
-[Service]
-User=<%= @user %>
-Group=<%= @group %>
-ExecStart=<%= @aphlict_cmd %>
-ExecReload=/bin/kill -HUP $MAINPID
-KillMode=process
-Restart=on-failure
-
-[Install]
-WantedBy=multi-user.target
-Alias=aphlict.service
diff --git a/modules/phabricator/templates/initscripts/aphlict.systemd.erb 
b/modules/phabricator/templates/initscripts/aphlict.systemd.erb
new file mode 100644
index 0000000..81dccb0
--- /dev/null
+++ b/modules/phabricator/templates/initscripts/aphlict.systemd.erb
@@ -0,0 +1,15 @@
+[Unit]
+Description=Aphlict - Phabricator notification service
+After=network.target auditd.service
+
+[Service]
+User=<%= scope.lookupvar('phabricator::aphlict::user') %>
+Group=<%= scope.lookupvar('phabricator::aphlict::group') %>
+ExecStart=<%= scope.lookupvar('phabricator::aphlict::aphlict_cmd') %>
+ExecReload=/bin/kill -HUP $MAINPID
+KillMode=process
+Restart=on-failure
+
+[Install]
+WantedBy=multi-user.target
+Alias=aphlict.service
diff --git a/modules/phabricator/templates/initscripts/aphlict.upstart.erb 
b/modules/phabricator/templates/initscripts/aphlict.upstart.erb
new file mode 100644
index 0000000..109fd67
--- /dev/null
+++ b/modules/phabricator/templates/initscripts/aphlict.upstart.erb
@@ -0,0 +1,19 @@
+# aphlict - Phabricator notification server
+#
+# Routes real-time notifications to websocket clients
+
+description "Phabricator notification websocket server"
+
+setuid <%= scope.lookupvar('phabricator::aphlict::user') %>
+setgid <%= scope.lookupvar('phabricator::aphlict::group') %>
+
+start on runlevel [2345]
+stop on runlevel [!2345]
+
+respawn
+respawn limit 10 5
+umask 022
+
+expect stop
+
+exec <%= scope.lookupvar('phabricator::aphlict::aphlict_cmd') %>

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

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

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

Reply via email to