From a72f12c4c70dab6e67b5e54fce6c36817fc14e5b Mon Sep 17 00:00:00 2001 From: m0duspwnens Date: Tue, 25 Jan 2022 10:50:00 -0500 Subject: [PATCH 1/9] add path.repo mount if symlink exists --- salt/elasticsearch/init.sls | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/salt/elasticsearch/init.sls b/salt/elasticsearch/init.sls index 83dfb63f1..d8916462a 100644 --- a/salt/elasticsearch/init.sls +++ b/salt/elasticsearch/init.sls @@ -24,7 +24,7 @@ include: {% set NODEIP = salt['pillar.get']('elasticsearch:mainip', '') -%} {% set TRUECLUSTER = salt['pillar.get']('elasticsearch:true_cluster', False) %} {% set MANAGERIP = salt['pillar.get']('global:managerip') %} -{% set ESMOUNT = salt['pillar.get']('elasticsearch:extramount', False) %} +{% set ES_PATH_REPO = salt['pillar.get']('elasticsearch:config:path:repo', False) %} {% if grains['role'] in ['so-eval','so-managersearch', 'so-manager', 'so-standalone', 'so-import'] %} {% set esclustername = salt['pillar.get']('manager:esclustername') %} @@ -235,6 +235,14 @@ eslogdir: - group: 939 - makedirs: True +es_repos_dir: + file.directory: + - name: /nsm/elasticsearch/repos/ + - user: 930 + - group: 939 + - require: + - file: nsmesdir + auth_users: file.managed: - name: /opt/so/conf/elasticsearch/users.tmp @@ -317,8 +325,13 @@ 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 ESMOUNT %} - - {{ ESMOUNT }}:/snapshots:rw + {% if ES_PATH_REPO %} + {% for repo in ES_PATH_REPO %} + # /nsm/elasticsearch/repos{{ repo }} must exist as a symlink for the bind to be created + {% if salt['cmd.retcode']("[[ ! test -L /nsm/elasticsearch/repos{{ repo }} ]]") %} + - /nsm/elasticsearch/repos{{ repo }}:{{ repo }}:rw + {% endif %} + {% endfor %} {% endif %} - watch: - file: cacertz From a92e2a917b2ee386d449f436a54ed44feb86e3ec Mon Sep 17 00:00:00 2001 From: m0duspwnens Date: Tue, 25 Jan 2022 10:53:28 -0500 Subject: [PATCH 2/9] change repos to repo --- salt/elasticsearch/init.sls | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/salt/elasticsearch/init.sls b/salt/elasticsearch/init.sls index d8916462a..9d624f4b7 100644 --- a/salt/elasticsearch/init.sls +++ b/salt/elasticsearch/init.sls @@ -235,9 +235,9 @@ eslogdir: - group: 939 - makedirs: True -es_repos_dir: +es_repo_dir: file.directory: - - name: /nsm/elasticsearch/repos/ + - name: /nsm/elasticsearch/repo/ - user: 930 - group: 939 - require: @@ -327,9 +327,9 @@ so-elasticsearch: {% endif %} {% if ES_PATH_REPO %} {% for repo in ES_PATH_REPO %} - # /nsm/elasticsearch/repos{{ repo }} must exist as a symlink for the bind to be created - {% if salt['cmd.retcode']("[[ ! test -L /nsm/elasticsearch/repos{{ repo }} ]]") %} - - /nsm/elasticsearch/repos{{ repo }}:{{ repo }}:rw + # /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 }} ]]") %} + - /nsm/elasticsearch/repo{{ repo }}:{{ repo }}:rw {% endif %} {% endfor %} {% endif %} From e62de2934c0eddddc97f61a59c3c1dc21024dc42 Mon Sep 17 00:00:00 2001 From: m0duspwnens Date: Tue, 25 Jan 2022 12:24:03 -0500 Subject: [PATCH 3/9] fix test for es repo --- salt/elasticsearch/init.sls | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/elasticsearch/init.sls b/salt/elasticsearch/init.sls index 9d624f4b7..b7d2b8b70 100644 --- a/salt/elasticsearch/init.sls +++ b/salt/elasticsearch/init.sls @@ -328,7 +328,7 @@ so-elasticsearch: {% 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 salt['cmd.retcode']('test ! -L /nsm/elasticsearch/repo'~repo) %} - /nsm/elasticsearch/repo{{ repo }}:{{ repo }}:rw {% endif %} {% endfor %} From 4423e93880bc8c1222c884164d82fe30c8073e16 Mon Sep 17 00:00:00 2001 From: m0duspwnens Date: Tue, 25 Jan 2022 12:57:05 -0500 Subject: [PATCH 4/9] prevent path.repo from being put in elasticsearch.yml if the symlink doesnt exist --- salt/elasticsearch/config.map.jinja | 11 +++++++++++ salt/elasticsearch/init.sls | 7 ++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/salt/elasticsearch/config.map.jinja b/salt/elasticsearch/config.map.jinja index c3f2b2067..c44e39e0d 100644 --- a/salt/elasticsearch/config.map.jinja +++ b/salt/elasticsearch/config.map.jinja @@ -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 %} diff --git a/salt/elasticsearch/init.sls b/salt/elasticsearch/init.sls index b7d2b8b70..62870bcc2 100644 --- a/salt/elasticsearch/init.sls +++ b/salt/elasticsearch/init.sls @@ -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: From a17e1aa87a2f692200259232ba017a4df1142256 Mon Sep 17 00:00:00 2001 From: m0duspwnens Date: Tue, 25 Jan 2022 13:00:04 -0500 Subject: [PATCH 5/9] 930 for group --- salt/elasticsearch/init.sls | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/elasticsearch/init.sls b/salt/elasticsearch/init.sls index 62870bcc2..353184625 100644 --- a/salt/elasticsearch/init.sls +++ b/salt/elasticsearch/init.sls @@ -239,7 +239,7 @@ es_repo_dir: file.directory: - name: /nsm/elasticsearch/repo/ - user: 930 - - group: 939 + - group: 930 - require: - file: nsmesdir From 00e17d5c789d4ca1c8101359a3166e81fe99a77c Mon Sep 17 00:00:00 2001 From: m0duspwnens Date: Tue, 25 Jan 2022 13:03:54 -0500 Subject: [PATCH 6/9] put repos in /repo in es container --- salt/elasticsearch/init.sls | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/elasticsearch/init.sls b/salt/elasticsearch/init.sls index 353184625..5ed9670a9 100644 --- a/salt/elasticsearch/init.sls +++ b/salt/elasticsearch/init.sls @@ -327,7 +327,7 @@ so-elasticsearch: {% endif %} {% if ESCONFIG.path.repo %} {% for repo in ESCONFIG.path.repo %} - - /nsm/elasticsearch/repo{{ repo }}:{{ repo }}:rw + - /nsm/elasticsearch/repo{{ repo }}:/repo/{{ repo }}:rw {% endfor %} {% endif %} - watch: From 7b6eeac03f40450f81e3ac009f2d5dc5898e2b23 Mon Sep 17 00:00:00 2001 From: m0duspwnens Date: Tue, 25 Jan 2022 13:08:46 -0500 Subject: [PATCH 7/9] dnt mount under /repo in the container --- salt/elasticsearch/init.sls | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/elasticsearch/init.sls b/salt/elasticsearch/init.sls index 5ed9670a9..353184625 100644 --- a/salt/elasticsearch/init.sls +++ b/salt/elasticsearch/init.sls @@ -327,7 +327,7 @@ so-elasticsearch: {% endif %} {% if ESCONFIG.path.repo %} {% for repo in ESCONFIG.path.repo %} - - /nsm/elasticsearch/repo{{ repo }}:/repo/{{ repo }}:rw + - /nsm/elasticsearch/repo{{ repo }}:{{ repo }}:rw {% endfor %} {% endif %} - watch: From 5d2b3992e29ad8c4b0b68d41c6c65be56a26dfc3 Mon Sep 17 00:00:00 2001 From: m0duspwnens Date: Tue, 25 Jan 2022 13:11:53 -0500 Subject: [PATCH 8/9] dont need to set ES_PATH_REPO --- salt/elasticsearch/init.sls | 1 - 1 file changed, 1 deletion(-) diff --git a/salt/elasticsearch/init.sls b/salt/elasticsearch/init.sls index 353184625..475aee223 100644 --- a/salt/elasticsearch/init.sls +++ b/salt/elasticsearch/init.sls @@ -24,7 +24,6 @@ include: {% set NODEIP = salt['pillar.get']('elasticsearch:mainip', '') -%} {% set TRUECLUSTER = salt['pillar.get']('elasticsearch:true_cluster', False) %} {% set MANAGERIP = salt['pillar.get']('global:managerip') %} -{% set ES_PATH_REPO = salt['pillar.get']('elasticsearch:config:path:repo', False) %} {% if grains['role'] in ['so-eval','so-managersearch', 'so-manager', 'so-standalone', 'so-import'] %} {% set esclustername = salt['pillar.get']('manager:esclustername') %} From dd00e3babcb57a95888d3dc63766b4ad2141a6e5 Mon Sep 17 00:00:00 2001 From: m0duspwnens Date: Tue, 25 Jan 2022 13:18:21 -0500 Subject: [PATCH 9/9] use .get since repo may not exist --- salt/elasticsearch/init.sls | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/elasticsearch/init.sls b/salt/elasticsearch/init.sls index 475aee223..8060757ed 100644 --- a/salt/elasticsearch/init.sls +++ b/salt/elasticsearch/init.sls @@ -324,7 +324,7 @@ 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 ESCONFIG.path.repo %} + {% if ESCONFIG.path.get('repo', False) %} {% for repo in ESCONFIG.path.repo %} - /nsm/elasticsearch/repo{{ repo }}:{{ repo }}:rw {% endfor %}