From 3f213a3b644c1ce9182a91b7904ce91987aea765 Mon Sep 17 00:00:00 2001 From: "Thierno IB. BARRY" Date: Wed, 27 Jan 2016 17:37:07 +0100 Subject: [PATCH 01/14] Define a proxy for plugin installation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Address the issue [ansible-elasticsearch #4](https://github.com/elastic/ansible-elasticsearch/issues/4) which add proxy for plugin installation and more generally es_proxy_host and es_proxy_port for global usage. Right now, it’s only used for plugins installation. In the futur, it can be used (or defined) in the java_opts within the default file for instance (elasticsearch.j2) --- README.md | 24 ++++++++++++++++++++++-- tasks/checkParameters.yml | 3 +++ tasks/elasticsearch-plugins.yml | 10 +++++++++- 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1be1b5e..bdf4ae2 100644 --- a/README.md +++ b/README.md @@ -100,6 +100,8 @@ A more complex example: - plugin: marvel-agent - plugin: lmenezes/elasticsearch-kopf version: master + proxy_host: proxy.example.com + proxy_port: 8080 ``` ### Multi Node Server Installations @@ -166,8 +168,7 @@ Following variables affect the versions installed: - plugin: elasticsearch-cloud-aws version: 2.5.0 ``` - - + Earlier examples illustrate the installation of plugins for 2.x. The correct use of this parameter varies depending on the version of Elasticsearch being installed: - 2.x. - For officially supported plugins no version or source delimiter is required. The plugin script will determine the appropriate plugin version based on the target Elasticsearch version. @@ -188,6 +189,25 @@ controlled by the following parameters: * ```es_work_dir``` - defaults to "/tmp/elasticsearch". * ```es_plugin_dir``` - defaults to "/usr/share/elasticsearch/plugins". +### Proxy + +To define proxy globaly, set the following variables: + +* ```es_proxy_host``` - global proxy host +* ```es_proxy_port``` - global proxy port + +To define proxy only for a particular plugin during its installation: + +``` + es_plugins: + - plugin: elasticsearch-cloud-aws + version: 2.5.0 + proxy_host: proxy.example.com + proxy_port: 8080 +``` + +> For plugins installation, proxy_host and proxy_port are used first if they are defined and fallback to the global proxy settings if not. + ## Notes * The role assumes the user/group exists on the server. The elasticsearch packages create the default elasticsearch user. If this needs to be changed, ensure the user exists. diff --git a/tasks/checkParameters.yml b/tasks/checkParameters.yml index 1c851ec..6fc5bef 100644 --- a/tasks/checkParameters.yml +++ b/tasks/checkParameters.yml @@ -3,6 +3,9 @@ - fail: msg="es_instance_name must be specified and cannot be blank" when: es_instance_name is not defined or es_instance_name == '' +- fail: msg="es_proxy_port must be specified and cannot be blank when es_proxy_host is defined" + when: (es_proxy_port is not defined or es_proxy_port == '') and (es_proxy_host is defined and es_proxy_host != '') + - set_fact: multi_cast={{ (es_version | version_compare('2.0', '<') and es_config['discovery.zen.ping.multicast.enabled'] is not defined) or (es_config['discovery.zen.ping.multicast.enabled'] is defined and es_config['discovery.zen.ping.multicast.enabled'])}} - debug: msg="WARNING - It is recommended you specify the parameter 'http.port' when multicast is disabled" diff --git a/tasks/elasticsearch-plugins.yml b/tasks/elasticsearch-plugins.yml index 28e9ec8..e7f26e8 100644 --- a/tasks/elasticsearch-plugins.yml +++ b/tasks/elasticsearch-plugins.yml @@ -20,7 +20,15 @@ - 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 %} --silent" + 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: "'Failed to install' in plugin_installed.stderr" changed_when: plugin_installed.rc == 0 From 48348df46e6effcfd14cf020977002df28f1065e Mon Sep 17 00:00:00 2001 From: "Thierno IB. BARRY" Date: Wed, 27 Jan 2016 19:48:19 +0100 Subject: [PATCH 02/14] fix typo fix typo --- tasks/elasticsearch-plugins.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/elasticsearch-plugins.yml b/tasks/elasticsearch-plugins.yml index e7f26e8..8b52648 100644 --- a/tasks/elasticsearch-plugins.yml +++ b/tasks/elasticsearch-plugins.yml @@ -24,9 +24,9 @@ {{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 }} + -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 }} + -DproxyHost={{ es_proxy_host }} -DproxyPort={{ es_proxy_port }} {% endif %} --silent register: plugin_installed From 0fd1f34852dfe74ee96c7cf7f53f5661fc277c24 Mon Sep 17 00:00:00 2001 From: Dale McDiarmid Date: Fri, 18 Mar 2016 19:30:11 +0000 Subject: [PATCH 03/14] Fixes issue 70, Improves plugin management, Refactoring, Updates tests, Introduces multiple data dir support --- README.md | 63 ++++++++++++++++--- defaults/main.yml | 2 +- filter_plugins/custom.py | 26 ++++++++ tasks/elasticsearch-config.yml | 43 ++++++++----- tasks/elasticsearch-plugins.yml | 28 ++++++--- tasks/main.yml | 2 +- templates/elasticsearch.j2 | 2 +- templates/elasticsearch.yml.j2 | 2 +- templates/init/debian/elasticsearch.j2 | 2 +- templates/systemd/elasticsearch.j2 | 2 +- test/integration/config.yml | 2 +- .../helpers/serverspec/config_spec.rb | 30 ++++++++- .../helpers/serverspec/multi_spec.rb | 33 ++++++++-- .../helpers/serverspec/package_spec.rb | 20 ++++++ .../helpers/serverspec/standard_spec.rb | 4 ++ test/integration/multi.yml | 4 +- 16 files changed, 216 insertions(+), 49 deletions(-) create mode 100644 filter_plugins/custom.py diff --git a/README.md b/README.md index 1a95b7f..686adbe 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Ansible role for Elasticsearch. Currently this works on Debian and RedHat based * Centos 6 * Centos 7 -The latest Elasticsearch versions of 1.7.x and 2.1.x are actively tested. +The latest Elasticsearch versions of 1.7.x and 2.x are actively tested. ## Usage @@ -54,7 +54,18 @@ The following illustrates applying configuration parameters to an Elasticsearch hosts: localhost roles: #expand to all available parameters - - { role: elasticsearch, es_instance_name: "node1", es_data_dir: "/opt/elasticsearch/data", 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", 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 } + } vars: es_scripts: false es_templates: false @@ -84,7 +95,18 @@ A more complex example: hosts: localhost roles: #expand to all available parameters - - { role: elasticsearch, es_instance_name: "node1", es_data_dir: "/opt/elasticsearch/data", 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", 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 } + } vars: es_scripts: false es_templates: false @@ -126,8 +148,28 @@ recommended in any multi node cluster configuration. - hosts: data_nodes roles: - - { role: elasticsearch, es_instance_name: "node1", es_data_dir: "/opt/elasticsearch", es_config: { "discovery.zen.ping.multicast.enabled": false, discovery.zen.ping.unicast.hosts: "elastic02:9300", http.port: 9200, transport.tcp.port: 9300, node.data: true, node.master: false, bootstrap.mlockall: false, discovery.zen.ping.multicast.enabled: false } } - - { role: elasticsearch, es_instance_name: "node2", es_config: { "discovery.zen.ping.multicast.enabled": false, discovery.zen.ping.unicast.hosts: "elastic02:9300", http.port: 9201, transport.tcp.port: 9301, node.data: true, node.master: false, bootstrap.mlockall: false, discovery.zen.ping.multicast.enabled: false } } + - { role: elasticsearch, es_instance_name: "node1", es_data_dirs: "/opt/elasticsearch", + es_config: { + "discovery.zen.ping.multicast.enabled": false, + discovery.zen.ping.unicast.hosts: "elastic02:9300", + http.port: 9200, + transport.tcp.port: 9300, + node.data: true, + node.master: false, + bootstrap.mlockall: false, + discovery.zen.ping.multicast.enabled: false } + } + - { role: elasticsearch, es_instance_name: "node2", + es_config: { + "discovery.zen.ping.multicast.enabled": false, + discovery.zen.ping.unicast.hosts: "elastic02:9300", + http.port: 9201, + transport.tcp.port: 9301, + node.data: true, + node.master: false, + bootstrap.mlockall: false, + discovery.zen.ping.multicast.enabled: false } + } vars: es_scripts: false es_templates: false @@ -159,7 +201,7 @@ Following variables affect the versions installed: * ```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_plugins``` (an array of plugin definitions e.g.: ``` es_plugins: @@ -183,10 +225,12 @@ By default, each node on a host will be installed to use unique pid, plugin, wor controlled by the following parameters: * ```es_pid_dir``` - defaults to "/var/run/elasticsearch". -* ```es_data_dir``` - defaults to "/var/lib/elasticsearch". +* ```es_data_dirs``` - defaults to "/var/lib/elasticsearch". This can be a list or comma separated string e.g. ["/opt/elasticsearch/data-1","/opt/elasticsearch/data-2"] or "/opt/elasticsearch/data-1,/opt/elasticsearch/data-2" * ```es_log_dir``` - defaults to "/var/log/elasticsearch". * ```es_work_dir``` - defaults to "/tmp/elasticsearch". * ```es_plugin_dir``` - defaults to "/usr/share/elasticsearch/plugins". +* ```es_restart_on_change``` - defaults to true. If false, changes will not result in Elasticsearch being restarted. +* ```es_plugins_reinstall``` - defaults to false. If true, all currently installed plugins will be removed from a node. Listed plugins will then be re-installed. This role ships with sample scripts and templates located in the [files/scripts/](files/scripts) and [files/templates/](files/templates) directories, respectively. These variables are used with the Ansible [with_fileglob](http://docs.ansible.com/ansible/playbooks_loops.html#id4) loop. When setting the globs, be sure to use an absolute path. * ```es_scripts_fileglob``` - defaults to `/files/scripts/`. @@ -203,3 +247,8 @@ all supported platforms. Elasticsearch restarted where required. * Systemd is used for Ubuntu versions >= 15, Debian >=8, Centos >=7. All other versions use init for service scripts. +## IMPORTANT NOTES RE PLUGIN MANAGEMENT + +* 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 diff --git a/defaults/main.yml b/defaults/main.yml index 924b229..7bf9af0 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -13,7 +13,7 @@ es_group: elasticsearch es_config: {} #Need to provide default directories es_pid_dir: "/var/run/elasticsearch" -es_data_dir: "/var/lib/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 diff --git a/filter_plugins/custom.py b/filter_plugins/custom.py new file mode 100644 index 0000000..0453a25 --- /dev/null +++ b/filter_plugins/custom.py @@ -0,0 +1,26 @@ +__author__ = 'dale mcdiarmid' + +import re + +def modify_list(values=[], pattern='', replacement='', ignorecase=False): + ''' Perform a `re.sub` on every item in the list''' + if ignorecase: + flags = re.I + else: + flags = 0 + _re = re.compile(pattern, flags=flags) + return [_re.sub(replacement, value) for value in values] + +def append_to_list(values=[], suffix=''): + if isinstance(values, basestring): + values = values.split(',') + return [str(value+suffix) for value in values] + +def array_to_str(values=[],separator=','): + return separator.join(values) + +class FilterModule(object): + def filters(self): + return {'modify_list': modify_list, + 'append_to_list':append_to_list, + 'array_to_str':array_to_str} \ No newline at end of file diff --git a/tasks/elasticsearch-config.yml b/tasks/elasticsearch-config.yml index b247f63..d5e6435 100644 --- a/tasks/elasticsearch-config.yml +++ b/tasks/elasticsearch-config.yml @@ -17,32 +17,35 @@ #For directories we also use the {{inventory_hostname}}-{{ es_instance_name }} - this helps if we have a shared SAN. -- set_fact: pid_dir={{ es_pid_dir }}/{{inventory_hostname}}-{{ es_instance_name }} +- set_fact: instance_suffix={{inventory_hostname}}-{{ es_instance_name }} -- set_fact: data_dir={{ es_data_dir }}/{{inventory_hostname}}-{{ es_instance_name }} +- set_fact: pid_dir={{ es_pid_dir }}/{{instance_suffix}} -- set_fact: log_dir={{ es_log_dir }}/{{inventory_hostname}}-{{ es_instance_name }} +- set_fact: log_dir={{ es_log_dir }}/{{instance_suffix}} -- set_fact: work_dir={{ es_work_dir }}/{{inventory_hostname}}-{{ es_instance_name }} +- set_fact: work_dir={{ es_work_dir }}/{{instance_suffix}} #Create required directories -- name: Create PID Directory - file: path={{ pid_dir }} state=directory owner={{ es_user }} group={{ es_group }} +- name: Create Directories + file: path={{ item }} state=directory owner={{ es_user }} group={{ es_group }} + with_items: + - "{{pid_dir}}" + - "{{work_dir}}" + - "{{log_dir}}" + - "{{conf_dir}}" + - "{{plugin_dir}}" -- name: Create data dir - file: state=directory path={{ data_dir }} owner={{ es_user }} group={{ es_group }} +- debug: msg="Data Dirs {{es_data_dirs}}" -- name: Create work dir - file: state=directory path={{ work_dir }} owner={{ es_user }} group={{ es_group }} +- set_fact: data_dirs={{ es_data_dirs | append_to_list('/'+instance_suffix) }} -- name: Create log dir - file: state=directory path={{ log_dir }} owner={{ es_user }} group={{ es_group }} +- debug: msg="Data Dirs {{data_dirs}}" -- name: Create Config Directory - file: path={{ conf_dir }} state=directory owner={{ es_user }} group={{ es_group }} +- name: Create Data Directories + file: path={{ item }} state=directory owner={{ es_user }} group={{ es_group }} + with_items: + - "{{data_dirs}}" -- name: Create Plugin Directory - file: state=directory path={{ plugin_dir }} owner={{ es_user }} group={{ es_group }} #Copy the config template - name: Copy Configuration File @@ -92,3 +95,11 @@ - name: Delete Default Sysconfig File file: dest=/usr/lib/systemd/system/elasticsearch.service state=absent + +- name: Delete Default Configuration File + file: dest=/etc/elasticsearch/elasticsearch.yml state=absent + +- name: Delete Default Logging File + file: dest=/etc/elasticsearch/logging.yml state=absent + +- debug: msg="Data Dirs {{data_dirs}}" \ No newline at end of file diff --git a/tasks/elasticsearch-plugins.yml b/tasks/elasticsearch-plugins.yml index 28e9ec8..46f0b51 100644 --- a/tasks/elasticsearch-plugins.yml +++ b/tasks/elasticsearch-plugins.yml @@ -1,22 +1,32 @@ --- -#es_plugins_reinstall will be set to true if elasticsearch_install.changed i.e. we have changed ES version +#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 + when: elasticsearch_install.changed or es_plugins is not defined or es_plugins is none + +- set_fact: list_command="list" + +- set_fact: list_command="--list" + when: es_version | version_compare('2.0', '<') #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 removed installed plugins not those listed +#This needs to removes any currently installed plugins - name: Remove elasticsearch plugins - command: "{{es_home}}/bin/plugin remove {{ item.plugin }} --silent" + command: "{{es_home}}/bin/plugin remove {{item}} --silent" ignore_errors: yes - with_items: es_plugins - when: es_plugins_reinstall + 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 @@ -25,7 +35,7 @@ failed_when: "'Failed to install' in plugin_installed.stderr" changed_when: plugin_installed.rc == 0 with_items: es_plugins - when: ansible_os_family == 'RedHat' or ansible_os_family == 'Debian' + when: es_plugins is defined and not es_plugins is none notify: restart elasticsearch environment: CONF_DIR: "{{ conf_dir }}" diff --git a/tasks/main.yml b/tasks/main.yml index e021b5d..eb7ecc4 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -9,7 +9,7 @@ - include: elasticsearch-scripts.yml when: es_scripts - include: elasticsearch-plugins.yml - when: es_plugins is defined + when: es_plugins is defined or es_plugins_reinstall - include: elasticsearch-service.yml - include: elasticsearch-templates.yml when: es_templates diff --git a/templates/elasticsearch.j2 b/templates/elasticsearch.j2 index da71a7b..fafb5e2 100644 --- a/templates/elasticsearch.j2 +++ b/templates/elasticsearch.j2 @@ -9,7 +9,7 @@ ES_HOME={{es_home}} CONF_DIR={{conf_dir}} # Elasticsearch data directory -DATA_DIR={{data_dir}} +DATA_DIR={{ data_dirs | array_to_str }} # Elasticsearch logs directory LOG_DIR={{log_dir}} diff --git a/templates/elasticsearch.yml.j2 b/templates/elasticsearch.yml.j2 index 32db02d..203a869 100644 --- a/templates/elasticsearch.yml.j2 +++ b/templates/elasticsearch.yml.j2 @@ -16,7 +16,7 @@ node.name: {{inventory_hostname}}-{{es_instance_name}} # Path to directory containing configuration (this file and logging.yml): path.conf: {{ conf_dir }} -path.data: {{ data_dir }} +path.data: {{ data_dirs | array_to_str }} path.work: {{ work_dir }} diff --git a/templates/init/debian/elasticsearch.j2 b/templates/init/debian/elasticsearch.j2 index 02206cc..5512728 100755 --- a/templates/init/debian/elasticsearch.j2 +++ b/templates/init/debian/elasticsearch.j2 @@ -10,7 +10,7 @@ # Modified by Nicolas Huray for Elasticsearch . # ### BEGIN INIT INFO -# Provides: elasticsearch +# Provides: {{es_instance_name}}_{{default_file | basename}} # Required-Start: $network $remote_fs $named # Required-Stop: $network $remote_fs $named # Default-Start: 2 3 4 5 diff --git a/templates/systemd/elasticsearch.j2 b/templates/systemd/elasticsearch.j2 index 35c48a1..8d400de 100644 --- a/templates/systemd/elasticsearch.j2 +++ b/templates/systemd/elasticsearch.j2 @@ -7,7 +7,7 @@ After=network-online.target [Service] Environment=ES_HOME={{es_home}} Environment=CONF_DIR={{conf_dir}} -Environment=DATA_DIR={{data_dir}} +Environment=DATA_DIR={{ data_dirs | array_to_str }} Environment=LOG_DIR={{log_dir}} Environment=PID_DIR={{pid_dir}} EnvironmentFile=-{{instance_default_file}} diff --git a/test/integration/config.yml b/test/integration/config.yml index 9bd8936..df13fe1 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_dir: "/opt/elasticsearch/data", 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_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 f8266fb..cf13ba3 100644 --- a/test/integration/helpers/serverspec/config_spec.rb +++ b/test/integration/helpers/serverspec/config_spec.rb @@ -30,7 +30,7 @@ shared_examples 'config::init' do |es_version| it { should contain 'bootstrap.mlockall: true' } it { should contain 'discovery.zen.ping.unicast.hosts: localhost:9301' } it { should contain 'path.conf: /etc/elasticsearch/node1' } - it { should contain 'path.data: /opt/elasticsearch/data/localhost-node1' } + it { should contain 'path.data: /opt/elasticsearch/data-1/localhost-node1,/opt/elasticsearch/data-2/localhost-node1' } it { should contain 'path.work: /opt/elasticsearch/temp/localhost-node1' } it { should contain 'path.logs: /opt/elasticsearch/logs/localhost-node1' } end @@ -41,7 +41,12 @@ shared_examples 'config::init' do |es_version| it { should be_owned_by 'elasticsearch' } end - describe file('/opt/elasticsearch/data/localhost-node1') do + describe file('/opt/elasticsearch/data-1/localhost-node1') do + it { should be_directory } + it { should be_owned_by 'elasticsearch' } + end + + describe file('/opt/elasticsearch/data-2/localhost-node1') do it { should be_directory } it { should be_owned_by 'elasticsearch' } end @@ -82,6 +87,27 @@ shared_examples 'config::init' do |es_version| end end + + describe file('/etc/init.d/elasticsearch') do + it { should_not exist } + end + + describe file('/etc/default/elasticsearch') do + it { should_not exist } + end + + describe file('/etc/sysconfig/elasticsearch') do + it { should_not exist } + end + + describe file('/usr/lib/systemd/system/elasticsearch.service') do + it { should_not exist } + end + + describe file('/etc/elasticsearch/elasticsearch.yml') do + it { should_not exist } + end + #Not copied on Debian 8 #describe file('/usr/lib/systemd/system/node1_elasticsearch.service') do # it { should be_file } diff --git a/test/integration/helpers/serverspec/multi_spec.rb b/test/integration/helpers/serverspec/multi_spec.rb index 74a8f58..1042ef6 100644 --- a/test/integration/helpers/serverspec/multi_spec.rb +++ b/test/integration/helpers/serverspec/multi_spec.rb @@ -29,7 +29,7 @@ shared_examples 'multi::init' do |es_version,plugins| it { should contain 'node.name: localhost-node1' } it { should_not contain 'bootstrap.mlockall: true' } it { should contain 'path.conf: /etc/elasticsearch/node1' } - it { should contain 'path.data: /var/lib/elasticsearch/localhost-node1' } + it { should contain 'path.data: /opt/elasticsearch/data-1/localhost-node1,/opt/elasticsearch/data-2/localhost-node1' } it { should contain 'path.work: /tmp/elasticsearch/localhost-node1' } it { should contain 'path.logs: /var/log/elasticsearch/localhost-node1' } end @@ -46,7 +46,7 @@ shared_examples 'multi::init' do |es_version,plugins| it { should contain 'node.name: localhost-master' } it { should contain 'bootstrap.mlockall: true' } it { should contain 'path.conf: /etc/elasticsearch/master' } - it { should contain 'path.data: /opt/elasticsearch/localhost-master' } + it { should contain 'path.data: /opt/elasticsearch/master/localhost-master' } it { should contain 'path.work: /tmp/elasticsearch/localhost-master' } it { should contain 'path.logs: /var/log/elasticsearch/localhost-master' } end @@ -129,16 +129,18 @@ shared_examples 'multi::init' do |es_version,plugins| end #Confirm that the data directory has only been set for the first node - describe file('/opt/elasticsearch/localhost-master') do + describe file('/opt/elasticsearch/master/localhost-master') do it { should be_directory } it { should be_owned_by 'elasticsearch' } end - describe file('/opt/elasticsearch/localhost-node1') do - it { should_not exist } + describe file('/opt/elasticsearch/data-1/localhost-node1') do + it { should be_directory } + it { should be_owned_by 'elasticsearch' } end - describe file('/var/lib/elasticsearch/localhost-node1') do + + describe file('/opt/elasticsearch/data-2/localhost-node1') do it { should be_directory } it { should be_owned_by 'elasticsearch' } end @@ -203,6 +205,25 @@ shared_examples 'multi::init' do |es_version,plugins| end end + describe file('/etc/init.d/elasticsearch') do + it { should_not exist } + end + + describe file('/etc/default/elasticsearch') do + it { should_not exist } + end + + describe file('/etc/sysconfig/elasticsearch') do + it { should_not exist } + end + + describe file('/usr/lib/systemd/system/elasticsearch.service') do + it { should_not exist } + end + + describe file('/etc/elasticsearch/elasticsearch.yml') do + it { should_not exist } + end diff --git a/test/integration/helpers/serverspec/package_spec.rb b/test/integration/helpers/serverspec/package_spec.rb index fe99c69..1e4218e 100644 --- a/test/integration/helpers/serverspec/package_spec.rb +++ b/test/integration/helpers/serverspec/package_spec.rb @@ -83,5 +83,25 @@ shared_examples 'package::init' do |es_version,plugins| end end + describe file('/etc/init.d/elasticsearch') do + it { should_not exist } + end + + describe file('/etc/default/elasticsearch') do + it { should_not exist } + end + + describe file('/etc/sysconfig/elasticsearch') do + it { should_not exist } + end + + describe file('/usr/lib/systemd/system/elasticsearch.service') do + it { should_not exist } + end + + describe file('/etc/elasticsearch/elasticsearch.yml') do + it { should_not exist } + end + end diff --git a/test/integration/helpers/serverspec/standard_spec.rb b/test/integration/helpers/serverspec/standard_spec.rb index a79fde0..05b8e0e 100644 --- a/test/integration/helpers/serverspec/standard_spec.rb +++ b/test/integration/helpers/serverspec/standard_spec.rb @@ -63,5 +63,9 @@ shared_examples 'standard::init' do |es_version| it { should_not exist } end + describe file('/etc/elasticsearch/elasticsearch.yml') do + it { should_not exist } + end + end diff --git a/test/integration/multi.yml b/test/integration/multi.yml index 33b9534..e291fcb 100644 --- a/test/integration/multi.yml +++ b/test/integration/multi.yml @@ -3,8 +3,8 @@ - name: Elasticsearch Multi tests hosts: localhost roles: - - { role: elasticsearch, es_instance_name: "master", es_data_dir: "/opt/elasticsearch", es_heap_size: "1g", es_config: { "discovery.zen.ping.multicast.enabled": false, discovery.zen.ping.unicast.hosts: "localhost:9300", http.port: 9200, transport.tcp.port: 9300, node.data: false, node.master: true, bootstrap.mlockall: true, discovery.zen.ping.multicast.enabled: false } } - - { role: elasticsearch, es_instance_name: "node1", es_config: { "discovery.zen.ping.multicast.enabled": false, discovery.zen.ping.unicast.hosts: "localhost:9300", http.port: 9201, transport.tcp.port: 9301, node.data: true, node.master: false, discovery.zen.ping.multicast.enabled: false } } + - { role: elasticsearch, es_instance_name: "master", es_data_dirs: ["/opt/elasticsearch/master"], es_heap_size: "1g", es_config: { "discovery.zen.ping.multicast.enabled": false, discovery.zen.ping.unicast.hosts: "localhost:9300", http.port: 9200, transport.tcp.port: 9300, 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_config: { "discovery.zen.ping.multicast.enabled": false, discovery.zen.ping.unicast.hosts: "localhost:9300", http.port: 9201, transport.tcp.port: 9301, node.data: true, node.master: false, discovery.zen.ping.multicast.enabled: false } } vars: es_scripts: true es_templates: true From b4342170d4235998b9b8521309b379dbcb8bfc40 Mon Sep 17 00:00:00 2001 From: Dale McDiarmid Date: Fri, 18 Mar 2016 20:50:55 +0000 Subject: [PATCH 04/14] Attempted fix at issues associated with kitchen OS test --- .kitchen.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.kitchen.yml b/.kitchen.yml index 4874b31..c3031ba 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -21,6 +21,7 @@ platforms: - apt-get update && apt-get install -y software-properties-common && add-apt-repository -y ppa:ansible/ansible - apt-get update && apt-get -y -q install ansible python-apt python-pycurl use_sudo: false + ansible_platform: ubuntu - name: debian-7 driver_config: image: electrical/debian:7.3 @@ -31,6 +32,7 @@ platforms: - apt-get install -y -q ansible - apt-get install -y -q net-tools use_sudo: false + ansible_platform: debian - name: debian-8 driver_config: image: electrical/debian:8 @@ -44,11 +46,13 @@ platforms: - sed -ri 's/^#?UsePAM .*/UsePAM no/' /etc/ssh/sshd_config use_sudo: false run_command: "/sbin/init" + ansible_platform: debian - name: centos-6 driver_config: image: electrical/centos:6.4-1 privileged: true use_sudo: false + ansible_platform: centos - name: centos-7 driver_config: image: electrical/centos:7 @@ -61,6 +65,7 @@ platforms: run_command: "/usr/sbin/init" privileged: true use_sudo: false + ansible_platform: centos suites: - name: standard-2x From ed8ca6f2714935e326d20a4cea57fbdcb9caf5c3 Mon Sep 17 00:00:00 2001 From: Dale McDiarmid Date: Fri, 18 Mar 2016 21:17:25 +0000 Subject: [PATCH 05/14] Proxy disabled --- .kitchen.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.kitchen.yml b/.kitchen.yml index c3031ba..e705f18 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -8,9 +8,9 @@ provisioner: roles_path: ../ require_ansible_repo: true ansible_verbose: true - http_proxy: <%= ENV['HTTP_PROXY'] %> - https_proxy: <%= ENV['HTTPS_PROXY'] %> - no_proxy: localhost,127.0.0.1 + #http_proxy: <%= ENV['HTTP_PROXY'] %> + #https_proxy: <%= ENV['HTTPS_PROXY'] %> + #no_proxy: localhost,127.0.0.1 platforms: - name: ubuntu-14.04 From 25e5620fb7a74152064f17b81ab96ace14221338 Mon Sep 17 00:00:00 2001 From: Dale McDiarmid Date: Fri, 18 Mar 2016 21:42:32 +0000 Subject: [PATCH 06/14] Gemfile spec for ansible kitchen --- .kitchen.yml | 11 +++-------- Gemfile | 2 +- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/.kitchen.yml b/.kitchen.yml index e705f18..4874b31 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -8,9 +8,9 @@ provisioner: roles_path: ../ require_ansible_repo: true ansible_verbose: true - #http_proxy: <%= ENV['HTTP_PROXY'] %> - #https_proxy: <%= ENV['HTTPS_PROXY'] %> - #no_proxy: localhost,127.0.0.1 + http_proxy: <%= ENV['HTTP_PROXY'] %> + https_proxy: <%= ENV['HTTPS_PROXY'] %> + no_proxy: localhost,127.0.0.1 platforms: - name: ubuntu-14.04 @@ -21,7 +21,6 @@ platforms: - apt-get update && apt-get install -y software-properties-common && add-apt-repository -y ppa:ansible/ansible - apt-get update && apt-get -y -q install ansible python-apt python-pycurl use_sudo: false - ansible_platform: ubuntu - name: debian-7 driver_config: image: electrical/debian:7.3 @@ -32,7 +31,6 @@ platforms: - apt-get install -y -q ansible - apt-get install -y -q net-tools use_sudo: false - ansible_platform: debian - name: debian-8 driver_config: image: electrical/debian:8 @@ -46,13 +44,11 @@ platforms: - sed -ri 's/^#?UsePAM .*/UsePAM no/' /etc/ssh/sshd_config use_sudo: false run_command: "/sbin/init" - ansible_platform: debian - name: centos-6 driver_config: image: electrical/centos:6.4-1 privileged: true use_sudo: false - ansible_platform: centos - name: centos-7 driver_config: image: electrical/centos:7 @@ -65,7 +61,6 @@ platforms: run_command: "/usr/sbin/init" privileged: true use_sudo: false - ansible_platform: centos suites: - name: standard-2x diff --git a/Gemfile b/Gemfile index cd4bcfb..dc71783 100644 --- a/Gemfile +++ b/Gemfile @@ -2,5 +2,5 @@ source 'https://rubygems.org' gem 'test-kitchen' gem "kitchen-docker", '< 2.2.0' -gem 'kitchen-ansible' +gem 'kitchen-ansible', '0.0.38' gem 'net-ssh', '~> 2.0' From 378fb6302d09d0d9781769038026966bb38cec6d Mon Sep 17 00:00:00 2001 From: Dale McDiarmid Date: Fri, 18 Mar 2016 21:58:05 +0000 Subject: [PATCH 07/14] Earlier kitchen ansible --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index dc71783..c40767e 100644 --- a/Gemfile +++ b/Gemfile @@ -2,5 +2,5 @@ source 'https://rubygems.org' gem 'test-kitchen' gem "kitchen-docker", '< 2.2.0' -gem 'kitchen-ansible', '0.0.38' +gem 'kitchen-ansible', '0.0.36' gem 'net-ssh', '~> 2.0' From ce56bb6e4893ec256d05a3e39cbc8c03379521ea Mon Sep 17 00:00:00 2001 From: Dale McDiarmid Date: Fri, 18 Mar 2016 22:25:26 +0000 Subject: [PATCH 08/14] Change in Gem File --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index c40767e..69b9fa7 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source 'https://rubygems.org' -gem 'test-kitchen' +gem 'test-kitchen', '1.4.2' gem "kitchen-docker", '< 2.2.0' gem 'kitchen-ansible', '0.0.36' gem 'net-ssh', '~> 2.0' From 65b6f966bf7ce93bc7188e7ea2cfbfb7cd1d8dba Mon Sep 17 00:00:00 2001 From: Dale McDiarmid Date: Fri, 18 Mar 2016 23:19:02 +0000 Subject: [PATCH 09/14] Remove Gem --- Gemfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Gemfile b/Gemfile index 69b9fa7..cb78f52 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,5 @@ source 'https://rubygems.org' -gem 'test-kitchen', '1.4.2' gem "kitchen-docker", '< 2.2.0' gem 'kitchen-ansible', '0.0.36' gem 'net-ssh', '~> 2.0' From abf422e0e33a29e3a95ff9d2f44ac5c940f21815 Mon Sep 17 00:00:00 2001 From: Dale McDiarmid Date: Mon, 21 Mar 2016 11:17:21 +0000 Subject: [PATCH 10/14] Moving to gem file 0.40.1 for kitchen ansible --- Gemfile | 3 ++- tasks/elasticsearch-config.yml | 4 ---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index cb78f52..8607482 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,6 @@ source 'https://rubygems.org' +gem 'test-kitchen' gem "kitchen-docker", '< 2.2.0' -gem 'kitchen-ansible', '0.0.36' +gem 'kitchen-ansible', '0.40.1' gem 'net-ssh', '~> 2.0' diff --git a/tasks/elasticsearch-config.yml b/tasks/elasticsearch-config.yml index d5e6435..28a421d 100644 --- a/tasks/elasticsearch-config.yml +++ b/tasks/elasticsearch-config.yml @@ -35,12 +35,8 @@ - "{{conf_dir}}" - "{{plugin_dir}}" -- debug: msg="Data Dirs {{es_data_dirs}}" - - set_fact: data_dirs={{ es_data_dirs | append_to_list('/'+instance_suffix) }} -- debug: msg="Data Dirs {{data_dirs}}" - - name: Create Data Directories file: path={{ item }} state=directory owner={{ es_user }} group={{ es_group }} with_items: From b8a077e8bd8280ce6702e95a2156267f2b735aab Mon Sep 17 00:00:00 2001 From: Dale McDiarmid Date: Mon, 21 Mar 2016 12:28:07 +0000 Subject: [PATCH 11/14] Fixes for ansible version not consistent across images --- .kitchen.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.kitchen.yml b/.kitchen.yml index 4874b31..0348eaf 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -26,9 +26,8 @@ platforms: image: electrical/debian:7.3 privileged: true provision_command: - - echo 'deb http://http.debian.net/debian/ wheezy-backports main' >> /etc/apt/sources.list - - apt-get update - - apt-get install -y -q ansible + - apt-get update && apt-get -y install python python-dev python-pip build-essential libyaml-dev python-yaml + - pip install ansible - apt-get install -y -q net-tools use_sudo: false - name: debian-8 @@ -36,8 +35,8 @@ platforms: image: electrical/debian:8 privileged: true provision_command: - - apt-get update - - apt-get install -y -q ansible + - apt-get update && apt-get -y install python python-dev python-pip build-essential libyaml-dev python-yaml + - pip install ansible - apt-get install -y -q net-tools - sed -ri 's/^#?PermitRootLogin .*/PermitRootLogin yes/' /etc/ssh/sshd_config - sed -ri 's/^#?PasswordAuthentication .*/PasswordAuthentication yes/' /etc/ssh/sshd_config @@ -48,11 +47,17 @@ platforms: driver_config: image: electrical/centos:6.4-1 privileged: true + provision_command: + - yum -y install gmp-devel python-devel python-pip + - pip install ansible use_sudo: false - name: centos-7 driver_config: image: electrical/centos:7 provision_command: + - 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 cea57cdd734c1eadfb861e6ff2fb95c1a92d016f Mon Sep 17 00:00:00 2001 From: Dale McDiarmid Date: Mon, 21 Mar 2016 13:21:35 +0000 Subject: [PATCH 12/14] Scripts and Templates to use default files directory --- .gitignore | 1 - tasks/elasticsearch-config.yml | 4 ++-- tasks/elasticsearch-scripts.yml | 7 +++++-- tasks/elasticsearch-templates.yml | 8 +++++++- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 3a02b2e..0bb96d7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ .kitchen/ -.kitchen.local.yml *.lock .vendor .bundle diff --git a/tasks/elasticsearch-config.yml b/tasks/elasticsearch-config.yml index 28a421d..70a1f42 100644 --- a/tasks/elasticsearch-config.yml +++ b/tasks/elasticsearch-config.yml @@ -56,13 +56,13 @@ #Copy the instance specific init file - name: Copy Debian Init File for Instance template: src=init/debian/elasticsearch.j2 dest={{instance_init_script}} mode=0755 force=yes - when: ansible_os_family == 'Debian' + when: ansible_os_family == 'Debian' and not use_system_d notify: restart elasticsearch #Copy the instance specific init file - name: Copy Redhat Init File for Instance template: src=init/redhat/elasticsearch.j2 dest={{instance_init_script}} mode=0755 force=yes - when: ansible_os_family == 'RedHat' + when: ansible_os_family == 'RedHat' and not use_system_d notify: restart elasticsearch #Copy the systemd specific file if systemd is installed diff --git a/tasks/elasticsearch-scripts.yml b/tasks/elasticsearch-scripts.yml index 6d7d297..aa363e8 100644 --- a/tasks/elasticsearch-scripts.yml +++ b/tasks/elasticsearch-scripts.yml @@ -7,8 +7,11 @@ - name: Create script dir file: state=directory path={{ es_script_dir }} owner={{ es_user }} group={{ es_group }} - when: es_config['path.scripts'] is defined + +- name: Copy default scripts to elasticsearch + copy: src=scripts dest={{ es_script_dir }} owner={{ es_user }} group={{ es_group }} + when: es_scripts_fileglob is not defined - name: Copy scripts to elasticsearch copy: src={{ item }} dest={{ es_script_dir }} owner={{ es_user }} group={{ es_group }} - with_fileglob: es_scripts_fileglob | default("scripts") + with_fileglob: es_scripts_fileglob diff --git a/tasks/elasticsearch-templates.yml b/tasks/elasticsearch-templates.yml index ba46fd8..0fe3a0f 100644 --- a/tasks/elasticsearch-templates.yml +++ b/tasks/elasticsearch-templates.yml @@ -1,8 +1,14 @@ --- +- file: path=/etc/elasticsearch/templates state=directory owner={{ es_user }} group={{ es_group }} + +- name: Copy default templates to elasticsearch + copy: src=templates dest=/etc/elasticsearch/ owner={{ es_user }} group={{ es_group }} + when: es_templates_fileglob is not defined + - name: Copy templates to elasticsearch copy: src={{ item }} dest=/etc/elasticsearch/ owner={{ es_user }} group={{ es_group }} - with_fileglob: es_templates_fileglob | default("templates") + with_fileglob: es_templates_fileglob - set_fact: http_port=9200 From 870035b385cba0713d601ca6fe4701b8c5f37ca2 Mon Sep 17 00:00:00 2001 From: Dale McDiarmid Date: Mon, 21 Mar 2016 14:34:43 +0000 Subject: [PATCH 13/14] Fixes for evaluating systemd and init --- .../helpers/serverspec/config_spec.rb | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/test/integration/helpers/serverspec/config_spec.rb b/test/integration/helpers/serverspec/config_spec.rb index cf13ba3..979e5d5 100644 --- a/test/integration/helpers/serverspec/config_spec.rb +++ b/test/integration/helpers/serverspec/config_spec.rb @@ -61,10 +61,6 @@ shared_examples 'config::init' do |es_version| it { should be_owned_by 'elasticsearch' } end - describe file('/etc/init.d/node1_elasticsearch') do - it { should be_file } - end - #test we started on the correct port was used describe command('curl -s "localhost:9201"') do #TODO: This is returning an empty string @@ -87,7 +83,6 @@ shared_examples 'config::init' do |es_version| end end - describe file('/etc/init.d/elasticsearch') do it { should_not exist } end @@ -108,11 +103,23 @@ shared_examples 'config::init' do |es_version| it { should_not exist } end - #Not copied on Debian 8 - #describe file('/usr/lib/systemd/system/node1_elasticsearch.service') do - # it { should be_file } - # it { should contain 'LimitMEMLOCK=infinity' } - #end + #Init vs Systemd tests + #Ubuntu 15 and up + #Debian 8 and up + #Centos 7 and up + + if ((os[:family] == 'centos' && os[:release].to_f >= 7.0) || + (os[:family] == 'ubuntu' && os[:release].to_f >= 15.0) || + (os[:family] == 'debian' && os[:release].to_f >= 8.0)) + describe file('/usr/lib/systemd/system/node1_elasticsearch.service') do + it { should be_file } + it { should contain 'LimitMEMLOCK=infinity' } + end + else + describe file('/etc/init.d/node1_elasticsearch') do + it { should be_file } + end + end end From f55f5c3c01037be6b17a86a13a8631521abc90a7 Mon Sep 17 00:00:00 2001 From: Dale McDiarmid Date: Mon, 21 Mar 2016 16:40:10 +0000 Subject: [PATCH 14/14] Fix for checking init and systemd in scripts --- test/integration/helpers/serverspec/config_spec.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/integration/helpers/serverspec/config_spec.rb b/test/integration/helpers/serverspec/config_spec.rb index 979e5d5..7eeb44c 100644 --- a/test/integration/helpers/serverspec/config_spec.rb +++ b/test/integration/helpers/serverspec/config_spec.rb @@ -103,13 +103,12 @@ shared_examples 'config::init' do |es_version| it { should_not exist } end - #Init vs Systemd tests #Ubuntu 15 and up #Debian 8 and up #Centos 7 and up - if ((os[:family] == 'centos' && os[:release].to_f >= 7.0) || + if (((os[:family] == 'redhat' || os[:family] == 'centos') && os[:release].to_f >= 7.0) || (os[:family] == 'ubuntu' && os[:release].to_f >= 15.0) || (os[:family] == 'debian' && os[:release].to_f >= 8.0)) describe file('/usr/lib/systemd/system/node1_elasticsearch.service') do