From f8e140708af743bbcb53911a2c9739980cea1fa2 Mon Sep 17 00:00:00 2001 From: Johan De Meersman Date: Wed, 17 Aug 2016 10:53:57 +0200 Subject: [PATCH 1/2] Add support for custom Debian repository; allow repository key to be set to false. --- defaults/main.yml | 2 ++ tasks/elasticsearch-Debian.yml | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 451000f..edc1556 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -3,6 +3,8 @@ es_major_version: "2.x" es_version: "2.2.0" es_version_lock: false es_use_repository: true +es_apt_key: "http://packages.elasticsearch.org/GPG-KEY-elasticsearch" +es_apt_url: "deb http://packages.elastic.co/elasticsearch/{{ es_major_version }}/debian stable main" es_start_service: true es_java_install: true update_java: false diff --git a/tasks/elasticsearch-Debian.yml b/tasks/elasticsearch-Debian.yml index dba5fa5..bde925a 100644 --- a/tasks/elasticsearch-Debian.yml +++ b/tasks/elasticsearch-Debian.yml @@ -6,11 +6,11 @@ when: es_allow_downgrades - name: Debian - Add Elasticsearch repository key - apt_key: url="http://packages.elasticsearch.org/GPG-KEY-elasticsearch" state=present - when: es_use_repository + apt_key: url="{{ es_apt_key }}" state=present + when: es_use_repository and es_apt_key - name: Debian - add elasticsearch repository - apt_repository: repo="deb http://packages.elastic.co/elasticsearch/{{ es_major_version }}/debian stable main" state=present + apt_repository: repo="{{ es_apt_url }}" state=present when: es_use_repository - name: Debian - Ensure elasticsearch is installed From 0d095aeea3f04ee940d5eb24afddd3525c932cc1 Mon Sep 17 00:00:00 2001 From: Johan De Meersman Date: Wed, 17 Aug 2016 16:09:50 +0200 Subject: [PATCH 2/2] Dodge deprecation warnings in plugin and template install by working as per http://docs.ansible.com/ansible/playbooks_conditionals.html#loops-and-conditionals --- tasks/elasticsearch-plugins.yml | 8 ++++---- tasks/elasticsearch-templates.yml | 5 ++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/tasks/elasticsearch-plugins.yml b/tasks/elasticsearch-plugins.yml index 7da2d8c..f3307b5 100644 --- a/tasks/elasticsearch-plugins.yml +++ b/tasks/elasticsearch-plugins.yml @@ -27,7 +27,7 @@ - name: Remove elasticsearch plugins command: "{{es_home}}/bin/plugin remove {{item}} --silent" ignore_errors: yes - with_items: "{{ installed_plugins.stdout_lines }}" + with_items: "{{ installed_plugins.stdout_lines | default([]) }}" when: es_plugins_reinstall and installed_plugins.stdout_lines | length > 0 and not 'No plugin detected' in installed_plugins.stdout_lines[0] notify: restart elasticsearch environment: @@ -41,8 +41,8 @@ register: plugin_installed failed_when: "'ERROR' in plugin_installed.stdout" changed_when: plugin_installed.rc == 0 - with_items: "{{ es_plugins }}" - when: es_plugins is defined and not es_plugins is none and es_plugins_reinstall + with_items: "{{ es_plugins | default([]) }}" + when: not es_plugins is none and es_plugins_reinstall notify: restart elasticsearch environment: CONF_DIR: "{{ conf_dir }}" @@ -50,4 +50,4 @@ #Set permissions on plugins directory - name: Set Plugin Directory Permissions - file: state=directory path={{ plugin_dir }} owner={{ es_user }} group={{ es_group }} recurse=yes \ No newline at end of file + file: state=directory path={{ plugin_dir }} owner={{ es_user }} group={{ es_group }} recurse=yes diff --git a/tasks/elasticsearch-templates.yml b/tasks/elasticsearch-templates.yml index c9de8bb..5f987b0 100644 --- a/tasks/elasticsearch-templates.yml +++ b/tasks/elasticsearch-templates.yml @@ -8,9 +8,8 @@ - name: Copy templates to elasticsearch copy: src={{ item }} dest=/etc/elasticsearch/templates owner={{ es_user }} group={{ es_group }} - when: es_templates_fileglob is defined with_fileglob: - - "{{ es_templates_fileglob }}" + - "{{ es_templates_fileglob | default('') }}" - set_fact: http_port=9200 tags: @@ -30,4 +29,4 @@ - name: Install template(s) command: "curl -sL -XPUT http://localhost:{{http_port}}/_template/{{item}} -d @/etc/elasticsearch/templates/{{item}}.json" - with_items: "{{ resultstemplate.stdout_lines }}" + with_items: "{{ resultstemplate.stdout_lines | default([]) }}"