From 01401f9d55f3feeb7c206a76eb0199919d3700f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B5=D1=85=D1=82=D1=8F=D1=80=D1=91=D0=B2=20=D0=95?= =?UTF-8?q?=D0=B2=D0=B3=D0=B5=D0=BD=D0=B8=D0=B9=20=D0=90=D1=80=D1=82=D1=83?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=D0=B8=D1=87?= Date: Wed, 25 May 2016 19:24:58 +0600 Subject: [PATCH 1/4] fix for ES plugins install --- handlers/main.yml | 2 +- tasks/elasticsearch-Debian.yml | 4 ++-- tasks/elasticsearch-RedHat.yml | 4 ++-- tasks/elasticsearch-plugins.yml | 7 ++++--- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/handlers/main.yml b/handlers/main.yml index 2432ffe..50a3a7e 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,4 +1,4 @@ - name: restart elasticsearch service: name={{instance_init_script | basename}} state=restarted enabled=yes - when: es_restart_on_change and es_start_service and not elasticsearch_started.changed and ((plugin_installed is defined and plugin_installed.changed) or elasticsearch_install.changed) + when: es_restart_on_change and es_start_service and not elasticsearch_started.changed and ((plugin_installed is defined and plugin_installed.changed) or (elasticsearch_install_from_repo.changed or elasticsearch_install_from_package.changed)) diff --git a/tasks/elasticsearch-Debian.yml b/tasks/elasticsearch-Debian.yml index 15e697f..6e71bec 100644 --- a/tasks/elasticsearch-Debian.yml +++ b/tasks/elasticsearch-Debian.yml @@ -10,7 +10,7 @@ - name: Debian - Ensure elasticsearch is installed apt: name=elasticsearch{% if es_version is defined and es_version != "" %}={{ es_version }}{% endif %} state=present cache_valid_time=86400 when: es_use_repository - register: elasticsearch_install + register: elasticsearch_install_from_repo - name: Debian - Download elasticsearch from url get_url: url={% if es_custom_package_url is defined %}{{ es_custom_package_url }}{% else %}{{ es_package_url }}-{{ es_version }}.deb{% endif %} dest=/tmp/elasticsearch-{{ es_version }}.deb validate_certs=no @@ -19,4 +19,4 @@ - name: Debian - Ensure elasticsearch is installed from downloaded package apt: deb=/tmp/elasticsearch-{{ es_version }}.deb when: not es_use_repository - register: elasticsearch_install \ No newline at end of file + register: elasticsearch_install_from_package \ No newline at end of file diff --git a/tasks/elasticsearch-RedHat.yml b/tasks/elasticsearch-RedHat.yml index d01163d..eab5f09 100644 --- a/tasks/elasticsearch-RedHat.yml +++ b/tasks/elasticsearch-RedHat.yml @@ -14,9 +14,9 @@ - name: RedHat - Install Elasticsearch yum: name=elasticsearch{% if es_version is defined and es_version != "" %}-{{ es_version }}{% endif %} state=present update_cache=yes when: es_use_repository - register: elasticsearch_install + register: elasticsearch_install_from_repo - name: RedHat - Install Elasticsearch from url yum: name={% if es_custom_package_url is defined %}{{ es_custom_package_url }}{% else %}{{ es_package_url }}-{{ es_version }}.noarch.rpm{% endif %} state=present when: not es_use_repository - register: elasticsearch_install \ No newline at end of file + register: elasticsearch_install_from_package \ No newline at end of file diff --git a/tasks/elasticsearch-plugins.yml b/tasks/elasticsearch-plugins.yml index a3e4e1b..0a53e03 100644 --- a/tasks/elasticsearch-plugins.yml +++ b/tasks/elasticsearch-plugins.yml @@ -1,8 +1,9 @@ --- -#es_plugins_reinstall will be set to true if elasticsearch_install.changed i.e. we have changed ES version, or if no plugins listed. Otherwise it is false and requires explicitly setting. +# es_plugins_reinstall will be set to true if elasticsearch_install_from_repo.changed or elasticsearch_install_from_package.changed +# i.e. we have changed ES version(or we have clean installation of ES), or if no plugins listed. Otherwise it is false and requires explicitly setting. - set_fact: es_plugins_reinstall=true - when: elasticsearch_install.changed or es_plugins is not defined or es_plugins is none + when: (elasticsearch_install_from_repo.changed or elasticsearch_install_from_package.changed) or es_plugins is not defined or es_plugins is none - set_fact: list_command="list" - set_fact: list_command="--list" @@ -35,7 +36,7 @@ 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 + when: es_plugins is defined and not es_plugins is none and es_plugins_reinstall notify: restart elasticsearch environment: CONF_DIR: "{{ conf_dir }}" From ef1f19ab09d8645ce14c9a7e55d363614ac69237 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B5=D1=85=D1=82=D1=8F=D1=80=D1=91=D0=B2=20=D0=95?= =?UTF-8?q?=D0=B2=D0=B3=D0=B5=D0=BD=D0=B8=D0=B9=20=D0=90=D1=80=D1=82=D1=83?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=D0=B8=D1=87?= Date: Thu, 26 May 2016 07:37:33 +0600 Subject: [PATCH 2/4] added new lines in tasks/elasticsearch-Debian.yml and tasks/elasticsearch-RedHat.yml --- tasks/elasticsearch-Debian.yml | 2 +- tasks/elasticsearch-RedHat.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/elasticsearch-Debian.yml b/tasks/elasticsearch-Debian.yml index 6e71bec..4311abb 100644 --- a/tasks/elasticsearch-Debian.yml +++ b/tasks/elasticsearch-Debian.yml @@ -19,4 +19,4 @@ - name: Debian - Ensure elasticsearch is installed from downloaded package apt: deb=/tmp/elasticsearch-{{ es_version }}.deb when: not es_use_repository - register: elasticsearch_install_from_package \ No newline at end of file + register: elasticsearch_install_from_package diff --git a/tasks/elasticsearch-RedHat.yml b/tasks/elasticsearch-RedHat.yml index eab5f09..0de8e71 100644 --- a/tasks/elasticsearch-RedHat.yml +++ b/tasks/elasticsearch-RedHat.yml @@ -19,4 +19,4 @@ - name: RedHat - Install Elasticsearch from url yum: name={% if es_custom_package_url is defined %}{{ es_custom_package_url }}{% else %}{{ es_package_url }}-{{ es_version }}.noarch.rpm{% endif %} state=present when: not es_use_repository - register: elasticsearch_install_from_package \ No newline at end of file + register: elasticsearch_install_from_package From 38b9f70586d4df2296f8fa7efa0cf60b137585c7 Mon Sep 17 00:00:00 2001 From: Dale McDiarmid Date: Wed, 20 Jul 2016 13:05:18 +0100 Subject: [PATCH 3/4] No changes --- handlers/main.yml | 2 +- tasks/elasticsearch-plugins.yml | 2 +- tasks/main.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/handlers/main.yml b/handlers/main.yml index 2432ffe..50a3a7e 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,4 +1,4 @@ - name: restart elasticsearch service: name={{instance_init_script | basename}} state=restarted enabled=yes - when: es_restart_on_change and es_start_service and not elasticsearch_started.changed and ((plugin_installed is defined and plugin_installed.changed) or elasticsearch_install.changed) + when: es_restart_on_change and es_start_service and not elasticsearch_started.changed and ((plugin_installed is defined and plugin_installed.changed) or (elasticsearch_install_from_repo.changed or elasticsearch_install_from_package.changed)) diff --git a/tasks/elasticsearch-plugins.yml b/tasks/elasticsearch-plugins.yml index 94d7353..dbba1c2 100644 --- a/tasks/elasticsearch-plugins.yml +++ b/tasks/elasticsearch-plugins.yml @@ -49,4 +49,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 + file: state=directory path={{ plugin_dir }} owner={{ es_user }} group={{ es_group }} recurse=yes \ No newline at end of file diff --git a/tasks/main.yml b/tasks/main.yml index ca1dfce..3a45816 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -35,4 +35,4 @@ when: es_templates tags: - templates -- meta: flush_handlers +- meta: flush_handlers \ No newline at end of file From 8f0f3f70fa7e6fc88a1517454b57b55921465517 Mon Sep 17 00:00:00 2001 From: Dale McDiarmid Date: Wed, 20 Jul 2016 13:18:41 +0100 Subject: [PATCH 4/4] remove .orig --- tasks/elasticsearch-plugins.yml.orig | 57 ---------------------------- 1 file changed, 57 deletions(-) delete mode 100644 tasks/elasticsearch-plugins.yml.orig diff --git a/tasks/elasticsearch-plugins.yml.orig b/tasks/elasticsearch-plugins.yml.orig deleted file mode 100644 index 10888eb..0000000 --- a/tasks/elasticsearch-plugins.yml.orig +++ /dev/null @@ -1,57 +0,0 @@ ---- - -# es_plugins_reinstall will be set to true if elasticsearch_install_from_repo.changed or elasticsearch_install_from_package.changed -# i.e. we have changed ES version(or we have clean installation of ES), or if no plugins listed. Otherwise it is false and requires explicitly setting. -- set_fact: es_plugins_reinstall=true -<<<<<<< HEAD - when: (elasticsearch_install is defined and elasticsearch_install.changed) or es_plugins is not defined or es_plugins is none - tags: - - always -======= - when: (elasticsearch_install_from_repo.changed or elasticsearch_install_from_package.changed) or es_plugins is not defined or es_plugins is none ->>>>>>> ef1f19ab09d8645ce14c9a7e55d363614ac69237 - -- set_fact: list_command="list" - tags: - - always -- set_fact: list_command="--list" - when: es_version | version_compare('2.0', '<') - tags: - - always - -#List currently installed plugins -- shell: "{{es_home}}/bin/plugin {{list_command}} | sed -n '1!p' | cut -d '-' -f2-" - register: installed_plugins - changed_when: False - environment: - CONF_DIR: "{{ conf_dir }}" - ES_INCLUDE: "{{ instance_default_file }}" - -#This needs to removes any currently installed plugins -- name: Remove elasticsearch plugins - command: "{{es_home}}/bin/plugin remove {{item}} --silent" - ignore_errors: yes - with_items: "{{ installed_plugins.stdout_lines }}" - 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: - CONF_DIR: "{{ conf_dir }}" - ES_INCLUDE: "{{ instance_default_file }}" - -- name: Install elasticsearch plugins - #debug: var=item - command: > - {{es_home}}/bin/plugin install {{ item.plugin }}{% if item.version is defined and item.version != '' %}/{{ item.version }}{% endif %} {% if item.proxy_host is defined and item.proxy_host != '' and item.proxy_port is defined and item.proxy_port != ''%} -DproxyHost={{ item.proxy_host }} -DproxyPort={{ item.proxy_port }} {% elif es_proxy_host is defined and es_proxy_host != '' %} -DproxyHost={{ es_proxy_host }} -DproxyPort={{ es_proxy_port }} {% endif %} --silent - 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 - notify: restart elasticsearch - environment: - CONF_DIR: "{{ conf_dir }}" - ES_INCLUDE: "{{ instance_default_file }}" - -#Set permissions on plugins directory -- name: Set Plugin Directory Permissions - file: state=directory path={{ plugin_dir }} owner={{ es_user }} group={{ es_group }} recurse=yes