From ded611be16fbd0a670b672d6c5428eafef390974 Mon Sep 17 00:00:00 2001 From: William Yardley Date: Mon, 17 Oct 2016 21:53:07 -0700 Subject: [PATCH] Fix streamhost support (with h/t to modax and alwiesner) --- manifests/config.pp | 5 ++++- manifests/init.pp | 3 +++ manifests/resource/streamhost.pp | 4 ---- spec/defines/resource_stream_spec.rb | 6 ------ templates/conf.d/nginx.conf.erb | 4 ++++ templates/streamhost/streamhost.erb | 1 - 6 files changed, 11 insertions(+), 12 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index 0907a4c27..6036f4ddc 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -77,6 +77,7 @@ $keepalive_requests = '100', $log_format = {}, $mail = false, + $stream = false, $multi_accept = 'off', $names_hash_bucket_size = '64', $names_hash_max_size = '512', @@ -174,6 +175,7 @@ } validate_bool($mail) + validate_bool($stream) validate_string($server_tokens) validate_string($client_max_body_size) if (!is_integer($names_hash_bucket_size)) { @@ -300,6 +302,7 @@ recurse => true, } } + # No real reason not to make these even if $stream is not enabled. file { "${conf_dir}/streams-enabled": ensure => directory, owner => $sites_available_owner, @@ -309,7 +312,7 @@ file { "${conf_dir}/streams-available": ensure => directory, } - if $vhost_purge == true { + if $vhost_purge { File["${conf_dir}/streams-enabled"] { purge => true, recurse => true, diff --git a/manifests/init.pp b/manifests/init.pp index 8bb5caacb..af2d63940 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -46,6 +46,7 @@ $keepalive_timeout = undef, $keepalive_requests = undef, $mail = undef, + $stream = undef, $multi_accept = undef, $names_hash_bucket_size = undef, $names_hash_max_size = undef, @@ -172,6 +173,7 @@ $logdir or $log_format or $mail or + $stream or $multi_accept or $names_hash_bucket_size or $names_hash_max_size or @@ -259,6 +261,7 @@ log_dir => $logdir, log_format => $log_format, mail => $mail, + stream => $stream, multi_accept => $multi_accept, names_hash_bucket_size => $names_hash_bucket_size, names_hash_max_size => $names_hash_max_size, diff --git a/manifests/resource/streamhost.pp b/manifests/resource/streamhost.pp index 15fdae2fe..0e17d0cee 100644 --- a/manifests/resource/streamhost.pp +++ b/manifests/resource/streamhost.pp @@ -28,8 +28,6 @@ # of 90 seconds # [*resolver*] - Array: Configures name servers used to resolve # names of upstream servers into addresses. -# [*server_name*] - List of streamhost names for which this streamhost will -# respond. Default [$name]. # [*raw_prepend*] - A single string, or an array of strings to # prepend to the server directive (after cfg prepend directives). NOTE: # YOU are responsible for a semicolon on each line that requires one. @@ -61,7 +59,6 @@ $proxy_read_timeout = $::nginx::config::proxy_read_timeout, $proxy_connect_timeout = $::nginx::config::proxy_connect_timeout, $resolver = [], - $server_name = [$name], $raw_prepend = undef, $raw_append = undef, $owner = $::nginx::config::global_owner, @@ -98,7 +95,6 @@ validate_string($proxy_read_timeout) validate_array($resolver) - validate_array($server_name) validate_string($owner) validate_string($group) diff --git a/spec/defines/resource_stream_spec.rb b/spec/defines/resource_stream_spec.rb index cd94ef658..914dc6073 100644 --- a/spec/defines/resource_stream_spec.rb +++ b/spec/defines/resource_stream_spec.rb @@ -97,12 +97,6 @@ value: 'spdy', match: %r{\s+listen\s+\[::\]:80 spdy;} }, - { - title: 'should set servername(s)', - attr: 'server_name', - value: ['www.foo.com', 'foo.com'], - match: %r{\s+server_name\s+www.foo.com foo.com;} - }, { title: 'should contain raw_prepend directives', attr: 'raw_prepend', diff --git a/templates/conf.d/nginx.conf.erb b/templates/conf.d/nginx.conf.erb index 5ed2b8168..f6dcc606c 100644 --- a/templates/conf.d/nginx.conf.erb +++ b/templates/conf.d/nginx.conf.erb @@ -190,6 +190,10 @@ mail { <% end -%> <% if @stream -%> stream { + <%-# conf.stream.d gets included either way if $stream is enabled -%> include <%= @conf_dir %>/conf.stream.d/*.conf; +<% unless @confd_only -%> + include <%= @conf_dir %>/streams-enabled/*; +<% end -%> } <% end -%> diff --git a/templates/streamhost/streamhost.erb b/templates/streamhost/streamhost.erb index 260648a5d..b91c2317c 100644 --- a/templates/streamhost/streamhost.erb +++ b/templates/streamhost/streamhost.erb @@ -17,7 +17,6 @@ server { listen [<%= @ipv6_listen_ip %>]:<%= @ipv6_listen_port %> <% if @ipv6_listen_options %><%= @ipv6_listen_options %><% end %>; <%- end -%> <%- end -%> - server_name <%= @server_name.join(" ") %>; <% Array(@raw_prepend).each do |line| -%> <%= line %>