mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2026-06-11 12:55:20 +02:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| eb82f9ea9d |
@@ -101,17 +101,6 @@ so-elastic-fleet:
|
||||
- file: trusttheca
|
||||
- x509: etc_elasticfleet_key
|
||||
- x509: etc_elasticfleet_crt
|
||||
|
||||
wait_for_so-elastic-fleet:
|
||||
http.wait_for_successful_query:
|
||||
- name: "https://localhost:8220/api/status"
|
||||
- ssl: True
|
||||
- verify_ssl: False
|
||||
- status: 200
|
||||
- wait_for: 300
|
||||
- request_interval: 15
|
||||
- require:
|
||||
- docker_container: so-elastic-fleet
|
||||
{% endif %}
|
||||
|
||||
delete_so-elastic-fleet_so-status.disabled:
|
||||
|
||||
@@ -9,20 +9,16 @@
|
||||
|
||||
include:
|
||||
- elasticfleet.config
|
||||
- kibana.enabled
|
||||
|
||||
# If enabled, automatically update Fleet Logstash Outputs
|
||||
{% if ELASTICFLEETMERGED.config.server.enable_auto_configuration %}
|
||||
{% if grains.role not in ['so-import', 'so-eval']%}
|
||||
{% if ELASTICFLEETMERGED.config.server.enable_auto_configuration and grains.role not in ['so-import', 'so-eval'] %}
|
||||
so-elastic-fleet-auto-configure-logstash-outputs:
|
||||
cmd.run:
|
||||
- name: /usr/sbin/so-elastic-fleet-outputs-update
|
||||
- retry:
|
||||
attempts: 4
|
||||
interval: 30
|
||||
- require:
|
||||
- http: wait_for_so-kibana
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
# If enabled, automatically update Fleet Server URLs & ES Connection
|
||||
so-elastic-fleet-auto-configure-server-urls:
|
||||
@@ -31,9 +27,6 @@ so-elastic-fleet-auto-configure-server-urls:
|
||||
- retry:
|
||||
attempts: 4
|
||||
interval: 30
|
||||
- require:
|
||||
- http: wait_for_so-kibana
|
||||
{% endif %}
|
||||
|
||||
# Automatically update Fleet Server Elasticsearch URLs & Agent Artifact URLs
|
||||
so-elastic-fleet-auto-configure-elasticsearch-urls:
|
||||
@@ -42,8 +35,6 @@ so-elastic-fleet-auto-configure-elasticsearch-urls:
|
||||
- retry:
|
||||
attempts: 4
|
||||
interval: 30
|
||||
- require:
|
||||
- http: wait_for_so-kibana
|
||||
|
||||
so-elastic-fleet-auto-configure-artifact-urls:
|
||||
cmd.run:
|
||||
@@ -51,8 +42,6 @@ so-elastic-fleet-auto-configure-artifact-urls:
|
||||
- retry:
|
||||
attempts: 4
|
||||
interval: 30
|
||||
- require:
|
||||
- http: wait_for_so-kibana
|
||||
|
||||
so-elastic-fleet-package-statefile:
|
||||
file.managed:
|
||||
@@ -64,9 +53,7 @@ so-elastic-fleet-package-upgrade:
|
||||
- name: /usr/sbin/so-elastic-fleet-package-upgrade
|
||||
- retry:
|
||||
attempts: 3
|
||||
interval: 30
|
||||
- require:
|
||||
- http: wait_for_so-kibana
|
||||
interval: 10
|
||||
- onchanges:
|
||||
- file: /opt/so/state/elastic_fleet_packages.txt
|
||||
|
||||
@@ -76,8 +63,6 @@ so-elastic-fleet-integrations:
|
||||
- retry:
|
||||
attempts: 3
|
||||
interval: 10
|
||||
- require:
|
||||
- http: wait_for_so-kibana
|
||||
|
||||
so-elastic-agent-grid-upgrade:
|
||||
cmd.run:
|
||||
@@ -85,8 +70,6 @@ so-elastic-agent-grid-upgrade:
|
||||
- retry:
|
||||
attempts: 12
|
||||
interval: 5
|
||||
- require:
|
||||
- http: wait_for_so-kibana
|
||||
|
||||
so-elastic-fleet-integration-upgrade:
|
||||
cmd.run:
|
||||
@@ -94,22 +77,16 @@ so-elastic-fleet-integration-upgrade:
|
||||
- retry:
|
||||
attempts: 3
|
||||
interval: 10
|
||||
- require:
|
||||
- http: wait_for_so-kibana
|
||||
|
||||
{# Optional integrations script doesn't need the retries like so-elastic-fleet-integration-upgrade which loads the default integrations #}
|
||||
so-elastic-fleet-addon-integrations:
|
||||
cmd.run:
|
||||
- name: /usr/sbin/so-elastic-fleet-optional-integrations-load
|
||||
- require:
|
||||
- http: wait_for_so-kibana
|
||||
|
||||
{% if ELASTICFLEETMERGED.config.defend_filters.enable_auto_configuration %}
|
||||
so-elastic-defend-manage-filters-file-watch:
|
||||
cmd.run:
|
||||
- name: python3 /sbin/so-elastic-defend-manage-filters.py -c /opt/so/conf/elasticsearch/curl.config -d /opt/so/conf/elastic-fleet/defend-exclusions/disabled-filters.yaml -i /nsm/securityonion-resources/event_filters/ -i /opt/so/conf/elastic-fleet/defend-exclusions/rulesets/custom-filters/ &>> /opt/so/log/elasticfleet/elastic-defend-manage-filters.log
|
||||
- require:
|
||||
- http: wait_for_so-kibana
|
||||
- onchanges:
|
||||
- file: elasticdefendcustom
|
||||
- file: elasticdefenddisabled
|
||||
|
||||
@@ -108,12 +108,9 @@ if [ ! -f /opt/so/state/eaintegrations.txt ]; then
|
||||
done
|
||||
|
||||
# Only create the state file if all policies were created/updated successfully
|
||||
if [[ $RETURN_CODE -eq 0 ]]; then
|
||||
if [[ "$RETURN_CODE" != "1" ]]; then
|
||||
touch /opt/so/state/eaintegrations.txt
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "Fleet integration policies already loaded."
|
||||
exit 0
|
||||
exit $RETURN_CODE
|
||||
fi
|
||||
|
||||
@@ -8,33 +8,18 @@
|
||||
|
||||
. /usr/sbin/so-elastic-fleet-common
|
||||
|
||||
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 }}")
|
||||
# exit 1 on failure to upgrade a default package, allow salt to handle retries
|
||||
echo -e "\nERROR: Failed to upgrade $PACKAGE to version: $VERSION"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
PKG_LOAD_FAILURES=$((PKG_LOAD_FAILURES + 1))
|
||||
PKG_LOAD_FAILURES_NAMES+=("{{ PACKAGE }}")
|
||||
echo -e "\nERROR: Failed to get version information for integration $PACKAGE"
|
||||
fi
|
||||
echo
|
||||
{%- endfor %}
|
||||
|
||||
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
|
||||
echo " - $PKG"
|
||||
done
|
||||
# exit 1 on failure to upgrade a default package, allow salt to handle retries
|
||||
exit 1
|
||||
else
|
||||
echo "Successfully upgraded all packages."
|
||||
fi
|
||||
|
||||
echo
|
||||
/usr/sbin/so-elasticsearch-templates-load
|
||||
|
||||
@@ -9,12 +9,9 @@
|
||||
{% from 'elasticsearch/config.map.jinja' import ELASTICSEARCHMERGED %}
|
||||
{% from 'elasticsearch/template.map.jinja' import ES_INDEX_SETTINGS, SO_MANAGED_INDICES %}
|
||||
{% if GLOBALS.role != 'so-heavynode' %}
|
||||
{% from 'elasticsearch/template.map.jinja' import ALL_ADDON_SETTINGS, ADDON_INDICES %}
|
||||
{% from 'elasticsearch/template.map.jinja' import ALL_ADDON_SETTINGS %}
|
||||
{% endif %}
|
||||
|
||||
include:
|
||||
- elasticsearch.enabled
|
||||
|
||||
escomponenttemplates:
|
||||
file.recurse:
|
||||
- name: /opt/so/conf/elasticsearch/templates/component
|
||||
@@ -38,20 +35,6 @@ so_index_template_dir:
|
||||
{%- endfor %}
|
||||
{%- endif %}
|
||||
|
||||
{% if GLOBALS.role != "so-heavynode" %}
|
||||
# Clean up legacy and non-SO managed templates from the elasticsearch/templates/addon-index/ directory
|
||||
addon_index_template_dir:
|
||||
file.directory:
|
||||
- name: /opt/so/conf/elasticsearch/templates/addon-index
|
||||
- clean: True
|
||||
{%- if ADDON_INDICES %}
|
||||
- require:
|
||||
{%- for index in ADDON_INDICES %}
|
||||
- file: addon_index_template_{{index}}
|
||||
{%- endfor %}
|
||||
{%- endif %}
|
||||
{% endif %}
|
||||
|
||||
# Auto-generate index templates for SO managed indices (directly defined in elasticsearch/defaults.yaml)
|
||||
# These index templates are for the core SO datasets and are always required
|
||||
{% for index, settings in ES_INDEX_SETTINGS.items() %}
|
||||
|
||||
@@ -61,25 +61,15 @@
|
||||
{% if ALL_ADDON_SETTINGS_ORIG.keys() | length > 0 %}
|
||||
{% for index in ALL_ADDON_SETTINGS_ORIG.keys() %}
|
||||
{% do ALL_ADDON_SETTINGS_GLOBAL_OVERRIDES.update({index: salt['defaults.merge'](ALL_ADDON_SETTINGS_ORIG[index], PILLAR_GLOBAL_OVERRIDES, in_place=False)}) %}
|
||||
{# Explicitly excluding addon indices from ES_INDEX_SETTINGS_ORIG
|
||||
When manager.soc_managed_annotations runs, new entries are added to the salt/elasticsearch/defaults.yaml file to support 'revert to default' functionality.
|
||||
Subsequent map renders will then incorrectly include 'integration X' in 'ES_INDEX_SETTINGS_ORIG' due to being in the defaults.yaml file. #}
|
||||
{% if index in ES_INDEX_SETTINGS_ORIG.keys() %}
|
||||
{% do ES_INDEX_SETTINGS_ORIG.pop(index) %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{% set ES_INDEX_SETTINGS = {} %}
|
||||
{% macro create_final_index_template(DEFINED_SETTINGS, GLOBAL_OVERRIDES, FINAL_INDEX_SETTINGS, EXCLUDE_INDICES=[]) %}
|
||||
{% macro create_final_index_template(DEFINED_SETTINGS, GLOBAL_OVERRIDES, FINAL_INDEX_SETTINGS) %}
|
||||
|
||||
{% do GLOBAL_OVERRIDES.update(salt['defaults.merge'](GLOBAL_OVERRIDES, ES_INDEX_PILLAR, in_place=False)) %}
|
||||
{% for index, settings in GLOBAL_OVERRIDES.items() %}
|
||||
|
||||
{% if index in EXCLUDE_INDICES %}
|
||||
{% continue %}
|
||||
{% endif %}
|
||||
|
||||
{# prevent this action from being performed on custom defined indices. #}
|
||||
{# the custom defined index is not present in either of the dictionaries and fails to reder. #}
|
||||
{% if index in DEFINED_SETTINGS and index in GLOBAL_OVERRIDES %}
|
||||
@@ -160,19 +150,10 @@
|
||||
{% endfor %}
|
||||
{% endmacro %}
|
||||
|
||||
{# Exclude addon integrations from final ES_INDEX_SETTINGS #}
|
||||
{{ create_final_index_template(ES_INDEX_SETTINGS_ORIG, ES_INDEX_SETTINGS_GLOBAL_OVERRIDES, ES_INDEX_SETTINGS, ALL_ADDON_SETTINGS_ORIG.keys() | list ) }}
|
||||
|
||||
{# Exclude SO managed indices, otherwise ALL_ADDON_SETTINGS will include pillar values
|
||||
of core integrations without merging defaults, resulting in an overlapping, but bad index template being generated. #}
|
||||
{{ create_final_index_template(ALL_ADDON_SETTINGS_ORIG, ALL_ADDON_SETTINGS_GLOBAL_OVERRIDES, ALL_ADDON_SETTINGS, ES_INDEX_SETTINGS_ORIG.keys() | list ) }}
|
||||
{{ create_final_index_template(ES_INDEX_SETTINGS_ORIG, ES_INDEX_SETTINGS_GLOBAL_OVERRIDES, ES_INDEX_SETTINGS) }}
|
||||
{{ create_final_index_template(ALL_ADDON_SETTINGS_ORIG, ALL_ADDON_SETTINGS_GLOBAL_OVERRIDES, ALL_ADDON_SETTINGS) }}
|
||||
|
||||
{% set SO_MANAGED_INDICES = [] %}
|
||||
{% for index, settings in ES_INDEX_SETTINGS.items() %}
|
||||
{% do SO_MANAGED_INDICES.append(index) %}
|
||||
{% endfor %}
|
||||
|
||||
{% set ADDON_INDICES = [] %}
|
||||
{% for index, settings in ALL_ADDON_SETTINGS.items() %}
|
||||
{% do ADDON_INDICES.append(index) %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
@@ -6,7 +6,6 @@
|
||||
{% from 'allowed_states.map.jinja' import allowed_states %}
|
||||
{% if sls.split('.')[0] in allowed_states %}
|
||||
{% from 'docker/docker.map.jinja' import DOCKERMERGED %}
|
||||
{% from 'elasticsearch/config.map.jinja' import ELASTICSEARCHMERGED %}
|
||||
{% from 'vars/globals.map.jinja' import GLOBALS %}
|
||||
|
||||
include:
|
||||
@@ -61,19 +60,6 @@ so-kibana:
|
||||
- watch:
|
||||
- file: kibanaconfig
|
||||
|
||||
wait_for_so-kibana:
|
||||
http.wait_for_successful_query:
|
||||
- name: "http://localhost:5601/api/status"
|
||||
- username: 'so_elastic'
|
||||
- password: '{{ ELASTICSEARCHMERGED.auth.users.so_elastic_user.pass }}'
|
||||
- ssl: True
|
||||
- verify_ssl: False
|
||||
- status: 200
|
||||
- wait_for: 300
|
||||
- request_interval: 15
|
||||
- require:
|
||||
- docker_container: so-kibana
|
||||
|
||||
delete_so-kibana_so-status.disabled:
|
||||
file.uncomment:
|
||||
- name: /opt/so/conf/so-status/so-status.conf
|
||||
|
||||
@@ -31,13 +31,11 @@ sync_es_users:
|
||||
- http: wait_for_kratos
|
||||
- file: so-user.lock # require so-user.lock file to be missing
|
||||
|
||||
# we dont want this added too early in setup, so the onlyif gates on the
|
||||
# /opt/so/state/setup-complete marker. The marker is written by
|
||||
# mark_setup_complete in setup/so-functions just before the final setup
|
||||
# highstate (and by an upgrade-path state for systems set up under the old gate).
|
||||
# we dont want this added too early in setup, so we add the onlyif to verify 'startup_states: highstate'
|
||||
# is in the minion config. That line is added before the final highstate during setup
|
||||
so-user_sync:
|
||||
cron.present:
|
||||
- user: root
|
||||
- name: 'PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin /usr/sbin/so-user sync &>> /opt/so/log/soc/sync.log'
|
||||
- identifier: so-user_sync
|
||||
- onlyif: "test -e /opt/so/state/setup-complete"
|
||||
- onlyif: "grep -x 'startup_states: highstate' /etc/salt/minion"
|
||||
|
||||
@@ -1,117 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright Security Onion Solutions LLC and/or licensed to Security Onion Solutions LLC under one
|
||||
# or more contributor license agreements. Licensed under the Elastic License 2.0 as shown at
|
||||
# https://securityonion.net/license; you may not use this file except in compliance with the
|
||||
# Elastic License 2.0.
|
||||
|
||||
# Runs once per boot on managers (via so-boot-mine-update.service), before
|
||||
# so-boot-highstate.service. Waits for the responsive minion set to settle, pushes
|
||||
# mine.update, waits until every up minion has actually reported to the mine, then
|
||||
# warms the master's per-minion pillar cache so the mine-backed node pillars (node
|
||||
# IPs, ES/Redis/Logstash/hypervisor discovery -- some glob- and some pillar/grain-
|
||||
# targeted) are complete before the boot highstate renders them. Otherwise a node
|
||||
# that is up but not yet fully reported gets dropped from those pillars and torn
|
||||
# out of the configs they build (e.g. so-elasticsearch ExtraHosts -> container recreate).
|
||||
|
||||
MAX_WAIT=${MINE_UPDATE_MAX_WAIT:-180} # hard backstop only
|
||||
INTERVAL=10
|
||||
STABLE_CHECKS=3 # up-count must hold steady this many polls
|
||||
elapsed=0
|
||||
prev=-1
|
||||
stable=0
|
||||
up=0
|
||||
|
||||
# Wait for the *reachable* minion set to settle rather than for every accepted
|
||||
# key to report up: an operator may accept a minion's key and then intentionally
|
||||
# power off that host, so requiring up >= accepted would never be satisfied and
|
||||
# we'd always burn the full MAX_WAIT. Once the responsive count stops growing we
|
||||
# stop waiting and run mine.update against whoever is up.
|
||||
while [ "$elapsed" -lt "$MAX_WAIT" ]; do
|
||||
up=$(/usr/bin/salt-run manage.up --out=json 2>/dev/null \
|
||||
| python3 -c 'import sys,json; print(len(json.load(sys.stdin)))' 2>/dev/null)
|
||||
up=${up:-0}
|
||||
if [ "$up" -gt 0 ] && [ "$up" -eq "$prev" ]; then
|
||||
stable=$((stable + 1))
|
||||
[ "$stable" -ge "$STABLE_CHECKS" ] && break
|
||||
else
|
||||
stable=0
|
||||
fi
|
||||
prev=$up
|
||||
sleep "$INTERVAL"
|
||||
elapsed=$((elapsed + INTERVAL))
|
||||
done
|
||||
|
||||
echo "so-boot-mine-update: ${up} minions up (settled after ${elapsed}s); running mine.update"
|
||||
/usr/bin/salt '*' mine.update --out=txt
|
||||
|
||||
# A node that is up but has not yet re-reported network.ip_addrs to the mine is
|
||||
# silently dropped from mine-backed pillars (elasticsearch:nodes, node_data, ...)
|
||||
# when highstate recompiles them -- which e.g. removes it from so-elasticsearch
|
||||
# ExtraHosts and forces a container recreate. After the broad mine.update above,
|
||||
# wait until every up minion actually has network.ip_addrs in the mine, re-pushing
|
||||
# mine.update to stragglers, before releasing the boot highstate. Bounded by the
|
||||
# same MAX_WAIT backstop so a slow/down node never blocks boot indefinitely.
|
||||
missing=""
|
||||
while [ "$elapsed" -lt "$MAX_WAIT" ]; do
|
||||
up_json=$(/usr/bin/salt-run manage.up --out=json 2>/dev/null)
|
||||
mine_json=$(/usr/bin/salt-run mine.get '*' network.ip_addrs tgt_type=glob --out=json 2>/dev/null)
|
||||
missing=$(printf '%s' "$up_json" | python3 -c '
|
||||
import sys, json
|
||||
up = set(json.load(sys.stdin) or [])
|
||||
mine = {k for k, v in (json.loads(sys.argv[1]) or {}).items() if v}
|
||||
print("\n".join(sorted(up - mine)))
|
||||
' "$mine_json" 2>/dev/null)
|
||||
if [ -z "$missing" ]; then
|
||||
echo "so-boot-mine-update: mine complete for all up minions after ${elapsed}s"
|
||||
break
|
||||
fi
|
||||
echo "so-boot-mine-update: mine missing up minion(s): $(echo $missing); re-running mine.update"
|
||||
for m in $missing; do /usr/bin/salt "$m" mine.update --out=txt; done
|
||||
sleep "$INTERVAL"
|
||||
elapsed=$((elapsed + INTERVAL))
|
||||
done
|
||||
[ -n "$missing" ] && echo "so-boot-mine-update: WARNING ${MAX_WAIT}s backstop hit; up minion(s) still absent from mine: $(echo $missing); highstate may drop them from configs"
|
||||
|
||||
# The pillar/compound-targeted node pillars (elasticsearch:nodes, redis:nodes,
|
||||
# logstash:nodes, hypervisor:nodes) resolve their target against the master's
|
||||
# per-minion data cache (grains+pillar in .../minions/<id>/data.p), populated only
|
||||
# when a minion's pillar is (re)compiled -- separately from the mine. A freshly
|
||||
# booted node can be in the mine (glob/node_data sees it) yet absent from that
|
||||
# cache, so it is dropped from those pillars and from the configs they build (e.g.
|
||||
# so-elasticsearch ExtraHosts). Force a synchronous pillar refresh so the master
|
||||
# caches every up node's pillar; refresh_pillar wait=True returns only once the
|
||||
# pillar is recompiled (and thus cached for matching). Retry stragglers <= MAX_WAIT.
|
||||
echo "so-boot-mine-update: warming master pillar cache for pillar/grain-targeted node pillars"
|
||||
/usr/bin/salt '*' saltutil.refresh_pillar wait=True --out=txt
|
||||
missing=""
|
||||
while [ "$elapsed" -lt "$MAX_WAIT" ]; do
|
||||
up_json=$(/usr/bin/salt-run manage.up --out=json 2>/dev/null)
|
||||
cached_json=$(/usr/bin/salt-run cache.pillar tgt='*' --out=json 2>/dev/null)
|
||||
missing=$(printf '%s' "$up_json" | python3 -c '
|
||||
import sys, json
|
||||
up = set(json.load(sys.stdin) or [])
|
||||
cached = {k for k, v in (json.loads(sys.argv[1]) or {}).items() if v}
|
||||
print("\n".join(sorted(up - cached)))
|
||||
' "$cached_json" 2>/dev/null)
|
||||
if [ -z "$missing" ]; then
|
||||
echo "so-boot-mine-update: pillar cache warm for all up minions after ${elapsed}s"
|
||||
break
|
||||
fi
|
||||
echo "so-boot-mine-update: pillar not yet cached for: $(echo $missing); refreshing"
|
||||
for m in $missing; do /usr/bin/salt "$m" saltutil.refresh_pillar wait=True --out=txt; done
|
||||
sleep "$INTERVAL"
|
||||
elapsed=$((elapsed + INTERVAL))
|
||||
done
|
||||
[ -n "$missing" ] && echo "so-boot-mine-update: WARNING ${MAX_WAIT}s backstop hit; pillar not cached for: $(echo $missing); pillar-targeted pillars may drop them"
|
||||
|
||||
# Log what the mine-backed pillars render so the boot-time state is inspectable.
|
||||
/usr/bin/salt-call saltutil.refresh_pillar >/dev/null 2>&1
|
||||
sleep 2
|
||||
for key in node_data elasticsearch:nodes; do
|
||||
rendered=$(/usr/bin/salt-call --out=json pillar.get "$key" 2>/dev/null \
|
||||
| python3 -c 'import sys,json; print(json.dumps(json.load(sys.stdin).get("local"), indent=2, sort_keys=True))' 2>/dev/null)
|
||||
echo "so-boot-mine-update: ${key} rendered as:"
|
||||
echo "${rendered:-null}"
|
||||
done
|
||||
exit 0
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
include:
|
||||
- salt.minion
|
||||
- salt.master.boot_mine_update
|
||||
{% if 'vrt' in salt['pillar.get']('features', []) %}
|
||||
- salt.cloud
|
||||
- salt.cloud.reactor_config_hypervisor
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
# Copyright Security Onion Solutions LLC and/or licensed to Security Onion Solutions LLC under one
|
||||
# or more contributor license agreements. Licensed under the Elastic License 2.0 as shown at
|
||||
# https://securityonion.net/license; you may not use this file except in compliance with the
|
||||
# Elastic License 2.0.
|
||||
|
||||
# Manages /etc/systemd/system/so-boot-mine-update.service, a manager-only
|
||||
# Type=oneshot unit that pushes `salt '*' mine.update` once per boot, ordered
|
||||
# before so-boot-highstate.service so mine-backed pillars (node IPs, ES/Redis/
|
||||
# Logstash discovery) are fresh before the boot highstate renders them.
|
||||
|
||||
include:
|
||||
- systemd.reload
|
||||
|
||||
so_boot_mine_update_unit_file:
|
||||
file.managed:
|
||||
- name: /etc/systemd/system/so-boot-mine-update.service
|
||||
- source: salt://salt/service/so-boot-mine-update.service
|
||||
- onchanges_in:
|
||||
- module: systemd_reload
|
||||
|
||||
# Only enable once setup is complete. Until then the gate file is missing and
|
||||
# the unit's own ConditionPathExists would no-op it anyway.
|
||||
so_boot_mine_update_service:
|
||||
service.enabled:
|
||||
- name: so-boot-mine-update.service
|
||||
- onlyif: test -e /opt/so/state/setup-complete
|
||||
- require:
|
||||
- file: so_boot_mine_update_unit_file
|
||||
- module: systemd_reload
|
||||
@@ -1,31 +0,0 @@
|
||||
# Copyright Security Onion Solutions LLC and/or licensed to Security Onion Solutions LLC under one
|
||||
# or more contributor license agreements. Licensed under the Elastic License 2.0 as shown at
|
||||
# https://securityonion.net/license; you may not use this file except in compliance with the
|
||||
# Elastic License 2.0.
|
||||
|
||||
# Manages /etc/systemd/system/so-boot-highstate.service, a Type=oneshot
|
||||
# RemainAfterExit=yes unit that runs `salt-call state.highstate` exactly once
|
||||
# per system boot. Replaces the legacy `startup_states: highstate` minion
|
||||
# config, which fired on every salt-minion service restart (causing a redundant
|
||||
# highstate whenever a highstate itself restarted salt-minion).
|
||||
|
||||
include:
|
||||
- systemd.reload
|
||||
|
||||
so_boot_highstate_unit_file:
|
||||
file.managed:
|
||||
- name: /etc/systemd/system/so-boot-highstate.service
|
||||
- source: salt://salt/service/so-boot-highstate.service
|
||||
- onchanges_in:
|
||||
- module: systemd_reload
|
||||
|
||||
# Only enable once setup is complete. Until then the gate file is missing and
|
||||
# the unit's own ConditionPathExists would no-op it anyway -- this just keeps
|
||||
# `systemctl is-enabled` honest for the sync_es_users gate.
|
||||
so_boot_highstate_service:
|
||||
service.enabled:
|
||||
- name: so-boot-highstate.service
|
||||
- onlyif: test -e /opt/so/state/setup-complete
|
||||
- require:
|
||||
- file: so_boot_highstate_unit_file
|
||||
- module: systemd_reload
|
||||
@@ -17,7 +17,6 @@ include:
|
||||
- repo.client
|
||||
- salt.mine_functions
|
||||
- salt.minion.service_file
|
||||
- salt.minion.boot_highstate
|
||||
{% if GLOBALS.is_manager %}
|
||||
- ca.signing_policy
|
||||
{% endif %}
|
||||
@@ -81,33 +80,11 @@ set_log_levels:
|
||||
- "log_level: info"
|
||||
- "log_level_logfile: info"
|
||||
|
||||
# startup_states: highstate caused a full highstate to run on every
|
||||
# salt-minion service start, including the restart triggered when a highstate
|
||||
# itself modified the minion config (beacons, mine, unit file). Replaced by
|
||||
# so-boot-highstate.service (managed in salt.minion.boot_highstate), which
|
||||
# runs once per system boot only. Strip the line from /etc/salt/minion on
|
||||
# upgrade; both the commented and uncommented forms historically existed.
|
||||
remove_startup_states:
|
||||
file.line:
|
||||
enable_startup_states:
|
||||
file.uncomment:
|
||||
- name: /etc/salt/minion
|
||||
- match: 'startup_states: highstate'
|
||||
- mode: delete
|
||||
|
||||
# Upgrade-path bridge: systems that already passed setup under the old gate
|
||||
# (`grep -x 'startup_states: highstate' /etc/salt/minion`) get a /opt/so/state/setup-complete
|
||||
# marker so so-boot-highstate.service can be enabled and the so-user_sync cron
|
||||
# in sync_es_users.sls keeps installing. Setup-in-progress systems instead get
|
||||
# the marker from `mark_setup_complete` in setup/so-functions at the right
|
||||
# moment. `replace: false` means we never overwrite a marker once written.
|
||||
mark_setup_complete_for_upgrades:
|
||||
file.managed:
|
||||
- name: /opt/so/state/setup-complete
|
||||
- replace: false
|
||||
- makedirs: True
|
||||
- onlyif: "grep -qx 'startup_states: highstate' /etc/salt/minion"
|
||||
- require_in:
|
||||
- file: remove_startup_states
|
||||
- service: so_boot_highstate_service
|
||||
- regex: '^startup_states: highstate$'
|
||||
- unless: pgrep so-setup
|
||||
|
||||
{% endif %}
|
||||
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
[Unit]
|
||||
Description=Security Onion boot-time highstate (runs once per boot)
|
||||
After=salt-minion.service network-online.target docker.service
|
||||
Wants=network-online.target docker.service
|
||||
Requires=salt-minion.service
|
||||
ConditionPathExists=/opt/so/state/setup-complete
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
ExecStart=/usr/bin/salt-call state.highstate -l info queue=True
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -1,15 +0,0 @@
|
||||
[Unit]
|
||||
Description=Security Onion boot-time grid mine.update (managers, runs once per boot before highstate)
|
||||
After=salt-master.service salt-minion.service network-online.target
|
||||
Wants=network-online.target
|
||||
Requires=salt-master.service salt-minion.service
|
||||
Before=so-boot-highstate.service
|
||||
ConditionPathExists=/opt/so/state/setup-complete
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
ExecStart=/usr/sbin/so-boot-mine-update
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -8,6 +8,11 @@ set_role_grain:
|
||||
- name: role
|
||||
- value: so-{{ grains.id.split("_") | last }}
|
||||
|
||||
set_highstate:
|
||||
file.append:
|
||||
- name: /etc/salt/minion
|
||||
- text: 'startup_states: highstate'
|
||||
|
||||
enable_salt_minion:
|
||||
service.enabled:
|
||||
- name: salt-minion
|
||||
|
||||
+6
-11
@@ -539,19 +539,16 @@ configure_minion() {
|
||||
" x509_v2: true"\
|
||||
"log_level: info"\
|
||||
"log_level_logfile: info"\
|
||||
"log_file: /opt/so/log/salt/minion" >> "$minion_config"
|
||||
"log_file: /opt/so/log/salt/minion"\
|
||||
"#startup_states: highstate" >> "$minion_config"
|
||||
|
||||
}
|
||||
|
||||
mark_setup_complete() {
|
||||
# Writes the setup-complete marker. Salt's so-boot-highstate.service
|
||||
# (boot-time oneshot) and the so-user_sync cron gate in
|
||||
# salt/manager/sync_es_users.sls both key off this file.
|
||||
local marker=/opt/so/state/setup-complete
|
||||
checkin_at_boot() {
|
||||
local minion_config=/etc/salt/minion
|
||||
|
||||
info "Marking setup as complete"
|
||||
mkdir -p "$(dirname "$marker")"
|
||||
touch "$marker"
|
||||
info "Enabling checkin at boot"
|
||||
sed -i 's/#startup_states: highstate/startup_states: highstate/' "$minion_config"
|
||||
}
|
||||
|
||||
check_requirements() {
|
||||
@@ -980,8 +977,6 @@ docker_seed_registry() {
|
||||
docker_seed_update_percent=25
|
||||
|
||||
update_docker_containers 'netinstall' '' 'docker_seed_update' '/dev/stdout' 2>&1 | tee -a "$setup_log"
|
||||
# Use pipe exit status of 'update_docker_containers' for return code
|
||||
return ${PIPESTATUS[0]}
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
+2
-5
@@ -767,10 +767,7 @@ if ! [[ -f $install_opt_file ]]; then
|
||||
title "Applying the registry state"
|
||||
logCmd "salt-call state.apply -l info registry"
|
||||
title "Seeding the docker registry"
|
||||
if ! docker_seed_registry; then
|
||||
error "Failed to seed the docker registry"
|
||||
fail_setup
|
||||
fi
|
||||
docker_seed_registry
|
||||
title "Applying the manager state"
|
||||
logCmd "salt-call state.apply -l info manager"
|
||||
logCmd "salt-call state.apply influxdb -l info"
|
||||
@@ -795,7 +792,7 @@ if ! [[ -f $install_opt_file ]]; then
|
||||
error "Failed to run so-elastic-fleet-setup"
|
||||
fail_setup
|
||||
fi
|
||||
mark_setup_complete
|
||||
checkin_at_boot
|
||||
set_initial_firewall_access
|
||||
initialize_elasticsearch_indices "so-case so-casehistory so-assistant-session so-assistant-chat"
|
||||
# run a final highstate before enabling scheduled highstates.
|
||||
|
||||
Reference in New Issue
Block a user