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 comments 5 trhough 9 Created May 12, 2017, 7:56 p.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 exec {"initialize_content":
125 command => shellquote($initialize_content_exec),
126 path => ["/usr/bin/", "/bin/"],
127 user => www,
128 subscribe => [Exec["fetch_repo"], Exec["fetch_cms"]],
129 refreshonly => true,
130 environment => $PYTHONPATH,
131 }
132
117 file {'/var/www': 133 file {'/var/www':
118 ensure => directory, 134 ensure => directory,
119 mode => 755, 135 mode => 755,
120 } 136 }
121 137
122 file {[ 138 file {[
123 "/var/cache/$repository", 139 "/var/cache/$repository",
124 "/var/www/$vhost", 140 "/var/www/$vhost",
125 "/var/www/docs", 141 "/var/www/docs",
126 ]: 142 ]:
127 ensure => directory, 143 ensure => directory,
128 owner => www, 144 owner => www,
129 mode => 755, 145 mode => 755,
130 } 146 }
131 147
132 cron {'update_cms': 148 cron {'update_cms':
133 ensure => present, 149 ensure => present,
134 command => "hg pull -q -u -R /opt/cms", 150 command => "hg pull -q -u -R /opt/cms",
135 minute => '4-59/20', 151 minute => '4-59/20',
136 } 152 }
137 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
138 cron {'update_repo': 166 cron {'update_repo':
139 ensure => present, 167 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}", 168 command => $update_webpage_cmd,
141 user => www, 169 user => www,
142 minute => '5-59/20', 170 minute => '5-59/20',
143 } 171 }
144 172
145 } 173 }
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