Puppet Function: merge_hardening

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

Overview

merge_hardening()Any

Returns:

  • (Any)


1
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
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/puppet/parser/functions/merge_hardening.rb', line 1

Puppet::Parser::Functions::newfunction(:merge_hardening, :type => :rvalue) do |args|
  user_params = args[0]
  hardening_params = args[1]

  # merge hashes
  if user_params.instance_of? Hash and
     hardening_params.instance_of? Hash

     # do a manual merge since we need to see what is set
     # or gets overwritten
     hardening_params.each do |k,v|
       # only set the hardening parameter, if the user
       # didn't define it himself
       if not user_params.key? k
         user_params[k] = v
       end

       if user_params[k] != hardening_params[k]
         # print some Warning!
       end
     end


  else

    # merge simple values
    if user_params.nil?
      user_params = hardening_params
    end

    if user_params != hardening_params
      # print some Warning!
    end

  end
  
  # return the merged value
  user_params
end