Skip to content

Commit

Permalink
Merge pull request #342 from thiagomarinho/ohs_config
Browse files Browse the repository at this point in the history
Defined type to configure OHS Standalone
  • Loading branch information
biemond committed Jun 6, 2016
2 parents d0e2bf8 + 319213a commit ea66858
Show file tree
Hide file tree
Showing 5 changed files with 164 additions and 0 deletions.
25 changes: 25 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ If you need support, checkout the [wls_install](https://www.enterprisemodules.co

- installs [FMW](#fmw) software(add-on) to a middleware home, like OSB,SOA Suite, Oracle Identity & Access Management, Oracle Unified Directory, WebCenter Portal + Content
- [WebTier](#webtier) Oracle HTTP server Standalone and Collocated
- [Configure Oracle HTTP Server](#configure-oracle-http-server)
- [OSB, SOA Suite](#fmwcluster) with BPM and BAM Cluster configuration support ( convert single osb/soa/bam servers to clusters and migrate 11g OPSS to the database )
- [ADF/JRF support](#fmwclusterjrf), Assign JRF libraries to a Server or Cluster target
- [OIM IDM](#oimconfig) / OAM 11.1.2.3 configurations with Oracle OHS OAM WebGate, Also it has Cluster support for OIM OAM
Expand Down Expand Up @@ -1612,6 +1613,30 @@ Example:
In the case of the wls_datasource type, the jdbc connection will be targetted on
the cluster if the managed server is in a cluster.


### Configure Oracle HTTP Server

You can configure OHS rewrites and locations using __orawls::ohs::config__ resource:

orawls::ohs::config { 'default':
server_name => 'ohs1',
domain_path => '/opt/oracle/middleware12c/user_projects/domains/domain_name',
owner => 'oracle',
group => 'dba',
rewrites => {
'^/mail$' => {
'to' => 'http://mail.domain.com',
'options' => 'R',
},
},
locations => {
'/application' => ['192.168.1.1:7001'],
},
}

OHS will include all __.conf__ files at ${domain_path}/config/fmwconfig/components/OHS/instances/${server_name}/mod_wl_ohs.d folder.


### fmwlogdir
__orawls::fmwlogdir__ Change a log folder location of a FMW server
when you set the defaults hiera variables
Expand Down
5 changes: 5 additions & 0 deletions files/mod_wl_ohs.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# NOTE: This is a template to configure mod_weblogic, generated by Puppet.

LoadModule weblogic_module "${PRODUCT_HOME}/modules/mod_wl_ohs.so"

Include mod_wl_ohs.d/*.conf
44 changes: 44 additions & 0 deletions manifests/ohs/config.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# == Define: orawls::ohs::config
#
# configures ohs locations and rewrites
##
define orawls::ohs::config (
$server_name,
$domain_path,
$owner,
$group,
$locations = undef,
$rewrites = undef,
) {

$mod_wl_ohs_config_file = "${domain_path}/config/fmwconfig/components/OHS/instances/${server_name}/mod_wl_ohs.conf"
$mod_wl_ohs_dir = "${domain_path}/config/fmwconfig/components/OHS/instances/${server_name}/mod_wl_ohs.d"

if (!defined(File[$mod_wl_ohs_dir])) {
file { $mod_wl_ohs_dir:
ensure => directory,
owner => $owner,
group => $group,
mode => '0640',
}
}

if (!defined(File[$mod_wl_ohs_config_file])) {
file { $mod_wl_ohs_config_file:
ensure => present,
source => 'puppet:///modules/orawls/mod_wl_ohs.conf',
owner => $owner,
group => $group,
mode => '0640',
}
}

file { "${mod_wl_ohs_dir}/${title}.conf":
ensure => present,
content => template('orawls/ohs/mod_wl_ohs_config.conf.erb'),
owner => $owner,
group => $group,
mode => '0640',
require => File[$mod_wl_ohs_dir],
}
}
62 changes: 62 additions & 0 deletions spec/defines/ohs/config_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
require 'spec_helper'

describe 'orawls::ohs::config', :type => :define do
let(:title) {'default'}

describe 'with one location' do
let(:params) {{:server_name => 'ohs1',
:domain_path => '/opt/test/wls/domains/domain1',
:owner => 'oracle',
:group => 'oracle',
:locations => {'/console' => ['192.168.1.1:7001']},
}}
it {
should contain_file('/opt/test/wls/domains/domain1/config/fmwconfig/components/OHS/instances/ohs1/mod_wl_ohs.d').with({
'ensure' => 'directory',
'owner' => 'oracle',
'group' => 'oracle',
})

should contain_file('/opt/test/wls/domains/domain1/config/fmwconfig/components/OHS/instances/ohs1/mod_wl_ohs.conf').with({
'ensure' => 'present',
'owner' => 'oracle',
'group' => 'oracle',
})

should contain_file('/opt/test/wls/domains/domain1/config/fmwconfig/components/OHS/instances/ohs1/mod_wl_ohs.d/default.conf').with({
'ensure' => 'present',
'owner' => 'oracle',
'group' => 'oracle',
})
.with_content(/\<LocationMatch "\/console"\>/)
.with_content(/WebLogicHost 192.168.1.1/)
.with_content(/WebLogicPort 7001/)
.that_requires('File[/opt/test/wls/domains/domain1/config/fmwconfig/components/OHS/instances/ohs1/mod_wl_ohs.d]')
}
end

describe 'with two locations' do
let(:params) {{:server_name => 'ohs1',
:domain_path => '/opt/test/wls/domains/domain1',
:owner => 'oracle',
:group => 'oracle',
:locations => {
'/console' => ['192.168.1.1:7001'],
'/application' => ['192.168.1.2:7001', '192.168.1.3:7001'],
},
}}
it {
should contain_file('/opt/test/wls/domains/domain1/config/fmwconfig/components/OHS/instances/ohs1/mod_wl_ohs.d/default.conf').with({
'ensure' => 'present',
'owner' => 'oracle',
'group' => 'oracle',
})
.with_content(/\<LocationMatch "\/console"\>/)
.with_content(/WebLogicHost 192.168.1.1/)
.with_content(/WebLogicPort 7001/)
.with_content(/\<LocationMatch "\/application"\>/)
.with_content(/WebLogicCluster 192.168.1.2:7001,192.168.1.3:7001/)
.that_requires('File[/opt/test/wls/domains/domain1/config/fmwconfig/components/OHS/instances/ohs1/mod_wl_ohs.d]')
}
end
end
28 changes: 28 additions & 0 deletions templates/ohs/mod_wl_ohs_config.conf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# NOTE: This is a template to configure mod_weblogic, generated by Puppet.

<% unless @rewrites.nil? || @rewrites.empty? %>
<IfModule mod_rewrite>
RewriteEngine on

<% @rewrites.each do |from, rewrite| -%>
RewriteRule <%= from %> <%= rewrite['to'] %> <%= (rewrite['options'].nil? || rewrite['options'].empty?) ? '' : "[#{rewrite['options']}]" %>
<% end -%>
</IfModule>
<% end %>
<% unless @locations.nil? || @locations.empty? %>
<IfModule weblogic_module>
<% @locations.each do |location, servers| %>
<LocationMatch "<%= location %>">
SetHandler weblogic-handler

<% if servers.size == 1 %>
WebLogicHost <%= servers[0].split(/:/).first %>
WebLogicPort <%= servers[0].split(/:/).last %>
<% else %>
WebLogicCluster <%= servers.map { |item| "#{item.split(/:/).first}:#{item.split(/:/).last}" }.join ',' %>
<% end %>
</LocationMatch>
<% end %>
</IfModule>
<% end %>

0 comments on commit ea66858

Please sign in to comment.