Puppet Class: db2_profile::database::db_primary
- Defined in:
- manifests/database/db_primary.pp
Summary
When the property `db2_profile::database::primary` is set, and the current node is the designated primary server, this class will be applied.Overview
db2_profile::database::db_primary
It will set the database in archiving mode, create a backup and then set the database in primary mode.
See the file “LICENSE” for the full license governing this code.
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 |
# File 'manifests/database/db_primary.pp', line 42
class db2_profile::database::db_primary (
Stdlib::Absolutepath $archive_path,
Stdlib::Absolutepath $backup_path,
String[1] $database,
String[1] $group,
String[1] $instance,
String[1] $owner,
Integer $wait_time,
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, $backup_path]:
ensure => 'directory',
owner => $owner,
group => $group,
}
if $facts['db2_databases'].dig("${instance}/${database}") == undef {
exec { "Set database ${database} in archiving mode":
command => "/home/${instance}/sqllib/bin/db2 update db cfg for ${database} using LOGARCHMETH1 \"DISK:${archive_path}\"",
unless => "/home/${instance}/sqllib/bin/db2 get database config for ${database} | /usr/bin/grep \"(LOGARCHMETH1) = DISK:${archive_path}\"",
user => $instance,
environment => "DB2INSTANCE=${instance}",
logoutput => $logoutput,
}
-> exec { "create backup for ${database}":
command => "/bin/sleep ${wait_time};/home/${instance}/sqllib/bin/db2 backup database ${database} to ${backup_path}",
cwd => $backup_path,
user => $instance,
environment => "DB2INSTANCE=${instance}",
logoutput => $logoutput,
}
-> exec { "set database '${database}' as primary":
command => "/home/${instance}/sqllib/bin/db2 start hadr on database ${database} as primary by force",
user => $instance,
environment => "DB2INSTANCE=${instance}",
logoutput => $logoutput,
}
}
}
|