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(String $cn, Variant[String, Sensitive[String]] $salt)String

Parameters:

  • cn (String)

    The common name of the Icinga host certificate.

  • salt (Variant[String, Sensitive[String]])

    The ticket salt of the Icinga CA.

Returns:

  • (String)

    Calculated ticket to receive a certificate.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/puppet/functions/icinga2/icinga2_ticket_id.rb', line 6

Puppet::Functions.create_function(:'icinga2::icinga2_ticket_id') do
  # @param cn
  #   The common name of the Icinga host certificate.
  #
  # @param salt
  #   The ticket salt of the Icinga CA.
  #
  # @return [String]
  #   Calculated ticket to receive a certificate.
  #
  dispatch :ticket do
    required_param 'String', :cn
    required_param 'Variant[String, Sensitive[String]]', :salt
    return_type 'String'
  end

  def ticket(cn, salt)
    if salt.is_a?(Puppet::Pops::Types::PSensitiveType::Sensitive)
      salt = salt.unwrap
    end

    PBKDF2.new(
      password: cn,
      salt: salt,
      iterations: 50_000,
      hash_function: OpenSSL::Digest.new('sha1'),
    ).hex_string
  end
end