| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- # == Class: oradb::database
- #
- #
- # action = createDatabase|deleteDatabase
- # databaseType = MULTIPURPOSE|DATA_WAREHOUSING|OLTP
- #
- #
- # oradb::database{ 'testDb':
- # oracleBase => '/oracle',
- # oracleHome => '/oracle/product/11.2/db',
- # version => "11.2",
- # user => 'oracle',
- # group => 'dba',
- # downloadDir => '/install',
- # action => 'create',
- # dbName => 'test',
- # dbDomain => 'oracle.com',
- # sysPassword => 'Welcome01',
- # systemPassword => 'Welcome01',
- # dataFileDestination => "/oracle/oradata",
- # recoveryAreaDestination => "/oracle/flash_recovery_area",
- # characterSet => "AL32UTF8",
- # nationalCharacterSet => "UTF8",
- # initParams => "open_cursors=1000,processes=600,job_queue_processes=4,compatible=11.2.0.0.0",
- # sampleSchema => 'TRUE',
- # memoryPercentage => "40",
- # memoryTotal => "800",
- # databaseType => "MULTIPURPOSE",
- # emConfiguration => "NONE",
- # require => Oradb::Listener['start listener'],
- # }
- #
- #
- #
- define oradb::database( $oracleBase = undef,
- $oracleHome = undef,
- $version = "11.2",
- $user = 'oracle',
- $group = 'dba',
- $downloadDir = '/install',
- $action = 'create',
- $dbName = 'orcl',
- $dbDomain = undef,
- $sysPassword = 'Welcome01',
- $systemPassword = 'Welcome01',
- $dataFileDestination = undef,
- $recoveryAreaDestination = undef,
- $characterSet = "AL32UTF8",
- $nationalCharacterSet = "UTF8",
- $initParams = undef,
- $sampleSchema = TRUE,
- $memoryPercentage = "40",
- $memoryTotal = "800",
- $databaseType = "MULTIPURPOSE",
- $emConfiguration = "NONE", # CENTRAL|LOCAL|ALL|NONE
- $storageType = "FS", #FS|CFS|ASM
- $asmSnmpPassword = 'Welcome01',
- $asmDiskgroup = 'DATA',
- $recoveryDiskgroup = undef,
- )
- {
- if $version == "11.2" or $version == "12.1" {
- } else {
- fail("Unrecognized version")
- }
- $continue = true
- if ( $continue ) {
- case $::kernel {
- Linux,SunOS: {
- $execPath = "${oracleHome}/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:"
- $path = $downloadDir
- Exec {
- path => $execPath,
- user => $user,
- group => $group,
- environment => ["USER=${user}",],
- logoutput => true,
- }
- File {
- ensure => present,
- mode => 0775,
- owner => $user,
- group => $group,
- }
- }
- default: {
- fail("Unrecognized operating system")
- }
- }
- $sanitized_title = regsubst($title, "[^a-zA-Z0-9.-]", "_", "G")
- $filename = "${path}/database_${sanitized_title}.rsp"
- if $action == 'create' {
- $operationType = 'createDatabase'
- } elsif $action == 'delete' {
- $operationType = 'deleteDatabase'
- } else {
- fail("Unrecognized database action")
- }
- if $dbDomain {
- $globalDbName = "${dbName}.${dbDomain}"
- } else {
- $globalDbName = $dbName
- }
- if ! defined(File[$filename]) {
- file { $filename:
- ensure => present,
- content => template("oradb/dbca_${version}.rsp.erb"),
- }
- }
- if $action == 'create' {
- exec { "install oracle database ${title}":
- command => "dbca -silent -responseFile ${filename}",
- require => File[$filename],
- creates => "${oracleBase}/admin/${dbName}",
- timeout => 0,
- }
- } elsif $action == 'delete' {
- exec { "delete oracle database ${title}":
- command => "dbca -silent -responseFile ${filename}",
- require => File[$filename],
- onlyif => "ls ${oracleBase}/admin/${dbName}",
- timeout => 0,
- }
- }
- }
- }
|