mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2026-08-30 11:19:19 +02:00
after an ES upgrade run a final elasticsearch state to create/regenerate any needed addon index templates
This commit is contained in:
@@ -68,6 +68,15 @@ so-elastic-fleet-package-upgrade:
|
||||
- require:
|
||||
- http: wait_for_so-kibana
|
||||
|
||||
# initial so-elasticsearch-templates run is earlier, but it can skip over templates that have component templates not yet installed to avoid elasticsearch rejecting the template.
|
||||
so-elasticsearch-templates-after-fleet-packages:
|
||||
cmd.run:
|
||||
- name: /usr/sbin/so-elasticsearch-templates-load
|
||||
- cwd: /opt/so
|
||||
- unless: test -f /opt/so/state/estemplates.txt
|
||||
- require:
|
||||
- cmd: so-elastic-fleet-package-upgrade
|
||||
|
||||
so-elastic-fleet-integration-upgrade:
|
||||
cmd.run:
|
||||
- name: /usr/sbin/so-elastic-fleet-integration-upgrade
|
||||
@@ -101,6 +110,7 @@ so-elastic-fleet-addon-integrations:
|
||||
- name: /usr/sbin/so-elastic-fleet-optional-integrations-load
|
||||
- require:
|
||||
- http: wait_for_so-kibana
|
||||
- cmd: so-elasticsearch-templates-after-fleet-packages
|
||||
|
||||
{% if ELASTICFLEETMERGED.config.defend_filters.enable_auto_configuration %}
|
||||
so-elastic-defend-manage-filters-file-watch:
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
PKG_LOAD_FAILURES=0
|
||||
PKG_LOAD_FAILURES_NAMES=()
|
||||
PKG_UPGRADED=0
|
||||
|
||||
cleanup_elasticsearch_fleet_transforms() {
|
||||
local transforms transform_id attempt
|
||||
@@ -49,6 +50,7 @@ if INSTALLED_VERSION=$(elastic_fleet_package_version_check "{{ PACKAGE }}") && L
|
||||
PKG_LOAD_FAILURES_NAMES+=("{{ PACKAGE }}")
|
||||
elif INSTALLED_VERSION=$(elastic_fleet_package_version_check "{{ PACKAGE }}") && [ "$INSTALLED_VERSION" == "$LATEST_VERSION" ]; then
|
||||
echo "{{ PACKAGE }} integration upgraded to version $LATEST_VERSION."
|
||||
PKG_UPGRADED=$((PKG_UPGRADED + 1))
|
||||
else
|
||||
echo "ERROR: {{ PACKAGE }} integration still at ${INSTALLED_VERSION:-unknown}; expected $LATEST_VERSION"
|
||||
PKG_LOAD_FAILURES=$((PKG_LOAD_FAILURES + 1))
|
||||
@@ -62,6 +64,11 @@ else
|
||||
fi
|
||||
{%- endfor %}
|
||||
|
||||
if [ $PKG_UPGRADED -gt 0 ]; then
|
||||
echo "Elasticsearch template statefiles cleared after $PKG_UPGRADED package upgrade(s), so templates can reload."
|
||||
rm -f /opt/so/state/estemplates.txt /opt/so/state/addon_estemplates.txt
|
||||
fi
|
||||
|
||||
if [ $PKG_LOAD_FAILURES -gt 0 ]; then
|
||||
echo "ERROR: Failed to upgrade $PKG_LOAD_FAILURES package(s):"
|
||||
for PKG in "${PKG_LOAD_FAILURES_NAMES[@]}"; do
|
||||
|
||||
@@ -2145,7 +2145,13 @@ main() {
|
||||
check_saltmaster_status
|
||||
postupgrade_changes
|
||||
[[ $is_airgap -eq 0 ]] && unmount_update
|
||||
|
||||
|
||||
if [[ "$es_version" != "$target_es_version" ]]; then
|
||||
# Run final elasticsearch state on manager to ensure addon index templates are created/regenerated and loaded
|
||||
echo "Running final elasticsearch state at $(date +"%T.%6N"), after upgrade to $POSTVERSION"
|
||||
salt-call state.apply elasticsearch queue=True
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Upgrade to $NEWVERSION complete."
|
||||
|
||||
|
||||
Reference in New Issue
Block a user