Skip to content

Commit

Permalink
lint providers
Browse files Browse the repository at this point in the history
  • Loading branch information
manegron committed Jun 2, 2024
1 parent d5f7f9b commit 02252f6
Showing 1 changed file with 45 additions and 49 deletions.
94 changes: 45 additions & 49 deletions resources/providers/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@
s3_local_storage = new_resource.s3_local_storage
elasticache_hosts = new_resource.elasticache_hosts

http_workers = ([[10 * node['cpu']['total'].to_i, (memory_kb / (3 * 1024 * 1024)).floor ].min, 1 ].max).to_i
http_workers = [[10 * node['cpu']['total'].to_i, (memory_kb / (3 * 1024 * 1024)).floor ].min, 1].max.to_i

# INSTALLATION
begin
licmode_dg = data_bag_item('rBglobal', 'licmode')
rescue
licmode_dg={}
end
licmode = licmode_dg['mode']
if (licmode != 'global' && licmode != 'organization')
licmode = 'global' if (licmode != 'global' && licmode != 'organization')
end
# begin
# licmode_dg = data_bag_item('rBglobal', 'licmode')
# rescue
# licmode_dg = {}
# end
# licmode = licmode_dg['mode']
# if licmode != 'global' && licmode != 'organization'
# licmode = 'global' if (licmode != 'global' && licmode != 'organization')
# end

dnf_package 'redborder-webui' do
action :install
Expand Down Expand Up @@ -113,7 +113,7 @@
cookbook 'webui'
action :create_if_missing
end

cookbook_file '/var/www/rb-rails/config/license.key.pub' do
source 'license.key.pub'
owner user
Expand Down Expand Up @@ -245,7 +245,7 @@
end

template '/var/www/rb-rails/config/chef_config.yml' do
source "chef_config.yml.erb"
source 'chef_config.yml.erb'
owner user
group group
mode '0644'
Expand Down Expand Up @@ -279,17 +279,16 @@
end

template '/var/www/rb-rails/config/redborder_config.yml' do
source 'redborder_config.yml.erb'
owner user
group group
mode '0644'
retries 2
cookbook 'webui'
variables(cdomain: cdomain,
webui_secret_token: webui_secret_token)
# :proxy_insecure => proxy_insecure) #TODO when client proxy done. Set proxy_verify_cert in template
notifies :restart, 'service[webui]', :delayed
notifies :restart, 'service[rb-workers]', :delayed
source 'redborder_config.yml.erb'
owner user
group group
mode '0644'
retries 2
cookbook 'webui'
variables(cdomain: cdomain,
webui_secret_token: webui_secret_token)
notifies :restart, 'service[webui]', :delayed
notifies :restart, 'service[rb-workers]', :delayed
end

template '/var/www/rb-rails/config/rbdruid_config.yml' do
Expand Down Expand Up @@ -351,7 +350,7 @@
retries 2
cookbook 'webui'
notifies :restart, 'service[webui]', :delayed
end
end

%w(flow ips location monitor iot).each do |x|
template "/var/www/rb-rails/lib/modules/#{x}/config/rbdruid_config.yml" do
Expand All @@ -362,29 +361,29 @@
retries 2
cookbook 'webui'
notifies :restart, 'service[webui]', :delayed
end if Dir.exists?("/var/www/rb-rails/lib/modules/#{x}/config")
end if Dir.exist?("/var/www/rb-rails/lib/modules/#{x}/config")
end

template '/var/www/rb-rails/config/unicorn.rb' do
source 'unicorn.rb.erb'
owner user
group group
mode '0644'
retries 2
cookbook 'webui'
variables(workers: http_workers)
notifies :restart, 'service[webui]', :delayed
source 'unicorn.rb.erb'
owner user
group group
mode '0644'
retries 2
cookbook 'webui'
variables(workers: http_workers)
notifies :restart, 'service[webui]', :delayed
end

template '/etc/sysconfig/webui' do
source 'webui_sysconfig.erb'
owner user
group group
mode '0644'
retries 2
cookbook 'webui'
variables(memory: memory_kb)
notifies :restart, 'service[webui]', :delayed
source 'webui_sysconfig.erb'
owner user
group group
mode '0644'
retries 2
cookbook 'webui'
variables(memory: memory_kb)
notifies :restart, 'service[webui]', :delayed
end

begin
Expand All @@ -393,7 +392,7 @@
rsa_pem = nil
end

if rsa_pem && rsa_pem["private_rsa"]
if rsa_pem && rsa_pem['private_rsa']
template '/var/www/rb-rails/config/rsa' do
source 'rsa_cert.pem.erb'
owner user
Expand All @@ -403,7 +402,7 @@
cookbook 'webui'
notifies :restart, 'service[webui]', :delayed
notifies :restart, 'service[rb-workers]', :delayed
variables(:private_rsa => rsa_pem['private_rsa'])
variables(private_rsa: rsa_pem['private_rsa'])
end
end

Expand Down Expand Up @@ -480,7 +479,7 @@
group group
action :nothing
end

bash 'redBorder_update' do
ignore_failure false
code <<-EOH
Expand Down Expand Up @@ -554,7 +553,7 @@
action :configure_certs do
begin
cdomain = new_resource.cdomain
json_cert = nginx_certs('webui',cdomain)
json_cert = nginx_certs('webui', cdomain)

template '/etc/nginx/ssl/webui.crt' do
source 'cert.crt.erb'
Expand Down Expand Up @@ -588,7 +587,7 @@

action :remove do
begin
web_dir = new_resource.web_dir
# web_dir = new_resource.web_dir

# dnf_package 'redborder-webui' do
# action :remove
Expand Down Expand Up @@ -675,7 +674,6 @@
end.run_action(:run)
end
Chef::Log.info('Webui cookbook - RSA cert has been processed')

rescue => e
Chef::Log.error(e.message)
end
Expand Down Expand Up @@ -817,7 +815,6 @@
supports status: true, reload: true, restart: true, enable: true
action :nothing
end

rescue => e
Chef::Log.error(e.message)
end
Expand All @@ -844,7 +841,6 @@
supports status: true, reload: true, restart: true, enable: true
action :nothing
end

rescue => e
Chef::Log.error(e.message)
end
Expand Down

0 comments on commit 02252f6

Please sign in to comment.