Puppet Function: classification::parse_hostname

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

Summary

Parse a hostname into a hash of its parts.

Overview

classification::parse_hostname(String $hostname_string)Hash

Parse a hostname into a hash of its parts

Examples:

{
  hostname      => $hostname,
  parts         => [$group, $function, $number_string, $context, $stage, $id],
  group         => $group,
  function      => $function,
  number        => $number_as_int,
  number_string => $number_string,
  context       => $context,
  stage         => $stage,
  id            => $id,
}

Parameters:

  • hostname_string (String)

    A hostname to parse

Returns:

  • (Hash)

    Some or all the values may be nil.



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/classification/parse_hostname.rb', line 7

Puppet::Functions.create_function(:'classification::parse_hostname') do
  # @summary Parse a hostname into a hash of its parts.
  #
  # Parse a hostname into a hash of its parts.
  #
  # @param hostname_string A hostname to parse
  # @return Some or all the values may be nil.
  # @example
  #   {
  #     hostname      => $hostname,
  #     parts         => [$group, $function, $number_string, $context, $stage, $id],
  #     group         => $group,
  #     function      => $function,
  #     number        => $number_as_int,
  #     number_string => $number_string,
  #     context       => $context,
  #     stage         => $stage,
  #     id            => $id,
  #   }
  dispatch :parse_hostname do
    param 'String', :hostname_string
    return_type 'Hash'
  end

  def parse_hostname(hostname_string)
    Ploperations::Classification.parse_hostname(hostname_string)
  end
end