From 4b8c57f696df6bd9ab2a1a32e62d104ca0370397 Mon Sep 17 00:00:00 2001 From: Steven Acres Date: Thu, 17 Nov 2016 19:21:28 -0500 Subject: [PATCH] Rename v[hH]ost to server everywhere Lint fixes. Formatting Replace stale code and re-format --- README.md | 62 +++--- docs/quickstart.md | 10 +- examples/location_alias.pp | 2 +- examples/location_params.pp | 2 +- examples/{vhost.pp => server.pp} | 4 +- examples/{vhost_ssl.pp => server_ssl.pp} | 8 +- manifests/config.pp | 10 +- manifests/init.pp | 10 +- manifests/resource/location.pp | 178 ++++++++--------- manifests/resource/mailhost.pp | 14 +- manifests/resource/{vhost.pp => server.pp} | 116 +++++------ manifests/service.pp | 2 +- spec/acceptance/nginx_proxy_spec.rb | 2 +- ...inx_vhost_spec.rb => nginx_server_spec.rb} | 12 +- spec/classes/nginx_spec.rb | 24 +-- spec/defines/resource_location_spec.rb | 182 +++++++++--------- spec/defines/resource_mailhost_spec.rb | 12 +- ..._vhost_spec.rb => resource_server_spec.rb} | 44 ++--- spec/defines/resource_stream_spec.rb | 2 +- .../{vhost => server}/fastcgi_params.erb | 0 templates/server/location.erb | 13 ++ .../{vhost => server}/location_footer.erb | 0 .../{vhost => server}/location_header.erb | 0 .../{vhost => server}/locations/alias.erb | 0 .../{vhost => server}/locations/directory.erb | 0 .../{vhost => server}/locations/empty.erb | 0 .../{vhost => server}/locations/fastcgi.erb | 0 .../{vhost => server}/locations/proxy.erb | 0 .../locations/stub_status.erb | 0 .../{vhost => server}/locations/try_files.erb | 0 .../{vhost => server}/locations/uwsgi.erb | 0 .../server_footer.erb} | 4 +- .../server_header.erb} | 4 +- .../server_ssl_footer.erb} | 8 +- .../server_ssl_header.erb} | 12 +- .../server_ssl_settings.erb} | 0 templates/{vhost => server}/uwsgi_params.erb | 0 templates/vhost/location.erb | 13 -- 38 files changed, 375 insertions(+), 375 deletions(-) rename examples/{vhost.pp => server.pp} (73%) rename examples/{vhost_ssl.pp => server_ssl.pp} (82%) rename manifests/resource/{vhost.pp => server.pp} (90%) rename spec/acceptance/{nginx_vhost_spec.rb => nginx_server_spec.rb} (92%) rename spec/defines/{resource_vhost_spec.rb => resource_server_spec.rb} (97%) rename templates/{vhost => server}/fastcgi_params.erb (100%) create mode 100644 templates/server/location.erb rename templates/{vhost => server}/location_footer.erb (100%) rename templates/{vhost => server}/location_header.erb (100%) rename templates/{vhost => server}/locations/alias.erb (100%) rename templates/{vhost => server}/locations/directory.erb (100%) rename templates/{vhost => server}/locations/empty.erb (100%) rename templates/{vhost => server}/locations/fastcgi.erb (100%) rename templates/{vhost => server}/locations/proxy.erb (100%) rename templates/{vhost => server}/locations/stub_status.erb (100%) rename templates/{vhost => server}/locations/try_files.erb (100%) rename templates/{vhost => server}/locations/uwsgi.erb (100%) rename templates/{vhost/vhost_footer.erb => server/server_footer.erb} (88%) rename templates/{vhost/vhost_header.erb => server/server_header.erb} (98%) rename templates/{vhost/vhost_ssl_footer.erb => server/server_ssl_footer.erb} (78%) rename templates/{vhost/vhost_ssl_header.erb => server/server_ssl_header.erb} (93%) rename templates/{vhost/vhost_ssl_settings.erb => server/server_ssl_settings.erb} (100%) rename templates/{vhost => server}/uwsgi_params.erb (100%) delete mode 100644 templates/vhost/location.erb diff --git a/README.md b/README.md index fac3db09e..31dd6481d 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ class { 'nginx': } ### A simple reverse proxy ```puppet -nginx::resource::vhost { 'kibana.myhost.com': +nginx::resource::server { 'kibana.myhost.com': listen_port => 80, proxy => 'http://localhost:5601', } @@ -46,7 +46,7 @@ nginx::resource::vhost { 'kibana.myhost.com': ### A virtual host with static content ```puppet -nginx::resource::vhost { 'www.puppetlabs.com': +nginx::resource::server { 'www.puppetlabs.com': www_root => '/var/www/www.puppetlabs.com', } ``` @@ -62,7 +62,7 @@ nginx::resource::upstream { 'puppet_rack_app': ], } -nginx::resource::vhost { 'rack.puppetlabs.com': +nginx::resource::server { 'rack.puppetlabs.com': proxy => 'http://puppet_rack_app', } ``` @@ -89,31 +89,31 @@ nginx::resource::mailhost { 'domain1.example': ## SSL configuration -By default, creating a vhost resource will only create a HTTP vhost. To also -create a HTTPS (SSL-enabled) vhost, set `ssl => true` on the vhost. You will +By default, creating a server resource will only create a HTTP server. To also +create a HTTPS (SSL-enabled) server, set `ssl => true` on the server. You will have a HTTP server listening on `listen_port` (port `80` by default) and a HTTPS -server listening on `ssl_port` (port `443` by default). Both vhosts will have +server listening on `ssl_port` (port `443` by default). Both servers will have the same `server_name` and a similar configuration. -To create only a HTTPS vhost, set `ssl => true` and also set `listen_port` to the -same value as `ssl_port`. Setting these to the same value disables the HTTP vhost. -The resulting vhost will be listening on `ssl_port`. +To create only a HTTPS server, set `ssl => true` and also set `listen_port` to the +same value as `ssl_port`. Setting these to the same value disables the HTTP server. +The resulting server will be listening on `ssl_port`. ### Locations Locations require specific settings depending on whether they should be included -in the HTTP, HTTPS or both vhosts. +in the HTTP, HTTPS or both servers. -#### HTTP only vhost (default) +#### HTTP only server (default) -If you only have a HTTP vhost (i.e. `ssl => false` on the vhost) make sure you -don't set `ssl => true` on any location you associate with the vhost. +If you only have a HTTP server (i.e. `ssl => false` on the server) make sure you +don't set `ssl => true` on any location you associate with the server. -#### HTTP and HTTPS vhost +#### HTTP and HTTPS server If you set `ssl => true` and also set `listen_port` and `ssl_port` to different -values on the vhost you will need to be specific with the location settings since -you will have a HTTP vhost listening on `listen_port` and a HTTPS vhost listening +values on the server you will need to be specific with the location settings since +you will have a HTTP server listening on `listen_port` and a HTTPS server listening on `ssl_port`: * To add a location to only the HTTP server, set `ssl => false` on the location @@ -123,11 +123,11 @@ on `ssl_port`: * To add a location only to the HTTPS server, set both `ssl => true` and `ssl_only => true` on the location. -#### HTTPS only vhost +#### HTTPS only server If you have set `ssl => true` and also set `listen_port` and `ssl_port` to the -same value on the vhost, you will have a single HTTPS vhost listening on -`ssl_port`. To add a location to this vhost set `ssl => true` and +same value on the server, you will have a single HTTPS server listening on +`ssl_port`. To add a location to this server set `ssl => true` and `ssl_only => true` on the location. ## Hiera Support @@ -142,7 +142,7 @@ nginx::nginx_upstreams: - localhost:3000 - localhost:3001 - localhost:3002 -nginx::nginx_vhosts: +nginx::nginx_servers: 'www.puppetlabs.com': www_root: '/var/www/www.puppetlabs.com' 'rack.puppetlabs.com': @@ -150,11 +150,11 @@ nginx::nginx_vhosts: nginx::nginx_locations: 'static': location: '~ "^/static/[0-9a-fA-F]{8}\/(.*)$"' - vhost: www.puppetlabs.com + server: www.puppetlabs.com www_root: /var/www/html 'userContent': location: /userContent - vhost: www.puppetlabs.com + server: www.puppetlabs.com www_root: /var/www/html nginx::nginx_mailhosts: 'smtp': @@ -198,9 +198,9 @@ Package source `passenger` will add [Phusion Passenger repository](https://oss-b to APT sources. For each virtual host you should specify which ruby should be used. ```puppet -nginx::resource::vhost { 'www.puppetlabs.com': - www_root => '/var/www/www.puppetlabs.com', - vhost_cfg_append => { +nginx::resource::server { 'www.puppetlabs.com': + www_root => '/var/www/www.puppetlabs.com', + server_cfg_append => { 'passenger_enabled' => 'on', 'passenger_ruby' => '/usr/bin/ruby', } @@ -212,7 +212,7 @@ nginx::resource::vhost { 'www.puppetlabs.com': Virtual host config for serving puppet master: ```puppet -nginx::resource::vhost { 'puppet': +nginx::resource::server { 'puppet': ensure => present, server_name => ['puppet'], listen_port => 8140, @@ -220,7 +220,7 @@ nginx::resource::vhost { 'puppet': ssl_cert => '/var/lib/puppet/ssl/certs/example.com.pem', ssl_key => '/var/lib/puppet/ssl/private_keys/example.com.pem', ssl_port => 8140, - vhost_cfg_append => { + server_cfg_append => { 'passenger_enabled' => 'on', 'passenger_ruby' => '/usr/bin/ruby', 'ssl_crl' => '/var/lib/puppet/ssl/ca/ca_crl.pem', @@ -239,7 +239,7 @@ nginx::resource::vhost { 'puppet': } ``` -### Example puppet class calling nginx::vhost with HTTPS FastCGI and redirection of HTTP +### Example puppet class calling nginx::server with HTTPS FastCGI and redirection of HTTP ```puppet @@ -252,7 +252,7 @@ define web::nginx_ssl_with_redirect ( $www_root = "${full_web_path}/${name}/", $location_cfg_append = undef, ) { - nginx::resource::vhost { "${name}.${::domain}": + nginx::resource::server { "${name}.${::domain}": ensure => present, www_root => "${full_web_path}/${name}/", location_cfg_append => { 'rewrite' => '^ https://$server_name$request_uri? permanent' }, @@ -264,7 +264,7 @@ define web::nginx_ssl_with_redirect ( $tmp_www_root = $www_root } - nginx::resource::vhost { "${name}.${::domain} ${name}": + nginx::resource::server { "${name}.${::domain} ${name}": ensure => present, listen_port => 443, www_root => $tmp_www_root, @@ -282,7 +282,7 @@ define web::nginx_ssl_with_redirect ( ensure => present, ssl => true, ssl_only => true, - vhost => "${name}.${::domain} ${name}", + server => "${name}.${::domain} ${name}", www_root => "${full_web_path}/${name}/", location => '~ \.php$', index_files => ['index.php', 'index.html', 'index.htm'], diff --git a/docs/quickstart.md b/docs/quickstart.md index 32b6b8897..ae09fb482 100644 --- a/docs/quickstart.md +++ b/docs/quickstart.md @@ -22,7 +22,7 @@ The choices here are `nginx-stable` (the current 'production' level release), `n Calling the `nginx` class from your manifest simply installs the NGINX software and puts some basic configuration in place. In this state, NGINX will not serve web pages or proxy to other services - for that, we need to define a *server*. In NGINX terminology, a *server* is how we define our services (such as websites) with a name. (If you are used to configuring Apache, a server is identical to an Apache *virtual host*.) A simple virtual host that serves static web pages can be defined with a server name and a *web root*, or the directory where our HTML pages are located. ``` - nginx::resource::vhost{'www.myhost.com': + nginx::resource::server{'www.myhost.com': www_root => '/opt/html/', } ``` @@ -35,7 +35,7 @@ Setting up a simple static webserver is straightforward, but is usually not the ``` nginx::resource::location{'/blog': proxy => 'http://192.168.99.1/' , - vhost => 'www.myhost.com' + server => 'www.myhost.com' } ``` This will proxy any requests made to `http://www.myhost.com/blog` to the URL `http://192.168.99.1/`. Pay special attention to the use of `/` at the end of the URL we are proxying to - that will allow your query parameters or subfolder structure on your secondary webserver to remain intact. @@ -56,7 +56,7 @@ We can expand on these simple proxies by defining *upstream* resources for our w ``` nginx::resource::location{'/blog': proxy => 'http://upstream_app/' , - vhost => 'www.myhost.com' + server => 'www.myhost.com' } ``` Now `/blog` will proxy requests to services defined in our `upstream_app` resource. @@ -78,13 +78,13 @@ Combining our configurations above into a single manifest, our code block looks ], } - nginx::resource::vhost{'www.myhost.com': + nginx::resource::server{'www.myhost.com': www_root => '/opt/html/', } nginx::resource::location{'/proxy': proxy => 'http://upstream_app/' , - vhost => 'www.myhost.com', + server => 'www.myhost.com', } ``` diff --git a/examples/location_alias.pp b/examples/location_alias.pp index 689768b5f..afc925a69 100644 --- a/examples/location_alias.pp +++ b/examples/location_alias.pp @@ -4,5 +4,5 @@ ensure => present, location => '/some/url', location_alias => '/new/url/', - vhost => 'www.test.com', + server => 'www.test.com', } diff --git a/examples/location_params.pp b/examples/location_params.pp index 40f532e88..4eaf2fd78 100644 --- a/examples/location_params.pp +++ b/examples/location_params.pp @@ -3,7 +3,7 @@ ::nginx::resource::location { 'www.test.com-params': ensure => present, location => '/some/url', - vhost => 'www.test.com', + server => 'www.test.com', fastcgi_param => { 'APP_ENV' => 'production', 'APP_VERSION' => '0.1.10', diff --git a/examples/vhost.pp b/examples/server.pp similarity index 73% rename from examples/vhost.pp rename to examples/server.pp index f50634b6e..59c996e1d 100644 --- a/examples/vhost.pp +++ b/examples/server.pp @@ -1,12 +1,12 @@ include ::nginx -::nginx::resource::vhost { 'test.local test': +::nginx::resource::server { 'test.local test': ensure => present, ipv6_enable => true, proxy => 'http://proxypass', } -::nginx::resource::vhost { 'test.local:8080': +::nginx::resource::server { 'test.local:8080': ensure => present, listen_port => 8080, server_name => ['test.local test'], diff --git a/examples/vhost_ssl.pp b/examples/server_ssl.pp similarity index 82% rename from examples/vhost_ssl.pp rename to examples/server_ssl.pp index cef2c9e96..fc34f29b8 100644 --- a/examples/vhost_ssl.pp +++ b/examples/server_ssl.pp @@ -1,6 +1,6 @@ include ::nginx -::nginx::resource::vhost { 'test3.local test3': +::nginx::resource::server { 'test3.local test3': ensure => present, www_root => '/var/www/nginx-default', ssl => true, @@ -9,7 +9,7 @@ ssl_key => 'puppet:///modules/sslkey/whildcard_mydomain.key', } -::nginx::resource::vhost { 'test2.local test2': +::nginx::resource::server { 'test2.local test2': ensure => present, www_root => '/var/www/nginx-default', ssl => true, @@ -21,12 +21,12 @@ ensure => present, www_root => '/var/www/bob', location => '/bob', - vhost => 'test2.local test2', + server => 'test2.local test2', } ::nginx::resource::location { 'test3.local-bob': ensure => present, www_root => '/var/www/bob', location => '/bob', - vhost => 'test3.local test3', + server => 'test3.local test3', } diff --git a/manifests/config.pp b/manifests/config.pp index 31b24e1be..b0195b6f6 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -42,7 +42,7 @@ $sites_available_mode = $::nginx::sites_available_mode $super_user = $::nginx::super_user $temp_dir = $::nginx::temp_dir - $vhost_purge = $::nginx::vhost_purge + $server_purge = $::nginx::server_purge $accept_mutex = $::nginx::accept_mutex $accept_mutex_delay = $::nginx::accept_mutex_delay $client_body_buffer_size = $::nginx::client_body_buffer_size @@ -132,10 +132,10 @@ ensure => directory, } if $confd_purge { - # Err on the side of caution - make sure *both* $vhost_purge and + # Err on the side of caution - make sure *both* $server_purge and # $confd_purge are set if $confd_only is set, before purging files # ${conf_dir}/conf.d - if (($confd_only and $vhost_purge) or !$confd_only) { + if (($confd_only and $server_purge) or !$confd_only) { File["${conf_dir}/conf.d"] { purge => true, recurse => true, @@ -194,7 +194,7 @@ file { "${conf_dir}/sites-enabled": ensure => directory, } - if $vhost_purge { + if $server_purge { File["${conf_dir}/sites-available"] { purge => true, recurse => true, @@ -214,7 +214,7 @@ file { "${conf_dir}/streams-available": ensure => directory, } - if $vhost_purge { + if $server_purge { File["${conf_dir}/streams-enabled"] { purge => true, recurse => true, diff --git a/manifests/init.pp b/manifests/init.pp index 0fbced137..efa0d56ec 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -52,7 +52,7 @@ $sites_available_mode = $::nginx::params::sites_available_mode, $super_user = $::nginx::params::super_user, $temp_dir = $::nginx::params::temp_dir, - $vhost_purge = false, + $server_purge = false, # Primary Templates $conf_template = 'nginx/conf.d/nginx.conf.erb', @@ -154,8 +154,8 @@ $nginx_mailhosts = {}, $nginx_streamhosts = {}, $nginx_upstreams = {}, - $nginx_vhosts = {}, - $nginx_vhosts_defaults = {}, + $nginx_servers = {}, + $nginx_servers_defaults = {}, ### END Hiera Lookups ### ) inherits ::nginx::params { @@ -184,7 +184,7 @@ } validate_bool($confd_only) validate_bool($confd_purge) - validate_bool($vhost_purge) + validate_bool($server_purge) if ( $proxy_cache_path != false) { if ( is_string($proxy_cache_path) or is_hash($proxy_cache_path)) {} else { @@ -272,7 +272,7 @@ Class['::nginx::package'] -> Class['::nginx::config'] ~> Class['::nginx::service'] create_resources('nginx::resource::upstream', $nginx_upstreams) - create_resources('nginx::resource::vhost', $nginx_vhosts, $nginx_vhosts_defaults) + 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::streamhost', $nginx_streamhosts) diff --git a/manifests/resource/location.pp b/manifests/resource/location.pp index 2a0f0b5fe..a11c69f8c 100644 --- a/manifests/resource/location.pp +++ b/manifests/resource/location.pp @@ -7,7 +7,7 @@ # (present|absent) # [*internal*] - Indicates whether or not this loation can be # used for internal requests only. Default: false -# [*vhost*] - Defines the default vHost for this location +# [*server*] - Defines the default server for this location # entry to include with # [*location*] - Specifies the URI associated with this location # entry @@ -30,9 +30,9 @@ # value of 90 seconds # [*proxy_connect_timeout*] - Override the default the proxy connect timeout # value of 90 seconds -# [*proxy_set_header*] - Array of vhost headers to set -# [*proxy_hide_header*] - Array of vhost headers to hide -# [*proxy_pass_header*] - Array of vhost headers to pass +# [*proxy_set_header*] - Array of server headers to set +# [*proxy_hide_header*] - Array of server headers to hide +# [*proxy_pass_header*] - Array of server headers to pass # [*fastcgi*] - location of fastcgi (host:port) # [*fastcgi_param*] - Set additional custom fastcgi_params # [*fastcgi_params*] - optional alternative fastcgi_params file to use @@ -45,7 +45,7 @@ # [*uwsgi_read_timeout*] - optional value for uwsgi_read_timeout # [*ssl*] - Indicates whether to setup SSL bindings for # this location. -# [*ssl_only*] - Required if the SSL and normal vHost have the +# [*ssl_only*] - Required if the SSL and normal server have the # same port. # [*location_alias*] - Path to be used as basis for serving requests # for this location @@ -111,7 +111,7 @@ # ensure => present, # www_root => '/var/www/bob', # location => '/bob', -# vhost => 'test2.local', +# server => 'test2.local', # } # # Custom config example to limit location on localhost, @@ -125,92 +125,92 @@ # ensure => present, # www_root => '/var/www/bob', # location => '/bob', -# vhost => 'test2.local', +# server => 'test2.local', # location_cfg_append => $my_config, # } # # Add Custom fastcgi_params # nginx::resource::location { 'test2.local-bob': -# ensure => present, -# www_root => '/var/www/bob', -# location => '/bob', -# vhost => 'test2.local', +# ensure => present, +# www_root => '/var/www/bob', +# location => '/bob', +# server => 'test2.local', # fastcgi_param => { -# 'APP_ENV' => 'local', +# 'APP_ENV' => 'local', # } # } # # Add Custom uwsgi_params # nginx::resource::location { 'test2.local-bob': -# ensure => present, -# www_root => '/var/www/bob', -# location => '/bob', -# vhost => 'test2.local', -# uwsgi_param => { +# ensure => present, +# www_root => '/var/www/bob', +# location => '/bob', +# server => 'test2.local', +# uwsgi_param => { # 'APP_ENV' => 'local', # } # } define nginx::resource::location ( - $ensure = present, - $internal = false, - $location = $name, - $vhost = undef, - $www_root = undef, - $autoindex = undef, - $index_files = [ + $ensure = present, + $internal = false, + $location = $name, + $server = undef, + $www_root = undef, + $autoindex = undef, + $index_files = [ 'index.html', 'index.htm', 'index.php'], - $proxy = undef, - $proxy_redirect = $::nginx::proxy_redirect, - $proxy_read_timeout = $::nginx::proxy_read_timeout, - $proxy_connect_timeout = $::nginx::proxy_connect_timeout, - $proxy_set_header = $::nginx::proxy_set_header, - $proxy_hide_header = $::nginx::proxy_hide_header, - $proxy_pass_header = $::nginx::proxy_pass_header, - $fastcgi = undef, - $fastcgi_index = undef, - $fastcgi_param = undef, - $fastcgi_params = "${::nginx::conf_dir}/fastcgi_params", - $fastcgi_script = undef, - $fastcgi_split_path = undef, - $uwsgi = undef, - $uwsgi_param = undef, - $uwsgi_params = "${nginx::config::conf_dir}/uwsgi_params", - $uwsgi_read_timeout = undef, - $ssl = false, - $ssl_only = false, - $location_alias = undef, - $location_satisfy = undef, - $location_allow = undef, - $location_deny = undef, - $option = undef, - $stub_status = undef, - $raw_prepend = undef, - $raw_append = undef, - $location_custom_cfg = undef, - $location_cfg_prepend = undef, - $location_cfg_append = undef, - $location_custom_cfg_prepend = undef, - $location_custom_cfg_append = undef, - $include = undef, - $try_files = undef, - $proxy_cache = false, - $proxy_cache_key = undef, - $proxy_cache_use_stale = undef, - $proxy_cache_valid = false, - $proxy_method = undef, - $proxy_http_version = undef, - $proxy_set_body = undef, - $proxy_buffering = undef, - $auth_basic = undef, - $auth_basic_user_file = undef, - $rewrite_rules = [], - $priority = 500, - $mp4 = false, - $flv = false, - $expires = undef, + $proxy = undef, + $proxy_redirect = $::nginx::proxy_redirect, + $proxy_read_timeout = $::nginx::proxy_read_timeout, + $proxy_connect_timeout = $::nginx::proxy_connect_timeout, + $proxy_set_header = $::nginx::proxy_set_header, + $proxy_hide_header = $::nginx::proxy_hide_header, + $proxy_pass_header = $::nginx::proxy_pass_header, + $fastcgi = undef, + $fastcgi_index = undef, + $fastcgi_param = undef, + $fastcgi_params = "${::nginx::conf_dir}/fastcgi_params", + $fastcgi_script = undef, + $fastcgi_split_path = undef, + $uwsgi = undef, + $uwsgi_param = undef, + $uwsgi_params = "${nginx::config::conf_dir}/uwsgi_params", + $uwsgi_read_timeout = undef, + $ssl = false, + $ssl_only = false, + $location_alias = undef, + $location_satisfy = undef, + $location_allow = undef, + $location_deny = undef, + $option = undef, + $stub_status = undef, + $raw_prepend = undef, + $raw_append = undef, + $location_custom_cfg = undef, + $location_cfg_prepend = undef, + $location_cfg_append = undef, + $location_custom_cfg_prepend = undef, + $location_custom_cfg_append = undef, + $include = undef, + $try_files = undef, + $proxy_cache = false, + $proxy_cache_key = undef, + $proxy_cache_use_stale = undef, + $proxy_cache_valid = false, + $proxy_method = undef, + $proxy_http_version = undef, + $proxy_set_body = undef, + $proxy_buffering = undef, + $auth_basic = undef, + $auth_basic_user_file = undef, + $rewrite_rules = [], + $priority = 500, + $mp4 = false, + $flv = false, + $expires = undef, ) { $root_group = $::nginx::root_group @@ -225,8 +225,8 @@ validate_re($ensure, '^(present|absent)$', "${ensure} is not supported for ensure. Allowed values are 'present' and 'absent'.") validate_string($location) - if ($vhost != undef) { - validate_string($vhost) + if ($server != undef) { + validate_string($server) } if ($www_root != undef) { validate_string($www_root) @@ -377,14 +377,14 @@ } ## Check for various error conditions - if ($vhost == undef) { + if ($server == undef) { fail('Cannot create a location reference without attaching to a virtual host') } if !($www_root or $proxy or $location_alias or $stub_status or $fastcgi or $uwsgi or $location_custom_cfg or $internal or $try_files or $location_allow or $location_deny) { - fail("Cannot create a location reference without a www_root, proxy, location_alias, stub_status, fastcgi, uwsgi, location_custom_cfg, internal, try_files, location_allow, or location_deny defined in ${vhost}:${title}") + fail("Cannot create a location reference without a www_root, proxy, location_alias, stub_status, fastcgi, uwsgi, location_custom_cfg, internal, try_files, location_allow, or location_deny defined in ${server}:${title}") } if ($www_root and $proxy) { - fail("Cannot define both directory and proxy in ${vhost}:${title}") + fail("Cannot define both directory and proxy in ${server}:${title}") } # Use proxy, fastcgi or uwsgi template if $proxy is defined, otherwise use directory template. @@ -393,14 +393,14 @@ warning('The $fastcgi_script parameter is deprecated; please use $fastcgi_param instead to define custom fastcgi_params!') } - $vhost_sanitized = regsubst($vhost, ' ', '_', 'G') + $server_sanitized = regsubst($server, ' ', '_', 'G') if $::nginx::confd_only { - $vhost_dir = "${::nginx::conf_dir}/conf.d" + $server_dir = "${::nginx::conf_dir}/conf.d" } else { - $vhost_dir = "${::nginx::conf_dir}/sites-available" + $server_dir = "${::nginx::conf_dir}/sites-available" } - $config_file = "${vhost_dir}/${vhost_sanitized}.conf" + $config_file = "${server_dir}/${server_sanitized}.conf" $location_sanitized_tmp = regsubst($location, '\/', '_', 'G') $location_sanitized = regsubst($location_sanitized_tmp, '\\\\', '_', 'G') @@ -409,7 +409,7 @@ file { $fastcgi_params: ensure => present, mode => '0770', - content => template('nginx/vhost/fastcgi_params.erb'), + content => template('nginx/server/fastcgi_params.erb'), } } @@ -417,17 +417,17 @@ file { $uwsgi_params: ensure => present, mode => '0770', - content => template('nginx/vhost/uwsgi_params.erb'), + content => template('nginx/server/uwsgi_params.erb'), } } if $ensure == present { - ## Create stubs for vHost File Fragment Pattern + ## Create stubs for server File Fragment Pattern $location_md5 = md5($location) if ($ssl_only != true) { - concat::fragment { "${vhost_sanitized}-${priority}-${location_md5}": + concat::fragment { "${server_sanitized}-${priority}-${location_md5}": target => $config_file, - content => template('nginx/vhost/location.erb'), + content => template('nginx/server/location.erb'), order => $priority, } } @@ -436,9 +436,9 @@ if ($ssl == true or $ssl_only == true) { $ssl_priority = $priority + 300 - concat::fragment { "${vhost_sanitized}-${ssl_priority}-${location_md5}-ssl": + concat::fragment { "${server_sanitized}-${ssl_priority}-${location_md5}-ssl": target => $config_file, - content => template('nginx/vhost/location.erb'), + content => template('nginx/server/location.erb'), order => $ssl_priority, } } diff --git a/manifests/resource/mailhost.pp b/manifests/resource/mailhost.pp index 0ad1d467d..5567f7826 100644 --- a/manifests/resource/mailhost.pp +++ b/manifests/resource/mailhost.pp @@ -4,13 +4,13 @@ # # Parameters: # [*ensure*] - Enables or disables the specified mailhost (present|absent) -# [*listen_ip*] - Default IP Address for NGINX to listen with this vHost on. Defaults to all interfaces (*) -# [*listen_port*] - Default IP Port for NGINX to listen with this vHost on. Defaults to TCP 80 +# [*listen_ip*] - Default IP Address for NGINX to listen with this server on. Defaults to all interfaces (*) +# [*listen_port*] - Default IP Port for NGINX to listen with this server on. Defaults to TCP 80 # [*listen_options*] - Extra options for listen directive like 'default' to catchall. Undef by default. # [*ipv6_enable*] - BOOL value to enable/disable IPv6 support (false|true). Module will check to see if IPv6 # support exists on your system before enabling. -# [*ipv6_listen_ip*] - Default IPv6 Address for NGINX to listen with this vHost on. Defaults to all interfaces (::) -# [*ipv6_listen_port*] - Default IPv6 Port for NGINX to listen with this vHost on. Defaults to TCP 80 +# [*ipv6_listen_ip*] - Default IPv6 Address for NGINX to listen with this server on. Defaults to all interfaces (::) +# [*ipv6_listen_port*] - Default IPv6 Port for NGINX to listen with this server on. Defaults to TCP 80 # [*ipv6_listen_options*] - Extra options for listen directive like 'default' to catchall. Template will allways add ipv6only=on. # While issue jfryman/puppet-nginx#30 is discussed, default value is 'default'. # [*index_files*] - Default index files for NGINX to read when traversing a directory @@ -24,7 +24,7 @@ # [*ssl_ecdh_curve*] - This directive specifies a curve for ECDHE ciphers. # [*ssl_key*] - Pre-generated SSL Key file to reference for SSL Support. This is not generated by this module. # [*ssl_password_file*] - This directive specifies a file containing passphrases for secret keys. -# [*ssl_port*] - Default IP Port for NGINX to listen with this SSL vHost on. Defaults to TCP 443 +# [*ssl_port*] - Default IP Port for NGINX to listen with this SSL server on. Defaults to TCP 443 # [*ssl_protocols*] - SSL protocols enabled. Defaults to nginx::ssl_protocols # [*ssl_session_cache*] - Sets the type and size of the session cache. # [*ssl_session_ticket_key*] - This directive specifies a file containing secret key used to encrypt and decrypt TLS session tickets. @@ -49,8 +49,8 @@ # [*server_name*] - List of mailhostnames for which this mailhost will respond. Default [$name]. # [*raw_prepend*] - A single string, or an array of strings to prepend to the server directive (after mailhost_cfg_prepend directive). NOTE: YOU are responsible for a semicolon on each line that requires one. # [*raw_append*] - A single string, or an array of strings to append to the server directive (after mailhost_cfg_append directive). NOTE: YOU are responsible for a semicolon on each line that requires one. -# [*mailhost_cfg_append*] - It expects a hash with custom directives to put after everything else inside vhost -# [*mailhost_cfg_prepend*] - It expects a hash with custom directives to put before everything else inside vhost +# [*mailhost_cfg_append*] - It expects a hash with custom directives to put after everything else inside server +# [*mailhost_cfg_prepend*] - It expects a hash with custom directives to put before everything else inside server # # Actions: # diff --git a/manifests/resource/vhost.pp b/manifests/resource/server.pp similarity index 90% rename from manifests/resource/vhost.pp rename to manifests/resource/server.pp index 6fca138ca..e815cae5b 100644 --- a/manifests/resource/vhost.pp +++ b/manifests/resource/server.pp @@ -1,20 +1,20 @@ -# define: nginx::resource::vhost +# define: nginx::resource::server # # This definition creates a virtual host # # Parameters: -# [*ensure*] - Enables or disables the specified vhost +# [*ensure*] - Enables or disables the specified server # (present|absent) # [*listen_ip*] - Default IP Address for NGINX to listen with this -# vHost on. Defaults to all interfaces (*) +# server on. Defaults to all interfaces (*) # [*listen_port*] - Default IP Port for NGINX to listen with this -# vHost on. Defaults to TCP 80 +# server on. Defaults to TCP 80 # [*listen_options*] - Extra options for listen directive like # 'default_server' to catchall. Undef by default. # [*listen_unix_socket_enable*] - BOOL value to enable/disable UNIX socket # listening support (false|true). # [*listen_unix_socket*] - Default unix socket for NGINX to listen with this -# vHost on. Defaults to UNIX /var/run/nginx.sock +# server on. Defaults to UNIX /var/run/nginx.sock # [*listen_unix_socket_options*] - Extra options for listen directive like # 'default' to catchall. Undef by default. # [*location_satisfy*] - Allows access if all (all) or at least one (any) of the auth modules allow access. @@ -24,9 +24,9 @@ # (false|true). Module will check to see if IPv6 support exists on your # system before enabling. # [*ipv6_listen_ip*] - Default IPv6 Address for NGINX to listen with -# this vHost on. Defaults to all interfaces (::) +# this server on. Defaults to all interfaces (::) # [*ipv6_listen_port*] - Default IPv6 Port for NGINX to listen with this -# vHost on. Defaults to TCP 80 +# server on. Defaults to TCP 80 # [*ipv6_listen_options*] - Extra options for listen directive like 'default' # to catchall. Template will allways add ipv6only=on. While issue # jfryman/puppet-nginx#30 is discussed, default value is 'default'. @@ -51,7 +51,7 @@ # [*fastcgi_script*] - optional SCRIPT_FILE parameter # [*uwsgi_read_timeout*] - optional value for uwsgi_read_timeout # [*ssl*] - Indicates whether to setup SSL bindings for this -# vhost. +# server. # [*ssl_cert*] - Pre-generated SSL Certificate file to reference # for SSL Support. This is not generated by this module. Set to `false` to # inherit from the http section, which improves performance by conserving @@ -65,13 +65,13 @@ # format, utilized for exchanging session keys between server and client. # [*ssl_redirect*] - Adds a server directive and return statement to # force ssl redirect. Will honor ssl_port if it's set. -# [*ssl_redirect_port*] - Overrides $ssl_port in the SSL redirect set by +# [*ssl_redirect_port*] - Overrides $ssl_port in the SSL redirect set by # ssl_redirect # [*ssl_key*] - Pre-generated SSL Key file to reference for SSL # Support. This is not generated by this module. Set to `false` to inherit # from the http section, which improves performance by conserving memory. # [*ssl_port*] - Default IP Port for NGINX to listen with this SSL -# vHost on. Defaults to TCP 443 +# server on. Defaults to TCP 443 # [*ssl_protocols*] - SSL protocols enabled. Defaults to 'TLSv1 TLSv1.1 # TLSv1.2'. # [*ssl_buffer_size*] - Sets the size of the buffer used for sending data. @@ -98,7 +98,7 @@ # OCSP responses if ssl_stapling is enabled. # [*spdy*] - Toggles SPDY protocol. # [*http2*] - Toggles HTTP/2 protocol. -# [*server_name*] - List of vhostnames for which this vhost will +# [*server_name*] - List of servernames for which this server will # respond. Default [$name]. # [*www_root*] - Specifies the location on disk for files to be # read from. Cannot be set in conjunction with $proxy @@ -140,24 +140,24 @@ # [*location_raw_append*] - A single string, or an array of strings # to append to the location directive (after custom_cfg directives). NOTE: # YOU are responsible for a semicolon on each line that requires one. -# [*vhost_cfg_append*] - It expects a hash with custom directives to -# put after everything else inside vhost -# [*vhost_cfg_prepend*] - It expects a hash with custom directives to -# put before everything else inside vhost -# [*vhost_cfg_ssl_append*] - It expects a hash with custom directives to -# put after everything else inside vhost ssl -# [*vhost_cfg_ssl_prepend*] - It expects a hash with custom directives to -# put before everything else inside vhost ssl -# [*include_files*] - Adds include files to vhost +# [*server_cfg_append*] - It expects a hash with custom directives to +# put after everything else inside server +# [*server_cfg_prepend*] - It expects a hash with custom directives to +# put before everything else inside server +# [*server_cfg_ssl_append*] - It expects a hash with custom directives to +# put after everything else inside server ssl +# [*server_cfg_ssl_prepend*] - It expects a hash with custom directives to +# put before everything else inside server ssl +# [*include_files*] - Adds include files to server # [*access_log*] - Where to write access log (log format can be # set with $format_log). This can be either a string or an array; in the # latter case, multiple lines will be created. Additionally, unlike the -# earlier behavior, setting it to 'absent' in the vhost context will remove -# this directive entirely from the vhost stanza, rather than setting a -# default. Can also be disabled for this vhost with the string 'off'. +# earlier behavior, setting it to 'absent' in the server context will remove +# this directive entirely from the server stanza, rather than setting a +# default. Can also be disabled for this server with the string 'off'. # [*error_log*] - Where to write error log. May add additional # options like error level to the end. May set to 'absent', in which case -# it will be omitted in this vhost stanza (and default to nginx.conf setting) +# it will be omitted in this server stanza (and default to nginx.conf setting) # [*passenger_cgi_param*] - Allows one to define additional CGI environment # variables to pass to the backend application # [*passenger_set_header*] - Allows one to set headers to pass to the @@ -177,25 +177,25 @@ # [*owner*] - Defines owner of the .conf file # [*group*] - Defines group of the .conf file # [*mode*] - Defines mode of the .conf file -# [*maintenance*] - A boolean value to set a vhost in maintenance +# [*maintenance*] - A boolean value to set a server in maintenance # [*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 vhosts ressources used by this vhost +# [*locations*] - Hash of servers ressources used by this server # Actions: # # Requires: # # Sample Usage: -# nginx::resource::vhost { 'test2.local': +# nginx::resource::server { 'test2.local': # ensure => present, # www_root => '/var/www/nginx-default', # ssl => true, # ssl_cert => '/tmp/server.crt', # ssl_key => '/tmp/server.pem', # } -define nginx::resource::vhost ( +define nginx::resource::server ( $ensure = 'present', $listen_ip = '*', $listen_port = 80, @@ -282,10 +282,10 @@ $raw_append = undef, $location_raw_prepend = undef, $location_raw_append = undef, - $vhost_cfg_prepend = undef, - $vhost_cfg_append = undef, - $vhost_cfg_ssl_prepend = undef, - $vhost_cfg_ssl_append = undef, + $server_cfg_prepend = undef, + $server_cfg_append = undef, + $server_cfg_ssl_prepend = undef, + $server_cfg_ssl_append = undef, $include_files = undef, $access_log = undef, $error_log = undef, @@ -511,17 +511,17 @@ if ($auth_basic_user_file != undef) { validate_string($auth_basic_user_file) } - if ($vhost_cfg_prepend != undef) { - validate_hash($vhost_cfg_prepend) + if ($server_cfg_prepend != undef) { + validate_hash($server_cfg_prepend) } - if ($vhost_cfg_append != undef) { - validate_hash($vhost_cfg_append) + if ($server_cfg_append != undef) { + validate_hash($server_cfg_append) } - if ($vhost_cfg_ssl_prepend != undef) { - validate_hash($vhost_cfg_ssl_prepend) + if ($server_cfg_ssl_prepend != undef) { + validate_hash($server_cfg_ssl_prepend) } - if ($vhost_cfg_ssl_append != undef) { - validate_hash($vhost_cfg_ssl_append) + if ($server_cfg_ssl_append != undef) { + validate_hash($server_cfg_ssl_append) } if ($include_files != undef) { validate_array($include_files) @@ -570,18 +570,18 @@ # Variables if $::nginx::confd_only { - $vhost_dir = "${::nginx::conf_dir}/conf.d" + $server_dir = "${::nginx::conf_dir}/conf.d" } else { - $vhost_dir = "${::nginx::conf_dir}/sites-available" - $vhost_enable_dir = "${::nginx::conf_dir}/sites-enabled" - $vhost_symlink_ensure = $ensure ? { + $server_dir = "${::nginx::conf_dir}/sites-available" + $server_enable_dir = "${::nginx::conf_dir}/sites-enabled" + $server_symlink_ensure = $ensure ? { 'absent' => absent, default => 'link', } } $name_sanitized = regsubst($name, ' ', '_', 'G') - $config_file = "${vhost_dir}/${name_sanitized}.conf" + $config_file = "${server_dir}/${name_sanitized}.conf" File { ensure => $ensure ? { @@ -615,7 +615,7 @@ group => $group, mode => $mode, notify => Class['::nginx::service'], - require => File[$vhost_dir], + require => File[$server_dir], } # This deals with a situation where the listen directive for SSL doesn't match @@ -635,10 +635,10 @@ } if $use_default_location == true { - # Create the default location reference for the vHost + # Create the default location reference for the server nginx::resource::location {"${name_sanitized}-default": ensure => $ensure, - vhost => $name_sanitized, + server => $name_sanitized, ssl => $ssl, ssl_only => $ssl_only, location => '/', @@ -690,7 +690,7 @@ file { $fastcgi_params: ensure => present, mode => '0770', - content => template('nginx/vhost/fastcgi_params.erb'), + content => template('nginx/server/fastcgi_params.erb'), } } @@ -698,14 +698,14 @@ file { $uwsgi_params: ensure => present, mode => '0660', - content => template('nginx/vhost/uwsgi_params.erb'), + content => template('nginx/server/uwsgi_params.erb'), } } if (($listen_port + 0) != ($ssl_port + 0)) { concat::fragment { "${name_sanitized}-header": target => $config_file, - content => template('nginx/vhost/vhost_header.erb'), + content => template('nginx/server/server_header.erb'), order => '001', } } @@ -714,7 +714,7 @@ if (($listen_port + 0) != ($ssl_port + 0)) { concat::fragment { "${name_sanitized}-footer": target => $config_file, - content => template('nginx/vhost/vhost_footer.erb'), + content => template('nginx/server/server_footer.erb'), order => '699', } } @@ -725,22 +725,22 @@ concat::fragment { "${name_sanitized}-ssl-header": target => $config_file, - content => template('nginx/vhost/vhost_ssl_header.erb'), + content => template('nginx/server/server_ssl_header.erb'), order => '700', } concat::fragment { "${name_sanitized}-ssl-footer": target => $config_file, - content => template('nginx/vhost/vhost_ssl_footer.erb'), + content => template('nginx/server/server_ssl_footer.erb'), order => '999', } } unless $::nginx::confd_only { file{ "${name_sanitized}.conf symlink": - ensure => $vhost_symlink_ensure, - path => "${vhost_enable_dir}/${name_sanitized}.conf", + ensure => $server_symlink_ensure, + path => "${server_enable_dir}/${name_sanitized}.conf", target => $config_file, - require => [File[$vhost_dir], File[$vhost_enable_dir], Concat[$config_file]], + require => [File[$server_dir], File[$server_enable_dir], Concat[$config_file]], notify => Class['::nginx::service'], } } @@ -749,7 +749,7 @@ create_resources('::nginx::resource::geo', $geo_mappings) create_resources('::nginx::resource::location', $locations, { ensure => $ensure, - vhost => $name_sanitized, + server => $name_sanitized, ssl => $ssl, ssl_only => $ssl_only, www_root => $www_root, diff --git a/manifests/service.pp b/manifests/service.pp index 2e753b9bf..587ed2569 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -1,6 +1,6 @@ # Class: nginx::service # -# This module manages NGINX service management and vhost rebuild +# This module manages NGINX service management and server rebuild # # Parameters: # diff --git a/spec/acceptance/nginx_proxy_spec.rb b/spec/acceptance/nginx_proxy_spec.rb index f69e56b2b..839f854bc 100644 --- a/spec/acceptance/nginx_proxy_spec.rb +++ b/spec/acceptance/nginx_proxy_spec.rb @@ -12,7 +12,7 @@ class { 'nginx': } 'localhost:3002', ], } - nginx::resource::vhost { 'rack.puppetlabs.com': + nginx::resource::server { 'rack.puppetlabs.com': ensure => present, proxy => 'http://puppet_rack_app', } diff --git a/spec/acceptance/nginx_vhost_spec.rb b/spec/acceptance/nginx_server_spec.rb similarity index 92% rename from spec/acceptance/nginx_vhost_spec.rb rename to spec/acceptance/nginx_server_spec.rb index 62798e2a4..c660b71e2 100644 --- a/spec/acceptance/nginx_vhost_spec.rb +++ b/spec/acceptance/nginx_server_spec.rb @@ -1,11 +1,11 @@ require 'spec_helper_acceptance' -describe 'nginx::resource::vhost define:' do - context 'new vhost on port 80' do - it 'configures a nginx vhost' do +describe 'nginx::resource::server define:' do + context 'new server on port 80' do + it 'configures a nginx server' do pp = " class { 'nginx': } - nginx::resource::vhost { 'www.puppetlabs.com': + nginx::resource::server { 'www.puppetlabs.com': ensure => present, www_root => '/var/www/www.puppetlabs.com', } @@ -48,10 +48,10 @@ class { 'nginx': } end context 'should run successfully with ssl' do - it 'configures a nginx SSL vhost' do + it 'configures a nginx SSL server' do pp = " class { 'nginx': } - nginx::resource::vhost { 'www.puppetlabs.com': + nginx::resource::server { 'www.puppetlabs.com': ensure => present, ssl => true, ssl_cert => '/etc/pki/tls/certs/blah.cert', diff --git a/spec/classes/nginx_spec.rb b/spec/classes/nginx_spec.rb index 0a9130dcf..9b2b3da0e 100644 --- a/spec/classes/nginx_spec.rb +++ b/spec/classes/nginx_spec.rb @@ -10,9 +10,9 @@ let :params do { nginx_upstreams: { 'upstream1' => { 'members' => ['localhost:3000'] } }, - nginx_vhosts: { 'test2.local' => { 'www_root' => '/' } }, - nginx_vhosts_defaults: { 'listen_options' => 'default_server' }, - nginx_locations: { 'test2.local' => { 'vhost' => 'test2.local', 'www_root' => '/' } }, + nginx_servers: { 'test2.local' => { 'www_root' => '/' } }, + 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_streamhosts: { 'streamhost1' => { 'proxy' => 'streamproxy' } } } @@ -29,8 +29,8 @@ it { is_expected.to contain_class('nginx::service').that_subscribes_to('Class[nginx::config]') } it { is_expected.to contain_anchor('nginx::end').that_requires('Class[nginx::service]') } it { is_expected.to contain_nginx__resource__upstream('upstream1') } - it { is_expected.to contain_nginx__resource__vhost('test2.local') } - it { is_expected.to contain_nginx__resource__vhost('test2.local').with_listen_options('default_server') } + it { is_expected.to contain_nginx__resource__server('test2.local') } + 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__streamhost('streamhost1').with_proxy('streamproxy') } @@ -945,8 +945,8 @@ end end - context 'when vhost_purge true' do - let(:params) { { vhost_purge: true } } + context 'when server_purge true' do + let(:params) { { server_purge: true } } it do is_expected.to contain_file('/etc/nginx/sites-available').with( purge: true, @@ -961,12 +961,12 @@ end end - context 'when confd_purge true, vhost_purge true, and confd_only true' do + context 'when confd_purge true, server_purge true, and confd_only true' do let(:params) do { confd_purge: true, confd_only: true, - vhost_purge: true + server_purge: true } end it do @@ -983,7 +983,7 @@ end end - context 'when confd_purge true, vhost_purge default (false), confd_only true' do + context 'when confd_purge true, server_purge default (false), confd_only true' do let(:params) do { confd_purge: true, @@ -1006,8 +1006,8 @@ end end - context 'when vhost_purge false' do - let(:params) { { vhost_purge: false } } + context 'when server_purge false' do + let(:params) { { server_purge: false } } it do is_expected.to contain_file('/etc/nginx/sites-available').without( %w( diff --git a/spec/defines/resource_location_spec.rb b/spec/defines/resource_location_spec.rb index 42253f1d6..13583b073 100644 --- a/spec/defines/resource_location_spec.rb +++ b/spec/defines/resource_location_spec.rb @@ -16,18 +16,18 @@ let :params do { www_root: '/var/www/rspec', - vhost: 'vhost1' + server: 'server1' } end it { is_expected.to contain_class('nginx::config') } - it { is_expected.to contain_concat__fragment('vhost1-500-33c6aa94600c830ad2d316bb4db36724').with_content(%r{location rspec-test}) } + it { is_expected.to contain_concat__fragment('server1-500-33c6aa94600c830ad2d316bb4db36724').with_content(%r{location rspec-test}) } it { is_expected.not_to contain_file('/etc/nginx/fastcgi_params') } - it { is_expected.not_to contain_concat__fragment('vhost1-800-rspec-test-ssl') } + it { is_expected.not_to contain_concat__fragment('server1-800-rspec-test-ssl') } it { is_expected.not_to contain_file('/etc/nginx/rspec-test_htpasswd') } end - describe 'vhost/location_header template content' do + describe 'server/location_header template content' do [ { title: 'should set the location', @@ -175,13 +175,13 @@ } ].each do |param| context "when #{param[:attr]} is #{param[:value]}" do - let(:default_params) { { location: 'location', proxy: 'proxy_value', vhost: 'vhost1' } } + let(:default_params) { { location: 'location', proxy: 'proxy_value', server: 'server1' } } let(:params) { default_params.merge(param[:attr].to_sym => param[:value]) } - it { is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)) } + it { is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)) } it param[:title] do - fragment = 'vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s) + fragment = 'server1-500-' + Digest::MD5.hexdigest(params[:location].to_s) matches = Array(param[:match]) if matches.all? { |m| m.is_a? Regexp } @@ -192,14 +192,14 @@ end Array(param[:notmatch]).each do |item| - is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)).without_content(item) + is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)).without_content(item) end end end end end - describe 'vhost/location_footer template content' do + describe 'server/location_footer template content' do [ { title: 'should contain ordered appended directives', @@ -252,13 +252,13 @@ } ].each do |param| context "when #{param[:attr]} is #{param[:value]}" do - let(:default_params) { { location: 'location', proxy: 'proxy_value', vhost: 'vhost1' } } + let(:default_params) { { location: 'location', proxy: 'proxy_value', server: 'server1' } } let(:params) { default_params.merge(param[:attr].to_sym => param[:value]) } - it { is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)) } + it { is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)) } it param[:title] do - fragment = 'vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s) + fragment = 'server1-500-' + Digest::MD5.hexdigest(params[:location].to_s) matches = Array(param[:match]) if matches.all? { |m| m.is_a? Regexp } @@ -269,12 +269,12 @@ end Array(param[:notmatch]).each do |item| - is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)).without_content(item) + is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)).without_content(item) end end it 'ends with a closing brace' do - fragment = 'vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s) + fragment = 'server1-500-' + Digest::MD5.hexdigest(params[:location].to_s) content = catalogue.resource('concat::fragment', fragment).send(:parameters)[:content] expect(content.split("\n").reject { |l| l =~ %r{^(\s*#|$)} }.last.strip).to eq('}') end @@ -282,28 +282,28 @@ end end - describe 'vhost_location_alias template content' do + describe 'server_location_alias template content' do let :default_params do { location: 'location', - vhost: 'vhost1', + server: 'server1', location_alias: 'value' } end context 'location_alias template with default params' do let(:params) { default_params } - it { is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest('location')) } + it { is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest('location')) } it 'sets alias' do - is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest('location')). + is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest('location')). with_content(%r{^\s+alias\s+value;}) end it "doesn't set try_files" do - is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest('location')). + is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest('location')). without_content(%r{^\s+try_files[^;]+;}) end it "doesn't set autoindex" do - is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest('location')). + is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest('location')). without_content(%r{^[ ]+autoindex[^;]+;}) end end @@ -331,9 +331,9 @@ context "when #{param[:attr]} is #{param[:value]}" do let(:params) { default_params.merge(param[:attr].to_sym => param[:value]) } - it { is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)) } + it { is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)) } it param[:title] do - fragment = 'vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s) + fragment = 'server1-500-' + Digest::MD5.hexdigest(params[:location].to_s) matches = Array(param[:match]) if matches.all? { |m| m.is_a? Regexp } @@ -344,19 +344,19 @@ end Array(param[:notmatch]).each do |item| - is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)).without_content(item) + is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)).without_content(item) end end end end end - describe 'vhost_location_directory template content' do + describe 'server_location_directory template content' do let :default_params do { location: 'location', www_root: '/var/www/root', - vhost: 'vhost1' + server: 'server1' } end @@ -383,9 +383,9 @@ context "when #{param[:attr]} is #{param[:value]}" do let(:params) { default_params.merge(param[:attr].to_sym => param[:value]) } - it { is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)) } + it { is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)) } it param[:title] do - fragment = 'vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s) + fragment = 'server1-500-' + Digest::MD5.hexdigest(params[:location].to_s) matches = Array(param[:match]) if matches.all? { |m| m.is_a? Regexp } @@ -396,7 +396,7 @@ end Array(param[:notmatch]).each do |item| - is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)).without_content(item) + is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)).without_content(item) end end end @@ -404,24 +404,24 @@ context "when autoindex is 'on'" do let(:params) { default_params.merge(autoindex: 'on') } - it { is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest('location')) } + it { is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest('location')) } it 'sets autoindex' do - is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest('location')). + is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest('location')). with_content(%r{^[ ]+autoindex\s+on;}) end end context 'when autoindex is not set' do let(:params) { default_params } - it { is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest('location')) } + it { is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest('location')) } it 'does not set autoindex' do - is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest('location')). + is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest('location')). without_content(%r{^[ ]+autoindex[^;]+;}) end end end - describe 'vhost_location_empty template content' do + describe 'server_location_empty template content' do [ { title: 'should contain ordered config directives', @@ -441,12 +441,12 @@ } ].each do |param| context "when #{param[:attr]} is #{param[:value]}" do - let(:default_params) { { location: 'location', location_custom_cfg: { 'test1' => 'value1' }, vhost: 'vhost1' } } + let(:default_params) { { location: 'location', location_custom_cfg: { 'test1' => 'value1' }, server: 'server1' } } let(:params) { default_params.merge(param[:attr].to_sym => param[:value]) } - it { is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)) } + it { is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)) } it param[:title] do - fragment = 'vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s) + fragment = 'server1-500-' + Digest::MD5.hexdigest(params[:location].to_s) matches = Array(param[:match]) if matches.all? { |m| m.is_a? Regexp } @@ -457,19 +457,19 @@ end Array(param[:notmatch]).each do |item| - is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)).without_content(item) + is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)).without_content(item) end end end end end - describe 'vhost_location_fastcgi template content' do + describe 'server_location_fastcgi template content' do let :default_params do { location: 'location', fastcgi: 'localhost:9000', - vhost: 'vhost1' + server: 'server1' } end @@ -508,9 +508,9 @@ context "when #{param[:attr]} is #{param[:value]}" do let(:params) { default_params.merge(param[:attr].to_sym => param[:value]) } - it { is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)) } + it { is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)) } it param[:title] do - fragment = 'vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s) + fragment = 'server1-500-' + Digest::MD5.hexdigest(params[:location].to_s) matches = Array(param[:match]) if matches.all? { |m| m.is_a? Regexp } @@ -521,7 +521,7 @@ end Array(param[:notmatch]).each do |item| - is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)).without_content(item) + is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)).without_content(item) end end end @@ -529,18 +529,18 @@ context "when fastcgi_script is 'value'" do let(:params) { default_params.merge(fastcgi_script: 'value') } - it { is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)) } + it { is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)) } it 'sets fastcgi_script' do - is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)). + is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)). with_content(%r{^[ ]+fastcgi_param\s+SCRIPT_FILENAME\s+value;}) end end context 'when fastcgi_script is not set' do let(:params) { default_params } - it { is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)) } + it { is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)) } it 'does not set fastcgi_script' do - is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)). + is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)). without_content(%r{^[ ]+fastcgi_param\s+SCRIPT_FILENAME\s+.+?;}) end end @@ -548,7 +548,7 @@ context "when fastcgi_param is {'CUSTOM_PARAM' => 'value'}" do let(:params) { default_params.merge(fastcgi_param: { 'CUSTOM_PARAM' => 'value', 'CUSTOM_PARAM2' => 'value2' }) } it 'sets fastcgi_param' do - is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)). + is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)). with_content(%r{fastcgi_param\s+CUSTOM_PARAM\s+value;}). with_content(%r{fastcgi_param\s+CUSTOM_PARAM2\s+value2;}) end @@ -557,7 +557,7 @@ context 'when fastcgi_param is {\'HTTP_PROXY\' => ""}' do let(:params) { default_params.merge(fastcgi_param: { 'HTTP_PROXY' => '""' }) } it 'sets fastcgi_param' do - is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)). + is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)). with_content(%r{fastcgi_param\s+HTTP_PROXY\s+"";}) end end @@ -565,23 +565,23 @@ context 'when fastcgi_param is not set' do let(:params) { default_params } it 'does not set fastcgi_param' do - is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)). + is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)). without_content(%r{fastcgi_param\s+CUSTOM_PARAM\s+.+?;}). without_content(%r{fastcgi_param\s+CUSTOM_PARAM2\s+.+?;}) end it 'does not add comment # Enable custom fastcgi_params' do - is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)). + is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)). without_content(%r{# Enable custom fastcgi_params\s+}) end end end - describe 'vhost_location_uwsgi template content' do + describe 'server_location_uwsgi template content' do let :default_params do { location: 'location', uwsgi: 'unix:/home/project/uwsgi.socket', - vhost: 'vhost1' + server: 'server1' } end @@ -620,9 +620,9 @@ context "when #{param[:attr]} is #{param[:value]}" do let(:params) { default_params.merge(param[:attr].to_sym => param[:value]) } - it { is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)) } + it { is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)) } it param[:title] do - fragment = 'vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s) + fragment = 'server1-500-' + Digest::MD5.hexdigest(params[:location].to_s) matches = Array(param[:match]) if matches.all? { |m| m.is_a? Regexp } @@ -633,7 +633,7 @@ end Array(param[:notmatch]).each do |item| - is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)).without_content(item) + is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)).without_content(item) end end end @@ -642,7 +642,7 @@ context "when uwsgi_param is {'CUSTOM_PARAM' => 'value'}" do let(:params) { default_params.merge(uwsgi_param: { 'CUSTOM_PARAM' => 'value', 'CUSTOM_PARAM2' => 'value2' }) } it 'sets uwsgi_param' do - is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)). + is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)). with_content(%r{uwsgi_param\s+CUSTOM_PARAM\s+value;}). with_content(%r{uwsgi_param\s+CUSTOM_PARAM2\s+value2;}) end @@ -651,7 +651,7 @@ context 'when uwsgi_param is {\'HTTP_PROXY\' => ""}' do let(:params) { default_params.merge(uwsgi_param: { 'HTTP_PROXY' => '""' }) } it 'sets uwsgi_param' do - is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)). + is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)). with_content(%r{uwsgi_param\s+HTTP_PROXY\s+"";}) end end @@ -659,13 +659,13 @@ context 'when uwsgi_param is not set' do let(:params) { default_params } it 'does not set uwsgi_param' do - is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)). + is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)). without_content(%r{^\s+uwsgi_param\s+}) end end end - describe 'vhost_location_proxy template content' do + describe 'server_location_proxy template content' do [ { title: 'should set proxy_redirect', @@ -801,12 +801,12 @@ } ].each do |param| context "when #{param[:attr]} is #{param[:value]}" do - let(:default_params) { { location: 'location', proxy: 'proxy_value', vhost: 'vhost1' } } + let(:default_params) { { location: 'location', proxy: 'proxy_value', server: 'server1' } } let(:params) { default_params.merge(param[:attr].to_sym => param[:value]) } - it { is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)) } + it { is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)) } it param[:title] do - fragment = 'vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s) + fragment = 'server1-500-' + Digest::MD5.hexdigest(params[:location].to_s) matches = Array(param[:match]) if matches.all? { |m| m.is_a? Regexp } @@ -817,7 +817,7 @@ end Array(param[:notmatch]).each do |item| - is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)).without_content(item) + is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)).without_content(item) end end end @@ -828,61 +828,61 @@ { location: 'location', proxy: 'proxy_value', - vhost: 'vhost1', + server: 'server1', proxy_cache: 'true', proxy_cache_valid: '10m' } end - it { is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest('location')).with_content(%r{proxy_cache_valid\s+10m;}) } + it { is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest('location')).with_content(%r{proxy_cache_valid\s+10m;}) } end end - describe 'vhost_location_stub_status template content' do - let(:params) { { location: 'location', stub_status: true, vhost: 'vhost1' } } + describe 'server_location_stub_status template content' do + let(:params) { { location: 'location', stub_status: true, server: 'server1' } } it do - is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)). + is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)). with_content(%r{stub_status\s+on}) end end context 'attribute resources' do context 'when fastcgi => "localhost:9000"' do - let(:params) { { fastcgi: 'localhost:9000', vhost: 'vhost1' } } + let(:params) { { fastcgi: 'localhost:9000', server: 'server1' } } it { is_expected.to contain_file('/etc/nginx/fastcgi_params').with_mode('0770') } end context 'when uwsgi => "unix:/home/project/uwsgi.socket"' do - let(:params) { { uwsgi: 'uwsgi_upstream', vhost: 'vhost1' } } + let(:params) { { uwsgi: 'uwsgi_upstream', server: 'server1' } } it { is_expected.to contain_file('/etc/nginx/uwsgi_params') } end context 'when ssl_only => true' do - let(:params) { { ssl_only: true, vhost: 'vhost1', www_root: '/' } } - it { is_expected.not_to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest('rspec-test')) } + let(:params) { { ssl_only: true, server: 'server1', www_root: '/' } } + it { is_expected.not_to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest('rspec-test')) } end context 'when ssl_only => false' do - let(:params) { { ssl_only: false, vhost: 'vhost1', www_root: '/' } } + let(:params) { { ssl_only: false, server: 'server1', www_root: '/' } } - it { is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest('rspec-test')) } + it { is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest('rspec-test')) } end context 'when ssl => true' do - let(:params) { { ssl: true, vhost: 'vhost1', www_root: '/' } } + let(:params) { { ssl: true, server: 'server1', www_root: '/' } } - it { is_expected.to contain_concat__fragment('vhost1-800-' + Digest::MD5.hexdigest('rspec-test') + '-ssl') } + it { is_expected.to contain_concat__fragment('server1-800-' + Digest::MD5.hexdigest('rspec-test') + '-ssl') } end context 'when ssl => false' do - let(:params) { { ssl: false, vhost: 'vhost1', www_root: '/' } } + let(:params) { { ssl: false, server: 'server1', www_root: '/' } } - it { is_expected.not_to contain_concat__fragment('vhost1-800-' + Digest::MD5.hexdigest('rspec-test') + '-ssl') } + it { is_expected.not_to contain_concat__fragment('server1-800-' + Digest::MD5.hexdigest('rspec-test') + '-ssl') } end - context 'vhost missing' do + context 'server missing' do let :params do { www_root: '/' @@ -895,62 +895,62 @@ context 'location type missing' do let :params do { - vhost: 'vhost1' + server: 'server1' } end - it { expect { is_expected.to contain_class('nginx::resource::location') }.to raise_error(Puppet::Error, %r{Cannot create a location reference without a www_root, proxy, location_alias, stub_status, fastcgi, uwsgi, location_custom_cfg, internal, try_files, location_allow, or location_deny defined in vhost1:rspec-test}) } + it { expect { is_expected.to contain_class('nginx::resource::location') }.to raise_error(Puppet::Error, %r{Cannot create a location reference without a www_root, proxy, location_alias, stub_status, fastcgi, uwsgi, location_custom_cfg, internal, try_files, location_allow, or location_deny defined in server1:rspec-test}) } end context 'www_root and proxy are set' do let :params do { - vhost: 'vhost1', + server: 'server1', www_root: '/', proxy: 'http://localhost:8000/uri/' } end - it { expect { is_expected.to contain_class('nginx::resource::location') }.to raise_error(Puppet::Error, %r{Cannot define both directory and proxy in vhost1:rspec-test}) } + it { expect { is_expected.to contain_class('nginx::resource::location') }.to raise_error(Puppet::Error, %r{Cannot define both directory and proxy in server1:rspec-test}) } end - context 'when vhost name is sanitized' do + context 'when server name is sanitized' do let(:title) { 'www.rspec-location.com' } let :params do { - vhost: 'www rspec-vhost com', + server: 'www rspec-server com', www_root: '/', ssl: true } end - it { is_expected.to contain_concat__fragment('www_rspec-vhost_com-500-' + Digest::MD5.hexdigest('www.rspec-location.com')).with_target('/etc/nginx/sites-available/www_rspec-vhost_com.conf') } - it { is_expected.to contain_concat__fragment('www_rspec-vhost_com-800-' + Digest::MD5.hexdigest('www.rspec-location.com') + '-ssl').with_target('/etc/nginx/sites-available/www_rspec-vhost_com.conf') } + it { is_expected.to contain_concat__fragment('www_rspec-server_com-500-' + Digest::MD5.hexdigest('www.rspec-location.com')).with_target('/etc/nginx/sites-available/www_rspec-server_com.conf') } + it { is_expected.to contain_concat__fragment('www_rspec-server_com-800-' + Digest::MD5.hexdigest('www.rspec-location.com') + '-ssl').with_target('/etc/nginx/sites-available/www_rspec-server_com.conf') } end context 'when ensure => absent' do let :params do { - vhost: 'vhost1', + server: 'server1', www_root: '/', ensure: 'absent' } end - it { is_expected.not_to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest('rspec-test')) } + it { is_expected.not_to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest('rspec-test')) } end context 'when ensure => absent and ssl => true' do let :params do { ssl: true, - vhost: 'vhost1', + server: 'server1', www_root: '/', ensure: 'absent' } end - it { is_expected.not_to contain_concat__fragment('vhost1-800-' + Digest::MD5.hexdigest('rspec-test') + '-ssl') } + it { is_expected.not_to contain_concat__fragment('server1-800-' + Digest::MD5.hexdigest('rspec-test') + '-ssl') } end end end diff --git a/spec/defines/resource_mailhost_spec.rb b/spec/defines/resource_mailhost_spec.rb index be20b14d1..bf787cc22 100644 --- a/spec/defines/resource_mailhost_spec.rb +++ b/spec/defines/resource_mailhost_spec.rb @@ -593,7 +593,7 @@ ) end - it { expect { is_expected.to contain_class('nginx::resource::vhost') }.to raise_error(Puppet::Error, %r{nginx: SSL certificate/key \(ssl_cert/ssl_cert\) and/or SSL Private must be defined and exist on the target system\(s\)}) } + it { expect { is_expected.to contain_class('nginx::resource::server') }.to raise_error(Puppet::Error, %r{nginx: SSL certificate/key \(ssl_cert/ssl_cert\) and/or SSL Private must be defined and exist on the target system\(s\)}) } end context 'SSL key missing and ssl => true' do @@ -602,7 +602,7 @@ ssl_cert: 'cert') end - it { expect { is_expected.to contain_class('nginx::resource::vhost') }.to raise_error(Puppet::Error, %r{nginx: SSL certificate/key \(ssl_cert/ssl_cert\) and/or SSL Private must be defined and exist on the target system\(s\)}) } + it { expect { is_expected.to contain_class('nginx::resource::server') }.to raise_error(Puppet::Error, %r{nginx: SSL certificate/key \(ssl_cert/ssl_cert\) and/or SSL Private must be defined and exist on the target system\(s\)}) } end context "SSL cert missing and starttls => 'on'" do @@ -611,7 +611,7 @@ ssl_key: 'key') end - it { expect { is_expected.to contain_class('nginx::resource::vhost') }.to raise_error(Puppet::Error, %r{nginx: SSL certificate/key \(ssl_cert/ssl_cert\) and/or SSL Private must be defined and exist on the target system\(s\)}) } + it { expect { is_expected.to contain_class('nginx::resource::server') }.to raise_error(Puppet::Error, %r{nginx: SSL certificate/key \(ssl_cert/ssl_cert\) and/or SSL Private must be defined and exist on the target system\(s\)}) } end context "SSL key missing and starttls => 'on'" do @@ -620,7 +620,7 @@ ssl_cert: 'cert') end - it { expect { is_expected.to contain_class('nginx::resource::vhost') }.to raise_error(Puppet::Error, %r{nginx: SSL certificate/key \(ssl_cert/ssl_cert\) and/or SSL Private must be defined and exist on the target system\(s\)}) } + it { expect { is_expected.to contain_class('nginx::resource::server') }.to raise_error(Puppet::Error, %r{nginx: SSL certificate/key \(ssl_cert/ssl_cert\) and/or SSL Private must be defined and exist on the target system\(s\)}) } end context "SSL cert missing and starttls => 'only'" do @@ -629,7 +629,7 @@ ssl_key: 'key') end - it { expect { is_expected.to contain_class('nginx::resource::vhost') }.to raise_error(Puppet::Error, %r{nginx: SSL certificate/key \(ssl_cert/ssl_cert\) and/or SSL Private must be defined and exist on the target system\(s\)}) } + it { expect { is_expected.to contain_class('nginx::resource::server') }.to raise_error(Puppet::Error, %r{nginx: SSL certificate/key \(ssl_cert/ssl_cert\) and/or SSL Private must be defined and exist on the target system\(s\)}) } end context "SSL key missing and starttls => 'only'" do @@ -638,7 +638,7 @@ ssl_cert: 'cert') end - it { expect { is_expected.to contain_class('nginx::resource::vhost') }.to raise_error(Puppet::Error, %r{nginx: SSL certificate/key \(ssl_cert/ssl_cert\) and/or SSL Private must be defined and exist on the target system\(s\)}) } + it { expect { is_expected.to contain_class('nginx::resource::server') }.to raise_error(Puppet::Error, %r{nginx: SSL certificate/key \(ssl_cert/ssl_cert\) and/or SSL Private must be defined and exist on the target system\(s\)}) } end context 'when listen_port != ssl_port' do diff --git a/spec/defines/resource_vhost_spec.rb b/spec/defines/resource_server_spec.rb similarity index 97% rename from spec/defines/resource_vhost_spec.rb rename to spec/defines/resource_server_spec.rb index 8f337c215..77c609f5b 100644 --- a/spec/defines/resource_vhost_spec.rb +++ b/spec/defines/resource_server_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'nginx::resource::vhost' do +describe 'nginx::resource::server' do let :title do 'www.rspec.example.com' end @@ -59,7 +59,7 @@ end end - describe 'vhost_header template content' do + describe 'server_header template content' do [ { title: 'should not contain www to non-www rewrite', @@ -213,7 +213,7 @@ }, { title: 'should contain ordered prepended directives', - attr: 'vhost_cfg_prepend', + attr: 'server_cfg_prepend', value: { 'test1' => ['test value 1a', 'test value 1b'], 'test2' => 'test value 2', 'allow' => 'test value 3' }, match: [ ' allow test value 3;', @@ -280,7 +280,7 @@ match: ' access_log /var/log/nginx/www.rspec.example.com.access.log custom;' }, { - title: 'should not include access_log in vhost when set to absent', + title: 'should not include access_log in server when set to absent', attr: 'access_log', value: 'absent', notmatch: 'access_log' @@ -301,7 +301,7 @@ ] }, { - title: 'should not include error_log in vhost when set to absent', + title: 'should not include error_log in server when set to absent', attr: 'error_log', value: 'absent', notmatch: 'error_log' @@ -334,7 +334,7 @@ end end - describe 'vhost_footer template content' do + describe 'server_footer template content' do [ { title: 'should not contain www to non-www rewrite', @@ -357,7 +357,7 @@ }, { title: 'should contain ordered appended directives', - attr: 'vhost_cfg_append', + attr: 'server_cfg_append', value: { 'test1' => 'test value 1', 'test2' => ['test value 2a', 'test value 2b'], 'allow' => 'test value 3' }, match: [ ' allow test value 3;', @@ -398,7 +398,7 @@ end end - describe 'vhost_ssl_header template content' do + describe 'server_ssl_header template content' do [ { title: 'should not contain www to non-www rewrite', @@ -622,7 +622,7 @@ match: ' access_log off;' }, { - title: 'should not include access_log in vhost when set to absent', + title: 'should not include access_log in server when set to absent', attr: 'access_log', value: 'absent', notmatch: 'access_log' @@ -655,7 +655,7 @@ ] }, { - title: 'should not include error_log in vhost when set to absent', + title: 'should not include error_log in server when set to absent', attr: 'error_log', value: 'absent', notmatch: 'error_log' @@ -678,7 +678,7 @@ }, { title: 'should contain ordered prepend directives', - attr: 'vhost_cfg_prepend', + attr: 'server_cfg_prepend', value: { 'test1' => 'test value 1', 'test2' => ['test value 2a', 'test value 2b'], 'allow' => 'test value 3' }, match: [ ' allow test value 3;', @@ -689,7 +689,7 @@ }, { title: 'should contain ordered ssl prepend directives', - attr: 'vhost_cfg_ssl_prepend', + attr: 'server_cfg_ssl_prepend', value: { 'test1' => 'test value 1', 'test2' => ['test value 2a', 'test value 2b'], 'allow' => 'test value 3' }, match: [ ' allow test value 3;', @@ -736,7 +736,7 @@ end end - describe 'vhost_ssl_footer template content' do + describe 'server_ssl_footer template content' do [ { title: 'should not contain www to non-www rewrite', @@ -759,7 +759,7 @@ }, { title: 'should contain ordered appended directives', - attr: 'vhost_cfg_append', + attr: 'server_cfg_append', value: { 'test1' => 'test value 1', 'test2' => 'test value 2', 'allow' => 'test value 3' }, match: [ ' allow test value 3;', @@ -779,7 +779,7 @@ }, { title: 'should contain ordered ssl appended directives', - attr: 'vhost_cfg_ssl_append', + attr: 'server_cfg_ssl_append', value: { 'test1' => 'test value 1', 'test2' => ['test value 2a', 'test value 2b'], 'allow' => 'test value 3' }, match: [ ' allow test value 3;', @@ -895,13 +895,13 @@ context 'SSL cert missing' do let(:params) { { ssl: true, ssl_key: 'key' } } - it { expect { is_expected.to contain_class('nginx::resource::vhost') }.to raise_error(Puppet::Error) } + it { expect { is_expected.to contain_class('nginx::resource::server') }.to raise_error(Puppet::Error) } end context 'SSL key missing' do let(:params) { { ssl: true, ssl_cert: 'cert' } } - it { expect { is_expected.to contain_class('nginx::resource::vhost') }.to raise_error(Puppet::Error) } + it { expect { is_expected.to contain_class('nginx::resource::server') }.to raise_error(Puppet::Error) } end context 'SSL cert and key are both set to fully qualified paths' do @@ -922,14 +922,14 @@ let(:params) { { ssl: true, ssl_cert: '/tmp/foo.crt' } } msg = %r{ssl_key must be set to false or to a fully qualified path} - it { expect { is_expected.to contain_class('nginx::resource::vhost') }.to raise_error(Puppet::Error, msg) } + it { expect { is_expected.to contain_class('nginx::resource::server') }.to raise_error(Puppet::Error, msg) } end context 'SSL key without cert' do let(:params) { { ssl: true, ssl_key: '/tmp/foo.key' } } msg = %r{ssl_cert must be set to false or to a fully qualified path} - it { expect { is_expected.to contain_class('nginx::resource::vhost') }.to raise_error(Puppet::Error, msg) } + it { expect { is_expected.to contain_class('nginx::resource::server') }.to raise_error(Puppet::Error, msg) } end context 'when use_default_location => true' do @@ -1175,11 +1175,11 @@ it { is_expected.to contain_concat__fragment("#{title}-footer").with_content(%r{passenger_pre_start http://example.com:3009/foo/bar;}) } end - context 'when vhost name is sanitized' do - let(:title) { 'www rspec-vhost com' } + context 'when server name is sanitized' do + let(:title) { 'www rspec-server com' } let(:params) { default_params } - it { is_expected.to contain_concat('/etc/nginx/sites-available/www_rspec-vhost_com.conf') } + it { is_expected.to contain_concat('/etc/nginx/sites-available/www_rspec-server_com.conf') } end context 'when add_header is set' do diff --git a/spec/defines/resource_stream_spec.rb b/spec/defines/resource_stream_spec.rb index 5b58fcc59..29dc8762b 100644 --- a/spec/defines/resource_stream_spec.rb +++ b/spec/defines/resource_stream_spec.rb @@ -50,7 +50,7 @@ end end - describe 'vhost_header template content' do + describe 'server_header template content' do [ { title: 'should set the IPv4 listen IP', diff --git a/templates/vhost/fastcgi_params.erb b/templates/server/fastcgi_params.erb similarity index 100% rename from templates/vhost/fastcgi_params.erb rename to templates/server/fastcgi_params.erb diff --git a/templates/server/location.erb b/templates/server/location.erb new file mode 100644 index 000000000..4a1d2211f --- /dev/null +++ b/templates/server/location.erb @@ -0,0 +1,13 @@ +<%= scope.function_template(['nginx/server/location_header.erb']) -%> +<%= scope.function_template(['nginx/server/locations/alias.erb']) -%> +<%= scope.function_template(['nginx/server/locations/stub_status.erb']) -%> +<% if @fastcgi or @uwsgi or @proxy -%> +<%= scope.function_template(['nginx/server/locations/proxy.erb']) -%> +<%= scope.function_template(['nginx/server/locations/uwsgi.erb']) -%> +<%= scope.function_template(['nginx/server/locations/fastcgi.erb']) -%> +<% else -%> +<%= scope.function_template(['nginx/server/locations/directory.erb']) -%> +<% end -%> +<%= scope.function_template(['nginx/server/locations/try_files.erb']) -%> +<%= scope.function_template(['nginx/server/locations/empty.erb']) -%> +<%= scope.function_template(['nginx/server/location_footer.erb']) -%> diff --git a/templates/vhost/location_footer.erb b/templates/server/location_footer.erb similarity index 100% rename from templates/vhost/location_footer.erb rename to templates/server/location_footer.erb diff --git a/templates/vhost/location_header.erb b/templates/server/location_header.erb similarity index 100% rename from templates/vhost/location_header.erb rename to templates/server/location_header.erb diff --git a/templates/vhost/locations/alias.erb b/templates/server/locations/alias.erb similarity index 100% rename from templates/vhost/locations/alias.erb rename to templates/server/locations/alias.erb diff --git a/templates/vhost/locations/directory.erb b/templates/server/locations/directory.erb similarity index 100% rename from templates/vhost/locations/directory.erb rename to templates/server/locations/directory.erb diff --git a/templates/vhost/locations/empty.erb b/templates/server/locations/empty.erb similarity index 100% rename from templates/vhost/locations/empty.erb rename to templates/server/locations/empty.erb diff --git a/templates/vhost/locations/fastcgi.erb b/templates/server/locations/fastcgi.erb similarity index 100% rename from templates/vhost/locations/fastcgi.erb rename to templates/server/locations/fastcgi.erb diff --git a/templates/vhost/locations/proxy.erb b/templates/server/locations/proxy.erb similarity index 100% rename from templates/vhost/locations/proxy.erb rename to templates/server/locations/proxy.erb diff --git a/templates/vhost/locations/stub_status.erb b/templates/server/locations/stub_status.erb similarity index 100% rename from templates/vhost/locations/stub_status.erb rename to templates/server/locations/stub_status.erb diff --git a/templates/vhost/locations/try_files.erb b/templates/server/locations/try_files.erb similarity index 100% rename from templates/vhost/locations/try_files.erb rename to templates/server/locations/try_files.erb diff --git a/templates/vhost/locations/uwsgi.erb b/templates/server/locations/uwsgi.erb similarity index 100% rename from templates/vhost/locations/uwsgi.erb rename to templates/server/locations/uwsgi.erb diff --git a/templates/vhost/vhost_footer.erb b/templates/server/server_footer.erb similarity index 88% rename from templates/vhost/vhost_footer.erb rename to templates/server/server_footer.erb index 370ea11e4..d8e0dff70 100644 --- a/templates/vhost/vhost_footer.erb +++ b/templates/server/server_footer.erb @@ -6,8 +6,8 @@ <%# make sure that allow comes before deny by forcing the allow key (if it -%> <%# exists) to be first in the output order. The hash keys also need to be -%> <%# sorted so that the ordering is stable. -%> -<% if @vhost_cfg_append -%> - <%- @vhost_cfg_append.sort_by{ |k, v| k.to_s == 'allow' ? '' : k.to_s }.each do |key,value| -%> +<% if @server_cfg_append -%> + <%- @server_cfg_append.sort_by{ |k, v| k.to_s == 'allow' ? '' : k.to_s }.each do |key,value| -%> <%- if value.is_a?(Hash) -%> <%- value.sort_by {|k,v| k}.each do |subkey,subvalue| -%> <%- Array(subvalue).each do |asubvalue| -%> diff --git a/templates/vhost/vhost_header.erb b/templates/server/server_header.erb similarity index 98% rename from templates/vhost/vhost_header.erb rename to templates/server/server_header.erb index 14b90036c..f8ea55017 100644 --- a/templates/vhost/vhost_header.erb +++ b/templates/server/server_header.erb @@ -87,8 +87,8 @@ server { <%# make sure that allow comes before deny by forcing the allow key (if it -%> <%# exists) to be first in the output order. The hash keys also need to be -%> <%# sorted so that the ordering is stable. -%> -<% if @vhost_cfg_prepend -%> - <%- @vhost_cfg_prepend.sort_by{ |k, v| k.to_s == 'allow' ? '' : k.to_s }.each do |key,value| -%> +<% if @server_cfg_prepend -%> + <%- @server_cfg_prepend.sort_by{ |k, v| k.to_s == 'allow' ? '' : k.to_s }.each do |key,value| -%> <%- if value.is_a?(Hash) -%> <%- value.sort_by {|k,v| k}.each do |subkey,subvalue| -%> <%- Array(subvalue).each do |asubvalue| -%> diff --git a/templates/vhost/vhost_ssl_footer.erb b/templates/server/server_ssl_footer.erb similarity index 78% rename from templates/vhost/vhost_ssl_footer.erb rename to templates/server/server_ssl_footer.erb index 90d0e4e85..343d0e8a0 100644 --- a/templates/vhost/vhost_ssl_footer.erb +++ b/templates/server/server_ssl_footer.erb @@ -3,8 +3,8 @@ include <%= file %>; <%- end -%> <% end -%> -<% if @vhost_cfg_append -%> - <%- @vhost_cfg_append.sort_by{ |k, v| k.to_s == 'allow' ? '' : k.to_s }.each do |key,value| -%> +<% if @server_cfg_append -%> + <%- @server_cfg_append.sort_by{ |k, v| k.to_s == 'allow' ? '' : k.to_s }.each do |key,value| -%> <%- if value.is_a?(Hash) -%> <%- value.sort_by{ |k, v| k}.each do |subkey,subvalue| -%> <%- Array(subvalue).each do |asubvalue| -%> @@ -18,8 +18,8 @@ <%- end -%> <%- end -%> <% end -%> -<% if @vhost_cfg_ssl_append -%> - <%- @vhost_cfg_ssl_append.sort_by{ |k, v| k.to_s == 'allow' ? '' : k.to_s }.each do |key,value| -%> +<% if @server_cfg_ssl_append -%> + <%- @server_cfg_ssl_append.sort_by{ |k, v| k.to_s == 'allow' ? '' : k.to_s }.each do |key,value| -%> <%- if value.is_a?(Hash) -%> <%- value.sort_by{ |k, v| k}.each do |subkey,subvalue| -%> <%- Array(subvalue).each do |asubvalue| -%> diff --git a/templates/vhost/vhost_ssl_header.erb b/templates/server/server_ssl_header.erb similarity index 93% rename from templates/vhost/vhost_ssl_header.erb rename to templates/server/server_ssl_header.erb index 382af3280..e3e865381 100644 --- a/templates/vhost/vhost_ssl_header.erb +++ b/templates/server/server_ssl_header.erb @@ -22,7 +22,7 @@ server { server_name www.<%= s.gsub(/^www\./, '') %>; return 301 https://<%= s.gsub(/^www\./, '') %>$request_uri; -<%= scope.function_template(["nginx/vhost/vhost_ssl_settings.erb"]) %> +<%= scope.function_template(["nginx/server/server_ssl_settings.erb"]) %> } @@ -48,7 +48,7 @@ server { <%- end -%> server_name <%= @rewrite_www_to_non_www ? @server_name.join(" ").gsub(/(^| )(www\.)?(?=[a-z0-9])/, '') : @server_name.join(" ") %>; -<%= scope.function_template(["nginx/vhost/vhost_ssl_settings.erb"]) %> +<%= scope.function_template(["nginx/server/server_ssl_settings.erb"]) %> <% if @maintenance -%> <%= @maintenance_value %>; <% end -%> @@ -109,9 +109,9 @@ server { error_page <%= key %> <%= @error_pages[key] %>; <%- end -%> <% end -%> -<% if @vhost_cfg_prepend -%> +<% if @server_cfg_prepend -%> - <%- @vhost_cfg_prepend.sort_by{ |k, v| k.to_s == 'allow' ? '' : k.to_s }.each do |key,value| -%> + <%- @server_cfg_prepend.sort_by{ |k, v| k.to_s == 'allow' ? '' : k.to_s }.each do |key,value| -%> <%- if value.is_a?(Hash) -%> <%- value.sort_by {|k,v| k}.each do |subkey,subvalue| -%> <%- Array(subvalue).each do |asubvalue| -%> @@ -125,9 +125,9 @@ server { <%- end -%> <%- end -%> <% end -%> -<% if @vhost_cfg_ssl_prepend -%> +<% if @server_cfg_ssl_prepend -%> - <%- @vhost_cfg_ssl_prepend.sort_by{ |k, v| k.to_s == 'allow' ? '' : k.to_s }.each do |key,value| -%> + <%- @server_cfg_ssl_prepend.sort_by{ |k, v| k.to_s == 'allow' ? '' : k.to_s }.each do |key,value| -%> <%- if value.is_a?(Hash) -%> <%- value.sort_by {|k,v| k}.each do |subkey,subvalue| -%> <%- Array(subvalue).each do |asubvalue| -%> diff --git a/templates/vhost/vhost_ssl_settings.erb b/templates/server/server_ssl_settings.erb similarity index 100% rename from templates/vhost/vhost_ssl_settings.erb rename to templates/server/server_ssl_settings.erb diff --git a/templates/vhost/uwsgi_params.erb b/templates/server/uwsgi_params.erb similarity index 100% rename from templates/vhost/uwsgi_params.erb rename to templates/server/uwsgi_params.erb diff --git a/templates/vhost/location.erb b/templates/vhost/location.erb deleted file mode 100644 index 653f1c2c1..000000000 --- a/templates/vhost/location.erb +++ /dev/null @@ -1,13 +0,0 @@ -<%= scope.function_template(['nginx/vhost/location_header.erb']) -%> -<%= scope.function_template(['nginx/vhost/locations/alias.erb']) -%> -<%= scope.function_template(['nginx/vhost/locations/stub_status.erb']) -%> -<% if @fastcgi or @uwsgi or @proxy -%> -<%= scope.function_template(['nginx/vhost/locations/proxy.erb']) -%> -<%= scope.function_template(['nginx/vhost/locations/uwsgi.erb']) -%> -<%= scope.function_template(['nginx/vhost/locations/fastcgi.erb']) -%> -<% else -%> -<%= scope.function_template(['nginx/vhost/locations/directory.erb']) -%> -<% end -%> -<%= scope.function_template(['nginx/vhost/locations/try_files.erb']) -%> -<%= scope.function_template(['nginx/vhost/locations/empty.erb']) -%> -<%= scope.function_template(['nginx/vhost/location_footer.erb']) -%>