From a29ead8dc9586869578e68d79fb420fbdb2ce945 Mon Sep 17 00:00:00 2001 From: Jakob Reiter Date: Thu, 16 Jul 2015 16:42:39 +0200 Subject: [PATCH 01/29] Added functionality to install rpm from elastic url instead of the repo. --- tasks/elasticsearch-RedHat.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tasks/elasticsearch-RedHat.yml b/tasks/elasticsearch-RedHat.yml index 8869d9c64e05c..b4706d023d188 100644 --- a/tasks/elasticsearch-RedHat.yml +++ b/tasks/elasticsearch-RedHat.yml @@ -2,10 +2,19 @@ - name: Ensure libselinux-python on CentOS 6.x yum: name=libselinux-python state=present update_cache=yes when: ( ansible_distribution == "CentOS" ) and ( ansible_distribution_major_version == "6" ) + - name: RedHat - add Elasticsearch repo template: src=elasticsearch.repo dest=/etc/yum.repos.d/elasticsearch-{{ es_major_version }}.repo + when: es_use_repository + - 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 + +- name: RedHat - Install Elasticsearch from url + yum: name={{ __es_package_url.default }}-{{ es_version }}.noarch.rpm state=present + when: not es_use_repository register: elasticsearch_install - name: RedHat - configure memory From 2c720238817621ce96411f0aa4aba22210218e51 Mon Sep 17 00:00:00 2001 From: Jakob Reiter Date: Mon, 27 Jul 2015 21:49:09 +0200 Subject: [PATCH 02/29] Update apt cache before java install. Good idea to do this for first package and especialy needed for AWS/EC2 --- tasks/java-Debian.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/java-Debian.yml b/tasks/java-Debian.yml index 477690b78e5d4..199e98f148aa2 100644 --- a/tasks/java-Debian.yml +++ b/tasks/java-Debian.yml @@ -1,5 +1,5 @@ --- # Debian specific Java - name: Debian - Ensure Java is installed - apt: name={{ item }} state=present cache_valid_time=86400 + apt: name={{ item }} state=present update_cache=yes with_items: java_packages From 3dc934b7b4d7bce1ddaf86f5f1b0e1ac509bcc52 Mon Sep 17 00:00:00 2001 From: Jakob Reiter Date: Mon, 27 Jul 2015 21:54:25 +0200 Subject: [PATCH 03/29] Changed var name to es_package_url and removed unneeded url's --- vars/main.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/vars/main.yml b/vars/main.yml index d3cad844d44a5..f4531d44dcf2a 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,6 +1,2 @@ --- -__es_package_url: - default: "https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch" - url_master: "http://s3-eu-west-1.amazonaws.com/build-eu.elasticsearch.org/origin/master/nightly/JDK7/elasticsearch-latest-" - url_17: "http://s3-eu-west-1.amazonaws.com/build.eu-west-1.elastic.co/origin/1.7/nightly/JDK7/elasticsearch-latest-" - url_16: "http://s3-eu-west-1.amazonaws.com/build.eu-west-1.elastic.co/origin/1.6/nightly/JDK7/elasticsearch-latest-" +es_package_url: "https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch" From 4ddc73882ca0e9647d135893a076a2f48349c1af Mon Sep 17 00:00:00 2001 From: Jakob Reiter Date: Mon, 27 Jul 2015 21:56:19 +0200 Subject: [PATCH 04/29] Changed package url variable to es_package_url and added functionality to install from custom url via es_custom_package_url --- tasks/elasticsearch-Debian.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/elasticsearch-Debian.yml b/tasks/elasticsearch-Debian.yml index 66bae4b2f68d3..ea10dc8441a70 100644 --- a/tasks/elasticsearch-Debian.yml +++ b/tasks/elasticsearch-Debian.yml @@ -13,7 +13,7 @@ register: elasticsearch_install - name: Debian - Download elasticsearch from url - get_url: url={{ __es_package_url.default }}-{{ es_version }}.deb dest=/tmp/elasticsearch-{{ es_version }}.deb validate_certs=no + 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 when: not es_use_repository - name: Debian - Ensure elasticsearch is installed from downloaded package From d13bb2fe98ad5e74eb4e3304fd3623a62adefd9c Mon Sep 17 00:00:00 2001 From: Jakob Reiter Date: Tue, 28 Jul 2015 11:29:56 +0200 Subject: [PATCH 05/29] Changed variable name to es_pakage_url to reflect changes from 3dc934b --- tasks/elasticsearch-RedHat.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/elasticsearch-RedHat.yml b/tasks/elasticsearch-RedHat.yml index b4706d023d188..98f37a9374a87 100644 --- a/tasks/elasticsearch-RedHat.yml +++ b/tasks/elasticsearch-RedHat.yml @@ -13,7 +13,7 @@ register: elasticsearch_install - name: RedHat - Install Elasticsearch from url - yum: name={{ __es_package_url.default }}-{{ es_version }}.noarch.rpm state=present + yum: name={{ es_package_url }}-{{ es_version }}.noarch.rpm state=present when: not es_use_repository register: elasticsearch_install From 2e7a21f31d3e060a96363eb61800a1d0538df522 Mon Sep 17 00:00:00 2001 From: Jakob Reiter Date: Tue, 28 Jul 2015 17:04:22 +0200 Subject: [PATCH 06/29] Use es_custom_package_url in EL if provided. --- tasks/elasticsearch-RedHat.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/elasticsearch-RedHat.yml b/tasks/elasticsearch-RedHat.yml index 98f37a9374a87..3363634b46bda 100644 --- a/tasks/elasticsearch-RedHat.yml +++ b/tasks/elasticsearch-RedHat.yml @@ -13,7 +13,7 @@ register: elasticsearch_install - name: RedHat - Install Elasticsearch from url - yum: name={{ es_package_url }}-{{ es_version }}.noarch.rpm state=present + 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 441d3238cff41cdad95987453b5695be92939d02 Mon Sep 17 00:00:00 2001 From: Jakob Reiter Date: Fri, 31 Jul 2015 11:34:09 +0200 Subject: [PATCH 07/29] Removed java list functionality, Closes #22. Simplified whole java task. --- tasks/java-Debian.yml | 5 ----- tasks/java-RedHat.yml | 6 ------ tasks/java.yml | 19 ++++++------------- vars/Debian.yml | 3 --- vars/RedHat.yml | 3 --- vars/main.yml | 4 +++- 6 files changed, 9 insertions(+), 31 deletions(-) delete mode 100644 tasks/java-Debian.yml delete mode 100644 tasks/java-RedHat.yml delete mode 100644 vars/Debian.yml delete mode 100644 vars/RedHat.yml diff --git a/tasks/java-Debian.yml b/tasks/java-Debian.yml deleted file mode 100644 index 199e98f148aa2..0000000000000 --- a/tasks/java-Debian.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -# Debian specific Java -- name: Debian - Ensure Java is installed - apt: name={{ item }} state=present update_cache=yes - with_items: java_packages diff --git a/tasks/java-RedHat.yml b/tasks/java-RedHat.yml deleted file mode 100644 index 7bf07efbc0d74..0000000000000 --- a/tasks/java-RedHat.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -# RedHat specific Java -- name: RedHat - Ensure Java is installed - yum: name={{ item }} state=latest - with_items: java_packages - diff --git a/tasks/java.yml b/tasks/java.yml index 9c4dafb288d86..7b042b0eac7be 100644 --- a/tasks/java.yml +++ b/tasks/java.yml @@ -1,15 +1,8 @@ --- -- name: Java - Define java_packages - set_fact: - java_packages: "{{ __java_packages | list }}" - when: java_packages is not defined - -- name: Include Debian specific Java stuff - include: java-Debian.yml - when: ansible_os_family == 'Debian' - -- name: Include RedHat specific Java stuff - include: java-RedHat.yml +- name: RedHat - Ensure Java is installed + yum: name={{ java_rhel }} state=latest when: ansible_os_family == 'RedHat' - - + +- name: Debian - Ensure Java is installed + apt: name={{ java_debian }} state=present update_cache=yes + when: ansible_os_family == 'Debian' \ No newline at end of file diff --git a/vars/Debian.yml b/vars/Debian.yml deleted file mode 100644 index 4c1c67e1f2f3a..0000000000000 --- a/vars/Debian.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -__java_packages: - - "openjdk-7-jre-headless" diff --git a/vars/RedHat.yml b/vars/RedHat.yml deleted file mode 100644 index b4f6c25d066ff..0000000000000 --- a/vars/RedHat.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -__java_packages: - - "java-1.8.0-openjdk.x86_64" diff --git a/vars/main.yml b/vars/main.yml index f4531d44dcf2a..7a6e693465119 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,2 +1,4 @@ --- -es_package_url: "https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch" +java_debian: "openjdk-7-jre-headless" +java_rhel: "java-1.8.0-openjdk.x86_64" +es_package_url: "https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch" \ No newline at end of file From 138ad32c55ce5d19fbcee102af64ae187c9f51d5 Mon Sep 17 00:00:00 2001 From: Jakob Reiter Date: Fri, 31 Jul 2015 12:16:09 +0200 Subject: [PATCH 08/29] Failed to commit changes in tasks/main.yml in 441d323 --- tasks/main.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index d88900172660e..f376d38244132 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,6 +1,4 @@ --- -- name: Include OS-specific variables - include_vars: "{{ ansible_os_family }}.yml" - include: java.yml - include: elasticsearch.yml - include: elasticsearch-plugins.yml From d006a0ce290f6356483ec5a2c2e37917e9d7eba9 Mon Sep 17 00:00:00 2001 From: Jakob Reiter Date: Mon, 3 Aug 2015 15:14:29 +0200 Subject: [PATCH 09/29] Added new variable for adding elasticsearch scripts --- defaults/main.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 7aad86e64033a..219d618faffa2 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,9 +1,10 @@ --- -es_major_version: "1.5" -es_version: "1.5.1" +es_major_version: "1.7" +es_version: "1.7.0" es_version_lock: false -es_use_repository: false +es_use_repository: true es_start_service: true es_plugins_reinstall: false +es_scripts: false es_user: elasticsearch es_group: elasticsearch From 12a3b037fae6948a9bf428a76e0b6b454b9aac55 Mon Sep 17 00:00:00 2001 From: Jakob Reiter Date: Mon, 3 Aug 2015 15:25:03 +0200 Subject: [PATCH 10/29] Added include for elasticsearch scripts --- tasks/main.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tasks/main.yml b/tasks/main.yml index f376d38244132..f92778043e6c1 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -5,3 +5,6 @@ when: es_plugins is defined - include: elasticsearch-version-lock.yml when: es_version_lock +- include: elasticsearch-scripts.yml + when: es_scripts + From 7d9d7204d960c33040e3fcbce2d1b7b62a61a7e1 Mon Sep 17 00:00:00 2001 From: Jakob Reiter Date: Mon, 3 Aug 2015 15:26:02 +0200 Subject: [PATCH 11/29] Added funktionality to copy elasticsearch scripts from ansible host to elasticsearch server. Closes #5 --- tasks/elasticsearch-scripts.yml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 tasks/elasticsearch-scripts.yml diff --git a/tasks/elasticsearch-scripts.yml b/tasks/elasticsearch-scripts.yml new file mode 100644 index 0000000000000..82655ab276816 --- /dev/null +++ b/tasks/elasticsearch-scripts.yml @@ -0,0 +1,3 @@ +--- +- name: Copy scripts to elasticsearch + copy: src=scripts dest=/etc/elasticsearch/ From fa78cf746d164f81a5ea4d949948c60fe74c6698 Mon Sep 17 00:00:00 2001 From: Jakob Reiter Date: Mon, 3 Aug 2015 21:30:45 +0200 Subject: [PATCH 12/29] Added new fariables to Readme. Changed formating. --- README.md | 58 +++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 44 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 063700d4a7eaa..a82c8bf84028c 100644 --- a/README.md +++ b/README.md @@ -40,8 +40,8 @@ hosts: my_host vars: java_packages: - "oracle-java7-installer" - es_major_version: 1.4 - es_version: 1.4.4 + es_major_version: 1.7 + es_version: 1.7.0 es_start_service: false es_plugins_reinstall: false es_plugins: @@ -72,19 +72,49 @@ ansible-playbook -i hosts ./your-playbook.yml ## Configuration You can add the role without any customisation and it will by default install Java and Elasticsearch, without any plugins. -Following variables affect the versions installed: +#### Description of the variables available. -* ```es_major_version``` (e.g. "1.5" ) -* ```es_version``` (e.g. "1.5.2") -* ```es_start_service``` (true (default) or false) -* ```es_plugins_reinstall``` (true or false (default) ) -* ```es_plugins``` (an array of plugin definitons e.g.: +```es_major_version``` (e.g. `1.7` ) + +Which major version to use. This is also used to define which the repository is used. + +```es_version``` (e.g. `1.7.0`) + +Which minor version to use. + +```es_start_service``` (true (default) or false) + +Should elasticsearch be startet after installation? + +```es_use_repository``` (true (default) or false ) + +Should elasticsearch be installed from a repository or from a url download. If false package will be downloaded from https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch.... You can also specify `es_custom_package_url` with a url to a custom package. + +```es_version_lock``` (true or false (default)) + +This will lock the elasticsearch version using `yum versionlock` or `apt-mark hold`. + +```es_scripts``` (true or false (default)) + +If true you need to supply a files/scripts/ folder with your scripts, inside the role directory. The folder and all files will be copied to `/etc/elasticsearch/scripts`. You can also provide a scripts/ folder at toplevel of your playbook. + + +```es_plugins_reinstall``` (true or false (default) ) + +Schould plugins be reinstalled? + +```es_plugins``` (an array of plugin definitons e.g.:) ``` - es_plugins: - - plugin: elasticsearch-cloud-aws - version: 2.5.0 - ``` + es_plugins: + - plugin: elasticsearch-cloud-aws + version: 2.5.0 +``` + +```java_debian``` + +name of the java debian package to use (e.g. `openjdk-7-jre-headless`) + +```java_rhel``` -* ```java_repos``` (an array of repositories to be added to allow java to be installed) -* ```java_packages``` (an array of packages to be installed to get Java installed) +name of the java rhel package to use (e.g. `java-1.8.0-openjdk.x86_64`) From cf8806d6bdde0f6000916f262f502e1cb0e04be6 Mon Sep 17 00:00:00 2001 From: Jakob Reiter Date: Mon, 3 Aug 2015 21:37:39 +0200 Subject: [PATCH 13/29] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a82c8bf84028c..d0a9fca90d56c 100644 --- a/README.md +++ b/README.md @@ -111,10 +111,10 @@ Schould plugins be reinstalled? version: 2.5.0 ``` -```java_debian``` +`java_debian` name of the java debian package to use (e.g. `openjdk-7-jre-headless`) -```java_rhel``` +`java_rhel` name of the java rhel package to use (e.g. `java-1.8.0-openjdk.x86_64`) From 43bfab9fcdc3683b818f9a639d2bfed8fe0f1f05 Mon Sep 17 00:00:00 2001 From: Jakob Reiter Date: Tue, 4 Aug 2015 09:05:01 +0200 Subject: [PATCH 14/29] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d0a9fca90d56c..bd040ab4fab5a 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ Which minor version to use. ```es_start_service``` (true (default) or false) -Should elasticsearch be startet after installation? +Should elasticsearch be started after installation? ```es_use_repository``` (true (default) or false ) From efca9a0b5f85ce6d9232749481957920a0c26fdf Mon Sep 17 00:00:00 2001 From: Jakob Reiter Date: Tue, 4 Aug 2015 09:18:50 +0200 Subject: [PATCH 15/29] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bd040ab4fab5a..32f5c4f38e82c 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ hosts: my_host - elasticsearch vars: java_packages: - - "oracle-java7-installer" + - "openjdk-7-jre-headless" es_major_version: 1.7 es_version: 1.7.0 es_start_service: false From a476a3c72044b4e2259c2fd60a616c1ce8d162ea Mon Sep 17 00:00:00 2001 From: Jakob Reiter Date: Tue, 4 Aug 2015 09:40:43 +0200 Subject: [PATCH 16/29] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 32f5c4f38e82c..7f2b22092ee8a 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ hosts: my_host roles: - elasticsearch vars: - java_packages: + java_debian: - "openjdk-7-jre-headless" es_major_version: 1.7 es_version: 1.7.0 From 69964ab776432a86fb0067884a683d40b28dae39 Mon Sep 17 00:00:00 2001 From: Jakob Reiter Date: Mon, 3 Aug 2015 21:30:45 +0200 Subject: [PATCH 17/29] Added new variables to Readme. Changed formating. --- README.md | 58 +++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 44 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 063700d4a7eaa..a82c8bf84028c 100644 --- a/README.md +++ b/README.md @@ -40,8 +40,8 @@ hosts: my_host vars: java_packages: - "oracle-java7-installer" - es_major_version: 1.4 - es_version: 1.4.4 + es_major_version: 1.7 + es_version: 1.7.0 es_start_service: false es_plugins_reinstall: false es_plugins: @@ -72,19 +72,49 @@ ansible-playbook -i hosts ./your-playbook.yml ## Configuration You can add the role without any customisation and it will by default install Java and Elasticsearch, without any plugins. -Following variables affect the versions installed: +#### Description of the variables available. -* ```es_major_version``` (e.g. "1.5" ) -* ```es_version``` (e.g. "1.5.2") -* ```es_start_service``` (true (default) or false) -* ```es_plugins_reinstall``` (true or false (default) ) -* ```es_plugins``` (an array of plugin definitons e.g.: +```es_major_version``` (e.g. `1.7` ) + +Which major version to use. This is also used to define which the repository is used. + +```es_version``` (e.g. `1.7.0`) + +Which minor version to use. + +```es_start_service``` (true (default) or false) + +Should elasticsearch be startet after installation? + +```es_use_repository``` (true (default) or false ) + +Should elasticsearch be installed from a repository or from a url download. If false package will be downloaded from https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch.... You can also specify `es_custom_package_url` with a url to a custom package. + +```es_version_lock``` (true or false (default)) + +This will lock the elasticsearch version using `yum versionlock` or `apt-mark hold`. + +```es_scripts``` (true or false (default)) + +If true you need to supply a files/scripts/ folder with your scripts, inside the role directory. The folder and all files will be copied to `/etc/elasticsearch/scripts`. You can also provide a scripts/ folder at toplevel of your playbook. + + +```es_plugins_reinstall``` (true or false (default) ) + +Schould plugins be reinstalled? + +```es_plugins``` (an array of plugin definitons e.g.:) ``` - es_plugins: - - plugin: elasticsearch-cloud-aws - version: 2.5.0 - ``` + es_plugins: + - plugin: elasticsearch-cloud-aws + version: 2.5.0 +``` + +```java_debian``` + +name of the java debian package to use (e.g. `openjdk-7-jre-headless`) + +```java_rhel``` -* ```java_repos``` (an array of repositories to be added to allow java to be installed) -* ```java_packages``` (an array of packages to be installed to get Java installed) +name of the java rhel package to use (e.g. `java-1.8.0-openjdk.x86_64`) From bf31d9aa89c85ab8232c85c4ad64f75c6952457c Mon Sep 17 00:00:00 2001 From: Jakob Reiter Date: Mon, 7 Sep 2015 11:05:47 +0200 Subject: [PATCH 18/29] Added versionlock to elasticsearch-RedHat.yml as it has to be done before install --- tasks/elasticsearch-RedHat.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tasks/elasticsearch-RedHat.yml b/tasks/elasticsearch-RedHat.yml index 3363634b46bda..98db33456c05f 100644 --- a/tasks/elasticsearch-RedHat.yml +++ b/tasks/elasticsearch-RedHat.yml @@ -7,6 +7,10 @@ template: src=elasticsearch.repo dest=/etc/yum.repos.d/elasticsearch-{{ es_major_version }}.repo when: es_use_repository +- name: Include RHEL versionlock + include: elasticsearch-RedHat-version-lock.yml + when: es_version_lock + - 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 From 8e99d1bae1e63908e4c9869e9ee3432a6cde49af Mon Sep 17 00:00:00 2001 From: Jakob Reiter Date: Mon, 7 Sep 2015 11:08:52 +0200 Subject: [PATCH 19/29] Change versionlock command to first remove the lock and then add a new one based on the es_version variable --- tasks/elasticsearch-RedHat-version-lock.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/elasticsearch-RedHat-version-lock.yml b/tasks/elasticsearch-RedHat-version-lock.yml index 8a56872196835..e6fd8381ff207 100644 --- a/tasks/elasticsearch-RedHat-version-lock.yml +++ b/tasks/elasticsearch-RedHat-version-lock.yml @@ -2,5 +2,5 @@ - name: RedHat - install yum-version-lock yum: name=yum-plugin-versionlock state=present update_cache=yes - name: RedHat - lock elasticsearch version - command: yum versionlock add elasticsearch + shell: yum versionlock delete 0:elasticsearch* ; yum versionlock add elasticsearch{% if es_version is defined and es_version != "" %}-{{ es_version }}{% endif %} From 68a7a02dc3c7ce625e6730eaf21bf7eac3ec10d7 Mon Sep 17 00:00:00 2001 From: Jakob Reiter Date: Mon, 7 Sep 2015 11:18:42 +0200 Subject: [PATCH 20/29] Changed versionlock include name --- tasks/elasticsearch-RedHat.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/elasticsearch-RedHat.yml b/tasks/elasticsearch-RedHat.yml index 98db33456c05f..e256293a6a841 100644 --- a/tasks/elasticsearch-RedHat.yml +++ b/tasks/elasticsearch-RedHat.yml @@ -7,7 +7,7 @@ template: src=elasticsearch.repo dest=/etc/yum.repos.d/elasticsearch-{{ es_major_version }}.repo when: es_use_repository -- name: Include RHEL versionlock +- name: RedHat - include versionlock include: elasticsearch-RedHat-version-lock.yml when: es_version_lock From 8df08f58534a3df68f5647163b6dcb2ac1973ac8 Mon Sep 17 00:00:00 2001 From: Jakob Reiter Date: Mon, 14 Sep 2015 10:31:21 +0200 Subject: [PATCH 21/29] Added templates task. Moved version lock tasks into Distro specific tasks --- tasks/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index f92778043e6c1..b492c29b1de37 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -3,8 +3,8 @@ - include: elasticsearch.yml - include: elasticsearch-plugins.yml when: es_plugins is defined -- include: elasticsearch-version-lock.yml - when: es_version_lock - include: elasticsearch-scripts.yml when: es_scripts +- include: elasticsearch-templates.yml + when: es_templates From 519182512f84062b72afab0735d66baba55d61cf Mon Sep 17 00:00:00 2001 From: Jakob Reiter Date: Mon, 14 Sep 2015 10:32:20 +0200 Subject: [PATCH 22/29] Added task to install templates if es_templates is set --- tasks/elasticsearch-templates.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 tasks/elasticsearch-templates.yml diff --git a/tasks/elasticsearch-templates.yml b/tasks/elasticsearch-templates.yml new file mode 100644 index 0000000000000..46ffefc2f03e5 --- /dev/null +++ b/tasks/elasticsearch-templates.yml @@ -0,0 +1,11 @@ +--- +- name: Copy templates to elasticsearch + copy: src=templates dest=/etc/elasticsearch/ + +- 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' + with_items: resultstemplate.stdout_lines From 800bba2958484dc3d494573de4d90bddae15fe1a Mon Sep 17 00:00:00 2001 From: Jakob Reiter Date: Mon, 14 Sep 2015 12:02:17 +0200 Subject: [PATCH 23/29] Use last working kitchen-docker version --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index a6d769123c811..41cc680ab2bdf 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,5 @@ source 'https://rubygems.org' gem 'test-kitchen' -gem "kitchen-docker" +gem 'kitchen-docker', '< 2.2.0' gem 'kitchen-ansible' From eefcf56993066afc74e602641012fbd7f5bfb2b4 Mon Sep 17 00:00:00 2001 From: Jakob Reiter Date: Mon, 14 Sep 2015 12:11:36 +0200 Subject: [PATCH 24/29] Changed minor version to 1.7.1, added new variable es_templates --- defaults/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/defaults/main.yml b/defaults/main.yml index 219d618faffa2..6b00692a96269 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,10 +1,11 @@ --- es_major_version: "1.7" -es_version: "1.7.0" +es_version: "1.7.1" es_version_lock: false es_use_repository: true es_start_service: true es_plugins_reinstall: false es_scripts: false +es_templates: false es_user: elasticsearch es_group: elasticsearch From 74f094712b48c84ede9dea4e8158a97db7424f39 Mon Sep 17 00:00:00 2001 From: Jakob Reiter Date: Mon, 14 Sep 2015 12:15:30 +0200 Subject: [PATCH 25/29] Added task to wait for es to startup. Adding templates failed sometimes if startup wasn't completed --- tasks/elasticsearch-templates.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tasks/elasticsearch-templates.yml b/tasks/elasticsearch-templates.yml index 46ffefc2f03e5..26e345b0c701a 100644 --- a/tasks/elasticsearch-templates.yml +++ b/tasks/elasticsearch-templates.yml @@ -2,6 +2,9 @@ - name: Copy templates to elasticsearch copy: src=templates dest=/etc/elasticsearch/ +- name: Wait for elasticsearch to startup + wait_for: port=9200 delay=10 + - name: Get template files shell: find . -maxdepth 1 -type f | sed "s#\./##" | sed "s/.json//" chdir=/etc/elasticsearch/templates register: resultstemplate From 68b6d6d9d6bcc42137c7e9764fc3342cd23abc64 Mon Sep 17 00:00:00 2001 From: Jakob Reiter Date: Mon, 14 Sep 2015 12:17:16 +0200 Subject: [PATCH 26/29] Added instructions on how to add apt pinning using an external ansible role. Closes #11 --- README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/README.md b/README.md index 7f2b22092ee8a..40013b565cf3e 100644 --- a/README.md +++ b/README.md @@ -118,3 +118,29 @@ name of the java debian package to use (e.g. `openjdk-7-jre-headless`) `java_rhel` name of the java rhel package to use (e.g. `java-1.8.0-openjdk.x86_64`) + +## apt pinning +apt pinning is possible using an external role like https://github.com/debops/ansible-apt_preferences. + +To use this, add it as another role e.g. +``` +cd /my/repos/ +git clone git@github.com:debops/ansible-apt_preferences.git +cd /my/ansible/playbook +mkdir -p roles +ln -s /my/repos/ansible-apt_preferences ./roles/apt_preferences +``` + +then add something like this to your playook: +``` + roles: + - apt_preferences + - elasticsearch + vars: + ... + apt_preferences_list: + - package: elasticsearch + version: 1.7.0 + ... + +``` From d403c81d67ea05ffbef0ee3b4a138314af20976c Mon Sep 17 00:00:00 2001 From: Jakob Reiter Date: Mon, 14 Sep 2015 17:04:47 +0200 Subject: [PATCH 27/29] Removed apt-mark (Debian version lock) as it was not working as expected. Added a hint to the Readme to use (external) apt pinning --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 40013b565cf3e..99d5e9e217213 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,7 @@ Should elasticsearch be installed from a repository or from a url download. If f ```es_version_lock``` (true or false (default)) -This will lock the elasticsearch version using `yum versionlock` or `apt-mark hold`. +This will lock the elasticsearch version using `yum versionlock`. Only available on RHEL/CentOS. For Debian/Ubuntu see `apt pinning` below. ```es_scripts``` (true or false (default)) From e96441f931047abd6888b2f80a1707c731f8374a Mon Sep 17 00:00:00 2001 From: Jakob Reiter Date: Mon, 19 Oct 2015 14:26:56 +0200 Subject: [PATCH 28/29] Had problems merging from master. Using this version now. --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 41cc680ab2bdf..460bf04545ebf 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,5 @@ source 'https://rubygems.org' gem 'test-kitchen' -gem 'kitchen-docker', '< 2.2.0' +gem "kitchen-docker", '< 2.2.0' gem 'kitchen-ansible' From b52e8170f8fbd77f5d316804747d9afa5ff9ceae Mon Sep 17 00:00:00 2001 From: Jakob Reiter Date: Mon, 19 Oct 2015 14:42:27 +0200 Subject: [PATCH 29/29] reset to elastic/master to work around rebase conflict --- README.md | 88 ++++++++++--------------------------------------------- 1 file changed, 16 insertions(+), 72 deletions(-) diff --git a/README.md b/README.md index 99d5e9e217213..063700d4a7eaa 100644 --- a/README.md +++ b/README.md @@ -38,10 +38,10 @@ hosts: my_host roles: - elasticsearch vars: - java_debian: - - "openjdk-7-jre-headless" - es_major_version: 1.7 - es_version: 1.7.0 + java_packages: + - "oracle-java7-installer" + es_major_version: 1.4 + es_version: 1.4.4 es_start_service: false es_plugins_reinstall: false es_plugins: @@ -72,75 +72,19 @@ ansible-playbook -i hosts ./your-playbook.yml ## Configuration You can add the role without any customisation and it will by default install Java and Elasticsearch, without any plugins. -#### Description of the variables available. +Following variables affect the versions installed: -```es_major_version``` (e.g. `1.7` ) +* ```es_major_version``` (e.g. "1.5" ) +* ```es_version``` (e.g. "1.5.2") +* ```es_start_service``` (true (default) or false) +* ```es_plugins_reinstall``` (true or false (default) ) +* ```es_plugins``` (an array of plugin definitons e.g.: -Which major version to use. This is also used to define which the repository is used. - -```es_version``` (e.g. `1.7.0`) - -Which minor version to use. - -```es_start_service``` (true (default) or false) - -Should elasticsearch be started after installation? - -```es_use_repository``` (true (default) or false ) - -Should elasticsearch be installed from a repository or from a url download. If false package will be downloaded from https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch.... You can also specify `es_custom_package_url` with a url to a custom package. - -```es_version_lock``` (true or false (default)) - -This will lock the elasticsearch version using `yum versionlock`. Only available on RHEL/CentOS. For Debian/Ubuntu see `apt pinning` below. - -```es_scripts``` (true or false (default)) - -If true you need to supply a files/scripts/ folder with your scripts, inside the role directory. The folder and all files will be copied to `/etc/elasticsearch/scripts`. You can also provide a scripts/ folder at toplevel of your playbook. - - -```es_plugins_reinstall``` (true or false (default) ) - -Schould plugins be reinstalled? - -```es_plugins``` (an array of plugin definitons e.g.:) - -``` - es_plugins: - - plugin: elasticsearch-cloud-aws - version: 2.5.0 -``` - -`java_debian` - -name of the java debian package to use (e.g. `openjdk-7-jre-headless`) - -`java_rhel` - -name of the java rhel package to use (e.g. `java-1.8.0-openjdk.x86_64`) - -## apt pinning -apt pinning is possible using an external role like https://github.com/debops/ansible-apt_preferences. - -To use this, add it as another role e.g. ``` -cd /my/repos/ -git clone git@github.com:debops/ansible-apt_preferences.git -cd /my/ansible/playbook -mkdir -p roles -ln -s /my/repos/ansible-apt_preferences ./roles/apt_preferences -``` - -then add something like this to your playook: -``` - roles: - - apt_preferences - - elasticsearch - vars: - ... - apt_preferences_list: - - package: elasticsearch - version: 1.7.0 - ... + es_plugins: + - plugin: elasticsearch-cloud-aws + version: 2.5.0 + ``` -``` +* ```java_repos``` (an array of repositories to be added to allow java to be installed) +* ```java_packages``` (an array of packages to be installed to get Java installed)