From b0d3347021b3c69f12f2768f811478f80d47b707 Mon Sep 17 00:00:00 2001 From: Edwin Biemond Date: Tue, 20 Jan 2015 15:04:24 +0100 Subject: [PATCH] replaced dirtree and own manifests with a type for the creation of all the oracle directories --- .fixtures.yml | 2 - CHANGELOG.md | 3 + README.md | 1 - lib/puppet/parser/functions/opatch_version.rb | 66 ++++++++++----- lib/puppet/parser/functions/oracle_exists.rb | 38 +++++---- .../db_directory_structure.rb | 42 ++++++++++ lib/puppet/type/db_directory_structure.rb | 83 +++++++++++++++++++ manifests/client.pp | 20 +++-- manifests/database.pp | 2 - manifests/goldengate.pp | 24 +++--- manifests/installasm.pp | 27 +++--- manifests/installdb.pp | 21 ++--- manifests/installem.pp | 23 ++--- manifests/installem_agent.pp | 23 ++--- manifests/net.pp | 1 - manifests/opatch.pp | 11 ++- manifests/opatchupgrade.pp | 24 +++--- manifests/rcu.pp | 1 - manifests/utils/dbcreatefolder.pp | 15 ---- manifests/utils/dbstructure.pp | 65 --------------- metadata.json | 4 - spec/defines/installdb_remote_spec.rb | 37 +++++---- 22 files changed, 305 insertions(+), 228 deletions(-) create mode 100644 lib/puppet/provider/db_directory_structure/db_directory_structure.rb create mode 100644 lib/puppet/type/db_directory_structure.rb delete mode 100644 manifests/utils/dbcreatefolder.pp delete mode 100644 manifests/utils/dbstructure.pp diff --git a/.fixtures.yml b/.fixtures.yml index a6df95b..e3a061f 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -2,7 +2,5 @@ fixtures: repositories: 'stdlib': repo: 'git://github.com/puppetlabs/puppetlabs-stdlib' - 'dirtree': - repo: 'git://github.com/AlexCline/puppet-dirtree' symlinks: 'oradb': '#{source_dir}' \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 89e6e11..9d31b3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Version updates +## 1.0.29 +- Custom type for db/asm/client oracle directory structure instead of dirtree and some manifests + ## 1.0.28 - fixed database install rsp 12.1.0.2 - db_listener custom puppet type/provider, listener.pp calls this type diff --git a/README.md b/README.md index 150b967..71cc914 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,6 @@ created by Edwin Biemond Dependency with - puppetlabs/concat >= 1.0.0 - puppetlabs/stdlib >= 3.2.0 -- AlexCline/dirtree >= 0.2.1 Should work on Docker, for Solaris and on all Linux version like RedHat, CentOS, Ubuntu, Debian, Suse SLES or OracleLinux - Docker image of Oracle Database 12.1 SE [Docker Oracle Database 12.1.0.1](https://github.com/biemond/docker-database-puppet) diff --git a/lib/puppet/parser/functions/opatch_version.rb b/lib/puppet/parser/functions/opatch_version.rb index 3c2d505..b3e3aab 100644 --- a/lib/puppet/parser/functions/opatch_version.rb +++ b/lib/puppet/parser/functions/opatch_version.rb @@ -1,32 +1,52 @@ -# restart the puppetmaster when changed -module Puppet::Parser::Functions - newfunction(:opatch_version, :type => :rvalue) do |args| +begin + require 'puppet/util/log' - oracleHomeArg = args[0].strip.downcase - oracleHome = oracleHomeArg.gsub("/","_").gsub("\\","_").gsub("c:","_c").gsub("d:","_d").gsub("e:","_e") + # restart the puppetmaster when changed + module Puppet + module Parser + module Functions + newfunction(:opatch_version, :type => :rvalue) do |args| - # check the oracle home opatch - lookup_db_var("oradb_inst_opatch#{oracleHome}") + oracleHomeArg = args[0].strip.downcase + oracleHome = oracleHomeArg.gsub('/', '_').gsub('\\', '_').gsub('c:', '_c').gsub('d:', '_d').gsub('e:', '_e') + + log "lookup fact oradb_inst_opatch#{oracleHome}" + # check the oracle home opatch + found = lookup_db_var("oradb_inst_opatch#{oracleHome}") + log "found value #{found}" + return found + end + end + end end -end -def lookup_db_var(name) - # puts "lookup fact "+name - if db_var_exists(name) - return lookupvar(name).to_s + def lookup_db_var(name) + # puts "lookup fact "+name + if db_var_exists(name) + return lookupvar(name).to_s + end + 'empty' end - 'empty' -end -def db_var_exists(name) - # puts "lookup fact "+name - if lookupvar(name) != :undefined - if lookupvar(name).nil? - # puts "return false" - return false + def db_var_exists(name) + # puts "lookup fact "+name + if lookupvar(name) != :undefined + if lookupvar(name).nil? + # puts "return false" + return false + end + return true end - return true + # puts "not found" + false + end + + def log(msg) + Puppet::Util::Log.create( + :level => :info, + :message => msg, + :source => 'oracle_exists' + ) end - # puts "not found" - false + end diff --git a/lib/puppet/parser/functions/oracle_exists.rb b/lib/puppet/parser/functions/oracle_exists.rb index ad684f5..ad5370d 100644 --- a/lib/puppet/parser/functions/oracle_exists.rb +++ b/lib/puppet/parser/functions/oracle_exists.rb @@ -2,26 +2,30 @@ require 'puppet/util/log' # restart the puppetmaster when changed - module Puppet::Parser::Functions - newfunction(:oracle_exists, :type => :rvalue) do |args| + module Puppet + module Parser + module Functions + newfunction(:oracle_exists, :type => :rvalue) do |args| + + ora = lookup_db_var('oradb_inst_products') + log "oracle_exists #{ora}" + + if ora == 'empty' || ora == 'NotFound' + log 'oracle_exists return empty -> false' + return false + else + software = args[0].strip + log "oracle_exists compare #{ora} with #{software}" + if ora.include? software + log 'oracle_exists return true' + return true + end + end + log 'oracle_exists return false' + return false - ora = lookup_db_var('oradb_inst_products') - log "oracle_exists #{ora}" - - if ora == 'empty' or ora == 'NotFound' - log 'oracle_exists return empty -> false' - return false - else - software = args[0].strip - log "oracle_exists compare #{ora} with #{software}" - if ora.include? software - log 'oracle_exists return true' - return true end end - log 'oracle_exists return false' - return false - end end diff --git a/lib/puppet/provider/db_directory_structure/db_directory_structure.rb b/lib/puppet/provider/db_directory_structure/db_directory_structure.rb new file mode 100644 index 0000000..f205dc4 --- /dev/null +++ b/lib/puppet/provider/db_directory_structure/db_directory_structure.rb @@ -0,0 +1,42 @@ +require 'fileutils' + +Puppet::Type.type(:db_directory_structure).provide(:db_directory_structure) do + + def configure + + name = resource[:name] + oracle_base = resource[:oracle_base_dir] + ora_inventory = resource[:ora_inventory_dir] + download_folder = resource[:download_dir] + user = resource[:os_user] + group = resource[:os_group] + Puppet.info "configure oracle folders for #{name}" + + Puppet.info "create the following directories: #{oracle_base}, #{ora_inventory}, #{download_folder}" + make_directory oracle_base + ownened_by_oracle oracle_base, user, group + + make_directory ora_inventory + ownened_by_oracle ora_inventory, user, group + + make_directory download_folder + allow_everybody download_folder + end + + def make_directory(path) + Puppet.info "creating directory #{path}" + FileUtils.mkdir_p path + end + + def ownened_by_oracle(path, user, group) + Puppet.info "Setting oracle ownership for #{path} with 0775" + FileUtils.chmod 0775, path + FileUtils.chown user, group, path + end + + def allow_everybody(path) + Puppet.info "Setting public permissions 0777 for #{path}" + FileUtils.chmod 0777, path + end + +end diff --git a/lib/puppet/type/db_directory_structure.rb b/lib/puppet/type/db_directory_structure.rb new file mode 100644 index 0000000..21e1efc --- /dev/null +++ b/lib/puppet/type/db_directory_structure.rb @@ -0,0 +1,83 @@ +module Puppet + newtype(:db_directory_structure) do + desc 'add all the directories needed by the oracle db or asm installation' + + newparam(:name) do + desc <<-EOT + The title. + EOT + isnamevar + end + + newproperty(:ensure) do + desc 'Whether to do something.' + + newvalue(:present) do + provider.configure + end + + def retrieve + oracle_base = resource[:oracle_base_dir] + ora_inventory = resource[:ora_inventory_dir] + download_folder = resource[:download_dir] + + if File.exist?(oracle_base) && File.exist?(ora_inventory) && File.exist?(download_folder) + :present + else + :absent + end + end + + end + + newparam(:oracle_base_dir) do + desc <<-EOT + The oracle base folder. + EOT + validate do |value| + if value.nil? + fail ArgumentError, 'oracle_base_dir cannot be empty' + end + end + end + + newparam(:ora_inventory_dir) do + desc <<-EOT + The oracle inventory folder. + EOT + validate do |value| + if value.nil? + fail ArgumentError, 'ora_inventory_dir cannot be empty' + end + end + end + + newparam(:download_dir) do + desc <<-EOT + The download folder. + EOT + validate do |value| + if value.nil? + fail ArgumentError, 'download_dir cannot be empty' + end + end + end + + newparam(:os_user) do + desc <<-EOT + The weblogic operating system user. + EOT + + defaultto 'oracle' + end + + newparam(:os_group) do + desc <<-EOT + The weblogic operating system group. + EOT + + defaultto 'oinstall' + end + + end +end diff --git a/manifests/client.pp b/manifests/client.pp index 9e794c2..40694cb 100644 --- a/manifests/client.pp +++ b/manifests/client.pp @@ -33,12 +33,13 @@ $oraInventory = "${oracleBase}/oraInventory" - oradb::utils::dbstructure{"oracle structure ${version}": - oracle_base_home_dir => $oracleBase, - ora_inventory_dir => $oraInventory, - os_user => $user, - os_group_install => $group_install, - download_dir => $downloadDir, + db_directory_structure{"client structure ${version}": + ensure => present, + oracle_base_dir => $oracleBase, + ora_inventory_dir => $oraInventory, + download_dir => $downloadDir, + os_user => $user, + os_group => $group_install, } if ( $continue ) { @@ -56,11 +57,11 @@ file { "${downloadDir}/${file}": ensure => present, source => "${mountPoint}/${file}", - require => Oradb::Utils::Dbstructure["oracle structure ${version}"], before => Exec["extract ${downloadDir}/${file}"], mode => '0775', owner => $user, group => $group, + require => Db_directory_structure["client structure ${version}"], } $source = $downloadDir } else { @@ -68,12 +69,12 @@ } exec { "extract ${downloadDir}/${file}": command => "unzip -o ${source}/${file} -d ${downloadDir}/client_${version}", - require => Oradb::Utils::Dbstructure["oracle structure ${version}"], timeout => 0, path => $execPath, user => $user, group => $group, logoutput => false, + require => Db_directory_structure["client structure ${version}"], } oradb::utils::dborainst{"oracle orainst ${version}": @@ -85,10 +86,11 @@ file { "${downloadDir}/db_client_${version}.rsp": ensure => present, content => template("oradb/db_client_${version}.rsp.erb"), - require => Oradb::Utils::Dborainst["oracle orainst ${version}"], mode => '0775', owner => $user, group => $group, + require => [Oradb::Utils::Dborainst["oracle orainst ${version}"], + Db_directory_structure["client structure ${version}"],], } } diff --git a/manifests/database.pp b/manifests/database.pp index 373eb44..3bfed51 100644 --- a/manifests/database.pp +++ b/manifests/database.pp @@ -113,7 +113,6 @@ owner => $user, group => $group, before => Exec["oracle database ${title}"], - require => File[$downloadDir], } } @@ -126,7 +125,6 @@ owner => $user, group => $group, before => Exec["oracle database ${title}"], - require => File[$downloadDir], } } diff --git a/manifests/goldengate.pp b/manifests/goldengate.pp index f53d501..27d557f 100644 --- a/manifests/goldengate.pp +++ b/manifests/goldengate.pp @@ -56,12 +56,13 @@ if ( $version == '12.1.2' ) { $oraInventory = "${oracleBase}/oraInventory" - oradb::utils::dbstructure{"oracle goldengate structure ${version}": - oracle_base_home_dir => $oracleBase, - ora_inventory_dir => $oraInventory, - os_user => $user, - os_group_install => $group_install, - download_dir => $downloadDir, + db_directory_structure{"oracle goldengate structure ${version}": + ensure => present, + oracle_base_dir => $oracleBase, + ora_inventory_dir => $oraInventory, + download_dir => $downloadDir, + os_user => $user, + os_group => $group_install, } } @@ -74,7 +75,7 @@ source => "${puppetDownloadMntPoint}/${file}", owner => $user, group => $group, - require => Oradb::Utils::Dbstructure["oracle goldengate structure ${version}"], + require => Db_directory_structure["oracle goldengate structure ${version}"], } exec { 'extract gg': @@ -92,7 +93,7 @@ content => template("oradb/oggcore_${version}.rsp.erb"), owner => $user, group => $group, - require => Oradb::Utils::Dbstructure["oracle goldengate structure ${version}"], + require => Db_directory_structure["oracle goldengate structure ${version}"], } oradb::utils::dborainst{"ggate orainst ${version}": @@ -132,10 +133,9 @@ #version is different, use the old way file { "${downloadDir}/${file}": - source => "${puppetDownloadMntPoint}/${file}", - owner => $user, - group => $group, - require => File[$downloadDir], + source => "${puppetDownloadMntPoint}/${file}", + owner => $user, + group => $group, } exec { "extract gg ${title}": diff --git a/manifests/installasm.pp b/manifests/installasm.pp index b947826..e36e40b 100644 --- a/manifests/installasm.pp +++ b/manifests/installasm.pp @@ -85,12 +85,13 @@ $oraInventory = "${oraInventoryDir}/oraInventory" } - oradb::utils::dbstructure{"grid structure ${version}": - oracle_base_home_dir => $gridBase, - ora_inventory_dir => $oraInventory, - os_user => $user, - os_group_install => $group_install, - download_dir => $downloadDir, + db_directory_structure{"grid structure ${version}": + ensure => present, + oracle_base_dir => $gridBase, + ora_inventory_dir => $oraInventory, + download_dir => $downloadDir, + os_user => $user, + os_group => $group_install, } if ( $continue ) { @@ -122,7 +123,7 @@ mode => '0775', owner => $user, group => $group, - require => Oradb::Utils::Dbstructure["grid structure ${version}"], + require => Db_directory_structure["grid structure ${version}"], before => Exec["extract ${downloadDir}/${file1}"], } @@ -151,7 +152,7 @@ user => $user, group => $group, creates => "${downloadDir}/${file_without_ext}", - require => Oradb::Utils::Dbstructure["grid structure ${version}"], + require => Db_directory_structure["grid structure ${version}"], before => Exec["install oracle grid ${title}"], } if ( $version == '12.1.0.1' ) { @@ -180,7 +181,8 @@ mode => '0775', owner => $user, group => $group, - require => Oradb::Utils::Dborainst["grid orainst ${version}"], + require => [Oradb::Utils::Dborainst["grid orainst ${version}"], + Db_directory_structure["grid structure ${version}"],], } } @@ -207,7 +209,6 @@ mode => '0775', owner => $user, group => $group, - require => Oradb::Utils::Dbstructure["grid structure ${version}"], } } @@ -271,7 +272,8 @@ path => $execPath, cwd => $gridBase, logoutput => true, - require => [Exec["run root.sh grid script ${title}"],File[$gridHome],], + require => [Exec["run root.sh grid script ${title}"], + File[$gridHome],], } } else { file { "${downloadDir}/cfgrsp.properties": @@ -280,7 +282,8 @@ mode => '0600', owner => $user, group => $group, - require => [Exec["run root.sh grid script ${title}"],File[$gridHome],], + require => [Exec["run root.sh grid script ${title}"], + File[$gridHome],], } exec { "run configToolAllCommands grid tool ${title}": diff --git a/manifests/installdb.pp b/manifests/installdb.pp index 7a6740f..6a0ea1b 100644 --- a/manifests/installdb.pp +++ b/manifests/installdb.pp @@ -84,12 +84,13 @@ $oraInventory = "${oraInventoryDir}/oraInventory" } - oradb::utils::dbstructure{"oracle structure ${version}": - oracle_base_home_dir => $oracleBase, - ora_inventory_dir => $oraInventory, - os_user => $user, - os_group_install => $group_install, - download_dir => $downloadDir, + db_directory_structure{"oracle structure ${version}": + ensure => present, + oracle_base_dir => $oracleBase, + ora_inventory_dir => $oraInventory, + download_dir => $downloadDir, + os_user => $user, + os_group => $group_install, } if ( $continue ) { @@ -115,7 +116,7 @@ mode => '0775', owner => $user, group => $group, - require => Oradb::Utils::Dbstructure["oracle structure ${version}"], + require => Db_directory_structure["oracle structure ${version}"], before => Exec["extract ${downloadDir}/${file1}"], } # db file 2 installer zip @@ -140,7 +141,7 @@ path => $execPath, user => $user, group => $group, - require => Oradb::Utils::Dbstructure["oracle structure ${version}"], + require => Db_directory_structure["oracle structure ${version}"], before => Exec["install oracle database ${title}"], } exec { "extract ${downloadDir}/${file2}": @@ -167,7 +168,8 @@ mode => '0775', owner => $user, group => $group, - require => Oradb::Utils::Dborainst["database orainst ${version}"], + require => [Oradb::Utils::Dborainst["database orainst ${version}"], + Db_directory_structure["oracle structure ${version}"],], } } @@ -195,7 +197,6 @@ mode => '0775', owner => $user, group => $group, - require => Oradb::Utils::Dbstructure["oracle structure ${version}"], } } } diff --git a/manifests/installem.pp b/manifests/installem.pp index b5bbe6c..20f28a5 100644 --- a/manifests/installem.pp +++ b/manifests/installem.pp @@ -56,12 +56,13 @@ $oraInventory = "${ora_inventory_dir}/oraInventory" } - oradb::utils::dbstructure{"oracle em structure ${version}": - oracle_base_home_dir => $oracle_base_dir, - ora_inventory_dir => $oraInventory, - os_user => $user, - os_group_install => $group, - download_dir => $download_dir, + db_directory_structure{"oracle em structure ${version}": + ensure => present, + oracle_base_dir => $oracle_base_dir, + ora_inventory_dir => $oraInventory, + download_dir => $download_dir, + os_user => $user, + os_group => $group, } if ( $continue ) { @@ -92,7 +93,7 @@ mode => '0775', owner => $user, group => $group, - require => Oradb::Utils::Dbstructure["oracle em structure ${version}"], + require => Db_directory_structure["oracle em structure ${version}"], before => Exec["extract ${download_dir}/${file1}"], } # db file 2 installer zip @@ -128,7 +129,7 @@ path => $execPath, user => $user, group => $group, - require => Oradb::Utils::Dbstructure["oracle em structure ${version}"], + require => Db_directory_structure["oracle em structure ${version}"], # before => Exec["install oracle em ${title}"], } exec { "extract ${download_dir}/${file2}": @@ -166,7 +167,8 @@ mode => '0775', owner => $user, group => $group, - require => Oradb::Utils::Dborainst["em orainst ${version}"], + require => [Oradb::Utils::Dborainst["em orainst ${version}"], + Db_directory_structure["oracle em structure ${version}"],], } } if ! defined(File["${download_dir}/em_install_static_${version}.ini"]) { @@ -176,7 +178,8 @@ mode => '0775', owner => $user, group => $group, - require => Oradb::Utils::Dborainst["em orainst ${version}"], + require => [Oradb::Utils::Dborainst["em orainst ${version}"], + Db_directory_structure["oracle em structure ${version}"],], } } diff --git a/manifests/installem_agent.pp b/manifests/installem_agent.pp index bb402b6..6d2f181 100644 --- a/manifests/installem_agent.pp +++ b/manifests/installem_agent.pp @@ -50,12 +50,13 @@ } # setup oracle base with the right permissions - oradb::utils::dbstructure{"oracle em agent structure ${version}": - oracle_base_home_dir => $oracle_base_dir, - ora_inventory_dir => $oraInventory, - os_user => $user, - os_group_install => $group, - download_dir => $download_dir, + db_directory_structure{"oracle em agent structure ${version}": + ensure => present, + oracle_base_dir => $oracle_base_dir, + ora_inventory_dir => $oraInventory, + download_dir => $download_dir, + os_user => $user, + os_group => $group, } if ( $continue ) { @@ -92,7 +93,8 @@ path => $execPath, user => $user, group => $group, - require => Package['curl'], + require => [Package['curl'], + Db_directory_structure["oracle em agent structure ${version}"],], } exec { "chmod ${title}": @@ -111,6 +113,7 @@ mode => '0755', owner => $user, group => $group, + require => Db_directory_structure["oracle em agent structure ${version}"], } $command = "${download_dir}/AgentPull.sh LOGIN_USER=${sysman_user} LOGIN_PASSWORD=${sysman_password} PLATFORM=\"${install_platform}\" VERSION=${install_version} AGENT_BASE_DIR=${agent_base_dir} AGENT_REGISTRATION_PASSWORD=${agent_registration_password} RSPFILE_LOC=${download_dir}/em_agent.properties" @@ -125,7 +128,7 @@ require => [Exec["agentPull ${title}"], Exec["chmod ${title}"], File["${download_dir}/em_agent.properties"], - Oradb::Utils::Dbstructure["oracle em agent structure ${version}"], + Db_directory_structure["oracle em agent structure ${version}"], Oradb::Utils::Dborainst["em agent orainst ${version}"],], } @@ -154,7 +157,7 @@ path => $execPath, user => $user, group => $group, - require => [Oradb::Utils::Dbstructure["oracle em agent structure ${version}"], + require => [Db_directory_structure["oracle em agent structure ${version}"], Oradb::Utils::Dborainst["em agent orainst ${version}"],], } @@ -172,7 +175,7 @@ user => $user, group => $group, require => [Exec["extract ${source} ${title}"], - Oradb::Utils::Dbstructure["oracle em agent structure ${version}"], + Db_directory_structure["oracle em agent structure ${version}"], Oradb::Utils::Dborainst["em agent orainst ${version}"],], } diff --git a/manifests/net.pp b/manifests/net.pp index ef11b78..85fec27 100644 --- a/manifests/net.pp +++ b/manifests/net.pp @@ -21,7 +21,6 @@ mode => '0775', owner => $user, group => $group, - require => File[$downloadDir], } exec { "install oracle net ${title}": diff --git a/manifests/opatch.pp b/manifests/opatch.pp index 21cee76..87d6ad1 100644 --- a/manifests/opatch.pp +++ b/manifests/opatch.pp @@ -57,12 +57,11 @@ # the patch used by the opatch if ! defined(File["${downloadDir}/${patchFile}"]) { file { "${downloadDir}/${patchFile}": - ensure => present, - source => "${mountPoint}/${patchFile}", - mode => '0775', - owner => $user, - group => $group, - require => File[$downloadDir], + ensure => present, + source => "${mountPoint}/${patchFile}", + mode => '0775', + owner => $user, + group => $group, } } } diff --git a/manifests/opatchupgrade.pp b/manifests/opatchupgrade.pp index 29a08b6..671a3c4 100644 --- a/manifests/opatchupgrade.pp +++ b/manifests/opatchupgrade.pp @@ -53,13 +53,12 @@ if ! defined(File["${downloadDir}/${patchFile}"]) { file {"${downloadDir}/${patchFile}": - ensure => present, - path => "${downloadDir}/${patchFile}", - source => "${mountDir}/${patchFile}", - mode => '0775', - owner => $user, - group => $group, - require => File[$downloadDir], + ensure => present, + path => "${downloadDir}/${patchFile}", + source => "${mountDir}/${patchFile}", + mode => '0775', + owner => $user, + group => $group, } } @@ -72,22 +71,22 @@ } -> exec { "extract opatch ${title} ${patchFile}": command => "unzip -o ${downloadDir}/${patchFile} -d ${oracleHome}", - require => File["${downloadDir}/${patchFile}"], path => $execPath, user => $user, group => $group, logoutput => false, + require => File["${downloadDir}/${patchFile}"], } if ( $csiNumber != undef and supportId != undef ) { exec { "exec emocmrsp ${title} ${opversion}": cwd => $patchDir, command => "${patchDir}/ocm/bin/emocmrsp -repeater NONE ${csiNumber} ${supportId}", - require => Exec["extract opatch ${patchFile}"], path => $execPath, user => $user, group => $group, logoutput => true, + require => Exec["extract opatch ${patchFile}"], } } else { @@ -103,18 +102,17 @@ mode => '0775', owner => $user, group => $group, - require => File[$downloadDir], } exec { "ksh ${downloadDir}/opatch_upgrade_${title}_${opversion}.ksh": cwd => $patchDir, - require => [File["${downloadDir}/opatch_upgrade_${title}_${opversion}.ksh"], - Exec["extract opatch ${title} ${patchFile}"], - Package['expect'],], path => $execPath, user => $user, group => $group, logoutput => true, + require => [File["${downloadDir}/opatch_upgrade_${title}_${opversion}.ksh"], + Exec["extract opatch ${title} ${patchFile}"], + Package['expect'],], } } diff --git a/manifests/rcu.pp b/manifests/rcu.pp index 6e4a617..7fe5460 100644 --- a/manifests/rcu.pp +++ b/manifests/rcu.pp @@ -65,7 +65,6 @@ mode => '0775', owner => $user, group => $group, - require => File[$downloadDir], } } diff --git a/manifests/utils/dbcreatefolder.pp b/manifests/utils/dbcreatefolder.pp deleted file mode 100644 index 888bebc..0000000 --- a/manifests/utils/dbcreatefolder.pp +++ /dev/null @@ -1,15 +0,0 @@ -# == define: oradb::utils::dbcreatefolder -# -define oradb::utils::dbcreatefolder( - $prefix = undef, -) -{ - # remove prefix - $dir_resource = regsubst($title, "(${prefix})(.*)$", '\2') - # notice("folder = ${dir_resource}") - if !defined(File[$dir_resource]) { - file { $dir_resource: - ensure => directory, - } - } -} \ No newline at end of file diff --git a/manifests/utils/dbstructure.pp b/manifests/utils/dbstructure.pp deleted file mode 100644 index 3ab70de..0000000 --- a/manifests/utils/dbstructure.pp +++ /dev/null @@ -1,65 +0,0 @@ -# == define: oradb::utils::dbstructure -# -# create directories for the download, ora inventory and oracle base directories -# -# -## -define oradb::utils::dbstructure( - $oracle_base_home_dir = undef, - $ora_inventory_dir = undef, - $os_user = undef, - $os_group_install = undef, - $download_dir = undef, -) -{ - # create all folders - # return an array of all folders and exclude duplicates - $dirtree_all = dirtree($oracle_base_home_dir,$ora_inventory_dir,$download_dir) - # exclude all folders which are important for permissions - $dirtree_all2 = delete($dirtree_all ,$oracle_base_home_dir) - $dirtree_all3 = delete($dirtree_all2,$download_dir) - $dirtree_all4 = delete($dirtree_all3,$ora_inventory_dir) - # add a unique prefix, to skip already defined with multiple dbstructures in - # same catalog like asm,db - $dirtree_all5 = prefix($dirtree_all4,$title) - ensure_resource('oradb::utils::dbcreatefolder', $dirtree_all5, - { - 'prefix' => $title, - } - ) - - # also set permissions on download dir - # check oracle install folder - if !defined(File[$download_dir]) { - file { $download_dir: - ensure => directory, - recurse => false, - replace => false, - mode => '0777', - } - } - - # also set permissions on oracle base dir - if !defined(File[$oracle_base_home_dir]) { - file { $oracle_base_home_dir: - ensure => directory, - recurse => false, - replace => false, - mode => '0775', - owner => $os_user, - group => $os_group_install, - } - } - - # also set permissions on ora inventory dir - if !defined(File[$ora_inventory_dir]) { - file { $ora_inventory_dir: - ensure => directory, - recurse => false, - replace => false, - mode => '0775', - owner => $os_user, - group => $os_group_install, - } - } -} \ No newline at end of file diff --git a/metadata.json b/metadata.json index 4bcbdea..0d1fc7e 100644 --- a/metadata.json +++ b/metadata.json @@ -8,10 +8,6 @@ { "name": "puppetlabs/stdlib", "version_requirement": ">= 3.2.0" - }, - { - "name": "AlexCline/dirtree", - "version_requirement": ">= 0.2.1" } ], "license": "Apache-2.0", diff --git a/spec/defines/installdb_remote_spec.rb b/spec/defines/installdb_remote_spec.rb index 9ac510b..34b9c4a 100644 --- a/spec/defines/installdb_remote_spec.rb +++ b/spec/defines/installdb_remote_spec.rb @@ -25,11 +25,13 @@ describe "oradb utils structure" do it do - should contain_oradb__utils__dbstructure("oracle structure 12.1.0.1").with({ - 'oracle_base_home_dir' => '/oracle', + should contain_db_directory_structure("oracle structure 12.1.0.1").with({ + 'ensure' => 'present', + 'oracle_base_dir' => '/oracle', 'ora_inventory_dir' => '/oracle/oraInventory', 'os_user' => 'oracle', - 'os_group_install' => 'oinstall', + 'os_group' => 'oinstall', + 'download_dir' => '/install', }) end end @@ -53,7 +55,7 @@ it { should contain_file("/install/linuxamd64_12c_database_1of2.zip").with({ 'source' => '/software/linuxamd64_12c_database_1of2.zip', - }).that_comes_before('Exec[extract /install/linuxamd64_12c_database_1of2.zip]').that_requires('Oradb::Utils::Dbstructure[oracle structure 12.1.0.1]') + }).that_comes_before('Exec[extract /install/linuxamd64_12c_database_1of2.zip]').that_requires('Db_directory_structure[oracle structure 12.1.0.1]') } end @@ -61,7 +63,7 @@ it { should contain_exec("extract /install/linuxamd64_12c_database_1of2.zip").with({ 'command' => 'unzip -o /install/linuxamd64_12c_database_1of2.zip -d /install/linuxamd64_12c_database', - }).that_requires('Oradb::Utils::Dbstructure[oracle structure 12.1.0.1]') + }).that_requires('Db_directory_structure[oracle structure 12.1.0.1]') } end @@ -106,7 +108,7 @@ should contain_file("/home/oracle/.bash_profile").with({ 'owner' => 'oracle', 'group' => 'dba', - }).that_requires('Oradb::Utils::Dbstructure[oracle structure 12.1.0.1]') + }) end end @@ -144,11 +146,13 @@ describe "oradb utils structure" do it do - should contain_oradb__utils__dbstructure("oracle structure 11.2.0.4").with({ - 'oracle_base_home_dir' => '/oracle', + should contain_db_directory_structure("oracle structure 11.2.0.4").with({ + 'ensure' => 'present', + 'oracle_base_dir' => '/oracle', 'ora_inventory_dir' => '/oracle/oraInventory', 'os_user' => 'oracle', - 'os_group_install' => 'oinstall', + 'os_group' => 'oinstall', + 'download_dir' => '/install', }) end end @@ -172,7 +176,7 @@ it { should contain_exec("extract /install/p13390677_112040_Linux-x86-64_1of7.zip").with({ 'command' => 'unzip -o /software/p13390677_112040_Linux-x86-64_1of7.zip -d /install/p13390677_112040_Linux-x86-64', - }).that_requires('Oradb::Utils::Dbstructure[oracle structure 11.2.0.4]') + }).that_requires('Db_directory_structure[oracle structure 11.2.0.4]') } end @@ -209,7 +213,7 @@ should contain_file("/home/oracle/.bash_profile").with({ 'owner' => 'oracle', 'group' => 'dba', - }).that_requires('Oradb::Utils::Dbstructure[oracle structure 11.2.0.4]') + }) end end @@ -245,13 +249,16 @@ :kernel => 'Linux', :osfamily => 'RedHat' }} + describe "oradb utils structure" do it do - should contain_oradb__utils__dbstructure("oracle structure 11.2.0.3").with({ - 'oracle_base_home_dir' => '/oracle', + should contain_db_directory_structure("oracle structure 11.2.0.3").with({ + 'ensure' => 'present', + 'oracle_base_dir' => '/oracle', 'ora_inventory_dir' => '/oracle/oraInventory', 'os_user' => 'oracle', - 'os_group_install' => 'oinstall', + 'os_group' => 'oinstall', + 'download_dir' => '/mnt', }) end end @@ -296,7 +303,7 @@ should contain_file("/home/oracle/.bash_profile").with({ 'owner' => 'oracle', 'group' => 'dba', - }).that_requires('Oradb::Utils::Dbstructure[oracle structure 11.2.0.3]') + }) end end