diff --git a/lib/puppet/provider/zpool/zpool.rb b/lib/puppet/provider/zpool/zpool.rb index 80c5675..799ebdc 100644 --- a/lib/puppet/provider/zpool/zpool.rb +++ b/lib/puppet/provider/zpool/zpool.rb @@ -44,7 +44,7 @@ def process_zpool_data(pool_array) pool[:raid_parity] = 'raidz2' if %r{^raidz2}.match?(value) else # get full drive name if the value is a partition (Linux only) - tmp << if Facter.value(:kernel) == 'Linux' && value =~ %r{/dev/(:?[a-z]+1|disk/by-id/.+-part1)$} + tmp << if Facter.value(:kernel) == 'Linux' && value =~ %r{/dev/(:?[a-z]+([0-9]+n[0-9]+p)?1|disk/by-id/.+-part1)$} execute("lsblk -p -no pkname #{value}").chomp else value diff --git a/spec/unit/provider/zpool/zpool_spec.rb b/spec/unit/provider/zpool/zpool_spec.rb index f773707..ffadc0b 100644 --- a/spec/unit/provider/zpool/zpool_spec.rb +++ b/spec/unit/provider/zpool/zpool_spec.rb @@ -63,9 +63,10 @@ describe 'when there are full path disks on Linux' do it 'munges partitions into disk names' do allow(provider).to receive(:execute).with('lsblk -p -no pkname /dev/sdc1').and_return('/dev/sdc') + allow(provider).to receive(:execute).with('lsblk -p -no pkname /dev/nvme0n1p1').and_return('/dev/nvme0n1') allow(provider).to receive(:execute).with('lsblk -p -no pkname /dev/disk/by-id/disk_serial-0:0-part1').and_return('/dev/disk/by-id/disk_serial-0:0') - zpool_data = ['foo', '/dev/sdc1', '/dev/disk/by-id/disk_serial-0:0-part1'] - expect(provider.process_zpool_data(zpool_data)[:disk]).to eq(['/dev/sdc /dev/disk/by-id/disk_serial-0:0']) + zpool_data = ['foo', '/dev/sdc1', '/dev/nvme0n1p1', '/dev/disk/by-id/disk_serial-0:0-part1'] + expect(provider.process_zpool_data(zpool_data)[:disk]).to eq(['/dev/sdc /dev/nvme0n1 /dev/disk/by-id/disk_serial-0:0']) end end