File tree Expand file tree Collapse file tree 3 files changed +35
-6
lines changed Expand file tree Collapse file tree 3 files changed +35
-6
lines changed Original file line number Diff line number Diff line change 4747# nginx::resource::streamhost { 'test2.local':
4848# ensure => present,
4949# }
50+ # @param allow
51+ # Locations to allow connections from
52+ # @param deny
53+ # Locations to deny connections from
5054#
5155define nginx::resource::streamhost (
5256 Enum['absent', 'present'] $ensure = ' present' ,
6670 String $owner = $nginx::global_owner,
6771 String $group = $nginx::global_group,
6872 String $mode = $nginx::global_mode,
73+ Array $allow = [],
74+ Array $deny = [],
6975) {
7076 if ! defined (Class[' nginx' ]) {
7177 fail(' You must include the nginx base class before using any defined resources' )
Original file line number Diff line number Diff line change 112112 value : [ '203.0.113.1' , '203.0.113.2' ] ,
113113 match : %r{\s +resolver\s +203.0.113.1 203.0.113.2;}
114114 } ,
115+ {
116+ title : 'should set allow(s)' ,
117+ attr : 'allow' ,
118+ value : [ '203.0.113.1' , '203.0.113.2' ] ,
119+ match : %r{\s +allow\s +203.0.113.1;}
120+ } ,
121+ {
122+ title : 'should set deny(s)' ,
123+ attr : 'deny' ,
124+ value : [ '203.0.113.1' , '203.0.113.2' ] ,
125+ match : %r{\s +deny\s +203.0.113.1;}
126+ } ,
115127 {
116128 title : 'should contain raw_prepend directives' ,
117129 attr : 'raw_prepend' ,
Original file line number Diff line number Diff line change @@ -22,15 +22,26 @@ server {
2222 resolver <% @resolver.each do |res| %> <%= res %> <% end %> ;
2323<%- end -%>
2424
25- <% Array(@raw_prepend).each do |line| -%>
26- <%= line %>
27- <% end %>
25+ <% if @allow -%>
26+ <%- @allow.flatten.uniq.each do |allow_rule| -%>
27+ allow <%= allow_rule %> ;
28+ <%- end -%>
29+ <% end -%>
30+ <% if @deny -%>
31+ <%- @deny.uniq.each do |deny_rule| -%>
32+ deny <%= deny_rule %> ;
33+ <%- end -%>
34+ <% end -%>
35+
36+ <% Array(@raw_prepend).each do |line| -%>
37+ <%= line %>
38+ <% end %>
2839
2940 proxy_timeout <%= @proxy_read_timeout %> ;
3041 proxy_connect_timeout <%= @proxy_connect_timeout %> ;
3142 proxy_pass <%= @proxy %> ;
3243
33- <% Array(@raw_append).each do |line| -%>
34- <%= line %>
35- <% end -%>
44+ <% Array(@raw_append).each do |line| -%>
45+ <%= line %>
46+ <% end -%>
3647}
You can’t perform that action at this time.
0 commit comments