aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/mso-asdc-controller-config.rb
diff options
context:
space:
mode:
Diffstat (limited to 'recipes/mso-asdc-controller-config.rb')
-rw-r--r--recipes/mso-asdc-controller-config.rb63
1 files changed, 63 insertions, 0 deletions
diff --git a/recipes/mso-asdc-controller-config.rb b/recipes/mso-asdc-controller-config.rb
new file mode 100644
index 0000000..0d84dec
--- /dev/null
+++ b/recipes/mso-asdc-controller-config.rb
@@ -0,0 +1,63 @@
+################
+#
+######
+include_recipe 'mso-config::createConfigDirectories'
+
+################
+#
+######
+
+if !node.attribute?("asdc-connections")
+ abort "ASDC connections not defined!\n"
+end
+
+ruby_block 'replace_consumer_group_in_asdc_json' do
+ block do
+
+ asdc_connections_reworked = Hash.new
+
+ node["asdc-connections"].each do | asdc_name, asdc_config |
+
+ asdc_client_configs = Hash.new
+ asdc_config.each do | config_name, config_value |
+
+ if "#{config_name}" == "consumerGroup" or "#{config_name}" == "consumerId"
+ asdc_client_configs[config_name] = "#{config_value}-#{node.chef_environment}#{node['hostname'][-1]}"
+ else
+ asdc_client_configs[config_name] = "#{config_value}"
+ end
+ end
+
+ asdc_connections_reworked[asdc_name] = asdc_client_configs
+ end
+
+ r = resources(template: 'mso_asdc_json')
+ r.variables(
+ :allAsdcConnections => asdc_connections_reworked
+ )
+ end
+ notifies :create, 'template[mso_asdc_json]', :immediately
+end
+
+template "mso_asdc_json" do
+ path "#{ node['mso_config_path'] }/mso.asdc.json"
+ source "mso-asdc-controller-config/mso.asdc.json"
+ owner "jboss"
+ group "jboss"
+ mode "0744"
+ action :nothing
+end
+
+remote_directory "#{node['mso_config_path']}" do
+ source "mso-asdc-controller-config"
+ #cookbook "default is current"
+ files_mode "0744"
+ files_owner "jboss"
+ files_group "jboss"
+ mode "0755"
+ owner "jboss"
+ group "jboss"
+ overwrite true
+ recursive true
+ action :create
+end