Skip to content

Commit

Permalink
Fix Bug: ensure => absent was not working on nginx::resource::location (
Browse files Browse the repository at this point in the history
  • Loading branch information
artberri authored and jyaworski committed Nov 10, 2016
1 parent 899bb40 commit f6237f1
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 24 deletions.
49 changes: 25 additions & 24 deletions manifests/resource/location.pp
Original file line number Diff line number Diff line change
Expand Up @@ -435,33 +435,34 @@
}
}


## Create stubs for vHost File Fragment Pattern
$location_md5 = md5($location)
if ($ssl_only != true) {
concat::fragment { "${vhost_sanitized}-${priority}-${location_md5}":
target => $config_file,
content => join([
template('nginx/vhost/location_header.erb'),
$content_real,
template('nginx/vhost/location_footer.erb'),
], ''),
order => $priority,
if $ensure == present {
## Create stubs for vHost File Fragment Pattern
$location_md5 = md5($location)
if ($ssl_only != true) {
concat::fragment { "${vhost_sanitized}-${priority}-${location_md5}":
target => $config_file,
content => join([
template('nginx/vhost/location_header.erb'),
$content_real,
template('nginx/vhost/location_footer.erb'),
], ''),
order => $priority,
}
}
}

## Only create SSL Specific locations if $ssl is true.
if ($ssl == true or $ssl_only == true) {
$ssl_priority = $priority + 300
## Only create SSL Specific locations if $ssl is true.
if ($ssl == true or $ssl_only == true) {
$ssl_priority = $priority + 300

concat::fragment { "${vhost_sanitized}-${ssl_priority}-${location_md5}-ssl":
target => $config_file,
content => join([
template('nginx/vhost/location_header.erb'),
$content_real,
template('nginx/vhost/location_footer.erb'),
], ''),
order => $ssl_priority,
concat::fragment { "${vhost_sanitized}-${ssl_priority}-${location_md5}-ssl":
target => $config_file,
content => join([
template('nginx/vhost/location_header.erb'),
$content_real,
template('nginx/vhost/location_footer.erb'),
], ''),
order => $ssl_priority,
}
}
}
}
25 changes: 25 additions & 0 deletions spec/defines/resource_location_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,31 @@
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') }
end

context 'when ensure => absent' do
let :params do
{
vhost: 'vhost1',
www_root: '/',
ensure: 'absent'
}
end

it { is_expected.not_to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest('rspec-test')) }
end

context 'when ensure => absent and ssl => true' do
let :params do
{
ssl: true,
vhost: 'vhost1',
www_root: '/',
ensure: 'absent'
}
end

it { is_expected.not_to contain_concat__fragment('vhost1-800-' + Digest::MD5.hexdigest('rspec-test') + '-ssl') }
end
end
end
end

0 comments on commit f6237f1

Please sign in to comment.