# Copyright 2016 Hewlett Packard Enterprise Development Company, L.P. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. # # == Class: phabricator::install # # Installation of phabricator itself. # class phabricator::install ( $phabricator_dir = $phabricator::vars::phabricator_dir, $mysql_database = $phabricator::vars::mysql_database, $mysql_host = $phabricator::vars::mysql_host, $mysql_port = $phabricator::vars::mysql_port, $mysql_user = $phabricator::vars::mysql_user, $mysql_user_password = $phabricator::vars::mysql_user_password, $httpd_vhost = $phabricator::vars::httpd_vhost, ) { # Dependencies package { [ 'php5', 'php5-mysql', 'php5-gd', 'php5-dev', 'php5-curl', 'php-apc', 'php5-cli', 'php5-json', 'sendmail', 'python-pygments']: ensure => present, } if !defined(Package['git']) { package { 'git': ensure => present } } if !defined(Package['libapache2-mod-auth-openid']) { package { 'libapache2-mod-auth-openid': ensure => present } } # Set "post_max_size" in your PHP configuration to at least 32MB to support # large file uploads. ini_setting { 'Increase post_max_size in php.ini': ensure => present, path => '/etc/php5/apache2/php.ini', section => 'PHP', setting => 'post_max_size', value => '32M', notify => Service['httpd'], } # In production, OPcache should be configured to never revalidate code. This # will slightly improve performance. To do this, disable # "opcache.validate_timestamps" in your PHP configuration. ini_setting { 'Set opcache.validate_timestamps in php.ini': ensure => present, path => '/etc/php5/apache2/php.ini', section => 'opcache', setting => 'opcache.validate_timestamps', value => '0', notify => Service['httpd'], } # PHP setting "always_populate_raw_post_data" should be set to "-1" to avoid # deprecation warnings. ini_setting { 'Disable PHP always_populate_raw_post_data on php.ini': ensure => present, path => '/etc/php5/apache2/php.ini', section => 'PHP', setting => 'always_populate_raw_post_data', value => '-1', notify => Service['httpd'], } file { [$phabricator_dir, "${phabricator_dir}/repo"]: ensure => directory, } vcsrepo { "${phabricator_dir}/phabricator": ensure => latest, provider => git, source => 'https://github.com/phacility/phabricator.git', revision => 'stable', require => [ File[$phabricator_dir], Package['git'], ] } vcsrepo { "${phabricator_dir}/arcanist": ensure => latest, provider => git, source => 'https://github.com/phacility/arcanist.git', revision => 'stable', require => [ File[$phabricator_dir], Package['git'], ] } vcsrepo { "${phabricator_dir}/libphutil": ensure => latest, provider => git, source => 'https://github.com/phacility/libphutil.git', revision => 'stable', require => [ File[$phabricator_dir], Package['git'], ] } vcsrepo { "${phabricator_dir}/libphremoteuser": ensure => latest, provider => git, source => 'https://github.com/psigen/libphremoteuser.git', revision => 'master', require => [ File[$phabricator_dir], Package['git', 'libapache2-mod-auth-openid'], ] } exec { 'Letting Phabricator know about libphremoteuser...': command => "${phabricator_dir}/phabricator/bin/config set load-libraries '[\"libphremoteuser/src\"]'", subscribe => Vcsrepo["${phabricator_dir}/libphremoteuser"], require => [ Vcsrepo["${phabricator_dir}/arcanist"], Vcsrepo["${phabricator_dir}/libphremoteuser"], ] } exec {'set-auth_providerconfig': command => "/usr/bin/mysql -u ${mysql_user} -p${mysql_user_password} < ${phabricator_dir}/set-auth_providerconfig.sql", subscribe => File['set-auth_providerconfig.sql'], require => [ Vcsrepo["${phabricator_dir}/phabricator"], File['set-auth_providerconfig.sql'], File[$phabricator_dir], Service['Phabricator-daemons'] ] } file {'set-auth_providerconfig.sql': ensure => present, path => "${phabricator_dir}/set-auth_providerconfig.sql", content => template('phabricator/set-auth_providerconfig.sql.erb'), } file { 'local.json': ensure => present, path => "${phabricator_dir}/phabricator/conf/local/local.json", content => template('phabricator/local.json.erb'), require => Vcsrepo["${phabricator_dir}/phabricator"], notify => Service['httpd'], } exec { 'load-initial-db': command => "${phabricator_dir}/phabricator/bin/storage upgrade --force", unless => "${phabricator_dir}/phabricator/bin/storage status", require => [ Vcsrepo["${phabricator_dir}/phabricator"], Vcsrepo["${phabricator_dir}/libphutil"], Vcsrepo["${phabricator_dir}/arcanist"], ] } service { 'Phabricator-daemons': ensure => running, provider => base, start => "${phabricator_dir}/phabricator/bin/phd start", stop => "${phabricator_dir}/phabricator/bin/phd stop", restart => "${phabricator_dir}/phabricator/bin/phd restart", status => "${phabricator_dir}/phabricator/bin/phd status", subscribe => Vcsrepo["${phabricator_dir}/libphutil"], require => [ File[$phabricator_dir], Vcsrepo["${phabricator_dir}/phabricator"], Vcsrepo["${phabricator_dir}/libphutil"], Vcsrepo["${phabricator_dir}/arcanist"], ] } }