From 4ef743614334cbd8c35f30f0a8f3449b57f64575 Mon Sep 17 00:00:00 2001 From: Dale McDiarmid Date: Wed, 25 Nov 2015 18:31:03 +0000 Subject: [PATCH] script fixes --- defaults/main.yml | 1 - {scripts => files/scripts}/calculate-score.groovy | 0 tasks/elasticsearch-scripts.yml | 5 +++-- tasks/elasticsearch-templates.yml | 1 + templates/elasticsearch.yml.j2 | 6 +----- test/integration/package.yml | 3 +-- test/integration/package/serverspec/default_spec.rb | 5 +++++ 7 files changed, 11 insertions(+), 10 deletions(-) rename {scripts => files/scripts}/calculate-score.groovy (100%) diff --git a/defaults/main.yml b/defaults/main.yml index 40b88e0..2906571 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -6,7 +6,6 @@ es_use_repository: true es_start_service: true es_plugins_reinstall: false es_scripts: false -es_scripts_src: scripts es_templates: false es_user: elasticsearch es_group: elasticsearch diff --git a/scripts/calculate-score.groovy b/files/scripts/calculate-score.groovy similarity index 100% rename from scripts/calculate-score.groovy rename to files/scripts/calculate-score.groovy diff --git a/tasks/elasticsearch-scripts.yml b/tasks/elasticsearch-scripts.yml index 554bf8e..546ed19 100644 --- a/tasks/elasticsearch-scripts.yml +++ b/tasks/elasticsearch-scripts.yml @@ -1,12 +1,13 @@ --- -- set_fact: es_script_dir={{ es_conf_dir }}/{{es_instance_name}}/scripts +- set_fact: es_script_dir={{ es_conf_dir }}/{{es_instance_name}} - set_fact: es_script_dir={{es_config['path.scripts']}} when: es_config['path.scripts'] is defined - name: Create script dir file: state=directory path={{ es_script_dir }} owner={{ es_user }} group={{ es_group }} + when: es_config['path.scripts'] is defined - name: Copy scripts to elasticsearch - copy: src={{es_scripts_src}} dest={{ es_script_dir }} \ No newline at end of file + copy: src=scripts dest={{ es_script_dir }} owner={{ es_user }} group={{ es_group }} \ No newline at end of file diff --git a/tasks/elasticsearch-templates.yml b/tasks/elasticsearch-templates.yml index 73f016f..b6fa7c6 100644 --- a/tasks/elasticsearch-templates.yml +++ b/tasks/elasticsearch-templates.yml @@ -1,5 +1,6 @@ --- #TODO: How to handle in multi node +# 1. Template directory needs to be specifiable. 2. Port needs to based on configuration - name: Copy templates to elasticsearch copy: src=templates dest=/etc/elasticsearch/ diff --git a/templates/elasticsearch.yml.j2 b/templates/elasticsearch.yml.j2 index 29c970d..275c93c 100644 --- a/templates/elasticsearch.yml.j2 +++ b/templates/elasticsearch.yml.j2 @@ -17,8 +17,4 @@ path.data: {{ data_dir }} path.work: {{ work_dir }} -path.logs: {{ log_dir }} - -{% if es_scripts and es_config['path.scripts'] is not defined %} -path.scripts: {{ es_conf_dir }}/{{es_instance_name}}/scripts -{% endif %} \ No newline at end of file +path.logs: {{ log_dir }} \ No newline at end of file diff --git a/test/integration/package.yml b/test/integration/package.yml index 9adbfcc..9c7db94 100644 --- a/test/integration/package.yml +++ b/test/integration/package.yml @@ -4,5 +4,4 @@ roles: - { role: elasticsearch, es_config: { "discovery.zen.ping.multicast.enabled": true }, es_instance_name: "node1" } vars: - es_scripts: true - es_scripts_src: "./test/package/scripts/" \ No newline at end of file + es_scripts: true \ No newline at end of file diff --git a/test/integration/package/serverspec/default_spec.rb b/test/integration/package/serverspec/default_spec.rb index b01bc1c..5670024 100644 --- a/test/integration/package/serverspec/default_spec.rb +++ b/test/integration/package/serverspec/default_spec.rb @@ -23,6 +23,11 @@ context "basic tests" do it { should be_owned_by 'elasticsearch' } end + describe file('/etc/elasticsearch/node1/scripts/calculate-score.groovy') do + it { should be_file } + it { should be_owned_by 'elasticsearch' } + end + describe 'Node listening' do it 'listening in port 9200' do expect(port 9200).to be_listening