Puppet Class: db2_profile::database::db_standby
- Defined in:
- manifests/database/db_standby.pp
Summary
When the property `db2_profile::database::primary` is set, and the current node is not the designated primary server, this class will be applied.Overview
db2_profile::database::db_standby
When the named database does not yet run on the server, Puppet will use the backup at the ‘backup_path` to create an intial running database and set it in standby mode.
See the file “LICENSE” for the full license governing this code.
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 |
# File 'manifests/database/db_standby.pp', line 43
class db2_profile::database::db_standby (
String[1] $archive_path,
Stdlib::Absolutepath $backup_path,
String[1] $database,
String[1] $group,
String[1] $instance,
Hash $list,
String[1] $owner,
Variant[Boolean,Enum['on_failure']]
$logoutput = lookup({ name => 'logoutput', default_value => 'on_failure' })
) {
easy_type::debug_evaluation() # Show local variable on extended debug
echo { "Ensure DB2 archiving path '${$archive_path}'":
withpath => false,
}
file { [$archive_path]:
ensure => 'directory',
owner => $owner,
group => $group,
}
if $facts['db2_databases'].dig("${instance}/${database}") == undef {
echo { "Ensure DB2 standby database based on backup in '${$backup_path}'":
withpath => false,
}
exec { "restore backup for ${database}":
command => "/home/${instance}/sqllib/bin/db2 restore database ${database} from ${backup_path}",
cwd => $backup_path,
user => $instance,
environment => "DB2INSTANCE=${instance}",
logoutput => $logoutput,
}
exec { "set database '${database}' as standby":
command => "/home/${instance}/sqllib/bin/db2 start hadr on database ${database} as standby",
user => $instance,
environment => "DB2INSTANCE=${instance}",
logoutput => $logoutput,
}
$require = Exec["restore backup for ${database}"]
$before = Exec["set database '${database}' as standby"]
} else {
$require = undef
$before = undef
}
$list.each |$name, $properties| {
db2_database { $name:
allow_restart => true,
* => $properties,
require => $require,
before => $before,
}
}
}
|