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 require => Package['nginx'], |
| 19 } |
| 20 |
12 nginx::hostconfig {$domain: | 21 nginx::hostconfig {$domain: |
13 source => 'puppet:///modules/trac/site.conf', | 22 content => "include $fcgi_config_dir/*;", |
14 is_default => $is_default, | 23 is_default => $is_default, |
15 certificate => $certificate, | 24 certificate => $certificate, |
16 private_key => $private_key, | 25 private_key => $private_key, |
17 log => 'access_log_trac' | 26 log => 'access_log_trac', |
| 27 require => File[$fcgi_config_dir], |
18 } | 28 } |
19 | 29 |
20 user {'trac': | 30 user {'trac': |
21 ensure => present, | 31 ensure => present, |
22 comment => 'User of the trac installation', | 32 comment => 'User of the trac installation', |
23 home => '/home/trac', | 33 home => '/home/trac', |
24 managehome => true | 34 managehome => true |
25 } | 35 } |
26 | 36 |
27 class {'mysql::server': | 37 class {'mysql::server': |
28 root_password => $database_root_password | 38 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 } | 39 } |
40 | 40 |
41 Exec { | 41 Exec { |
42 path => '/usr/bin:/usr/sbin:/bin:/usr/local/bin', | 42 path => '/usr/bin:/usr/sbin:/bin:/usr/local/bin', |
43 } | 43 } |
44 | 44 |
45 exec { 'install_trac': | 45 exec { 'install_trac': |
46 command => "pip install Trac==1.0.1", | 46 command => "pip install Trac==1.0.1", |
47 require => Package['python-pip'], | 47 require => Package['python-pip'], |
48 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)'", |
49 } | 49 } |
50 | 50 |
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': | 51 exec { 'install_BlackMagicTicketTweaks': |
62 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/", |
63 require => Package['subversion', 'python-pip'], | 53 require => Package['subversion', 'python-pip'], |
64 unless => "python -c 'import blackmagic'", | 54 unless => "python -c 'import blackmagic'", |
65 } | 55 } |
66 | 56 |
67 exec { 'install_SensitiveTickets': | 57 exec { 'install_SensitiveTickets': |
68 command => "pip install svn+http://trac-hacks.org/svn/sensitiveticketsplugin
/trunk/", | 58 command => "pip install svn+http://trac-hacks.org/svn/sensitiveticketsplugin
/trunk/", |
69 require => Package['subversion', 'python-pip'], | 59 require => Package['subversion', 'python-pip'], |
70 unless => "python -c 'import sensitivetickets'", | 60 unless => "python -c 'import sensitivetickets'", |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 } | 101 } |
112 | 102 |
113 exec { 'install_TracSpamFilter': | 103 exec { 'install_TracSpamFilter': |
114 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", |
115 require => Package[ | 105 require => Package[ |
116 'spambayes', | 106 'spambayes', |
117 'python-pip'], | 107 'python-pip'], |
118 unless => "python -c 'import tracspamfilter'", | 108 unless => "python -c 'import tracspamfilter'", |
119 } | 109 } |
120 | 110 |
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': | 111 exec { 'install_Tractags': |
129 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/", |
130 require => Package['python-pip'], | 113 require => Package['python-pip'], |
131 unless => "python -c 'import tractags'", | 114 unless => "python -c 'import tractags'", |
132 } | 115 } |
133 | 116 |
134 file {"/home/trac/htdocs/htdocs/common/adblockplus_logo.png": | 117 exec { 'install_PrivateTickets': |
135 ensure => present, | 118 command => "pip install svn+http://trac-hacks.org/svn/privateticketsplugin/t
ags/2.0.2/", |
136 source => 'puppet:///modules/trac/adblockplus_logo.png', | 119 require => Package['subversion', 'python-pip'], |
137 owner => trac, | 120 unless => "python -c 'import privateticketsplugin'", |
138 require => Exec['deploy'] | |
139 } | 121 } |
140 | 122 |
141 file {"/home/trac/environment/htdocs/theme.css": | 123 file { '/home/trac/trac.ini': |
142 ensure => present, | 124 ensure => present, |
143 source => 'puppet:///modules/trac/theme.css', | 125 source => 'puppet:///modules/trac/trac.ini', |
144 owner => trac, | 126 owner => 'trac', |
145 require => Exec['trac_env'] | 127 mode => 644, |
146 } | 128 } |
147 | 129 |
148 exec {"update_env": | 130 define instance ( |
149 command => "trac-admin /home/trac/environment upgrade", | 131 $config = 'trac/trac.ini.erb', |
150 user => trac, | 132 $description = 'Issue Tracker', |
151 require => [ | 133 $location = '/', |
152 File['/home/trac/environment/conf/trac.ini'], | 134 $logo = 'puppet:///modules/trac/logo.png', |
153 Exec['install_SensitiveTickets'], | 135 $database = 'trac', |
154 Exec['install_BlackMagicTicketTweaks'], | 136 $permissions = 'puppet:///modules/trac/permissions.csv', |
155 Exec['install_AccountManager'], | 137 $theme = 'puppet:///modules/trac/theme.css') { |
156 Exec['install_AutocompleteUsers'], | 138 |
157 Exec['install_TicketTemplate'], | 139 $database_password = $private::trac::database_password |
158 Exec['install_NeverNotifyUpdater'], | 140 $environment = "environment-$name" |
159 Exec['install_MasterTickets'], | 141 |
160 Exec['install_ThemeEngine'], | 142 mysql::db {$database: |
161 Exec['install_Tractags'], | 143 user => 'trac', |
162 Exec['install_TracSpamFilter']] | 144 password => $database_password, |
| 145 host => 'localhost', |
| 146 grant => ['all'], |
| 147 charset => 'utf8', |
| 148 collate => 'utf8_bin', |
| 149 require => Class['mysql::server'], |
| 150 } |
| 151 |
| 152 $location_base = regsubst($location, '/+$', '') |
| 153 |
| 154 file {"${trac::fcgi_config_dir}/${name}.conf": |
| 155 ensure => file, |
| 156 owner => 'root', |
| 157 mode => 644, |
| 158 content => template('trac/fcgi.conf.erb'), |
| 159 require => File[$trac::fcgi_config_dir], |
| 160 notify => Service['nginx'], |
| 161 } |
| 162 |
| 163 exec {"trac_env_${name}": |
| 164 command => shellquote( |
| 165 'trac-admin', "/home/trac/$environment", 'initenv', $description, |
| 166 "mysql://trac:${database_password}@localhost:3306/$database"), |
| 167 logoutput => true, |
| 168 path => '/usr/bin:/usr/sbin:/bin:/usr/local/bin', |
| 169 require => [ |
| 170 Exec['install_trac'], |
| 171 Mysql_grant["trac@localhost/${database}.*"]], |
| 172 user => trac, |
| 173 unless => "test -d /home/trac/$environment", |
| 174 } |
| 175 |
| 176 file {"/home/trac/${environment}/conf/permissions.csv": |
| 177 ensure => present, |
| 178 owner => trac, |
| 179 source => $permissions, |
| 180 require => Exec["trac_env_$name"], |
| 181 } |
| 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 } |
163 } | 244 } |
| 245 } |
164 | 246 |
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 |