Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
replaced dirtree and own manifests with a type for the creation of al…
…l the oracle directories
- Loading branch information
Showing
22 changed files
with
305 additions
and
228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
lib/puppet/provider/db_directory_structure/db_directory_structure.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.