Skip to content

Instantly share code, notes, and snippets.

@fatmcgav
Last active Dec 12, 2015
Embed
What would you like to do?
Database remove defined type.
# Define: act::util::linux::nfs_mount
#
# This define manages nfs mounts on linux.
#
# Parameters:
#
# Actions:
#
# Requires:
#
# Sample Usage:
#
#
define act::util::linux::nfs_mount (
$server = undef,
$prefix,
$mount = undef,
$state = 'mounted',
$export_path = undef,
$options = 'defaults'
) {
# Check if mount is defined.
if !$mount {
$mount_point = "${prefix}/${name}"
} else {
$mount_point = "${prefix}/${mount}"
}
case $state {
'mounted': {
# Create mount point and then mount
file { $mount_point:
ensure => directory,
}
->
mount { $mount_point:
ensure => $state,
device => "${server}:${export_path}",
fstype => 'nfs',
options => $options,
}
}
'absent': {
# Unmount and remove mount point.
mount { $mount_point:
ensure => $state
}
->
file { $mount_point:
ensure => $state,
recurse => true,
force => true
}
}
default: {
notify { 'state_not_supported':
message => "State ${state} is not supported."
}
}
}
}
class act::server::linux::db::oracle {
..
# Load db yaml data
$db_details = loadyaml('/etc/puppet/data/databases.yaml')
# Parse data and filter to only primary databses for this server
$primary_databases = parse_databases($db_details, 'database_primary_server', $::hostname)
# Parse data and filter for standby databases for this server
$standby_databases = parse_databases($db_details, 'database_replication_server', $::hostname)
# Work out what we need to remove
$configured_databases = split($::oracle_sids, ',')
$required_databases = keys($primary_databases)
$remove_databases = compare_arrays($configured_databases, $required_databases)
# Remove databases before creating databases.
if !empty($remove_databases) {
if $::oracle_netapp {
act::env::oracle::instance::netapp::remove { $remove_databases: }
}
} else {
notify {'nothing to remove':
message => 'No databases to remove.',
require => Notify['parsing_databases']
}
}
..
}
# Define: act::env::oracle::instance::netapp::remove
#
# This define manages the removal of Oracle database
# instances hosted on NetApp storage.
#
# Parameters:
#
# Actions:
#
# Requires:
#
# Sample Usage:
#
#
define act::env::oracle::instance::netapp::remove(
$oracle_sid = $name
) {
# Database prefix and top folder.
$tier1_prefix = "/data/tier1/oracle/oradata/${oracle_sid}"
# Set default options for 'act::util::linux::nfs_mount'
Act::Util::Linux::Nfs_mount {
state => 'absent',
prefix => $tier1_prefix
}
notify { "removing_${oracle_sid}":
message => "Preparing to remove database ${oracle_sid}"
}
->
file { "${oracle_sid}_profile":
path => "/data/tier2/scripts/profiles/profile.${oracle_sid}",
ensure => absent
}
->
oranfstab { $oracle_sid:
ensure => absent
}
->
oratab { $oracle_sid:
ensure => absent
}
->
act::util::linux::nfs_mount { "${oracle_sid}_controlfiles":
mount => 'controlfiles'
}
->
act::util::linux::nfs_mount { "${oracle_sid}_datafiles":
mount => 'datafiles'
}
->
act::util::linux::nfs_mount { "${oracle_sid}_redologs":
mount => 'redologs'
}
->
act::util::linux::nfs_mount { "${oracle_sid}_tempfiles":
mount => 'tempfiles'
}
->
act::util::linux::nfs_mount { "${oracle_sid}_archive":
prefix => "/data/tier2/oracle/archivelogs",
mount => "${oracle_sid}"
}
->
act::util::linux::nfs_mount { "${oracle_sid}_diag":
prefix => "/data/tier2/oracle/diag",
mount => "${oracle_sid}"
}
->
file { $tier1_prefix:
ensure => absent,
recurse => true,
force => true
}
->
notify { 'removed_${oracle_sid}':
message => "Removed ${oracle_sid} from host."
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment