OLD | NEW |
1 class trac( | 1 class trac( |
2 $domain, | 2 $domain, |
3 $certificate, | 3 $certificate, |
4 $private_key, | 4 $private_key, |
| 5 $fcgi_config_dir = '/etc/nginx/trac.d', |
5 $is_default = false) inherits private::trac { | 6 $is_default = false) inherits private::trac { |
| 7 |
6 package {['python-mysqldb','python-pip','subversion', 'tofrodos', 'graphviz']: | 8 package {['python-mysqldb','python-pip','subversion', 'tofrodos', 'graphviz']: |
7 ensure => present | 9 ensure => present |
8 } | 10 } |
9 | 11 |
10 include nginx, spawn-fcgi | 12 include nginx, spawn-fcgi |
11 | 13 |
| 14 file {$fcgi_config_dir: |
| 15 ensure => directory, |
| 16 owner => 'root', |
| 17 mode => 755, |
| 18 } |
| 19 |
12 nginx::hostconfig {$domain: | 20 nginx::hostconfig {$domain: |
13 source => 'puppet:///modules/trac/site.conf', | 21 source => 'puppet:///modules/trac/site.conf', |
14 is_default => $is_default, | 22 is_default => $is_default, |
15 certificate => $certificate, | 23 certificate => $certificate, |
16 private_key => $private_key, | 24 private_key => $private_key, |
17 log => 'access_log_trac' | 25 log => 'access_log_trac', |
| 26 require => File[$fcgi_config_dir], |
18 } | 27 } |
19 | 28 |
20 user {'trac': | 29 user {'trac': |
21 ensure => present, | 30 ensure => present, |
22 comment => 'User of the trac installation', | 31 comment => 'User of the trac installation', |
23 home => '/home/trac', | 32 home => '/home/trac', |
24 managehome => true | 33 managehome => true |
25 } | 34 } |
26 | 35 |
27 class {'mysql::server': | 36 class {'mysql::server': |
28 root_password => $database_root_password | 37 root_password => $database_root_password, |
29 } | |
30 | |
31 mysql::db {'trac': | |
32 user => 'trac', | |
33 password => $database_password, | |
34 host => 'localhost', | |
35 grant => ['all'], | |
36 charset => 'utf8', | |
37 collate => 'utf8_bin', | |
38 require => Class['mysql::server'] | |
39 } | 38 } |
40 | 39 |
41 Exec { | 40 Exec { |
42 path => '/usr/bin:/usr/sbin:/bin:/usr/local/bin', | 41 path => '/usr/bin:/usr/sbin:/bin:/usr/local/bin', |
43 } | 42 } |
44 | 43 |
45 exec { 'install_trac': | 44 exec { 'install_trac': |
46 command => "pip install Trac==1.0.1", | 45 command => "pip install Trac==1.0.1", |
47 require => Package['python-pip'], | 46 require => Package['python-pip'], |
48 unless => "python -c 'import trac,sys;sys.exit(0 if trac.__version__ == \"1.
0.1\" else 1)'", | 47 unless => "python -c 'import trac,sys;sys.exit(0 if trac.__version__ == \"1.
0.1\" else 1)'", |
49 } | 48 } |
50 | 49 |
51 exec { 'trac_env': | |
52 command => "trac-admin /home/trac/environment initenv \"Adblock Plus issue t
racker\" mysql://trac:${database_password}@localhost:3306/trac", | |
53 require => [ | |
54 Exec['install_trac'], | |
55 Mysql_grant['trac@localhost/trac.*'] | |
56 ], | |
57 user => trac, | |
58 unless => "test -d /home/trac/environment" | |
59 } | |
60 | |
61 exec { 'install_BlackMagicTicketTweaks': | 50 exec { 'install_BlackMagicTicketTweaks': |
62 command => "pip install svn+http://trac-hacks.org/svn/blackmagictickettweaks
plugin/0.12/", | 51 command => "pip install svn+http://trac-hacks.org/svn/blackmagictickettweaks
plugin/0.12/", |
63 require => Package['subversion', 'python-pip'], | 52 require => Package['subversion', 'python-pip'], |
64 unless => "python -c 'import blackmagic'", | 53 unless => "python -c 'import blackmagic'", |
65 } | 54 } |
66 | 55 |
67 exec { 'install_SensitiveTickets': | 56 exec { 'install_SensitiveTickets': |
68 command => "pip install svn+http://trac-hacks.org/svn/sensitiveticketsplugin
/trunk/", | 57 command => "pip install svn+http://trac-hacks.org/svn/sensitiveticketsplugin
/trunk/", |
69 require => Package['subversion', 'python-pip'], | 58 require => Package['subversion', 'python-pip'], |
70 unless => "python -c 'import sensitivetickets'", | 59 unless => "python -c 'import sensitivetickets'", |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 } | 100 } |
112 | 101 |
113 exec { 'install_TracSpamFilter': | 102 exec { 'install_TracSpamFilter': |
114 command => "pip install svn+http://svn.edgewall.com/repos/trac/plugins/1.0/s
pam-filter", | 103 command => "pip install svn+http://svn.edgewall.com/repos/trac/plugins/1.0/s
pam-filter", |
115 require => Package[ | 104 require => Package[ |
116 'spambayes', | 105 'spambayes', |
117 'python-pip'], | 106 'python-pip'], |
118 unless => "python -c 'import tracspamfilter'", | 107 unless => "python -c 'import tracspamfilter'", |
119 } | 108 } |
120 | 109 |
121 file {"/home/trac/environment/conf/trac.ini": | |
122 ensure => present, | |
123 content => template('trac/trac.ini.erb'), | |
124 owner => trac, | |
125 require => Exec['trac_env'] | |
126 } | |
127 | |
128 exec { 'install_Tractags': | 110 exec { 'install_Tractags': |
129 command => "pip install svn+http://trac-hacks.org/svn/tagsplugin/tags/0.7/", | 111 command => "pip install svn+http://trac-hacks.org/svn/tagsplugin/tags/0.7/", |
130 require => Package['python-pip'], | 112 require => Package['python-pip'], |
131 unless => "python -c 'import tractags'", | 113 unless => "python -c 'import tractags'", |
132 } | 114 } |
133 | 115 |
134 file {"/home/trac/htdocs/htdocs/common/adblockplus_logo.png": | 116 file { '/home/trac/trac.ini': |
135 ensure => present, | 117 ensure => present, |
136 source => 'puppet:///modules/trac/adblockplus_logo.png', | 118 source => 'puppet:///modules/trac/trac.ini', |
137 owner => trac, | 119 owner => 'trac', |
138 require => Exec['deploy'] | 120 mode => 644, |
139 } | 121 } |
140 | 122 |
141 file {"/home/trac/environment/htdocs/theme.css": | 123 define instance ( |
142 ensure => present, | 124 $config = 'trac/trac.ini.erb', |
143 source => 'puppet:///modules/trac/theme.css', | 125 $description = 'Issue Tracker', |
144 owner => trac, | 126 $environment = 'environment', |
145 require => Exec['trac_env'] | 127 $location = '/', |
| 128 $logo = 'eyeo_logo.png', |
| 129 $database = 'trac', |
| 130 $permissions = 'puppet:///modules/trac/permissions.csv', |
| 131 $theme = 'puppet:///modules/trac/theme.css') { |
| 132 |
| 133 $database_password = $private::trac::database_password |
| 134 |
| 135 mysql::db {$database: |
| 136 user => 'trac', |
| 137 password => $database_password, |
| 138 host => 'localhost', |
| 139 grant => ['all'], |
| 140 charset => 'utf8', |
| 141 collate => 'utf8_bin', |
| 142 require => Class['mysql::server'], |
| 143 } |
| 144 |
| 145 $location_base = $location ? { |
| 146 '/' => '', |
| 147 default => $location, |
| 148 } |
| 149 |
| 150 file {"${trac::fcgi_config_dir}/${name}.conf": |
| 151 ensure => file, |
| 152 owner => 'root', |
| 153 mode => 644, |
| 154 content => " |
| 155 location $location_base/ |
| 156 { |
| 157 fastcgi_pass unix:/tmp/${name}-fastcgi.sock; |
| 158 fastcgi_split_path_info ^(${location_base})(.*)\$; |
| 159 include /etc/nginx/fastcgi_params; |
| 160 fastcgi_param SCRIPT_NAME \$fastcgi_script_name; |
| 161 fastcgi_param PATH_INFO \$fastcgi_path_info; |
| 162 client_max_body_size 20m; |
| 163 } |
| 164 location $location_base/chrome/ |
| 165 { |
| 166 alias /home/trac/htdocs-$name/htdocs/; |
| 167 }", |
| 168 require => File[$trac::fcgi_config_dir], |
| 169 } |
| 170 |
| 171 exec {"trac_env_${name}": |
| 172 command => shellquote( |
| 173 'trac-admin', "/home/trac/$environment", 'initenv', $description, |
| 174 "mysql://trac:${database_password}@localhost:3306/$database"), |
| 175 path => '/usr/bin:/usr/sbin:/bin:/usr/local/bin', |
| 176 require => [ |
| 177 Exec['install_trac'], |
| 178 Mysql_grant["trac@localhost/${database}.*"]], |
| 179 user => trac, |
| 180 unless => "test -d /home/trac/$environment" |
| 181 } |
| 182 |
| 183 file {"/home/trac/${environment}/conf/permissions.csv": |
| 184 ensure => present, |
| 185 owner => trac, |
| 186 source => $permissions, |
| 187 require => Exec["trac_env_$name"], |
| 188 } |
| 189 |
| 190 file {"/home/trac/$environment/conf/trac.ini": |
| 191 ensure => present, |
| 192 content => template($config), |
| 193 owner => trac, |
| 194 require => Exec["trac_env_$name"] |
| 195 } |
| 196 |
| 197 file {"/home/trac/$environment/htdocs/theme.css": |
| 198 ensure => present, |
| 199 source => $theme, |
| 200 owner => trac, |
| 201 require => Exec["trac_env_$name"], |
| 202 } |
| 203 |
| 204 exec {"update_env_$name": |
| 205 command => "trac-admin /home/trac/$environment upgrade", |
| 206 user => trac, |
| 207 path => '/usr/bin:/usr/sbin:/bin:/usr/local/bin', |
| 208 require => [ |
| 209 File["/home/trac/$environment/conf/trac.ini"], |
| 210 Exec['install_SensitiveTickets'], |
| 211 Exec['install_BlackMagicTicketTweaks'], |
| 212 Exec['install_AccountManager'], |
| 213 Exec['install_AutocompleteUsers'], |
| 214 Exec['install_TicketTemplate'], |
| 215 Exec['install_NeverNotifyUpdater'], |
| 216 Exec['install_MasterTickets'], |
| 217 Exec['install_ThemeEngine'], |
| 218 Exec['install_Tractags'], |
| 219 Exec['install_TracSpamFilter']], |
| 220 } |
| 221 |
| 222 exec {"deploy_$name": |
| 223 command => "trac-admin /home/trac/$environment \ |
| 224 deploy /home/trac/htdocs-$name \ |
| 225 && fromdos /home/trac/htdocs-$name/cgi-bin/trac.fcgi \ |
| 226 && chmod 755 /home/trac/htdocs-$name/cgi-bin/trac.fcgi", |
| 227 user => trac, |
| 228 path => '/usr/bin:/usr/sbin:/bin:/usr/local/bin', |
| 229 require => [ |
| 230 Exec["update_env_$name"], |
| 231 Package["tofrodos"]], |
| 232 } |
| 233 |
| 234 file {"/home/trac/htdocs-$name/htdocs/common/$logo": |
| 235 ensure => present, |
| 236 source => "puppet:///modules/trac/$logo", |
| 237 owner => trac, |
| 238 require => Exec["deploy_$name"], |
| 239 } |
| 240 |
| 241 spawn-fcgi::pool {"${name}d": |
| 242 ensure => present, |
| 243 fcgi_app => "/home/trac/htdocs-$name/cgi-bin/trac.fcgi", |
| 244 socket => "/tmp/${name}-fastcgi.sock", |
| 245 mode => "0666", |
| 246 user => trac, |
| 247 children => 1, |
| 248 require => Exec["deploy_$name"], |
| 249 } |
146 } | 250 } |
| 251 } |
147 | 252 |
148 exec {"update_env": | |
149 command => "trac-admin /home/trac/environment upgrade", | |
150 user => trac, | |
151 require => [ | |
152 File['/home/trac/environment/conf/trac.ini'], | |
153 Exec['install_SensitiveTickets'], | |
154 Exec['install_BlackMagicTicketTweaks'], | |
155 Exec['install_AccountManager'], | |
156 Exec['install_AutocompleteUsers'], | |
157 Exec['install_TicketTemplate'], | |
158 Exec['install_NeverNotifyUpdater'], | |
159 Exec['install_MasterTickets'], | |
160 Exec['install_ThemeEngine'], | |
161 Exec['install_Tractags'], | |
162 Exec['install_TracSpamFilter']] | |
163 } | |
164 | |
165 exec {"deploy": | |
166 command => "trac-admin /home/trac/environment deploy /home/trac/htdocs && fr
omdos /home/trac/htdocs/cgi-bin/trac.fcgi && chmod 755 /home/trac/htdocs/cgi-bin
/trac.fcgi", | |
167 user => trac, | |
168 require => [ | |
169 Exec["update_env"], | |
170 Package["tofrodos"]] | |
171 } | |
172 | |
173 spawn-fcgi::pool {"tracd": | |
174 ensure => present, | |
175 fcgi_app => "/home/trac/htdocs/cgi-bin/trac.fcgi", | |
176 socket => "/tmp/trac-fastcgi.sock", | |
177 mode => "0666", | |
178 user => trac, | |
179 children => 1, | |
180 require => Exec['deploy'], | |
181 } | |
182 | |
183 file {"/home/trac/permissions.csv": | |
184 ensure => present, | |
185 owner => trac, | |
186 source => 'puppet:///modules/trac/permissions.csv' | |
187 } | |
188 | |
189 } | |
OLD | NEW |