Defined Type: oradb::opatchupgrade

Defined in:
manifests/opatchupgrade.pp

Overview

opatchupgrade

upgrades oracle opatch of an Oracle Home

Examples:

opatch upgrade


oradb::opatchupgrade{'112000_opatch_upgrade':
  oracle_home               => '/oracle/product/11.2/db',
  patch_file                => 'p6880880_112000_Linux-x86-64.zip',
  csi_number                => undef,
  support_id                => undef,
  opversion                 => '11.2.0.3.6',
  user                      => 'oracle',
  group                     => 'dba',
  download_dir              => '/install',
  puppet_download_mnt_point => $puppet_download_mnt_point,
}

Parameters:

  • oracle_home (String) (defaults to: undef)

    full path to the Oracle Home directory

  • user (String) (defaults to: lookup('oradb::user'))

    operating system user

  • group (String) (defaults to: lookup('oradb::group'))

    the operating group name for using the oracle software

  • download_dir (String) (defaults to: lookup('oradb::download_dir'))

    location for installation files used by this module

  • puppet_download_mnt_point (String) (defaults to: lookup('oradb::module_mountpoint'))

    the location where the installation software is available

  • patch_file (String) (defaults to: undef)

    the opatch upgrade patch file

  • csi_number (Optional[Integer]) (defaults to: undef)

    oracle support csi number

  • support_id (Optional[String]) (defaults to: undef)

    oracle support id

  • opversion (String) (defaults to: undef)

    opatch version of current patch



30
31
32
33
34
35
36
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'manifests/opatchupgrade.pp', line 30

define oradb::opatchupgrade(
  String $oracle_home               = undef,
  String $patch_file                = undef,
  Optional[Integer] $csi_number     = undef,
  Optional[String] $support_id      = undef,
  String $opversion                 = undef,
  String $user                      = lookup('oradb::user'),
  String $group                     = lookup('oradb::group'),
  String $download_dir              = lookup('oradb::download_dir'),
  String $puppet_download_mnt_point = lookup('oradb::module_mountpoint'),
){
  $exec_path = lookup('oradb::exec_path')
  $patch_dir = "${oracle_home}/OPatch"

  $supported_db_kernels = join( lookup('oradb::kernels'), '|')
  if ( $facts['kernel'] in $supported_db_kernels == false){
    fail("Unrecognized operating system, please use it on a ${supported_db_kernels} host")
  }

  # check the opatch version
  $installed_version = oradb::opatch_version($oracle_home)

  if $installed_version == $opversion {
    $continue = false
  } else {
    notify {"oradb::opatchupgrade ${title} ${installed_version} installed - performing upgrade":}
    $continue = true
  }

  if ( $continue ) {

    if ! defined(File["${download_dir}/${patch_file}"]) {
      file {"${download_dir}/${patch_file}":
        ensure => present,
        path   => "${download_dir}/${patch_file}",
        source => "${puppet_download_mnt_point}/${patch_file}",
        mode   => '0775',
        owner  => $user,
        group  => $group,
      }
    }

    case $facts['kernel'] {
      'Linux', 'SunOS': {
        file { $patch_dir:
          ensure  => absent,
          recurse => true,
          force   => true,
        } ->
        exec { "extract opatch ${title} ${patch_file}":
          command   => "unzip -o ${download_dir}/${patch_file} -d ${oracle_home}",
          path      => $exec_path,
          user      => $user,
          group     => $group,
          logoutput => false,
          require   => File["${download_dir}/${patch_file}"],
        }

        if ( $csi_number != undef and support_id != undef ) {
          exec { "exec emocmrsp ${title} ${opversion}":
            cwd       => $patch_dir,
            command   => "${patch_dir}/ocm/bin/emocmrsp -repeater NONE ${csi_number} ${support_id}",
            path      => $exec_path,
            user      => $user,
            group     => $group,
            logoutput => true,
            require   => Exec["extract opatch ${patch_file}"],
          }
        } else {

          if ! defined(Package['expect']) {
            package { 'expect':
              ensure => present,
            }
          }

          file { "${download_dir}/opatch_upgrade_${title}_${opversion}.ksh":
            ensure  => present,
            content => epp('oradb/ocm.rsp.epp', { 'patchDir' => $patch_dir }),
            mode    => '0775',
            owner   => $user,
            group   => $group,
          }

          exec { "ksh ${download_dir}/opatch_upgrade_${title}_${opversion}.ksh":
            cwd       => $patch_dir,
            path      => $exec_path,
            user      => $user,
            group     => $group,
            logoutput => true,
            require   => [File["${download_dir}/opatch_upgrade_${title}_${opversion}.ksh"],
                          Exec["extract opatch ${title} ${patch_file}"],
                          Package['expect'],],
          }
        }

      }
      default: {
        fail('Unrecognized operating system')
      }
    }
  }
}