mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-08 18:22:47 +01:00
enabled/disable elaticfleet in ui
This commit is contained in:
60
salt/elasticfleet/config.sls
Normal file
60
salt/elasticfleet/config.sls
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
{% from 'allowed_states.map.jinja' import allowed_states %}
|
||||||
|
{% if sls.split('.')[0] in allowed_states %}
|
||||||
|
|
||||||
|
# Add EA Group
|
||||||
|
elasticsagentgroup:
|
||||||
|
group.present:
|
||||||
|
- name: elastic-agent
|
||||||
|
- gid: 947
|
||||||
|
|
||||||
|
# Add EA user
|
||||||
|
elastic-agent:
|
||||||
|
user.present:
|
||||||
|
- uid: 947
|
||||||
|
- gid: 947
|
||||||
|
- home: /opt/so/conf/elastic-fleet
|
||||||
|
- createhome: False
|
||||||
|
|
||||||
|
elasticfleet_sbin:
|
||||||
|
file.recurse:
|
||||||
|
- name: /usr/sbin
|
||||||
|
- source: salt://elasticfleet/tools/sbin
|
||||||
|
- user: 947
|
||||||
|
- group: 939
|
||||||
|
- file_mode: 755
|
||||||
|
|
||||||
|
elasticfleet_sbin_jinja:
|
||||||
|
file.recurse:
|
||||||
|
- name: /usr/sbin
|
||||||
|
- source: salt://elasticfleet/tools/sbin_jinja
|
||||||
|
- user: 947
|
||||||
|
- group: 939
|
||||||
|
- file_mode: 755
|
||||||
|
- template: jinja
|
||||||
|
|
||||||
|
eaconfdir:
|
||||||
|
file.directory:
|
||||||
|
- name: /opt/so/conf/elastic-fleet
|
||||||
|
- user: 947
|
||||||
|
- group: 939
|
||||||
|
- makedirs: True
|
||||||
|
|
||||||
|
eastatedir:
|
||||||
|
file.directory:
|
||||||
|
- name: /opt/so/conf/elastic-fleet/state
|
||||||
|
- user: 947
|
||||||
|
- group: 939
|
||||||
|
- makedirs: True
|
||||||
|
|
||||||
|
{% else %}
|
||||||
|
|
||||||
|
{{sls}}_state_not_allowed:
|
||||||
|
test.fail_without_changes:
|
||||||
|
- name: {{sls}}_state_not_allowed
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
8
salt/elasticfleet/defaults.yaml
Normal file
8
salt/elasticfleet/defaults.yaml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
elasticfleet:
|
||||||
|
enabled: False
|
||||||
|
config:
|
||||||
|
server:
|
||||||
|
endpoints_enrollment: ''
|
||||||
|
es_token: ''
|
||||||
|
grid_enrollment: ''
|
||||||
|
url: ''
|
||||||
27
salt/elasticfleet/disabled.sls
Normal file
27
salt/elasticfleet/disabled.sls
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
{% from 'allowed_states.map.jinja' import allowed_states %}
|
||||||
|
{% if sls.split('.')[0] in allowed_states %}
|
||||||
|
|
||||||
|
include:
|
||||||
|
- elasticfleet.sostatus
|
||||||
|
|
||||||
|
so-elastic-fleet:
|
||||||
|
docker_container.absent:
|
||||||
|
- force: True
|
||||||
|
|
||||||
|
so-elastic-fleet_so-status.disabled:
|
||||||
|
file.comment:
|
||||||
|
- name: /opt/so/conf/so-status/so-status.conf
|
||||||
|
- regex: ^so-elastic-fleet$
|
||||||
|
|
||||||
|
{% else %}
|
||||||
|
|
||||||
|
{{sls}}_state_not_allowed:
|
||||||
|
test.fail_without_changes:
|
||||||
|
- name: {{sls}}_state_not_allowed
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
62
salt/elasticfleet/enabled.sls
Normal file
62
salt/elasticfleet/enabled.sls
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
{% from 'allowed_states.map.jinja' import allowed_states %}
|
||||||
|
{% if sls.split('.')[0] in allowed_states %}
|
||||||
|
{% from 'vars/globals.map.jinja' import GLOBALS %}
|
||||||
|
{% from 'docker/docker.map.jinja' import DOCKER %}
|
||||||
|
{# This value is generated during node install and stored in minion pillar #}
|
||||||
|
{% set SERVICETOKEN = salt['pillar.get']('elasticfleet:config:server:es_token','') %}
|
||||||
|
|
||||||
|
include:
|
||||||
|
- elasticfleet.config
|
||||||
|
- elasticfleet.sostatus
|
||||||
|
|
||||||
|
{% if SERVICETOKEN != '' %}
|
||||||
|
so-elastic-fleet:
|
||||||
|
docker_container.running:
|
||||||
|
- image: {{ GLOBALS.registry_host }}:5000/{{ GLOBALS.image_repo }}/so-elastic-agent:{{ GLOBALS.so_version }}
|
||||||
|
- name: so-elastic-fleet
|
||||||
|
- hostname: FleetServer-{{ GLOBALS.hostname }}
|
||||||
|
- detach: True
|
||||||
|
- user: 947
|
||||||
|
- networks:
|
||||||
|
- sobridge:
|
||||||
|
- ipv4_address: {{ DOCKER.containers['so-elastic-fleet'].ip }}
|
||||||
|
- extra_hosts:
|
||||||
|
- {{ GLOBALS.manager }}:{{ GLOBALS.manager_ip }}
|
||||||
|
- {{ GLOBALS.hostname }}:{{ GLOBALS.node_ip }}
|
||||||
|
- port_bindings:
|
||||||
|
{% for BINDING in DOCKER.containers['so-elastic-fleet'].port_bindings %}
|
||||||
|
- {{ BINDING }}
|
||||||
|
{% endfor %}
|
||||||
|
- binds:
|
||||||
|
- /etc/pki:/etc/pki:ro
|
||||||
|
#- /opt/so/conf/elastic-fleet/state:/usr/share/elastic-agent/state:rw
|
||||||
|
- environment:
|
||||||
|
- FLEET_SERVER_ENABLE=true
|
||||||
|
- FLEET_URL=https://{{ GLOBALS.node_ip }}:8220
|
||||||
|
- FLEET_SERVER_ELASTICSEARCH_HOST=https://{{ GLOBALS.manager }}:9200
|
||||||
|
- FLEET_SERVER_SERVICE_TOKEN={{ SERVICETOKEN }}
|
||||||
|
- FLEET_SERVER_POLICY_ID=FleetServer_{{ GLOBALS.hostname }}
|
||||||
|
- FLEET_SERVER_ELASTICSEARCH_CA=/etc/pki/tls/certs/intca.crt
|
||||||
|
- FLEET_SERVER_CERT=/etc/pki/elasticfleet.crt
|
||||||
|
- FLEET_SERVER_CERT_KEY=/etc/pki/elasticfleet.key
|
||||||
|
- FLEET_CA=/etc/pki/tls/certs/intca.crt
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
delete_so-elastic-fleet_so-status.disabled:
|
||||||
|
file.uncomment:
|
||||||
|
- name: /opt/so/conf/so-status/so-status.conf
|
||||||
|
- regex: ^so-elastic-fleet$
|
||||||
|
|
||||||
|
|
||||||
|
{% else %}
|
||||||
|
|
||||||
|
{{sls}}_state_not_allowed:
|
||||||
|
test.fail_without_changes:
|
||||||
|
- name: {{sls}}_state_not_allowed
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
@@ -1,104 +1,13 @@
|
|||||||
# Copyright Security Onion Solutions LLC and/or licensed to Security Onion Solutions LLC under one
|
# 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; you may not use
|
# or more contributor license agreements. Licensed under the Elastic License 2.0 as shown at
|
||||||
# this file except in compliance with the Elastic License 2.0.
|
# https://securityonion.net/license; you may not use this file except in compliance with the
|
||||||
{% from 'allowed_states.map.jinja' import allowed_states %}
|
# Elastic License 2.0.
|
||||||
{% if sls in allowed_states %}
|
|
||||||
{% from 'vars/globals.map.jinja' import GLOBALS %}
|
|
||||||
{% from 'docker/docker.map.jinja' import DOCKER %}
|
|
||||||
|
|
||||||
# These values are generated during node install and stored in minion pillar
|
{% from 'elasticfleet/map.jinja' import ELASTICFLEETMERGED %}
|
||||||
{% set SERVICETOKEN = salt['pillar.get']('elasticfleet:server:es_token','') %}
|
|
||||||
#{% set FLEETSERVERPOLICY = salt['pillar.get']('elasticfleet:server:server_policy','so-manager') %}
|
|
||||||
#{% set FLEETURL = salt['pillar.get']('elasticfleet:server:url') %}
|
|
||||||
|
|
||||||
# Add EA Group
|
|
||||||
elasticsagentgroup:
|
|
||||||
group.present:
|
|
||||||
- name: elastic-agent
|
|
||||||
- gid: 947
|
|
||||||
|
|
||||||
# Add EA user
|
|
||||||
elastic-agent:
|
|
||||||
user.present:
|
|
||||||
- uid: 947
|
|
||||||
- gid: 947
|
|
||||||
- home: /opt/so/conf/elastic-fleet
|
|
||||||
- createhome: False
|
|
||||||
|
|
||||||
elasticfleet_sbin:
|
|
||||||
file.recurse:
|
|
||||||
- name: /usr/sbin
|
|
||||||
- source: salt://elasticfleet/tools/sbin
|
|
||||||
- user: 947
|
|
||||||
- group: 939
|
|
||||||
- file_mode: 755
|
|
||||||
|
|
||||||
elasticfleet_sbin_jinja:
|
|
||||||
file.recurse:
|
|
||||||
- name: /usr/sbin
|
|
||||||
- source: salt://elasticfleet/tools/sbin_jinja
|
|
||||||
- user: 947
|
|
||||||
- group: 939
|
|
||||||
- file_mode: 755
|
|
||||||
- template: jinja
|
|
||||||
|
|
||||||
eaconfdir:
|
|
||||||
file.directory:
|
|
||||||
- name: /opt/so/conf/elastic-fleet
|
|
||||||
- user: 947
|
|
||||||
- group: 939
|
|
||||||
- makedirs: True
|
|
||||||
|
|
||||||
eastatedir:
|
|
||||||
file.directory:
|
|
||||||
- name: /opt/so/conf/elastic-fleet/state
|
|
||||||
- user: 947
|
|
||||||
- group: 939
|
|
||||||
- makedirs: True
|
|
||||||
|
|
||||||
|
|
||||||
{% if SERVICETOKEN != '' %}
|
|
||||||
so-elastic-fleet:
|
|
||||||
docker_container.running:
|
|
||||||
- image: {{ GLOBALS.registry_host }}:5000/{{ GLOBALS.image_repo }}/so-elastic-agent:{{ GLOBALS.so_version }}
|
|
||||||
- name: so-elastic-fleet
|
|
||||||
- hostname: FleetServer-{{ GLOBALS.hostname }}
|
|
||||||
- detach: True
|
|
||||||
- user: 947
|
|
||||||
- networks:
|
|
||||||
- sobridge:
|
|
||||||
- ipv4_address: {{ DOCKER.containers['so-elastic-fleet'].ip }}
|
|
||||||
- extra_hosts:
|
|
||||||
- {{ GLOBALS.manager }}:{{ GLOBALS.manager_ip }}
|
|
||||||
- {{ GLOBALS.hostname }}:{{ GLOBALS.node_ip }}
|
|
||||||
- port_bindings:
|
|
||||||
{% for BINDING in DOCKER.containers['so-elastic-fleet'].port_bindings %}
|
|
||||||
- {{ BINDING }}
|
|
||||||
{% endfor %}
|
|
||||||
- binds:
|
|
||||||
- /etc/pki:/etc/pki:ro
|
|
||||||
#- /opt/so/conf/elastic-fleet/state:/usr/share/elastic-agent/state:rw
|
|
||||||
- environment:
|
|
||||||
- FLEET_SERVER_ENABLE=true
|
|
||||||
- FLEET_URL=https://{{ GLOBALS.node_ip }}:8220
|
|
||||||
- FLEET_SERVER_ELASTICSEARCH_HOST=https://{{ GLOBALS.manager }}:9200
|
|
||||||
- FLEET_SERVER_SERVICE_TOKEN={{ SERVICETOKEN }}
|
|
||||||
- FLEET_SERVER_POLICY_ID=FleetServer_{{ GLOBALS.hostname }}
|
|
||||||
- FLEET_SERVER_ELASTICSEARCH_CA=/etc/pki/tls/certs/intca.crt
|
|
||||||
- FLEET_SERVER_CERT=/etc/pki/elasticfleet.crt
|
|
||||||
- FLEET_SERVER_CERT_KEY=/etc/pki/elasticfleet.key
|
|
||||||
- FLEET_CA=/etc/pki/tls/certs/intca.crt
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
append_so-elastic-fleet_so-status.conf:
|
|
||||||
file.append:
|
|
||||||
- name: /opt/so/conf/so-status/so-status.conf
|
|
||||||
- text: so-elastic-fleet
|
|
||||||
|
|
||||||
|
include:
|
||||||
|
{% if ELASTICFLEETMERGED.enabled %}
|
||||||
|
- elasticfleet.enabled
|
||||||
{% else %}
|
{% else %}
|
||||||
|
- elasticfleet.disabled
|
||||||
{{sls}}_state_not_allowed:
|
|
||||||
test.fail_without_changes:
|
|
||||||
- name: {{sls}}_state_not_allowed
|
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
7
salt/elasticfleet/map.jinja
Normal file
7
salt/elasticfleet/map.jinja
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{# 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. #}
|
||||||
|
|
||||||
|
{% import_yaml 'elasticfleet/defaults.yaml' as ELASTICFLEETDEFAULTS %}
|
||||||
|
{% set ELASTICFLEETMERGED = salt['pillar.get']('elasticfleet', ELASTICFLEETDEFAULTS.elasticfleet, merge=True) %}
|
||||||
@@ -1,25 +1,29 @@
|
|||||||
elasticfleet:
|
elasticfleet:
|
||||||
server:
|
enabled:
|
||||||
endpoints_enrollment:
|
description: You can enable or disable Elastic Fleet.
|
||||||
description: Endpoint enrollment key.
|
helpLink: elastic-fleet.html
|
||||||
global: True
|
config:
|
||||||
helpLink: elastic-fleet.html
|
server:
|
||||||
sensitive: True
|
endpoints_enrollment:
|
||||||
advanced: True
|
description: Endpoint enrollment key.
|
||||||
es_token:
|
global: True
|
||||||
description: Elastic auth token.
|
helpLink: elastic-fleet.html
|
||||||
global: True
|
sensitive: True
|
||||||
helpLink: elastic-fleet.html
|
advanced: True
|
||||||
sensitive: True
|
es_token:
|
||||||
advanced: True
|
description: Elastic auth token.
|
||||||
grid_enrollment:
|
global: True
|
||||||
description: Grid enrollment key.
|
helpLink: elastic-fleet.html
|
||||||
global: True
|
sensitive: True
|
||||||
helpLink: elastic-fleet.html
|
advanced: True
|
||||||
sensitive: True
|
grid_enrollment:
|
||||||
advanced: True
|
description: Grid enrollment key.
|
||||||
url:
|
global: True
|
||||||
description: Agent connection URL.
|
helpLink: elastic-fleet.html
|
||||||
global: True
|
sensitive: True
|
||||||
helpLink: elastic-fleet.html
|
advanced: True
|
||||||
advanced: True
|
url:
|
||||||
|
description: Agent connection URL.
|
||||||
|
global: True
|
||||||
|
helpLink: elastic-fleet.html
|
||||||
|
advanced: True
|
||||||
|
|||||||
21
salt/elasticfleet/sostatus.sls
Normal file
21
salt/elasticfleet/sostatus.sls
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
{% from 'allowed_states.map.jinja' import allowed_states %}
|
||||||
|
{% if sls.split('.')[0] in allowed_states %}
|
||||||
|
|
||||||
|
append_so-elastic-fleet_so-status.conf:
|
||||||
|
file.append:
|
||||||
|
- name: /opt/so/conf/so-status/so-status.conf
|
||||||
|
- text: so-elastic-fleet
|
||||||
|
- unless: grep -q so-elastic-fleet /opt/so/conf/so-status/so-status.conf
|
||||||
|
|
||||||
|
{% else %}
|
||||||
|
|
||||||
|
{{sls}}_state_not_allowed:
|
||||||
|
test.fail_without_changes:
|
||||||
|
- name: {{sls}}_state_not_allowed
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
@@ -81,10 +81,11 @@ GRIDNODESENROLLMENTOKEN=$(curl -K /opt/so/conf/elasticsearch/curl.config -L "loc
|
|||||||
pillar_file=/opt/so/saltstack/local/pillar/minions/{{ GLOBALS.minion_id }}.sls
|
pillar_file=/opt/so/saltstack/local/pillar/minions/{{ GLOBALS.minion_id }}.sls
|
||||||
printf '%s\n'\
|
printf '%s\n'\
|
||||||
"elasticfleet:"\
|
"elasticfleet:"\
|
||||||
" server:"\
|
" config:"\
|
||||||
" es_token: '$ESTOKEN'"\
|
" server:"\
|
||||||
" endpoints_enrollment: '$ENDPOINTSENROLLMENTOKEN'"\
|
" es_token: '$ESTOKEN'"\
|
||||||
" grid_enrollment: '$GRIDNODESENROLLMENTOKEN'"\
|
" endpoints_enrollment: '$ENDPOINTSENROLLMENTOKEN'"\
|
||||||
|
" grid_enrollment: '$GRIDNODESENROLLMENTOKEN'"\
|
||||||
"" >> "$pillar_file"
|
"" >> "$pillar_file"
|
||||||
|
|
||||||
#Store Grid Nodes Enrollment token in Global pillar
|
#Store Grid Nodes Enrollment token in Global pillar
|
||||||
@@ -98,4 +99,4 @@ salt-call state.apply elasticfleet queue=True
|
|||||||
|
|
||||||
# Generate installers & install Elastic Agent on the node
|
# Generate installers & install Elastic Agent on the node
|
||||||
so-elastic-agent-gen-installers
|
so-elastic-agent-gen-installers
|
||||||
salt-call state.apply elasticfleet.install_agent_grid queue=True
|
salt-call state.apply elasticfleet.install_agent_grid queue=True
|
||||||
|
|||||||
@@ -143,8 +143,9 @@ function add_fleet_to_minion() {
|
|||||||
# Write out settings to minion file
|
# Write out settings to minion file
|
||||||
printf '%s\n'\
|
printf '%s\n'\
|
||||||
"elasticfleet:"\
|
"elasticfleet:"\
|
||||||
" server:"\
|
" config:"\
|
||||||
" es_token: '$ESTOKEN'"\
|
" server:"\
|
||||||
|
" es_token: '$ESTOKEN'"\
|
||||||
" " >> $PILLARFILE
|
" " >> $PILLARFILE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user