TLS sdc-be-init: truststore & keystore handling
[sdc.git] / catalog-be / sdc-backend-init / chef-repo / cookbooks / sdc-catalog-be-setup / recipes / 2_check_Backend.rb
1 require 'base64'
2 if node['disableHttp']
3   protocol = "https"
4   https_flag = "--https"
5   be_port = node['BE']['https_port']
6   if node['BE-init']['tls_cert'] && node['BE-init']['tls_key']
7     tls_key = "--tls_key " + node['BE-init']['tls_key']
8     tls_cert = "--tls_cert " + node['BE-init']['tls_cert']
9     if node['BE-init']['tls_password']
10       tls_key_pw = "--tls_key_pw " + node['BE-init']['tls_password']
11     end
12   end
13   if node['BE-init']['ca_cert']
14     ca_cert =  "--ca_cert " + node['BE-init']['ca_cert']
15   end
16 else
17   protocol = "http"
18   https_flag = ""
19   be_port = node['BE']['http_port']
20 end
21
22 if node['basic_auth']
23   basic_auth_enabled = node['basic_auth']['enabled']
24   basic_auth_user = node['basic_auth']['user_name']
25   basic_auth_pass = node['basic_auth']['user_pass']
26   if basic_auth_enabled
27     basic_auth_config = "--header " + Base64.strict_encode64(basic_auth_user + ":" + basic_auth_pass)
28   else
29     # set default user configuration file
30     basic_auth_config = ""
31   end
32 end
33
34 execute "executing-check_backend_health" do
35   command "sdccheckbackend -i #{node['Nodes']['BE']} -p #{be_port} #{basic_auth_config} #{https_flag} #{tls_cert} #{tls_key} #{tls_key_pw} #{ca_cert}"
36   action :run
37 end