From 0cdeba64bf8108e14946939205ce54637c5c8203 Mon Sep 17 00:00:00 2001 From: Jose M Date: Mon, 30 Dec 2019 18:22:58 +0100 Subject: [PATCH] Add Bash block to remove the .wazuh index and configure wazuh.yml file --- cookbooks/wazuh_elastic/recipes/kibana.rb | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/cookbooks/wazuh_elastic/recipes/kibana.rb b/cookbooks/wazuh_elastic/recipes/kibana.rb index 07d188ac..1f586961 100644 --- a/cookbooks/wazuh_elastic/recipes/kibana.rb +++ b/cookbooks/wazuh_elastic/recipes/kibana.rb @@ -83,10 +83,36 @@ end end +bash 'Removing .wazuh index if exists' do + code <<-EOH + curl_response=$(curl -s -XDELETE -sL -w "%{http_code}" -I "http://#{node['wazuh-elastic']['elasticsearch_ip']}:#{node['wazuh-elastic']['elasticsearch_port']}/.wazuh" -o /dev/null) + if [ ${curl_response} == 404 ] + then + echo "Index .wazuh not found" + elif [ ${curl_response} == 200 ] + then + echo "Index .wazuh removed successfully" + else + echo "Unable to communicate with Elasticsearch API" + fi + EOH +end + +template 'Configuring API credentials in wazuh.yml file' do + path '/usr/share/kibana/plugins/wazuh/wazuh.yml' + source 'wazuh.yml.erb' + owner 'kibana' + group 'root' + mode 0644 + notifies :restart, "service[kibana]", :delayed +end + bash 'Verify Kibana folders owner' do code <<-EOF chown -R kibana:kibana /usr/share/kibana/optimize chown -R kibana:kibana /usr/share/kibana/plugins EOF +end + end \ No newline at end of file