Puppet Class: phabricator::aphlict

Defined in:
manifests/aphlict.pp

Summary

This class manages Aphlict, Phabricator's real-time notifications

Overview

Class for installing Aphlict.

service. See Notifications User Guide: Setup and Configuration.

Parameters:



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'manifests/aphlict.pp', line 16

class phabricator::aphlict(
  Array[Phabricator::Aphlict::Server] $servers,
  Array[Phabricator::Aphlict::Peer]   $peers,
  String                              $user,
) {
  $config = {
    servers => $servers,
    logs    => [
      {
        path => "${phabricator::logs_dir}/aphlict.log",
      },
    ],
    cluster => $peers,
    pidfile => "${phabricator::pid_dir}/aphlict.pid",
  }

  file { 'phabricator/conf/aphlict.json':
    ensure  => 'file',
    path    => "${phabricator::install_dir}/phabricator/conf/aphlict/aphlict.custom.json",
    owner   => 'root',
    group   => 'root',
    mode    => '0644',
    notify  => Service['aphlict'],
    require => Vcsrepo['phabricator'],

    # TODO: Use an EPP template instead of an ERB template.
    content => inline_template('<%= @config.to_json %>');
  }

  user { $user:
    ensure     => 'present',
    comment    => 'Phabricator Aphlict',
    gid        => $phabricator::group,
    home       => $phabricator::pid_dir,
    managehome => false,
    shell      => '/usr/sbin/nologin',
    system     => true,
  }

  include nodejs

  nodejs::npm { 'ws':
    ensure  => 'present',
    target  => "${phabricator::install_dir}/phabricator/support/aphlict/server",
    notify  => Service['aphlict'],
    require => Vcsrepo['phabricator'],
  }

  # TODO: The `strict_indent` check doesn't seem to work properly here. See
  # https://github.com/relud/puppet-lint-strict_indent-check/issues/11.
  #
  # lint:ignore:strict_indent
  systemd::unit_file { 'aphlict.service':
    ensure  => 'file',
    content => epp('phabricator/aphlict.systemd.epp', {
      command           => "${phabricator::install_dir}/phabricator/bin/aphlict",
      user              => $user,
      group             => $phabricator::group,
      runtime_directory => $phabricator::runtime_directory,
    }),
    notify  => Service['aphlict'],
  }
  # lint:endignore

  # TODO: Should we also specify `hasrestart => true`? According to the
  # documentation the default value is `false`, although I am somewhat
  # surprised by this.
  service { 'aphlict':
    ensure    => 'running',
    enable    => true,
    require   => [
      Class['php::cli'],
      Exec['systemctl-daemon-reload'],
      File[$phabricator::logs_dir],
      Group[$phabricator::group],
      User[$user],
      Vcsrepo['arcanist'],
    ],
    subscribe => [
      Class['nodejs::install'],
      Vcsrepo['libphutil'],
      Vcsrepo['phabricator'],
    ],
  }

  logrotate::rule { 'aphlict':
    ensure        => 'present',
    path          => "${phabricator::logs_dir}/aphlict.log",
    compress      => true,
    copytruncate  => true,
    delaycompress => true,
    ifempty       => false,
    missingok     => true,
    rotate        => 7,
    rotate_every  => 'day',
    su            => true,
    su_user       => 'root',
    su_group      => $phabricator::group,
  }
}