From 230696af89811438a5eb78c9e68191ada71c3032 Mon Sep 17 00:00:00 2001 From: mbakerbp Date: Wed, 12 Apr 2017 07:19:31 +0800 Subject: [PATCH] Adding fastcgi_index support --- manifests/init.pp | 3 ++- manifests/package/debian.pp | 6 +++--- manifests/resource/server.pp | 4 ++++ spec/classes/nginx_spec.rb | 6 ++++-- spec/defines/resource_server_spec.rb | 11 ++++++++++- 5 files changed, 23 insertions(+), 7 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 6a762b398..a5f8d853b 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -156,6 +156,7 @@ $string_mappings = {}, $nginx_locations = {}, $nginx_mailhosts = {}, + $nginx_mailhosts_defaults = {}, $nginx_streamhosts = {}, $nginx_upstreams = {}, $nginx_servers = {}, @@ -181,7 +182,7 @@ create_resources('nginx::resource::upstream', $nginx_upstreams) create_resources('nginx::resource::server', $nginx_servers, $nginx_servers_defaults) create_resources('nginx::resource::location', $nginx_locations) - create_resources('nginx::resource::mailhost', $nginx_mailhosts) + create_resources('nginx::resource::mailhost', $nginx_mailhosts, $nginx_mailhosts_defaults) create_resources('nginx::resource::streamhost', $nginx_streamhosts) create_resources('nginx::resource::map', $string_mappings) create_resources('nginx::resource::geo', $geo_mappings) diff --git a/manifests/package/debian.pp b/manifests/package/debian.pp index af9efccab..08e074a14 100644 --- a/manifests/package/debian.pp +++ b/manifests/package/debian.pp @@ -37,21 +37,21 @@ apt::source { 'nginx': location => "https://nginx.org/packages/${distro}", repos => 'nginx', - key => '573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62', + key => {'id' => '573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62'}, } } 'nginx-mainline': { apt::source { 'nginx': location => "https://nginx.org/packages/mainline/${distro}", repos => 'nginx', - key => '573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62', + key => {'id' => '573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62'}, } } 'passenger': { apt::source { 'nginx': location => 'https://oss-binaries.phusionpassenger.com/apt/passenger', repos => 'main', - key => '16378A33A6EF16762922526E561F9B9CAC40B2F7', + key => {'id' => '16378A33A6EF16762922526E561F9B9CAC40B2F7'}, } ensure_packages([ 'apt-transport-https', 'ca-certificates' ]) diff --git a/manifests/resource/server.pp b/manifests/resource/server.pp index 4a2c6d297..7ab7c8316 100644 --- a/manifests/resource/server.pp +++ b/manifests/resource/server.pp @@ -31,6 +31,7 @@ # [*fastcgi*] - location of fastcgi (host:port) # [*fastcgi_param*] - Set additional custom fastcgi_params # [*fastcgi_params*] - optional alternative fastcgi_params file to use +# [*fastcgi_index*] - optional FastCGI index page # [*fastcgi_script*] - optional SCRIPT_FILE parameter # [*uwsgi_read_timeout*] - optional value for uwsgi_read_timeout # [*ssl*] - Indicates whether to setup SSL bindings for this server. @@ -120,6 +121,7 @@ # [*maintenance_value*] - Value to return when maintenance is on. Default to return 503 # [*error_pages*] - Hash: setup errors pages, hash key is the http code and hash value the page # [*locations*] - Hash of servers resources used by this server + # Actions: # # Requires: @@ -191,6 +193,7 @@ Optional[String] $proxy_buffering = undef, Array $resolver = [], Optional[String] $fastcgi = undef, + Optional[String] $fastcgi_index = undef, $fastcgi_param = undef, String $fastcgi_params = "${::nginx::conf_dir}/fastcgi_params", Optional[String] $fastcgi_script = undef, @@ -342,6 +345,7 @@ proxy_set_body => $proxy_set_body, proxy_buffering => $proxy_buffering, fastcgi => $fastcgi, + fastcgi_index => $fastcgi_index, fastcgi_param => $fastcgi_param, fastcgi_params => $fastcgi_params, fastcgi_script => $fastcgi_script, diff --git a/spec/classes/nginx_spec.rb b/spec/classes/nginx_spec.rb index 278680b0d..4cb2c1204 100644 --- a/spec/classes/nginx_spec.rb +++ b/spec/classes/nginx_spec.rb @@ -14,6 +14,7 @@ nginx_servers_defaults: { 'listen_options' => 'default_server' }, nginx_locations: { 'test2.local' => { 'server' => 'test2.local', 'www_root' => '/' } }, nginx_mailhosts: { 'smtp.test2.local' => { 'auth_http' => 'server2.example/cgi-bin/auth', 'protocol' => 'smtp', 'listen_port' => 587 } }, + nginx_mailhosts_defaults: { 'listen_options' => 'default_server_smtp' }, nginx_streamhosts: { 'streamhost1' => { 'proxy' => 'streamproxy' } } } end @@ -33,6 +34,7 @@ it { is_expected.to contain_nginx__resource__server('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__mailhost('smtp.test2.local').with_listen_options('default_server_smtp') } it { is_expected.to contain_nginx__resource__streamhost('streamhost1').with_proxy('streamproxy') } end @@ -159,7 +161,7 @@ is_expected.to contain_apt__source('nginx').with( 'location' => "https://nginx.org/packages/#{operatingsystem.downcase}", 'repos' => 'nginx', - 'key' => '573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62' + 'key' => { 'id' => '573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62' } ) end it { is_expected.to contain_anchor('nginx::package::begin').that_comes_before('Class[nginx::package::debian]') } @@ -183,7 +185,7 @@ is_expected.to contain_apt__source('nginx').with( 'location' => 'https://oss-binaries.phusionpassenger.com/apt/passenger', 'repos' => 'main', - 'key' => '16378A33A6EF16762922526E561F9B9CAC40B2F7' + 'key' => { 'id' => '16378A33A6EF16762922526E561F9B9CAC40B2F7' } ) end end diff --git a/spec/defines/resource_server_spec.rb b/spec/defines/resource_server_spec.rb index 5c55722a7..ac1187cb7 100644 --- a/spec/defines/resource_server_spec.rb +++ b/spec/defines/resource_server_spec.rb @@ -9,7 +9,8 @@ { www_root: '/', ipv6_enable: true, - listen_unix_socket_enable: true + listen_unix_socket_enable: true, + fastcgi_index: 'index.php' } end @@ -986,6 +987,14 @@ it { is_expected.to contain_file('/etc/nginx/fastcgi_params').with_mode('0644') } end + context 'when fastcgi_index => "index.php"' do + let :params do + default_params.merge(fastcgi_index: 'index.php') + end + + it { is_expected.to contain_nginx__resource__location("#{title}-default").with_fastcgi_index('index.php') } + end + context 'when fastcgi_param => {key => value}' do let :params do default_params.merge(fastcgi_param: { 'key' => 'value' })