LEFT | RIGHT |
1 class web::server( | 1 class web::server( |
2 $vhost, | 2 $vhost, |
3 $repository, | 3 $repository, |
4 $certificate = hiera('web::server::certificate', 'undef'), | 4 $certificate = hiera('web::server::certificate', 'undef'), |
5 $private_key = hiera('web::server::private_key', 'undef'), | 5 $private_key = hiera('web::server::private_key', 'undef'), |
6 $is_default = false, | 6 $is_default = false, |
7 $aliases = undef, | 7 $aliases = undef, |
8 $custom_config = undef, | 8 $custom_config = undef, |
9 $multiplexer_locations = undef, | 9 $multiplexer_locations = undef, |
10 $geoip = false, | 10 $geoip = false, |
11 ) { | 11 ) { |
12 | 12 |
13 include sitescripts | 13 include sitescripts |
14 | 14 |
| 15 $PYTHONPATH = 'PYTHONPATH=/opt/cms:/opt/sitescripts' |
| 16 |
15 # Ensure there is at least one character in the respective strings; | 17 # Ensure there is at least one character in the respective strings; |
16 # see https://codereview.adblockplus.org/29329028/#msg3 | 18 # see https://codereview.adblockplus.org/29329028/#msg3 |
17 validate_re($vhost, '.+') | 19 validate_re($vhost, '.+') |
18 validate_re($repository, '.+') | 20 validate_re($repository, '.+') |
19 | 21 |
20 File { | 22 File { |
21 owner => 'root', | 23 owner => 'root', |
22 group => 'root', | 24 group => 'root', |
23 mode => 0644, | 25 mode => 0644, |
24 } | 26 } |
25 | 27 |
26 Cron { | 28 Cron { |
27 environment => concat(hiera('cron::environment', []), [ | 29 environment => concat(hiera('cron::environment', []), [ |
28 'PYTHONPATH=/opt/cms:/opt/sitescripts', | 30 $PYTHONPATH, |
29 ]), | 31 ]), |
30 } | 32 } |
31 | 33 |
32 class {'nginx': | 34 class {'nginx': |
33 geoip_country => $geoip ? { | 35 geoip_country => $geoip ? { |
34 false => undef, | 36 false => undef, |
35 default => '/usr/share/GeoIP/GeoIPv6.dat', | 37 default => '/usr/share/GeoIP/GeoIPv6.dat', |
36 }, | 38 }, |
37 } | 39 } |
38 | 40 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 109 |
108 exec {"fetch_repo": | 110 exec {"fetch_repo": |
109 command => "hg clone -U https://hg.adblockplus.org/${repository} /home/www/$
{repository}", | 111 command => "hg clone -U https://hg.adblockplus.org/${repository} /home/www/$
{repository}", |
110 path => ["/usr/bin/", "/bin/"], | 112 path => ["/usr/bin/", "/bin/"], |
111 require => Package['mercurial'], | 113 require => Package['mercurial'], |
112 user => www, | 114 user => www, |
113 timeout => 0, | 115 timeout => 0, |
114 creates => "/home/www/${repository}/.hg/hgrc", | 116 creates => "/home/www/${repository}/.hg/hgrc", |
115 } | 117 } |
116 | 118 |
117 exec {"generate_static_pages": | 119 $initialize_content_exec = [ |
118 command => "python -m cms.bin.generate_static_pages /home/www/${repository}
/var/www/${vhost}", | 120 'python', '-m', 'cms.bin.generate_static_pages', |
| 121 "/home/www/${repository}", "/var/www/${vhost}", |
| 122 ] |
| 123 |
| 124 exec {"initialize_content": |
| 125 command => shellquote($initialize_content_exec), |
119 path => ["/usr/bin/", "/bin/"], | 126 path => ["/usr/bin/", "/bin/"], |
120 user => www, | 127 user => www, |
121 require => [Exec["fetch_repo"], Exec["fetch_cms"]], | 128 subscribe => [Exec["fetch_repo"], Exec["fetch_cms"]], |
122 environment => 'PYTHONPATH=/opt/cms:/opt/sitescripts', | 129 refreshonly => true, |
| 130 environment => $PYTHONPATH, |
123 } | 131 } |
124 | 132 |
125 file {'/var/www': | 133 file {'/var/www': |
126 ensure => directory, | 134 ensure => directory, |
127 mode => 755, | 135 mode => 755, |
128 } | 136 } |
129 | 137 |
130 file {[ | 138 file {[ |
131 "/var/cache/$repository", | 139 "/var/cache/$repository", |
132 "/var/www/$vhost", | 140 "/var/www/$vhost", |
133 "/var/www/docs", | 141 "/var/www/docs", |
134 ]: | 142 ]: |
135 ensure => directory, | 143 ensure => directory, |
136 owner => www, | 144 owner => www, |
137 mode => 755, | 145 mode => 755, |
138 } | 146 } |
139 | 147 |
140 cron {'update_cms': | 148 cron {'update_cms': |
141 ensure => present, | 149 ensure => present, |
142 command => "hg pull -q -u -R /opt/cms", | 150 command => "hg pull -q -u -R /opt/cms", |
143 minute => '4-59/20', | 151 minute => '4-59/20', |
144 } | 152 } |
145 | 153 |
| 154 $update_repo_cmd = [ |
| 155 "hg", "pull", "-q", "-R", "/home/www/${repository}", |
| 156 ] |
| 157 |
| 158 $update_webpage_cmd = join( |
| 159 [ |
| 160 shellquote($update_repo_cmd), |
| 161 shellquote($initialize_content_exec) |
| 162 ], |
| 163 "&&" |
| 164 ) |
| 165 |
146 cron {'update_repo': | 166 cron {'update_repo': |
147 ensure => present, | 167 ensure => present, |
148 command => "hg pull -q -R /home/www/${repository} && python -m cms.bin.gener
ate_static_pages /home/www/${repository} /var/www/${vhost}", | 168 command => $update_webpage_cmd, |
149 user => www, | 169 user => www, |
150 minute => '5-59/20', | 170 minute => '5-59/20', |
151 } | 171 } |
152 | 172 |
153 } | 173 } |
LEFT | RIGHT |