aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/mso-asdc-controller-config.rb
blob: 0d84dec143fe9e60b6dd5e93e6d1dc4f1316ac9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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