-
Notifications
You must be signed in to change notification settings - Fork 113
/
Copy pathdatabase_pluggable.pp
65 lines (56 loc) · 2.47 KB
/
database_pluggable.pp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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
#
#
define oradb::database_pluggable(
$ensure = 'present', #present|absent
$version = '12.1',
$oracle_home_dir = undef,
$user = 'oracle',
$group = 'dba',
$source_db = undef,
$pdb_name = undef,
$pdb_datafile_destination = undef,
$pdb_admin_username = 'pdb_adm',
$pdb_admin_password = undef,
$create_user_tablespace = true,
$log_output = false,
){
if (!( $version == '12.1')){
fail('Unrecognized version, use 12.1')
}
if (!( $ensure in ['present','absent'])){
fail('Unrecognized ensure value, use present or absent')
}
if ( $source_db == undef or is_string($source_db) == false) {fail('You must specify an source_db') }
if ( $pdb_name == undef or is_string($pdb_name) == false) {fail('You must specify an pdb_name') }
if ( $pdb_datafile_destination == undef or is_string($pdb_datafile_destination) == false) {fail('You must specify an pdb_datafile_destination') }
if ( $ensure == 'present') {
if ( $pdb_admin_username == undef or is_string($pdb_admin_username) == false) {fail('You must specify an pdb_admin_username') }
if ( $pdb_admin_password == undef or is_string($pdb_admin_password) == false) {fail('You must specify an pdb_admin_password') }
}
$execPath = '/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin'
if ( $ensure == 'present') {
$command = "${oracle_home_dir}/bin/dbca -silent -createPluggableDatabase -sourceDB ${source_db} -pdbName ${pdb_name} -createPDBFrom DEFAULT -pdbAdminUserName ${pdb_admin_username} -pdbAdminPassword ${pdb_admin_password} -pdbDatafileDestination ${pdb_datafile_destination} -createUserTableSpace ${create_user_tablespace}"
exec { "dbca pdb execute ${title}":
command => $command,
timeout => 0,
path => $execPath,
cwd => $oracle_home_dir,
user => $user,
group => $group,
creates => $pdb_datafile_destination,
logoutput => $log_output,
}
} else {
$command = "${oracle_home_dir}/bin/dbca -silent -deletePluggableDatabase -sourceDB ${source_db} -pdbName ${pdb_name}"
exec { "dbca pdb execute ${title}":
command => $command,
timeout => 0,
path => $execPath,
cwd => $oracle_home_dir,
user => $user,
group => $group,
onlyif => "ls ${$pdb_datafile_destination}",
logoutput => $log_output,
}
}
}