Support for mlock with tests

This commit is contained in:
Dale McDiarmid 2015-11-26 14:19:25 +00:00
parent f2621c4af9
commit dc9b2dd53c
6 changed files with 34 additions and 10 deletions

View file

@ -3,7 +3,7 @@
allow_duplicates: yes
galaxy_info:
author: Robin Clarke
author: Robin Clarke, Jakob Reiter, Dale McDiarmid
description: Elasticsearch for Linux
company: "Elastic.co"
license: "license (Apache)"

View file

@ -4,12 +4,14 @@
when: es_instance_name is not defined
- fail: msg="Parameter 'http.port' must be defined when multicast is disabled"
when: es_config['discovery.zen.ping.multicast.enabled'] == false or (es_version | version_compare('2.0', '>=') and es_config['discovery.zen.ping.multicast.enabled'] is not defined) and es_config['http.port'] is not defined
when: (es_config['discovery.zen.ping.multicast.enabled'] == False or (es_version | version_compare('2.0', '>=') and es_config['discovery.zen.ping.multicast.enabled'] is not defined)) and es_config['http.port'] is not defined
- fail: msg="Parameter 'transport.tcp.port' must be defined when multicast is disabled"
when: es_config['discovery.zen.ping.multicast.enabled'] == false or (es_version | version_compare('2.0', '>=') and es_config['discovery.zen.ping.multicast.enabled'] is not defined) and es_config['transport.tcp.port'] is not defined
when: (es_config['discovery.zen.ping.multicast.enabled'] == False or (es_version | version_compare('2.0', '>=') and es_config['discovery.zen.ping.multicast.enabled'] is not defined)) and es_config['transport.tcp.port'] is not defined
- fail: msg="Parameter 'discovery.zen.ping.unicast.hosts' must be defined when multicast is disabled"
when: es_config['discovery.zen.ping.multicast.enabled'] == false or (es_version | version_compare('2.0', '>=') and es_config['discovery.zen.ping.multicast.enabled'] is not defined) and es_config['discovery.zen.ping.unicast.hosts'] is not defined
when: (es_config['discovery.zen.ping.multicast.enabled'] == False or (es_version | version_compare('2.0', '>=') and es_config['discovery.zen.ping.multicast.enabled'] is not defined)) and es_config['discovery.zen.ping.unicast.hosts'] is not defined
# If multicast is false OR if > 2.0 AND not defined as true (or explicitly false)
#If the user attempts to lock memory they must specify a heap size
- fail: msg="If locking memory with bootstrap.mlockall a heap size must be specified"
when: es_config['bootstrap.mlockall'] == True and es_heap_size is not defined

View file

@ -111,9 +111,25 @@
register: elasticsearch_configure
when: ansible_os_family == 'RedHat'
#Copy the logging.yml - TODO: i.e we may template this.
#Copy the logging.yml
- name: Copy Logging.yml for Instance
command: creates={{instance_config_directory}}/logging.yml cp "{{ es_conf_dir }}/logging.yml" "{{instance_config_directory}}/logging.yml"
when: instance_init_script != init_script
- file: path={{instance_config_directory}}/logging.yml state=touch owner={{ es_user }} group={{ es_group }}
- file: path={{instance_config_directory}}/logging.yml state=touch owner={{ es_user }} group={{ es_group }}
#Configure mlock if enabled
- name: Configure mlock
lineinfile: dest={{instance_default_file}} regexp="^MAX_LOCKED_MEMORY" insertafter="^#MAX_LOCKED_MEMORY" line="MAX_LOCKED_MEMORY=unlimited"
when: es_config['bootstrap.mlockall'] is defined and es_config['bootstrap.mlockall'] == True
register: elasticsearch_configure
#Change for systemd setting to ensure mlock is achieved
- stat: path=/usr/lib/systemd/system/elasticsearch.service
register: systemd_service
- name: Configure systemd
lineinfile: dest=/usr/lib/systemd/system/elasticsearch.service regexp="^LimitMEMLOCK" insertafter="^#LimitMEMLOCK" line="LimitMEMLOCK=infinity"
when: es_config['bootstrap.mlockall'] is defined and es_config['bootstrap.mlockall'] == True and systemd_service.stat.exists == True
register: elasticsearch_configure

View file

@ -24,12 +24,12 @@
# Make sure the service is started, and restart if necessary
- name: Start elasticsearch service
service: name={{instance_init_script | basename}} state=started
service: name={{instance_init_script | basename}} state=started enabled=yes
when: es_start_service
register: elasticsearch_started
- name: Restart elasticsearch service if new version installed
service: name={{instance_init_script | basename}} state=restarted
service: name={{instance_init_script | basename}} state=restarted enabled=yes
when: es_start_service and
( elasticsearch_install.changed or elasticsearch_configure.changed )
and not elasticsearch_started.changed

View file

@ -8,4 +8,5 @@
vars:
es_scripts: false
es_templates: false
es_version_lock: false
es_version_lock: false
es_heap_size: 1g

View file

@ -67,6 +67,11 @@ context "basic tests" do
its(:exit_status) { should eq 0 }
end
#test to make sure mlock was applied
describe command('curl "localhost:9201/_nodes/process?pretty" | grep mlockall') do
its(:stdout) { should match /\"mlockall\" : true/ }
its(:exit_status) { should eq 0 }
end
end