├── .gitignore ├── .travis.yml ├── README.md ├── Vagrantfile ├── defaults └── main.yml ├── handlers └── main.yml ├── meta └── main.yml ├── tasks ├── aws.yml ├── custom-jars.yml ├── elastic-install.yml ├── java.yml ├── main.yml ├── marvel.yml ├── plugins.yml ├── post-run.yml ├── spm.yml └── timezone.yml ├── templates ├── elasticsearch.default.j2 ├── elasticsearch.in.sh.j2 └── elasticsearch.yml.j2 ├── tests ├── ansible.cfg ├── elastic_test.sh ├── local.ini ├── test1.yml └── test1_var.yml ├── vagrant-inventory.ini ├── vagrant-main.yml └── vars ├── sample.yml └── vagrant.yml /.gitignore: -------------------------------------------------------------------------------- 1 | # Numerous always-ignore extensions 2 | *.diff 3 | *.err 4 | *.orig 5 | *.log 6 | *.rej 7 | *.swo 8 | *.swp 9 | *.vi 10 | *~ 11 | *.sass-cache 12 | *.iml 13 | 14 | # OS or Editor folders 15 | .DS_Store 16 | Thumbs.db 17 | .cache 18 | .project 19 | .classpath 20 | .settings 21 | .tmproj 22 | *.esproj 23 | nbproject 24 | *.sublime-project 25 | *.sublime-workspace 26 | *.ipr 27 | *.iws 28 | 29 | # Folders to ignore 30 | .hg 31 | .svn 32 | .CVS 33 | intermediate 34 | publish 35 | .idea 36 | target 37 | target-eclipse 38 | .vagrant 39 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | language: python 3 | python: "2.7" 4 | 5 | before_install: 6 | # Make sure everything's up to date. 7 | - sudo apt-get update -qq 8 | - sudo apt-get install -qq python-apt python-pycurl 9 | 10 | install: 11 | # Install Ansible. 12 | - pip install ansible 13 | 14 | script: 15 | - cd tests 16 | 17 | - echo -e "\e[31m######AnsibleVersion#######\e[0m" 18 | - ansible --version 19 | 20 | # 1st: check syntax 21 | - echo "\e[31m######***************************** SYNTAX CHECK (1) *****************************\e[0m" 22 | - ansible-playbook -i local.ini test1.yml --syntax-check 23 | 24 | # 2nd: Make sure we run the entire playbook 25 | - echo "***************************** RUN PLAY (2) *****************************" 26 | - ansible-playbook -i local.ini test1.yml --sudo -vvvv --diff 27 | - sudo netstat -antlp | grep LISTEN 28 | - sudo ps aux | grep java 29 | - curl 127.0.0.1:9200 30 | 31 | # 3rd: Make sure our playbook is idempotent 32 | - echo "***************************** Idempotence test (3) *****************************" 33 | - > 34 | ansible-playbook -i local.ini test1.yml --sudo -vvvv --diff | tee ansible_output 35 | | grep -q 'changed=0.*failed=0' 36 | && (echo 'Idempotence test: pass' && exit 0) 37 | || (echo 'Idempotence test: fail' && exit 1) 38 | 39 | # 4th: Application test 40 | - ./elastic_test.sh 41 | 42 | after_failure: 43 | - echo -e "\e[31m######IdepotanceLog#######\e[0m" 44 | - sudo cat ansible_output 45 | - echo -e "\e[31m######netstat#######\e[0m" 46 | - sudo netstat -atnlp 47 | - echo -e "\e[31m######ps#######\e[0m" 48 | - sudo ps aux | grep java 49 | - echo -e "\e[31m######CurlElasticsearch#######\e[0m" 50 | - curl 127.0.0.1:9200 51 | - echo -e "\e[31m######AnsibleFacts#######\e[0m" 52 | - ansible -i 127.0.0.1, -m setup all -c local 53 | 54 | after_success: 55 | - echo -e "\e[0;32m######Cool Success#######\e[0m" 56 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Important Note 2 | This project is no longer actively maintained. We recommend using the official [ansible-elasticsearch](https://github.com/elastic/ansible-elasticsearch) repo which is a lot more comprehensive. 3 | 4 | # Ansible Playbook for Elasticsearch 5 | [![Build Status](https://travis-ci.org/Traackr/ansible-elasticsearch.svg?branch=master)](https://travis-ci.org/Traackr/ansible-elasticsearch) 6 | 7 | This is an [Ansible](http://www.ansibleworks.com/) playbook for [Elasticsearch](http://www.elasticsearch.org/). You can use it by itself or as part of a larger playbook customized for your local environment. 8 | 9 | ## Features 10 | - Support for installing plugins 11 | - Support for installing and configuring EC2 plugin 12 | - Support for installing custom JARs in the Elasticsearch classpath (e.g. custom Lucene Similarity JAR) 13 | - Support for installing the [Sematext SPM](http://www.sematext.com/spm/) monitor 14 | - Support for installing the [Marvel](http://www.elasticsearch.org/guide/en/marvel/current/) plugin 15 | 16 | ## Installing 17 | 18 | Install [ansible-elasticsearch](https://galaxy.ansible.com/list#/roles/181) via ansible galaxy: 19 | 20 | ``` 21 | ansible-galaxy install gpstathis.elasticsearch 22 | ``` 23 | 24 | ## Testing locally with Vagrant 25 | A sample [Vagrant](http://www.vagrantup.com/) configuration is provided to help with local testing. After installing Vagrant, run `vagrant up` at the root of the project to get an VM instance bootstrapped and configured with a running instance of Elasticsearch. Look at `vars/vagrant.yml` and `defaults/main.yml` for the variables that will be substituted in `templates/elasticsearch.yml.j2`. 26 | 27 | ## Running Standalone Playbook 28 | ### Copy Example Files 29 | Make copies of the following files and rename them to suit your environment. E.g.: 30 | 31 | - vagrant-main.yml => my-playbook-main.yml 32 | - vagrant-inventory.ini => my-inventory.ini 33 | - vars/vagrant.yml => vars/my-vars.yml 34 | 35 | Edit the copied files to suit your environment and needs. See examples below. 36 | 37 | ### Edit your my-inventory.ini 38 | Edit your my-inventory.ini and customize your cluster and node names: 39 | 40 | ``` 41 | ######################### 42 | # Elasticsearch Cluster # 43 | ######################### 44 | [es_node_1] 45 | 1.2.3.4.compute-1.amazonaws.com 46 | [es_node_1:vars] 47 | elasticsearch_node_name=elasticsearch-1 48 | 49 | [es_node_2] 50 | 5.6.7.8.compute-1.amazonaws.com 51 | [es_node_2:vars] 52 | elasticsearch_node_name=elasticsearch-2 53 | 54 | [es_node_3] 55 | 9.10.11.12.compute-1.amazonaws.com 56 | [es_node_3:vars] 57 | elasticsearch_node_name=elasticsearch-3 58 | 59 | [all_nodes:children] 60 | es_node_1 61 | es_node_2 62 | es_node_3 63 | 64 | [all_nodes:vars] 65 | elasticsearch_cluster_name=my.elasticsearch.cluster 66 | elasticsearch_plugin_aws_ec2_groups=MyElasticSearchGroup 67 | spm_client_token= 68 | ``` 69 | 70 | ### Edit your vars/my-vars.yml 71 | See `vars/sample.yml` and `vars/vagrant.yml` for example variable files. These are the files where you specify Elasticsearch settings and apply certain features such as plugins, custom JARs or monitoring. The best way to enable configurations is to look at `templates/elasticsearch.yml.j2` and see which variables you want to defile in your `vars/my-vars.yml`. See below for configurations regarding EC2, plugins and custom JARs. 72 | 73 | ### Edit your my-playbook-main.yml 74 | Example `my-playbook-main.yml`: 75 | 76 | ``` 77 | --- 78 | 79 | ######################### 80 | # Elasticsearch install # 81 | ######################### 82 | 83 | - hosts: all_nodes 84 | user: $user 85 | sudo: yes 86 | 87 | vars_files: 88 | - defaults/main.yml 89 | - vars/my-vars.yml 90 | 91 | tasks: 92 | - include: tasks/main.yml 93 | ``` 94 | 95 | ### Launch 96 | ``` 97 | $ ansible-playbook my-playbook-main.yml -i my-inventory.ini -e user= 98 | ``` 99 | 100 | ## Enabling Added Features 101 | ### Configuring EC2 102 | The following variables need to be defined in your playbook or inventory: 103 | 104 | - elasticsearch_plugin_aws_version 105 | 106 | See [https://github.com/elasticsearch/elasticsearch-cloud-aws](https://github.com/elasticsearch/elasticsearch-cloud-aws) for the version that most accurately matches your installation. 107 | 108 | The following variables provide a for now limited configuration for the plugin. More options may be available in the future (see [http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-discovery-ec2.html)](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-discovery-ec2.html)): 109 | 110 | - elasticsearch_plugin_aws_ec2_groups 111 | - elasticsearch_plugin_aws_ec2_ping_timeout 112 | - elasticsearch_plugin_aws_access_key 113 | - elasticsearch_plugin_aws_secret_key 114 | - elasticsearch_plugin_aws_region 115 | 116 | ### Installing plugins 117 | You will need to define an array called `elasticsearch_plugins` in your playbook or inventory, such that: 118 | ``` 119 | elasticsearch_plugins: 120 | - { name: '', url: '<[optional] plugin url>' } 121 | - ... 122 | ``` 123 | 124 | where if you were to install the plugin via bin/plugin, you would type: 125 | `bin/plugin -install ` or `bin/plugin -install -url ` 126 | 127 | Example for [https://github.com/elasticsearch/elasticsearch-mapper-attachments](https://github.com/elasticsearch/elasticsearch-mapper-attachments) (`bin/plugin -install elasticsearch/elasticsearch-mapper-attachments/1.9.0`): 128 | 129 | ``` 130 | elasticsearch_plugins: 131 | - { name: 'elasticsearch/elasticsearch-mapper-attachments/1.9.0' } 132 | ``` 133 | 134 | Example for [https://github.com/richardwilly98/elasticsearch-river-mongodb](https://github.com/richardwilly98/elasticsearch-river-mongodb) (`bin/plugin -i com.github.richardwilly98.elasticsearch/elasticsearch-river-mongodb/1.7.1`): 135 | 136 | ``` 137 | elasticsearch_plugins: 138 | - { name: 'com.github.richardwilly98.elasticsearch/elasticsearch-river-mongodb/1.7.1' } 139 | ``` 140 | 141 | Example for [https://github.com/imotov/elasticsearch-facet-script](https://github.com/imotov/elasticsearch-facet-script) (`bin/plugin -install facet-script -url http://dl.bintray.com/content/imotov/elasticsearch-plugins/elasticsearch-facet-script-1.1.2.zip`): 142 | 143 | ``` 144 | elasticsearch_plugins: 145 | - { name: 'facet-script', url: 'http://dl.bintray.com/content/imotov/elasticsearch-plugins/elasticsearch-facet-script-1.1.2.zip' } 146 | ``` 147 | 148 | ### Installing Custom JARs 149 | Custom jars are made available to the Elasticsearch classpath by being downloaded into the elasticsearch_home_dir/lib folder. An example of a custom jar can include a custom Lucene Similarity Provider. You will need to define an array called `elasticsearch_custom_jars` in your playbook or inventory, such that: 150 | 151 | ``` 152 | elasticsearch_custom_jars: 153 | - { uri: '', filename: '', user: '', passwd: '' } 154 | - ... 155 | ``` 156 | 157 | ### Configuring Thread Pools 158 | Elasticsearch [thread pools](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-threadpool.html) can be configured using the `elasticsearch_thread_pools` list variable: 159 | 160 | ``` 161 | elasticsearch_thread_pools: 162 | - "threadpool.bulk.type: fixed" 163 | - "threadpool.bulk.size: 50" 164 | - "threadpool.bulk.queue_size: 1000" 165 | ``` 166 | 167 | ### Enabling Sematext SPM 168 | Enable the SPM task in your playbook: 169 | 170 | ``` 171 | tasks: 172 | - include: tasks/spm.yml 173 | - ... 174 | ``` 175 | 176 | Set the spm_client_token variable in your inventory.ini to your SPM key. 177 | 178 | ### Configuring Marvel 179 | 180 | The following variables need to be defined in your playbook or inventory: 181 | 182 | - elasticsearch_plugin_marvel_version 183 | 184 | The following variables provide configuration for the plugin. More options may be available in the future (see [http://www.elasticsearch.org/guide/en/marvel/current/#stats-export](http://www.elasticsearch.org/guide/en/marvel/current/#stats-export)): 185 | 186 | - elasticsearch_plugin_marvel_agent_enabled 187 | - elasticsearch_plugin_marvel_agent_exporter_es_hosts 188 | - elasticsearch_plugin_marvel_agent_indices 189 | - elasticsearch_plugin_marvel_agent_interval 190 | - elasticsearch_plugin_marvel_agent_exporter_es_index_timeformat 191 | 192 | ## Disable Java installation 193 | 194 | If you prefer to skip the built-in installation of the Oracle JRE, use the `elasticsearch_install_java` flag: 195 | 196 | ``` 197 | elasticsearch_install_java: "false" 198 | ``` 199 | 200 | ## Include role in a larger playbook 201 | ### Add this role as a git submodule 202 | Assuming your playbook structure is such as: 203 | ``` 204 | - my-master-playbook 205 | |- vars 206 | |- roles 207 | |- my-master-playbook-main.yml 208 | \- my-master-inventory.ini 209 | ``` 210 | 211 | Checkout this project as a submodule under roles: 212 | 213 | ``` 214 | $ cd roles 215 | $ git submodule add git://github.com/traackr/ansible-elasticsearch.git ./ansible-elasticsearch 216 | $ git submodule update --init 217 | $ git commit ./submodule -m "Added submodule as ./subm" 218 | ``` 219 | 220 | ### Include this playbook as a role in your master playbook 221 | Example `my-master-playbook-main.yml`: 222 | 223 | ``` 224 | --- 225 | 226 | ######################### 227 | # Elasticsearch install # 228 | ######################### 229 | 230 | - hosts: all_nodes 231 | user: ubuntu 232 | sudo: yes 233 | 234 | roles: 235 | - ansible-elasticsearch 236 | 237 | vars_files: 238 | - vars/my-vars.yml 239 | ``` 240 | 241 | # Issues, requests, contributions 242 | This software is provided as is. Having said that, if you see an issue, feel free to log a ticket. We'll do our best to address it. Same if you want to see a certain feature supported in the fututre. No guarantees are made that any requested feature will be implemented. If you'd like to contribute, feel free to clone and submit a pull request. 243 | 244 | # Dependencies 245 | None 246 | 247 | # License 248 | MIT 249 | 250 | # Author Information 251 | 252 | George Stathis - gstathis [at] traackr.com 253 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! 5 | VAGRANTFILE_API_VERSION = "2" 6 | 7 | Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 8 | # Every Vagrant virtual environment requires a box to build off of. 9 | config.vm.box = "ubuntu/trusty64" 10 | config.vm.provider "virtualbox" do |v| 11 | v.memory = 2048 12 | v.cpus = 2 13 | end 14 | 15 | # Create a private network, which allows host-only access to the machine 16 | # using a specific IP. 17 | # config.vm.network :private_network, ip: "192.168.33.10" 18 | config.vm.network :private_network, ip: "192.168.111.10" 19 | 20 | # Share an additional folder to the guest VM. The first argument is 21 | # the path on the host to the actual folder. The second argument is 22 | # the path on the guest to mount the folder. And the optional third 23 | # argument is a set of non-required options. 24 | # config.vm.synced_folder "../data", "/vagrant_data" 25 | config.vm.synced_folder '.', '/vagrant' 26 | 27 | config.vm.provision :ansible do |ansible| 28 | ansible.inventory_path = "vagrant-inventory.ini" 29 | ansible.playbook = "vagrant-main.yml" 30 | ansible.extra_vars = { user: "vagrant" } 31 | ansible.limit = 'all' 32 | # ansible.verbose = 'vvvv' 33 | end 34 | end 35 | -------------------------------------------------------------------------------- /defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Elasticsearch Ansible Variables 3 | 4 | elasticsearch_user: elasticsearch 5 | elasticsearch_group: elasticsearch 6 | elasticsearch_download_url: https://download.elasticsearch.org/elasticsearch/elasticsearch 7 | elasticsearch_version: 1.7.3 8 | elasticsearch_apt_repos: 9 | - 'ppa:webupd8team/java' 10 | elasticsearch_apt_java_package: oracle-java7-installer 11 | elasticsearch_apt_dependencies: 12 | - htop 13 | - ntp 14 | - unzip 15 | elasticsearch_max_open_files: 65535 16 | elasticsearch_home_dir: /usr/share/elasticsearch 17 | elasticsearch_plugin_dir: /usr/share/elasticsearch/plugins 18 | elasticsearch_log_dir: /var/log/elasticsearch 19 | elasticsearch_data_dir: /var/lib/elasticsearch 20 | elasticsearch_work_dir: /tmp/elasticsearch 21 | elasticsearch_conf_dir: /etc/elasticsearch 22 | elasticsearch_pid_dir: /var/run 23 | elasticsearch_service_startonboot: no 24 | elasticsearch_timezone: "Etc/UTC" # Default to UTC 25 | 26 | #elasticsearch_http_cors_enabled: "false" 27 | elasticsearch_service_state: started 28 | 29 | # Non-Elasticsearch Defaults 30 | apt_cache_valid_time: 300 # seconds between "apt-get update" calls. 31 | elasticsearch_install_java: "true" 32 | -------------------------------------------------------------------------------- /handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Elasticsearch Ansible Handlers 3 | 4 | # Restart Elasticsearch 5 | - name: Restart Elasticsearch 6 | service: name=elasticsearch state=restarted 7 | -------------------------------------------------------------------------------- /meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Elasticsearch Ansible Meta 3 | galaxy_info: 4 | author: "George Stathis" 5 | company: Traackr 6 | license: MIT 7 | min_ansible_version: 1.3 8 | platforms: 9 | - name: Ubuntu 10 | versions: 11 | - precise 12 | categories: 13 | - database:nosql 14 | dependencies: [] 15 | -------------------------------------------------------------------------------- /tasks/aws.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Install AWS Plugin (see https://github.com/elasticsearch/elasticsearch-cloud-aws) 3 | # 4 | # The following variables need to be defined in your playbook or inventory: 5 | # - elasticsearch_plugin_aws_version 6 | # 7 | # The following variables provide a for now limited configuration for the plugin. 8 | # More options may be available in the future. 9 | # (see http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-discovery-ec2.html): 10 | # - elasticsearch_plugin_aws_ec2_groups 11 | # - elasticsearch_plugin_aws_ec2_ping_timeout 12 | # - elasticsearch_plugin_aws_access_key 13 | # - elasticsearch_plugin_aws_secret_key 14 | # - elasticsearch_plugin_aws_region 15 | 16 | - name: aws | Removing AWS Plugin if it exists 17 | shell: bin/plugin --remove cloud-aws 18 | chdir={{ elasticsearch_home_dir }} 19 | when: elasticsearch_plugin_aws_reinstall is defined and elasticsearch_plugin_aws_reinstall == True 20 | ignore_errors: yes 21 | - name: aws | Installing AWS Plugin 22 | shell: bin/plugin -install elasticsearch/elasticsearch-cloud-aws/{{ elasticsearch_plugin_aws_version }} 23 | chdir={{ elasticsearch_home_dir }} 24 | register: aws_plugins_installed 25 | changed_when: "'Installed' in aws_plugins_installed.stdout" 26 | failed_when: "aws_plugins_installed.rc != 0 and aws_plugins_installed.stdout.find('already exists. To update the plugin') == -1" 27 | -------------------------------------------------------------------------------- /tasks/custom-jars.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Install Custom JARs 3 | # 4 | # Custom jars are made available to the Elasticsearch classpath by being downloaded into the elasticsearch_home_dir/lib folder. 5 | # An example of a custom jar can include a custom Lucene Similarity Provider. You will need to define an array called 6 | # 'elasticsearch_custom_jars' in your playbook or inventory, such that: 7 | # 8 | # elasticsearch_custom_jars: 9 | # - { uri: '', filename: '', user: '', passwd: '' } 10 | # - ... 11 | 12 | # Loop though elasticsearch_custom_jars and install them 13 | - name: Installing Custom JARs 14 | action: > 15 | get_url url={{ item.uri }} 16 | url_username={{ item.user }} url_password={{ item.passwd }} dest="{{ elasticsearch_home_dir }}/lib/{{ item.filename }}" 17 | with_items: elasticsearch_custom_jars 18 | # Fix permissions 19 | - file: > 20 | path="{{ elasticsearch_home_dir }}/lib" state=directory 21 | owner={{ elasticsearch_user }} group={{ elasticsearch_group }} 22 | recurse=yes 23 | -------------------------------------------------------------------------------- /tasks/elastic-install.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: elastic-install | Install python-software-properties 4 | apt: 5 | pkg=python-software-properties 6 | state=present 7 | update_cache=yes 8 | cache_valid_time={{apt_cache_valid_time}} 9 | 10 | - name: elastic-install | Install dependencies 11 | apt: 12 | pkg={{ item }} 13 | state=present 14 | with_items: elasticsearch_apt_dependencies 15 | 16 | - name: elastic-install | Configuring elastic group 17 | group: 18 | name={{ elasticsearch_group }} 19 | 20 | - name: elastic-install | Configuring elastic user 21 | user: 22 | name={{ elasticsearch_user }} 23 | group={{ elasticsearch_group }} 24 | createhome=no 25 | 26 | - name: elastic-install | Ensure temp elasticsearch directories exists 27 | file: 28 | path="{{ elasticsearch_work_dir }}" 29 | state=directory 30 | owner={{ elasticsearch_user }} 31 | group={{ elasticsearch_group }} 32 | recurse=yes 33 | 34 | - name: elastic-install | Check if we have elastic with same version installed 35 | stat: 36 | path="/usr/share/elasticsearch/lib/elasticsearch-{{ elasticsearch_version }}.jar" 37 | register: installed_version 38 | 39 | - name: elastic-install | Try to stop elasticsearch if running 40 | service: 41 | name=elasticsearch 42 | state=stopped 43 | ignore_errors: yes 44 | when: not installed_version.stat.exists 45 | 46 | - name: elastic-install | Download Elasticsearch deb 47 | get_url: 48 | url={{ elasticsearch_download_url }}/elasticsearch-{{ elasticsearch_version }}.deb 49 | dest=/tmp/elasticsearch-{{ elasticsearch_version }}.deb 50 | mode=0440 51 | when: not installed_version.stat.exists 52 | 53 | #shell: dpkg --remove elasticsearch 54 | - name: elastic-install | Uninstalling previous version if applicable 55 | apt: 56 | name="elasticsearch" 57 | state="absent" 58 | when: not installed_version.stat.exists 59 | 60 | - name: elastic-install | Remove elasticsearch directory 61 | file: 62 | path="{{ elasticsearch_home_dir }}" 63 | state=absent 64 | when: not installed_version.stat.exists 65 | 66 | - name: elastic-install | Install Elasticsearch deb 67 | shell: dpkg -i -E --force-confnew /tmp/elasticsearch-{{ elasticsearch_version }}.deb 68 | when: not installed_version.stat.exists 69 | notify: Restart Elasticsearch 70 | 71 | - name: elastic-install | Ensure elastic directories exists 72 | file: 73 | path="{{ item }}" 74 | state=directory 75 | owner={{ elasticsearch_user }} 76 | group={{ elasticsearch_group }} 77 | recurse=yes 78 | with_items: 79 | - "{{ elasticsearch_work_dir }}" 80 | - "{{ elasticsearch_home_dir }}" 81 | - "{{ elasticsearch_log_dir }}" 82 | - "{{ elasticsearch_data_dir }}" 83 | - "{{ elasticsearch_work_dir }}" 84 | - "{{ elasticsearch_conf_dir }}" 85 | 86 | - name: Configure limits max_open_files 87 | lineinfile: 88 | dest=/etc/security/limits.conf 89 | regexp='^{{ elasticsearch_user }} - nofile {{ elasticsearch_max_open_files }}' 90 | insertafter=EOF 91 | line='{{ elasticsearch_user }} - nofile {{ elasticsearch_max_open_files }}' 92 | when: elasticsearch_max_open_files is defined 93 | notify: Restart Elasticsearch 94 | 95 | - name: elastic-install | Configure limits max_locked_memory 96 | lineinfile: 97 | dest=/etc/security/limits.conf 98 | regexp='^{{ elasticsearch_user }} - memlock {{ elasticsearch_max_locked_memory }}' 99 | insertafter=EOF 100 | line='{{ elasticsearch_user }} - memlock {{ elasticsearch_max_locked_memory }}' 101 | when: elasticsearch_max_locked_memory is defined 102 | notify: Restart Elasticsearch 103 | 104 | - name: elastic-install | Configure su pam_limits.so 105 | lineinfile: 106 | dest=/etc/pam.d/su 107 | regexp='^session required pam_limits.so' 108 | insertafter=EOF 109 | line='session required pam_limits.so' 110 | notify: Restart Elasticsearch 111 | 112 | - name: elastic-install | Configure common-session pam_limits.so 113 | lineinfile: 114 | dest=/etc/pam.d/common-session 115 | regexp='^session required pam_limits.so' 116 | insertafter=EOF 117 | line='session required pam_limits.so' 118 | notify: Restart Elasticsearch 119 | 120 | - name: elastic-install | Configure common-session-noninteractive pam_limits.so 121 | lineinfile: 122 | dest=/etc/pam.d/common-session-noninteractive 123 | regexp='^session required pam_limits.so' 124 | insertafter=EOF 125 | line='session required pam_limits.so' 126 | notify: Restart Elasticsearch 127 | 128 | - name: elastic-install | Configure sudo pam_limits.so 129 | lineinfile: 130 | dest=/etc/pam.d/sudo 131 | regexp='^session required pam_limits.so' 132 | insertafter=EOF 133 | line='session required pam_limits.so' 134 | notify: Restart Elasticsearch 135 | 136 | - name: elastic-install | Configure initd java opts in /etc/init.d/elasticsearch 137 | lineinfile: 138 | dest=/etc/init.d/elasticsearch 139 | regexp='^(DAEMON_OPTS=".*-Des.max-open-files=true")$' 140 | insertafter='^(DAEMON_OPTS=".*CONF_DIR")$' 141 | line='DAEMON_OPTS="$DAEMON_OPTS -Des.max-open-files=true"' 142 | notify: Restart Elasticsearch 143 | 144 | - name: elastic-install | Configuring Elasticsearch elasticsearch.yml Node 145 | template: 146 | src=elasticsearch.yml.j2 147 | dest={{ elasticsearch_conf_dir }}/elasticsearch.yml 148 | owner={{ elasticsearch_user }} 149 | group={{ elasticsearch_group }} 150 | mode=0644 151 | when: elasticsearch_conf_dir is defined 152 | notify: Restart Elasticsearch 153 | 154 | - name : elastic-install | Configure /etc/default/elasticsearch 155 | template: 156 | src=elasticsearch.default.j2 157 | dest=/etc/default/elasticsearch 158 | owner={{ elasticsearch_user }} 159 | group={{ elasticsearch_group }} 160 | mode=0644 161 | notify: Restart Elasticsearch -------------------------------------------------------------------------------- /tasks/java.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: java | Accept Oracle license prior JDK installation 4 | shell: echo debconf shared/accepted-oracle-license-v1-1 select true | sudo debconf-set-selections; echo debconf shared/accepted-oracle-license-v1-1 seen true | sudo debconf-set-selections 5 | creates=/usr/lib/jvm/java-8-oracle 6 | 7 | - name: java | Update repositories 8 | apt_repository: 9 | repo={{ item }} 10 | state=present 11 | update_cache=yes 12 | with_items: elasticsearch_apt_repos 13 | 14 | - name: java | Install dependencies 15 | apt: 16 | pkg={{elasticsearch_apt_java_package}} 17 | state=present 18 | -------------------------------------------------------------------------------- /tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Elasticsearch Ansible Tasks 3 | 4 | # Install Java 5 | - include: java.yml 6 | when: elasticsearch_install_java 7 | 8 | # Configure timezome 9 | - include: timezone.yml 10 | 11 | # Install and configure elasticsearch 12 | - include: elastic-install.yml 13 | 14 | # Install AWS Plugin 15 | - include: aws.yml 16 | when: (elasticsearch_plugin_aws_version is defined) 17 | 18 | # Install Other Generic Plugins 19 | - include: plugins.yml 20 | when: (elasticsearch_plugins is defined) 21 | 22 | # Install custom JARs 23 | - include: custom-jars.yml 24 | when: (elasticsearch_custom_jars is defined) 25 | 26 | # Install Marvel Plugin 27 | - include: marvel.yml 28 | when: (elasticsearch_plugin_marvel_version is defined) 29 | 30 | # Always run post-run tasks 31 | - include: post-run.yml 32 | -------------------------------------------------------------------------------- /tasks/marvel.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Install Marvel (see http://www.elasticsearch.org/guide/en/marvel/current/) 3 | # 4 | # The following variables need to be defined in your playbook or inventory: 5 | # - elasticsearch_plugin_marvel_version 6 | # 7 | # The following variables provide configuration for the plugin. 8 | # More options may be available in the future: 9 | # - elasticsearch_plugin_marvel_agent_enabled 10 | # - elasticsearch_plugin_marvel_agent_exporter_es_hosts 11 | # - elasticsearch_plugin_marvel_agent_indices 12 | # - elasticsearch_plugin_marvel_agent_interval 13 | # - elasticsearch_plugin_marvel_agent_exporter_es_index_timeformat 14 | 15 | - name: marvel | Removing Marvel Plugin if it exists 16 | shell: bin/plugin --remove marvel 17 | chdir={{ elasticsearch_home_dir }} 18 | ignore_errors: yes 19 | - name: marvel | Installing Marvel Plugin 20 | shell: bin/plugin -i elasticsearch/marvel/{{ elasticsearch_plugin_marvel_version }} 21 | chdir={{ elasticsearch_home_dir }} 22 | register: marvel_plugins_installed 23 | changed_when: "'Installed' in marvel_plugins_installed.stdout" 24 | failed_when: "marvel_plugins_installed.rc != 0 and marvel_plugins_installed.stdout.find('already exists. To update the plugin') == -1" 25 | -------------------------------------------------------------------------------- /tasks/plugins.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Install Elasticsearch Plugins 3 | # 4 | # You will need to define an array called 'elasticsearch_plugins' in your playbook or inventory, such that: 5 | # 6 | # elasticsearch_plugins: 7 | # - { name: '', url: '<[optional] plugin url>' } 8 | # - ... 9 | # where if you were to install the plugin via bin/plugin, you would type: 10 | # 11 | # bin/plugin -install 12 | # 13 | # or 14 | # 15 | # bin/plugin -install -url 16 | 17 | # Example for https://github.com/elasticsearch/elasticsearch-mapper-attachments (bin/plugin -install elasticsearch/elasticsearch-mapper-attachments/1.9.0): 18 | # elasticsearch_plugins: 19 | # - { name: 'elasticsearch/elasticsearch-mapper-attachments/1.9.0' } 20 | # 21 | # Example for https://github.com/richardwilly98/elasticsearch-river-mongodb (bin/plugin -i com.github.richardwilly98.elasticsearch/elasticsearch-river-mongodb/1.7.1): 22 | # elasticsearch_plugins: 23 | # - { name: 'com.github.richardwilly98.elasticsearch/elasticsearch-river-mongodb/1.7.1' } 24 | # 25 | # Example for https://github.com/imotov/elasticsearch-facet-script (bin/plugin -install facet-script -url http://dl.bintray.com/content/imotov/elasticsearch-plugins/elasticsearch-facet-script-1.1.2.zip): 26 | # elasticsearch_plugins: 27 | # - { name: 'facet-script', url: 'http://dl.bintray.com/content/imotov/elasticsearch-plugins/elasticsearch-facet-script-1.1.2.zip' } 28 | 29 | # Loop though elasticsearch_plugins and install them 30 | 31 | - name: plugins | Removing Old Plugins 32 | shell: bin/plugin --remove {{ item.name }} 33 | chdir={{ elasticsearch_home_dir }} 34 | when: item.name is defined and item.reinstall is defined and item.reinstall == True 35 | with_items: elasticsearch_plugins 36 | ignore_errors: yes 37 | - name: plugins | Installing Plugins 38 | shell: bin/plugin -install {{ item.name }} {{ '-url ' + item.url if item.url is defined else '' }} 39 | chdir={{ elasticsearch_home_dir }} 40 | when: item.download_only is not defined 41 | with_items: elasticsearch_plugins 42 | register: plugins_installed 43 | changed_when: "'Installed' in plugins_installed.stdout" 44 | failed_when: "plugins_installed.rc != 0 and plugins_installed.stdout.find('already exists. To update the plugin') == -1" 45 | - name: plugins | Ensure Paths for Download only Plugins 46 | file: 47 | path="{{ elasticsearch_plugin_dir }}/{{ item.name }}" 48 | state=directory 49 | when: item.download_only is defined and item.name is defined 50 | with_items: elasticsearch_plugins 51 | - name: plugins | Download only Plugins 52 | get_url: 53 | url={{ item.url }} 54 | dest={{ elasticsearch_plugin_dir }}/{{ item.name }} 55 | when: item.download_only is defined and item.name is defined 56 | with_items: elasticsearch_plugins 57 | ignore_errors: yes 58 | -------------------------------------------------------------------------------- /tasks/post-run.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: post-run | Ensure plugins directory permission are correct 4 | file: 5 | path="{{ elasticsearch_plugin_dir }}" 6 | state=directory 7 | owner={{ elasticsearch_user }} 8 | group={{ elasticsearch_group }} 9 | recurse=yes 10 | 11 | - name: post-run | Ensure Elasticsearch is running and started on boot 12 | service: 13 | name=elasticsearch 14 | enabled={{ elasticsearch_service_startonboot }} 15 | state={{ elasticsearch_service_state }} 16 | when: installed_version.stat.exists 17 | 18 | # Flush handlers to restart elastic if needed 19 | - meta: flush_handlers 20 | 21 | - name: post-run | Check http port is open and running version. timeout 160s 22 | wait_for: 23 | host={{ '127.0.0.1' if elasticsearch_network_bind_host is not defined or elasticsearch_network_bind_host == '0.0.0.0' else elasticsearch_network_bind_host }} 24 | port={{ elasticsearch_network_http_port | default('9200') }} 25 | timeout=160 26 | when: elasticsearch_service_state == "started" -------------------------------------------------------------------------------- /tasks/spm.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # SPM Tasks (see http://sematext.com/spm/) 3 | 4 | - name: spm | Install Collectd 5 | apt: 6 | pkg=collectd 7 | state=present 8 | 9 | # TODO: Make idempotent 10 | - name: spm | Downloading and running package 11 | shell: wget --no-check-certificate -O installer.sh "https://apps.sematext.com/spm-reports/installerDownload.do?client_token={{ spm_client_token }}" && bash installer.sh 12 | 13 | # TODO: Make idempotent 14 | - name: spm | Preparing monitor configurations 15 | shell: bash /opt/spm/bin/spm-client-setup-conf.sh {{ spm_client_token }} es standalone 16 | 17 | - name: spm | Configuring JXM in Elasticsearch 18 | lineinfile: 19 | dest=/etc/default/elasticsearch 20 | regexp='^(ES_JAVA_OPTS="\$ES_JAVA_OPTS -Dcom.sun.management.jmxremote.*")$' 21 | insertafter='^(#ES_JAVA_OPTS=.*)$' 22 | line='ES_JAVA_OPTS="\$ES_JAVA_OPTS -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=3000 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"' 23 | notify: Restart Elasticsearch 24 | 25 | - name: spm | Configuring JXM in SPM 26 | lineinfile: 27 | dest=/opt/spm/spm-monitor/conf/spm-monitor-config-{{ spm_client_token }}-default.properties 28 | regexp='^(SPM_MONITOR_JMX_PARAMS="")$' 29 | line='SPM_MONITOR_JMX_PARAMS="-Dspm.remote.jmx.url=localhost:3000"' 30 | 31 | - name: spm | Restarting SPM 32 | service: 33 | name=spm-monitor 34 | state=restarted 35 | -------------------------------------------------------------------------------- /tasks/timezone.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: timezone | check current timezone 4 | shell: cat /etc/timezone 5 | changed_when: 0 6 | register: current_zone 7 | 8 | - name: timezone | Set timezone variables 9 | copy: 10 | content={{elasticsearch_timezone}} 11 | dest=/etc/timezone 12 | owner=root 13 | group=root 14 | mode=0644 15 | when: current_zone.stdout != elasticsearch_timezone 16 | 17 | - name: timezone | Run dpkg-reconfigure to configure timezone 18 | shell: dpkg-reconfigure --frontend noninteractive tzdata 19 | when: current_zone.stdout != elasticsearch_timezone -------------------------------------------------------------------------------- /templates/elasticsearch.default.j2: -------------------------------------------------------------------------------- 1 | # Run ElasticSearch as this user ID and group ID 2 | #ES_USER=elasticsearch 3 | {% if elasticsearch_user is defined %} 4 | ES_USER={{ elasticsearch_user }} 5 | {% endif %} 6 | #ES_GROUP=elasticsearch 7 | {% if elasticsearch_group is defined %} 8 | ES_GROUP={{ elasticsearch_group }} 9 | {% endif %} 10 | 11 | # Heap Size (defaults to 256m min, 1g max) 12 | #ES_HEAP_SIZE=2g 13 | {% if elasticsearch_heap_size is defined %} 14 | ES_HEAP_SIZE={{ elasticsearch_heap_size }} 15 | {% endif %} 16 | 17 | # Heap new generation 18 | #ES_HEAP_NEWSIZE= 19 | 20 | # max direct memory 21 | #ES_DIRECT_SIZE= 22 | 23 | # Maximum number of open files, defaults to 65535. 24 | #MAX_OPEN_FILES=65535 25 | {% if elasticsearch_max_open_files is defined %} 26 | MAX_OPEN_FILES={{ elasticsearch_max_open_files }} 27 | {% endif %} 28 | 29 | # Maximum locked memory size. Set to "unlimited" if you use the 30 | # bootstrap.mlockall option in elasticsearch.yml. You must also set 31 | # ES_HEAP_SIZE. 32 | #MAX_LOCKED_MEMORY=unlimited 33 | {% if elasticsearch_max_locked_memory is defined %} 34 | MAX_LOCKED_MEMORY={{ elasticsearch_max_locked_memory }} 35 | {% endif %} 36 | 37 | # ElasticSearch log directory 38 | #LOG_DIR=/var/log/elasticsearch 39 | 40 | # ElasticSearch data directory 41 | #DATA_DIR=/var/lib/elasticsearch 42 | 43 | # ElasticSearch work directory 44 | #WORK_DIR=/tmp/elasticsearch 45 | 46 | # ElasticSearch configuration directory 47 | #CONF_DIR=/etc/elasticsearch 48 | 49 | # ElasticSearch configuration file (elasticsearch.yml) 50 | #CONF_FILE=/etc/elasticsearch/elasticsearch.yml 51 | 52 | # Additional Java OPTS 53 | {% if elasticsearch_java_opts is defined %} 54 | ES_JAVA_OPTS="{{ elasticsearch_java_opts }}" 55 | {% else %} 56 | #ES_JAVA_OPTS= 57 | {% endif %} 58 | 59 | # Environment Vars 60 | {% if elasticsearch_env_use_gc_logging is defined %} 61 | export ES_USE_GC_LOGGING=true 62 | {% endif %} 63 | {% if elasticsearch_java_home is defined %} 64 | JAVA_HOME={{ elasticsearch_java_home }} 65 | {% endif %} 66 | 67 | PID_DIR={{ elasticsearch_pid_dir }} 68 | -------------------------------------------------------------------------------- /templates/elasticsearch.in.sh.j2: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ES_CLASSPATH=$ES_CLASSPATH:$ES_HOME/lib/elasticsearch-{{ elasticsearch_version }}.jar:$ES_HOME/lib/*:$ES_HOME/lib/sigar/* 4 | 5 | if [ "x$ES_MIN_MEM" = "x" ]; then 6 | ES_MIN_MEM=256m 7 | fi 8 | if [ "x$ES_MAX_MEM" = "x" ]; then 9 | ES_MAX_MEM=1g 10 | fi 11 | if [ "x$ES_HEAP_SIZE" != "x" ]; then 12 | ES_MIN_MEM=$ES_HEAP_SIZE 13 | ES_MAX_MEM=$ES_HEAP_SIZE 14 | fi 15 | 16 | # min and max heap sizes should be set to the same value to avoid 17 | # stop-the-world GC pauses during resize, and so that we can lock the 18 | # heap in memory on startup to prevent any of it from being swapped 19 | # out. 20 | JAVA_OPTS="$JAVA_OPTS -Xms${ES_MIN_MEM}" 21 | JAVA_OPTS="$JAVA_OPTS -Xmx${ES_MAX_MEM}" 22 | 23 | # new generation 24 | if [ "x$ES_HEAP_NEWSIZE" != "x" ]; then 25 | JAVA_OPTS="$JAVA_OPTS -Xmn${ES_HEAP_NEWSIZE}" 26 | fi 27 | 28 | # max direct memory 29 | if [ "x$ES_DIRECT_SIZE" != "x" ]; then 30 | JAVA_OPTS="$JAVA_OPTS -XX:MaxDirectMemorySize=${ES_DIRECT_SIZE}" 31 | fi 32 | 33 | # reduce the per-thread stack size 34 | JAVA_OPTS="$JAVA_OPTS -Xss256k" 35 | 36 | # set to headless, just in case 37 | JAVA_OPTS="$JAVA_OPTS -Djava.awt.headless=true" 38 | 39 | # Force the JVM to use IPv4 stack 40 | if [ "x$ES_USE_IPV4" != "x" ]; then 41 | JAVA_OPTS="$JAVA_OPTS -Djava.net.preferIPv4Stack=true" 42 | fi 43 | 44 | JAVA_OPTS="$JAVA_OPTS -XX:+UseParNewGC" 45 | JAVA_OPTS="$JAVA_OPTS -XX:+UseConcMarkSweepGC" 46 | 47 | JAVA_OPTS="$JAVA_OPTS -XX:CMSInitiatingOccupancyFraction=75" 48 | JAVA_OPTS="$JAVA_OPTS -XX:+UseCMSInitiatingOccupancyOnly" 49 | 50 | # When running under Java 7 51 | # JAVA_OPTS="$JAVA_OPTS -XX:+UseCondCardMark" 52 | 53 | # GC logging options 54 | if [ "x$ES_USE_GC_LOGGING" != "x" ]; then 55 | JAVA_OPTS="$JAVA_OPTS -XX:+PrintGCDetails" 56 | JAVA_OPTS="$JAVA_OPTS -XX:+PrintGCTimeStamps" 57 | JAVA_OPTS="$JAVA_OPTS -XX:+PrintClassHistogram" 58 | JAVA_OPTS="$JAVA_OPTS -XX:+PrintTenuringDistribution" 59 | JAVA_OPTS="$JAVA_OPTS -XX:+PrintGCApplicationStoppedTime" 60 | {% if elasticsearch_log_dir is defined %} 61 | JAVA_OPTS="$JAVA_OPTS -Xloggc:{{ elasticsearch_log_dir }}/gc.log" 62 | {% else %} 63 | JAVA_OPTS="$JAVA_OPTS -Xloggc:/var/log/elasticsearch/gc.log" 64 | {% endif %} 65 | {% if elasticsearch_java_opts is defined %} 66 | JAVA_OPTS="$JAVA_OPTS {{ elasticsearch_java_opts }}" 67 | {% endif %} 68 | fi 69 | 70 | # Causes the JVM to dump its heap on OutOfMemory. 71 | JAVA_OPTS="$JAVA_OPTS -XX:+HeapDumpOnOutOfMemoryError" 72 | # The path to the heap dump location, note directory must exists and have enough 73 | # space for a full heap dump. 74 | #JAVA_OPTS="$JAVA_OPTS -XX:HeapDumpPath=$ES_HOME/logs/heapdump.hprof" 75 | -------------------------------------------------------------------------------- /templates/elasticsearch.yml.j2: -------------------------------------------------------------------------------- 1 | ##################### ElasticSearch Configuration Example ##################### 2 | 3 | # This file contains an overview of various configuration settings, 4 | # targeted at operations staff. Application developers should 5 | # consult the guide at . 6 | # 7 | # The installation procedure is covered at 8 | # . 9 | # 10 | # ElasticSearch comes with reasonable defaults for most settings, 11 | # so you can try it out without bothering with configuration. 12 | # 13 | # Most of the time, these defaults are just fine for running a production 14 | # cluster. If you're fine-tuning your cluster, or wondering about the 15 | # effect of certain configuration option, please _do ask_ on the 16 | # mailing list or IRC channel [http://elasticsearch.org/community]. 17 | 18 | # See 19 | # for information on supported formats and syntax for the configuration file. 20 | 21 | 22 | ################################### Cluster ################################### 23 | 24 | # Cluster name identifies your cluster for auto-discovery. If you're running 25 | # multiple clusters on the same network, make sure you're using unique names. 26 | # 27 | # cluster.name: elasticsearch 28 | {% if elasticsearch_cluster_name is defined %} 29 | cluster.name: {{ elasticsearch_cluster_name }} 30 | {% endif %} 31 | 32 | #################################### Node ##################################### 33 | 34 | # Node names are generated dynamically on startup, so you're relieved 35 | # from configuring them manually. You can tie this node to a specific name: 36 | # 37 | # node.name: "Franz Kafka" 38 | {% if elasticsearch_node_name is defined %} 39 | node.name: {{ elasticsearch_node_name }} 40 | {% endif %} 41 | 42 | # Every node can be configured to allow or deny being eligible as the master, 43 | # and to allow or deny to store the data. 44 | # 45 | # Allow this node to be eligible as a master node (enabled by default): 46 | # 47 | # node.master: true 48 | {% if elasticsearch_node_master is defined %} 49 | node.master: {{ elasticsearch_node_master }} 50 | {% endif %} 51 | # 52 | # Allow this node to store data (enabled by default): 53 | # 54 | # node.data: true 55 | {% if elasticsearch_node_data is defined %} 56 | node.data: {{ elasticsearch_node_data }} 57 | {% endif %} 58 | 59 | # You can exploit these settings to design advanced cluster topologies. 60 | # 61 | # 1. You want this node to never become a master node, only to hold data. 62 | # This will be the "workhorse" of your cluster. 63 | # 64 | # node.master: false 65 | # node.data: true 66 | # 67 | # 2. You want this node to only serve as a master: to not store any data and 68 | # to have free resources. This will be the "coordinator" of your cluster. 69 | # 70 | # node.master: true 71 | # node.data: false 72 | # 73 | # 3. You want this node to be neither master nor data node, but 74 | # to act as a "search load balancer" (fetching data from nodes, 75 | # aggregating results, etc.) 76 | # 77 | # node.master: false 78 | # node.data: false 79 | 80 | # Use the Cluster Health API [http://localhost:9200/_cluster/health], the 81 | # Node Info API [http://localhost:9200/_cluster/nodes] or GUI tools 82 | # such as and 83 | # to inspect the cluster state. 84 | 85 | # A node can have generic attributes associated with it, which can later be used 86 | # for customized shard allocation filtering, or allocation awareness. An attribute 87 | # is a simple key value pair, similar to node.key: value, here is an example: 88 | # 89 | # node.rack: rack314 90 | {% if elasticsearch_node_rack is defined %} 91 | node.rack: {{ elasticsearch_node_rack }} 92 | {% endif %} 93 | 94 | # By default, multiple nodes are allowed to start from the same installation location 95 | # to disable it, set the following: 96 | # node.max_local_storage_nodes: 1 97 | {% if elasticsearch_node_max_local_storage_nodes is defined %} 98 | node.max_local_storage_nodes: {{ elasticsearch_node_max_local_storage_nodes }} 99 | {% endif %} 100 | 101 | # Disable network discovery by setting the following (useful for development): 102 | # node.local: true 103 | {% if elasticsearch_node_local is defined %} 104 | node.local: {{ elasticsearch_node_local }} 105 | {% endif %} 106 | 107 | #################################### Index #################################### 108 | 109 | # You can set a number of options (such as shard/replica options, mapping 110 | # or analyzer definitions, translog settings, ...) for indices globally, 111 | # in this file. 112 | # 113 | # Note, that it makes more sense to configure index settings specifically for 114 | # a certain index, either when creating it or by using the index templates API. 115 | # 116 | # See and 117 | # 118 | # for more information. 119 | 120 | # Set the number of shards (splits) of an index (5 by default): 121 | # 122 | # index.number_of_shards: 5 123 | {% if elasticsearch_index_number_of_shards is defined %} 124 | index.number_of_shards: {{ elasticsearch_index_number_of_shards }} 125 | {% endif %} 126 | 127 | # Set the number of replicas (additional copies) of an index (1 by default): 128 | # 129 | # index.number_of_replicas: 1 130 | {% if elasticsearch_index_number_of_replicas is defined %} 131 | index.number_of_replicas: {{ elasticsearch_index_number_of_replicas }} 132 | {% endif %} 133 | 134 | # Note, that for development on a local machine, with small indices, it usually 135 | # makes sense to "disable" the distributed features: 136 | # 137 | # index.number_of_shards: 1 138 | # index.number_of_replicas: 0 139 | 140 | # These settings directly affect the performance of index and search operations 141 | # in your cluster. Assuming you have enough machines to hold shards and 142 | # replicas, the rule of thumb is: 143 | # 144 | # 1. Having more *shards* enhances the _indexing_ performance and allows to 145 | # _distribute_ a big index across machines. 146 | # 2. Having more *replicas* enhances the _search_ performance and improves the 147 | # cluster _availability_. 148 | # 149 | # The "number_of_shards" is a one-time setting for an index. 150 | # 151 | # The "number_of_replicas" can be increased or decreased anytime, 152 | # by using the Index Update Settings API. 153 | # 154 | # ElasticSearch takes care about load balancing, relocating, gathering the 155 | # results from nodes, etc. Experiment with different settings to fine-tune 156 | # your setup. 157 | 158 | # Use the Index Status API () to inspect 159 | # the index status. 160 | 161 | {% if elasticsearch_index_mapper_dynamic is defined %} 162 | index.mapper_dynamic: {{ elasticsearch_index_mapper_dynamic }} 163 | {% endif %} 164 | {% if elasticsearch_misc_query_bool_max_clause_count is defined %} 165 | index.query.bool.max_clause_count: {{ elasticsearch_misc_query_bool_max_clause_count }} 166 | {% endif %} 167 | {% if elasticsearch_index_refresh_interval is defined %} 168 | index.refresh_interval: {{ elasticsearch_index_refresh_interval }} 169 | {% endif %} 170 | {% if elasticsearch_index_store_throttle_type is defined %} 171 | index.store.throttle.type: {{ elasticsearch_index_store_throttle_type }} 172 | {% endif %} 173 | {% if elasticsearch_index_store_throttle_max_bytes_per_sec is defined %} 174 | indices.store.throttle.max_bytes_per_sec: {{ elasticsearch_index_store_throttle_max_bytes_per_sec }} 175 | {% endif %} 176 | {% if elasticsearch_index_merge_scheduler_max_thread_count is defined %} 177 | index.merge.scheduler.max_thread_count: {{ elasticsearch_index_merge_scheduler_max_thread_count }} 178 | {% endif %} 179 | 180 | #################################### Paths #################################### 181 | 182 | # Path to directory containing configuration (this file and logging.yml): 183 | # 184 | # path.conf: /path/to/conf 185 | {% if elasticsearch_conf_dir is defined %} 186 | path.conf: {{ elasticsearch_conf_dir }} 187 | {% endif %} 188 | 189 | # Path to directory where to store index data allocated for this node. 190 | # 191 | # path.data: /path/to/data 192 | {% if elasticsearch_data_dir is defined %} 193 | path.data: {{ elasticsearch_data_dir }} 194 | {% endif %} 195 | 196 | # Can optionally include more than one location, causing data to be striped across 197 | # the locations (a la RAID 0) on a file level, favouring locations with most free 198 | # space on creation. For example: 199 | # 200 | # path.data: /path/to/data1,/path/to/data2 201 | 202 | # Path to temporary files: 203 | # 204 | # path.work: /path/to/work 205 | {% if elasticsearch_work_dir is defined %} 206 | path.work: {{ elasticsearch_work_dir }} 207 | {% endif %} 208 | 209 | # Path to log files: 210 | # 211 | # path.logs: /path/to/logs 212 | {% if elasticsearch_log_dir is defined %} 213 | path.logs: {{ elasticsearch_log_dir }} 214 | {% endif %} 215 | 216 | # Path to where plugins are installed: 217 | # 218 | # path.plugins: /path/to/plugins 219 | {% if elasticsearch_plugin_dir is defined %} 220 | path.plugins: {{ elasticsearch_plugin_dir }} 221 | {% endif %} 222 | 223 | #################################### Plugin ################################### 224 | 225 | # If a plugin listed here is not installed for current node, the node will not start. 226 | # 227 | # plugin.mandatory: mapper-attachments,lang-groovy 228 | 229 | 230 | ################################### Memory #################################### 231 | 232 | # ElasticSearch performs poorly when JVM starts swapping: you should ensure that 233 | # it _never_ swaps. 234 | # 235 | # Set this property to true to lock the memory: 236 | # 237 | # 238 | {% if elasticsearch_memory_bootstrap_mlockall is defined %} 239 | bootstrap.mlockall: {{ elasticsearch_memory_bootstrap_mlockall }} 240 | {% endif %} 241 | 242 | # Make sure that the ES_MIN_MEM and ES_MAX_MEM environment variables are set 243 | # to the same value, and that the machine has enough memory to allocate 244 | # for ElasticSearch, leaving enough memory for the operating system itself. 245 | # 246 | # You should also make sure that the ElasticSearch process is allowed to lock 247 | # the memory, eg. by using `ulimit -l unlimited`. 248 | 249 | {% if elasticsearch_indices_fielddata_cache_size is defined %} 250 | indices.fielddata.cache.size: {{ elasticsearch_indices_fielddata_cache_size }} 251 | {% endif %} 252 | 253 | {% if elasticsearch_indices_breaker_fielddata_limit is defined %} 254 | indices.breaker.fielddata.limit: {{ elasticsearch_indices_breaker_fielddata_limit }} 255 | {% endif %} 256 | 257 | {% if elasticsearch_indices_breaker_request_limit is defined %} 258 | indices.breaker.request.limit: {{ elasticsearch_indices_breaker_request_limit }} 259 | {% endif %} 260 | 261 | {% if elasticsearch_indices_breaker_total_limit is defined %} 262 | indices.breaker.total.limit: {{ elasticsearch_indices_breaker_total_limit }} 263 | {% endif %} 264 | 265 | ############################## Network And HTTP ############################### 266 | 267 | # ElasticSearch, by default, binds itself to the 0.0.0.0 address, and listens 268 | # on port [9200-9300] for HTTP traffic and on port [9300-9400] for node-to-node 269 | # communication. (the range means that if the port is busy, it will automatically 270 | # try the next port). 271 | 272 | # Set the bind address specifically (IPv4 or IPv6): 273 | # 274 | # network.bind_host: 192.168.0.1 275 | {% if elasticsearch_network_bind_host is defined %} 276 | network.bind_host: {{ elasticsearch_network_bind_host }} 277 | {% endif %} 278 | 279 | # Set the address other nodes will use to communicate with this node. If not 280 | # set, it is automatically derived. It must point to an actual IP address. 281 | # 282 | # network.publish_host: 192.168.0.1 283 | {% if elasticsearch_network_publish_host is defined %} 284 | network.publish_host: {{ elasticsearch_network_publish_host }} 285 | {% endif %} 286 | 287 | # Set both 'bind_host' and 'publish_host': 288 | # 289 | # network.host: 192.168.0.1 290 | {% if elasticsearch_network_host is defined %} 291 | network.host: {{ elasticsearch_network_host }} 292 | {% endif %} 293 | 294 | # Set a custom port for the node to node communication (9300 by default): 295 | # 296 | # transport.tcp.port: 9300 297 | {% if elasticsearch_network_transport_tcp_port is defined %} 298 | transport.tcp.port: {{ elasticsearch_network_transport_tcp_port }} 299 | {% endif %} 300 | 301 | # Enable compression for all communication between nodes (disabled by default): 302 | # 303 | # transport.tcp.compress: true 304 | {% if elasticsearch_network_transport_tcp_compress is defined %} 305 | transport.tcp.compress: {{ elasticsearch_network_transport_tcp_compress }} 306 | {% endif %} 307 | 308 | # Set a custom port to listen for HTTP traffic: 309 | # 310 | # http.port: 9200 311 | {% if elasticsearch_network_http_port is defined %} 312 | http.port: {{ elasticsearch_network_http_port }} 313 | {% endif %} 314 | 315 | # Set a custom allowed content length: 316 | # 317 | # http.max_content_length: 100mb 318 | {% if elasticsearch_network_http_max_content_lengtht is defined %} 319 | http.max_content_length: {{ elasticsearch_network_http_max_content_lengtht }} 320 | {% endif %} 321 | 322 | # Disable HTTP completely: 323 | # 324 | # http.enabled: false 325 | {% if elasticsearch_network_http_enabled is defined %} 326 | http.enabled: {{ elasticsearch_network_http_enabled }} 327 | {% endif %} 328 | 329 | # Basic HTTP 330 | {% if elasticsearch_http_basic_log is defined %} 331 | http.basic.log: {{ elasticsearch_http_basic_log }} 332 | {% endif %} 333 | {% if elasticsearch_http_basic_user is defined %} 334 | http.basic.user: {{ elasticsearch_http_basic_user }} 335 | {% endif %} 336 | {% if elasticsearch_http_basic_password is defined %} 337 | http.basic.password: {{ elasticsearch_http_basic_password }} 338 | {% endif %} 339 | 340 | 341 | ################################### Gateway ################################### 342 | 343 | # The gateway allows for persisting the cluster state between full cluster 344 | # restarts. Every change to the state (such as adding an index) will be stored 345 | # in the gateway, and when the cluster starts up for the first time, 346 | # it will read its state from the gateway. 347 | 348 | # There are several types of gateway implementations. For more information, 349 | # see . 350 | 351 | # The default gateway type is the "local" gateway (recommended): 352 | # 353 | # gateway.type: local 354 | {% if elasticsearch_gateway_type is defined %} 355 | gateway.type: {{ elasticsearch_gateway_type }} 356 | {% endif %} 357 | 358 | # Settings below control how and when to start the initial recovery process on 359 | # a full cluster restart (to reuse as much local data as possible when using shared 360 | # gateway). 361 | 362 | # Allow recovery process after N nodes in a cluster are up: 363 | # 364 | # gateway.recover_after_nodes: 1 365 | {% if elasticsearch_gateway_recover_after_nodes is defined %} 366 | gateway.recover_after_nodes: {{ elasticsearch_gateway_recover_after_nodes }} 367 | {% endif %} 368 | 369 | # Set the timeout to initiate the recovery process, once the N nodes 370 | # from previous setting are up (accepts time value): 371 | # 372 | # gateway.recover_after_time: 5m 373 | {% if elasticsearch_gateway_recover_after_time is defined %} 374 | gateway.recover_after_time: {{ elasticsearch_gateway_recover_after_time }} 375 | {% endif %} 376 | 377 | # Set how many nodes are expected in this cluster. Once these N nodes 378 | # are up (and recover_after_nodes is met), begin recovery process immediately 379 | # (without waiting for recover_after_time to expire): 380 | # 381 | # gateway.expected_nodes: 2 382 | {% if elasticsearch_gateway_expected_nodes is defined %} 383 | gateway.expected_nodes: {{ elasticsearch_gateway_expected_nodes }} 384 | {% endif %} 385 | 386 | ############################# Recovery Throttling ############################# 387 | 388 | # These settings allow to control the process of shards allocation between 389 | # nodes during initial recovery, replica allocation, rebalancing, 390 | # or when adding and removing nodes. 391 | 392 | # Set the number of concurrent recoveries happening on a node: 393 | # 394 | # 1. During the initial recovery 395 | # 396 | # cluster.routing.allocation.node_initial_primaries_recoveries: 4 397 | {% if elasticsearch_recovery_node_initial_primaries_recoveries is defined %} 398 | cluster.routing.allocation.node_initial_primaries_recoveries: {{ elasticsearch_recovery_node_initial_primaries_recoveries }} 399 | {% endif %} 400 | 401 | # 402 | # 2. During adding/removing nodes, rebalancing, etc 403 | # 404 | # cluster.routing.allocation.node_concurrent_recoveries: 2 405 | {% if elasticsearch_recovery_node_concurrent_recoveries is defined %} 406 | cluster.routing.allocation.node_concurrent_recoveries: {{ elasticsearch_recovery_node_concurrent_recoveries }} 407 | {% endif %} 408 | 409 | # Set to throttle throughput when recovering (eg. 100mb, by default unlimited): 410 | # 411 | # indices.recovery.max_size_per_sec: 0 412 | {% if elasticsearch_recovery_max_size_per_sec is defined %} 413 | indices.recovery.max_size_per_sec: {{ elasticsearch_recovery_max_size_per_sec }} 414 | {% endif %} 415 | 416 | # Set to limit the number of open concurrent streams when 417 | # recovering a shard from a peer: 418 | # 419 | # indices.recovery.concurrent_streams: 5 420 | {% if elasticsearch_recovery_concurrent_streams is defined %} 421 | indices.recovery.concurrent_streams: {{ elasticsearch_recovery_concurrent_streams }} 422 | {% endif %} 423 | 424 | 425 | ################################## Discovery ################################## 426 | 427 | {% if elasticsearch_plugin_aws_version is defined %} 428 | 429 | {% if elasticsearch_plugin_aws_discovery_disable is not defined %} 430 | discovery.type: ec2 431 | {% endif %} 432 | {% if elasticsearch_plugin_aws_ec2_groups is defined %} 433 | discovery.ec2.groups: '{{ elasticsearch_plugin_aws_ec2_groups }}' 434 | {% endif %} 435 | {% if elasticsearch_plugin_aws_ec2_ping_timeout is defined %} 436 | discovery.ec2.ping_timeout: {{ elasticsearch_plugin_aws_ec2_ping_timeout}} 437 | {% endif %} 438 | cloud.node.auto_attributes: true 439 | {% if elasticsearch_plugin_aws_access_key is defined %} 440 | {% if elasticsearch_plugin_aws_secret_key is defined %} 441 | cloud.aws.access_key: '{{ elasticsearch_plugin_aws_access_key }}' 442 | cloud.aws.secret_key: '{{ elasticsearch_plugin_aws_secret_key }}' 443 | {% endif %} 444 | {% endif %} 445 | {% if elasticsearch_plugin_aws_region is defined %} 446 | cloud.aws.region: {{ elasticsearch_plugin_aws_region}} 447 | {% endif %} 448 | 449 | {% endif %} 450 | 451 | # Discovery infrastructure ensures nodes can be found within a cluster 452 | # and master node is elected. Multicast discovery is the default. 453 | 454 | # Set to ensure a node sees N other master eligible nodes to be considered 455 | # operational within the cluster. Set this option to a higher value (2-4) 456 | # for large clusters (>3 nodes): 457 | # 458 | # discovery.zen.minimum_master_nodes: 1 459 | {% if elasticsearch_discovery_zen_minimum_master_nodes is defined %} 460 | discovery.zen.minimum_master_nodes: {{ elasticsearch_discovery_zen_minimum_master_nodes }} 461 | {% endif %} 462 | 463 | # Set the time to wait for ping responses from other nodes when discovering. 464 | # Set this option to a higher value on a slow or congested network 465 | # to minimize discovery failures: 466 | # 467 | # discovery.zen.ping.timeout: 3s 468 | {% if elasticsearch_discovery_zen_ping_timeout is defined %} 469 | discovery.zen.ping.timeout: {{ elasticsearch_discovery_zen_ping_timeout }} 470 | {% endif %} 471 | 472 | # See 473 | # for more information. 474 | 475 | # Unicast discovery allows to explicitly control which nodes will be used 476 | # to discover the cluster. It can be used when multicast is not present, 477 | # or to restrict the cluster communication-wise. 478 | # 479 | # 1. Disable multicast discovery (enabled by default): 480 | # 481 | # discovery.zen.ping.multicast.enabled: false 482 | {% if elasticsearch_discovery_zen_ping_multicast_enabled is defined %} 483 | discovery.zen.ping.multicast.enabled: {{ elasticsearch_discovery_zen_ping_multicast_enabled }} 484 | {% endif %} 485 | 486 | # 487 | # 2. Configure an initial list of master nodes in the cluster 488 | # to perform discovery when new nodes (master or data) are started: 489 | # 490 | # discovery.zen.ping.unicast.hosts: ["host1", "host2:port", "host3[portX-portY]"] 491 | {% if elasticsearch_discovery_zen_ping_unicast_hosts is defined %} 492 | discovery.zen.ping.unicast.hosts: {{ elasticsearch_discovery_zen_ping_unicast_hosts }} 493 | {% endif %} 494 | 495 | # EC2 discovery allows to use AWS EC2 API in order to perform discovery. 496 | # 497 | # You have to install the cloud-aws plugin for enabling the EC2 discovery. 498 | # 499 | # See 500 | # for more information. 501 | # 502 | # See 503 | # for a step-by-step tutorial. 504 | 505 | # Fault Discovery 506 | # See 507 | {% if elasticsearch_discovery_zen_fd_ping_interval is defined %} 508 | discovery.zen.fd.ping_interval: {{ elasticsearch_discovery_zen_fd_ping_interval }} 509 | {% endif %} 510 | {% if elasticsearch_discovery_zen_fd_ping_timeout is defined %} 511 | discovery.zen.fd.ping_timeout: {{ elasticsearch_discovery_zen_fd_ping_timeout }} 512 | {% endif %} 513 | {% if elasticsearch_discovery_zen_fd_ping_retries is defined %} 514 | discovery.zen.fd.ping_retries: {{ elasticsearch_discovery_zen_fd_ping_retries }} 515 | {% endif %} 516 | 517 | # Configurations for Google Compute Engine plugin 518 | {% if elasticsearch_cloud_gce_project_id is defined %} 519 | cloud.gce.project_id: {{ elasticsearch_cloud_gce_project_id }} 520 | {% endif %} 521 | {% if elasticsearch_cloud_gce_zone is defined %} 522 | cloud.gce.zone: {{ elasticsearch_cloud_gce_zone }} 523 | {% endif %} 524 | {% if elasticsearch_discovery_type is defined %} 525 | discovery.type: {{ elasticsearch_discovery_type }} 526 | {% endif %} 527 | {% if elasticsearch_discovery_gce_tags is defined %} 528 | discovery.gce.tags: {{ elasticsearch_discovery_gce_tags }} 529 | {% endif %} 530 | 531 | 532 | ################################## Slow Log ################################## 533 | 534 | # Shard level query and fetch threshold logging. 535 | 536 | #index.search.slowlog.threshold.query.warn: 10s 537 | {% if elasticsearch_slowlog_threshold_query_warn is defined %} 538 | index.search.slowlog.threshold.query.warn: {{ elasticsearch_slowlog_threshold_query_warn }} 539 | {% endif %} 540 | #index.search.slowlog.threshold.query.info: 5s 541 | {% if elasticsearch_slowlog_threshold_query_info is defined %} 542 | index.search.slowlog.threshold.query.info: {{ elasticsearch_slowlog_threshold_query_info }} 543 | {% endif %} 544 | #index.search.slowlog.threshold.query.debug: 2s 545 | {% if elasticsearch_slowlog_threshold_query_debug is defined %} 546 | index.search.slowlog.threshold.query.debug: {{ elasticsearch_slowlog_threshold_query_debug }} 547 | {% endif %} 548 | #index.search.slowlog.threshold.query.trace: 500ms 549 | {% if elasticsearch_slowlog_threshold_query_trace is defined %} 550 | index.search.slowlog.threshold.query.trace: {{ elasticsearch_slowlog_threshold_query_trace }} 551 | {% endif %} 552 | 553 | #index.search.slowlog.threshold.fetch.warn: 1s 554 | {% if elasticsearch_slowlog_threshold_fetch_warn is defined %} 555 | index.search.slowlog.threshold.fetch.warn: {{ elasticsearch_slowlog_threshold_fetch_warn }} 556 | {% endif %} 557 | #index.search.slowlog.threshold.fetch.info: 800ms 558 | {% if elasticsearch_slowlog_threshold_fetch_info is defined %} 559 | index.search.slowlog.threshold.fetch.info: {{ elasticsearch_slowlog_threshold_fetch_info }} 560 | {% endif %} 561 | #index.search.slowlog.threshold.fetch.debug: 500ms 562 | {% if elasticsearch_slowlog_threshold_fetch_debug is defined %} 563 | index.search.slowlog.threshold.fetch.debug: {{ elasticsearch_slowlog_threshold_fetch_debug }} 564 | {% endif %} 565 | #index.search.slowlog.threshold.fetch.trace: 200ms 566 | {% if elasticsearch_slowlog_threshold_fetch_trace is defined %} 567 | index.search.slowlog.threshold.fetch.trace: {{ elasticsearch_slowlog_threshold_fetch_trace }} 568 | {% endif %} 569 | 570 | #index.indexing.slowlog.threshold.index.warn: 10s 571 | {% if elasticsearch_slowlog_threshold_index_warn is defined %} 572 | index.indexing.slowlog.threshold.index.warn: {{ elasticsearch_slowlog_threshold_index_warn }} 573 | {% endif %} 574 | #index.indexing.slowlog.threshold.index.info: 5s 575 | {% if elasticsearch_slowlog_threshold_index_info is defined %} 576 | index.indexing.slowlog.threshold.index.info: {{ elasticsearch_slowlog_threshold_index_info }} 577 | {% endif %} 578 | #index.indexing.slowlog.threshold.index.debug: 2s 579 | {% if elasticsearch_slowlog_threshold_index_debug is defined %} 580 | index.indexing.slowlog.threshold.index.debug: {{ elasticsearch_slowlog_threshold_index_debug }} 581 | {% endif %} 582 | #index.indexing.slowlog.threshold.index.trace: 500ms 583 | {% if elasticsearch_slowlog_threshold_index_trace is defined %} 584 | index.indexing.slowlog.threshold.index.trace: {{ elasticsearch_slowlog_threshold_index_trace }} 585 | {% endif %} 586 | 587 | ################################## GC Logging ################################ 588 | 589 | #monitor.jvm.gc.ParNew.warn: 1000ms 590 | {% if elasticsearch_gc_par_new_warn is defined %} 591 | monitor.jvm.gc.ParNew.warn: {{ elasticsearch_gc_par_new_warn }} 592 | {% endif %} 593 | #monitor.jvm.gc.ParNew.info: 700ms 594 | {% if elasticsearch_gc_par_new_info is defined %} 595 | monitor.jvm.gc.ParNew.info: {{ elasticsearch_gc_par_new_info }} 596 | {% endif %} 597 | #monitor.jvm.gc.ParNew.debug: 400ms 598 | {% if elasticsearch_gc_par_new_debug is defined %} 599 | monitor.jvm.gc.ParNew.debug: {{ elasticsearch_gc_par_new_debug }} 600 | {% endif %} 601 | 602 | #monitor.jvm.gc.ConcurrentMarkSweep.warn: 10s 603 | {% if elasticsearch_gc_soncurrent_mark_sweep_warn is defined %} 604 | monitor.jvm.gc.ConcurrentMarkSweep.warn: {{ elasticsearch_gc_soncurrent_mark_sweep_warn }} 605 | {% endif %} 606 | #monitor.jvm.gc.ConcurrentMarkSweep.info: 5s 607 | {% if elasticsearch_gc_soncurrent_mark_sweep_info is defined %} 608 | monitor.jvm.gc.ConcurrentMarkSweep.info: {{ elasticsearch_gc_soncurrent_mark_sweep_info }} 609 | {% endif %} 610 | #monitor.jvm.gc.ConcurrentMarkSweep.debug: 2s 611 | {% if elasticsearch_gc_soncurrent_mark_sweep_debug is defined %} 612 | monitor.jvm.gc.ConcurrentMarkSweep.debug: {{ elasticsearch_gc_soncurrent_mark_sweep_debug }} 613 | {% endif %} 614 | 615 | ################################### Varia ##################################### 616 | 617 | {% if elasticsearch_plugin_marvel_version is defined %} 618 | 619 | {% if elasticsearch_plugin_marvel_agent_exporter_es_index_timeformat is defined %} 620 | marvel.agent.exporter.es.index.timeformat: {{ elasticsearch_plugin_marvel_agent_exporter_es_index_timeformat }} 621 | {% endif %} 622 | {% if elasticsearch_plugin_marvel_agent_interval is defined %} 623 | marvel.agent.interval: {{ elasticsearch_plugin_marvel_agent_interval }} 624 | {% endif %} 625 | {% if elasticsearch_plugin_marvel_agent_indices is defined %} 626 | marvel.agent.indices: {{ elasticsearch_plugin_marvel_agent_indices }} 627 | {% endif %} 628 | {% if elasticsearch_plugin_marvel_agent_exporter_es_hosts is defined %} 629 | marvel.agent.exporter.es.hosts: {{ elasticsearch_plugin_marvel_agent_exporter_es_hosts }} 630 | {% endif %} 631 | {% if elasticsearch_plugin_marvel_agent_enabled is defined %} 632 | marvel.agent.enabled: {{ elasticsearch_plugin_marvel_agent_enabled }} 633 | {% endif %} 634 | 635 | {% endif %} 636 | 637 | {% if elasticsearch_misc_auto_create_index is defined %} 638 | action.auto_create_index: {{ elasticsearch_misc_auto_create_index }} 639 | {% endif %} 640 | {% if elasticsearch_misc_disable_delete_all_indices is defined %} 641 | action.disable_delete_all_indices: {{ elasticsearch_misc_disable_delete_all_indices }} 642 | {% endif %} 643 | {% if elasticsearch_thread_pools is defined %} 644 | {% for threadPoolSetting in elasticsearch_thread_pools %} 645 | {{ threadPoolSetting }} 646 | {% endfor %} 647 | {% endif %} 648 | 649 | 650 | {% if elasticsearch_indices_cache_filter_size is defined %} 651 | indices.cache.filter.size: {{ elasticsearch_indices_cache_filter_size }} 652 | {% endif %} 653 | 654 | ################################### Dynamic Scripting ##################################### 655 | 656 | {% if elasticsearch_script_disable_dynamic is defined %} 657 | script.disable_dynamic: {{ elasticsearch_script_disable_dynamic }} 658 | {% endif %} 659 | 660 | ################################### CORS Settings ##################################### 661 | 662 | {% if elasticsearch_http_cors_enabled is defined %} 663 | http.cors.enabled: {{ elasticsearch_http_cors_enabled }} 664 | {% endif %} 665 | 666 | {% if elasticsearch_http_cors_allow_origin is defined %} 667 | http.cors.allow-origin: {{ elasticsearch_http_cors_allow_origin}} 668 | {% endif %} 669 | 670 | {% if elasticsearch_script_groovy_sandbox_enabled is defined %} 671 | script.groovy.sandbox.enabled: {{ elasticsearch_script_groovy_sandbox_enabled }} 672 | {% endif %} 673 | 674 | 675 | ################################### Awareness Settings ##################################### 676 | 677 | {% if elasticsearch_cluster_routing_allocation_zone_awareness is defined %} 678 | cluster.routing.allocation.awareness.attributes: zone 679 | node.zone: {{ facter_ec2_placement_availability_zone }} 680 | {% endif %} 681 | -------------------------------------------------------------------------------- /tests/ansible.cfg: -------------------------------------------------------------------------------- 1 | [defaults] 2 | roles_path=../../ -------------------------------------------------------------------------------- /tests/elastic_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | # Put data 5 | curl -XPUT 'http://localhost:9200/blog/user/dilbert' -d '{ "name" : "Dilbert Brown" }' 6 | 7 | #Get data 8 | curl -XGET 'http://localhost:9200/blog/user/dilbert?pretty=true' | grep "\"name\" : \"Dilbert Brown\"" 9 | 10 | # Check if kopf is running 11 | curl -XGET 'http://localhost:9200/_plugin/kopf/' | grep "ng-app=\"kopf\"" 12 | -------------------------------------------------------------------------------- /tests/local.ini: -------------------------------------------------------------------------------- 1 | localhost ansible_connection='local' -------------------------------------------------------------------------------- /tests/test1.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # This playbook nexus 3 | - hosts: all 4 | sudo: true 5 | vars_files: 6 | - "test1_var.yml" 7 | roles: 8 | - ansible-elasticsearch 9 | -------------------------------------------------------------------------------- /tests/test1_var.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | elasticsearch_version: 1.4.2 4 | elasticsearch_apt_java_package: oracle-java8-installer 5 | elasticsearch_java_home: /usr/lib/jvm/java-8-oracle 6 | elasticsearch_heap_size: 1g 7 | elasticsearch_max_open_files: 65535 8 | elasticsearch_timezone: "America/New_York" 9 | elasticsearch_node_max_local_storage_nodes: 1 10 | elasticsearch_index_mapper_dynamic: "true" 11 | elasticsearch_memory_bootstrap_mlockall: "true" 12 | elasticsearch_install_java: "true" 13 | elasticsearch_plugins: 14 | - { name: 'elasticsearch/elasticsearch-mapper-attachments/2.4.1' } 15 | - { name: 'com.github.richardwilly98.elasticsearch/elasticsearch-river-mongodb/2.0.5' } 16 | - { name: 'facet-script', url: 'http://dl.bintray.com/content/imotov/elasticsearch-plugins/elasticsearch-facet-script-1.1.2.zip' } 17 | - { name: 'lmenezes/elasticsearch-kopf' } 18 | elasticsearch_thread_pools: 19 | - "threadpool.bulk.type: fixed" 20 | - "threadpool.bulk.size: 50" 21 | - "threadpool.bulk.queue_size: 1000" 22 | -------------------------------------------------------------------------------- /vagrant-inventory.ini: -------------------------------------------------------------------------------- 1 | # 2 | # Inventory for provisioning with Vagrant 3 | # 4 | 5 | ##################### 6 | # Local Environment # 7 | ##################### 8 | [vagrant] 9 | 192.168.111.10 ansible_ssh_user=vagrant ansible_ssh_pass=vagrant 10 | 11 | [vagrant:vars] 12 | # spm_client_token= 13 | -------------------------------------------------------------------------------- /vagrant-main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Elasticsearch Ansible Playbook 3 | - hosts: all 4 | user: $user 5 | sudo: yes 6 | 7 | vars_files: 8 | - defaults/main.yml 9 | - vars/vagrant.yml 10 | 11 | tasks: 12 | - include: tasks/main.yml 13 | # Uncomment to install and enable SPM. Make sure to set the spm_client_token variable in your inventory.ini to your SPM key 14 | # - include: tasks/spm.yml 15 | 16 | handlers: 17 | - include: handlers/main.yml 18 | -------------------------------------------------------------------------------- /vars/sample.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Elasticsearch Ansible Sample Variables 3 | 4 | elasticsearch_version: 0.90.5 5 | elasticsearch_heap_size: 1g 6 | elasticsearch_max_open_files: 65535 7 | elasticsearch_max_locked_memory: unlimited 8 | elasticsearch_timezone: "America/New_York" 9 | elasticsearch_cluster_name: elasticsearch-ansible 10 | elasticsearch_node_name: elasticsearch-ansible-node 11 | elasticsearch_node_max_local_storage_nodes: 1 12 | elasticsearch_index_mapper_dynamic: "true" 13 | elasticsearch_memory_bootstrap_mlockall: "true" 14 | elasticsearch_gateway_type: local 15 | elasticsearch_gateway_recover_after_nodes: 1 16 | elasticsearch_gateway_recover_after_time: 2m 17 | elasticsearch_gateway_expected_nodes: 1 18 | elasticsearch_discovery_zen_minimum_master_nodes: 1 19 | elasticsearch_discovery_zen_ping_timeout: 30s 20 | elasticsearch_discovery_zen_ping_multicast_enabled: "true" 21 | elasticsearch_misc_auto_create_index: "true" 22 | elasticsearch_misc_query_bool_max_clause_count: 4096 23 | elasticsearch_misc_disable_delete_all_indices: "true" 24 | elasticsearch_java_opts: "-XX:-UseSuperWord" 25 | -------------------------------------------------------------------------------- /vars/vagrant.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Elasticsearch Ansible Variables 3 | 4 | elasticsearch_version: 1.7.3 5 | elasticsearch_apt_java_package: oracle-java8-installer 6 | elasticsearch_java_home: /usr/lib/jvm/java-8-oracle 7 | elasticsearch_heap_size: 1g 8 | elasticsearch_max_open_files: 65535 9 | elasticsearch_timezone: "America/New_York" 10 | elasticsearch_node_max_local_storage_nodes: 1 11 | elasticsearch_index_mapper_dynamic: "true" 12 | elasticsearch_memory_bootstrap_mlockall: "true" 13 | elasticsearch_install_java: "true" 14 | elasticsearch_plugins: 15 | - { name: 'elasticsearch/elasticsearch-mapper-attachments/2.7.1', reinstall: false } 16 | - { name: 'com.github.richardwilly98.elasticsearch/elasticsearch-river-mongodb/2.0.9', reinstall: false } 17 | - { name: 'facet-script', url: 'http://dl.bintray.com/content/imotov/elasticsearch-plugins/elasticsearch-facet-script-1.1.2.zip', reinstall: false } 18 | - { name: 'http-basic', url: 'https://github.com/Asquera/elasticsearch-http-basic/releases/download/v1.5.1/elasticsearch-http-basic-1.5.1.jar', download_only: true, reinstall: false } 19 | elasticsearch_thread_pools: 20 | - "threadpool.bulk.type: fixed" 21 | - "threadpool.bulk.size: 50" 22 | - "threadpool.bulk.queue_size: 1000" 23 | elasticsearch_service_startonboot: yes 24 | --------------------------------------------------------------------------------