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

Allow to add +auto.master in auto.master file #183

Merged
merged 5 commits into from
Aug 22, 2022
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
8 changes: 7 additions & 1 deletion manifests/mapping.pp
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,15 @@
}

# Declare an appropriate fragment of the target map file
if $key == '+' {
$content = "${key}${fs}\n"
} else {
$content = "${key} ${formatted_options} ${fs}\n"
}

concat::fragment { "autofs::mapping/${title}":
target => $mapfile,
content => "${key} ${formatted_options} ${fs}\n",
content => $content,
order => $order,
}
}
Expand Down
35 changes: 35 additions & 0 deletions spec/acceptance/autofs_init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,41 @@ class { 'autofs': }
end
end

context 'master nismap inclusion test' do
before(:context) do
cleanup_helper
end

it 'applies' do
pp = <<-EOS
class { 'autofs':

mapfiles => {
'/etc/auto.master' => {
mappings => [
{ 'key' => '+', 'fs' => 'auto.master' }
]
}
}
}
EOS

apply_manifest(pp, catch_failures: true)
end

describe file('/etc/auto.master') do
it 'exists and belongs to root' do
expect(subject).to exist
expect(subject).to be_owned_by 'root'
expect(subject).to be_grouped_into 'root'
end

its(:content) do
is_expected.to match %r{^\+auto.master$}
end
end
end

context 'package set to absent' do
before(:context) do
cleanup_helper
Expand Down
24 changes: 24 additions & 0 deletions spec/classes/autofs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,30 @@
end
end

context 'should declare automaster mapfile with nismap' do
master_mappings = [
{ 'key' => '+', 'fs' => 'auto.master' }
]
let(:params) do
{
mounts: {},
mapfiles: {
'master' => { path: '/etc/auto.master', mappings: master_mappings },
},
maps: :undef
}
end

it do
expect(subject).to compile.with_all_deps
expect(subject).to contain_autofs__mapfile('master').
with(path: '/etc/auto.master', mappings: master_mappings)
expect(subject).to have_autofs__mapfile_resource_count(1)
expect(subject).to have_autofs__mount_resource_count(0)
expect(subject).to have_autofs__map_resource_count(0)
end
end

context 'with $mounts not a hash' do
let(:params) { { mounts: 'string' } }

Expand Down