Puppet Function: wls_install::wls_patches_missing

Defined in:
lib/puppet/functions/wls_install/wls_patches_missing.rb
Function type:
Ruby 4.x API

Overview

wls_install::wls_patches_missing(Hash $patch_list)Hash

This function checks if the specfied patches are installed. And it will return a Hash with the oracle home(s) with patch details that still needs at least one more patch

It will check all registered Oracle homes for the installed patches.

See the file “LICENSE” for the full license governing this code.

Parameters:

  • patch_list (Hash)

Returns:

  • (Hash)


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
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/puppet/functions/wls_install/wls_patches_missing.rb', line 14

Puppet::Functions.create_function(:'wls_install::wls_patches_missing') do
  dispatch :check_patch_list do
    param 'Hash', :patch_list
    return_type 'Hash'
  end

  def check_patch_list(patch_list)
    converted_patch_list = call_function('wls_install::wls_physical_patches', patch_list)
    log("converted patch list: #{converted_patch_list}")
    scope = closure_scope
    middleware_homes = scope['wls_install_homes'] || []
    if middleware_homes.empty?
      patch_list
    else
      middleware_homes['installed_patches'].each_key do |home|
        fail "Either ORACLE_HOME '#{home}' or '#{home}/OPatch/opatch' not found. Faulty oraInventory entry? Please fix!" if middleware_homes['opatch_version'][home] == 'Invalid'
      end
      existing_patches = middleware_homes.nil? ? [] : middleware_homes['installed_patches'].collect { |key, val| val.map { |patch| "#{key}:#{patch}" } }.flatten
      log("existing patches: #{existing_patches}")
      missing_patches = converted_patch_list.reject { |patch| existing_patches.include?(patch) }
      log("missing patches: #{missing_patches}")
      if missing_patches.empty?
        {}
      else
        homes_to_be_patches = missing_patches.map { |patch| patch.split(':')[0] }.uniq
        patch_list.select { |home, _patch| homes_to_be_patches.include?(home.split(':')[0]) }
      end
    end
  end

  def log(msg)
    Puppet::Util::Log.create(
      :level => :debug,
      :message => msg,
      :source => 'wls_install::wls_patches_missing'
    )
  end
end