Puppet Class: sentry
- Defined in:
- puppet/modules/sentry/manifests/init.pp
Overview
Class: sentry
This Puppet class installs and configures a Sentry instance -an error aggregator and dashboard which can be used to view and organize MediaWiki PHP and JS errors.
Sentry is installed as a Python package, and as part of that, pip compiles lxml. This is memory-intensive; you might have to increase the memory available to the VM with something like 'vagrant config vagrant_ram 2048; vagrant reload'.
Parameters
- db_name
-
Logical MySQL database name (example: 'sentry').
- db_user
-
MySQL user to use to connect to the database (example: 'wikidb').
- db_pass
-
Password for MySQL account (example: 'secret123').
- vhost_name
-
Hostname of the Sentry server (example: 'sentry.local.wmftest.net').
- deploy_dir
-
Path where Sentry should be installed (example: '/var/sentry').
- cfg_file
-
Sentry configuration file. Needs to end in '.py' (example: '/etc/sentry.conf.py'). The file will be generated by Puppet.
- mail_log_dir
-
Directory for logging emails which would be sent in a normal (non-vagrant) setup (example: '/vagrant/logs/sentry-mail').
- secret_key
-
The secret key required by Sentry.
- dsn_file
-
A text file which will store the DSN to the default group. Clients will need to send logs to this URL. (example: '/var/sentry/sentry_dsn.txt')
- admin_user
-
Username of the Sentry superuser. (example: 'admin')
- admin_pass
-
Password of the Sentry superuser. (example: 'vagrant')
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 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'puppet/modules/sentry/manifests/init.pp', line 50
class sentry (
$db_name,
$db_user,
$db_pass,
$vhost_name,
$deploy_dir,
$cfg_file,
$mail_log_dir,
$secret_key,
$dsn_file,
$admin_user,
$admin_pass,
) {
include ::apache
include ::apache::mod::proxy
include ::apache::mod::proxy_http
include ::apache::mod::headers
include ::php
require ::mysql
require ::virtualenv
# http://stackoverflow.com/questions/5178292/pip-install-mysql-python-fails-with-environmenterror-mysql-config-not-found
require_package('default-libmysqlclient-dev')
# needed for building the python package lxml
require_package('libxml2-dev', 'libxslt1-dev')
# needed for building the python package cffi (?)
require_package('libffi-dev')
# needed for building the python package cryptography (?)
require_package('libssl-dev')
$sentry_cli = "${deploy_dir}/bin/sentry --config='${cfg_file}'"
$sentry_create_project_script = "${deploy_dir}/bin/sentry_create_project.py"
# Use virtualenv because Sentry has lots of dependencies
virtualenv::environment { $deploy_dir:
ensure => present,
packages => [
'sentry[mysql]==7.7.0',
'raven',
],
require => Package['default-libmysqlclient-dev'],
timeout => 600, # This can take a while
}
mysql::db { $db_name:
ensure => present,
}
mysql::user { $db_user:
ensure => present,
grant => "ALL ON ${db_name}.*",
password => $db_pass,
require => Mysql::Db[$db_name],
}
apache::reverse_proxy { 'sentry':
port => 9002,
}
file { $cfg_file:
ensure => present,
group => 'www-data',
content => template('sentry/sentry.conf.py.erb'),
mode => '0640',
}
exec { 'initialize sentry database':
command => "${sentry_cli} upgrade --noinput",
user => 'www-data',
require => [
Virtualenv::Environment[$deploy_dir],
Mysql::User[$db_user],
File[$cfg_file],
],
}
file { $sentry_create_project_script:
ensure => present,
content => template('sentry/sentry_create_project.py.erb'),
mode => '0755',
require => Virtualenv::Environment[$deploy_dir],
}
# make sure www-data can write to $dsn_file
file { $dsn_file:
ensure => present,
owner => 'www-data',
mode => '0644',
}
exec { 'create sentry project':
command => "${deploy_dir}/bin/python ${sentry_create_project_script}",
user => 'www-data',
unless => "test -s \"${dsn_file}\"",
require => [
Exec['initialize sentry database'],
File[$sentry_create_project_script],
File[$dsn_file],
],
}
systemd::service { 'sentry-server':
ensure => 'present',
service_params => {
require => [
Virtualenv::Environment[$deploy_dir],
Mysql::User[$db_user],
],
subscribe => [
File[$cfg_file],
Exec['create sentry project'],
],
},
}
systemd::service { 'sentry-worker':
ensure => 'present',
service_params => {
require => [
Virtualenv::Environment[$deploy_dir],
Mysql::User[$db_user],
],
subscribe => [
File[$cfg_file],
Exec['create sentry project'],
],
},
}
}
|