Commit a2e41c15 by e0d

Merge pull request #738 from edx/e0d/es-cluster

E0d/es cluster
parents add10296 545d3ebf
- hosts: tag_play_elasticsearch:&tag_environment_stage:&tag_deployment_edx
sudo: True
vars_files:
- "{{ secure_dir }}/vars/common/common.yml"
- "{{ secure_dir }}/vars/stage/stage-edx.yml"
roles:
- common
- gh_users
- oraclejdk
- elasticsearch
--- ---
elasticsearch_app_dir: "{{ COMMON_APP_DIR }}/elasticsearch"
elasticsearch_version: "0.90.2" elasticsearch_data_dir: "{{ COMMON_DATA_DIR }}/elasticsearch"
elasticsearch_sha: "397227ce37f616734f39f6e93539c9eaa82bec9" elasticsearch_log_dir: "{{ COMMON_LOG_DIR }}/elasticsearch"
elasticsearch_cfg_dir: "{{ COMMON_CFG_DIR }}/elasticsearch"
elasticsearch_version: "0.90.11"
elasticsearch_sha: "8e81388d0ba7e427b42514d96e25ba6499024c24"
elasticsearch_file: "elasticsearch-{{ elasticsearch_version }}.deb" elasticsearch_file: "elasticsearch-{{ elasticsearch_version }}.deb"
elasticsearch_url: "https://download.elasticsearch.org/elasticsearch/elasticsearch/{{ elasticsearch_file }}" elasticsearch_url: "https://download.elasticsearch.org/elasticsearch/elasticsearch/{{ elasticsearch_file }}"
elasticsearch_user: "elasticsearch"
elasticsearch_group: "elasticsearch"
#
# Defaults for a single server installation.
ELASTICSEARCH_CLUSTERED: true
ELASTICSEARCH_HEAP_SIZE: "512m"
\ No newline at end of file
...@@ -8,29 +8,61 @@ ...@@ -8,29 +8,61 @@
# * oraclejdk # * oraclejdk
# #
# Example play: # Example play:
#
# This role can be used to do a single-server or clustered
# installation of the elasticsearch service. When a cluster
# is being installed, there are two important things that
# you must know.
# The ELASTICSEARCH_CLUSTERED var must be true.
# All hosts targeted by your play will be cluster peers.
# Elasticsearch will determine who the master should be.
#
# Ansible provides handy set operators for use in the
# plays host declaration, as seen in the following example.
#
# - hosts: tag_role_elasticsearch:&tag_environment_stage
# roles:
# - common
# - oraclejdk
# - elasticsearch
# #
# roles:
# - common
# - oraclejdk
# - elasticsearch
- name: download elasticsearch - name: download elasticsearch
get_url: > get_url: >
url={{ elasticsearch_url }} url={{ elasticsearch_url }}
dest=/var/tmp/{{ elasticsearch_file }} dest=/var/tmp/{{ elasticsearch_file }}
force=no force=no
register: elasticsearch_reinstall
- name: install elasticsearch from local package - name: install elasticsearch from local package
shell: > shell: >
dpkg -i /var/tmp/elasticsearch-{{ elasticsearch_version }}.deb dpkg -i --force-confold /var/tmp/elasticsearch-{{ elasticsearch_version }}.deb
executable=/bin/bash executable=/bin/bash
creates=/usr/share/elasticsearch/bin/elasticsearch when: elasticsearch_reinstall.changed
tags:
- elasticsearch - name: create directories
- install file: >
path="{{ item }}"
state=directory
owner="{{ elasticsearch_user }}"
group="{{ elasticsearch_group }}"
with_items:
- "{{ elasticsearch_data_dir }}"
- "{{ elasticsearch_log_dir }}"
- "{{ elasticsearch_cfg_dir }}"
- name: update elasticsearch defaults
template: >
src=etc/default/elasticsearch.j2 dest=/etc/default/elasticsearch
when: ELASTICSEARCH_CLUSTERED
- name: drop the elasticsearch config
template: >
src=edx/etc/elasticsearch/elasticsearch.yml.j2 dest={{ elasticsearch_cfg_dir }}/elasticsearch.yml
mode=0744
when: ELASTICSEARCH_CLUSTERED
- name: Ensure elasticsearch is enabled and started - name: Ensure elasticsearch is enabled and started
service: name=elasticsearch state=started enabled=yes service: name=elasticsearch state=restarted enabled=yes
tags: \ No newline at end of file
- elasticsearch
- install
# {{ ansible_managed }}
# Path to directory where to store index data allocated for this node.
#
path.data: {{elasticsearch_data_dir}}
# Path to log files:
#
path.logs: {{elasticsearch_log_dir}}
# ElasticSearch performs poorly when JVM starts swapping: you should ensure that
# it _never_ swaps.
#
# Set this property to true to lock the memory:
#
bootstrap.mlockall: true
# Unicast discovery allows to explicitly control which nodes will be used
# to discover the cluster. It can be used when multicast is not present,
# or to restrict the cluster communication-wise.
#
# 1. Disable multicast discovery (enabled by default):
#
# discovery.zen.ping.multicast.enabled: false
#
# 2. Configure an initial list of master nodes in the cluster
# to perform discovery when new nodes (master or data) are started:
#
# discovery.zen.ping.unicast.hosts: ["host1", "host2:port", "host3[portX-portY]"]
{%- if ELASTICSEARCH_CLUSTERED -%}
{%- set hosts= [] -%}
{%- for host in hostvars.keys() -%}
{% do hosts.append(host) %}
{%- endfor %}
discovery.zen.ping.unicast.hosts: ['{{hosts|join("\',\'") }}']
{% endif -%}
\ No newline at end of file
# {{ ansible_managed }}
# Run ElasticSearch as this user ID and group ID
#ES_USER=elasticsearch
#ES_GROUP=elasticsearch
# Heap Size (defaults to 256m min, 1g max)
ES_HEAP_SIZE={{ ELASTICSEARCH_HEAP_SIZE }}
# Heap new generation
#ES_HEAP_NEWSIZE=
# max direct memory
#ES_DIRECT_SIZE=
# Maximum number of open files, defaults to 65535.
#MAX_OPEN_FILES=65535
# Maximum locked memory size. Set to "unlimited" if you use the
# bootstrap.mlockall option in elasticsearch.yml. You must also set
# ES_HEAP_SIZE.
#MAX_LOCKED_MEMORY=unlimited
# ElasticSearch log directory
LOG_DIR={{ elasticsearch_log_dir }}
# ElasticSearch data directory
DATA_DIR={{ COMMON_DATA_DIR }}
# ElasticSearch work directory
#WORK_DIR=/tmp/elasticsearch
# ElasticSearch configuration directory
CONF_DIR={{ elasticsearch_cfg_dir }}
# ElasticSearch configuration file (elasticsearch.yml)
# CONF_FILE=/etc/elasticsearch/elasticsearch.yml
# Additional Java OPTS
#ES_JAVA_OPTS=
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment