43 lines
1.8 KiB
Bash
43 lines
1.8 KiB
Bash
#!/bin/bash
|
|
|
|
## run security_admin in each node
|
|
#for NODE_NAME in "node1" "node2"
|
|
#do
|
|
#
|
|
# COMMAND=(docker exec -it opensearch-$NODE_NAME /usr/share/opensearch/plugins/opensearch-security/tools/securityadmin.sh --clustername opensearch-cluster --configdir /usr/share/opensearch/config/opensearch-security -cacert /usr/share/opensearch/config/certs/opensearch-ca.pem -key /usr/share/opensearch/config/certs/opensearch-admin.key -cert /usr/share/opensearch/config/certs/opensearch-admin.pem -h opensearch-$NODE_NAME)
|
|
#
|
|
# until "${COMMAND[@]}" ; do
|
|
# echo "opensearch not up yet. retrying in 10 seconds..."
|
|
# sleep 10
|
|
# done
|
|
#done
|
|
|
|
# use opensearch-dashboards api to create index pattern logstash-* for global tennant until it succeeds. (this will not create it for you personal tenant)
|
|
cat > /tmp/opensearch_create_index_pattern.sh << EOF
|
|
curl -k \
|
|
-X POST "http://opensearch-dashboards:5601/api/saved_objects/index-pattern/logstash-*" \
|
|
-u 'admin:vagrant' \
|
|
-H "securitytenant:global" \
|
|
-H "osd-xsrf:true" \
|
|
-H "content-type:application/json" \
|
|
-d "{ \"attributes\": { \"title\": \"logstash-*\", \"timeFieldName\": \"@timestamp\" } }"
|
|
EOF
|
|
|
|
cat > /tmp/opensearch_check_index_pattern.sh << EOF
|
|
curl -k \
|
|
-X GET "http://opensearch-dashboards:5601/api/saved_objects/index-pattern/logstash-*" \
|
|
-u 'admin:vagrant' \
|
|
-H "securitytenant:global" \
|
|
-H "osd-xsrf:true" \
|
|
-H "content-type:application/json" \
|
|
| grep "namespace"
|
|
EOF
|
|
chmod +x /tmp/opensearch_*.sh
|
|
|
|
until "/tmp/opensearch_check_index_pattern.sh" ; do
|
|
echo "opensearch index-pattern does not exist; trying to create logstash-*"
|
|
/tmp/opensearch_create_index_pattern.sh
|
|
sleep 10
|
|
done
|
|
echo "opensearch index-pattern created"
|