Fixes for cloud Elastic 7 (#260)

Former-commit-id: ca1578ed27
This commit is contained in:
AlfonsoRBJ
2019-10-03 17:38:43 +02:00
committed by Jesús Linares
parent fdb55e8ce1
commit ddd37f0f9a
13 changed files with 233 additions and 46 deletions

View File

@@ -17,6 +17,9 @@ ENV WAZUH_ALERTS_SHARDS="1" \
ADD https://raw.githubusercontent.com/wazuh/wazuh/$TEMPLATE_VERSION/extensions/elasticsearch/7.x/wazuh-template.json /usr/share/elasticsearch/config
RUN yum install epel-release -y && \
yum install jq -y
# This CA is created for testing. Please set your own CA zip containing the key and the signed certificate.
# command: $ docker build <elasticsearch_directory> --build-arg SECURITY_CA_PEM_LOCATION=<CA_PEM_LOCATION> --build-arg SECURITY_CA_KEY_LOCATION=<CA_KEY_LOCATION>
# ENV variables are necessary: SECURITY_CA_PEM, SECURITY_CA_KEY, SECURITY_CA_TRUST, SECURITY_OPENSSL_CONF

View File

@@ -174,6 +174,53 @@ if [ "x$CONFIG_CODE" != "x200" ]; then
' > /dev/null
else
echo "LOAD SETTINGS - Wazuh APP already configured"
echo "LOAD SETTINGS - Check if it is an upgrade from Elasticsearch 6.x to 7.x"
wazuh_search_request=`curl -s ${auth} "$el_url/.wazuh/_search?pretty"`
full_type=`echo $wazuh_search_request | jq .hits.hits | jq .[] | jq ._type`
elasticsearch_request=`curl -s $auth "$el_url"`
full_elasticsearch_version=`echo $elasticsearch_request | jq .version.number`
type=`echo "$full_type" | tr -d '"'`
elasticsearch_version=`echo "$full_elasticsearch_version" | tr -d '"'`
elasticsearch_major="${elasticsearch_version:0:1}"
if [[ $type == "wazuh-configuration" ]] && [[ $elasticsearch_major == "7" ]]; then
echo "LOAD SETTINGS - Elasticsearch major = $elasticsearch_major."
echo "LOAD SETTINGS - Reindex .wazuh in .wazuh-backup."
curl -s ${auth} -XPOST "$el_url/_reindex" -H 'Content-Type: application/json' -d'
{
"source": {
"index": ".wazuh"
},
"dest": {
"index": ".wazuh-backup"
}
}
'
echo "LOAD SETTINGS - Remove .wazuh index."
curl -s ${auth} -XDELETE "$el_url/.wazuh"
echo "LOAD SETTINGS - Reindex .wazuh-backup in .wazuh."
curl -s ${auth} -XPOST "$el_url/_reindex" -H 'Content-Type: application/json' -d'
{
"source": {
"index": ".wazuh-backup"
},
"dest": {
"index": ".wazuh"
}
}
'
curl -s ${auth} -XPUT "https://elasticsearch:9200/.wazuh-backup/_settings?pretty" -H 'Content-Type: application/json' -d'
{
"index" : {
"number_of_replicas" : 0
}
}
'
fi
fi
sleep 5