Puppet Class: varnishkafka

Defined in:
modules/varnishkafka/manifests/init.pp

Overview

Class varnishkafka

Configures and runs varnishkafka Varnish to Kafka producer. See: github.com/wikimedia/varnishkafka



5
6
7
8
9
10
11
12
13
14
15
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
# File 'modules/varnishkafka/manifests/init.pp', line 5

class varnishkafka {
    package { 'varnishkafka':
        ensure => present,
    }

    file { '/etc/varnishkafka':
        ensure  => directory,
        owner   => 'root',
        group   => 'root',
        mode    => '0444',
        recurse => true,
        purge   => true,
        force   => true,
    }

    # Don't use the init script provided by the package, because it precludes
    # running multiple instances.

    file { '/var/cache/varnishkafka':
        ensure  => directory,
        owner   => 'varnishlog',
        group   => 'varnish',
        mode    => '0755',
        require => Package['varnishkafka'],
    }

    # Basic rsyslog.d configuration to create /var/log/varnishkafka.log
    if defined(Service['rsyslog']) {
        file { '/etc/rsyslog.d/70-varnishkafka.conf':
            owner  => 'root',
            group  => 'root',
            mode   => '0444',
            source => 'puppet:///modules/varnishkafka/varnishkafka_rsyslog.conf',
            notify =>  Service['rsyslog']
        }
    }

    # Since we are doing per instance stats.json files, the logrotate
    # config that comes with the varnishkafka instance is not sufficient.
    # This file will rotate only the daemon log file at /var/log/varnishkafka.log
    # varnishkafka::instance will take care of installing a logrotate file for
    # the per-instance stats.json file.
    file { '/etc/logrotate.d/varnishkafka':
        owner  => 'root',
        group  => 'root',
        mode   => '0444',
        source => 'puppet:///modules/varnishkafka/varnishkafka_logrotate'
    }

    # Managing the varnishkafka service via its init script requires that the
    # init script be present and that the default file mark the service as
    # enabled. Invoking start-stop-daemon directly allows us to manage the
    # service without having a tricky ordering dependency on those two
    # resources.

    exec { 'stop-varnishkafka-service':
        command   => '/sbin/start-stop-daemon --stop --pidfile /var/run/varnishkafka/varnishkafka.pid --exec /usr/bin/varnishkafka',
        onlyif    => '/sbin/start-stop-daemon --status --pidfile /var/run/varnishkafka/varnishkafka.pid --exec /usr/bin/varnishkafka',
        subscribe => Package['varnishkafka'],
    }

    file { '/etc/init.d/varnishkafka':
        ensure    => absent,
        subscribe => Package['varnishkafka'],
    }

    file { '/etc/default/varnishkafka':
        ensure    => absent,
        subscribe => Package['varnishkafka'],
    }
}