Update to allow for passing HL saved objects

This commit is contained in:
Wes Lambert
2022-01-28 17:59:34 +00:00
parent 5a37b14809
commit 3b76c2421c
4 changed files with 1019 additions and 743 deletions

View File

@@ -1,5 +1,6 @@
#!/bin/bash #!/bin/bash
{%- set MANAGER = salt['pillar.get']('global:url_base', '') %} {%- set MANAGER = salt['pillar.get']('global:url_base', '') %}
{%- set ENDGAMEHOST = salt['pillar.get']('soc:endgamehost', 'ENDGAMEHOST') %}
. /usr/sbin/so-common . /usr/sbin/so-common
check_file() { check_file() {
@@ -24,6 +25,11 @@ import() {
sed -i "s/PLACEHOLDER/{{ MANAGER }}/g" "$ndjson_file" sed -i "s/PLACEHOLDER/{{ MANAGER }}/g" "$ndjson_file"
fi fi
# Endgame
if grep -lq 'ENDGAMEHOST' "$ndjson_file"; then
sed -i "s/ENDGAMEHOST/{{ ENDGAMEHOST }}/g" "$ndjson_file"
fi
wait_for_web_response "http://localhost:5601/app/kibana" "Elastic" 300 "{{ ELASTICCURL }}" wait_for_web_response "http://localhost:5601/app/kibana" "Elastic" 300 "{{ ELASTICCURL }}"
SESSIONCOOKIE=$({{ ELASTICCURL }} -c - -X GET http://localhost:5601/ | grep sid | awk '{print $7}') SESSIONCOOKIE=$({{ ELASTICCURL }} -c - -X GET http://localhost:5601/ | grep sid | awk '{print $7}')
@@ -35,7 +41,7 @@ update() {
wait_for_web_response "http://localhost:5601/app/kibana" "Elastic" 300 "{{ ELASTICCURL }}" wait_for_web_response "http://localhost:5601/app/kibana" "Elastic" 300 "{{ ELASTICCURL }}"
IFS=$'\r\n' GLOBIGNORE='*' command eval 'LINES=($(cat $1))' IFS=$'\r\n' GLOBIGNORE='*' command eval 'LINES=($(cat $1))'
for i in "${LINES[@]}"; do for i in "${LINES[@]}"; do
{{ ELASTICCURL }} -X PUT "localhost:5601/api/saved_objects/config/7.16.3" -H 'kbn-xsrf: true' -H 'Content-Type: application/json' -d " $i " {{ ELASTICCURL }} -X PUT "localhost:5601/api/saved_objects/config/7.16.2" -H 'kbn-xsrf: true' -H 'Content-Type: application/json' -d " $i "
done done
} }

169
salt/kibana/files/hl.ndjson Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,3 +1,4 @@
{% set HIGHLANDER = salt['pillar.get']('global:highlander', False) %}
include: include:
- kibana - kibana
@@ -16,3 +17,20 @@ so-kibana-dashboard-load:
- require: - require:
- sls: kibana - sls: kibana
- file: dashboard_saved_objects_template - file: dashboard_saved_objects_template
{%- if HIGHLANDER %}
dashboard_saved_objects_template_hl:
file.managed:
- name: /opt/so/conf/kibana/hl.ndjson
- source: salt://kibana/files/hl.ndjson
- user: 932
- group: 939
- show_changes: False
so-kibana-dashboard-load_hl:
cmd.run:
- name: /usr/sbin/so-kibana-config-load -i /opt/so/conf/kibana/hl.ndjson
- cwd: /opt/so
- require:
- sls: kibana
- file: dashboard_saved_objects_template_hl
{%- endif %}