Skip to content

Commit 60c6bb1

Browse files
committed
Allow for trailing slashes in mount resource title
1 parent b7ed657 commit 60c6bb1

File tree

12 files changed

+35
-1
lines changed

12 files changed

+35
-1
lines changed

lib/puppet/provider/mount/parsed.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,9 @@ def pre_gen(record)
205205
# Every entry in fstab is :unmounted until we can prove different
206206
def self.prefetch_hook(target_records)
207207
target_records.map do |record|
208+
# Eat the trailing slash(es) of mountpoints in fstab
209+
# This mimics the behavior of munging the resource title
210+
record[:name].gsub!(%r{^(.+?)/*$}, '\1') unless record[:name].nil?
208211
record[:ensure] = :unmounted if record[:record_type] == :parsed
209212
record
210213
end

spec/acceptance/tests/query_spec.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,21 @@
1616
fail_test "didn't find the mount #{name}" unless result.stdout =~ %r{'/#{name}':\s+ensure\s+=>\s+'unmounted'}
1717
end
1818
end
19+
20+
# There is a discrepancy between how `puppet resource` and `puppet apply` handle this case.
21+
# With this patch, using a resource title with a trailing slash in `puppet apply` will match a mount resource without a trailing slash.
22+
# However, `puppet resource mount` with a trailing slash will not match.
23+
# Therefore, this test cheats by performing the munging that occurs during a manifest application
24+
it 'finds an existing filesystem table entry with trailing slash' do
25+
munged_name = name_w_slash.gsub(%r{^(.+?)/*$}, '\1')
26+
step '(setup) add entry to filesystem table'
27+
MountUtils.add_entry_to_filesystem_table(agent, name_w_slash)
28+
29+
step 'verify mount with puppet'
30+
on(agent, puppet_resource('mount', "/#{munged_name}")) do |result|
31+
fail_test "didn't find the mount #{name_w_slash}" unless result.stdout =~ %r{'/#{munged_name}':\s+ensure\s+=>\s+'unmounted'}
32+
end
33+
end
1934
end
2035
end
2136
end

spec/fixtures/unit/provider/mount/parsed/freebsd.fstab

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
/dev/ad0s1d /var ufs rw 2 2
77
/dev/ad0s1g /boot ufs rw 2 2
88
/dev/acd0 /cdrom cd9660 ro,noauto 0 0
9+
tmpfs /run/ tmpfs rw,nosuid,nodev,seclabel,mode=755 0 0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/dev/ad0s1a on / (ufs, local, soft-updates)
22
/dev/ad0s1d on /ghost (ufs, local, soft-updates)
33
devfs on /dev (devfs, local, multilabel)
4+
tmpfs on /run (tmpfs, rw, nosuid, nodev, seclabel, mode=755)

spec/fixtures/unit/provider/mount/parsed/linux.fstab

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ proc /proc proc defaults 0 0
99
/dev/vg00/lv01 /spare ext3 defaults 1 2
1010
sysfs /sys sysfs defaults 0 0
1111
LABEL=SWAP-hda6 swap swap defaults 0 0
12+
tmpfs /run/ tmpfs rw,nosuid,nodev,seclabel,mode=755 0 0

spec/fixtures/unit/provider/mount/parsed/linux.mount

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ rc-svcdir on /lib64/rc/init.d type tmpfs (rw,nosuid,nodev,noexec,relatime,size=1
33
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
44
/dev/sda9 on /usr/portage type jfs (rw)
55
/dev/fake on /ghost type jfs (rw)
6+
tmpfs on /run tmpfs (rw,nosuid,nodev,seclabel,mode=755)

spec/fixtures/unit/provider/mount/parsed/netbsd.fstab

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
/dev/ad3s1b none swap sw 0 0
88
/dev/ad3s1e /data ufs rw 2 2
99
/dev/ad3s1g /boot ufs rw 2 2
10+
tmpfs /run/ tmpfs rw,nosuid,nodev,seclabel,mode=755 0 0

spec/fixtures/unit/provider/mount/parsed/netbsd.mount

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ devfs on /dev (devfs, local)
66
/dev/ad3s1e on /data (ufs, local, soft-updates)
77
/dev/ad3s1h on /ghost (ufs, local, soft-updates)
88
devfs on /var/named/dev (devfs, local)
9+
tmpfs on /run (tmpfs, rw, nosuid, nodev, seclabel, mode=755)

spec/fixtures/unit/provider/mount/parsed/openbsd.fstab

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
/dev/wd0e /home ffs rw,nodev,nosuid 1 2
33
/dev/wd0d /usr ffs rw,nodev 1 2
44
/dev/wd0f /boot ffs rw,nodev 1 2
5+
tmpfs /run/ tmpfs rw,nosuid,nodev,seclabel,mode=755 0 0

spec/fixtures/unit/provider/mount/parsed/openbsd.mount

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
/dev/wd0e on /home type ffs (local, nodev, nosuid)
33
/dev/wd0d on /usr type ffs (local, nodev)
44
/dev/wd0g on /ghost type ffs (local, nodev)
5+
tmpfs on /run (tmpfs, rw, nosuid, nodev, seclabel, mode=755)

0 commit comments

Comments
 (0)