Support for scripts

This commit is contained in:
Dale McDiarmid 2015-11-25 17:13:45 +00:00
parent d25fc792b6
commit bdb9ee6a4a
13 changed files with 53 additions and 14 deletions

View file

@ -14,4 +14,4 @@ es_group: elasticsearch
es_pid_dir: "/var/run/elasticsearch" es_pid_dir: "/var/run/elasticsearch"
es_data_dir: "/var/lib/elasticsearch" es_data_dir: "/var/lib/elasticsearch"
es_log_dir: "/var/log/elasticsearch" es_log_dir: "/var/log/elasticsearch"
es_work_dir: "/tmp/elasticsearch" es_work_dir: "/tmp/elasticsearch"

View file

@ -13,4 +13,4 @@
when: es_config['discovery.zen.ping.multicast.enabled'] == false and es_config['discovery.zen.ping.unicast.hosts'] is not defined when: es_config['discovery.zen.ping.multicast.enabled'] == false 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 explictly false) # If multicast is false OR if > 2.0 AND not defined as true (or explicitly false)

View file

@ -1,3 +1,12 @@
--- ---
- set_fact: es_script_dir={{ es_log_dir }}/{{inventory_hostname}}-{{ es_instance_name }}
- set_fact: es_script_dir={{es_config['path.scripts']}}
when: es_config['path.scripts'] is not defined
- name: Create script dir
file: state=directory path={{ es_script_dir }} owner={{ es_user }} group={{ es_group }}
- name: Copy scripts to elasticsearch - name: Copy scripts to elasticsearch
copy: src=scripts dest=/etc/elasticsearch/ copy: src=scripts dest={{ es_scripts_dir }}

View file

@ -7,8 +7,8 @@
- include: elasticsearch.yml - include: elasticsearch.yml
- include: elasticsearch-plugins.yml - include: elasticsearch-plugins.yml
when: es_plugins is defined when: es_plugins is defined
#- include: elasticsearch-scripts.yml - include: elasticsearch-scripts.yml
# when: es_scripts when: es_scripts
#- include: elasticsearch-templates.yml #- include: elasticsearch-templates.yml
# when: es_templates # when: es_templates

View file

@ -17,4 +17,8 @@ path.data: {{ data_dir }}
path.work: {{ work_dir }} path.work: {{ work_dir }}
path.logs: {{ log_dir }} path.logs: {{ log_dir }}
{% if es_scripts and es_config['path.scripts'] is not defined %}
path.scripts: {{ es_conf_dir }}/{{es_instance_name}}/scripts
{% endif %}

View file

@ -4,7 +4,7 @@
hosts: localhost hosts: localhost
roles: roles:
#expand to all available parameters #expand to all available parameters
- { role: elasticsearch, es_instance_name: "node1", 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_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 } }
vars: vars:
es_scripts: false es_scripts: false
es_templates: false es_templates: false

View file

@ -30,9 +30,34 @@ context "basic tests" do
it { should contain 'bootstrap.mlockall: true' } it { should contain 'bootstrap.mlockall: true' }
it { should contain 'discovery.zen.ping.unicast.hosts: localhost:9301' } it { should contain 'discovery.zen.ping.unicast.hosts: localhost:9301' }
it { should contain 'path.conf: /etc/elasticsearch/node1' } 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/localhost-node1' }
it { should contain 'path.work: /tmp/elasticsearch/localhost-node1' } it { should contain 'path.work: /opt/elasticsearch/temp/localhost-node1' }
it { should contain 'path.logs: /var/log/elasticsearch/localhost-node1' } it { should contain 'path.logs: /opt/elasticsearch/logs/localhost-node1' }
end
#test directories exist
describe file('/etc/elasticsearch/node1') do
it { should be_directory }
it { should be_owned_by 'elasticsearch' }
end
describe file('/opt/elasticsearch/data/localhost-node1') do
it { should be_directory }
it { should be_owned_by 'elasticsearch' }
end
describe file('/opt/elasticsearch/logs/localhost-node1') do
it { should be_directory }
it { should be_owned_by 'elasticsearch' }
end
describe file('/opt/elasticsearch/temp/localhost-node1') do
it { should be_directory }
it { should be_owned_by 'elasticsearch' }
end
describe file('/etc/init.d/node1_elasticsearch') do
it { should be_file }
end end
#test we started on the correct port was used #test we started on the correct port was used

View file

@ -3,4 +3,5 @@
hosts: localhost hosts: localhost
roles: roles:
- { role: elasticsearch, es_config: { "discovery.zen.ping.multicast.enabled": true }, es_instance_name: "node1" } - { role: elasticsearch, es_config: { "discovery.zen.ping.multicast.enabled": true }, es_instance_name: "node1" }
vars: vars:
es_scripts: true

View file

@ -0,0 +1 @@
log(_score * 2) + my_modifier

View file

@ -20,7 +20,7 @@ context "basic tests" do
describe file('/etc/elasticsearch/node1/elasticsearch.yml') do describe file('/etc/elasticsearch/node1/elasticsearch.yml') do
it { should contain 'node.name: localhost-node1' } it { should contain 'node.name: localhost-node1' }
it { should contain 'cluster.name: "elasticsearch"' } it { should contain 'cluster.name: elasticsearch' }
it { should contain 'path.conf: /etc/elasticsearch/node1' } it { should contain 'path.conf: /etc/elasticsearch/node1' }
it { should contain 'path.data: /var/lib/elasticsearch/localhost-node1' } it { should contain 'path.data: /var/lib/elasticsearch/localhost-node1' }
it { should contain 'path.work: /tmp/elasticsearch/localhost-node1' } it { should contain 'path.work: /tmp/elasticsearch/localhost-node1' }

View file

@ -2,5 +2,4 @@
java: "openjdk-7-jre-headless" java: "openjdk-7-jre-headless"
default_file: "/etc/default/elasticsearch" default_file: "/etc/default/elasticsearch"
init_script: "/etc/init.d/elasticsearch" init_script: "/etc/init.d/elasticsearch"
es_conf_dir: "/etc/elasticsearch"
es_home: "/usr/share/elasticsearch" es_home: "/usr/share/elasticsearch"

View file

@ -2,5 +2,4 @@
java: "java-1.8.0-openjdk.x86_64" java: "java-1.8.0-openjdk.x86_64"
default_file: "/etc/sysconfig/elasticsearch" default_file: "/etc/sysconfig/elasticsearch"
init_script: "/etc/init.d/elasticsearch" init_script: "/etc/init.d/elasticsearch"
es_conf_dir: "/etc/elasticsearch"
es_home: "/usr/share/elasticsearch" es_home: "/usr/share/elasticsearch"

View file

@ -1,2 +1,3 @@
--- ---
es_package_url: "https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch" es_package_url: "https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch"
es_conf_dir: "/etc/elasticsearch"