Puppet Function: get_partition_devices

Defined in:
lib/puppet/functions/get_partition_devices.rb
Function type:
Ruby 4.x API

Overview

get_partition_devices(Hash $partitioning)String

get_partition_devices.rb Examin partitioning information of Debian/Ubuntu hosts and get all used disk devices

Parameters:

  • partitioning (Hash)

Returns:

  • (String)


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/puppet/functions/get_partition_devices.rb', line 6

Puppet::Functions.create_function(:get_partition_devices) do
  dispatch :get_partition_devices do
    required_param 'Hash', :partitioning
    return_type 'String'
  end

  def get_partition_devices(partitioning)
    return 'fail' if partitioning.empty?
    return 'nil' if partitioning.nil?

    device_list = []
    partitioning.each do |_part, part_data|
      if part_data.key?('device')
        device_list.push(part_data['device'])
      end
    end
    return 'failed' if device_list.empty?
    device_list.uniq.join(' ') unless device_list.empty?
  end
end