From a43a23929f4c9bc73739fda676f71e69b9cf91b6 Mon Sep 17 00:00:00 2001 From: Andy Botting Date: Thu, 22 Sep 2016 20:12:54 +1000 Subject: [PATCH] Add missing stream dirs and create streams from hiera This creates the missing streams-available and streams-enabled directories if stream is true and allow the streamhost resources to be created from hiera. Some simple tests are included. --- manifests/config.pp | 27 +++++++++++++++++++++++++++ manifests/init.pp | 2 ++ spec/classes/config_spec.rb | 6 ++++++ spec/classes/nginx_spec.rb | 4 +++- 4 files changed, 38 insertions(+), 1 deletion(-) diff --git a/manifests/config.pp b/manifests/config.pp index da9e29b7f..caa680583 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -264,6 +264,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, diff --git a/manifests/init.pp b/manifests/init.pp index 2656b62de..509a1c6fa 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -123,6 +123,7 @@ $string_mappings = {}, $nginx_locations = {}, $nginx_mailhosts = {}, + $nginx_streamhosts = {}, $nginx_upstreams = {}, $nginx_vhosts = {}, $nginx_vhosts_defaults = {}, @@ -311,6 +312,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) diff --git a/spec/classes/config_spec.rb b/spec/classes/config_spec.rb index 92dee1671..b30a8470d 100644 --- a/spec/classes/config_spec.rb +++ b/spec/classes/config_spec.rb @@ -636,6 +636,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') } diff --git a/spec/classes/nginx_spec.rb b/spec/classes/nginx_spec.rb index 33c79183a..5339f22f5 100644 --- a/spec/classes/nginx_spec.rb +++ b/spec/classes/nginx_spec.rb @@ -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 @@ -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