Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: modules/web/manifests/server.pp

Issue 29435656: Noissue - Generate content on provision (Closed)
Patch Set: For comment 2 Created May 11, 2017, 1:45 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
119 $initialize_content_exec = [
120 'python', '-m', 'cms.bin.generate_static_pages',
121 "/home/www/${repository}", "/var/www/${vhost}",
122 ]
123
124 if $::environment == 'development' {
125 exec {"initialize_content":
126 command => shellquote($initialize_content_exec),
127 path => ["/usr/bin/", "/bin/"],
128 user => www,
129 require => [Exec["fetch_repo"], Exec["fetch_cms"]],
130 environment => $PYTHONPATH,
131 }
132 }
133
117 file {'/var/www': 134 file {'/var/www':
118 ensure => directory, 135 ensure => directory,
119 mode => 755, 136 mode => 755,
120 } 137 }
121 138
122 file {[ 139 file {[
123 "/var/cache/$repository", 140 "/var/cache/$repository",
124 "/var/www/$vhost", 141 "/var/www/$vhost",
125 "/var/www/docs", 142 "/var/www/docs",
126 ]: 143 ]:
127 ensure => directory, 144 ensure => directory,
128 owner => www, 145 owner => www,
129 mode => 755, 146 mode => 755,
130 } 147 }
131 148
132 cron {'update_cms': 149 cron {'update_cms':
133 ensure => present, 150 ensure => present,
134 command => "hg pull -q -u -R /opt/cms", 151 command => "hg pull -q -u -R /opt/cms",
135 minute => '4-59/20', 152 minute => '4-59/20',
136 } 153 }
137 154
138 cron {'update_repo': 155 cron {'update_repo':
139 ensure => present, 156 ensure => present,
140 command => "hg pull -q -R /home/www/${repository} && python -m cms.bin.gener ate_static_pages /home/www/${repository} /var/www/${vhost}", 157 command => "hg pull -q -R /home/www/${repository} && python -m cms.bin.gener ate_static_pages /home/www/${repository} /var/www/${vhost}",
mathias 2017/05/11 20:05:51 What about using $initialize_content_exec here as
141 user => www, 158 user => www,
142 minute => '5-59/20', 159 minute => '5-59/20',
143 } 160 }
144 161
145 } 162 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld