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.
--
–++–
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']}")
}
}
}
|