Puppet Function: pacemaker_cluster_options

Defined in:
lib/puppet/parser/functions/pacemaker_cluster_options.rb
Function type:
Ruby 3.x API

Overview

pacemaker_cluster_options()Any

Convert the cluster options to the “pcs cluster create” CLI options string

Returns:

  • (Any)


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/puppet/parser/functions/pacemaker_cluster_options.rb', line 2

newfunction(
    :pacemaker_cluster_options,
    type: :rvalue,
    arity: 1,
    doc: <<-eof
Convert the cluster options to the "pcs cluster create" CLI options string
eof
) do |args|
  options = args[0]
  break '' unless options
  break options if options.is_a? String
  if options.is_a? Hash
    options_array = []
    options.each do |option, value|
      option = "--#{option}" unless option.start_with? '--'
      if value.is_a? TrueClass or value.is_a? FalseClass
        options_array << option if value
      else
        options_array << option
        options_array << value
      end
    end
    options = options_array
  end
  [options].flatten.join ' '
end