From 23c8bdb7de11272cc7177b8b1260f72e29e7557c Mon Sep 17 00:00:00 2001 From: Dale McDiarmid Date: Wed, 25 Nov 2015 23:43:01 +0000 Subject: [PATCH] Fixes for scripts, Logging.yml moved --- defaults/main.yml | 2 +- files/templates/basic.json | 0 tasks/elasticsearch-config.yml | 10 ++++++---- tasks/elasticsearch-templates.yml | 11 ++++++++--- tasks/main.yml | 4 ++-- test/integration/standard/serverspec/default_spec.rb | 4 ++++ 6 files changed, 21 insertions(+), 10 deletions(-) create mode 100644 files/templates/basic.json diff --git a/defaults/main.yml b/defaults/main.yml index 2906571..96f0e88 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,6 +1,6 @@ --- es_major_version: "1.7" -es_version: "1.7.1" +es_version: "1.7.3" es_version_lock: false es_use_repository: true es_start_service: true diff --git a/files/templates/basic.json b/files/templates/basic.json new file mode 100644 index 0000000..e69de29 diff --git a/tasks/elasticsearch-config.yml b/tasks/elasticsearch-config.yml index 128c9ae..c8decc6 100644 --- a/tasks/elasticsearch-config.yml +++ b/tasks/elasticsearch-config.yml @@ -16,14 +16,11 @@ command: creates={{instance_default_file}} cp "{{default_file}}" "{{instance_default_file}}" when: instance_default_file != default_file -- debug: msg="DEBUG {{ hostvars[inventory_hostname] }}" - # Create an instance specific init file - name: Copy Init File for Instance command: creates={{instance_init_script}} cp "{{init_script}}" "{{instance_init_script}}" when: instance_init_script != init_script - #Create Config directory - name: Create Config Directory file: path={{ instance_config_directory }} state=directory owner={{ es_user }} group={{ es_group }} @@ -47,7 +44,6 @@ register: elasticsearch_configure #We only have to set these if they are specified. The start scripts will by default use the NAME set later on constructing directory names to avoid collisions. - - name: Configure max open files lineinfile: dest={{instance_default_file}} regexp="^MAX_OPEN_FILES" insertafter="^#MAX_OPEN_FILES" line="MAX_OPEN_FILES={{ es_max_open_files }}" when: es_max_open_files is defined @@ -115,3 +111,9 @@ register: elasticsearch_configure when: ansible_os_family == 'RedHat' +#Copy the logging.yml - TODO: i.e we may template this. +- name: Copy Logging.yml for Instance + command: creates={{instance_config_directory}}/logging.yml cp "{{ es_conf_dir }}/logging.yml" "{{instance_config_directory}}/logging.yml" + when: instance_init_script != init_script + +- file: path={{instance_config_directory}}/logging.yml state=touch 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 b6fa7c6..e524c0c 100644 --- a/tasks/elasticsearch-templates.yml +++ b/tasks/elasticsearch-templates.yml @@ -1,16 +1,21 @@ --- #TODO: How to handle in multi node -# 1. Template directory needs to be specifiable. 2. Port needs to based on configuration +# 1. Template directory needs to be specifiable - name: Copy templates to elasticsearch copy: src=templates dest=/etc/elasticsearch/ +- set_fact: http_port=9200 + +- set_fact: http_port={{es_config['http.port']}} + when: es_config['http.port'] is defined + - name: Wait for elasticsearch to startup - wait_for: port=9200 delay=10 + wait_for: port={{http_port}} delay=10 - name: Get template files shell: find . -maxdepth 1 -type f | sed "s#\./##" | sed "s/.json//" chdir=/etc/elasticsearch/templates register: resultstemplate - name: Install template(s) - command: 'curl -sL -XPUT http://localhost:9200/_template/{{item}} -d @/etc/elasticsearch/templates/{{item}}.json' + command: "curl -sL -XPUT http://localhost:{{http_port}}/_template/{{item}} -d @/etc/elasticsearch/templates/{{item}}.json" with_items: resultstemplate.stdout_lines diff --git a/tasks/main.yml b/tasks/main.yml index 2df9bd1..5791593 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -9,6 +9,6 @@ when: es_plugins is defined - include: elasticsearch-scripts.yml when: es_scripts -#- include: elasticsearch-templates.yml -# when: es_templates +- include: elasticsearch-templates.yml + when: es_templates diff --git a/test/integration/standard/serverspec/default_spec.rb b/test/integration/standard/serverspec/default_spec.rb index fa19d45..d378831 100644 --- a/test/integration/standard/serverspec/default_spec.rb +++ b/test/integration/standard/serverspec/default_spec.rb @@ -18,6 +18,10 @@ context "basic tests" do it { should be_file } end + describe file('/etc/elasticsearch/node1/logging.yml') do + it { should be_file } + end + describe file('/etc/elasticsearch/node1/elasticsearch.yml') do it { should contain 'node.name: localhost-node1' } it { should contain 'cluster.name: elasticsearch' }