From 717dd74a9f6c251a706c68ae6da908c3a649315c Mon Sep 17 00:00:00 2001 From: Artem Alexandrov Date: Fri, 25 Mar 2016 11:20:23 +0300 Subject: [PATCH 01/30] Removed bare variables Issue #86 --- tasks/elasticsearch-plugins.yml | 6 +++--- tasks/elasticsearch-templates.yml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tasks/elasticsearch-plugins.yml b/tasks/elasticsearch-plugins.yml index caa7316..e74874f 100644 --- a/tasks/elasticsearch-plugins.yml +++ b/tasks/elasticsearch-plugins.yml @@ -21,7 +21,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 }}" 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: @@ -42,7 +42,7 @@ register: plugin_installed failed_when: "'Failed to install' in plugin_installed.stderr" changed_when: plugin_installed.rc == 0 - with_items: es_plugins + with_items: "{{ es_plugins }}" when: es_plugins is defined and not es_plugins is none notify: restart elasticsearch environment: @@ -51,4 +51,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 0fe3a0f..42bad77 100644 --- a/tasks/elasticsearch-templates.yml +++ b/tasks/elasticsearch-templates.yml @@ -8,7 +8,7 @@ - name: Copy templates to elasticsearch copy: src={{ item }} dest=/etc/elasticsearch/ owner={{ es_user }} group={{ es_group }} - with_fileglob: es_templates_fileglob + with_fileglob: "{{ es_templates_fileglob }}" - set_fact: http_port=9200 @@ -24,4 +24,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 }}" From 62c16c69c96a8bb1dfb9a6329a1af37ee85da02a Mon Sep 17 00:00:00 2001 From: Artem Alexandrov Date: Thu, 31 Mar 2016 10:51:21 +0300 Subject: [PATCH 02/30] Fix for copying ES templates if es_templates_fileglob was specified --- tasks/elasticsearch-templates.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/elasticsearch-templates.yml b/tasks/elasticsearch-templates.yml index 42bad77..a4179a6 100644 --- a/tasks/elasticsearch-templates.yml +++ b/tasks/elasticsearch-templates.yml @@ -7,7 +7,7 @@ when: es_templates_fileglob is not defined - name: Copy templates to elasticsearch - copy: src={{ item }} dest=/etc/elasticsearch/ owner={{ es_user }} group={{ es_group }} + copy: src={{ item }} dest=/etc/elasticsearch/templates owner={{ es_user }} group={{ es_group }} with_fileglob: "{{ es_templates_fileglob }}" - set_fact: http_port=9200 From c7e449f63fdfbb25b6120640c2ef895cea44ebbe Mon Sep 17 00:00:00 2001 From: Artem Alexandrov Date: Thu, 31 Mar 2016 10:52:39 +0300 Subject: [PATCH 03/30] Added *.pyc files to .gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 0bb96d7..dca2467 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,9 @@ .kitchen/ *.lock +*.pyc .vendor .bundle Converging TODO .idea/ -elasticsearch.iml \ No newline at end of file +elasticsearch.iml From 8d438c19036c08415c2625321179071f7c9985f5 Mon Sep 17 00:00:00 2001 From: Dale McDiarmid Date: Sun, 3 Apr 2016 18:41:07 +0100 Subject: [PATCH 04/30] New images optimised for local network --- .kitchen.yml | 6 +++--- Gemfile | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.kitchen.yml b/.kitchen.yml index f0d6ad1..0728b01 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -15,7 +15,7 @@ provisioner: platforms: - name: ubuntu-14.04 driver_config: - image: dliappis/ubuntu:14.04 + image: dliappis/ubuntuhetzner:14.04 privileged: true provision_command: - apt-get update && apt-get install -y software-properties-common && add-apt-repository -y ppa:ansible/ansible @@ -45,7 +45,7 @@ platforms: run_command: "/sbin/init" - name: centos-6 driver_config: - image: dliappis/centos:6 + image: dliappis/centoshetzner:6 privileged: true provision_command: - yum remove -y ansible @@ -54,7 +54,7 @@ platforms: use_sudo: false - name: centos-7 driver_config: - image: dliappis/centos:7 + image: dliappis/centoshetzner:7 provision_command: - yum remove -y ansible - yum -y install gmp-devel python-devel python-pip diff --git a/Gemfile b/Gemfile index e0591b1..e58a757 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source 'https://rubygems.org' -gem 'test-kitchen', '1.4.2' +gem 'test-kitchen', '1.7.1' gem "kitchen-docker", '2.1.0' gem 'kitchen-ansible', '0.40.1' gem 'net-ssh', '~> 2.0' From cba5bf8f11275935b6e46030ad7010757440e6ab Mon Sep 17 00:00:00 2001 From: Dale McDiarmid Date: Sun, 3 Apr 2016 23:33:15 +0100 Subject: [PATCH 05/30] Gem Fix --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index e58a757..e0591b1 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source 'https://rubygems.org' -gem 'test-kitchen', '1.7.1' +gem 'test-kitchen', '1.4.2' gem "kitchen-docker", '2.1.0' gem 'kitchen-ansible', '0.40.1' gem 'net-ssh', '~> 2.0' From 151468703499711037995946bc489498c5b2f97f Mon Sep 17 00:00:00 2001 From: Dale McDiarmid Date: Mon, 4 Apr 2016 18:29:06 +0100 Subject: [PATCH 06/30] Cluster Name documentation was wrong - es_cluster_name is not supported. Use config map --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 98a24d0..fdafe1f 100644 --- a/README.md +++ b/README.md @@ -137,12 +137,11 @@ recommended in any multi node cluster configuration. ``` - hosts: master_nodes roles: - - { role: elasticsearch, es_instance_name: "node1", es_heap_size: "1g", es_config: { "discovery.zen.ping.multicast.enabled": false, discovery.zen.ping.unicast.hosts: "elastic02:9300", http.port: 9200, transport.tcp.port: 9300, node.data: false, node.master: true, bootstrap.mlockall: false, discovery.zen.ping.multicast.enabled: false } } + - { role: elasticsearch, es_instance_name: "node1", es_heap_size: "1g", es_config: {cluster.name: "test-cluster", "discovery.zen.ping.multicast.enabled": false, discovery.zen.ping.unicast.hosts: "elastic02:9300", http.port: 9200, transport.tcp.port: 9300, node.data: false, node.master: true, bootstrap.mlockall: false, discovery.zen.ping.multicast.enabled: false } } vars: es_scripts: false es_templates: false es_version_lock: false - es_cluster_name: test-cluster ansible_user: ansible es_plugins: - plugin: elasticsearch/license @@ -159,6 +158,7 @@ recommended in any multi node cluster configuration. node.data: true, node.master: false, bootstrap.mlockall: false, + cluster.name: "test-cluster", discovery.zen.ping.multicast.enabled: false } } - { role: elasticsearch, es_instance_name: "node2", @@ -170,13 +170,13 @@ recommended in any multi node cluster configuration. node.data: true, node.master: false, bootstrap.mlockall: false, + cluster.name: "test-cluster", discovery.zen.ping.multicast.enabled: false } } vars: es_scripts: false es_templates: false es_version_lock: false - es_cluster_name: test-cluster ansible_user: ansible es_plugins: - plugin: elasticsearch/license From 8393b86a27b6dde3e8aec346d3c8e7422a229a75 Mon Sep 17 00:00:00 2001 From: David Reagan Date: Fri, 22 Jan 2016 12:14:09 -0800 Subject: [PATCH 07/30] Added support for optionally creating the elasticsearch user and group before installing elasticsearch. Renamed vars, set the tasks to use the es_user and es_group vars in elasticsearch-optional-user.yml. Modifed README.md to list the es_user_id and es_group_id vars, made note that both vars are required if they are used. Removed the commented out instances of the vars in defaults/main.yml. Added es_user, es_group, es_user_id, es_group_id vars to config testing. Made conditionals use explicit 'is defined' test. Add tests for es_user_id and es_group_id. Update defaults/main.yml and test/integration/config.yml to match master plus test config additions. --- README.md | 4 ++++ tasks/elasticsearch-optional-user.yml | 18 ++++++++++++++++++ tasks/elasticsearch.yml | 4 ++++ test/integration/config.yml | 2 +- .../helpers/serverspec/config_spec.rb | 8 ++++++++ 5 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 tasks/elasticsearch-optional-user.yml diff --git a/README.md b/README.md index 98a24d0..34d7356 100644 --- a/README.md +++ b/README.md @@ -221,6 +221,10 @@ If installing Marvel or Watcher, ensure the license plugin is also specified. S * ```es_user``` - defaults to elasticsearch. * ```es_group``` - defaults to elasticsearch. +* ```es_user_id``` - default is undefined. +* ```es_group_id``` - default is undefined. + +Both ```es_user_id``` and ```es_group_id``` must be set for the user and group ids to be set. By default, each node on a host will be installed to use unique pid, plugin, work, data and log directories. These directories are created, using the instance and host name, beneath default locations ] controlled by the following parameters: diff --git a/tasks/elasticsearch-optional-user.yml b/tasks/elasticsearch-optional-user.yml new file mode 100644 index 0000000..5cf1d38 --- /dev/null +++ b/tasks/elasticsearch-optional-user.yml @@ -0,0 +1,18 @@ +--- +#Add the elasticsearch user before installing from packages. +- name: Ensure optional elasticsearch group is created with the correct id. + group: + state: present + name: "{{ es_group }}" + system: yes + gid: "{{ es_group_id }}" + +- name: Ensure optional elasticsearch user is created with the correct id. + user: + state: present + name: "{{ es_user }}" + comment: elasticsearch system user + system: yes + createhome: no + uid: "{{ es_user_id }}" + group: "{{ es_group }}" diff --git a/tasks/elasticsearch.yml b/tasks/elasticsearch.yml index 5343ff3..18c9206 100644 --- a/tasks/elasticsearch.yml +++ b/tasks/elasticsearch.yml @@ -8,6 +8,10 @@ - debug: msg="Node configuration {{ es_config }} " +- name: Include optional user and group creation. + when: (es_user_id is defined) and (es_group_id is defined) + include: elasticsearch-optional-user.yml + #- name: Include specific Elasticsearch # include: "elasticsearch-{{ansible_os_family}}.yml" diff --git a/test/integration/config.yml b/test/integration/config.yml index df13fe1..fabc7cd 100644 --- a/test/integration/config.yml +++ b/test/integration/config.yml @@ -4,7 +4,7 @@ hosts: localhost roles: #expand to all available parameters - - { role: elasticsearch, es_instance_name: "node1", es_data_dirs: ["/opt/elasticsearch/data-1","/opt/elasticsearch/data-2"], es_log_dir: "/opt/elasticsearch/logs", es_work_dir: "/opt/elasticsearch/temp", es_config: {node.name: "node1", cluster.name: "custom-cluster", discovery.zen.ping.unicast.hosts: "localhost:9301", http.port: 9201, transport.tcp.port: 9301, node.data: false, node.master: true, bootstrap.mlockall: true, discovery.zen.ping.multicast.enabled: false } } + - { role: elasticsearch, es_instance_name: "node1", es_data_dirs: ["/opt/elasticsearch/data-1","/opt/elasticsearch/data-2"], es_log_dir: "/opt/elasticsearch/logs", es_work_dir: "/opt/elasticsearch/temp", es_user_id: 333, es_group_id: 333, es_config: {node.name: "node1", cluster.name: "custom-cluster", discovery.zen.ping.unicast.hosts: "localhost:9301", http.port: 9201, transport.tcp.port: 9301, node.data: false, node.master: true, bootstrap.mlockall: true, discovery.zen.ping.multicast.enabled: false } } vars: es_scripts: false es_templates: false diff --git a/test/integration/helpers/serverspec/config_spec.rb b/test/integration/helpers/serverspec/config_spec.rb index 396b9c1..086c063 100644 --- a/test/integration/helpers/serverspec/config_spec.rb +++ b/test/integration/helpers/serverspec/config_spec.rb @@ -5,6 +5,14 @@ shared_examples 'config::init' do |es_version| describe user('elasticsearch') do it { should exist } end + + describe group('elasticsearch') do + it { should have_gid 333 } + end + + describe user('elasticsearch') do + it { should have_uid 333 } + end describe service('node1_elasticsearch') do it { should be_running } From 53f5d61fe536a595b3d98a8f579e77996d22d490 Mon Sep 17 00:00:00 2001 From: Dale McDiarmid Date: Fri, 15 Apr 2016 17:04:31 +0100 Subject: [PATCH 08/30] Gem lock + standard images --- .gitignore | 1 - .kitchen.yml | 6 +++--- Gemfile.lock | 42 ++++++++++++++++++++++++++++++++++++++++++ handlers/main.yml | 2 +- 4 files changed, 46 insertions(+), 5 deletions(-) create mode 100644 Gemfile.lock diff --git a/.gitignore b/.gitignore index dca2467..7a4be3e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ .kitchen/ -*.lock *.pyc .vendor .bundle diff --git a/.kitchen.yml b/.kitchen.yml index 0728b01..f0d6ad1 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -15,7 +15,7 @@ provisioner: platforms: - name: ubuntu-14.04 driver_config: - image: dliappis/ubuntuhetzner:14.04 + image: dliappis/ubuntu:14.04 privileged: true provision_command: - apt-get update && apt-get install -y software-properties-common && add-apt-repository -y ppa:ansible/ansible @@ -45,7 +45,7 @@ platforms: run_command: "/sbin/init" - name: centos-6 driver_config: - image: dliappis/centoshetzner:6 + image: dliappis/centos:6 privileged: true provision_command: - yum remove -y ansible @@ -54,7 +54,7 @@ platforms: use_sudo: false - name: centos-7 driver_config: - image: dliappis/centoshetzner:7 + image: dliappis/centos:7 provision_command: - yum remove -y ansible - yum -y install gmp-devel python-devel python-pip diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..8c827c2 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,42 @@ +GEM + remote: https://rubygems.org/ + specs: + faraday (0.9.2) + multipart-post (>= 1.2, < 3) + highline (1.7.8) + kitchen-ansible (0.40.1) + librarian-ansible + test-kitchen (~> 1.4) + kitchen-docker (2.1.0) + test-kitchen (>= 1.0.0) + librarian (0.1.2) + highline + thor (~> 0.15) + librarian-ansible (3.0.0) + faraday + librarian (~> 0.1.0) + mixlib-shellout (2.2.6) + multipart-post (2.0.0) + net-scp (1.2.1) + net-ssh (>= 2.6.5) + net-ssh (2.9.4) + safe_yaml (1.0.4) + test-kitchen (1.4.2) + mixlib-shellout (>= 1.2, < 3.0) + net-scp (~> 1.1) + net-ssh (~> 2.7, < 2.10) + safe_yaml (~> 1.0) + thor (~> 0.18) + thor (0.19.1) + +PLATFORMS + ruby + +DEPENDENCIES + kitchen-ansible (= 0.40.1) + kitchen-docker (= 2.1.0) + net-ssh (~> 2.0) + test-kitchen (= 1.4.2) + +BUNDLED WITH + 1.11.2 diff --git a/handlers/main.yml b/handlers/main.yml index 8c6431e..2432ffe 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 or (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.changed) From b246a63979d9f887ce67722de45b484bd07a55ea Mon Sep 17 00:00:00 2001 From: Dale McDiarmid Date: Fri, 15 Apr 2016 17:10:00 +0100 Subject: [PATCH 09/30] No need to install ansible as provided by images --- .kitchen.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.kitchen.yml b/.kitchen.yml index f0d6ad1..c5d3279 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -48,18 +48,11 @@ platforms: image: dliappis/centos:6 privileged: true provision_command: - - yum remove -y ansible - - yum -y install gmp-devel python-devel python-pip - - pip install ansible use_sudo: false - name: centos-7 driver_config: image: dliappis/centos:7 provision_command: - - yum remove -y ansible - - yum -y install gmp-devel python-devel python-pip - - yum -y groupinstall "Development Tools" - - pip install ansible - sed -ri 's/^#?PermitRootLogin .*/PermitRootLogin yes/' /etc/ssh/sshd_config - sed -ri 's/^#?PasswordAuthentication .*/PasswordAuthentication yes/' /etc/ssh/sshd_config - sed -ri 's/^#?UsePAM .*/UsePAM no/' /etc/ssh/sshd_config From 50155e79cbd3e75e28ba906191caee5b0fac1cfd Mon Sep 17 00:00:00 2001 From: Dale McDiarmid Date: Fri, 15 Apr 2016 23:17:10 +0100 Subject: [PATCH 10/30] Optimised testing images --- .kitchen.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.kitchen.yml b/.kitchen.yml index c5d3279..a02d9be 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -15,7 +15,7 @@ provisioner: platforms: - name: ubuntu-14.04 driver_config: - image: dliappis/ubuntu:14.04 + image: dliappis/ubuntu-devopsci:14.04 privileged: true provision_command: - apt-get update && apt-get install -y software-properties-common && add-apt-repository -y ppa:ansible/ansible @@ -23,7 +23,7 @@ platforms: use_sudo: false - name: debian-7 driver_config: - image: debian:7 + image: dliappis/debian-devopsci:7 privileged: true provision_command: - apt-get update && apt-get -y install python python-dev python-pip build-essential libyaml-dev python-yaml @@ -32,7 +32,7 @@ platforms: use_sudo: false - name: debian-8 driver_config: - image: debian:8 + image: dliappis/debian-devopsci:8 privileged: true provision_command: - apt-get update && apt-get -y install python python-dev python-pip build-essential libyaml-dev python-yaml curl wget @@ -45,13 +45,13 @@ platforms: run_command: "/sbin/init" - name: centos-6 driver_config: - image: dliappis/centos:6 + image: dliappis/centos-devopsci:6 privileged: true provision_command: use_sudo: false - name: centos-7 driver_config: - image: dliappis/centos:7 + image: dliappis/centos-devopsci:7 provision_command: - sed -ri 's/^#?PermitRootLogin .*/PermitRootLogin yes/' /etc/ssh/sshd_config - sed -ri 's/^#?PasswordAuthentication .*/PasswordAuthentication yes/' /etc/ssh/sshd_config From 34899bde24a26d3c6865177ce483b8cebe27e5f4 Mon Sep 17 00:00:00 2001 From: Dale McDiarmid Date: Sat, 16 Apr 2016 11:22:27 +0100 Subject: [PATCH 11/30] Idempotent Java --- defaults/main.yml | 1 + tasks/java.yml | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 5f7bd60..9e718e9 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -4,6 +4,7 @@ es_version: "2.2.0" es_version_lock: false es_use_repository: true es_start_service: true +update_java: false es_restart_on_change: true es_plugins_reinstall: false es_scripts: false diff --git a/tasks/java.yml b/tasks/java.yml index 05fb5e7..3c6bc51 100644 --- a/tasks/java.yml +++ b/tasks/java.yml @@ -1,8 +1,15 @@ --- + + +- set_fact: java_state="present" + +- set_fact: java_state="latest" + when: update_java == true + - name: RedHat - Ensure Java is installed - yum: name={{ java }} state=latest + yum: name={{ java }} state={{java_state}} update_cache=yes when: ansible_os_family == 'RedHat' - name: Debian - Ensure Java is installed - apt: name={{ java }} state=present update_cache=yes force=yes + apt: name={{ java }} state={{java_state}} update_cache=yes force=yes when: ansible_os_family == 'Debian' \ No newline at end of file From 496af8b2ab8eee7593ad36e9a81bf6d50faad594 Mon Sep 17 00:00:00 2001 From: Dale McDiarmid Date: Sat, 16 Apr 2016 11:31:50 +0100 Subject: [PATCH 12/30] Yum to not update cache --- tasks/java.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/java.yml b/tasks/java.yml index 3c6bc51..ed7247f 100644 --- a/tasks/java.yml +++ b/tasks/java.yml @@ -7,7 +7,7 @@ when: update_java == true - name: RedHat - Ensure Java is installed - yum: name={{ java }} state={{java_state}} update_cache=yes + yum: name={{ java }} state={{java_state}} when: ansible_os_family == 'RedHat' - name: Debian - Ensure Java is installed From fee6270f663197cb66dd2c65d11dbbaa305e7329 Mon Sep 17 00:00:00 2001 From: Will Winder Date: Wed, 20 Apr 2016 11:45:29 -0400 Subject: [PATCH 13/30] Make an example in the README more readable. --- README.md | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8959c68..201158c 100644 --- a/README.md +++ b/README.md @@ -137,7 +137,18 @@ recommended in any multi node cluster configuration. ``` - hosts: master_nodes roles: - - { role: elasticsearch, es_instance_name: "node1", es_heap_size: "1g", es_config: {cluster.name: "test-cluster", "discovery.zen.ping.multicast.enabled": false, discovery.zen.ping.unicast.hosts: "elastic02:9300", http.port: 9200, transport.tcp.port: 9300, node.data: false, node.master: true, bootstrap.mlockall: false, discovery.zen.ping.multicast.enabled: false } } + - { role: elasticsearch, es_instance_name: "node1", es_heap_size: "1g", + es_config: { + cluster.name: "test-cluster", + "discovery.zen.ping.multicast.enabled": false, + discovery.zen.ping.unicast.hosts: "elastic02:9300", + http.port: 9200, + transport.tcp.port: 9300, + node.data: false, + node.master: true, + bootstrap.mlockall: false, + discovery.zen.ping.multicast.enabled: false } + } vars: es_scripts: false es_templates: false @@ -275,4 +286,4 @@ Elasticsearch restarted where required. * If the ES version is changed, all plugins will be removed. Those listed in the playbook will be re-installed. This is behaviour is required in ES 2.x. * If no plugins are listed in the playbook for a node, all currently installed plugins will be removed. -* The role does not currently support automatic detection of differences between installed and listed plugins (other than if none are listed). Should users wish to change installed plugins should set es_plugins_reinstall to true. This will cause all currently installed plugins to be removed and those listed to be installed. Change detection will be implemented in future releases. \ No newline at end of file +* The role does not currently support automatic detection of differences between installed and listed plugins (other than if none are listed). Should users wish to change installed plugins should set es_plugins_reinstall to true. This will cause all currently installed plugins to be removed and those listed to be installed. Change detection will be implemented in future releases. From aa129e4eb42d34979db2fb2a5d349358900c7518 Mon Sep 17 00:00:00 2001 From: Jonathan Strootman Date: Tue, 26 Apr 2016 11:45:11 -0700 Subject: [PATCH 14/30] Add tags to main.yml --- tasks/main.yml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tasks/main.yml b/tasks/main.yml index eb7ecc4..bb33824 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,16 +1,32 @@ --- - name: check-parameters include: checkParameters.yml + tags: + - check - name: os-specific vars include_vars: "{{ansible_os_family}}.yml" - include: java.yml + tags: + - java - include: elasticsearch.yml + tags: + - install - include: elasticsearch-config.yml + tags: + - config - include: elasticsearch-scripts.yml when: es_scripts + tags: + - scripts - include: elasticsearch-plugins.yml when: es_plugins is defined or es_plugins_reinstall + tags: + - plugins - include: elasticsearch-service.yml + tags: + - service - include: elasticsearch-templates.yml when: es_templates -- meta: flush_handlers \ No newline at end of file + tags: + - templates +- meta: flush_handlers From 87bbff52790191b9317e4657920b1d2e94fd88bd Mon Sep 17 00:00:00 2001 From: Jonathan Strootman Date: Tue, 26 Apr 2016 12:11:13 -0700 Subject: [PATCH 15/30] Add `always` tags to `set_fact` tasks Small correction to `when` clause in `tasks/elasticsearch-plugins.yml`. --- tasks/elasticsearch-config.yml | 14 ++++++++++++++ tasks/elasticsearch-plugins.yml | 8 +++++++- tasks/elasticsearch-scripts.yml | 4 ++++ tasks/elasticsearch-templates.yml | 4 ++++ tasks/elasticsearch.yml | 10 ++++++++++ tasks/main.yml | 2 ++ 6 files changed, 41 insertions(+), 1 deletion(-) diff --git a/tasks/elasticsearch-config.yml b/tasks/elasticsearch-config.yml index 70a1f42..77d0a5f 100644 --- a/tasks/elasticsearch-config.yml +++ b/tasks/elasticsearch-config.yml @@ -11,19 +11,31 @@ - set_fact: use_system_d={{(ansible_distribution == 'Debian' and ansible_distribution_version | version_compare('8', '>=')) or (ansible_distribution == 'CentOS' and ansible_distribution_version | version_compare('7', '>=')) or (ansible_distribution == 'Ubuntu' and ansible_distribution_version | version_compare('15', '>=')) }} + tags: + - always - set_fact: instance_sysd_script={{sysd_script | dirname }}/{{es_instance_name}}_{{sysd_script | basename}} when: use_system_d + tags: + - always #For directories we also use the {{inventory_hostname}}-{{ es_instance_name }} - this helps if we have a shared SAN. - set_fact: instance_suffix={{inventory_hostname}}-{{ es_instance_name }} + tags: + - always - set_fact: pid_dir={{ es_pid_dir }}/{{instance_suffix}} + tags: + - always - set_fact: log_dir={{ es_log_dir }}/{{instance_suffix}} + tags: + - always - set_fact: work_dir={{ es_work_dir }}/{{instance_suffix}} + tags: + - always #Create required directories - name: Create Directories @@ -36,6 +48,8 @@ - "{{plugin_dir}}" - set_fact: data_dirs={{ es_data_dirs | append_to_list('/'+instance_suffix) }} + tags: + - always - name: Create Data Directories file: path={{ item }} state=directory owner={{ es_user }} group={{ es_group }} diff --git a/tasks/elasticsearch-plugins.yml b/tasks/elasticsearch-plugins.yml index a3e4e1b..94d7353 100644 --- a/tasks/elasticsearch-plugins.yml +++ b/tasks/elasticsearch-plugins.yml @@ -2,11 +2,17 @@ #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. - set_fact: es_plugins_reinstall=true - when: elasticsearch_install.changed or es_plugins is not defined or es_plugins is none + when: (elasticsearch_install is defined and elasticsearch_install.changed) or es_plugins is not defined or es_plugins is none + tags: + - always - 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-" diff --git a/tasks/elasticsearch-scripts.yml b/tasks/elasticsearch-scripts.yml index aa363e8..3dc4150 100644 --- a/tasks/elasticsearch-scripts.yml +++ b/tasks/elasticsearch-scripts.yml @@ -1,9 +1,13 @@ --- - set_fact: es_script_dir={{ es_conf_dir }}/{{es_instance_name}} + tags: + - always - set_fact: es_script_dir={{es_config['path.scripts']}} when: es_config['path.scripts'] is defined + tags: + - always - name: Create script dir file: state=directory path={{ es_script_dir }} owner={{ es_user }} group={{ es_group }} diff --git a/tasks/elasticsearch-templates.yml b/tasks/elasticsearch-templates.yml index a4179a6..ccc8b8d 100644 --- a/tasks/elasticsearch-templates.yml +++ b/tasks/elasticsearch-templates.yml @@ -11,9 +11,13 @@ with_fileglob: "{{ es_templates_fileglob }}" - set_fact: http_port=9200 + tags: + - always - set_fact: http_port={{es_config['http.port']}} when: es_config['http.port'] is defined + tags: + - always - name: Wait for elasticsearch to startup wait_for: port={{http_port}} delay=10 diff --git a/tasks/elasticsearch.yml b/tasks/elasticsearch.yml index 18c9206..1e5cc89 100644 --- a/tasks/elasticsearch.yml +++ b/tasks/elasticsearch.yml @@ -1,10 +1,20 @@ --- - set_fact: instance_default_file={{default_file | dirname}}/{{es_instance_name}}_{{default_file | basename}} + tags: + - always - set_fact: instance_init_script={{init_script | dirname }}/{{es_instance_name}}_{{init_script | basename}} + tags: + - always - set_fact: conf_dir={{ es_conf_dir }}/{{es_instance_name}} + tags: + - always - set_fact: plugin_dir={{ es_plugin_dir }}/{{es_instance_name}} + tags: + - always - set_fact: m_lock_enabled={{ es_config['bootstrap.mlockall'] is defined and es_config['bootstrap.mlockall'] == True }} + tags: + - always - debug: msg="Node configuration {{ es_config }} " diff --git a/tasks/main.yml b/tasks/main.yml index bb33824..6b97512 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -5,6 +5,8 @@ - check - name: os-specific vars include_vars: "{{ansible_os_family}}.yml" + tags: + - always - include: java.yml tags: - java From 250b0de3005878eb8cfe0fe170108240e330926a Mon Sep 17 00:00:00 2001 From: Jonathan Strootman Date: Tue, 3 May 2016 09:56:16 -0700 Subject: [PATCH 16/30] Updated README with statement about ansible tags --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 201158c..efef3b5 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,8 @@ The simplest configuration therefore consists of: The above installs a single node 'node1' on the hosts 'localhost'. +This role also uses [Ansible tags](http://docs.ansible.com/ansible/playbooks_tags.html). Run your playbook with the `--list-tasks` flag for more information. + ### Basic Elasticsearch Configuration All Elasticsearch configuration parameters are supported. This is achieved using a configuration map parameter 'es_config' which is serialized into the elasticsearch.yml file. From 19a794dafba12018faac6aec507f2990d5c0380d Mon Sep 17 00:00:00 2001 From: Emanuelis Date: Mon, 16 May 2016 13:22:07 +0300 Subject: [PATCH 17/30] LimitNOFILE configurable by es_max_open_files --- defaults/main.yml | 4 +++- templates/systemd/elasticsearch.j2 | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 9e718e9..a912892 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -17,4 +17,6 @@ es_pid_dir: "/var/run/elasticsearch" es_data_dirs: "/var/lib/elasticsearch" es_log_dir: "/var/log/elasticsearch" es_work_dir: "/tmp/elasticsearch" -es_plugin_dir: "/usr/share/elasticsearch/plugins" \ No newline at end of file +es_plugin_dir: "/usr/share/elasticsearch/plugins" +es_max_open_files: 65535 + diff --git a/templates/systemd/elasticsearch.j2 b/templates/systemd/elasticsearch.j2 index 8d400de..ab75b44 100644 --- a/templates/systemd/elasticsearch.j2 +++ b/templates/systemd/elasticsearch.j2 @@ -31,7 +31,7 @@ StandardOutput=null StandardError=journal # Specifies the maximum file descriptor number that can be opened by this process -LimitNOFILE=65535 +LimitNOFILE={{es_max_open_files}} # Specifies the maximum number of bytes of memory that may be locked into RAM # Set to "infinity" if you use the 'bootstrap.mlockall: true' option @@ -53,4 +53,4 @@ SendSIGKILL=no SuccessExitStatus=143 [Install] -WantedBy=multi-user.target \ No newline at end of file +WantedBy=multi-user.target 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 18/30] 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 19/30] 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 d9d8810b629b63d566d35b2fb3e4daab79f00aec Mon Sep 17 00:00:00 2001 From: Marji Cermak Date: Sun, 5 Jun 2016 15:43:04 +1000 Subject: [PATCH 20/30] enable specify java package name If es_java variable is set, it will use that as the java package name instead of the default package. --- vars/Debian.yml | 2 +- vars/RedHat.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/vars/Debian.yml b/vars/Debian.yml index 6e58b35..7725f49 100644 --- a/vars/Debian.yml +++ b/vars/Debian.yml @@ -1,4 +1,4 @@ --- -java: "openjdk-7-jre-headless" +java: "{{ es_java | default('openjdk-7-jre-headless') }}" default_file: "/etc/default/elasticsearch" es_home: "/usr/share/elasticsearch" \ No newline at end of file diff --git a/vars/RedHat.yml b/vars/RedHat.yml index faeec01..b0aa42b 100644 --- a/vars/RedHat.yml +++ b/vars/RedHat.yml @@ -1,4 +1,4 @@ --- -java: "java-1.8.0-openjdk.x86_64" +java: "{{ es_java | default('java-1.8.0-openjdk.x86_64') }}" default_file: "/etc/sysconfig/elasticsearch" es_home: "/usr/share/elasticsearch" \ No newline at end of file From 1d104d77b5122187137d583f58aa14c888c4d6d0 Mon Sep 17 00:00:00 2001 From: Emanuelis Date: Wed, 29 Jun 2016 10:56:32 +0300 Subject: [PATCH 21/30] es_max_open_files default value changed to 65536 --- defaults/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/defaults/main.yml b/defaults/main.yml index a912892..c120127 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -18,5 +18,5 @@ es_data_dirs: "/var/lib/elasticsearch" es_log_dir: "/var/log/elasticsearch" es_work_dir: "/tmp/elasticsearch" es_plugin_dir: "/usr/share/elasticsearch/plugins" -es_max_open_files: 65535 +es_max_open_files: 65536 From 0d80dde1ef4e048bf676fbeb14b04f455bd42666 Mon Sep 17 00:00:00 2001 From: Dale McDiarmid Date: Fri, 8 Jul 2016 13:32:17 +0100 Subject: [PATCH 22/30] Initial Shield Files --- defaults/main.yml | 1 + tasks/elasticsearch-shield.yml | 3 +++ tasks/main.yml | 2 ++ 3 files changed, 6 insertions(+) create mode 100644 tasks/elasticsearch-shield.yml diff --git a/defaults/main.yml b/defaults/main.yml index c120127..96095aa 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -12,6 +12,7 @@ es_templates: false es_user: elasticsearch es_group: elasticsearch es_config: {} +es_install_shield: false #Need to provide default directories es_pid_dir: "/var/run/elasticsearch" es_data_dirs: "/var/lib/elasticsearch" diff --git a/tasks/elasticsearch-shield.yml b/tasks/elasticsearch-shield.yml new file mode 100644 index 0000000..849169c --- /dev/null +++ b/tasks/elasticsearch-shield.yml @@ -0,0 +1,3 @@ +--- + + diff --git a/tasks/main.yml b/tasks/main.yml index 6b97512..a44de58 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -24,6 +24,8 @@ when: es_plugins is defined or es_plugins_reinstall tags: - plugins +- include: elasticsearch-shield.yml + when: es_install_shield - include: elasticsearch-service.yml tags: - service From 6160207b6f359a4aa732be701e4579238910598f Mon Sep 17 00:00:00 2001 From: Dale McDiarmid Date: Fri, 8 Jul 2016 14:49:21 +0100 Subject: [PATCH 23/30] Shield tag --- tasks/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tasks/main.yml b/tasks/main.yml index a44de58..ca1dfce 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -26,6 +26,8 @@ - plugins - include: elasticsearch-shield.yml when: es_install_shield + tags: + - shield - include: elasticsearch-service.yml tags: - service From 59bdee229d6ba4c8d8261d97b930427ace41ab15 Mon Sep 17 00:00:00 2001 From: Dale McDiarmid Date: Wed, 20 Jul 2016 12:47:34 +0100 Subject: [PATCH 24/30] Fix if template file globs are not defined --- tasks/elasticsearch-templates.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tasks/elasticsearch-templates.yml b/tasks/elasticsearch-templates.yml index ccc8b8d..c9de8bb 100644 --- a/tasks/elasticsearch-templates.yml +++ b/tasks/elasticsearch-templates.yml @@ -8,7 +8,9 @@ - name: Copy templates to elasticsearch copy: src={{ item }} dest=/etc/elasticsearch/templates owner={{ es_user }} group={{ es_group }} - with_fileglob: "{{ es_templates_fileglob }}" + when: es_templates_fileglob is defined + with_fileglob: + - "{{ es_templates_fileglob }}" - set_fact: http_port=9200 tags: From 38b9f70586d4df2296f8fa7efa0cf60b137585c7 Mon Sep 17 00:00:00 2001 From: Dale McDiarmid Date: Wed, 20 Jul 2016 13:05:18 +0100 Subject: [PATCH 25/30] 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 26/30] 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 From 5982dad832011b8d8fc0b0153c35cd4c117b8952 Mon Sep 17 00:00:00 2001 From: Dale McDiarmid Date: Wed, 20 Jul 2016 13:51:14 +0100 Subject: [PATCH 27/30] 107 changes --- defaults/main.yml | 1 + tasks/main.yml | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/defaults/main.yml b/defaults/main.yml index 96095aa..d3c970d 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -4,6 +4,7 @@ es_version: "2.2.0" es_version_lock: false es_use_repository: true es_start_service: true +es_java_install: true update_java: false es_restart_on_change: true es_plugins_reinstall: false diff --git a/tasks/main.yml b/tasks/main.yml index 3a45816..6a92155 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -8,6 +8,7 @@ tags: - always - include: java.yml + when: es_java_install tags: - java - include: elasticsearch.yml @@ -35,4 +36,4 @@ when: es_templates tags: - templates -- meta: flush_handlers \ No newline at end of file +- meta: flush_handlers From 0cdc83d918de5b2f1f3208d131ea3dd93c8c78dd Mon Sep 17 00:00:00 2001 From: Dale McDiarmid Date: Wed, 20 Jul 2016 14:57:21 +0100 Subject: [PATCH 28/30] Support for package downgrade --- defaults/main.yml | 1 + tasks/elasticsearch-Debian.yml | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/defaults/main.yml b/defaults/main.yml index d3c970d..451000f 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -21,4 +21,5 @@ es_log_dir: "/var/log/elasticsearch" es_work_dir: "/tmp/elasticsearch" es_plugin_dir: "/usr/share/elasticsearch/plugins" es_max_open_files: 65536 +es_allow_downgrades: false diff --git a/tasks/elasticsearch-Debian.yml b/tasks/elasticsearch-Debian.yml index 4311abb..cc2112c 100644 --- a/tasks/elasticsearch-Debian.yml +++ b/tasks/elasticsearch-Debian.yml @@ -1,4 +1,14 @@ --- + +- set_fact: force_install=no + tags: + - always + +- set_fact: force_install=yes + when: es_allow_downgrades + tags: + - always + - name: Debian - Add Elasticsearch repository key apt_key: url="http://packages.elasticsearch.org/GPG-KEY-elasticsearch" state=present when: es_use_repository @@ -8,7 +18,7 @@ when: es_use_repository - 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 + apt: name=elasticsearch{% if es_version is defined and es_version != "" %}={{ es_version }}{% endif %} state=present force={{force_install}} cache_valid_time=86400 when: es_use_repository register: elasticsearch_install_from_repo From d75961c25ff42da372f54cdba42fb0ce28d740c3 Mon Sep 17 00:00:00 2001 From: Dale McDiarmid Date: Wed, 20 Jul 2016 14:59:10 +0100 Subject: [PATCH 29/30] Support for package downgrade --- tasks/elasticsearch-Debian.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tasks/elasticsearch-Debian.yml b/tasks/elasticsearch-Debian.yml index cc2112c..dba5fa5 100644 --- a/tasks/elasticsearch-Debian.yml +++ b/tasks/elasticsearch-Debian.yml @@ -1,13 +1,9 @@ --- - set_fact: force_install=no - tags: - - always - set_fact: force_install=yes when: es_allow_downgrades - tags: - - always - name: Debian - Add Elasticsearch repository key apt_key: url="http://packages.elasticsearch.org/GPG-KEY-elasticsearch" state=present From 6f968bd789b28023b244cab194781b774c473af1 Mon Sep 17 00:00:00 2001 From: Dale McDiarmid Date: Wed, 20 Jul 2016 15:06:46 +0100 Subject: [PATCH 30/30] New params in docs --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index efef3b5..1fa450d 100644 --- a/README.md +++ b/README.md @@ -217,6 +217,11 @@ Following variables affect the versions installed: * ```es_start_service``` (true (default) or false) * ```es_plugins_reinstall``` (true or false (default) ) * ```es_plugins``` (an array of plugin definitions e.g.: +* ```es_allow_downgrades``` For development purposes only. (true or false (default) ) +* ```es_java_install``` If set to false, Java will not be installed. (true (default) or false) +* ```update_java``` Updates Java to the latest version. (true or false (default)) + + ``` es_plugins: