Puppet Class: matomo

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

Overview

Class: matomo

Matomo (formerly Piwik) is an open-source analytics platform.

matomo.org/

Matomo's installation is meant to be executed manually using its UI, to initialize the database and generate the related config file. Therefore each new deployment from scratch will require some manual work, please keep it mind.

Misc: Q: Where did the deb package come from? A: debian.piwik.org, imported to jessie-wikimedia.

Parameters:

  • database_host (Any) (defaults to: 'localhost')
  • database_password (Any) (defaults to: undef)
  • database_username (Any) (defaults to: 'piwik')
  • admin_username (Any) (defaults to: undef)
  • admin_password (Any) (defaults to: undef)
  • password_salt (Any) (defaults to: undef)
  • trusted_hosts (Any) (defaults to: [])
  • piwik_username (Any) (defaults to: 'www-data')
  • archive_cron_url (Any) (defaults to: undef)
  • archive_cron_email (Any) (defaults to: undef)


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
# File 'modules/matomo/manifests/init.pp', line 16

class matomo (
    $database_host      = 'localhost',
    $database_password  = undef,
    $database_username  = 'piwik',
    $admin_username     = undef,
    $admin_password     = undef,
    $password_salt      = undef,
    $trusted_hosts      = [],
    $piwik_username     = 'www-data',
    $archive_cron_url   = undef,
    $archive_cron_email = undef,
) {

    apt::package_from_component { 'matomo':
        component => 'thirdparty/matomo',
        packages  => ['matomo'],
    }

    $database_name = 'piwik'
    $database_table_prefix = 'piwik_'
    $proxy_client_headers = ['HTTP_X_FORWARDED_FOR']

    file { '/etc/matomo/config.ini.php':
        ensure  => present,
        content => template('matomo/config.ini.php.erb'),
        owner   => $piwik_username,
        group   => $piwik_username,
        mode    => '0750',
        require => Package['matomo'],
    }

    file { '/var/log/matomo':
        ensure  => 'directory',
        owner   => $piwik_username,
        group   => $piwik_username,
        mode    => '0755',
        require => Package['matomo'],
    }

    # Install a cronjob to run the Archive task periodically
    # (not user triggered to avoid unexpected performance hits)
    # Running it once a day to avoid performance penalties on high
    # trafficated websites (https://piwik.org/docs/setup-auto-archiving/#important-tips-for-medium-to-high-traffic-websites)
    if $archive_cron_url and $archive_cron_email {
        $cmd = "[ -e /usr/share/matomo/console ] && [ -x /usr/bin/php ] && nice /usr/bin/php /usr/share/matomo/console core:archive --url=\"${archive_cron_url}\" >> /var/log/matomo/matomo-archive.log"
        cron { 'matomo_archiver':
            command     => $cmd,
            user        => $piwik_username,
            environment => "MAILTO=${archive_cron_email}",
            hour        => '*/8',
            minute      => '0',
            month       => '*',
            monthday    => '*',
            weekday     => '*',
            require     => File['/var/log/matomo'],
        }
    }
}