diff --git a/.kitchen.yml b/.kitchen.yml index e729a58ff..312b48b75 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -94,12 +94,3 @@ suites: run_list: - recipe[java] - recipe[elasticsearch_test::default_with_plugins] - - - name: shieldwatcher # install licensed plugins for testing - require_chef_omnibus: true - run_list: - - recipe[java] - - recipe[elasticsearch_test::shieldwatcher] - attributes: - elasticsearch: - install_type: package diff --git a/README.md b/README.md index 0e1762f6a..9d3309a91 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [Java Runtime](https://www.java.com/en/) - This cookbook requires java, but does not provide it. Please install Java before using any recipe in this cookbook. Please also note that Elasticsearch itself has [specific minimum Java version requirements](https://www.elastic.co/guide/en/elasticsearch/reference/current/setup.html#jvm-version). We recommend [this cookbook](https://github.com/agileorbit-cookbooks/java) to install Java. -[Elasticsearch](https://www.elastic.co/products/elasticsearch) - This cookbook is being written and tested to support Elasticsearch 2.x and greater. If you must have a cookbook that works with older versions of Elasticsearch, please test and then pin to a specific, older `major.minor` version of this cookbook and only leave the patch release to float. +[Elasticsearch](https://www.elastic.co/products/elasticsearch) - This cookbook is being written and tested to support Elasticsearch 5.x and greater. If you must have a cookbook that works with older versions of Elasticsearch, please test and then pin to a specific, older `major.minor` version of this cookbook and only leave the patch release to float. Older versions can be found via [Git tags](https://github.com/elastic/cookbook-elasticsearch/tags) or on [Chef Supermarket](https://supermarket.chef.io/cookbooks/elasticsearch). We also maintain bugfix branches for major released lines (0.x, 1.x, 2.x) of this cookbook so that we can still release fixes for older cookbooks. [Chef](https://www.chef.io/) - The latest release of this cookbook is intended to support the three most recent releases of Chef, and tests against those. Earlier versions may also be supported, though we suggest that you use Chef 12.x at a minimum. It implements support for CI as well as more modern testing with chefspec and test-kitchen. It no longer supports some of the more extraneous features such as discovery (use [chef search](https://docs.chef.io/chef_search.html) in your wrapper cookbook) or EBS device creation (use [the aws cookbook](https://github.com/chef-cookbooks/aws)). @@ -24,7 +24,7 @@ the version parameter as a string into your download_url. |Name|Default|Other values| |----|-------|------------| -|`default['elasticsearch']['version']`|`'2.4.1'`|[See list](attributes/default.rb).| +|`default['elasticsearch']['version']`|`'5.0.0'`|[See list](attributes/default.rb).| |`default['elasticsearch']['install_type']`|`:package`|`:tarball`| |`default['elasticsearch']['download_urls']['debian']`|[See values](attributes/default.rb).|`%s` will be replaced with the version attribute above| |`default['elasticsearch']['download_urls']['rhel']`|[See values](attributes/default.rb).|`%s` will be replaced with the version attribute above| diff --git a/attributes/default.rb b/attributes/default.rb index d080932bb..d8fa0c7a2 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -1,90 +1,15 @@ # elasticsearch version & install type -default['elasticsearch']['version'] = '2.4.1' +default['elasticsearch']['version'] = '5.0.0' default['elasticsearch']['install_type'] = :package # platform_family keyed download URLs default['elasticsearch']['download_urls'] = { - 'debian' => 'https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-%s.deb', - 'rhel' => 'https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-%s.noarch.rpm', - 'tar' => 'https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-%s.tar.gz' -} - -default['elasticsearch']['download_urls_v2'] = { - 'debian' => 'https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/deb/elasticsearch/%s/elasticsearch-%s.deb', - 'rhel' => 'https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/rpm/elasticsearch/%s/elasticsearch-%s.rpm', - 'tar' => 'https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/%s/elasticsearch-%s.tar.gz' + 'debian' => 'https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-%s.deb', + 'rhel' => 'https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-%s.rpm', + 'tar' => 'https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-%s.tar.gz' } # platform_family keyed download sha256 checksums -default['elasticsearch']['checksums']['1.4.5']['debian'] = '68dce951181e9802e94fd83b894f4b628394fc44bb01c77eb61fdbd1940d94b5' -default['elasticsearch']['checksums']['1.4.5']['rhel'] = '29b005c4148036556f78d6bd01a5e7c8e4ea60e2c20f82b63d8362ab46d83a19' -default['elasticsearch']['checksums']['1.4.5']['tar'] = 'dc28aa9e441cbc3282ecc9cb498bea219355887b102aac872bdf05d5977356e2' -default['elasticsearch']['checksums']['1.5.0']['debian'] = '15a02a2bea74da2330bb78718efb3a8f83a2b2e040a6ee859e100a6556981f36' -default['elasticsearch']['checksums']['1.5.0']['rhel'] = 'b72a9fb9a2c0471e8fe1a35373cdcfe39d29e72b7281bfccbdc32d03ee0eff70' -default['elasticsearch']['checksums']['1.5.0']['tar'] = 'acf572c606552bc446cceef3f8e93814a363ba0d215b323a2864682b3abfbe45' -default['elasticsearch']['checksums']['1.6.2']['debian'] = 'da22c2df44ade970c7d8ec346fd37a440ed40f9e73fb3427b9eacf44baf298c2' -default['elasticsearch']['checksums']['1.6.2']['rhel'] = '60c75a6f386bd729c6af2995af0a5290dd0ed6286673d435fc52620721815d91' -default['elasticsearch']['checksums']['1.6.2']['tar'] = 'b7ef3aae0a263c2312bd1a25b191c3c108c92d5413c3527d776587e582c518d0' -default['elasticsearch']['checksums']['1.7.1']['debian'] = '5832808f2a4c77de5af225db11da00138d9ea07a17f7b9212f4d2aac5317169d' -default['elasticsearch']['checksums']['1.7.1']['rhel'] = '9b083f441490b32f98f9bf654e5e8ddec885838128726691103cfda5068423bc' -default['elasticsearch']['checksums']['1.7.1']['tar'] = '86a0c20eea6ef55b14345bff5adf896e6332437b19180c4582a346394abde019' -default['elasticsearch']['checksums']['1.7.2']['debian'] = '791fb9f2131be2cf8c1f86ca35e0b912d7155a53f89c2df67467ca2105e77ec2' -default['elasticsearch']['checksums']['1.7.2']['rhel'] = 'c5410b88494d5cc9fdadf59353430b46c28e58eddc5c610ea4c4516eacc2fa09' -default['elasticsearch']['checksums']['1.7.2']['tar'] = '6f81935e270c403681e120ec4395c28b2ddc87e659ff7784608b86beb5223dd2' -default['elasticsearch']['checksums']['1.7.3']['debian'] = '52950c688cb3d6a13686753b4e8b1c80183e81174059924ee08b2df172afbb1c' -default['elasticsearch']['checksums']['1.7.3']['rhel'] = '2380343487ffafc6a7a834cf51d2abbfb7c5ad9d9d45301671adebf97abc632a' -default['elasticsearch']['checksums']['1.7.3']['tar'] = 'af517611493374cfb2daa8897ae17e63e2efea4d0377d316baa351c1776a2bca' -default['elasticsearch']['checksums']['1.7.4']['debian'] = 'f46a2892e454030d267f087db1be6bd9ae556bb1708a12cf94eeb4180951bf1f' -default['elasticsearch']['checksums']['1.7.4']['rhel'] = 'a3469fa93e05029ae4ba9dd7ddf80828095b850bc5764c24bae4dafc2346ef1f' -default['elasticsearch']['checksums']['1.7.4']['tar'] = '395f3417c26a6b36125f6a062c1129b454a961efea09151c692adc63562e5a94' -default['elasticsearch']['checksums']['1.7.5']['debian'] = '4e5a4d29f5fbd737d203e7049f2e18515c3443f9e01e193583e2b5c60779cc0f' -default['elasticsearch']['checksums']['1.7.5']['rhel'] = '4e0a4ff1ae76337308ebed977fb29c2f2d1251b2780f751676e3b18a1d7db00f' -default['elasticsearch']['checksums']['1.7.5']['tar'] = '0aa58947d66b487488e86059352deb7c6cab5da4accdff043cce9fed7c3d2fa7' -default['elasticsearch']['checksums']['2.0.0-rc1']['debian'] = '6ba92f96676932756ff7113f42d8946679e9be2144acece59bd79367568eb712' -default['elasticsearch']['checksums']['2.0.0-rc1']['rhel'] = '4dd4bdd1b4333f221bc5d2a2638bdc89282d57923842ce4c76607497abafb44d' -default['elasticsearch']['checksums']['2.0.0-rc1']['tar'] = 'cfd97bba0c49000a2799fffd359ec351f0ca7ef5f0a8c160920137db6b057784' -default['elasticsearch']['checksums']['2.0.0']['debian'] = 'f846cab2b7e99159650d38767249275c2fd5d3574fe700ef199cd1cb06ef28bf' -default['elasticsearch']['checksums']['2.0.0']['rhel'] = '6bd2d7840447836450d8781fffa9e296dfb257b523598c6e55433850e37feb25' -default['elasticsearch']['checksums']['2.0.0']['tar'] = 'b25f13f615337c2072964fd9fc5c7250f8a2a983b22198daf93548285d5d16df' -default['elasticsearch']['checksums']['2.0.1']['debian'] = '815a7b7d3bbd862c3ec136aa7bfb1adec272bdecdae45233d9ffdf61d307e86c' -default['elasticsearch']['checksums']['2.0.1']['rhel'] = '69957ef5ee6a142adf02c1065faa29bda7e2cf7f2d5c56edad4852b7f644345a' -default['elasticsearch']['checksums']['2.0.1']['tar'] = '7be4a6c717002057e422073ca8e957df8b4cb198bf2399a0d79f42121e34798b' -default['elasticsearch']['checksums']['2.1.0']['debian'] = '099fdeb7b3903ce8cea7d39b577ed6445b78b64d14dd2664fd2ca1e0896691dd' -default['elasticsearch']['checksums']['2.1.0']['rhel'] = 'a79c1985224c1b57479275794b258f4eba973e0b65f5c62b1c38e02738a1ce71' -default['elasticsearch']['checksums']['2.1.0']['tar'] = '8a4e85bcb506daa369651506af1cbc55c09fd7ff387d111142ae14d0a85d4d14' -default['elasticsearch']['checksums']['2.1.1']['debian'] = '097400b0b46c826c6a8be837739ade0c0c326b47d38ef54df7bd48de9e9e9995' -default['elasticsearch']['checksums']['2.1.1']['rhel'] = '22fc646aed2b6900116589a5712ac9324682470336bbbb025b4a607efb735e5a' -default['elasticsearch']['checksums']['2.1.1']['tar'] = 'ebd69c0483f20ba7e51caa9606d4e3ce5fe2667e1216c799f0cdbb815c317ce6' -default['elasticsearch']['checksums']['2.2.0']['debian'] = 'c97ac75303a7ba042c45adff74e27c3584d64d8e0f6f24c43afdcbff484b43d5' -default['elasticsearch']['checksums']['2.2.0']['rhel'] = '13fe3717e7761f23cd41a148a31ee49496cbdb45f44bfaeb3ba5538a41fdd79a' -default['elasticsearch']['checksums']['2.2.0']['tar'] = 'ed70cc81e1f55cd5f0032beea2907227b6ad8e7457dcb75ddc97a2cc6e054d30' -default['elasticsearch']['checksums']['2.2.1']['debian'] = 'cb89f880e03276624b3529506c9d2ed6b537968d1c819026e087117cd4c60c7c' -default['elasticsearch']['checksums']['2.2.1']['rhel'] = 'ddb5e1545e90b45e2b9495c35d5336a40fc63e09d8ac9cac73079888405df7f4' -default['elasticsearch']['checksums']['2.2.1']['tar'] = '7d43d18a8ee8d715d827ed26b4ff3d939628f5a5b654c6e8de9d99bf3a9b2e03' -default['elasticsearch']['checksums']['2.2.2']['debian'] = '5d44d4151430e5c87455f8efba41475a50a228131711a803b7ba7e271764bd9c' -default['elasticsearch']['checksums']['2.2.2']['rhel'] = '988d1b3c9aef94b8ea74daef14889690000c9fd6c80b0cf032039b4d26c252a6' -default['elasticsearch']['checksums']['2.2.2']['tar'] = 'c706db594f1feb5051d90697c6c412eadd60e00a9ec3b4f345a122801183af69' -default['elasticsearch']['checksums']['2.3.0']['debian'] = '2645e341587f636edaca1ee1380eeb76596d99b596bf17e03e2c37c697523efd' -default['elasticsearch']['checksums']['2.3.0']['rhel'] = '7469808bc64bca0b2e1a9fe258ff04ba4acde6c86d13a5cd19d623966fecfffd' -default['elasticsearch']['checksums']['2.3.0']['tar'] = 'd68482c7633f2986263bc5f11f93b8a58c54c6cf5e337b615446d0a7c6fdcd8b' -default['elasticsearch']['checksums']['2.3.1']['debian'] = 'ff22da40b60ae216761c7f6148e12760f34e0e51bc2198d5022934dc520b7d6c' -default['elasticsearch']['checksums']['2.3.1']['rhel'] = '841946dfe9220a4fdae7bbd491114a0eccbcc6d096bf4343d02e7c6e7abb704f' -default['elasticsearch']['checksums']['2.3.1']['tar'] = 'f0092e73038e0472fcdd923e5f2792e13692ea0f09ca034a54dd49b217110ebb' -default['elasticsearch']['checksums']['2.3.2']['debian'] = '3d474b0123ec8ad4ebfa089f8cde607033e6cbef28a6a0df318bdc3d2a546cd8' -default['elasticsearch']['checksums']['2.3.2']['rhel'] = '7bc84521921af8e43089c4fd64eced9eb68167d73fc14c102732f78750dfc607' -default['elasticsearch']['checksums']['2.3.2']['tar'] = '04c4d3913d496d217e038da88df939108369ae2e78eea29cb1adf1c4ab3a000a' -default['elasticsearch']['checksums']['2.3.3']['debian'] = 'fa90c6aefc5e82e0e19cb0ec546b9a64fec354ede201cf24658ddcfe01762d92' -default['elasticsearch']['checksums']['2.3.3']['rhel'] = '9aef1abe334d3143d8347144d69a35f449c5ecd8eebc3d7277f224d18679585a' -default['elasticsearch']['checksums']['2.3.3']['tar'] = '5fe0a6887432bb8a8d3de2e79c9b81c83cfa241e6440f0f0379a686657789165' -default['elasticsearch']['checksums']['2.3.4']['debian'] = 'abf6ce899cb7f2d9fc6eae0ecba148a191093e62afd1e242ba0bb1a7c2686074' -default['elasticsearch']['checksums']['2.3.4']['rhel'] = '781af05407d88a7bf4cf743d49e8b595d9494ba7334794ed2e2f8f9e64b67e71' -default['elasticsearch']['checksums']['2.3.4']['tar'] = '371e0c5f4ded0a8548f1cce55faff3efebcfd5f895c2c816f220146521f6f06e' -default['elasticsearch']['checksums']['2.3.5']['debian'] = '9fd12eca701ccd7a1ae5767187882327262717154ba1fb7eab3c3a653874d3fb' -default['elasticsearch']['checksums']['2.3.5']['rhel'] = 'ad869bb0d91cdf97391f85832c7309d44684e867d7c74263808e4687c4ab8789' -default['elasticsearch']['checksums']['2.3.5']['tar'] = '1119a8c18620b98c4b85261318663a1f26dea92a26f34dfeb7f813fb7cbb468a' -default['elasticsearch']['checksums']['2.4.0']['debian'] = '5edf1ac795d6950781b20ecc8db992d6dc95e55abb1ff66e6b1234d85bd68514' -default['elasticsearch']['checksums']['2.4.0']['rhel'] = 'aa75abe581685cb5767ce91a042b8b395290d966bcb575ff2e3d1cf1fd06ff7f' -default['elasticsearch']['checksums']['2.4.0']['tar'] = '3ae01140ae7bcbb91436feef381fbed774e36ef6d1e8e6a3153640db82acf4c9' -default['elasticsearch']['checksums']['2.4.1']['debian'] = 'cdf94b84cbf3024961cd09a689957fe39df6da9afcfe76ceba20dbfb50b92945' -default['elasticsearch']['checksums']['2.4.1']['rhel'] = 'c8a275d12876165da532ebfde1eeb6a502613bda919d95516f30f6495ae5086d' -default['elasticsearch']['checksums']['2.4.1']['tar'] = '23a369ef42955c19aaaf9e34891eea3a055ed217d7fbe76da0998a7a54bbe167' +default['elasticsearch']['checksums']['5.0.0']['debian'] = '0a4f8842a1f7d7bd3015118298284383efcd4c25f9591c46bb5ab68189815268' +default['elasticsearch']['checksums']['5.0.0']['rhel'] = 'fb502a9754f2162f27590125aecc6b68fa999738051d8f230c4da4ed6deb8d62' +default['elasticsearch']['checksums']['5.0.0']['tar'] = 'a866534f0fa7428e980c985d712024feef1dee04709add6e360fc7b73bb1e7ae' diff --git a/libraries/helpers.rb b/libraries/helpers.rb index 75824c0a2..4f2f8cbc1 100644 --- a/libraries/helpers.rb +++ b/libraries/helpers.rb @@ -85,23 +85,18 @@ def determine_download_url(new_resource, node) platform_family = node['platform_family'] install_type = determine_install_type(new_resource, node) version = determine_version(new_resource, node) - newer_url_style = version.to_f >= 2.0 - - # v2 and greater has a different set of URLs - url_hash_key = newer_url_style ? 'download_urls_v2' : 'download_urls' url_string = nil if new_resource.download_url url_string = new_resource.download_url elsif install_type.to_s == 'tar' || install_type.to_s == 'tarball' - url_string = node['elasticsearch'][url_hash_key]['tar'] - elsif install_type.to_s == 'package' && node['elasticsearch'][url_hash_key][platform_family] - url_string = node['elasticsearch'][url_hash_key][platform_family] + url_string = node['elasticsearch']['download_urls']['tar'] + elsif install_type.to_s == 'package' && node['elasticsearch']['download_urls'][platform_family] + url_string = node['elasticsearch']['download_urls'][platform_family] end if url_string && version - # v2 and greater has two %s entries for version - return (newer_url_style ? format(url_string, version, version) : format(url_string, version)) + return format(url_string, version) elsif url_string return url_string end diff --git a/libraries/provider_configure.rb b/libraries/provider_configure.rb index a36a282f1..c8373e578 100644 --- a/libraries/provider_configure.rb +++ b/libraries/provider_configure.rb @@ -66,36 +66,29 @@ def whyrun_supported? new_resource.updated_by_last_action(true) if d.updated_by_last_action? end + # Create elasticsearch shell variables file + # # Valid values in /etc/sysconfig/elasticsearch or /etc/default/elasticsearch - # ES_HOME CONF_DIR CONF_FILE DATA_DIR LOG_DIR WORK_DIR PID_DIR - # ES_HEAP_SIZE ES_HEAP_NEWSIZE ES_DIRECT_SIZE ES_JAVA_OPTS - # ES_RESTART_ON_UPGRADE ES_GC_LOG_FILE ES_STARTUP_SLEEP_TIME - # ES_USER ES_GROUP MAX_OPEN_FILES MAX_LOCKED_MEMORY MAX_MAP_COUNT + # ES_HOME JAVA_HOME CONF_DIR DATA_DIR LOG_DIR PID_DIR ES_JAVA_OPTS + # RESTART_ON_UPGRADE ES_USER ES_GROUP ES_STARTUP_SLEEP_TIME MAX_OPEN_FILES + # MAX_LOCKED_MEMORY MAX_MAP_COUNT + # + # We provide these values as resource attributes/parameters directly + params = {} params[:ES_HOME] = new_resource.path_home[es_install.type] + params[:JAVA_HOME] = new_resource.java_home params[:CONF_DIR] = new_resource.path_conf[es_install.type] params[:DATA_DIR] = new_resource.path_data[es_install.type] params[:LOG_DIR] = new_resource.path_logs[es_install.type] params[:PID_DIR] = new_resource.path_pid[es_install.type] - - params[:ES_STARTUP_SLEEP_TIME] = new_resource.startup_sleep_seconds.to_s + params[:RESTART_ON_UPGRADE] = new_resource.restart_on_upgrade params[:ES_USER] = es_user.username params[:ES_GROUP] = es_user.groupname - - params[:JAVA_HOME] = new_resource.java_home - params[:ES_HEAP_SIZE] = new_resource.allocated_memory + params[:ES_STARTUP_SLEEP_TIME] = new_resource.startup_sleep_seconds.to_s params[:MAX_OPEN_FILES] = new_resource.nofile_limit params[:MAX_LOCKED_MEMORY] = new_resource.memlock_limit - - params[:ES_JAVA_OPTS] = '"' - params[:ES_JAVA_OPTS] << '-server ' - params[:ES_JAVA_OPTS] << '-Djava.awt.headless=true ' - params[:ES_JAVA_OPTS] << "-Xss#{new_resource.thread_stack_size} " - params[:ES_JAVA_OPTS] << "#{new_resource.gc_settings.tr("\n", ' ').strip.squeeze(' ')} " if new_resource.gc_settings - params[:ES_JAVA_OPTS] << '-Dfile.encoding=UTF-8 ' - params[:ES_JAVA_OPTS] << '-Djna.nosys=true' - params[:ES_JAVA_OPTS] << " #{new_resource.env_options}" if new_resource.env_options - params[:ES_JAVA_OPTS] << '"' + params[:MAX_MAP_COUNT] = new_resource.memlock_limit default_config_name = es_svc.service_name || es_svc.instance_name || new_resource.instance_name || 'elasticsearch' @@ -110,12 +103,31 @@ def whyrun_supported? shell_template.run_action(:create) new_resource.updated_by_last_action(true) if shell_template.updated_by_last_action? + # Create jvm.options file + # + jvm_options_template = template 'jvm_options' do + path "#{new_resource.path_conf[es_install.type]}/jvm.options" + source new_resource.template_jvm_options + cookbook new_resource.cookbook_jvm_options + owner es_user.username + group es_user.groupname + mode 0644 + variables(jvm_options: [ + "-Xms#{new_resource.allocated_memory}", + "-Xmx#{new_resource.allocated_memory}", + new_resource.jvm_options + ].flatten.join("\n")) + action :nothing + end + jvm_options_template.run_action(:create) + new_resource.updated_by_last_action(true) if jvm_options_template.updated_by_last_action? + # Create ES logging file # - logging_template = template 'logging.yml' do - path "#{new_resource.path_conf[es_install.type]}/logging.yml" - source new_resource.template_logging_yml - cookbook new_resource.cookbook_logging_yml + logging_template = template 'log4j2_properties' do + path "#{new_resource.path_conf[es_install.type]}/log4j2.properties" + source new_resource.template_log4j2_properties + cookbook new_resource.cookbook_log4j2_properties owner es_user.username group es_user.groupname mode 0644 @@ -125,6 +137,8 @@ def whyrun_supported? logging_template.run_action(:create) new_resource.updated_by_last_action(true) if logging_template.updated_by_last_action? + # Create ES elasticsearch.yml file + # merged_configuration = default_configuration.merge(new_resource.configuration.dup) # warn if someone is using symbols. we don't support. diff --git a/libraries/provider_install.rb b/libraries/provider_install.rb index afca876bf..b91a3f34c 100644 --- a/libraries/provider_install.rb +++ b/libraries/provider_install.rb @@ -102,7 +102,7 @@ def install_tarball_wrapper_action owner es_user.username group es_user.groupname version determine_version(new_resource, node) - has_binaries ['bin/elasticsearch', 'bin/plugin'] + has_binaries ['bin/elasticsearch', 'bin/elasticsearch-plugin'] checksum determine_download_checksum(new_resource, node) prefix_root new_resource.dir[new_resource.type] prefix_home new_resource.dir[new_resource.type] diff --git a/libraries/provider_plugin.rb b/libraries/provider_plugin.rb index 24eaa48c9..981d8dae4 100644 --- a/libraries/provider_plugin.rb +++ b/libraries/provider_plugin.rb @@ -35,7 +35,7 @@ def manage_plugin(arguments) plugin_dir_exists = ::File.exist?(es_conf.path_plugins[es_install.type]) shell_out_as_user!("mkdir -p #{es_conf.path_plugins[es_install.type]}", run_context) unless plugin_dir_exists - command_array = "#{es_conf.path_bin[es_install.type]}/plugin #{arguments.chomp(' ')}".chomp(' ').split(' ') + command_array = "#{es_conf.path_bin[es_install.type]}/elasticsearch-plugin #{arguments.chomp(' ')} #{new_resource.options}".chomp(' ').split(' ') shell_out_as_user!(command_array, run_context) new_resource.updated_by_last_action(true) end @@ -54,14 +54,6 @@ def plugin_exists(name) end def assert_state_is_valid(es_user, es_install, es_conf) - begin - if es_user.username != 'root' && es_install.version.to_f < 2.0 - Chef::Log.warn("Elasticsearch < 2.0.0 (you are using #{es_install.version}) requires plugins be installed as root (you are using #{es_user.username})") - end - rescue - Chef::Log.warn("Could not parse #{es_install.version} as floating point number") - end - unless es_conf.path_plugins[es_install.type] # we do not check existence (may not exist if no plugins installed) raise "Could not determine the plugin directory (#{es_conf.path_plugins[es_install.type]}). Please check elasticsearch_configure[#{es_conf.name}]." end diff --git a/libraries/provider_service.rb b/libraries/provider_service.rb index f4740b5dc..faa8b9260 100644 --- a/libraries/provider_service.rb +++ b/libraries/provider_service.rb @@ -26,7 +26,7 @@ def whyrun_supported? d_r.run_action(:create) new_resource.updated_by_last_action(true) if d_r.updated_by_last_action? - # Create service + # Create service for init and systemd # init_r = template "/etc/init.d/#{new_resource.service_name}" do source new_resource.init_source @@ -37,11 +37,27 @@ def whyrun_supported? # we need to include something about #{progname} fixed in here. program_name: new_resource.service_name ) + only_if { ::File.exist?('/etc/init.d') } action :nothing end init_r.run_action(:create) new_resource.updated_by_last_action(true) if init_r.updated_by_last_action? + systemd_r = template "/usr/lib/systemd/system/#{new_resource.service_name}.service" do + source new_resource.systemd_source + cookbook new_resource.systemd_cookbook + owner 'root' + mode 0755 + variables( + # we need to include something about #{progname} fixed in here. + program_name: new_resource.service_name + ) + only_if { ::File.exist?('/usr/lib/systemd/system') } + action :nothing + end + systemd_r.run_action(:create) + new_resource.updated_by_last_action(true) if systemd_r.updated_by_last_action? + # flatten in an array here, in case the service_actions are a symbol vs. array [new_resource.service_actions].flatten.each do |act| passthrough_action(act) diff --git a/libraries/resource_configure.rb b/libraries/resource_configure.rb index 310637eff..dfdaf71cc 100644 --- a/libraries/resource_configure.rb +++ b/libraries/resource_configure.rb @@ -42,34 +42,45 @@ class ElasticsearchCookbook::ConfigureResource < Chef::Resource::LWRPBase attribute(:template_elasticsearch_env, kind_of: String, default: 'elasticsearch.in.sh.erb') attribute(:cookbook_elasticsearch_env, kind_of: String, default: 'elasticsearch') + attribute(:template_jvm_options, kind_of: String, default: 'jvm_options.erb') + attribute(:cookbook_jvm_options, kind_of: String, default: 'elasticsearch') + attribute(:template_elasticsearch_yml, kind_of: String, default: 'elasticsearch.yml.erb') attribute(:cookbook_elasticsearch_yml, kind_of: String, default: 'elasticsearch') - attribute(:template_logging_yml, kind_of: String, default: 'logging.yml.erb') - attribute(:cookbook_logging_yml, kind_of: String, default: 'elasticsearch') + attribute(:template_log4j2_properties, kind_of: String, default: 'log4j2.properties.erb') + attribute(:cookbook_log4j2_properties, kind_of: String, default: 'elasticsearch') attribute(:logging, kind_of: Hash, default: {}.freeze) attribute(:java_home, kind_of: String, default: nil) + attribute(:restart_on_upgrade, kind_of: [TrueClass, FalseClass], default: false) attribute(:startup_sleep_seconds, kind_of: [String, Integer], default: 5) # Calculations for this are done in the provider, as we can't do them in the # resource definition. default is 50% of RAM or 31GB, which ever is smaller. attribute(:allocated_memory, kind_of: String) - attribute(:thread_stack_size, kind_of: String, default: '256k') - attribute(:env_options, kind_of: String, default: nil) - attribute(:gc_settings, kind_of: String, default: - <<-CONFIG - -XX:+UseParNewGC + attribute(:jvm_options, kind_of: Array, default: + %w( -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly - -XX:+HeapDumpOnOutOfMemoryError -XX:+DisableExplicitGC - CONFIG - ) + -XX:+AlwaysPreTouch + -server + -Djava.awt.headless=true + -Dfile.encoding=UTF-8 + -Djna.nosys=true + -Dio.netty.noUnsafe=true + -Dio.netty.noKeySetOptimization=true + -Dlog4j.shutdownHookEnabled=false + -Dlog4j2.disable.jmx=true + -Dlog4j.skipJansi=true + -XX:+HeapDumpOnOutOfMemoryError + ).freeze + ) # default user limits attribute(:memlock_limit, kind_of: String, default: 'unlimited') @@ -94,13 +105,6 @@ class ElasticsearchCookbook::ConfigureResource < Chef::Resource::LWRPBase # # 'node.data' => ?, # 'node.master' => ?, - - 'action.destructive_requires_name' => true, - 'node.max_local_storage_nodes' => 1, - - 'gateway.expected_nodes' => 0, - - 'http.port' => 9200 }.freeze) # These settings are merged with the `default_configuration` attribute, diff --git a/libraries/resource_plugin.rb b/libraries/resource_plugin.rb index 06a524dfd..28bf81a6c 100644 --- a/libraries/resource_plugin.rb +++ b/libraries/resource_plugin.rb @@ -12,6 +12,7 @@ class ElasticsearchCookbook::PluginResource < Chef::Resource::LWRPBase attribute(:plugin_name, kind_of: String, name_attribute: true) attribute(:url, kind_of: String, name_attribute: true) attribute(:chef_proxy, kind_of: [TrueClass, FalseClass], default: true) + attribute(:options, kind_of: String, default: '') # this is what helps the various resources find each other attribute(:instance_name, kind_of: String, default: nil) diff --git a/libraries/resource_service.rb b/libraries/resource_service.rb index ace872540..71494add2 100644 --- a/libraries/resource_service.rb +++ b/libraries/resource_service.rb @@ -21,4 +21,8 @@ class ElasticsearchCookbook::ServiceResource < Chef::Resource::LWRPBase # allow overridable init script attribute(:init_source, kind_of: String, default: 'initscript.erb') attribute(:init_cookbook, kind_of: String, default: 'elasticsearch') + + # allow overridable systemd unit + attribute(:systemd_source, kind_of: String, default: 'systemd_unit.erb') + attribute(:systemd_cookbook, kind_of: String, default: 'elasticsearch') end diff --git a/templates/amazon/systemd_unit.erb b/templates/amazon/systemd_unit.erb new file mode 100644 index 000000000..549520522 --- /dev/null +++ b/templates/amazon/systemd_unit.erb @@ -0,0 +1,61 @@ +[Unit] +Description=Elasticsearch +Documentation=http://www.elastic.co +Wants=network-online.target +After=network-online.target + +[Service] +Environment=ES_HOME=/usr/share/elasticsearch +Environment=CONF_DIR=/etc/elasticsearch +Environment=DATA_DIR=/var/lib/elasticsearch +Environment=LOG_DIR=/var/log/elasticsearch +Environment=PID_DIR=/var/run/elasticsearch +EnvironmentFile=-/etc/sysconfig/elasticsearch + +WorkingDirectory=/usr/share/elasticsearch + +User=elasticsearch +Group=elasticsearch + +ExecStartPre=/usr/share/elasticsearch/bin/elasticsearch-systemd-pre-exec + +ExecStart=/usr/share/elasticsearch/bin/elasticsearch \ + -p ${PID_DIR}/elasticsearch.pid \ + --quiet \ + -Edefault.path.logs=${LOG_DIR} \ + -Edefault.path.data=${DATA_DIR} \ + -Edefault.path.conf=${CONF_DIR} + +# StandardOutput is configured to redirect to journalctl since +# some error messages may be logged in standard output before +# elasticsearch logging system is initialized. Elasticsearch +# stores its logs in /var/log/elasticsearch and does not use +# journalctl by default. If you also want to enable journalctl +# logging, you can simply remove the "quiet" option from ExecStart. +StandardOutput=journal +StandardError=inherit + +# Specifies the maximum file descriptor number that can be opened by this process +LimitNOFILE=65536 + +# Specifies the maximum number of bytes of memory that may be locked into RAM +# Set to "infinity" if you use the 'bootstrap.memory_lock: true' option +# in elasticsearch.yml and 'MAX_LOCKED_MEMORY=unlimited' in /etc/sysconfig/elasticsearch +#LimitMEMLOCK=infinity + +# Disable timeout logic and wait until process is stopped +TimeoutStopSec=0 + +# SIGTERM signal is used to stop the Java process +KillSignal=SIGTERM + +# Java process is never killed +SendSIGKILL=no + +# When a JVM receives a SIGTERM signal it exits with code 143 +SuccessExitStatus=143 + +[Install] +WantedBy=multi-user.target + +# Built for distribution-5.0.0 (distribution) diff --git a/templates/centos/systemd_unit.erb b/templates/centos/systemd_unit.erb new file mode 100644 index 000000000..549520522 --- /dev/null +++ b/templates/centos/systemd_unit.erb @@ -0,0 +1,61 @@ +[Unit] +Description=Elasticsearch +Documentation=http://www.elastic.co +Wants=network-online.target +After=network-online.target + +[Service] +Environment=ES_HOME=/usr/share/elasticsearch +Environment=CONF_DIR=/etc/elasticsearch +Environment=DATA_DIR=/var/lib/elasticsearch +Environment=LOG_DIR=/var/log/elasticsearch +Environment=PID_DIR=/var/run/elasticsearch +EnvironmentFile=-/etc/sysconfig/elasticsearch + +WorkingDirectory=/usr/share/elasticsearch + +User=elasticsearch +Group=elasticsearch + +ExecStartPre=/usr/share/elasticsearch/bin/elasticsearch-systemd-pre-exec + +ExecStart=/usr/share/elasticsearch/bin/elasticsearch \ + -p ${PID_DIR}/elasticsearch.pid \ + --quiet \ + -Edefault.path.logs=${LOG_DIR} \ + -Edefault.path.data=${DATA_DIR} \ + -Edefault.path.conf=${CONF_DIR} + +# StandardOutput is configured to redirect to journalctl since +# some error messages may be logged in standard output before +# elasticsearch logging system is initialized. Elasticsearch +# stores its logs in /var/log/elasticsearch and does not use +# journalctl by default. If you also want to enable journalctl +# logging, you can simply remove the "quiet" option from ExecStart. +StandardOutput=journal +StandardError=inherit + +# Specifies the maximum file descriptor number that can be opened by this process +LimitNOFILE=65536 + +# Specifies the maximum number of bytes of memory that may be locked into RAM +# Set to "infinity" if you use the 'bootstrap.memory_lock: true' option +# in elasticsearch.yml and 'MAX_LOCKED_MEMORY=unlimited' in /etc/sysconfig/elasticsearch +#LimitMEMLOCK=infinity + +# Disable timeout logic and wait until process is stopped +TimeoutStopSec=0 + +# SIGTERM signal is used to stop the Java process +KillSignal=SIGTERM + +# Java process is never killed +SendSIGKILL=no + +# When a JVM receives a SIGTERM signal it exits with code 143 +SuccessExitStatus=143 + +[Install] +WantedBy=multi-user.target + +# Built for distribution-5.0.0 (distribution) diff --git a/templates/debian/systemd_unit.erb b/templates/debian/systemd_unit.erb new file mode 100644 index 000000000..a1ae52f50 --- /dev/null +++ b/templates/debian/systemd_unit.erb @@ -0,0 +1,61 @@ +[Unit] +Description=Elasticsearch +Documentation=http://www.elastic.co +Wants=network-online.target +After=network-online.target + +[Service] +Environment=ES_HOME=/usr/share/elasticsearch +Environment=CONF_DIR=/etc/elasticsearch +Environment=DATA_DIR=/var/lib/elasticsearch +Environment=LOG_DIR=/var/log/elasticsearch +Environment=PID_DIR=/var/run/elasticsearch +EnvironmentFile=-/etc/default/elasticsearch + +WorkingDirectory=/usr/share/elasticsearch + +User=elasticsearch +Group=elasticsearch + +ExecStartPre=/usr/share/elasticsearch/bin/elasticsearch-systemd-pre-exec + +ExecStart=/usr/share/elasticsearch/bin/elasticsearch \ + -p ${PID_DIR}/elasticsearch.pid \ + --quiet \ + -Edefault.path.logs=${LOG_DIR} \ + -Edefault.path.data=${DATA_DIR} \ + -Edefault.path.conf=${CONF_DIR} + +# StandardOutput is configured to redirect to journalctl since +# some error messages may be logged in standard output before +# elasticsearch logging system is initialized. Elasticsearch +# stores its logs in /var/log/elasticsearch and does not use +# journalctl by default. If you also want to enable journalctl +# logging, you can simply remove the "quiet" option from ExecStart. +StandardOutput=journal +StandardError=inherit + +# Specifies the maximum file descriptor number that can be opened by this process +LimitNOFILE=65536 + +# Specifies the maximum number of bytes of memory that may be locked into RAM +# Set to "infinity" if you use the 'bootstrap.memory_lock: true' option +# in elasticsearch.yml and 'MAX_LOCKED_MEMORY=unlimited' in /etc/default/elasticsearch +#LimitMEMLOCK=infinity + +# Disable timeout logic and wait until process is stopped +TimeoutStopSec=0 + +# SIGTERM signal is used to stop the Java process +KillSignal=SIGTERM + +# Java process is never killed +SendSIGKILL=no + +# When a JVM receives a SIGTERM signal it exits with code 143 +SuccessExitStatus=143 + +[Install] +WantedBy=multi-user.target + +# Built for distribution-5.0.0 (distribution) diff --git a/templates/default/jvm_options.erb b/templates/default/jvm_options.erb new file mode 100644 index 000000000..35d710ca3 --- /dev/null +++ b/templates/default/jvm_options.erb @@ -0,0 +1,3 @@ +## JVM configuration + +<%= @jvm_options %> diff --git a/templates/default/log4j2.properties.erb b/templates/default/log4j2.properties.erb new file mode 100644 index 000000000..d16af9cfc --- /dev/null +++ b/templates/default/log4j2.properties.erb @@ -0,0 +1,78 @@ +status = error + +# log action execution errors for easier debugging +logger.action.name = org.elasticsearch.action +logger.action.level = debug + +appender.console.type = Console +appender.console.name = console +appender.console.layout.type = PatternLayout +appender.console.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] %marker%m%n + +appender.rolling.type = RollingFile +appender.rolling.name = rolling +appender.rolling.fileName = ${sys:es.logs}.log +appender.rolling.layout.type = PatternLayout +appender.rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] %marker%.10000m%n +appender.rolling.filePattern = ${sys:es.logs}-%d{yyyy-MM-dd}.log +appender.rolling.policies.type = Policies +appender.rolling.policies.time.type = TimeBasedTriggeringPolicy +appender.rolling.policies.time.interval = 1 +appender.rolling.policies.time.modulate = true + +rootLogger.level = info +rootLogger.appenderRef.console.ref = console +rootLogger.appenderRef.rolling.ref = rolling + +appender.deprecation_rolling.type = RollingFile +appender.deprecation_rolling.name = deprecation_rolling +appender.deprecation_rolling.fileName = ${sys:es.logs}_deprecation.log +appender.deprecation_rolling.layout.type = PatternLayout +appender.deprecation_rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] %marker%.10000m%n +appender.deprecation_rolling.filePattern = ${sys:es.logs}_deprecation-%i.log.gz +appender.deprecation_rolling.policies.type = Policies +appender.deprecation_rolling.policies.size.type = SizeBasedTriggeringPolicy +appender.deprecation_rolling.policies.size.size = 1GB +appender.deprecation_rolling.strategy.type = DefaultRolloverStrategy +appender.deprecation_rolling.strategy.max = 4 + +logger.deprecation.name = org.elasticsearch.deprecation +logger.deprecation.level = warn +logger.deprecation.appenderRef.deprecation_rolling.ref = deprecation_rolling +logger.deprecation.additivity = false + +appender.index_search_slowlog_rolling.type = RollingFile +appender.index_search_slowlog_rolling.name = index_search_slowlog_rolling +appender.index_search_slowlog_rolling.fileName = ${sys:es.logs}_index_search_slowlog.log +appender.index_search_slowlog_rolling.layout.type = PatternLayout +appender.index_search_slowlog_rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c] %marker%.10000m%n +appender.index_search_slowlog_rolling.filePattern = ${sys:es.logs}_index_search_slowlog-%d{yyyy-MM-dd}.log +appender.index_search_slowlog_rolling.policies.type = Policies +appender.index_search_slowlog_rolling.policies.time.type = TimeBasedTriggeringPolicy +appender.index_search_slowlog_rolling.policies.time.interval = 1 +appender.index_search_slowlog_rolling.policies.time.modulate = true + +logger.index_search_slowlog_rolling.name = index.search.slowlog +logger.index_search_slowlog_rolling.level = trace +logger.index_search_slowlog_rolling.appenderRef.index_search_slowlog_rolling.ref = index_search_slowlog_rolling +logger.index_search_slowlog_rolling.additivity = false + +appender.index_indexing_slowlog_rolling.type = RollingFile +appender.index_indexing_slowlog_rolling.name = index_indexing_slowlog_rolling +appender.index_indexing_slowlog_rolling.fileName = ${sys:es.logs}_index_indexing_slowlog.log +appender.index_indexing_slowlog_rolling.layout.type = PatternLayout +appender.index_indexing_slowlog_rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c] %marker%.10000m%n +appender.index_indexing_slowlog_rolling.filePattern = ${sys:es.logs}_index_indexing_slowlog-%d{yyyy-MM-dd}.log +appender.index_indexing_slowlog_rolling.policies.type = Policies +appender.index_indexing_slowlog_rolling.policies.time.type = TimeBasedTriggeringPolicy +appender.index_indexing_slowlog_rolling.policies.time.interval = 1 +appender.index_indexing_slowlog_rolling.policies.time.modulate = true + +logger.index_indexing_slowlog.name = index.indexing.slowlog.index +logger.index_indexing_slowlog.level = trace +logger.index_indexing_slowlog.appenderRef.index_indexing_slowlog_rolling.ref = index_indexing_slowlog_rolling +logger.index_indexing_slowlog.additivity = false + +<% @logging.each do |k,v| %> +<%= k %>=<%= v %> +<% end %> diff --git a/templates/default/logging.yml.erb b/templates/default/logging.yml.erb deleted file mode 100755 index 3a40215eb..000000000 --- a/templates/default/logging.yml.erb +++ /dev/null @@ -1,104 +0,0 @@ -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# THIS FILE IS MANAGED BY CHEF, DO NOT EDIT MANUALLY, YOUR CHANGES WILL BE OVERWRITTEN! -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# -# See the source file for context and more information: -# -# -# You may also supply your own template to the elasticsearch cookbook's -# elasticsearch_configure resource using the template_logging_yml and cookbook_logging_yml -# parameters defined here: -# -# - -# you can override this using by setting a system property, for example -Des.logger.level=DEBUG -es.logger.level: INFO -rootLogger: ${es.logger.level}, console, file -logger: - # log action execution errors for easier debugging - action: DEBUG - - # deprecation logging, turn to DEBUG to see them - deprecation: INFO, deprecation_log_file - - # reduce the logging for aws, too much is logged under the default INFO - com.amazonaws: WARN - # aws will try to do some sketchy JMX stuff, but its not needed. - com.amazonaws.jmx.SdkMBeanRegistrySupport: ERROR - com.amazonaws.metrics.AwsSdkMetrics: ERROR - - org.apache.http: INFO - - # gateway - #gateway: DEBUG - #index.gateway: DEBUG - - # peer shard recovery - #indices.recovery: DEBUG - - # discovery - #discovery: TRACE - - index.search.slowlog: TRACE, index_search_slow_log_file - index.indexing.slowlog: TRACE, index_indexing_slow_log_file - -# ----- Configuration set by Chef --------------------------------------------- -<% @logging.sort.each do |key, value| %> -logger.<%= key %>: <%= value %> -<% end %> -# ----------------------------------------------------------------------------- - -additivity: - index.search.slowlog: false - index.indexing.slowlog: false - deprecation: false - -appender: - console: - type: console - layout: - type: consolePattern - conversionPattern: "[%d{ISO8601}][%-5p][%-25c] %m%n" - - file: - type: dailyRollingFile - file: ${path.logs}/${cluster.name}.log - datePattern: "'.'yyyy-MM-dd" - layout: - type: pattern - conversionPattern: "[%d{ISO8601}][%-5p][%-25c] %.10000m%n" - - # Use the following log4j-extras RollingFileAppender to enable gzip compression of log files. - # For more information see https://logging.apache.org/log4j/extras/apidocs/org/apache/log4j/rolling/RollingFileAppender.html - #file: - #type: extrasRollingFile - #file: ${path.logs}/${cluster.name}.log - #rollingPolicy: timeBased - #rollingPolicy.FileNamePattern: ${path.logs}/${cluster.name}.log.%d{yyyy-MM-dd}.gz - #layout: - #type: pattern - #conversionPattern: "[%d{ISO8601}][%-5p][%-25c] %m%n" - - deprecation_log_file: - type: dailyRollingFile - file: ${path.logs}/${cluster.name}_deprecation.log - datePattern: "'.'yyyy-MM-dd" - layout: - type: pattern - conversionPattern: "[%d{ISO8601}][%-5p][%-25c] %m%n" - - index_search_slow_log_file: - type: dailyRollingFile - file: ${path.logs}/${cluster.name}_index_search_slowlog.log - datePattern: "'.'yyyy-MM-dd" - layout: - type: pattern - conversionPattern: "[%d{ISO8601}][%-5p][%-25c] %m%n" - - index_indexing_slow_log_file: - type: dailyRollingFile - file: ${path.logs}/${cluster.name}_index_indexing_slowlog.log - datePattern: "'.'yyyy-MM-dd" - layout: - type: pattern - conversionPattern: "[%d{ISO8601}][%-5p][%-25c] %m%n" diff --git a/templates/oracle/systemd_unit.erb b/templates/oracle/systemd_unit.erb new file mode 100644 index 000000000..549520522 --- /dev/null +++ b/templates/oracle/systemd_unit.erb @@ -0,0 +1,61 @@ +[Unit] +Description=Elasticsearch +Documentation=http://www.elastic.co +Wants=network-online.target +After=network-online.target + +[Service] +Environment=ES_HOME=/usr/share/elasticsearch +Environment=CONF_DIR=/etc/elasticsearch +Environment=DATA_DIR=/var/lib/elasticsearch +Environment=LOG_DIR=/var/log/elasticsearch +Environment=PID_DIR=/var/run/elasticsearch +EnvironmentFile=-/etc/sysconfig/elasticsearch + +WorkingDirectory=/usr/share/elasticsearch + +User=elasticsearch +Group=elasticsearch + +ExecStartPre=/usr/share/elasticsearch/bin/elasticsearch-systemd-pre-exec + +ExecStart=/usr/share/elasticsearch/bin/elasticsearch \ + -p ${PID_DIR}/elasticsearch.pid \ + --quiet \ + -Edefault.path.logs=${LOG_DIR} \ + -Edefault.path.data=${DATA_DIR} \ + -Edefault.path.conf=${CONF_DIR} + +# StandardOutput is configured to redirect to journalctl since +# some error messages may be logged in standard output before +# elasticsearch logging system is initialized. Elasticsearch +# stores its logs in /var/log/elasticsearch and does not use +# journalctl by default. If you also want to enable journalctl +# logging, you can simply remove the "quiet" option from ExecStart. +StandardOutput=journal +StandardError=inherit + +# Specifies the maximum file descriptor number that can be opened by this process +LimitNOFILE=65536 + +# Specifies the maximum number of bytes of memory that may be locked into RAM +# Set to "infinity" if you use the 'bootstrap.memory_lock: true' option +# in elasticsearch.yml and 'MAX_LOCKED_MEMORY=unlimited' in /etc/sysconfig/elasticsearch +#LimitMEMLOCK=infinity + +# Disable timeout logic and wait until process is stopped +TimeoutStopSec=0 + +# SIGTERM signal is used to stop the Java process +KillSignal=SIGTERM + +# Java process is never killed +SendSIGKILL=no + +# When a JVM receives a SIGTERM signal it exits with code 143 +SuccessExitStatus=143 + +[Install] +WantedBy=multi-user.target + +# Built for distribution-5.0.0 (distribution) diff --git a/templates/redhat/systemd_unit.erb b/templates/redhat/systemd_unit.erb new file mode 100644 index 000000000..549520522 --- /dev/null +++ b/templates/redhat/systemd_unit.erb @@ -0,0 +1,61 @@ +[Unit] +Description=Elasticsearch +Documentation=http://www.elastic.co +Wants=network-online.target +After=network-online.target + +[Service] +Environment=ES_HOME=/usr/share/elasticsearch +Environment=CONF_DIR=/etc/elasticsearch +Environment=DATA_DIR=/var/lib/elasticsearch +Environment=LOG_DIR=/var/log/elasticsearch +Environment=PID_DIR=/var/run/elasticsearch +EnvironmentFile=-/etc/sysconfig/elasticsearch + +WorkingDirectory=/usr/share/elasticsearch + +User=elasticsearch +Group=elasticsearch + +ExecStartPre=/usr/share/elasticsearch/bin/elasticsearch-systemd-pre-exec + +ExecStart=/usr/share/elasticsearch/bin/elasticsearch \ + -p ${PID_DIR}/elasticsearch.pid \ + --quiet \ + -Edefault.path.logs=${LOG_DIR} \ + -Edefault.path.data=${DATA_DIR} \ + -Edefault.path.conf=${CONF_DIR} + +# StandardOutput is configured to redirect to journalctl since +# some error messages may be logged in standard output before +# elasticsearch logging system is initialized. Elasticsearch +# stores its logs in /var/log/elasticsearch and does not use +# journalctl by default. If you also want to enable journalctl +# logging, you can simply remove the "quiet" option from ExecStart. +StandardOutput=journal +StandardError=inherit + +# Specifies the maximum file descriptor number that can be opened by this process +LimitNOFILE=65536 + +# Specifies the maximum number of bytes of memory that may be locked into RAM +# Set to "infinity" if you use the 'bootstrap.memory_lock: true' option +# in elasticsearch.yml and 'MAX_LOCKED_MEMORY=unlimited' in /etc/sysconfig/elasticsearch +#LimitMEMLOCK=infinity + +# Disable timeout logic and wait until process is stopped +TimeoutStopSec=0 + +# SIGTERM signal is used to stop the Java process +KillSignal=SIGTERM + +# Java process is never killed +SendSIGKILL=no + +# When a JVM receives a SIGTERM signal it exits with code 143 +SuccessExitStatus=143 + +[Install] +WantedBy=multi-user.target + +# Built for distribution-5.0.0 (distribution) diff --git a/templates/ubuntu/systemd_unit.erb b/templates/ubuntu/systemd_unit.erb new file mode 100644 index 000000000..a1ae52f50 --- /dev/null +++ b/templates/ubuntu/systemd_unit.erb @@ -0,0 +1,61 @@ +[Unit] +Description=Elasticsearch +Documentation=http://www.elastic.co +Wants=network-online.target +After=network-online.target + +[Service] +Environment=ES_HOME=/usr/share/elasticsearch +Environment=CONF_DIR=/etc/elasticsearch +Environment=DATA_DIR=/var/lib/elasticsearch +Environment=LOG_DIR=/var/log/elasticsearch +Environment=PID_DIR=/var/run/elasticsearch +EnvironmentFile=-/etc/default/elasticsearch + +WorkingDirectory=/usr/share/elasticsearch + +User=elasticsearch +Group=elasticsearch + +ExecStartPre=/usr/share/elasticsearch/bin/elasticsearch-systemd-pre-exec + +ExecStart=/usr/share/elasticsearch/bin/elasticsearch \ + -p ${PID_DIR}/elasticsearch.pid \ + --quiet \ + -Edefault.path.logs=${LOG_DIR} \ + -Edefault.path.data=${DATA_DIR} \ + -Edefault.path.conf=${CONF_DIR} + +# StandardOutput is configured to redirect to journalctl since +# some error messages may be logged in standard output before +# elasticsearch logging system is initialized. Elasticsearch +# stores its logs in /var/log/elasticsearch and does not use +# journalctl by default. If you also want to enable journalctl +# logging, you can simply remove the "quiet" option from ExecStart. +StandardOutput=journal +StandardError=inherit + +# Specifies the maximum file descriptor number that can be opened by this process +LimitNOFILE=65536 + +# Specifies the maximum number of bytes of memory that may be locked into RAM +# Set to "infinity" if you use the 'bootstrap.memory_lock: true' option +# in elasticsearch.yml and 'MAX_LOCKED_MEMORY=unlimited' in /etc/default/elasticsearch +#LimitMEMLOCK=infinity + +# Disable timeout logic and wait until process is stopped +TimeoutStopSec=0 + +# SIGTERM signal is used to stop the Java process +KillSignal=SIGTERM + +# Java process is never killed +SendSIGKILL=no + +# When a JVM receives a SIGTERM signal it exits with code 143 +SuccessExitStatus=143 + +[Install] +WantedBy=multi-user.target + +# Built for distribution-5.0.0 (distribution) diff --git a/test/fixtures/cookbooks/elasticsearch_test/recipes/default_with_plugins.rb b/test/fixtures/cookbooks/elasticsearch_test/recipes/default_with_plugins.rb index 415a8d461..b4a701aa6 100644 --- a/test/fixtures/cookbooks/elasticsearch_test/recipes/default_with_plugins.rb +++ b/test/fixtures/cookbooks/elasticsearch_test/recipes/default_with_plugins.rb @@ -17,21 +17,15 @@ elasticsearch_install 'elasticsearch' do type node['elasticsearch']['install_type'].to_sym # since TK can't symbol. end -elasticsearch_configure 'elasticsearch' +elasticsearch_configure 'elasticsearch' do + nofile_limit '75000' +end elasticsearch_service 'elasticsearch' do service_actions [:enable, :start] end -# by default, no plugins, but we do one here. -elasticsearch_plugin 'head' do - url 'mobz/elasticsearch-head' - notifies :restart, 'elasticsearch_service[elasticsearch]', :delayed -end - -# remove an installed plugin -elasticsearch_plugin 'kopf' do - url 'lmenezes/elasticsearch-kopf' - action [:install, :remove] +# by default, no plugins, but we do the x-pack +elasticsearch_plugin 'x-pack' do notifies :restart, 'elasticsearch_service[elasticsearch]', :delayed end diff --git a/test/fixtures/cookbooks/elasticsearch_test/recipes/shieldwatcher.rb b/test/fixtures/cookbooks/elasticsearch_test/recipes/shieldwatcher.rb deleted file mode 100644 index fc64474d7..000000000 --- a/test/fixtures/cookbooks/elasticsearch_test/recipes/shieldwatcher.rb +++ /dev/null @@ -1,11 +0,0 @@ -# Cookbook Name:: elasticsearch_test -# Recipe:: shieldwatcher - -include_recipe "#{cookbook_name}::default_with_plugins" - -# test these since they need to write to 'bin' directory -%w(license shield watcher).each do |plugin_name| - elasticsearch_plugin plugin_name do - notifies :restart, 'elasticsearch_service[elasticsearch]', :delayed - end -end