Skip to content

Commit

Permalink
Merge pull request #879 from andybotting/create-streams-dirs
Browse files Browse the repository at this point in the history
Add missing stream dirs and create streams from hiera
  • Loading branch information
bastelfreak committed Oct 10, 2016
2 parents 3d2ad10 + a43a239 commit d48b434
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
27 changes: 27 additions & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,33 @@
owner => $daemon_user,
}

if $stream {
file { "${conf_dir}/streams-available":
ensure => directory,
owner => $sites_available_owner,
group => $sites_available_group,
mode => $sites_available_mode,
}

if $vhost_purge == true {
File["${conf_dir}/streams-available"] {
purge => true,
recurse => true,
}
}

file { "${conf_dir}/streams-enabled":
ensure => directory,
}

if $vhost_purge == true {
File["${conf_dir}/streams-enabled"] {
purge => true,
recurse => true,
}
}
}

file { "${conf_dir}/sites-available":
ensure => directory,
owner => $sites_available_owner,
Expand Down
2 changes: 2 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
$string_mappings = {},
$nginx_locations = {},
$nginx_mailhosts = {},
$nginx_streamhosts = {},
$nginx_upstreams = {},
$nginx_vhosts = {},
$nginx_vhosts_defaults = {},
Expand Down Expand Up @@ -313,6 +314,7 @@
create_resources('nginx::resource::vhost', $nginx_vhosts, $nginx_vhosts_defaults)
create_resources('nginx::resource::location', $nginx_locations)
create_resources('nginx::resource::mailhost', $nginx_mailhosts)
create_resources('nginx::resource::streamhost', $nginx_streamhosts)
create_resources('nginx::resource::map', $string_mappings)
create_resources('nginx::resource::geo', $geo_mappings)

Expand Down
6 changes: 6 additions & 0 deletions spec/classes/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,12 @@
end
end

context 'when stream true' do
let(:params) { { stream: true } }
it { is_expected.to contain_file('/etc/nginx/streams-available') }
it { is_expected.to contain_file('/etc/nginx/streams-enabled') }
end

context 'when daemon_user = www-data' do
let(:params) { { daemon_user: 'www-data' } }
it { is_expected.to contain_file('/var/nginx/client_body_temp').with(owner: 'www-data') }
Expand Down
4 changes: 3 additions & 1 deletion spec/classes/nginx_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
nginx_vhosts: { 'test2.local' => { 'www_root' => '/' } },
nginx_vhosts_defaults: { 'listen_options' => 'default_server' },
nginx_locations: { 'test2.local' => { 'vhost' => 'test2.local', 'www_root' => '/' } },
nginx_mailhosts: { 'smtp.test2.local' => { 'auth_http' => 'server2.example/cgi-bin/auth', 'protocol' => 'smtp', 'listen_port' => 587 } }
nginx_mailhosts: { 'smtp.test2.local' => { 'auth_http' => 'server2.example/cgi-bin/auth', 'protocol' => 'smtp', 'listen_port' => 587 } },
nginx_streamhosts: { 'streamhost1' => { 'proxy' => 'streamproxy' } }
}
end

Expand All @@ -32,5 +33,6 @@
it { is_expected.to contain_nginx__resource__vhost('test2.local').with_listen_options('default_server') }
it { is_expected.to contain_nginx__resource__location('test2.local') }
it { is_expected.to contain_nginx__resource__mailhost('smtp.test2.local') }
it { is_expected.to contain_nginx__resource__streamhost('streamhost1').with_proxy('streamproxy') }
end
end

0 comments on commit d48b434

Please sign in to comment.