Skip to content

Ensure that vhosts are purged with new parameter purge_vhost #271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 10, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
$worker_processes = $nginx::params::nx_worker_processes,
$worker_connections = $nginx::params::nx_worker_connections,
$confd_purge = $nginx::params::nx_confd_purge,
$vhost_purge = $nginx::params::nx_vhost_purge,
$server_tokens = $nginx::params::nx_server_tokens,
$proxy_set_header = $nginx::params::nx_proxy_set_header,
$proxy_cache_path = $nginx::params::nx_proxy_cache_path,
Expand Down Expand Up @@ -98,10 +99,24 @@
ensure => directory,
}

if $vhost_purge == true {
File["${nginx::params::nx_conf_dir}/sites-available"] {
purge => true,
recurse => true,
}
}

file { "${nginx::params::nx_conf_dir}/sites-enabled":
ensure => directory,
}

if $vhost_purge == true {
File["${nginx::params::nx_conf_dir}/sites-enabled"] {
purge => true,
recurse => true,
}
}

file { '/etc/nginx/sites-enabled/default':
ensure => absent,
}
Expand Down
3 changes: 3 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
$proxy_set_header = $nginx::params::nx_proxy_set_header,
$proxy_http_version = $nginx::params::nx_proxy_http_version,
$confd_purge = $nginx::params::nx_confd_purge,
$vhost_purge = $nginx::params::nx_vhost_purge,
$proxy_cache_path = $nginx::params::nx_proxy_cache_path,
$proxy_cache_levels = $nginx::params::nx_proxy_cache_levels,
$proxy_cache_keys_zone = $nginx::params::nx_proxy_cache_keys_zone,
Expand Down Expand Up @@ -75,6 +76,7 @@
validate_array($proxy_set_header)
validate_string($proxy_http_version)
validate_bool($confd_purge)
validate_bool($vhost_purge)
if ($proxy_cache_path != false) {
validate_string($proxy_cache_path)
}
Expand Down Expand Up @@ -126,6 +128,7 @@
proxy_cache_max_size => $proxy_cache_max_size,
proxy_cache_inactive => $proxy_cache_inactive,
confd_purge => $confd_purge,
vhost_purge => $vhost_purge,
server_tokens => $server_tokens,
client_max_body_size => $client_max_body_size,
names_hash_bucket_size => $names_hash_bucket_size,
Expand Down
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

$nx_conf_dir = '/etc/nginx'
$nx_confd_purge = false
$nx_vhost_purge = false
$nx_worker_processes = 1
$nx_worker_connections = 1024
$nx_types_hash_max_size = 1024
Expand Down
26 changes: 26 additions & 0 deletions spec/classes/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -288,5 +288,31 @@
'recurse'
])}
end

context "when vhost_purge true" do
let(:params) {{:vhost_purge => true}}
it { should contain_file('/etc/nginx/sites-available').with(
:purge => true,
:recurse => true
)}
it { should contain_file('/etc/nginx/sites-enabled').with(
:purge => true,
:recurse => true
)}
end

context "when vhost_purge false" do
let(:params) {{:vhost_purge => false}}
it { should contain_file('/etc/nginx/sites-available').without([
'ignore',
'purge',
'recurse'
])}
it { should contain_file('/etc/nginx/sites-enabled').without([
'ignore',
'purge',
'recurse'
])}
end
end
end