diff --git a/salt/elasticfleet/config.sls b/salt/elasticfleet/config.sls index 9c79dfab6..6a8919605 100644 --- a/salt/elasticfleet/config.sls +++ b/salt/elasticfleet/config.sls @@ -173,7 +173,7 @@ eaoptionalintegrationsdir: {% for minion in node_data %} {% set role = node_data[minion]["role"] %} -{% if role in [ "eval","fleet","heavynode","import","manager", "managerhype", "managersearch","standalone" ] %} +{% if role in [ "eval","fleet","import","manager", "managerhype", "managersearch","standalone" ] %} {% set optional_integrations = ELASTICFLEETMERGED.optional_integrations %} {% set integration_keys = optional_integrations.keys() %} fleet_server_integrations_{{ minion }}: diff --git a/salt/elasticfleet/manager.sls b/salt/elasticfleet/manager.sls index c9fe91d4d..4ae64314b 100644 --- a/salt/elasticfleet/manager.sls +++ b/salt/elasticfleet/manager.sls @@ -67,8 +67,6 @@ so-elastic-fleet-package-upgrade: interval: 30 - require: - http: wait_for_so-kibana - - onchanges: - - file: /opt/so/state/elastic_fleet_packages.txt so-elastic-fleet-integrations: cmd.run: diff --git a/salt/elasticfleet/tools/sbin/so-elastic-fleet-integration-policy-load b/salt/elasticfleet/tools/sbin/so-elastic-fleet-integration-policy-load index 33c880dba..7c2aeb006 100644 --- a/salt/elasticfleet/tools/sbin/so-elastic-fleet-integration-policy-load +++ b/salt/elasticfleet/tools/sbin/so-elastic-fleet-integration-policy-load @@ -9,13 +9,11 @@ RETURN_CODE=0 if [ ! -f /opt/so/state/eaintegrations.txt ]; then - # First, check for any package upgrades - /usr/sbin/so-elastic-fleet-package-upgrade - # Second, update Fleet Server policies + # update Fleet Server policies /usr/sbin/so-elastic-fleet-integration-policy-elastic-fleet-server - # Third, configure Elastic Defend Integration seperately + # configure Elastic Defend Integration separately /usr/sbin/so-elastic-fleet-integration-policy-elastic-defend # Each group fetches its agent policy once and dispatches create/update writes concurrently. @@ -32,9 +30,12 @@ if [ ! -f /opt/so/state/eaintegrations.txt ]; then elastic_fleet_load_integrations_dir "so-grid-nodes_heavy" \ /opt/so/conf/elastic-fleet/integrations/grid-nodes_heavy "Grid Nodes Policy_Heavy" || RETURN_CODE=1 - # Fleet Server - Optional integrations (one agent policy per FleetServer_* directory) + # Fleet Server - Optional integrations (adds integration configuration to a given FleetServer_ policy) for FLEET_DIR in /opt/so/conf/elastic-fleet/integrations-optional/FleetServer*/; do [ -d "$FLEET_DIR" ] || continue + INTEGRATIONS=("${FLEET_DIR%/}"/*.json) + [ -e "${INTEGRATIONS[0]}" ] || continue + FLEET_POLICY=$(basename "$FLEET_DIR") elastic_fleet_load_integrations_dir "$FLEET_POLICY" \ "${FLEET_DIR%/}" "Fleet Server Policy" "elasticsearch-logs" || RETURN_CODE=1 diff --git a/salt/elasticfleet/tools/sbin_jinja/so-elastic-fleet-package-upgrade b/salt/elasticfleet/tools/sbin_jinja/so-elastic-fleet-package-upgrade index 8ba250c00..f3d77b852 100644 --- a/salt/elasticfleet/tools/sbin_jinja/so-elastic-fleet-package-upgrade +++ b/salt/elasticfleet/tools/sbin_jinja/so-elastic-fleet-package-upgrade @@ -12,17 +12,22 @@ PKG_LOAD_FAILURES=0 PKG_LOAD_FAILURES_NAMES=() {%- for PACKAGE in SUPPORTED_PACKAGES %} -echo "Upgrading {{ PACKAGE }} package..." -if VERSION=$(elastic_fleet_package_latest_version_check "{{ PACKAGE }}"); then - if ! elastic_fleet_package_install "{{ PACKAGE }}" "$VERSION"; then - PKG_LOAD_FAILURES=$((PKG_LOAD_FAILURES + 1)) - PKG_LOAD_FAILURES_NAMES+=("{{ PACKAGE }}") +if INSTALLED_VERSION=$(elastic_fleet_package_version_check "{{ PACKAGE }}") && LATEST_VERSION=$(elastic_fleet_package_latest_version_check "{{ PACKAGE }}"); then + + if [ "$INSTALLED_VERSION" == "$LATEST_VERSION" ]; then + echo "{{ PACKAGE }} integration version $INSTALLED_VERSION is already at the reported latest version $LATEST_VERSION, skipping upgrade." + else + echo "Upgrading {{ PACKAGE }} package to version $LATEST_VERSION..." + if ! elastic_fleet_package_install "{{ PACKAGE }}" "$LATEST_VERSION"; then + PKG_LOAD_FAILURES=$((PKG_LOAD_FAILURES + 1)) + PKG_LOAD_FAILURES_NAMES+=("{{ PACKAGE }}") + fi fi else + echo "ERROR: Failed to get version information for integration {{ PACKAGE }}" PKG_LOAD_FAILURES=$((PKG_LOAD_FAILURES + 1)) PKG_LOAD_FAILURES_NAMES+=("{{ PACKAGE }}") fi -echo {%- endfor %} if [ $PKG_LOAD_FAILURES -gt 0 ]; then @@ -35,6 +40,3 @@ if [ $PKG_LOAD_FAILURES -gt 0 ]; then else echo "Successfully upgraded all packages." fi - -echo -/usr/sbin/so-elasticsearch-templates-load diff --git a/salt/elasticfleet/tools/sbin_jinja/so-elastic-fleet-setup b/salt/elasticfleet/tools/sbin_jinja/so-elastic-fleet-setup index 5e0dc0c69..b62310375 100755 --- a/salt/elasticfleet/tools/sbin_jinja/so-elastic-fleet-setup +++ b/salt/elasticfleet/tools/sbin_jinja/so-elastic-fleet-setup @@ -181,6 +181,9 @@ if ! elastic_fleet_policy_create "so-grid-nodes_heavy" "SO Grid Nodes - Heavy No exit 1 fi +# Check for package upgrades +so-elastic-fleet-package-upgrade + # Load Integrations for default policies so-elastic-fleet-integration-policy-load