Prevent string conversion for messageBusAddress
[so/so-config.git] / recipes / mso-asdc-controller-config.rb
1 ################
2
3 ######
4 include_recipe 'mso-config::createConfigDirectories'
5   
6 ################
7
8 ######
9
10 if !node.attribute?("asdc-connections") 
11     abort "ASDC connections not defined!\n" 
12 end
13
14 ruby_block 'replace_consumer_group_in_asdc_json' do 
15   block do 
16     
17     asdc_connections_reworked = Hash.new
18     
19     node["asdc-connections"].each do | asdc_name, asdc_config |
20         
21         asdc_client_configs = Hash.new
22         asdc_config.each do | config_name, config_value |
23            
24             if "#{config_name}" == "consumerGroup" or "#{config_name}" == "consumerId" 
25                 asdc_client_configs[config_name] = "#{config_value}-#{node.chef_environment}#{node['hostname'][-1]}"
26             elsif config_value.class == Array or config_value.class == Chef::Node::ImmutableArray
27                 asdc_client_configs[config_name] = config_value
28             else 
29                 asdc_client_configs[config_name] = "#{config_value}"
30             end
31         end
32         
33         asdc_connections_reworked[asdc_name] = asdc_client_configs
34     end
35
36     r = resources(template: 'mso_asdc_json') 
37     r.variables( 
38         :allAsdcConnections => asdc_connections_reworked
39     ) 
40   end 
41    notifies :create, 'template[mso_asdc_json]', :immediately
42 end
43
44 template "mso_asdc_json" do 
45   path "#{ node['mso_config_path'] }/mso.asdc.json" 
46   source "mso-asdc-controller-config/mso.asdc.json"
47   owner "jboss" 
48   group "jboss" 
49   mode "0744" 
50   action :nothing 
51 end
52
53 template "mso_asdc_clients_properties" do 
54   path "#{ node['mso_config_path'] }/mso.asdc.clients.properties" 
55   source "mso-asdc-controller-config/mso.asdc.clients.properties"
56   owner "jboss" 
57   group "jboss" 
58   mode "0744" 
59   variables(
60     :var => node["mso-asdc-controller-config"]
61   )
62 end
63
64 remote_directory "#{node['mso_config_path']}" do
65   source "mso-asdc-controller-config"
66   #cookbook "default is current"
67   files_mode "0744"
68   files_owner "jboss"
69   files_group "jboss"
70   mode "0755"
71   owner "jboss"
72   group "jboss"
73   overwrite true
74   recursive true
75   action :create
76 end