prevent path.repo from being put in elasticsearch.yml if the symlink doesnt exist

This commit is contained in:
m0duspwnens
2022-01-25 12:57:05 -05:00
parent e62de2934c
commit 4423e93880
2 changed files with 13 additions and 5 deletions

View File

@@ -33,4 +33,15 @@
{% endif %}
{% endif %}
{# merge with the elasticsearch pillar #}
{% set ESCONFIG = salt['pillar.get']('elasticsearch:config', default=ESCONFIG.elasticsearch.config, merge=True) %}
{# remove elasticsearch.config.path.repo values if a symlink /nsm/elasticsearch/repo{{ repo }} doesn't exist #}
{% if salt['pillar.get']('elasticsearch:config:path:repo', False) %}
{% for repo in pillar.elasticsearch.config.path.repo %}
{# retcode is 1 if symlink doesn't exist #}
{% if salt['cmd.retcode']('test -L /nsm/elasticsearch/repo'~repo) %}
{% do ESCONFIG.path.repo.remove(repo) %}
{% endif %}
{% endfor %}
{% endif %}

View File

@@ -325,12 +325,9 @@ so-elasticsearch:
- /opt/so/conf/elasticsearch/users_roles:/usr/share/elasticsearch/config/users_roles:ro
- /opt/so/conf/elasticsearch/users:/usr/share/elasticsearch/config/users:ro
{% endif %}
{% if ES_PATH_REPO %}
{% for repo in ES_PATH_REPO %}
# /nsm/elasticsearch/repo{{ repo }} must exist as a symlink for the bind to be created
{% if salt['cmd.retcode']('test ! -L /nsm/elasticsearch/repo'~repo) %}
{% if ESCONFIG.path.repo %}
{% for repo in ESCONFIG.path.repo %}
- /nsm/elasticsearch/repo{{ repo }}:{{ repo }}:rw
{% endif %}
{% endfor %}
{% endif %}
- watch: