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