Defined Type: oradb::opatch

Defined in:
manifests/opatch.pp

Overview

opatch

installs oracle patches for Oracle products

Examples:

opatch


oradb::opatch{'19121551_db_patch':
  ensure                    => 'present',
  oracle_product_home       => /app/oracle/product/11.2/db',
  patch_id                  => '19121551',
  patch_file                => 'p19121551_112040_Linux-x86-64.zip',
  user                      => 'oracle',
  group                     => 'oinstall',
  download_dir              => '/var/tmp/install',
  ocmrf                     => true,
  puppet_download_mnt_point => '/software',
}

Parameters:

  • oracle_product_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

  • remote_file (Boolean) (defaults to: true)

    the installation is remote accessiable or not

  • ensure (Enum['present', 'absent']) (defaults to: 'present')

    patch should be applied or removed

  • patch_id (String) (defaults to: undef)

    the opatch id

  • patch_file (String) (defaults to: undef)

    the opatch patch file

  • clusterware (Boolean) (defaults to: false)

    use opatch auto

  • use_opatchauto_utility (Boolean) (defaults to: false)
  • bundle_sub_patch_id (Optional[String]) (defaults to: undef)

    sub opatch id in case of a bundle patch to check if the bundle patch is already applied

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

    just apply a patch from a bundle

  • ocmrf (Boolean) (defaults to: false)


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
133
134
135
# File 'manifests/opatch.pp', line 35

define oradb::opatch(
  Enum['present', 'absent'] $ensure     = 'present',
  String $oracle_product_home           = undef,
  String $patch_id                      = undef,
  String $patch_file                    = undef,
  Boolean $clusterware                  = false, # opatch auto or opatch apply
  Boolean $use_opatchauto_utility       = false,
  Optional[String] $bundle_sub_patch_id = undef,
  Optional[String] $bundle_sub_folder   = undef,
  String $user                          = lookup('oradb::user'),
  String $group                         = lookup('oradb::group'),
  String $download_dir                  = lookup('oradb::download_dir'),
  Boolean $ocmrf                        = false,
  String $puppet_download_mnt_point     = lookup('oradb::module_mountpoint'),
  Boolean $remote_file                  = true,
)
{
  $exec_path     = lookup('oradb::exec_path')
  $ora_inst_path = lookup('oradb::orainst_dir')

  if $ensure == 'present' {
    if $remote_file == true {
      # the patch used by the opatch
      if ! defined(File["${download_dir}/${patch_file}"]) {
        file { "${download_dir}/${patch_file}":
          ensure => present,
          source => "${puppet_download_mnt_point}/${patch_file}",
          mode   => '0775'
        }
      }
    }
  }

  case $facts['kernel'] {
    'Linux', 'SunOS': {
      if $ensure == 'present' {
        if $remote_file == true {
          exec { "extract opatch ${patch_file} ${title}":
            command   => "unzip -n ${download_dir}/${patch_file} -d ${download_dir}",
            require   => File["${download_dir}/${patch_file}"],
            creates   => "${download_dir}/${patch_id}",
            path      => $exec_path,
            logoutput => false,
            before    => Db_opatch["${patch_id} ${title}"],
          }
        } else {
          exec { "extract opatch ${patch_file} ${title}":
            command   => "unzip -n ${puppet_download_mnt_point}/${patch_file} -d ${download_dir}",
            creates   => "${download_dir}/${patch_id}",
            path      => $exec_path,
            user      => $user,
            group     => $group,
            logoutput => false,
            before    => Db_opatch["${patch_id} ${title}"],
          }
        }
      }

      # sometimes the bundle patch inside an other folder
      if ( $bundle_sub_folder ) {
        $extracted_patch_dir = "${download_dir}/${patch_id}/${bundle_sub_folder}"
      } else {
        $extracted_patch_dir = "${download_dir}/${patch_id}"
      }

      if $ocmrf == true {

        db_opatch{ "${patch_id} ${title}":
          ensure                  => $ensure,
          patch_id                => $patch_id,
          os_user                 => $user,
          oracle_product_home_dir => $oracle_product_home,
          orainst_dir             => $ora_inst_path,
          extracted_patch_dir     => $extracted_patch_dir,
          ocmrf_file              => "${oracle_product_home}/OPatch/ocm.rsp",
          bundle_sub_patch_id     => $bundle_sub_patch_id,
          opatch_auto             => $clusterware,
          use_opatchauto_utility  => $use_opatchauto_utility,
        }

      } else {

        db_opatch{ "${patch_id} ${title}":
          ensure                  => $ensure,
          patch_id                => $patch_id,
          os_user                 => $user,
          oracle_product_home_dir => $oracle_product_home,
          orainst_dir             => $ora_inst_path,
          extracted_patch_dir     => $extracted_patch_dir,
          bundle_sub_patch_id     => $bundle_sub_patch_id,
          opatch_auto             => $clusterware,
          use_opatchauto_utility  => $use_opatchauto_utility,
        }

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