enabled/disable elastic-fleet-package-registry via ui

This commit is contained in:
m0duspwnens
2023-05-15 11:14:21 -04:00
parent 1a1bcb3526
commit ba2392997b
9 changed files with 153 additions and 47 deletions

View File

@@ -0,0 +1,29 @@
# 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 Group
elasticsagentprgroup:
group.present:
- name: elastic-agent-pr
- gid: 948
# Add user
elastic-agent-pr:
user.present:
- uid: 948
- gid: 948
- home: /opt/so/conf/elastic-fleet-pr
- createhome: False
{% else %}
{{sls}}_state_not_allowed:
test.fail_without_changes:
- name: {{sls}}_state_not_allowed
{% endif %}

View File

@@ -0,0 +1,2 @@
elastic-fleet-package-registry:
enabled: False

View 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:
- elastic-fleet-package-registry.sostatus
so-elastic-fleet-package-registry:
docker_container.absent:
- force: True
so-elastic-fleet-package-registry_so-status.disabled:
file.comment:
- name: /opt/so/conf/so-status/so-status.conf
- regex: ^so-elastic-fleet-package-registry$
{% else %}
{{sls}}_state_not_allowed:
test.fail_without_changes:
- name: {{sls}}_state_not_allowed
{% endif %}

View File

@@ -0,0 +1,43 @@
# 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 %}
include:
- elastic-fleet-package-registry.config
- elastic-fleet-package-registry.sostatus
so-elastic-fleet-package-registry:
docker_container.running:
- image: {{ GLOBALS.registry_host }}:5000/{{ GLOBALS.image_repo }}/so-elastic-fleet-package-registry:{{ GLOBALS.so_version }}
- name: so-elastic-fleet-package-registry
- hostname: Fleet-package-reg-{{ GLOBALS.hostname }}
- detach: True
- user: 948
- networks:
- sobridge:
- ipv4_address: {{ DOCKER.containers['so-elastic-fleet-package-registry'].ip }}
- extra_hosts:
- {{ GLOBALS.hostname }}:{{ GLOBALS.node_ip }}
- port_bindings:
{% for BINDING in DOCKER.containers['so-elastic-fleet-package-registry'].port_bindings %}
- {{ BINDING }}
{% endfor %}
delete_so-elastic-fleet-package-registry_so-status.disabled:
file.uncomment:
- name: /opt/so/conf/so-status/so-status.conf
- regex: ^so-elastic-fleet-package-registry$
{% else %}
{{sls}}_state_not_allowed:
test.fail_without_changes:
- name: {{sls}}_state_not_allowed
{% endif %}

View File

@@ -1,52 +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 %}
# Add Group {% from 'elastic-fleet-package-registry/map.jinja' import ELASTICFLEETPACKAGEREGISTRYMERGED %}
elasticsagentprgroup:
group.present:
- name: elastic-agent-pr
- gid: 948
# Add user
elastic-agent-pr:
user.present:
- uid: 948
- gid: 948
- home: /opt/so/conf/elastic-fleet-pr
- createhome: False
so-elastic-fleet-package-registry:
docker_container.running:
- image: {{ GLOBALS.registry_host }}:5000/{{ GLOBALS.image_repo }}/so-elastic-fleet-package-registry:{{ GLOBALS.so_version }}
- name: so-elastic-fleet-package-registry
- hostname: Fleet-package-reg-{{ GLOBALS.hostname }}
- detach: True
- user: 948
- networks:
- sobridge:
- ipv4_address: {{ DOCKER.containers['so-elastic-fleet-package-registry'].ip }}
- extra_hosts:
- {{ GLOBALS.hostname }}:{{ GLOBALS.node_ip }}
- port_bindings:
{% for BINDING in DOCKER.containers['so-elastic-fleet-package-registry'].port_bindings %}
- {{ BINDING }}
{% endfor %}
append_so-elastic-fleet-package-registry_so-status.conf:
file.append:
- name: /opt/so/conf/so-status/so-status.conf
- text: so-elastic-fleet-package-registry
include:
{% if ELASTICFLEETPACKAGEREGISTRYMERGED.enabled %}
- elastic-fleet-package-registry.enabled
{% else %} {% else %}
- elastic-fleet-package-registry.disabled
{{sls}}_state_not_allowed:
test.fail_without_changes:
- name: {{sls}}_state_not_allowed
{% endif %} {% endif %}

View 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 'elastic-fleet-package-registry/defaults.yaml' as ELASTICFLEETPACKAGEREGISTRYDEFAULTS with context %}
{% set ELASTICFLEETPACKAGEREGISTRYMERGED = salt['pillar.get']('elastic-fleet-package-registry', ELASTICFLEETPACKAGEREGISTRYDEFAULTS.elastic-fleet-package-registry, merge=True) %}

View File

@@ -0,0 +1,4 @@
elastic-fleet-package-registry:
enabled:
description: You can enable or disable Elastic Fleet Package Registry.
advanced: True

View 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-package-registry_so-status.conf:
file.append:
- name: /opt/so/conf/so-status/so-status.conf
- text: so-elastic-fleet-package-registry
- unless: grep -q so-elastic-fleet-package-registry /opt/so/conf/so-status/so-status.conf
{% else %}
{{sls}}_state_not_allowed:
test.fail_without_changes:
- name: {{sls}}_state_not_allowed
{% endif %}

View File

@@ -353,6 +353,13 @@ function add_idstools_to_minion() {
" " >> $PILLARFILE " " >> $PILLARFILE
} }
function add_elastic-fleet-package-registry_to_minion() {
printf '%s\n'\
"elastic-fleet-package-registry:"\
" enabled: True"\
" " >> $PILLARFILE
}
function create_fleet_policy() { function create_fleet_policy() {
JSON_STRING=$( jq -n \ JSON_STRING=$( jq -n \
@@ -412,6 +419,7 @@ function createEVAL() {
add_mysql_to_minion add_mysql_to_minion
add_kratos_to_minion add_kratos_to_minion
add_idstools_to_minion add_idstools_to_minion
add_elastic-fleet-package-registry_to_minion
} }
function createSTANDALONE() { function createSTANDALONE() {
@@ -433,6 +441,7 @@ function createSTANDALONE() {
add_mysql_to_minion add_mysql_to_minion
add_kratos_to_minion add_kratos_to_minion
add_idstools_to_minion add_idstools_to_minion
add_elastic-fleet-package-registry_to_minion
} }
function createMANAGER() { function createMANAGER() {
@@ -452,6 +461,7 @@ function createMANAGER() {
add_mysql_to_minion add_mysql_to_minion
add_kratos_to_minion add_kratos_to_minion
add_idstools_to_minion add_idstools_to_minion
add_elastic-fleet-package-registry_to_minion
} }
function createMANAGERSEARCH() { function createMANAGERSEARCH() {
@@ -471,6 +481,7 @@ function createMANAGERSEARCH() {
add_mysql_to_minion add_mysql_to_minion
add_kratos_to_minion add_kratos_to_minion
add_idstools_to_minion add_idstools_to_minion
add_elastic-fleet-package-registry_to_minion
} }
function createIMPORT() { function createIMPORT() {
@@ -484,6 +495,7 @@ function createIMPORT() {
add_registry_to_minion add_registry_to_minion
add_kratos_to_minion add_kratos_to_minion
add_idstools_to_minion add_idstools_to_minion
add_elastic-fleet-package-registry_to_minion
} }
function createFLEET() { function createFLEET() {