Skip to content
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

Use correct stream mapfile location #1389

Merged
merged 1 commit into from
May 25, 2020
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
12 changes: 9 additions & 3 deletions manifests/resource/map.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# [*hostnames*] - Indicates that source values can be hostnames with a
# prefix or suffix mask.
# [*include_files*] - An array of external files to include
# [*context'] - Specify if mapping is for http or stream context
#
# Actions:
#
Expand Down Expand Up @@ -77,14 +78,19 @@
Optional[String] $default = undef,
Enum['absent', 'present'] $ensure = 'present',
Array[String] $include_files = [],
Boolean $hostnames = false
Boolean $hostnames = false,
Enum['http', 'stream'] $context = 'http',
) {
if ! defined(Class['nginx']) {
fail('You must include the nginx base class before using any defined resources')
}

$root_group = $nginx::root_group
$conf_dir = "${nginx::conf_dir}/conf.d"

$conf_dir = $context ? {
'stream' => "${nginx::conf_dir}/conf.stream.d",
'http' => "${nginx::conf_dir}/conf.d",
}

$ensure_real = $ensure ? {
'absent' => absent,
Expand All @@ -97,7 +103,7 @@
mode => '0644',
}

file { "${nginx::conf_dir}/conf.d/${name}-map.conf":
file { "${conf_dir}/${name}-map.conf":
ensure => $ensure_real,
content => template('nginx/conf.d/map.erb'),
notify => Class['nginx::service'],
Expand Down
19 changes: 19 additions & 0 deletions spec/defines/resource_map_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,25 @@
end
end

describe 'basic assumptions on stream mapfiles' do
let :params do
default_params.merge(
context: 'stream'
)
end

it { is_expected.to contain_file("/etc/nginx/conf.stream.d/#{title}-map.conf").that_requires('File[/etc/nginx/conf.stream.d]') }
it do
is_expected.to contain_file("/etc/nginx/conf.stream.d/#{title}-map.conf").with(
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
'ensure' => 'file',
'content' => %r{map \$uri \$#{title}}
)
end
end

describe 'map.conf template content' do
[
{
Expand Down