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.

TODO: Remove the default values after we drop support for Puppet 4.7.

Parameters:

  • servers (Array[Phabricator::Aphlict::Server]) (defaults to: [ { listen => '0.0.0.0', port => 22280, type => 'client', }, { listen => '127.0.0.1', port => 22281, type => 'admin', }, ])

    A list of servers to start. See Running the Aphlict Server.

  • peers (Array[Phabricator::Aphlict::Peer]) (defaults to: [])

    A list of cluster peers. See Configuring Aphlict.

  • user (String) (defaults to: 'aphlict')


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
116
117
118
119
120
121
122
123
124
125
# File 'manifests/aphlict.pp', line 18

class phabricator::aphlict(
  Array[Phabricator::Aphlict::Server] $servers = [
    {
      listen => '0.0.0.0',
      port   => 22280,
      type   => 'client',
    },
    {
      listen => '127.0.0.1',
      port   => 22281,
      type   => 'admin',
    },
  ],
  Array[Phabricator::Aphlict::Peer] $peers = [],
  String $user = 'aphlict',
) {
  $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,
    }),
    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   => [
      Exec['systemctl-daemon-reload'],
      File[$phabricator::logs_dir],
      File[$phabricator::pid_dir],
      Group[$phabricator::group],
      User[$user],
    ],
    subscribe => [
      Class['nodejs::install'],
      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_owner      => 'root',
    su_group      => $phabricator::group,
  }
}