Skip to content

Commit

Permalink
Merge pull request #152 from extigy/mapping_fix
Browse files Browse the repository at this point in the history
Add optional integer "order" to fs_mapping type
  • Loading branch information
ekohl committed Apr 8, 2020
2 parents fbf0a6e + 618bbca commit 8b65c3e
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
65 changes: 65 additions & 0 deletions spec/acceptance/autofs_mapping_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
require 'spec_helper_acceptance'

describe 'autofs::mapping tests' do
context 'basic mapping test' do
it 'applies' do
pp = <<-EOS
autofs::mapfile { '/etc/auto.data':
}
autofs::mapping { 'dataA':
mapfile => '/etc/auto.data',
key => 'dataA',
options => 'ro',
fs => 'fs.net:/export/dataA',
}
EOS

apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end

describe file('/etc/auto.data') do
it 'exists and belongs to root' do
is_expected.to exist
is_expected.to be_owned_by 'root'
is_expected.to be_grouped_into 'root'
end
its(:content) do
is_expected.to match %r{^\s*dataA\s+-ro\s+fs.net:/export/dataA\s*$}
end
end
end

context 'with order parameter' do
it 'applies' do
pp = <<-EOS
autofs::mapfile { '/etc/auto.data':
mappings => [
{ 'key' => 'dataB', 'options' => 'rw,noexec', 'fs' => 'fs.net:/export/dataB', 'order' => 20 },
]
}
autofs::mapping { 'dataA':
mapfile => '/etc/auto.data',
key => 'dataA',
options => 'ro',
fs => 'fs.net:/export/dataA',
order => 10,
}
EOS

apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end

describe file('/etc/auto.data') do
it 'exists and belongs to root' do
is_expected.to exist
is_expected.to be_owned_by 'root'
is_expected.to be_grouped_into 'root'
end
its(:content) do
is_expected.to match %r{^\s*dataA\s+-ro\s+fs.net:/export/dataA\s*\n\s*dataB\s+-rw,noexec\s+fs.net:/export/dataB\s*$}
end
end
end
end
1 change: 1 addition & 0 deletions types/fs_mapping.pp
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@
type Autofs::Fs_mapping = Struct[{
key => Pattern[/\A\S+\z/],
options => Optional[Autofs::Options],
order => Optional[Integer],
fs => Pattern[/\S/] # contains at least one non-whitespace character
}]

0 comments on commit 8b65c3e

Please sign in to comment.