Merge pull request #4334 from Security-Onion-Solutions/pipeline_userpass

Pipeline userpass
This commit is contained in:
Josh Patterson
2021-05-28 15:29:07 -04:00
committed by GitHub
5 changed files with 39 additions and 8 deletions

View File

@@ -3,6 +3,12 @@
{% set role = grains.id.split('_') | last %} {% set role = grains.id.split('_') | last %}
{% from 'elasticsearch/auth.map.jinja' import ELASTICAUTH with context %} {% from 'elasticsearch/auth.map.jinja' import ELASTICAUTH with context %}
{% set ES_INCLUDED_NODES = ['so-standalone'] %}
{% if grains.role in ES_INCLUDED_NODES %}
include:
- elasticsearch.auth
{% %}
# Remove variables.txt from /tmp - This is temp # Remove variables.txt from /tmp - This is temp
rmvariablesfile: rmvariablesfile:
@@ -179,7 +185,10 @@ utilsyncscripts:
- source: salt://common/tools/sbin - source: salt://common/tools/sbin
- defaults: - defaults:
ELASTICCURL: {{ ELASTICAUTH.elasticcurl }} ELASTICCURL: {{ ELASTICAUTH.elasticcurl }}
{% if grains.role in ES_INCLUDED_NODES %}
- require:
- file: elastic_auth_pillar
{% endif %}
{% if role in ['eval', 'standalone', 'sensor', 'heavynode'] %} {% if role in ['eval', 'standalone', 'sensor', 'heavynode'] %}
# Add sensor cleanup # Add sensor cleanup

View File

@@ -1,7 +1,7 @@
{% set ELASTICAUTH = salt['pillar.filter_by']({ {% set ELASTICAUTH = salt['pillar.filter_by']({
True: { True: {
'user': salt['pillar.get']('elasticsearch:auth:user'), 'user': salt['pillar.get']('elasticsearch:auth:users:so_elastic_user:user'),
'pass': salt['pillar.get']('elasticsearch:auth:pass'), 'pass': salt['pillar.get']('elasticsearch:auth:users:so_elastic_user:pass'),
'elasticcurl':'curl -K /opt/so/conf/elasticsearch/curl.config' }, 'elasticcurl':'curl -K /opt/so/conf/elasticsearch/curl.config' },
False: {'elasticcurl': 'curl'}, False: {'elasticcurl': 'curl'},
}, pillar='elasticsearch:auth:enabled', default=False) %} }, pillar='elasticsearch:auth:enabled', default=False) %}

View File

@@ -5,8 +5,27 @@ elastic_auth_pillar:
elasticsearch: elasticsearch:
auth: auth:
enabled: False enabled: False
user: so_elastic users:
pass: {{ salt['random.get_str'](20) }} so_elastic_user:
user: so_elastic
pass: {{ salt['random.get_str'](20) }}
so_kibana_user:
user: so_kibana
pass: {{ salt['random.get_str'](20) }}
so_logstash_user:
user: so_logstash
pass: {{ salt['random.get_str'](20) }}
so_beats_user:
user: so_beats
pass: {{ salt['random.get_str'](20) }}
so_monitor_user:
user: so_monitor
pass: {{ salt['random.get_str'](20) }}
# since we are generating a random password, and we don't want that to happen everytime # since we are generating a random password, and we don't want that to happen everytime
# a highstate runs, we only manage the file if it doesn't exist # a highstate runs, we only manage the file each user isn't present in the file. if the
- unless: ls /opt/so/saltstack/local/pillar/elasticsearch/auth.sls # pillar file doesn't exists, then the default vault provided to pillar.get should not
# be within the file either, so it should then be created
- unless:
{% for so_app_user in salt['pillar.get']('elasticsearch:auth:users', {'so_noapp_user': {'user': 'r@NDumu53Rd0NtDOoP'}}) %}
- grep {{ so_app_user.user }} /opt/so/saltstack/local/pillar/elasticsearch/auth.sls
{% endfor%}

View File

@@ -293,7 +293,7 @@ elastic_curl_config:
file.managed: file.managed:
- name: /opt/so/conf/elasticsearch/curl.config - name: /opt/so/conf/elasticsearch/curl.config
- mode: 600 - mode: 600
- contents: user = "{{ salt['pillar.get']('elasticsearch:auth:user') }}:{{ salt['pillar.get']('elasticsearch:auth:pass') }}" - contents: user = "{{ salt['pillar.get']('elasticsearch:auth:users:so_elastic_user:user') }}:{{ salt['pillar.get']('elasticsearch:auth:users:so_elastic_user:pass') }}"
- show_changes: False - show_changes: False
{% endif %} {# if grains['role'] != 'so-helix' #} {% endif %} {# if grains['role'] != 'so-helix' #}

View File

@@ -20,6 +20,9 @@
{% set MANAGER = salt['grains.get']('master') %} {% set MANAGER = salt['grains.get']('master') %}
{% set STRELKA_RULES = salt['pillar.get']('strelka:rules', '1') %} {% set STRELKA_RULES = salt['pillar.get']('strelka:rules', '1') %}
include:
- elasticsearch.auth
socore_own_saltstack: socore_own_saltstack:
file.directory: file.directory:
- name: /opt/so/saltstack - name: /opt/so/saltstack