| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- # == Define: wls::opatch
- #
- # installs oracle patches for Oracle products
- #
- #
- # === Examples
- #
- # $jdkWls11gJDK = 'jdk1.7.0_09'
- #
- # case $operatingsystem {
- # CentOS, RedHat, OracleLinux, Ubuntu, Debian: {
- # $oracleHome = "/opt/oracle/wls/wls11g/Oracle_OSB1"
- # $user = "oracle"
- # $group = "dba"
- # }
- # windows: {
- # $oracleHome = "c:/oracle/wls/wls11g/Oracle_OSB1"
- # $user = "Administrator"
- # $group = "Administrators"
- # }
- # }
- #
- # wls::opatch{'14389126_osb_patch':
- # oracleProductHome => $oracleHome ,
- # fullJDKName => $defaultFullJDK,
- # patchId => '14389126',
- # patchFile => 'p14389126_111160_Generic.zip',
- # user => $user,
- # group => $group,
- # }
- ##
- define wls::opatch( $oracleProductHome = undef,
- $fullJDKName = undef,
- $patchId = undef,
- $patchFile = undef,
- $user = 'oracle',
- $group = 'dba',
- $downloadDir = '/install',
- $puppetDownloadMntPoint = undef,
- $remoteFile = true,
- ) {
- case $operatingsystem {
- CentOS, RedHat, OracleLinux, Ubuntu, Debian, SLES: {
- $execPath = '/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:'
- $path = $downloadDir
- $JAVA_HOME = "/usr/java/${fullJDKName}"
- Exec { path => $execPath,
- user => $user,
- group => $group,
- logoutput => true,
- }
- File {
- ensure => present,
- mode => 0775,
- owner => $user,
- group => $group,
- backup => false,
- }
- }
- Solaris: {
- $execPath = '/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:'
- $path = $downloadDir
- $JAVA_HOME = "/usr/jdk/${fullJDKName}"
- Exec { path => $execPath,
- user => $user,
- group => $group,
- logoutput => true,
- }
- File {
- ensure => present,
- mode => 0775,
- owner => $user,
- group => $group,
- backup => false,
- }
- }
- windows: {
- $execPath = "C:\\oracle\\${fullJDKName}\\bin;C:\\unxutils\\bin;C:\\unxutils\\usr\\local\\wbin;C:\\Windows\\system32;C:\\Windows"
- $checkCommand = "C:\\Windows\\System32\\cmd.exe /c"
- $path = $downloadDir
- $JAVA_HOME = "c:\\oracle\\${fullJDKName}"
- $oracleHomeWin = slash_replace($oracleProductHome)
- Exec { path => $execPath,
- logoutput => true,
- }
- File { ensure => present,
- mode => 0555,
- backup => false,
- }
- }
- }
- if $puppetDownloadMntPoint == undef {
- $mountPoint = "puppet:///modules/wls/"
- } else {
- $mountPoint = $puppetDownloadMntPoint
- }
- # the patch used by the opatch
- if $remoteFile == true {
- file { "${path}/${patchFile}":
- source => "${mountPoint}/${patchFile}",
- }
- }
- case $operatingsystem {
- CentOS, RedHat, OracleLinux, Ubuntu, Debian, SLES, Solaris: {
- if $remoteFile == true {
- exec { "extract opatch ${patchFile} ${title}":
- command => "unzip -n ${path}/${patchFile} -d ${path}",
- require => File ["${path}/${patchFile}"],
- creates => "${path}/${patchId}",
- }
- } else {
- exec { "extract opatch ${patchFile} ${title}":
- command => "unzip -n ${puppetDownloadMntPoint}/${patchFile} -d ${path}",
- creates => "${path}/${patchId}",
- }
- }
- case $::kernel {
- 'Linux': {
- $oraInstPath = "/etc"
- }
- 'SunOS': {
- $oraInstPath = "/var/opt"
- }
- default: {
- fail("Unrecognized operating system ${::kernel}, please use it on a Linux host")
- }
- }
- opatch{ $patchId:
- ensure => present,
- os_user => $user,
- oracle_product_home_dir => $oracleProductHome,
- orainst_dir => $oraInstPath,
- jdk_home_dir => $JAVA_HOME,
- extracted_patch_dir => "${path}/${patchId}",
- require => Exec["extract opatch ${patchFile} ${title}"],
- }
- }
- windows: {
- # opatch apply -silent -jdk %JDK_HOME% -jre %JDK_HOME%\jre -oh C:\oracle\MiddlewarePS5\Oracle_OSB1 C:\temp\14389126
- $oPatchCommand = "opatch apply -silent -jre"
- if $remoteFile == true {
- exec { "extract opatch ${patchFile} ${title}":
- command => "jar.exe xf ${path}/${patchFile}",
- creates => "${path}/${patchId}",
- cwd => $path,
- require => File ["${path}/${patchFile}"],
- }
- } else {
- exec { "extract opatch ${patchFile} ${title}":
- command => "jar.exe xf ${puppetDownloadMntPoint}/${patchFile}",
- creates => "${path}/${patchId}",
- cwd => $path,
- }
- }
- #notify {"wls::opatch win exec ${title} ${checkCommand} ${oracleProductHome}/OPatch/${oPatchCommand} ${JAVA_HOME}\\jre -oh ${oracleHomeWin} ${path}/${patchId}":}
- exec { "exec opatch win ${title}":
- command => "${checkCommand} ${oracleProductHome}/OPatch/${oPatchCommand} ${JAVA_HOME}\\jre -oh ${oracleHomeWin} ${path}/${patchId}",
- logoutput => true,
- require => Exec["extract opatch ${patchFile} ${title}"],
- }
- }
- }
- }
|