diff --git a/spec/defines/mount_spec.rb b/spec/defines/mount_spec.rb index 3ac1f81..27473f1 100644 --- a/spec/defines/mount_spec.rb +++ b/spec/defines/mount_spec.rb @@ -274,6 +274,55 @@ end end + context 'with map format option' do + let(:title) { '/data' } + let(:params) do + { + mapfile: 'file,sun:/etc/auto.data', + mapfile_manage: false + } + end + + it do + is_expected.to compile + is_expected.to contain_concat(master_map_file) + is_expected.to contain_concat__fragment('autofs::fragment preamble /data file,sun:/etc/auto.data'). + with_target(master_map_file). + with_content(%r{\A\s*/data\s+file,sun:/etc/auto.data\s*$}) + end + end + + context 'with map type and no leading slash' do + # this example is drawn directly from the Linux auto.master(5) manual page + let(:title) { '/mnt' } + let(:params) do + { + mapfile: 'yp:mnt.map', + mapfile_manage: false + } + end + + it do + is_expected.to compile + is_expected.to contain_concat(master_map_file) + is_expected.to contain_concat__fragment('autofs::fragment preamble /mnt yp:mnt.map'). + with_target(master_map_file). + with_content(%r{\A\s*/mnt\s+yp:mnt.map\s*$}) + end + end + + context 'with relative map file' do + # This one expects compilation to fail + let(:title) { '/data' } + let(:params) do + { + mapfile: 'etc/auto.data' + } + end + + it { is_expected.to compile.and_raise_error(%r{.*}) } + end + context 'with ensure set to absent' do let(:title) { '/data' } let(:params) do diff --git a/types/mapentry.pp b/types/mapentry.pp index f0655f4..de3fe5c 100644 --- a/types/mapentry.pp +++ b/types/mapentry.pp @@ -1,6 +1,9 @@ -# This type matches a map type and path. +# This type matches a map specfication with map type and optional format, +# or the built-in -hosts map. # @example program:/etc/auto.smb # @example file:/etc/auto.file -# @example hosts:-hosts +# @example file,sun:/etc/auto.file +# @example yp:mnt.map +# @example -hosts -type Autofs::Mapentry = Pattern[/^[a-z]+:\/([^\/\0]+(\/)?)+$|^-hosts$/] +type Autofs::Mapentry = Pattern[/\A([a-z]+(,[a-z]+)?:\S+|-hosts)\z/]