Puppet Function: icinga2::icinga2_ticket_id

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

Summary

Summarise what the function does here

Overview

icinga2::icinga2_ticket_id(Any *$args)Data type

—- original file header —-

Parameters:

  • *args (Any)

    The original array of arguments. Port this to individually managed params to get the full benefit of the modern function API.

Returns:

  • (Data type)

    Describe what the function returns here



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/puppet/functions/icinga2/icinga2_ticket_id.rb', line 16

Puppet::Functions.create_function(:'icinga2::icinga2_ticket_id') do
  # @param args
  #   The original array of arguments. Port this to individually managed params
  #   to get the full benefit of the modern function API.
  #
  # @return [Data type]
  #   Describe what the function returns here
  #
  dispatch :default_impl do
    # Call the method named 'default_impl' when this is matched
    # Port this to match individual params for better type safety
    repeated_param 'Any', :args
  end


  def default_impl(*args)
    
    raise Puppet::ParseError, 'Must provide exactly two arguments to icinga2_ticket_id' if args.length != 2

    if !args[0] or args[0] == ''
      raise Puppet::ParseError, 'first argument (cn) can not be empty for icinga2_ticket_id'
    end
    if !args[1] or args[1] == ''
      raise Puppet::ParseError, 'second argument (salt) can not be empty for icinga2_ticket_id'
    end

    PBKDF2.new(
      :password => args[0],
      :salt => args[1],
      :iterations => 50000,
      :hash_function => OpenSSL::Digest.new("sha1")
    ).hex_string
  
  end
end