Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support allow and deny to streamhost #1627

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions manifests/resource/streamhost.pp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
# nginx::resource::streamhost { 'test2.local':
# ensure => present,
# }
# @param allow
# Locations to allow connections from
# @param deny
# Locations to deny connections from
#
define nginx::resource::streamhost (
Enum['absent', 'present'] $ensure = 'present',
Expand All @@ -66,6 +70,8 @@
String $owner = $nginx::global_owner,
String $group = $nginx::global_group,
String $mode = $nginx::global_mode,
Array $allow = [],
Array $deny = [],
) {
if ! defined(Class['nginx']) {
fail('You must include the nginx base class before using any defined resources')
Expand Down
12 changes: 12 additions & 0 deletions spec/defines/resource_stream_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,18 @@
value: ['203.0.113.1', '203.0.113.2'],
match: %r{\s+resolver\s+203.0.113.1 203.0.113.2;}
},
{
title: 'should set allow(s)',
attr: 'allow',
value: ['203.0.113.1', '203.0.113.2'],
match: %r{\s+allow\s+203.0.113.1;}
},
{
title: 'should set deny(s)',
attr: 'deny',
value: ['203.0.113.1', '203.0.113.2'],
match: %r{\s+deny\s+203.0.113.1;}
},
{
title: 'should contain raw_prepend directives',
attr: 'raw_prepend',
Expand Down
23 changes: 17 additions & 6 deletions templates/streamhost/streamhost.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,26 @@ server {
resolver <% @resolver.each do |res| %> <%= res %><% end %>;
<%- end -%>

<% Array(@raw_prepend).each do |line| -%>
<%= line %>
<% end %>
<% if @allow -%>
<%- @allow.flatten.uniq.each do |allow_rule| -%>
allow <%= allow_rule %>;
<%- end -%>
<% end -%>
<% if @deny -%>
<%- @deny.uniq.each do |deny_rule| -%>
deny <%= deny_rule %>;
<%- end -%>
<% end -%>

<% Array(@raw_prepend).each do |line| -%>
<%= line %>
<% end %>

proxy_timeout <%= @proxy_read_timeout %>;
proxy_connect_timeout <%= @proxy_connect_timeout %>;
proxy_pass <%= @proxy %>;

<% Array(@raw_append).each do |line| -%>
<%= line %>
<% end -%>
<% Array(@raw_append).each do |line| -%>
<%= line %>
<% end -%>
}
Loading