Index: modules/trac/manifests/init.pp |
=================================================================== |
--- a/modules/trac/manifests/init.pp |
+++ b/modules/trac/manifests/init.pp |
@@ -2,19 +2,28 @@ |
$domain, |
$certificate, |
$private_key, |
+ $fcgi_config_dir = '/etc/nginx/trac.d', |
$is_default = false) inherits private::trac { |
+ |
package {['python-mysqldb','python-pip','subversion', 'tofrodos', 'graphviz']: |
ensure => present |
} |
include nginx, spawn-fcgi |
+ file {$fcgi_config_dir: |
+ ensure => directory, |
+ owner => 'root', |
+ mode => 755, |
+ } |
+ |
nginx::hostconfig {$domain: |
source => 'puppet:///modules/trac/site.conf', |
is_default => $is_default, |
certificate => $certificate, |
private_key => $private_key, |
- log => 'access_log_trac' |
+ log => 'access_log_trac', |
+ require => File[$fcgi_config_dir], |
} |
user {'trac': |
@@ -25,17 +34,7 @@ |
} |
class {'mysql::server': |
- root_password => $database_root_password |
- } |
- |
- mysql::db {'trac': |
- user => 'trac', |
- password => $database_password, |
- host => 'localhost', |
- grant => ['all'], |
- charset => 'utf8', |
- collate => 'utf8_bin', |
- require => Class['mysql::server'] |
+ root_password => $database_root_password, |
} |
Exec { |
@@ -48,16 +47,6 @@ |
unless => "python -c 'import trac,sys;sys.exit(0 if trac.__version__ == \"1.0.1\" else 1)'", |
} |
- exec { 'trac_env': |
- command => "trac-admin /home/trac/environment initenv \"Adblock Plus issue tracker\" mysql://trac:${database_password}@localhost:3306/trac", |
- require => [ |
- Exec['install_trac'], |
- Mysql_grant['trac@localhost/trac.*'] |
- ], |
- user => trac, |
- unless => "test -d /home/trac/environment" |
- } |
- |
exec { 'install_BlackMagicTicketTweaks': |
command => "pip install svn+http://trac-hacks.org/svn/blackmagictickettweaksplugin/0.12/", |
require => Package['subversion', 'python-pip'], |
@@ -118,72 +107,146 @@ |
unless => "python -c 'import tracspamfilter'", |
} |
- file {"/home/trac/environment/conf/trac.ini": |
- ensure => present, |
- content => template('trac/trac.ini.erb'), |
- owner => trac, |
- require => Exec['trac_env'] |
- } |
- |
exec { 'install_Tractags': |
command => "pip install svn+http://trac-hacks.org/svn/tagsplugin/tags/0.7/", |
require => Package['python-pip'], |
unless => "python -c 'import tractags'", |
} |
- file {"/home/trac/htdocs/htdocs/common/adblockplus_logo.png": |
+ file { '/home/trac/trac.ini': |
ensure => present, |
- source => 'puppet:///modules/trac/adblockplus_logo.png', |
- owner => trac, |
- require => Exec['deploy'] |
+ source => 'puppet:///modules/trac/trac.ini', |
+ owner => 'trac', |
+ mode => 644, |
} |
- file {"/home/trac/environment/htdocs/theme.css": |
- ensure => present, |
- source => 'puppet:///modules/trac/theme.css', |
- owner => trac, |
- require => Exec['trac_env'] |
+ define instance ( |
+ $config = 'trac/trac.ini.erb', |
+ $description = 'Issue Tracker', |
+ $environment = 'environment', |
+ $location = '/', |
+ $logo = 'eyeo_logo.png', |
+ $database = 'trac', |
+ $permissions = 'puppet:///modules/trac/permissions.csv', |
+ $theme = 'puppet:///modules/trac/theme.css') { |
+ |
+ $database_password = $private::trac::database_password |
+ |
+ mysql::db {$database: |
+ user => 'trac', |
+ password => $database_password, |
+ host => 'localhost', |
+ grant => ['all'], |
+ charset => 'utf8', |
+ collate => 'utf8_bin', |
+ require => Class['mysql::server'], |
+ } |
+ |
+ $location_base = $location ? { |
+ '/' => '', |
+ default => $location, |
+ } |
+ |
+ file {"${trac::fcgi_config_dir}/${name}.conf": |
+ ensure => file, |
+ owner => 'root', |
+ mode => 644, |
+ content => " |
+ location $location_base/ |
+ { |
+ fastcgi_pass unix:/tmp/${name}-fastcgi.sock; |
+ fastcgi_split_path_info ^(${location_base})(.*)\$; |
+ include /etc/nginx/fastcgi_params; |
+ fastcgi_param SCRIPT_NAME \$fastcgi_script_name; |
+ fastcgi_param PATH_INFO \$fastcgi_path_info; |
+ client_max_body_size 20m; |
+ } |
+ location $location_base/chrome/ |
+ { |
+ alias /home/trac/htdocs-$name/htdocs/; |
+ }", |
+ require => File[$trac::fcgi_config_dir], |
+ } |
+ |
+ exec {"trac_env_${name}": |
+ command => shellquote( |
+ 'trac-admin', "/home/trac/$environment", 'initenv', $description, |
+ "mysql://trac:${database_password}@localhost:3306/$database"), |
+ path => '/usr/bin:/usr/sbin:/bin:/usr/local/bin', |
+ require => [ |
+ Exec['install_trac'], |
+ Mysql_grant["trac@localhost/${database}.*"]], |
+ user => trac, |
+ unless => "test -d /home/trac/$environment" |
+ } |
+ |
+ file {"/home/trac/${environment}/conf/permissions.csv": |
+ ensure => present, |
+ owner => trac, |
+ source => $permissions, |
+ require => Exec["trac_env_$name"], |
+ } |
+ |
+ file {"/home/trac/$environment/conf/trac.ini": |
+ ensure => present, |
+ content => template($config), |
+ owner => trac, |
+ require => Exec["trac_env_$name"] |
+ } |
+ |
+ file {"/home/trac/$environment/htdocs/theme.css": |
+ ensure => present, |
+ source => $theme, |
+ owner => trac, |
+ require => Exec["trac_env_$name"], |
+ } |
+ |
+ exec {"update_env_$name": |
+ command => "trac-admin /home/trac/$environment upgrade", |
+ user => trac, |
+ path => '/usr/bin:/usr/sbin:/bin:/usr/local/bin', |
+ require => [ |
+ File["/home/trac/$environment/conf/trac.ini"], |
+ Exec['install_SensitiveTickets'], |
+ Exec['install_BlackMagicTicketTweaks'], |
+ Exec['install_AccountManager'], |
+ Exec['install_AutocompleteUsers'], |
+ Exec['install_TicketTemplate'], |
+ Exec['install_NeverNotifyUpdater'], |
+ Exec['install_MasterTickets'], |
+ Exec['install_ThemeEngine'], |
+ Exec['install_Tractags'], |
+ Exec['install_TracSpamFilter']], |
+ } |
+ |
+ exec {"deploy_$name": |
+ command => "trac-admin /home/trac/$environment \ |
+ deploy /home/trac/htdocs-$name \ |
+ && fromdos /home/trac/htdocs-$name/cgi-bin/trac.fcgi \ |
+ && chmod 755 /home/trac/htdocs-$name/cgi-bin/trac.fcgi", |
+ user => trac, |
+ path => '/usr/bin:/usr/sbin:/bin:/usr/local/bin', |
+ require => [ |
+ Exec["update_env_$name"], |
+ Package["tofrodos"]], |
+ } |
+ |
+ file {"/home/trac/htdocs-$name/htdocs/common/$logo": |
+ ensure => present, |
+ source => "puppet:///modules/trac/$logo", |
+ owner => trac, |
+ require => Exec["deploy_$name"], |
+ } |
+ |
+ spawn-fcgi::pool {"${name}d": |
+ ensure => present, |
+ fcgi_app => "/home/trac/htdocs-$name/cgi-bin/trac.fcgi", |
+ socket => "/tmp/${name}-fastcgi.sock", |
+ mode => "0666", |
+ user => trac, |
+ children => 1, |
+ require => Exec["deploy_$name"], |
+ } |
} |
+} |
- exec {"update_env": |
- command => "trac-admin /home/trac/environment upgrade", |
- user => trac, |
- require => [ |
- File['/home/trac/environment/conf/trac.ini'], |
- Exec['install_SensitiveTickets'], |
- Exec['install_BlackMagicTicketTweaks'], |
- Exec['install_AccountManager'], |
- Exec['install_AutocompleteUsers'], |
- Exec['install_TicketTemplate'], |
- Exec['install_NeverNotifyUpdater'], |
- Exec['install_MasterTickets'], |
- Exec['install_ThemeEngine'], |
- Exec['install_Tractags'], |
- Exec['install_TracSpamFilter']] |
- } |
- |
- exec {"deploy": |
- command => "trac-admin /home/trac/environment deploy /home/trac/htdocs && fromdos /home/trac/htdocs/cgi-bin/trac.fcgi && chmod 755 /home/trac/htdocs/cgi-bin/trac.fcgi", |
- user => trac, |
- require => [ |
- Exec["update_env"], |
- Package["tofrodos"]] |
- } |
- |
- spawn-fcgi::pool {"tracd": |
- ensure => present, |
- fcgi_app => "/home/trac/htdocs/cgi-bin/trac.fcgi", |
- socket => "/tmp/trac-fastcgi.sock", |
- mode => "0666", |
- user => trac, |
- children => 1, |
- require => Exec['deploy'], |
- } |
- |
- file {"/home/trac/permissions.csv": |
- ensure => present, |
- owner => trac, |
- source => 'puppet:///modules/trac/permissions.csv' |
- } |
- |
-} |