Skip to content

Instantly share code, notes, and snippets.

@jollyrojer
Last active March 15, 2017 18:51
Show Gist options
  • Save jollyrojer/a7da02d50653e2232978657d61a97a08 to your computer and use it in GitHub Desktop.
Save jollyrojer/a7da02d50653e2232978657d61a97a08 to your computer and use it in GitHub Desktop.
require 'resolv'
wl_servers = Array(node[:econnect][:wl_servers]).to_a
machines = Array(node[:econnect][:machines]).to_a
wl_servers.map! {|x| x["args"] = (node[:econnect][:server][:arguments] | x["args"]).join(" "); x}
clusters = wl_servers.map {|s| { "name" => s["name"]+"Cluster", "addresses" => machines.map {|m| m+":#{s["port"]}"}.join(",")} }
wlst "create coherence cluster" do
user "oracle" if node.platform_family?("rhel")
weblogic_home node[:weblogic][:weblogic_home]
code <<-EEND.gsub(/^[^\|]*\|/,'')
|connect('#{node[:weblogic][:username]}', '#{node[:weblogic][:password]}', 't3://#{node[:weblogic][:admin_console]}')
|edit()
|startEdit()
|cohSR = getMBean('/CoherenceClusterSystemResources/#{node[:coherence][:cluster_name]}')
|if cohSR is None:
| cohSR = create('#{node[:coherence][:cluster_name]}', 'CoherenceClusterSystemResource')
|cohBean = cohSR.getCoherenceClusterResource()
|cohCluster = cohBean.getCoherenceClusterParams()
|# set cluster parameters
|cohCluster.setUnicastPortAutoAdjust(false)
|cohCluster.setUnicastListenAddress("localhost")
|cohCluster.setUnicastListenPort(#{node[:coherence][:unicast_port]})
|# Save changes
|save()
|activate()
|exit()
EEND
end
wlst "create clusters" do
user "oracle" if node.platform_family?("rhel")
weblogic_home node[:weblogic][:weblogic_home]
code <<-EEND.gsub(/^[^\|]*\|/,'')
|wl_servers = #{wl_servers.to_json}
|clusters = #{clusters.to_json}
|connect('#{node[:weblogic][:username]}', '#{node[:weblogic][:password]}', 't3://#{node[:weblogic][:admin_console]}')
|edit()
|startEdit()
|# Create WebLogic Clusters
|for c in clusters:
| cluster = getMBean('/Clusters/' + c["name"])
| if cluster is None:
| cluster = create(c["name"], 'Cluster')
| cluster.setClusterMessagingMode("unicast")
| cluster.setClusterAddress(c["addresses"])
|# Save changes
|save()
|activate()
|exit()
EEND
end
machines.each_with_index do | machine, i |
ipaddr = Resolv.getaddress(machine)
wl_servers.map! {|x| x["ip"] = ipaddr; x}
wlst "create infrastructure #{machine}" do
user "oracle" if node.platform_family?("rhel")
weblogic_home node[:weblogic][:weblogic_home]
code <<-EEND.gsub(/^[^\|]*\|/,'')
|wl_servers = #{wl_servers.to_json}
|connect('#{node[:weblogic][:username]}', '#{node[:weblogic][:password]}', 't3://#{node[:weblogic][:admin_console]}')
|edit()
|startEdit()
|cohSR = getMBean('/CoherenceClusterSystemResources/#{node[:coherence][:cluster_name]}')
|# Create WebLogic servers
|for srv in wl_servers:
| s = getMBean('/Servers/' + srv["name"] + "Server#{i}")
| if s is None:
| s = create(srv["name"] + "Server#{i}", 'Server')
| s.setListenAddress(srv["ip"])
| s.setListenPort(srv["port"])
| s.setMachine(getMBean("/Machines/#{machine}"))
| s.setCluster(getMBean('/Clusters/' + srv["name"] + "Cluster"))
| st = s.getServerStart()
| args = srv["args"]
| if "debug_port" in args():
| debug_port = str(srv['debug_port'])
| args = args.replace('8888', debug_port)
| st.setArguments(args)
| st.setClassPath('#{node[:econnect][:server][:classpath].join(node[:weblogic][:classpath_sep])}')
| s.setCoherenceClusterSystemResource(cohSR)
| cohSR.addTarget(s)
|# Save changes
|save()
|activate()
|exit()
EEND
end
end
#on admine node
include_recipe "econnect::create_users"
include_recipe "econnect::create_jms"
include_recipe "econnect::create_jms_modules"
include_recipe "econnect::create_auth_provider"
include_recipe "econnect::deploy_libs"
include_recipe "econnect::deploy_app"
include_recipe "econnect::deploy_cc_app"
include_recipe "econnect::deploy_ca_app"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment