Puppet Plan: ora_install::patch_home

Defined in:
plans/patch_home.pp

Summary

This plan will install patches into specified home.

Overview

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

--

–++–

Examples:

bolt plan run ora_install::patch_home -t localhost patch_list='{"/u01/app/oracle/product/18.0.0.0/db_home2:30116795": {"source": "/nfs_share/software/p30116795_180000_Linux-x86-64.zip", "sub_patches": ["30112122","30113775"]}}'

Parameters:

  • dbserver (TargetSpec)

    The target for this plan.

  • install_group (String[1]) (defaults to: 'oinstall')

    The os group to use for installation.

  • os_user (String[1]) (defaults to: 'oracle')

    The user used for the specified installation.

  • source (Optional[String[1]]) (defaults to: undef)

    The source of the patch. Can be either an extracted folder or the raw zip file.

  • patch_list (Hash) (defaults to: {})

    List of patches to apply.

  • tmp_dir (Stdlib::Absolutepath) (defaults to: '/install')

    Directory to use for temporary files.

  • format (Optional[Enum['json','pretty']]) (defaults to: 'pretty')

    Specify the format of the output, human readable (pretty) or not (json).

Options Hash (patch_list):

  • source (String[1])

    Full path to the zipfile that contains the patch

  • sub_patches (Array)

    List of patch numbers that are part of the patchset



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'plans/patch_home.pp', line 37

plan ora_install::patch_home(
  TargetSpec                      $dbserver,
  String[1]                       $install_group = 'oinstall',
  String[1]                       $os_user       = 'oracle',
  Optional[String[1]]             $source        = undef,
  Hash                            $patch_list    = {},
  Stdlib::Absolutepath            $tmp_dir       = '/install',
  Optional[Enum['json','pretty']] $format        = 'pretty',
) {
  if get_targets($dbserver).length > 1 {
    fail_plan("${dbserver} did not resolve to a single target")
  }

  $dbserver.apply_prep

  $result = apply($dbserver, { required_modules => ['easy_type', 'ora_install'], '_catch_errors' => true }) {
    $converted_patch_list = $patch_list.map | $i, $j | { $j['sub_patches'].map | $x | { "${i.split(':')[0]}:${x}" } }.flatten

    if ora_install::ora_patches_installed($converted_patch_list) {
      notify { 'All DB patches already installed. Skipping patches.': }
    } else {
      # Check that there is no db running in the oracle_home(s) in the patch_list
      $oracle_homes = $patch_list.keys.map | $k | { split($k,':')[0] }.unique
      $oracle_homes.each | $oracle_home | {
        if $facts['ora_install_homes']['running_processes'][$oracle_home]['sids'].length > 0 {
          $databases = join($facts['ora_install_homes']['running_processes'][$oracle_home]['sids'].keys,',')
          fail("Database(s) ${databases} still running from oracle home ${oracle_home}, stop it before patching.")
        }
        if $facts['ora_install_homes']['running_processes'][$oracle_home]['listeners'].length > 0 {
          $listeners = join($facts['ora_install_homes']['running_processes'][$oracle_home]['listeners'].keys,',')
          fail("Listeners(s) ${listeners} still running from oracle home ${oracle_home}, stop it before patching.")
        }
      }
      $defaults = {
        ensure  => 'present',
        tmp_dir => "${tmp_dir}/patches",               # always use subdir, the whole directory will be removed when done
      }
      ensure_resources('ora_opatch', $patch_list, $defaults)
    }
  }
  $target_result = $result.first()
  if $target_result.error {
    fail_plan($target_result.error())
  } else {
    $target_result.report['logs'].each |$log| {
      out::message("${log['source']}: ${log['message']}")
    }
  }
}