Skip to content

Commit d45a512

Browse files
committed
Merge pull request #6 from puppetlabs-operations/pf_202
Pf 202 - adding additional logic to support cache def in the lb manifest.
2 parents fa6bb23 + a220a86 commit d45a512

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

manifests/loadbalancer.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
define nginx::loadbalancer(
22
$workers,
3+
$caches,
34
$backups = [],
45
$priority = 75,
56
$template = 'nginx/vhost-loadbalancing.conf.erb',
@@ -14,6 +15,7 @@
1415
$fail_timeout = 10,
1516
$proto = 'http',
1617
$magic = '', # Accept arbitrary template data to append to the vhost
18+
$locations = '',
1719
) {
1820

1921
include nginx

templates/vhost-loadbalancing.conf.erb

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,26 @@ upstream workers {
1010
<% end -%>
1111
<% end -%>
1212
}
13-
server {
1413

15-
<%= scope.function_template(['nginx/vhost/_listen.conf.erb']) %>
14+
<% unless @caches.nil? or @caches.empty? -%>
15+
# Hack to add in additonal upstream for caching
16+
upstream vcache_workers {
17+
<% @caches.each do |cache| -%>
18+
server <%= cache %>;
19+
<% end -%>
20+
}
21+
<% end -%>
1622

23+
server {
24+
<%= scope.function_template(['nginx/vhost/_listen.conf.erb']) %>
25+
# Define empty root dir for LB
1726
root /usr/share/empty;
27+
<% unless @locations.nil? or @locations.empty? -%>
28+
29+
# Add placeholder for additional nginx locations
30+
<%= locations %>
1831

32+
<% end -%>
1933
location / {
2034
proxy_pass <%= @proto %>://workers;
2135
proxy_redirect off;

0 commit comments

Comments
 (0)