Require password auth for redis access

This commit is contained in:
Mike Reeves
2023-01-04 11:02:40 -05:00
parent cd77e71d8d
commit 831300b540
6 changed files with 24 additions and 7 deletions

View File

@@ -120,6 +120,7 @@ base:
'*_heavynode': '*_heavynode':
- elasticsearch.auth - elasticsearch.auth
- soc_global - soc_global
- redis.soc_redis
- minions.{{ grains.id }} - minions.{{ grains.id }}
- minions.adv_{{ grains.id }} - minions.adv_{{ grains.id }}
@@ -136,6 +137,7 @@ base:
{% if salt['file.file_exists']('/opt/so/saltstack/local/pillar/elasticsearch/auth.sls') %} {% if salt['file.file_exists']('/opt/so/saltstack/local/pillar/elasticsearch/auth.sls') %}
- elasticsearch.auth - elasticsearch.auth
{% endif %} {% endif %}
- redis.soc_redis
- soc_global - soc_global
- adv_global - adv_global
- minions.{{ grains.id }} - minions.{{ grains.id }}
@@ -148,6 +150,8 @@ base:
{% if salt['file.file_exists']('/opt/so/saltstack/local/pillar/elasticsearch/auth.sls') %} {% if salt['file.file_exists']('/opt/so/saltstack/local/pillar/elasticsearch/auth.sls') %}
- elasticsearch.auth - elasticsearch.auth
{% endif %} {% endif %}
- redis.soc_redis
- redis.adv_redis
- soc_global - soc_global
- adv_global - adv_global
- minions.{{ grains.id }} - minions.{{ grains.id }}

View File

@@ -1,9 +1,10 @@
{% set THREADS = salt['pillar.get']('logstash_settings:ls_input_threads', '') -%} {%- set THREADS = salt['pillar.get']('logstash_settings:ls_input_threads', '') %}
{% set BATCH = salt['pillar.get']('logstash_settings:ls_pipeline_batch_size', 125) -%} {%- set BATCH = salt['pillar.get']('logstash_settings:ls_pipeline_batch_size', 125) %}
{% from 'logstash/map.jinja' import REDIS_NODES with context -%} {%- from 'logstash/map.jinja' import REDIS_NODES with context %}
{%- set REDIS_PASS = salt['pillar.get']('redis:config:requirepass') %}
{% for index in range(REDIS_NODES|length) -%} {%- for index in range(REDIS_NODES|length) %}
{% for host in REDIS_NODES[index] -%} {%- for host in REDIS_NODES[index] %}
input { input {
redis { redis {
host => '{{ host }}' host => '{{ host }}'
@@ -14,6 +15,7 @@ input {
type => 'redis-input' type => 'redis-input'
threads => {{ THREADS }} threads => {{ THREADS }}
batch_count => {{ BATCH }} batch_count => {{ BATCH }}
password => {{ REDIS_PASS }}
} }
} }
{% endfor %} {% endfor %}

View File

@@ -4,6 +4,8 @@
{%- set HOST = GLOBALS.manager %} {%- set HOST = GLOBALS.manager %}
{%- endif %} {%- endif %}
{%- set BATCH = salt['pillar.get']('logstash_settings:ls_pipeline_batch_size', 125) %} {%- set BATCH = salt['pillar.get']('logstash_settings:ls_pipeline_batch_size', 125) %}
{%- set REDIS_PASS = salt['pillar.get']('redis:config:requirepass') %}
output { output {
redis { redis {
host => '{{ HOST }}' host => '{{ HOST }}'
@@ -14,5 +16,6 @@ output {
congestion_threshold => 50000000 congestion_threshold => 50000000
batch => true batch => true
batch_events => {{ BATCH }} batch_events => {{ BATCH }}
password => {{ REDIS_PASS }}
} }
} }

View File

@@ -1,7 +1,7 @@
redis: redis:
config: config:
bind: '0.0.0.0' bind: '0.0.0.0'
protected-mode: 'no' protected-mode: 'yes'
tls-cert-file: '/certs/redis.crt' tls-cert-file: '/certs/redis.crt'
tls-key-file: '/certs/redis.key' tls-key-file: '/certs/redis.key'
tls-ca-cert-file: '/certs/ca.crt' tls-ca-cert-file: '/certs/ca.crt'

View File

@@ -10,6 +10,10 @@ redis:
global: True global: True
advanced: True advanced: True
helpLink: redis.html helpLink: redis.html
requirepass:
description: Password for accessing Redis.
global: True
sensitive: True
tls-cert-file: tls-cert-file:
description: TLS cert file location. description: TLS cert file location.
global: True global: True

View File

@@ -1209,6 +1209,7 @@ generate_passwords(){
GRAFANAPASS=$(get_random_value) GRAFANAPASS=$(get_random_value)
SENSORONIKEY=$(get_random_value) SENSORONIKEY=$(get_random_value)
KRATOSKEY=$(get_random_value) KRATOSKEY=$(get_random_value)
REDISPASS=$(get_random_value)
} }
generate_interface_vars() { generate_interface_vars() {
@@ -1496,7 +1497,10 @@ docker_pillar() {
redis_pillar() { redis_pillar() {
title "Create the redis pillar file" title "Create the redis pillar file"
touch $adv_redis_pillar_file touch $adv_redis_pillar_file
touch $redis_pillar_file printf '%s\n'\
"redis:"\
" config:"\
" requirepass: '$REDISPASS'" > $redis_pillar_file
} }
influxdb_pillar() { influxdb_pillar() {