From 60092f3a0f0f5ff59804cdde5a77ae72155a978b Mon Sep 17 00:00:00 2001 From: Jan Tomsa Date: Thu, 28 May 2020 10:52:31 +0200 Subject: [PATCH] Fix `undefined method '[]' for nil:NilClass` when creating filesystem on existing partitions without FS --- lib/puppet/provider/filesystem/lvm.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/puppet/provider/filesystem/lvm.rb b/lib/puppet/provider/filesystem/lvm.rb index a5422f56..c13216d3 100644 --- a/lib/puppet/provider/filesystem/lvm.rb +++ b/lib/puppet/provider/filesystem/lvm.rb @@ -18,7 +18,12 @@ def destroy end def fstype - %r{\bTYPE=\"(\S+)\"}.match(blkid(@resource[:name]))[1] + type_match = %r{\bTYPE=\"(\S+)\"}.match(blkid(@resource[:name])) + # when creating FS on a non LVM partition that already exists but does not have FS + # blkid output does not contain `TYPE=....` -> type_match is nil + if type_match + type_match[1] + end rescue Puppet::ExecutionFailure nil end