Dynamically Creating Configuration file

Hi All,

I am writing OHS cookbooks for my project and created a role file as,

“locations”: {
“Gateway”: {
“path”: “/p1”,
“weblogic_host”: “somefqdn1.com”,
“weblogic_port”: “8001”,
“set_handler”: “weblogic-handler”
},
“Analytics”: {
“path”: “/p2”,
“weblogic_cluster”: “somefqdn2.com:8101,
somefqdn3.com:8101”,
“set_handler”: “weblogic-handler”,
“wl_proxy_ssl_pass_through”: “ON”,
“wl_proxy_ssl”: “ON”
}
}

with these attribute values, I would like to populate my mod_wl_ohs.conf
something like this

#Gateway
<path /p1>
SetHandler weblogic-handler
weblogic_host somefqdn1.com
weblogic_port 8001

#Analytics
<path /p2>
SetHandler weblogic-handler
weblogic_cluster somefqdn2.com:8001,somefqdn3.com:8001
wl_proxy_ssl_pass_through ON
wl_proxy_ssl ON

Compress ouput from server before being sent to client side network

DeflateBufferSize 20000

In my OHS install recipe, I have added the code to iterate over locations as

  node[:oc_ohs][:locations].each do |location, location_attrib|
    Chef::Log.info "the different locations are #{location}"
    Chef::Log.info "the app path is   is #{location_attrib.path}"
   end

I am able to get two locations as Gateway and Analytics and there paths as
/p1 and p2 respectively.
but when I tried to get attributes values for weblogic_host and
weblogic_port, getting error as

[2015-06-17T07:53:01+00:00] ERROR: Undefined method or attribute
weblogic_host' onnode’

this may be because weblogic_host and weblogic_port are not defined in
second location Analytics

so how to get different attribute values of location instances. and how to
dynamically create mod_wl_ohs.conf from these attribute values.

Any idea would be helpful.

Thanks & Regards,
Sachin Gupta

Well for starters I'd try accessing the attribute as an attribute instead
of a method

#{location_attrib['path']}

On Wed, Jun 17, 2015 at 1:05 AM, Sachin Gupta guptasachin1112mrt@gmail.com
wrote:

Hi All,

I am writing OHS cookbooks for my project and created a role file as,

"locations": {
"Gateway": {
"path": "/p1",
"weblogic_host": "somefqdn1.com",
"weblogic_port": "8001",
"set_handler": "weblogic-handler"
},
"Analytics": {
"path": "/p2",
"weblogic_cluster": "somefqdn2.com:8101,
somefqdn3.com:8101",
"set_handler": "weblogic-handler",
"wl_proxy_ssl_pass_through": "ON",
"wl_proxy_ssl": "ON"
}
}

with these attribute values, I would like to populate my mod_wl_ohs.conf
something like this

#Gateway
<path /p1>
SetHandler weblogic-handler
weblogic_host somefqdn1.com
weblogic_port 8001

#Analytics
<path /p2>
SetHandler weblogic-handler
weblogic_cluster somefqdn2.com:8001,somefqdn3.com:8001
wl_proxy_ssl_pass_through ON
wl_proxy_ssl ON

Compress ouput from server before being sent to client side network

DeflateBufferSize 20000

In my OHS install recipe, I have added the code to iterate over locations
as

  node[:oc_ohs][:locations].each do |location, location_attrib|
    Chef::Log.info "the different locations are #{location}"
    Chef::Log.info "the app path is   is #{location_attrib.path}"
   end

I am able to get two locations as Gateway and Analytics and there paths as
/p1 and p2 respectively.
but when I tried to get attributes values for weblogic_host and
weblogic_port, getting error as

[2015-06-17T07:53:01+00:00] ERROR: Undefined method or attribute
weblogic_host' on node'

this may be because weblogic_host and weblogic_port are not defined in
second location Analytics

so how to get different attribute values of location instances. and how to
dynamically create mod_wl_ohs.conf from these attribute values.

Any idea would be helpful.

Thanks & Regards,
Sachin Gupta

--
Yoshi Spendiff
Ops Engineer
Indochino
Mobile: +1 778 952 2025
Email: yoshi.spendiff@indochino.com

Hi,

I have modified my role file and added some location instance attribute, so
that I can iterate through a loop in the mod_wl_ohs template now my role
file is

"locations": {
"Gateway": {
"path": "/p1",
"weblogic_host": "somefqdn1.com",
"weblogic_port": "8001",
"weblogic_cluster": "",
"wl_proxy_ssl_pass_through": "",
"wl_proxy_ssl": ""
"set_handler": "weblogic-handler"
},
"Analytics": {
"path": "/p2",
"weblogic_cluster": "somefqdn2.com:8101,
somefqdn3.com:8101",
"weblogic_host": "",
"weblogic_port": "",
"set_handler": "weblogic-handler",
"wl_proxy_ssl_pass_through": "ON",
"wl_proxy_ssl": "ON"
}
}

added this code in mod_wl_ohs template to generate mod_wl_ohs.conf file

<% node[:oc_ohs][:locations].each do |location, location_attrib| %> #<%= location %> > SetHandler <%=location_attrib.set_handler %> Debug <%=location_attrib.debug %> <% if location_attrib.weblogic_host != "" -%> WeblogicHost <%=location_attrib.weblogic_host %> <% end -%> <% if location_attrib.weblogic_port != "" -%> WeblogicPort <%=location_attrib.weblogic_port %> <% end -%> <% if location_attrib.weblogic_cluster != "" -%> WebLogicCluster <%=location_attrib.weblogic_cluster %> <% end -%> <% if location_attrib.wl_proxy_ssl_pass_through != "" -%> WLProxySSLPassThrough <%=location_attrib.wl_proxy_ssl_pass_through %> <% end -%> <% if location_attrib.wl_proxy_ssl != "" -%> WLProxySSL <%=location_attrib.wl_proxy_ssl %> <% end -%> WLLogFile "${ORACLE_INSTANCE}/diagnostics/logs/OHS/${COMPONENT_NAME}/ohs_WLScomponent.log"
   <% end %>

In my install ohs recipe, generated the mod_wl_ohs.conf file through a
template

##Configure mod_wl_ohs.conf file from template
template "#{node[:oc_fmw][:ohs_configFile_path]}/mod_wl_ohs.conf" do
source 'mod_wl_ohs.conf.erb'
owner node[:oc_ohs][:user]
group node[:oc_ohs][:group]
mode '0644'
end

also added the check's in the mod_wl_ohs.conf.erb template, if any value is
null then it will not write to mod_wl_ohs.conf file. also able to restart
the ohs instance will generated mod_wl_ohs.conf file. Now this is working
fine as expected.

Thanks & Regards,
Sachin Kumar

On Wed, Jun 17, 2015 at 8:59 PM, Yoshi Spendiff <
yoshi.spendiff@indochino.com> wrote:

Well for starters I'd try accessing the attribute as an attribute instead
of a method

#{location_attrib['path']}

On Wed, Jun 17, 2015 at 1:05 AM, Sachin Gupta <
guptasachin1112mrt@gmail.com> wrote:

Hi All,

I am writing OHS cookbooks for my project and created a role file as,

"locations": {
"Gateway": {
"path": "/p1",
"weblogic_host": "somefqdn1.com",
"weblogic_port": "8001",
"set_handler": "weblogic-handler"
},
"Analytics": {
"path": "/p2",
"weblogic_cluster": "somefqdn2.com:8101,
somefqdn3.com:8101",
"set_handler": "weblogic-handler",
"wl_proxy_ssl_pass_through": "ON",
"wl_proxy_ssl": "ON"
}
}

with these attribute values, I would like to populate my mod_wl_ohs.conf
something like this

#Gateway
<path /p1>
SetHandler weblogic-handler
weblogic_host somefqdn1.com
weblogic_port 8001

#Analytics
<path /p2>
SetHandler weblogic-handler
weblogic_cluster somefqdn2.com:8001,somefqdn3.com:8001
wl_proxy_ssl_pass_through ON
wl_proxy_ssl ON

Compress ouput from server before being sent to client side network

DeflateBufferSize 20000

In my OHS install recipe, I have added the code to iterate over locations
as

  node[:oc_ohs][:locations].each do |location, location_attrib|
    Chef::Log.info "the different locations are #{location}"
    Chef::Log.info "the app path is   is #{location_attrib.path}"
   end

I am able to get two locations as Gateway and Analytics and there paths
as /p1 and p2 respectively.
but when I tried to get attributes values for weblogic_host and
weblogic_port, getting error as

[2015-06-17T07:53:01+00:00] ERROR: Undefined method or attribute
weblogic_host' on node'

this may be because weblogic_host and weblogic_port are not defined in
second location Analytics

so how to get different attribute values of location instances. and how
to dynamically create mod_wl_ohs.conf from these attribute values.

Any idea would be helpful.

Thanks & Regards,
Sachin Gupta

--
Yoshi Spendiff
Ops Engineer
Indochino
Mobile: +1 778 952 2025
Email: yoshi.spendiff@indochino.com