Puppet Class: phabricator
- Defined in:
- puppet/modules/phabricator/manifests/init.pp
Overview
Class: phabricator
This class provisions an Apache vhost running the Phabricator application, creates the application database.
Parameters
- deploy_dir
-
Directory to clone Phabricator git repo in.
- log_dir
-
Directory phd will write logs to.
- vhost_name
-
Phabricator vhost name.
- remote
-
Phabricator git remote.
- dbuser
-
Database user
- dbpass
-
Database password
- branch
-
Phabricator branch to check out. If left undefined the default HEAD of the remote will be used.
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 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 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 |
# File 'puppet/modules/phabricator/manifests/init.pp', line 32
class phabricator(
$deploy_dir,
$log_dir,
$vhost_name,
$remote,
$dbuser,
$dbpass,
$branch = undef,
$protocol = 'http',
){
require ::arcanist
include ::apache
include ::apache::mod::rewrite
include ::mysql
include ::php
require_package(
'python-pygments',
'python-phabricator',
'php7.4-mailparse',
'php7.4-ldap'
)
php::ini { 'phab_post_max_size':
settings => [
'post_max_size = 32M'
],
}
git::clone { 'phabricator':
directory => "${deploy_dir}/phabricator",
remote => $remote,
branch => $branch,
}
service::gitupdate { 'phd':
dir => "${deploy_dir}/phabricator",
}
# Add our vhost
apache::site { $vhost_name:
ensure => present,
# Load before MediaWiki vhost for Labs where the MediaWiki wildcard
# vhost is likely to conflict with our hostname.
priority => 40,
content => template('phabricator/apache.conf.erb'),
require => Class['::apache::mod::rewrite'],
}
mysql::user { $dbuser:
password => $dbpass,
grant => 'ALL ON `phabricator\\_%`.*',
}
phabricator::config { 'mysql.host':
value => '127.0.0.1',
}
phabricator::config { 'mysql.port':
value => 3306,
}
phabricator::config { 'mysql.user':
value => $dbuser,
}
phabricator::config { 'mysql.pass':
value => $dbpass,
}
phabricator::config { 'phabricator.base-uri':
value => "${protocol}://${vhost_name}${::port_fragment}/",
}
phabricator::config { 'pygments.enabled':
value => true,
}
phabricator::config { 'phabricator.developer-mode':
value => true,
}
phabricator::config { 'storage.mysql-engine.max-size':
value => 0,
}
# HACK! set mailer config differently
$phab_dir = "${deploy_dir}/phabricator"
$conf_dir = "${phab_dir}/conf"
file { "${conf_dir}/mailers.json":
ensure => present,
owner => 'root',
group => 'root',
mode => '0600',
content => '[{"key": "test-mailer", "type": "test"}]',
}
exec { 'phab_set_cluster_mailers':
command => "${phab_dir}/bin/config set --stdin cluster.mailers < ${conf_dir}/mailers.json",
unless => "/bin/grep -q test-mailer ${conf_dir}/local/local.json",
require => File["${conf_dir}/mailers.json"],
}
group { 'phd':
ensure => present,
system => true,
}
user { 'phd':
gid => 'phd',
shell => '/bin/false',
managehome => false,
system => true,
}
file { '/home/phd':
ensure => 'directory',
owner => 'phd',
group => 'phd',
mode => '0755',
require => [
User['phd'],
Group['phd'],
],
}
phabricator::config { 'phd.user':
value => 'phd',
require => [
User['phd'],
File['/home/phd'],
],
}
# Repository hosting
file { '/var/repo':
ensure => directory,
mode => '0755',
owner => 'phd',
group => 'www-data',
}
phabricator::config { 'repository.default-local-path':
value => '/var/repo',
require => File['/var/repo'],
}
file { '/usr/local/bin/git-http-backend':
ensure => 'link',
target => '/usr/lib/git-core/git-http-backend',
require => Package['git'],
}
sudo::user { 'www-data as phd':
user => 'www-data',
privileges => [
'ALL=(phd) SETENV: NOPASSWD: /usr/bin/git, /usr/local/bin/git-http-backend',
],
require => File['/usr/local/bin/git-http-backend'],
}
phabricator::config { 'diffusion.allow-http-auth':
value => true,
}
phabricator::config { 'security.require-https':
value => false,
}
# File uploads
file { '/srv/phabfiles':
ensure => directory,
owner => 'www-data',
}
phabricator::config { 'storage.local-disk.path':
value => '/srv/phabfiles',
require => File['/srv/phabfiles'],
}
# Setup databases
exec { 'phab_setup_db':
command => "${deploy_dir}/phabricator/bin/storage upgrade --force",
require => [
Class['::mysql'],
Phabricator::Config['mysql.host'],
Phabricator::Config['mysql.user'],
Phabricator::Config['mysql.pass'],
Phabricator::Config['mysql.port'],
Mysql::User[$dbuser],
],
unless => "${deploy_dir}/phabricator/bin/storage status > /dev/null",
}
file { '/var/run/phd':
ensure => 'directory',
owner => 'phd',
group => 'phd',
mode => '0775',
}
file { $log_dir:
ensure => 'directory',
mode => '0777',
}
phabricator::config { 'phd.log-directory':
value => $log_dir,
require => File[$log_dir],
}
$phd = "${deploy_dir}/phabricator/bin/phd"
service { 'phd':
ensure => running,
enable => true,
provider => base,
binary => $phd,
start => "${phd} start",
stop => "${phd} stop",
status => "${phd} status | grep -v DEAD",
require => Exec['phab_setup_db'],
}
}
|