From dd1ca8d11e393f243a896330a0917eb66f7dd675 Mon Sep 17 00:00:00 2001 From: David Hollinger Date: Tue, 20 Feb 2018 21:08:12 -0600 Subject: [PATCH] Update code to allow for the special -hosts map --- spec/acceptance/autofs_hosts_spec.rb | 29 ++++++++++++++++++++++++++++ spec/defines/mount_spec.rb | 16 +++++++++++++++ types/mapentry.pp | 4 ++-- 3 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 spec/acceptance/autofs_hosts_spec.rb diff --git a/spec/acceptance/autofs_hosts_spec.rb b/spec/acceptance/autofs_hosts_spec.rb new file mode 100644 index 0000000..82bdce1 --- /dev/null +++ b/spec/acceptance/autofs_hosts_spec.rb @@ -0,0 +1,29 @@ +require 'spec_helper_acceptance' + +describe 'autofs::mount -hosts test' do + context 'basic special -hosts test' do + it 'applies' do + pp = <<-MANIFEST + class { 'autofs': } + autofs::mount { 'auto.net': + mount => '/net', + mapfile_manage => false, + mapfile => '-hosts', + } + MANIFEST + + apply_manifest(pp, catch_failures: true) + apply_manifest(pp, catch_changes: true) + end + + describe file('/etc/auto.master') do + it 'exists and has content' do + is_expected.to exist + is_expected.to be_owned_by 'root' + is_expected.to be_grouped_into 'root' + end + + its(:content) { is_expected.to contain('/net -hosts') } + end + end +end diff --git a/spec/defines/mount_spec.rb b/spec/defines/mount_spec.rb index 5117887..6278767 100644 --- a/spec/defines/mount_spec.rb +++ b/spec/defines/mount_spec.rb @@ -240,6 +240,22 @@ is_expected.not_to contain_file('/data').with('ensure' => 'directory') end end + + context 'with special -hosts map' do + let(:title) { 'auto.NET' } + let(:params) do + { + mount: '/net', + mapfile_manage: false, + mapfile: '-hosts' + } + end + + it do + is_expected.to contain_concat('/etc/auto.master') + is_expected.to contain_concat__fragment('autofs::fragment preamble /net -hosts').with_target('/etc/auto.master') + end + end end end end diff --git a/types/mapentry.pp b/types/mapentry.pp index 9de5797..f0655f4 100644 --- a/types/mapentry.pp +++ b/types/mapentry.pp @@ -1,6 +1,6 @@ # This type matches a map type and path. # @example program:/etc/auto.smb # @example file:/etc/auto.file +# @example hosts:-hosts -type Autofs::Mapentry = Pattern[/^[a-z]+:\/([^\/\0]+(\/)?)+$/] - +type Autofs::Mapentry = Pattern[/^[a-z]+:\/([^\/\0]+(\/)?)+$|^-hosts$/]