From 47e66c55978a019774cdbfa777be7bbcec325863 Mon Sep 17 00:00:00 2001 From: Martin Zobel-Helas Date: Thu, 2 Apr 2015 14:02:20 +0000 Subject: [PATCH] Add new module elasticsearch for listsearch We do not want write our own puppet module for elasticsearch. Therefor we use the one from puppetforge. This commit invents the use of r10k in an extra 3rdparty module subdirectory. This way we can pull in new modules from puppetforge without deleting the old ones. Puppetfile allows us to define which module in which version is pulled in from puppetforge by running: r10k puppetfile install Signed-off-by: Martin Zobel-Helas --- 3rdparty/Puppetfile | 9 + 3rdparty/README.md | 9 + 3rdparty/modules/elasticsearch/CHANGELOG.md | 256 +++++++++ .../modules/elasticsearch/CONTRIBUTING.md | 46 ++ 3rdparty/modules/elasticsearch/CONTRIBUTORS | 20 + 3rdparty/modules/elasticsearch/Gemfile | 22 + 3rdparty/modules/elasticsearch/Gemfile.lock | 335 ++++++++++++ 3rdparty/modules/elasticsearch/LICENSE | 13 + 3rdparty/modules/elasticsearch/Modulefile | 9 + 3rdparty/modules/elasticsearch/README.md | 485 ++++++++++++++++++ 3rdparty/modules/elasticsearch/checksums.json | 39 ++ .../elasticsearch/lib/facter/es_facts.rb | 93 ++++ .../puppet/parser/functions/array_suffix.rb | 45 ++ .../es_instance_conn_validator/tcp_port.rb | 51 ++ .../puppet/type/es_instance_conn_validator.rb | 38 ++ .../lib/puppet/util/es_instance_validator.rb | 36 ++ .../log/2015-03-13_19_24_02/sut.log | 2 + .../log/2015-03-14_18_41_25/sut.log | 2 + .../log/2015-03-16_02_10_40/sut.log | 2 + .../log/2015-03-16_23_30_55/sut.log | 2 + .../modules/elasticsearch/manifests/config.pp | 124 +++++ .../modules/elasticsearch/manifests/init.pp | 385 ++++++++++++++ .../elasticsearch/manifests/instance.pp | 296 +++++++++++ .../elasticsearch/manifests/package.pp | 181 +++++++ .../modules/elasticsearch/manifests/params.pp | 190 +++++++ .../modules/elasticsearch/manifests/plugin.pp | 126 +++++ .../modules/elasticsearch/manifests/python.pp | 70 +++ .../modules/elasticsearch/manifests/repo.pp | 78 +++ .../modules/elasticsearch/manifests/ruby.pp | 67 +++ .../elasticsearch/manifests/service.pp | 91 ++++ .../elasticsearch/manifests/service/init.pp | 195 +++++++ .../manifests/service/systemd.pp | 202 ++++++++ .../elasticsearch/manifests/template.pp | 145 ++++++ 3rdparty/modules/elasticsearch/metadata.json | 80 +++ .../etc/elasticsearch/elasticsearch.yml.erb | 93 ++++ .../etc/elasticsearch/logging.yml.erb | 52 ++ .../etc/init.d/elasticsearch.Debian.erb | 204 ++++++++ .../etc/init.d/elasticsearch.RedHat.erb | 159 ++++++ .../etc/init.d/elasticsearch.systemd.erb | 20 + .../templates/etc/sysconfig/defaults.erb | 3 + hieradata/common.yaml | 2 + modules/debian-org/templates/puppet.conf.erb | 1 + modules/roles/manifests/init.pp | 4 + modules/roles/manifests/listsearch.pp | 13 + 44 files changed, 4295 insertions(+) create mode 100644 3rdparty/Puppetfile create mode 100644 3rdparty/README.md create mode 100644 3rdparty/modules/elasticsearch/CHANGELOG.md create mode 100644 3rdparty/modules/elasticsearch/CONTRIBUTING.md create mode 100644 3rdparty/modules/elasticsearch/CONTRIBUTORS create mode 100644 3rdparty/modules/elasticsearch/Gemfile create mode 100644 3rdparty/modules/elasticsearch/Gemfile.lock create mode 100644 3rdparty/modules/elasticsearch/LICENSE create mode 100644 3rdparty/modules/elasticsearch/Modulefile create mode 100644 3rdparty/modules/elasticsearch/README.md create mode 100644 3rdparty/modules/elasticsearch/checksums.json create mode 100644 3rdparty/modules/elasticsearch/lib/facter/es_facts.rb create mode 100644 3rdparty/modules/elasticsearch/lib/puppet/parser/functions/array_suffix.rb create mode 100644 3rdparty/modules/elasticsearch/lib/puppet/provider/es_instance_conn_validator/tcp_port.rb create mode 100644 3rdparty/modules/elasticsearch/lib/puppet/type/es_instance_conn_validator.rb create mode 100644 3rdparty/modules/elasticsearch/lib/puppet/util/es_instance_validator.rb create mode 100644 3rdparty/modules/elasticsearch/log/2015-03-13_19_24_02/sut.log create mode 100644 3rdparty/modules/elasticsearch/log/2015-03-14_18_41_25/sut.log create mode 100644 3rdparty/modules/elasticsearch/log/2015-03-16_02_10_40/sut.log create mode 100644 3rdparty/modules/elasticsearch/log/2015-03-16_23_30_55/sut.log create mode 100644 3rdparty/modules/elasticsearch/manifests/config.pp create mode 100644 3rdparty/modules/elasticsearch/manifests/init.pp create mode 100644 3rdparty/modules/elasticsearch/manifests/instance.pp create mode 100644 3rdparty/modules/elasticsearch/manifests/package.pp create mode 100644 3rdparty/modules/elasticsearch/manifests/params.pp create mode 100644 3rdparty/modules/elasticsearch/manifests/plugin.pp create mode 100644 3rdparty/modules/elasticsearch/manifests/python.pp create mode 100644 3rdparty/modules/elasticsearch/manifests/repo.pp create mode 100644 3rdparty/modules/elasticsearch/manifests/ruby.pp create mode 100644 3rdparty/modules/elasticsearch/manifests/service.pp create mode 100644 3rdparty/modules/elasticsearch/manifests/service/init.pp create mode 100644 3rdparty/modules/elasticsearch/manifests/service/systemd.pp create mode 100644 3rdparty/modules/elasticsearch/manifests/template.pp create mode 100644 3rdparty/modules/elasticsearch/metadata.json create mode 100644 3rdparty/modules/elasticsearch/templates/etc/elasticsearch/elasticsearch.yml.erb create mode 100644 3rdparty/modules/elasticsearch/templates/etc/elasticsearch/logging.yml.erb create mode 100644 3rdparty/modules/elasticsearch/templates/etc/init.d/elasticsearch.Debian.erb create mode 100644 3rdparty/modules/elasticsearch/templates/etc/init.d/elasticsearch.RedHat.erb create mode 100644 3rdparty/modules/elasticsearch/templates/etc/init.d/elasticsearch.systemd.erb create mode 100644 3rdparty/modules/elasticsearch/templates/etc/sysconfig/defaults.erb create mode 100644 modules/roles/manifests/listsearch.pp diff --git a/3rdparty/Puppetfile b/3rdparty/Puppetfile new file mode 100644 index 000000000..411a26247 --- /dev/null +++ b/3rdparty/Puppetfile @@ -0,0 +1,9 @@ +forge "http://forge.puppetlabs.com" + +#mod 'puppetlabs/stdlib', '4.5.1' +#mod 'puppetlabs/concat', '1.2.0' +#mod 'puppetlabs/rabbitmq', '5.1.0' +#mod 'puppetlabs/xinetd', '1.5.0' +#mod 'puppetlabs/stunnel', '0.1.0' + +mod 'elasticsearch/elasticsearch', '0.9.3' diff --git a/3rdparty/README.md b/3rdparty/README.md new file mode 100644 index 000000000..73198391e --- /dev/null +++ b/3rdparty/README.md @@ -0,0 +1,9 @@ +== 3rd-Party puppet component modules + +This repository contains puppetlabs and other 3rd-party puppet modules. This repository intentionally mirrors upstream code. + +The modules are managed with r10k or librarian-puppet. E.g. + + r10k puppetfile install + +will install all modules as listed in the Puppetfile. diff --git a/3rdparty/modules/elasticsearch/CHANGELOG.md b/3rdparty/modules/elasticsearch/CHANGELOG.md new file mode 100644 index 000000000..07afa59f3 --- /dev/null +++ b/3rdparty/modules/elasticsearch/CHANGELOG.md @@ -0,0 +1,256 @@ +##0.9.3( Mar 24, 2015 ) + +###Summary +Bugfix release 0.9.3 + +####Features + +####Bugfixes +* Not setting repo_version did not give the correct error +* Systemd file did not contain User/Group values + +####Changes +* Brand rename from Elasticsearch to Elastic + +####Testing changes +* Moved from multiple Gemfiles to single Gemfile + +####Known bugs +* Possible package conflicts when using ruby/python defines with main package name + +##0.9.2( Mar 06, 2015 ) + +###Summary +Bugfix release 0.9.2 + +####Features +* Introducing es_instance_conn_validator resource to verify instance availability + +####Bugfixes +* Fix missing data path when using the path config setting but not setting the data path + +####Changes +None + +####Testing changes +None + +####Known bugs +* Possible package conflicts when using ruby/python defines with main package name + +##0.9.1 ( Feb 23, 2015 ) + +###Summary +This is the first bug fix release for 0.9 version. +A bug was reported with the recursive file management. + +####Features +None + +####Bugfixes +* Fix recursive file management +* Set undefined variables to work with strict_variables + +####Changes +None + +####Testing changes +None + +####Known bugs +* Possible package conflicts when using ruby/python defines with main package name + +##0.9.0 ( Feb 02, 2015 ) + +###Summary +This release is the first one towards 1.0 release. +Our planning is to provide LTS releases with the puppet module + +####Features +* Support for using hiera to define instances and plugins. +* Support for OpenSuSE 13.x +* Custom facts about the installed Elasticsearch instance(s) +* Proxy host/port support for the plugin installation +* Ability to supply a custom logging.yml template + +####Bugfixes +* Ensure file owners are correct accross all related files +* Fix of possible service name conflict +* Empty main config would fail with instances +* Removal of standard files from packages we dont use +* Ensuring correct sequence of plugin and template defines +* Added ES_CLASSPATH export to init scripts + +####Changes +* Java installation to use puppetlabs-java module +* Added Support and testing for Puppet 3.7 and PE 3.7 +* Improve metadata.json based on scoring from Forge + + +####Testing changes +* Added testing against Puppet 3.7 and PE 3.7 +* Using rspec3 +* Using rspec-puppet-facts gem simplifies rspec testing + +####Known Bugs +* Possible package conflicts when using ruby/python defines with main package name + +##0.4.0 ( Jun 18, 2014 ) - Backwards compatible breaking release + +###Summary +This release introduces instances to facilitate the option to have more then a single instance running on the host system. + +####Features +* Rewrite module to incorperate multi instance support +* New readme layout + +####Bugfixes +* None + +####Changes +* Adding ec2-linux osfamily for repo management +* Retry behaviour for plugin installation + +####Testing changes +* Adding Puppet 3.6.x testing +* Ubuntu 14.04 testing +* Using new docker images +* Pin rspec to 2.14.x + +####Known Bugs +* No known bugs + +##0.3.2 ( May 15, 2014 ) +* Add support for SLC/Scientific Linux CERN ( PR #121 ) +* Add support for custom package names ( PR #122 ) +* Fix python and ruby client defines to avoid name clashes. +* Add ability to use stage instead of anchor for repo class +* Minor fixes to system tests + +##0.3.1 ( April 22, 2014 ) +* Ensure we create the plugin directory before installing plugins +* Added Puppet 3.5.x to rspec and system tests + +##0.3.0 ( April 2, 2014 ) +* Fix minor issue with yumrepo in repo class ( PR #92 ) +* Implement OpenSuse support +* Implement Junit reporting for tests +* Adding more system tests and convert to Docker images +* Use Augeas for managing the defaults file +* Add retry to package download exec +* Add management to manage the logging.yml file +* Improve inline documentation +* Improve support for Debian 6 +* Improve augeas for values with spaces +* Run plugin install as ES user ( PR #108 ) +* Fix rights for the plugin directory +* Pin Rake for Ruby 1.8.7 +* Adding new metadata for Forge. +* Increase time for retry to insert the template + +##0.2.4 ( Feb 21, 2014 ) +* Set puppetlabs-stdlib dependency version from 3.0.0 to 3.2.0 to be inline with other modules +* Let puppet run fail when template insert fails +* Documentation improvements ( PR #77, #78, #83 ) +* Added beaker system tests +* Fixed template define after failing system tests +* Some fixes so variables are more inline with intended structure + +##0.2.3 ( Feb 06, 2014 ) +* Add repository management feature +* Improve testing coverage and implement basic resource coverage reporting +* Add puppet 3.4.x testing +* Fix dependency in template define ( PR #72 ) +* For apt repo change from key server to key file + +##0.2.2 ( Jan 23, 2014 ) +* Ensure exec names are unique. This caused issues when using our logstash module +* Add spec tests for plugin define + +##0.2.1 ( Jan 22, 2014 ) +* Simplify the management of the defaults file ( PR #64 ) +* Doc improvements for the plugin define ( PR #66 ) +* Allow creation of data directory ( PR #68 ) +* Fail early when package version and package_url are defined + +##0.2.0 ( Nov 19, 2013 ) +* Large rewrite of the entire module described below +* Make the core more dynamic for different service providers and multi instance capable +* Add better testing and devided into different files +* Fix template function. Replace of template is now only done when the file is changed +* Add different ways to install the package except from the repository ( puppet/http/https/ftp/file ) +* Update java class to install openjdk 1.7 +* Add tests for python function +* Update config file template to fix scoping issue ( from PR #57 ) +* Add validation of templates +* Small changes for preperation for system tests +* Update readme for new functionality +* Added more test scenario's +* Added puppet parser validate task for added checking +* Ensure we don't add stuff when removing the module +* Update python client define +* Add ruby client define +* Add tests for ruby clients and update python client tests + +##0.1.3 ( Sep 06, 2013 ) +* Exec path settings has been updated to fix warnings ( PR #37, #47 ) +* Adding define to install python bindings ( PR #43 ) +* Scope deprecation fixes ( PR #41 ) +* feature to install plugins ( PR #40 ) + +##0.1.2 ( Jun 21, 2013 ) +* Update rake file to ignore the param inherit +* Added missing documentation to the template define +* Fix for template define to allow multiple templates ( PR #36 by Bruce Morrison ) + +##0.1.1 ( Jun 14, 2013 ) +* Add Oracle Linux to the OS list ( PR #25 by Stas Alekseev ) +* Respect the restart_on_change on the defaults ( PR #29 by Simon Effenberg ) +* Make sure the config can be empty as advertised in the readme +* Remove dependency cycle when the defaults file is updated ( PR #31 by Bruce Morrison ) +* Enable retry on the template insert in case ES isn't started yet ( PR #32 by Bruce Morrison ) +* Update templates to avoid deprecation notice with Puppet 3.2.x +* Update template define to avoid auto insert issue with ES +* Update spec tests to reflect changes to template define + +##0.1.0 ( May 09, 2013 ) +* Populate .gitignore ( PR #19 by Igor Galić ) +* Add ability to install initfile ( PR #20 by Justin Lambert ) +* Add ability to manage default file service parameters ( PR #21 by Mathieu Bornoz ) +* Providing complete containment of the module ( PR #24 by Brian Lalor ) +* Add ability to specify package version ( PR #25 by Justin Lambert ) +* Adding license file + +##0.0.7 ( Mar 23, 2013 ) +* Ensure config directory is created and managed ( PR #13 by Martin Seener ) +* Dont backup package if it changes +* Create explicit dependency on template directory ( PR #16 by Igor Galić ) +* Make the config directory variable ( PR #17 by Igor Galić and PR #18 by Vincent Janelle ) +* Fixing template define + +##0.0.6 ( Mar 05, 2013 ) +* Fixing issue with configuration not printing out arrays +* New feature to write the config hash shorter +* Updated readme to reflect the new feature +* Adding spec tests for config file generation + +##0.0.5 ( Mar 03, 2013 ) +* Option to disable restart on config file change ( PR #10 by Chris Boulton ) + +##0.0.4 ( Mar 02, 2013 ) +* Fixed a major issue with the config template ( Issue #9 ) + +##0.0.3 ( Mar 02, 2013 ) +* Adding spec tests +* Fixed init issue on Ubuntu ( Issue #6 by Marcus Furlong ) +* Fixed config template problem ( Issue #8 by surfchris ) +* New feature to manage templates + +##0.0.2 ( Feb 16, 2013 ) +* Feature to supply a package instead of being dependent on the repository +* Feature to install java in case one doesn't manage it externally +* Adding RedHat and Amazon as Operating systems +* fixed a typo - its a shard not a shared :) ( PR #5 by Martin Seener ) + +##0.0.1 ( Jan 13, 2013 ) +* Initial release of the module diff --git a/3rdparty/modules/elasticsearch/CONTRIBUTING.md b/3rdparty/modules/elasticsearch/CONTRIBUTING.md new file mode 100644 index 000000000..80f5cdde2 --- /dev/null +++ b/3rdparty/modules/elasticsearch/CONTRIBUTING.md @@ -0,0 +1,46 @@ +If you have a bugfix or new feature that you would like to contribute to this puppet module, please find or open an issue about it first. Talk about what you would like to do. It may be that somebody is already working on it, or that there are particular issues that you should know about before implementing the change. + +We enjoy working with contributors to get their code accepted. There are many approaches to fixing a problem and it is important to find the best approach before writing too much code. + +The process for contributing to any of the Elastic repositories is similar. + +1. Sign the contributor license agreement +Please make sure you have signed the [Contributor License Agreement](http://www.elastic.co/contributor-agreement/). We are not asking you to assign copyright to us, but to give us the right to distribute your code without restriction. We ask this of all contributors in order to assure our users of the origin and continuing existence of the code. You only need to sign the CLA once. + +2. Run the rspec tests and ensure it completes without errors with your changes. + +3. Run the acceptance tests + +These instructions are for Ubuntu 14.04 + +* install docker 0.11.1 + * wget https://get.docker.io/ubuntu/pool/main/l/lxc-docker/lxc-docker_0.11.1_amd64.deb + * wget https://get.docker.io/ubuntu/pool/main/l/lxc-docker-0.11.1/lxc-docker-0.11.1_0.11.1_amd64.deb + * sudo dpkg -i lxc-docker_0.11.1_amd64.deb lxc-docker-0.11.1_0.11.1_amd64.deb + * sudo usermod -a -G docker $USER +* export RS_SET='ubuntu-server-1404-x64' # see spec/acceptance/nodesets for more +* export VM_PUPPET_VERSION='3.7.0' +* wget https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.1.0.deb +* wget https://forgeapi.puppetlabs.com/v3/files/puppetlabs-stdlib-3.2.0.tar.gz +* wget https://forgeapi.puppetlabs.com/v3/files/puppetlabs-apt-1.4.2.tar.gz +* export files_dir=$(pwd) +* bundle install +* bundle exec rspec --require ci/reporter/rspec --format CI::Reporter::RSpecFormatter spec/acceptance/*_spec.rb + +``` + Hypervisor for ubuntu-14-04 is docker + Beaker::Hypervisor, found some docker boxes to create + Provisioning docker + provisioning ubuntu-14-04 + ... + Finished in 18 minutes 6 seconds + 224 examples, 0 failures, 3 pending +``` + +4. Rebase your changes +Update your local repository with the most recent code from the main this puppet module repository, and rebase your branch on top of the latest master branch. We prefer your changes to be squashed into a single commit. + +5. Submit a pull request +Push your local changes to your forked copy of the repository and submit a pull request. In the pull request, describe what your changes do and mention the number of the issue where discussion has taken place, eg “Closes #123″. + +Then sit back and wait. There will probably be discussion about the pull request and, if any changes are needed, we would love to work with you to get your pull request merged into this puppet module. diff --git a/3rdparty/modules/elasticsearch/CONTRIBUTORS b/3rdparty/modules/elasticsearch/CONTRIBUTORS new file mode 100644 index 000000000..ad0eb76c4 --- /dev/null +++ b/3rdparty/modules/elasticsearch/CONTRIBUTORS @@ -0,0 +1,20 @@ +The following is a list of people who have contributed ideas, code, bug +reports, or in general have helped this puppet module along its way. + +Project Owner +* Richard Pijnenburg (electrical) + +Contributors: +Martin Seener (martinseener) +Marcus Furlong (furlongm) +Chris Boulton (chrisboulton) +Igor Galić (igalic) +Vincent Janelle (vjanelle) +Mathieu Bornoz (mbornoz) +Justin Lambert (jlambert121) +Brian Lalor (blalor) +Stas Alekseev (salekseev) +Simon Effenberg (Savar) +Bruce Morrison (brucem) +deanmalmgren +Matteo Sessa (msessa-cotd) diff --git a/3rdparty/modules/elasticsearch/Gemfile b/3rdparty/modules/elasticsearch/Gemfile new file mode 100644 index 000000000..b76842515 --- /dev/null +++ b/3rdparty/modules/elasticsearch/Gemfile @@ -0,0 +1,22 @@ +source 'https://rubygems.org' + +puppetversion = ENV['PUPPET_VERSION'] || '~> 3.7.0' +gem 'puppet', puppetversion, :require => false + +gem 'beaker', :git => 'git@github.com:puppetlabs/beaker.git', :branch => 'master' +gem 'beaker-rspec', :git => 'git@github.com:puppetlabs/beaker-rspec.git', :branch => 'master' +gem 'metadata-json-lint', :git => 'https://github.com/nibalizer/metadata-json-lint.git', :branch => 'master' +gem 'rspec-puppet', :git => 'https://github.com/rodjek/rspec-puppet.git', :branch => 'master' + +gem 'pry' +gem 'docker-api', '~> 1.0' +gem 'rubysl-securerandom' +gem 'ci_reporter_rspec' +gem 'rspec', '~> 3.0' +gem 'rake' +gem 'puppet-doc-lint' +gem 'puppet-lint' +gem 'puppetlabs_spec_helper' +gem 'puppet-syntax' +gem 'rspec-puppet-facts' +gem 'webmock' diff --git a/3rdparty/modules/elasticsearch/Gemfile.lock b/3rdparty/modules/elasticsearch/Gemfile.lock new file mode 100644 index 000000000..9e6569304 --- /dev/null +++ b/3rdparty/modules/elasticsearch/Gemfile.lock @@ -0,0 +1,335 @@ +GIT + remote: git@github.com:puppetlabs/beaker-rspec.git + revision: c4c43fd726c4910f38585c30177f088596ce1872 + branch: master + specs: + beaker-rspec (5.0.1) + beaker (~> 2.0) + rspec + serverspec (~> 2) + specinfra (~> 2) + +GIT + remote: git@github.com:puppetlabs/beaker.git + revision: f426a7cffb1588105623578d6b98a4c37186cf91 + branch: master + specs: + beaker (2.7.1) + aws-sdk (~> 1.57) + docker-api + fission (~> 0.4) + fog (~> 1.25) + google-api-client (~> 0.8) + hocon (~> 0.0.4) + inifile (~> 2.0) + json (~> 1.8) + minitest (~> 5.4) + net-scp (~> 1.2) + net-ssh (~> 2.9) + rbvmomi (~> 1.8) + rsync (~> 1.0.9) + unf (~> 0.1) + +GIT + remote: https://github.com/nibalizer/metadata-json-lint.git + revision: c2225fed4b88aef1945e8da3f8580709939371cd + branch: master + specs: + metadata-json-lint (0.0.6) + json + spdx-licenses (~> 1.0) + +GIT + remote: https://github.com/rodjek/rspec-puppet.git + revision: a9a837669cf6955279f02d1d9b524dc140b9d3e8 + branch: master + specs: + rspec-puppet (2.0.1) + rspec + +GEM + remote: https://rubygems.org/ + specs: + CFPropertyList (2.3.1) + activesupport (4.2.1) + i18n (~> 0.7) + json (~> 1.7, >= 1.7.7) + minitest (~> 5.1) + thread_safe (~> 0.3, >= 0.3.4) + tzinfo (~> 1.1) + addressable (2.3.7) + autoparse (0.3.3) + addressable (>= 2.3.1) + extlib (>= 0.9.15) + multi_json (>= 1.0.0) + aws-sdk (1.63.0) + aws-sdk-v1 (= 1.63.0) + aws-sdk-v1 (1.63.0) + json (~> 1.4) + nokogiri (>= 1.4.4) + axiom-types (0.1.1) + descendants_tracker (~> 0.0.4) + ice_nine (~> 0.11.0) + thread_safe (~> 0.3, >= 0.3.1) + builder (3.2.2) + ci_reporter (2.0.0) + builder (>= 2.1.2) + ci_reporter_rspec (1.0.0) + ci_reporter (~> 2.0) + rspec (>= 2.14, < 4) + coderay (1.1.0) + coercible (1.0.0) + descendants_tracker (~> 0.0.1) + crack (0.4.2) + safe_yaml (~> 1.0.0) + descendants_tracker (0.0.4) + thread_safe (~> 0.3, >= 0.3.1) + diff-lcs (1.2.5) + docker-api (1.20.0) + excon (>= 0.38.0) + json + equalizer (0.0.11) + excon (0.44.4) + extlib (0.9.16) + facter (1.7.6) + faraday (0.9.1) + multipart-post (>= 1.2, < 3) + fission (0.5.0) + CFPropertyList (~> 2.2) + fog (1.28.0) + fog-atmos + fog-aws (~> 0.0) + fog-brightbox (~> 0.4) + fog-core (~> 1.27, >= 1.27.3) + fog-ecloud + fog-json + fog-profitbricks + fog-radosgw (>= 0.0.2) + fog-riakcs + fog-sakuracloud (>= 0.0.4) + fog-serverlove + fog-softlayer + fog-storm_on_demand + fog-terremark + fog-vmfusion + fog-voxel + fog-xml (~> 0.1.1) + ipaddress (~> 0.5) + nokogiri (~> 1.5, >= 1.5.11) + fog-atmos (0.1.0) + fog-core + fog-xml + fog-aws (0.1.1) + fog-core (~> 1.27) + fog-json (~> 1.0) + fog-xml (~> 0.1) + ipaddress (~> 0.8) + fog-brightbox (0.7.1) + fog-core (~> 1.22) + fog-json + inflecto (~> 0.0.2) + fog-core (1.29.0) + builder + excon (~> 0.38) + formatador (~> 0.2) + mime-types + net-scp (~> 1.1) + net-ssh (>= 2.1.3) + fog-ecloud (0.0.2) + fog-core + fog-xml + fog-json (1.0.0) + multi_json (~> 1.0) + fog-profitbricks (0.0.2) + fog-core + fog-xml + nokogiri + fog-radosgw (0.0.3) + fog-core (>= 1.21.0) + fog-json + fog-xml (>= 0.0.1) + fog-riakcs (0.1.0) + fog-core + fog-json + fog-xml + fog-sakuracloud (1.0.0) + fog-core + fog-json + fog-serverlove (0.1.1) + fog-core + fog-json + fog-softlayer (0.4.1) + fog-core + fog-json + fog-storm_on_demand (0.1.0) + fog-core + fog-json + fog-terremark (0.0.4) + fog-core + fog-xml + fog-vmfusion (0.0.1) + fission + fog-core + fog-voxel (0.0.2) + fog-core + fog-xml + fog-xml (0.1.1) + fog-core + nokogiri (~> 1.5, >= 1.5.11) + formatador (0.2.5) + google-api-client (0.8.3) + activesupport (>= 3.2) + addressable (~> 2.3) + autoparse (~> 0.3) + extlib (~> 0.9) + faraday (~> 0.9) + googleauth (~> 0.3) + launchy (~> 2.4) + multi_json (~> 1.10) + retriable (~> 1.4) + signet (~> 0.6) + googleauth (0.3.0) + faraday (~> 0.9) + jwt (~> 1.4.1) + logging (~> 1.8) + memoist (~> 0.11.0) + multi_json (= 1.11.0) + signet (~> 0.6.0) + hiera (1.3.4) + json_pure + hocon (0.0.7) + i18n (0.7.0) + ice_nine (0.11.1) + inflecto (0.0.2) + inifile (2.0.2) + ipaddress (0.8.0) + json (1.8.2) + json_pure (1.8.2) + jwt (1.4.1) + launchy (2.4.3) + addressable (~> 2.3) + little-plugger (1.1.3) + logging (1.8.2) + little-plugger (>= 1.1.3) + multi_json (>= 1.8.4) + memoist (0.11.0) + metaclass (0.0.4) + method_source (0.8.2) + mime-types (2.4.3) + mini_portile (0.6.2) + minitest (5.5.1) + mocha (1.1.0) + metaclass (~> 0.0.1) + multi_json (1.11.0) + multipart-post (2.0.0) + net-scp (1.2.1) + net-ssh (>= 2.6.5) + net-ssh (2.9.2) + nokogiri (1.6.6.2) + mini_portile (~> 0.6.0) + pry (0.10.1) + coderay (~> 1.1.0) + method_source (~> 0.8.1) + slop (~> 3.4) + puppet (3.7.4) + facter (> 1.6, < 3) + hiera (~> 1.0) + json_pure + puppet-doc-lint (0.3.0) + facter + puppet + rdoc (>= 3.12, < 4.0) + virtus (~> 1.0.1) + puppet-lint (1.1.0) + puppet-syntax (2.0.0) + rake + puppetlabs_spec_helper (0.10.1) + mocha + puppet-lint + puppet-syntax + rake + rspec-puppet + rake (10.4.2) + rbvmomi (1.8.2) + builder + nokogiri (>= 1.4.1) + trollop + rdoc (3.12.2) + json (~> 1.4) + retriable (1.4.1) + rspec (3.2.0) + rspec-core (~> 3.2.0) + rspec-expectations (~> 3.2.0) + rspec-mocks (~> 3.2.0) + rspec-core (3.2.2) + rspec-support (~> 3.2.0) + rspec-expectations (3.2.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.2.0) + rspec-its (1.2.0) + rspec-core (>= 3.0.0) + rspec-expectations (>= 3.0.0) + rspec-mocks (3.2.1) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.2.0) + rspec-puppet-facts (0.6.0) + facter + json + rspec-support (3.2.2) + rsync (1.0.9) + rubysl-securerandom (2.0.0) + safe_yaml (1.0.4) + serverspec (2.13.0) + multi_json + rspec (~> 3.0) + rspec-its + specinfra (~> 2.25) + signet (0.6.0) + addressable (~> 2.3) + extlib (~> 0.9) + faraday (~> 0.9) + jwt (~> 1.0) + multi_json (~> 1.10) + slop (3.6.0) + spdx-licenses (1.0.0) + json + specinfra (2.25.0) + net-scp + net-ssh + thread_safe (0.3.5) + trollop (2.1.2) + tzinfo (1.2.2) + thread_safe (~> 0.1) + unf (0.1.4) + unf_ext + unf_ext (0.0.6) + virtus (1.0.5) + axiom-types (~> 0.1) + coercible (~> 1.0) + descendants_tracker (~> 0.0, >= 0.0.3) + equalizer (~> 0.0, >= 0.0.9) + webmock (1.20.4) + addressable (>= 2.3.6) + crack (>= 0.3.2) + +PLATFORMS + ruby + +DEPENDENCIES + beaker! + beaker-rspec! + ci_reporter_rspec + docker-api (~> 1.0) + metadata-json-lint! + pry + puppet (~> 3.7.0) + puppet-doc-lint + puppet-lint + puppet-syntax + puppetlabs_spec_helper + rake + rspec (~> 3.0) + rspec-puppet! + rspec-puppet-facts + rubysl-securerandom + webmock diff --git a/3rdparty/modules/elasticsearch/LICENSE b/3rdparty/modules/elasticsearch/LICENSE new file mode 100644 index 000000000..8eba2be11 --- /dev/null +++ b/3rdparty/modules/elasticsearch/LICENSE @@ -0,0 +1,13 @@ +Copyright (c) 2012-2015 Elasticsearch + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/3rdparty/modules/elasticsearch/Modulefile b/3rdparty/modules/elasticsearch/Modulefile new file mode 100644 index 000000000..1432103ee --- /dev/null +++ b/3rdparty/modules/elasticsearch/Modulefile @@ -0,0 +1,9 @@ +name 'elasticsearch-elasticsearch' +version '0.9.3' +source 'https://github.com/elastic/puppet-elasticsearch' +author 'elasticsearch' +license 'Apache License, Version 2.0' +summary 'Module for managing and configuring Elasticsearch nodes' +description 'Module for managing and configuring Elasticsearch nodes' +project_page 'https://github.com/elastic/puppet-elasticsearch' +dependency 'puppetlabs/stdlib', '>= 3.2.0 < 5.0.0' diff --git a/3rdparty/modules/elasticsearch/README.md b/3rdparty/modules/elasticsearch/README.md new file mode 100644 index 000000000..096e1bbc9 --- /dev/null +++ b/3rdparty/modules/elasticsearch/README.md @@ -0,0 +1,485 @@ +#Elasticsearch Puppet module + +[![Build Status](https://travis-ci.org/elasticsearch/puppet-elasticsearch.png?branch=master)](https://travis-ci.org/elasticsearch/puppet-elasticsearch) + +####Table of Contents + +1. [Overview](#overview) +2. [Module description - What the module does and why it is useful](#module-description) +3. [Setup - The basics of getting started with Elasticsearch](#setup) + * [The module manages the following](#the-module-manages-the-following) + * [Requirements](#requirements) +4. [Usage - Configuration options and additional functionality](#usage) +5. [Advanced features - Extra information on advanced usage](#advanced-features) +6. [Limitations - OS compatibility, etc.](#limitations) +7. [Development - Guide for contributing to the module](#development) +8. [Support - When you need help with this module](#support) + + + +##Overview + +This module manages Elasticsearch (http://www.elasticsearch.org/overview/elasticsearch/) + +##Module description + +The elasticsearch module sets up Elasticsearch instances and can manage plugins and templates. + +This module has been tested against ES 1.0 and up. + +##Setup + +###The module manages the following + +* Elasticsearch repository files. +* Elasticsearch package. +* Elasticsearch configuration file. +* Elasticsearch service. +* Elasticsearch plugins. +* Elasticsearch templates. + +###Requirements + +* The [stdlib](https://forge.puppetlabs.com/puppetlabs/stdlib) Puppet library. +* Augeas + +#### Repository management +When using the repository management you will need the following dependency modules: + +* Debian/Ubuntu: [Puppetlabs/apt](http://forge.puppetlabs.com/puppetlabs/apt) +* OpenSuSE: [Darin/zypprepo](https://forge.puppetlabs.com/darin/zypprepo) + +##Usage + +###Main class + +####Install a specific version + +```puppet +class { 'elasticsearch': + version => '1.4.2' +} +``` + +Note: This will only work when using the repository. + +####Automatic upgrade of the software ( default set to false ) +``` +class { 'elasticsearch': + autoupgrade => true +} +``` + +####Removal/decommissioning +```puppet +class { 'elasticsearch': + ensure => 'absent' +} +``` + +####Install everything but disable service(s) afterwards +```puppet +class { 'elasticsearch': + status => 'disabled' +} +``` + +###Instances + +This module works with the concept of instances. For service to start you need to specify at least one instance. + +####Quick setup +```puppet +elasticsearch::instance { 'es-01': } +``` + +This will set up its own data directory and set the node name to `$hostname-$instance_name` + +####Advanced options + +Instance specific options can be given: + +```puppet +elasticsearch::instance { 'es-01': + config => { }, # Configuration hash + init_defaults => { }, # Init defaults hash + datadir => [ ], # Data directory +} +``` + +See [Advanced features](#advanced-features) for more information + +###Plug-ins + +Install [a variety of plugins](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-plugins.html#known-plugins): + +####From official repository +```puppet +elasticsearch::plugin{'lmenezes/elasticsearch-kopf': + module_dir => 'kopf', + instances => 'instance_name' +} +``` +####From custom url +```puppet +elasticsearch::plugin{ 'elasticsearch-jetty': + module_dir => 'jetty', + url => 'https://oss-es-plugins.s3.amazonaws.com/elasticsearch-jetty/elasticsearch-jetty-1.2.1.zip', + instances => 'instance_name' +} +``` + + +####Using a proxy +You can also use a proxy if required by setting the `proxy_host` and `proxy_port` options: +```puppet +elasticsearch::plugin { 'lmenezes/elasticsearch-kopf', + module_dir => 'kopf', + instances => 'instance_name', + proxy_host => 'proxy.host.com', + proxy_port => 3128 +} +``` + +#####Plugin name could be: +* `elasticsearch/plugin/version` for official elasticsearch plugins (download from download.elasticsearch.org) +* `groupId/artifactId/version` for community plugins (download from maven central or oss sonatype) +* `username/repository` for site plugins (download from github master) + +###Templates + +#### Add a new template using a file + +This will install and/or replace the template in Elasticsearch: + +```puppet +elasticsearch::template { 'templatename': + file => 'puppet:///path/to/template.json' +} +``` + +#### Add a new template using content + +This will install and/or replace the template in Elasticsearch: + +```puppet +elasticsearch::template { 'templatename': + content => '{"template":"*","settings":{"number_of_replicas":0}}' +} +``` + +#### Delete a template + +```puppet +elasticsearch::template { 'templatename': + ensure => 'absent' +} +``` + +#### Host + +By default it uses localhost:9200 as host. you can change this with the `host` and `port` variables + +```puppet +elasticsearch::template { 'templatename': + host => $::ipaddress, + port => 9200 +} +``` + +###Bindings / Clients + +Install a variety of [clients/bindings](http://www.elasticsearch.org/guide/en/elasticsearch/client/community/current/clients.html): + +####Python + +```puppet +elasticsearch::python { 'rawes': } +``` + +####Ruby +```puppet +elasticsearch::ruby { 'elasticsearch': } +``` + +###Connection Validator + +This module offers a way to make sure an instance has been started and is up and running before +doing a next action. This is done via the use of the `es_instance_conn_validator` resource. +```puppet +es_instance_conn_validator { 'myinstance' : + server => 'es.example.com', + port => '9200', +} +``` + +A common use would be for example : + +```puppet +class { 'kibana4' : + require => Es_Instance_Conn_Validator['myinstance'], +} +``` + +###Package installation + +There are 2 different ways of installing the software + +####Repository + +This option allows you to use an existing repository for package installation. +The `repo_version` corresponds with the major version of Elasticsearch. + +```puppet +class { 'elasticsearch': + manage_repo => true, + repo_version => '1.4', +} +``` + +####Remote package source + +When a repository is not available or preferred you can install the packages from a remote source: + +#####http/https/ftp +```puppet +class { 'elasticsearch': + package_url => 'https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.4.2.deb' +} +``` + +#####puppet:// +```puppet +class { 'elasticsearch': + package_url => 'puppet:///path/to/elasticsearch-1.4.2.deb' +} +``` + +#####Local file +```puppet +class { 'elasticsearch': + package_url => 'file:/path/to/elasticsearch-1.4.2.deb' +} +``` + +###Java installation + +Most sites will manage Java separately; however, this module can attempt to install Java as well. +This is done by using the [puppetlabs-java](https://forge.puppetlabs.com/puppetlabs/java) module. + +```puppet +class { 'elasticsearch': + java_install => true +} +``` + +Specify a particular Java package/version to be installed: + +```puppet +class { 'elasticsearch': + java_install => true, + java_package => 'packagename' +} +``` + +###Service management + +Currently only the basic SysV-style [init](https://en.wikipedia.org/wiki/Init) and [Systemd](http://en.wikipedia.org/wiki/Systemd) service providers are supported, but other systems could be implemented as necessary (pull requests welcome). + + +####Defaults File + +The *defaults* file (`/etc/defaults/elasticsearch` or `/etc/sysconfig/elasticsearch`) for the Elasticsearch service can be populated as necessary. This can either be a static file resource or a simple key value-style [hash](http://docs.puppetlabs.com/puppet/latest/reference/lang_datatypes.html#hashes) object, the latter being particularly well-suited to pulling out of a data source such as Hiera. + +#####file source +```puppet +class { 'elasticsearch': + init_defaults_file => 'puppet:///path/to/defaults' +} +``` +#####hash representation +```puppet +$config_hash = { + 'ES_USER' => 'elasticsearch', + 'ES_GROUP' => 'elasticsearch', +} + +class { 'elasticsearch': + init_defaults => $config_hash +} +``` + +Note: `init_defaults` hash can be passed to the main class and to the instance. + +##Advanced features + + +###Data directories + +There are 4 different ways of setting data directories for Elasticsearch. +In every case the required configuration options are placed in the `elasticsearch.yml` file. + +####Default +By default we use: + +`/usr/share/elasticsearch/data/$instance_name` + +Which provides a data directory per instance. + + +####Single global data directory + +```puppet +class { 'elasticsearch': + datadir => '/var/lib/elasticsearch-data' +} +``` +Creates the following for each instance: + +`/var/lib/elasticsearch-data/$instance_name` + +####Multiple Global data directories + +```puppet +class { 'elasticsearch': + datadir => [ '/var/lib/es-data1', '/var/lib/es-data2'] +} +``` +Creates the following for each instance: +`/var/lib/es-data1/$instance_name` +and +`/var/lib/es-data2/$instance_name` + + +####Single instance data directory + +```puppet +class { 'elasticsearch': } + +elasticsearch::instance { 'es-01': + datadir => '/var/lib/es-data-es01' +} +``` +Creates the following for this instance: +`/var/lib/es-data-es01` + +####Multiple instance data directories + +```puppet +class { 'elasticsearch': } + +elasticsearch::instance { 'es-01': + datadir => ['/var/lib/es-data1-es01', '/var/lib/es-data2-es01'] +} +``` +Creates the following for this instance: +`/var/lib/es-data1-es01` +and +`/var/lib/es-data2-es01` + + +###Main and instance configurations + +The `config` option in both the main class and the instances can be configured to work together. + +The options in the `instance` config hash will merged with the ones from the main class and override any duplicates. + +#### Simple merging + +```puppet +class { 'elasticsearch': + config => { 'cluster.name' => 'clustername' } +} + +elasticsearch::instance { 'es-01': + config => { 'node.name' => 'nodename' } +} +elasticsearch::instance { 'es-02': + config => { 'node.name' => 'nodename2' } +} + +``` + +This example merges the `cluster.name` together with the `node.name` option. + +#### Overriding + +When duplicate options are provided, the option in the instance config overrides the ones from the main class. + +```puppet +class { 'elasticsearch': + config => { 'cluster.name' => 'clustername' } +} + +elasticsearch::instance { 'es-01': + config => { 'node.name' => 'nodename', 'cluster.name' => 'otherclustername' } +} + +elasticsearch::instance { 'es-02': + config => { 'node.name' => 'nodename2' } +} +``` + +This will set the cluster name to `otherclustername` for the instance `es-01` but will keep it to `clustername` for instance `es-02` + +####Configuration writeup + +The `config` hash can be written in 2 different ways: + +##### Full hash writeup + +Instead of writing the full hash representation: +```puppet +class { 'elasticsearch': + config => { + 'cluster' => { + 'name' => 'ClusterName', + 'routing' => { + 'allocation' => { + 'awareness' => { + 'attributes' => 'rack' + } + } + } + } + } +} +``` +##### Short hash writeup +```puppet +class { 'elasticsearch': + config => { + 'cluster' => { + 'name' => 'ClusterName', + 'routing.allocation.awareness.attributes' => 'rack' + } + } +} +``` + + +##Limitations + +This module has been built on and tested against Puppet 3.2 and higher. + +The module has been tested on: + +* Debian 6/7 +* CentOS 6 +* Ubuntu 12.04, 14.04 +* OpenSuSE 13.x + +Other distro's that have been reported to work: + +* RHEL 6 +* OracleLinux 6 +* Scientific 6 + +Testing on other platforms has been light and cannot be guaranteed. + +##Development + + +##Support + +Need help? Join us in [#elasticsearch](https://webchat.freenode.net?channels=%23elasticsearch) on Freenode IRC or subscribe to the [elasticsearch@googlegroups.com](https://groups.google.com/forum/#!forum/elasticsearch) mailing list. diff --git a/3rdparty/modules/elasticsearch/checksums.json b/3rdparty/modules/elasticsearch/checksums.json new file mode 100644 index 000000000..7bf75bbc2 --- /dev/null +++ b/3rdparty/modules/elasticsearch/checksums.json @@ -0,0 +1,39 @@ +{ + "CHANGELOG.md": "4a81c4fe644a2359154438a3f22b9314", + "CONTRIBUTING.md": "c2985e231626a62f65cb661eaa346794", + "CONTRIBUTORS": "14df2fd27cf7b6ca9833527f2ba93442", + "Gemfile": "4be55511a7990290d9693eb8131d3767", + "Gemfile.lock": "a385e2f9cad45b87ad5c264827c8ff8e", + "LICENSE": "0e0bfc0e5636afdb297a2aa49d8d933d", + "Modulefile": "cb22d42b03516f2fb9e0cf7dd2a95ac4", + "README.md": "79bd2afce64519598a63de9041c966a3", + "lib/facter/es_facts.rb": "b4b33e1047d659e45cb2590402f4b376", + "lib/puppet/parser/functions/array_suffix.rb": "f4d8cfd448698eb9594f49bb2ed3c263", + "lib/puppet/provider/es_instance_conn_validator/tcp_port.rb": "1f20143aa8023524ad568cabc0fc36c8", + "lib/puppet/type/es_instance_conn_validator.rb": "60016925ceb392dad8e4d1c7f4bcbea7", + "lib/puppet/util/es_instance_validator.rb": "ded80d7d5ae1467f1060a57de7210cad", + "log/2015-03-13_19_24_02/sut.log": "2d4dae0768ba158fbf6f67f9758a88eb", + "log/2015-03-14_18_41_25/sut.log": "c3101099c35c9804c9f47a304a49c82b", + "log/2015-03-16_02_10_40/sut.log": "51407bfcddeb9689ab330c8e8120806b", + "log/2015-03-16_23_30_55/sut.log": "1f0faa9e603fcf3af4b51045e9215c64", + "manifests/config.pp": "ee90bc3dee3f75225e4ed5df281b7067", + "manifests/init.pp": "bb9bdda59f5a0e4ddf307c6f61c06a5f", + "manifests/instance.pp": "3cd452071af6e612a61ffec93c6d20f5", + "manifests/package.pp": "176fa044686caca3ca13de5aad10e85d", + "manifests/params.pp": "43e6580af881579a9f607ade881cfa7e", + "manifests/plugin.pp": "bfb8df0bb1158ca4f4070fa86fe27e3e", + "manifests/python.pp": "109f076fea175ffef78da479952dc1a0", + "manifests/repo.pp": "4cff161af5b4500437354d79c1839307", + "manifests/ruby.pp": "dd72a2538e23bba1c47618c9b3e6d66f", + "manifests/service/init.pp": "a642c495df7b249c0e84ec87024fd928", + "manifests/service/systemd.pp": "5a20cdd31c37d70635847acf6c444d5b", + "manifests/service.pp": "594de29d273d24f25b9f5ec61380d7e6", + "manifests/template.pp": "87af209a0d768cc36b9e4a5fcefcaf46", + "metadata.json": "2f76c1774a6a1d7afdcb7b850550db96", + "templates/etc/elasticsearch/elasticsearch.yml.erb": "08529839471ef1fac3a9f4a169ec5da8", + "templates/etc/elasticsearch/logging.yml.erb": "99062dbf00c6b96d9bec7382dadafb9d", + "templates/etc/init.d/elasticsearch.Debian.erb": "e7a586b5fd921ec6819936f44694f4c2", + "templates/etc/init.d/elasticsearch.RedHat.erb": "4dde4b836654ea8332d65d852568d2f5", + "templates/etc/init.d/elasticsearch.systemd.erb": "61d511192a7b6a915f590cba546fd889", + "templates/etc/sysconfig/defaults.erb": "57b40f8213c0c05d5dcf185bf00a25b7" +} \ No newline at end of file diff --git a/3rdparty/modules/elasticsearch/lib/facter/es_facts.rb b/3rdparty/modules/elasticsearch/lib/facter/es_facts.rb new file mode 100644 index 000000000..0d6f2477b --- /dev/null +++ b/3rdparty/modules/elasticsearch/lib/facter/es_facts.rb @@ -0,0 +1,93 @@ +require 'net/http' +require 'json' +require 'yaml' + +module EsFacts + + def self.add_fact(prefix, key, value) + key = "#{prefix}_#{key}".to_sym + ::Facter.add(key) do + setcode { value } + end + end + + def self.run + + dir_prefix = '/etc/elasticsearch' + ports = [] + + # only when the directory exists we need to process the stuff + if File.directory?(dir_prefix) + + Dir.foreach(dir_prefix) { |dir| + next if dir == '.' + if File.exists?("#{dir_prefix}/#{dir}/elasticsearch.yml") + config_data = YAML.load_file("#{dir_prefix}/#{dir}/elasticsearch.yml") + unless config_data['http'].nil? + next if config_data['http']['enabled'] == 'false' + if config_data['http']['port'].nil? + port = "9200" + else + port = config_data['http']['port'] + end + else + port = "9200" + end + ports << port + end + } + + begin + if ports.count > 0 + + add_fact('elasticsearch', 'ports', ports.join(",") ) + ports.each do |port| + + key_prefix = "elasticsearch_#{port}" + + uri = URI("http://localhost:#{port}") + json_data = JSON.parse(Net::HTTP.get(uri)) + next if json_data['status'] && json_data['status'] != 200 + + add_fact(key_prefix, 'name', json_data['name']) + add_fact(key_prefix, 'version', json_data['version']['number']) + + uri2 = URI("http://localhost:#{port}/_nodes/#{json_data['name']}") + json_data_node = JSON.parse(Net::HTTP.get(uri2)) + + add_fact(key_prefix, 'cluster_name', json_data_node['cluster_name']) + node_data = json_data_node['nodes'].first + + add_fact(key_prefix, 'node_id', node_data[0]) + + nodes_data = json_data_node['nodes'][node_data[0]] + + process = nodes_data['process'] + add_fact(key_prefix, 'mlockall', process['mlockall']) + + plugins = nodes_data['plugins'] + + plugin_names = [] + plugins.each do |plugin| + plugin_names << plugin['name'] + + plugin.each do |key, value| + prefix = "#{key_prefix}_plugin_#{plugin['name']}" + add_fact(prefix, key, value) unless key == 'name' + end + end + add_fact(key_prefix, 'plugins', plugin_names.join(",")) + + end + + end + rescue + end + + end + + end + +end + +EsFacts.run diff --git a/3rdparty/modules/elasticsearch/lib/puppet/parser/functions/array_suffix.rb b/3rdparty/modules/elasticsearch/lib/puppet/parser/functions/array_suffix.rb new file mode 100644 index 000000000..0f2da68e7 --- /dev/null +++ b/3rdparty/modules/elasticsearch/lib/puppet/parser/functions/array_suffix.rb @@ -0,0 +1,45 @@ +# +# suffix.rb +# + +module Puppet::Parser::Functions + newfunction(:array_suffix, :type => :rvalue, :doc => <<-EOS +This function applies a suffix to all elements in an array. + +*Examples:* + + array_suffix(['a','b','c'], 'p') + +Will return: ['ap','bp','cp'] + EOS + ) do |arguments| + + # Technically we support two arguments but only first is mandatory ... + raise(Puppet::ParseError, "array_suffix(): Wrong number of arguments " + + "given (#{arguments.size} for 1)") if arguments.size < 1 + + array = arguments[0] + + unless array.is_a?(Array) + raise Puppet::ParseError, "array_suffix(): expected first argument to be an Array, got #{array.inspect}" + end + + suffix = arguments[1] if arguments[1] + + if suffix + unless suffix.is_a? String + raise Puppet::ParseError, "array_suffix(): expected second argument to be a String, got #{suffix.inspect}" + end + end + + # Turn everything into string same as join would do ... + result = array.collect do |i| + i = i.to_s + suffix ? i + suffix : i + end + + return result + end +end + +# vim: set ts=2 sw=2 et : diff --git a/3rdparty/modules/elasticsearch/lib/puppet/provider/es_instance_conn_validator/tcp_port.rb b/3rdparty/modules/elasticsearch/lib/puppet/provider/es_instance_conn_validator/tcp_port.rb new file mode 100644 index 000000000..3cd1ef6bf --- /dev/null +++ b/3rdparty/modules/elasticsearch/lib/puppet/provider/es_instance_conn_validator/tcp_port.rb @@ -0,0 +1,51 @@ +$LOAD_PATH.unshift(File.join(File.dirname(__FILE__),"..","..","..")) +require 'puppet/util/es_instance_validator' + +# This file contains a provider for the resource type `es_instance_conn_validator`, +# which validates the Elasticsearch instance connection by attempting an https connection. + +Puppet::Type.type(:es_instance_conn_validator).provide(:tcp_port) do + desc "A provider for the resource type `es_instance_conn_validator`, + which validates the connection by attempting an https + connection to the Elasticsearch instance." + + def exists? + start_time = Time.now + timeout = resource[:timeout] + + success = validator.attempt_connection + + while success == false && ((Time.now - start_time) < timeout) + # It can take several seconds for the Elasticsearch instance to start up; + # especially on the first install. Therefore, our first connection attempt + # may fail. Here we have somewhat arbitrarily chosen to retry every 2 + # seconds until the configurable timeout has expired. + Puppet.debug("Failed to connect to the Elasticsearch instance; sleeping 2 seconds before retry") + sleep 2 + success = validator.attempt_connection + end + + if success + Puppet.debug("Connected to the ES instance in #{Time.now - start_time} seconds.") + else + Puppet.notice("Failed to connect to the ES instance within timeout window of #{timeout} seconds; giving up.") + end + + success + end + + def create + # If `#create` is called, that means that `#exists?` returned false, which + # means that the connection could not be established... so we need to + # cause a failure here. + raise Puppet::Error, "Unable to connect to ES instance ! (#{@validator.instance_server}:#{@validator.instance_port})" + end + + private + + # @api private + def validator + @validator ||= Puppet::Util::EsInstanceValidator.new(resource[:server], resource[:port]) + end + +end diff --git a/3rdparty/modules/elasticsearch/lib/puppet/type/es_instance_conn_validator.rb b/3rdparty/modules/elasticsearch/lib/puppet/type/es_instance_conn_validator.rb new file mode 100644 index 000000000..5ecd14d06 --- /dev/null +++ b/3rdparty/modules/elasticsearch/lib/puppet/type/es_instance_conn_validator.rb @@ -0,0 +1,38 @@ +Puppet::Type.newtype(:es_instance_conn_validator) do + + @doc = "Verify that a connection can be successfully established between a node + and the Elasticsearch instance. It could potentially be used for other + purposes such as monitoring." + + ensurable do + defaultvalues + defaultto :present + end + + newparam(:name, :namevar => true) do + desc 'An arbitrary name used as the identity of the resource.' + end + + newparam(:server) do + desc 'DNS name or IP address of the server where Elasticsearch instance should be running.' + defaultto 'localhost' + end + + newparam(:port) do + desc 'The port that the Elasticsearch instance should be listening on.' + defaultto 9200 + end + + newparam(:timeout) do + desc 'The max number of seconds that the validator should wait before giving up and deciding that the Elasticsearch instance is not running; defaults to 60 seconds.' + defaultto 60 + validate do |value| + # This will raise an error if the string is not convertible to an integer + Integer(value) + end + munge do |value| + Integer(value) + end + end + +end diff --git a/3rdparty/modules/elasticsearch/lib/puppet/util/es_instance_validator.rb b/3rdparty/modules/elasticsearch/lib/puppet/util/es_instance_validator.rb new file mode 100644 index 000000000..e0973148f --- /dev/null +++ b/3rdparty/modules/elasticsearch/lib/puppet/util/es_instance_validator.rb @@ -0,0 +1,36 @@ +require 'socket' +require 'timeout' + +module Puppet + module Util + class EsInstanceValidator + attr_reader :instance_server + attr_reader :instance_port + + def initialize(instance_server, instance_port) + @instance_server = instance_server + @instance_port = instance_port + end + + # Utility method; attempts to make an https connection to the Elasticsearch instance. + # This is abstracted out into a method so that it can be called multiple times + # for retry attempts. + # + # @return true if the connection is successful, false otherwise. + def attempt_connection + Timeout::timeout(Puppet[:configtimeout]) do + begin + TCPSocket.new(@instance_server, @instance_port).close + true + rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH => e + Puppet.debug "Unable to connect to Elasticsearch instance (#{@instance_server}:#{@instance_port}): #{e.message}" + false + end + end + rescue Timeout::Error + false + end + end + end +end + diff --git a/3rdparty/modules/elasticsearch/log/2015-03-13_19_24_02/sut.log b/3rdparty/modules/elasticsearch/log/2015-03-13_19_24_02/sut.log new file mode 100644 index 000000000..5a22630fe --- /dev/null +++ b/3rdparty/modules/elasticsearch/log/2015-03-13_19_24_02/sut.log @@ -0,0 +1,2 @@ +2015-03-13 19:25:37 [+] docker el-6-x86_64 centos-6-x64 +2015-03-13 20:02:34 [-] docker el-6-x86_64 centos-6-x64 diff --git a/3rdparty/modules/elasticsearch/log/2015-03-14_18_41_25/sut.log b/3rdparty/modules/elasticsearch/log/2015-03-14_18_41_25/sut.log new file mode 100644 index 000000000..1ab900fbc --- /dev/null +++ b/3rdparty/modules/elasticsearch/log/2015-03-14_18_41_25/sut.log @@ -0,0 +1,2 @@ +2015-03-14 18:46:32 [+] docker ubuntu-14.04-amd64 ubuntu-14-04 +2015-03-14 19:35:05 [-] docker ubuntu-14.04-amd64 ubuntu-14-04 diff --git a/3rdparty/modules/elasticsearch/log/2015-03-16_02_10_40/sut.log b/3rdparty/modules/elasticsearch/log/2015-03-16_02_10_40/sut.log new file mode 100644 index 000000000..2ee9d536a --- /dev/null +++ b/3rdparty/modules/elasticsearch/log/2015-03-16_02_10_40/sut.log @@ -0,0 +1,2 @@ +2015-03-16 02:10:42 [+] docker el-6-x86_64 centos-6-x64 +2015-03-16 02:47:36 [-] docker el-6-x86_64 centos-6-x64 diff --git a/3rdparty/modules/elasticsearch/log/2015-03-16_23_30_55/sut.log b/3rdparty/modules/elasticsearch/log/2015-03-16_23_30_55/sut.log new file mode 100644 index 000000000..95631af6f --- /dev/null +++ b/3rdparty/modules/elasticsearch/log/2015-03-16_23_30_55/sut.log @@ -0,0 +1,2 @@ +2015-03-16 23:30:56 [+] docker el-6-x86_64 centos-6-x64 +2015-03-17 00:08:30 [-] docker el-6-x86_64 centos-6-x64 diff --git a/3rdparty/modules/elasticsearch/manifests/config.pp b/3rdparty/modules/elasticsearch/manifests/config.pp new file mode 100644 index 000000000..3b69e5b05 --- /dev/null +++ b/3rdparty/modules/elasticsearch/manifests/config.pp @@ -0,0 +1,124 @@ +# == Class: elasticsearch::config +# +# This class exists to coordinate all configuration related actions, +# functionality and logical units in a central place. +# +# +# === Parameters +# +# This class does not provide any parameters. +# +# +# === Examples +# +# This class may be imported by other classes to use its functionality: +# class { 'elasticsearch::config': } +# +# It is not intended to be used directly by external resources like node +# definitions or other modules. +# +# +# === Authors +# +# * Richard Pijnenburg +# +class elasticsearch::config { + + #### Configuration + + File { + owner => $elasticsearch::elasticsearch_user, + group => $elasticsearch::elasticsearch_group + } + + Exec { + path => [ '/bin', '/usr/bin', '/usr/local/bin' ], + cwd => '/', + } + + if ( $elasticsearch::ensure == 'present' ) { + + $notify_service = $elasticsearch::restart_on_change ? { + true => Class['elasticsearch::service'], + false => undef, + } + + file { $elasticsearch::configdir: + ensure => directory, + mode => '0644' + } + + file { $elasticsearch::params::logdir: + ensure => 'directory', + group => undef, + mode => '0644', + recurse => true + } + + file { $elasticsearch::params::homedir: + ensure => 'directory' + } + + file { "${elasticsearch::params::homedir}/bin": + ensure => 'directory', + recurse => true, + mode => '0755' + } + + file { $elasticsearch::plugindir: + ensure => 'directory', + recurse => true + } + + file { $elasticsearch::datadir: + ensure => 'directory' + } + + file { "${elasticsearch::homedir}/lib": + ensure => 'directory', + recurse => true + } + + if $elasticsearch::params::pid_dir { + file { $elasticsearch::params::pid_dir: + ensure => 'directory', + group => undef, + recurse => true + } + } + + exec { 'mkdir_templates_elasticsearch': + command => "mkdir -p ${elasticsearch::configdir}/templates_import", + creates => "${elasticsearch::configdir}/templates_import", + } + + file { "${elasticsearch::configdir}/templates_import": + ensure => 'directory', + mode => '0644', + require => [ Exec['mkdir_templates_elasticsearch'] ] + } + + # Removal of files that are provided with the package which we don't use + file { '/etc/init.d/elasticsearch': + ensure => 'absent' + } + file { '/usr/lib/systemd/system/elasticsearch.service': + ensure => 'absent' + } + + file { "${elasticsearch::params::defaults_location}/elasticsearch": + ensure => 'absent' + } + + file { '/etc/elasticsearch/elasticsearch.yml': + ensure => 'absent' + } + file { '/etc/elasticsearch/logging.yml': + ensure => 'absent' + } + + } elsif ( $elasticsearch::ensure == 'absent' ) { + # don't remove anything for now + } + +} diff --git a/3rdparty/modules/elasticsearch/manifests/init.pp b/3rdparty/modules/elasticsearch/manifests/init.pp new file mode 100644 index 000000000..be92dd5db --- /dev/null +++ b/3rdparty/modules/elasticsearch/manifests/init.pp @@ -0,0 +1,385 @@ +# == Class: elasticsearch +# +# This class is able to install or remove elasticsearch on a node. +# It manages the status of the related service. +# +# === Parameters +# +# [*ensure*] +# String. Controls if the managed resources shall be present or +# absent. If set to absent: +# * The managed software packages are being uninstalled. +# * Any traces of the packages will be purged as good as possible. This may +# include existing configuration files. The exact behavior is provider +# dependent. Q.v.: +# * Puppet type reference: {package, "purgeable"}[http://j.mp/xbxmNP] +# * {Puppet's package provider source code}[http://j.mp/wtVCaL] +# * System modifications (if any) will be reverted as good as possible +# (e.g. removal of created users, services, changed log settings, ...). +# * This is thus destructive and should be used with care. +# Defaults to present. +# +# [*autoupgrade*] +# Boolean. If set to true, any managed package gets upgraded +# on each Puppet run when the package provider is able to find a newer +# version than the present one. The exact behavior is provider dependent. +# Q.v.: +# * Puppet type reference: {package, "upgradeable"}[http://j.mp/xbxmNP] +# * {Puppet's package provider source code}[http://j.mp/wtVCaL] +# Defaults to false. +# +# [*status*] +# String to define the status of the service. Possible values: +# * enabled: Service is running and will be started at boot time. +# * disabled: Service is stopped and will not be started at boot +# time. +# * running: Service is running but will not be started at boot time. +# You can use this to start a service on the first Puppet run instead of +# the system startup. +# * unmanaged: Service will not be started at boot time and Puppet +# does not care whether the service is running or not. For example, this may +# be useful if a cluster management software is used to decide when to start +# the service plus assuring it is running on the desired node. +# Defaults to enabled. The singular form ("service") is used for the +# sake of convenience. Of course, the defined status affects all services if +# more than one is managed (see service.pp to check if this is the +# case). +# +# [*version*] +# String to set the specific version you want to install. +# Defaults to false. +# +# [*restart_on_change*] +# Boolean that determines if the application should be automatically restarted +# whenever the configuration changes. Disabling automatic restarts on config +# changes may be desired in an environment where you need to ensure restarts +# occur in a controlled/rolling manner rather than during a Puppet run. +# +# Defaults to true, which will restart the application on any config +# change. Setting to false disables the automatic restart. +# +# [*configdir*] +# Path to directory containing the elasticsearch configuration. +# Use this setting if your packages deviate from the norm (/etc/elasticsearch) +# +# [*plugindir*] +# Path to directory containing the elasticsearch plugins +# Use this setting if your packages deviate from the norm (/usr/share/elasticsearch/plugins) +# +# [*plugintool*] +# Path to directory containing the elasticsearch plugin installation script +# Use this setting if your packages deviate from the norm (/usr/share/elasticsearch/bin/plugin) +# +# [*package_url*] +# Url to the package to download. +# This can be a http,https or ftp resource for remote packages +# puppet:// resource or file:/ for local packages +# +# [*package_provider*] +# Way to install the packages, currently only packages are supported. +# +# [*package_dir*] +# Directory where the packages are downloaded to +# +# [*package_name*] +# Name of the package to install +# +# [*purge_package_dir*] +# Purge package directory on removal +# +# [*package_dl_timeout*] +# For http,https and ftp downloads you can set howlong the exec resource may take. +# Defaults to: 600 seconds +# +# [*elasticsearch_user*] +# The user Elasticsearch should run as. This also sets the file rights. +# +# [*elasticsearch_group*] +# The group Elasticsearch should run as. This also sets the file rights +# +# [*purge_configdir*] +# Purge the config directory for any unmanaged files +# +# [*service_provider*] +# Service provider to use. By Default when a single service provider is possibe that one is selected. +# +# [*init_defaults*] +# Defaults file content in hash representation +# +# [*init_defaults_file*] +# Defaults file as puppet resource +# +# [*init_template*] +# Service file as a template +# +# [*config*] +# Elasticsearch configuration hash +# +# [*datadir*] +# Allows you to set the data directory of Elasticsearch +# +# [*java_install*] +# Install java which is required for Elasticsearch. +# Defaults to: false +# +# [*java_package*] +# If you like to install a custom java package, put the name here. +# +# [*manage_repo*] +# Enable repo management by enabling our official repositories +# +# [*repo_version*] +# Our repositories are versioned per major version (0.90, 1.0) select here which version you want +# +# [*logging_config*] +# Hash representation of information you want in the logging.yml file +# +# [*logging_file*] +# Instead of a hash you can supply a puppet:// file source for the logging.yml file +# +# [*logging_template*] +# Use a custom logging template - just supply the reative path ie ${module}/elasticsearch/logging.yml.erb +# +# [*default_logging_level*] +# Default logging level for Elasticsearch. +# Defaults to: INFO +# +# [*repo_stage*] +# Use stdlib stage setup for managing the repo, instead of anchoring +# +# [*instances*] +# Define instances via a hash. This is mainly used with Hiera's auto binding +# Defaults to: undef +# +# [*instances_hiera_merge*] +# Enable Hiera's merging function for the instances +# Defaults to: false +# +# [*plugins*] +# Define plugins via a hash. This is mainly used with Hiera's auto binding +# Defaults to: undef +# +# [*plugins_hiera_merge*] +# Enable Hiera's merging function for the plugins +# Defaults to: false +# +# The default values for the parameters are set in elasticsearch::params. Have +# a look at the corresponding params.pp manifest file if you need more +# technical information about them. +# +# === Examples +# +# * Installation, make sure service is running and will be started at boot time: +# class { 'elasticsearch': } +# +# * Removal/decommissioning: +# class { 'elasticsearch': +# ensure => 'absent', +# } +# +# * Install everything but disable service(s) afterwards +# class { 'elasticsearch': +# status => 'disabled', +# } +# +# +# === Authors +# +# * Richard Pijnenburg +# +class elasticsearch( + $ensure = $elasticsearch::params::ensure, + $status = $elasticsearch::params::status, + $restart_on_change = $elasticsearch::params::restart_on_change, + $autoupgrade = $elasticsearch::params::autoupgrade, + $version = false, + $package_provider = 'package', + $package_url = undef, + $package_dir = $elasticsearch::params::package_dir, + $package_name = $elasticsearch::params::package, + $purge_package_dir = $elasticsearch::params::purge_package_dir, + $package_dl_timeout = $elasticsearch::params::package_dl_timeout, + $elasticsearch_user = $elasticsearch::params::elasticsearch_user, + $elasticsearch_group = $elasticsearch::params::elasticsearch_group, + $configdir = $elasticsearch::params::configdir, + $purge_configdir = $elasticsearch::params::purge_configdir, + $service_provider = 'init', + $init_defaults = undef, + $init_defaults_file = undef, + $init_template = undef, + $config = undef, + $datadir = $elasticsearch::params::datadir, + $plugindir = $elasticsearch::params::plugindir, + $plugintool = $elasticsearch::params::plugintool, + $java_install = false, + $java_package = undef, + $manage_repo = false, + $repo_version = undef, + $logging_file = undef, + $logging_config = undef, + $logging_template = undef, + $default_logging_level = $elasticsearch::params::default_logging_level, + $repo_stage = false, + $instances = undef, + $instances_hiera_merge = false, + $plugins = undef, + $plugins_hiera_merge = false +) inherits elasticsearch::params { + + anchor {'elasticsearch::begin': } + anchor {'elasticsearch::end': } + + + #### Validate parameters + + # ensure + if ! ($ensure in [ 'present', 'absent' ]) { + fail("\"${ensure}\" is not a valid ensure parameter value") + } + + # autoupgrade + validate_bool($autoupgrade) + + # service status + if ! ($status in [ 'enabled', 'disabled', 'running', 'unmanaged' ]) { + fail("\"${status}\" is not a valid status parameter value") + } + + # restart on change + validate_bool($restart_on_change) + + # purge conf dir + validate_bool($purge_configdir) + + if is_array($elasticsearch::params::service_providers) { + # Verify the service provider given is in the array + if ! ($service_provider in $elasticsearch::params::service_providers) { + fail("\"${service_provider}\" is not a valid provider for \"${::operatingsystem}\"") + } + $real_service_provider = $service_provider + } else { + # There is only one option so simply set it + $real_service_provider = $elasticsearch::params::service_providers + } + + if ($package_url != undef and $version != false) { + fail('Unable to set the version number when using package_url option.') + } + + if $ensure == 'present' { + # validate config hash + if ($config != undef) { + validate_hash($config) + } + } + + # java install validation + validate_bool($java_install) + + validate_bool($manage_repo) + + if ($manage_repo == true) { + if $repo_version == undef { + fail('Please fill in a repository version at $repo_version') + } else { + validate_string($repo_version) + } + } + + #### Manage actions + + # package(s) + class { 'elasticsearch::package': } + + # configuration + class { 'elasticsearch::config': } + + # Hiera support for instances + validate_bool($instances_hiera_merge) + + if $instances_hiera_merge == true { + $x_instances = hiera_hash('elasticsearch::instances', $::elasticsearch::instances) + } else { + $x_instances = $instances + } + + if $x_instances { + validate_hash($x_instances) + create_resources('elasticsearch::instance', $x_instances) + } + + # Hiera support for plugins + validate_bool($plugins_hiera_merge) + + if $plugins_hiera_merge == true { + $x_plugins = hiera_hash('elasticsearch::plugins', $::elasticsearch::plugins) + } else { + $x_plugins = $plugins + } + + if $x_plugins { + validate_hash($x_plugins) + create_resources('elasticsearch::plugin', $x_plugins) + } + + + if $java_install == true { + # Install java + class { '::java': + package => $java_package, + distribution => 'jre' + } + + # ensure we first java java and then manage the service + Anchor['elasticsearch::begin'] + -> Class['::java'] + -> Class['elasticsearch::package'] + } + + if ($manage_repo == true) { + + if ($repo_stage == false) { + # use anchor for ordering + + # Set up repositories + class { 'elasticsearch::repo': } + + # Ensure that we set up the repositories before trying to install + # the packages + Anchor['elasticsearch::begin'] + -> Class['elasticsearch::repo'] + -> Class['elasticsearch::package'] + + } else { + # use staging for ordering + + if !(defined(Stage[$repo_stage])) { + stage { $repo_stage: before => Stage['main'] } + } + + class { 'elasticsearch::repo': + stage => $repo_stage + } + } + } + + #### Manage relationships + + if $ensure == 'present' { + + # we need the software before configuring it + Anchor['elasticsearch::begin'] + -> Class['elasticsearch::package'] + -> Class['elasticsearch::config'] + -> Elasticsearch::Instance <| |> + -> Elasticsearch::Template <| |> + } else { + + # make sure all services are getting stopped before software removal + Elasticsearch::Instance <| |> + -> Class['elasticsearch::config'] + -> Class['elasticsearch::package'] + + } + +} diff --git a/3rdparty/modules/elasticsearch/manifests/instance.pp b/3rdparty/modules/elasticsearch/manifests/instance.pp new file mode 100644 index 000000000..93ab6e5bd --- /dev/null +++ b/3rdparty/modules/elasticsearch/manifests/instance.pp @@ -0,0 +1,296 @@ +# == Define: elasticsearch::instance +# +# This define allows you to create or remove an elasticsearch instance +# +# === Parameters +# +# [*ensure*] +# String. Controls if the managed resources shall be present or +# absent. If set to absent: +# * The managed software packages are being uninstalled. +# * Any traces of the packages will be purged as good as possible. This may +# include existing configuration files. The exact behavior is provider +# dependent. Q.v.: +# * Puppet type reference: {package, "purgeable"}[http://j.mp/xbxmNP] +# * {Puppet's package provider source code}[http://j.mp/wtVCaL] +# * System modifications (if any) will be reverted as good as possible +# (e.g. removal of created users, services, changed log settings, ...). +# * This is thus destructive and should be used with care. +# Defaults to present. +# +# [*status*] +# String to define the status of the service. Possible values: +# * enabled: Service is running and will be started at boot time. +# * disabled: Service is stopped and will not be started at boot +# time. +# * running: Service is running but will not be started at boot time. +# You can use this to start a service on the first Puppet run instead of +# the system startup. +# * unmanaged: Service will not be started at boot time and Puppet +# does not care whether the service is running or not. For example, this may +# be useful if a cluster management software is used to decide when to start +# the service plus assuring it is running on the desired node. +# Defaults to enabled. The singular form ("service") is used for the +# sake of convenience. Of course, the defined status affects all services if +# more than one is managed (see service.pp to check if this is the +# case). +# +# [*config*] +# Elasticsearch configuration hash +# +# [*configdir*] +# Path to directory containing the elasticsearch configuration. +# Use this setting if your packages deviate from the norm (/etc/elasticsearch) +# +# [*datadir*] +# Allows you to set the data directory of Elasticsearch +# +# [*logging_file*] +# Instead of a hash you can supply a puppet:// file source for the logging.yml file +# +# [*logging_config*] +# Hash representation of information you want in the logging.yml file +# +# [*logging_template*] +# Use a custom logging template - just supply the reative path ie ${module}/elasticsearch/logging.yml.erb +# +# [*logging_level*] +# Default logging level for Elasticsearch. +# Defaults to: INFO +# +# [*init_defaults*] +# Defaults file content in hash representation +# +# === Authors +# +# * Richard Pijnenburg +# +define elasticsearch::instance( + $ensure = $elasticsearch::ensure, + $status = $elasticsearch::status, + $config = undef, + $configdir = undef, + $datadir = undef, + $logging_file = undef, + $logging_config = undef, + $logging_template = undef, + $logging_level = $elasticsearch::default_logging_level, + $init_defaults = undef +) { + + require elasticsearch::params + + File { + owner => $elasticsearch::elasticsearch_user, + group => $elasticsearch::elasticsearch_group + } + + Exec { + path => [ '/bin', '/usr/bin', '/usr/local/bin' ], + cwd => '/', + } + + # ensure + if ! ($ensure in [ 'present', 'absent' ]) { + fail("\"${ensure}\" is not a valid ensure parameter value") + } + + $notify_service = $elasticsearch::restart_on_change ? { + true => Elasticsearch::Service[$name], + false => undef, + } + + # Instance config directory + if ($configdir == undef) { + $instance_configdir = "${elasticsearch::configdir}/${name}" + } else { + $instance_configdir = $configdir + } + + if ($ensure == 'present') { + + # Configuration hash + if ($config == undef) { + $instance_config = {} + } else { + validate_hash($config) + $instance_config = $config + } + + if(has_key($instance_config, 'node.name')) { + $instance_node_name = {} + } elsif(has_key($instance_config,'node')) { + if(has_key($instance_config['node'], 'name')) { + $instance_node_name = {} + } else { + $instance_node_name = { 'node.name' => "${::hostname}-${name}" } + } + } else { + $instance_node_name = { 'node.name' => "${::hostname}-${name}" } + } + + # String or array for data dir(s) + if ($datadir == undef) { + if (is_array($elasticsearch::datadir)) { + $instance_datadir = array_suffix($elasticsearch::datadir, "/${name}") + } else { + $instance_datadir = "${elasticsearch::datadir}/${name}" + } + } else { + $instance_datadir = $datadir + } + + # Logging file or hash + if ($logging_file != undef) { + $logging_source = $logging_file + $logging_content = undef + } elsif ($elasticsearch::logging_file != undef) { + $logging_source = $elasticsearch::logging_file + $logging_content = undef + } else { + + if(is_hash($elasticsearch::logging_config)) { + $main_logging_config = $elasticsearch::logging_config + } else { + $main_logging_config = { } + } + + if(is_hash($logging_config)) { + $instance_logging_config = $logging_config + } else { + $instance_logging_config = { } + } + $logging_hash = merge($elasticsearch::params::logging_defaults, $main_logging_config, $instance_logging_config) + if ($logging_template != undef ) { + $logging_content = template($logging_template) + } elsif ($elasticsearch::logging_template != undef) { + $logging_content = template($elasticsearch::logging_template) + } else { + $logging_content = template("${module_name}/etc/elasticsearch/logging.yml.erb") + } + $logging_source = undef + } + + if ($elasticsearch::config != undef) { + $main_config = $elasticsearch::config + } else { + $main_config = { } + } + + if(has_key($instance_config, 'path.data')) { + $instance_datadir_config = { 'path.data' => $instance_datadir } + } elsif(has_key($instance_config, 'path')) { + if(has_key($instance_config['path'], 'data')) { + $instance_datadir_config = { 'path' => { 'data' => $instance_datadir } } + } else { + $instance_datadir_config = { 'path.data' => $instance_datadir } + } + } else { + $instance_datadir_config = { 'path.data' => $instance_datadir } + } + + if(is_array($instance_datadir)) { + $dirs = join($instance_datadir, ' ') + } else { + $dirs = $instance_datadir + } + + exec { "mkdir_datadir_elasticsearch_${name}": + command => "mkdir -p ${dirs}", + creates => $instance_datadir, + require => Class['elasticsearch::package'], + before => Elasticsearch::Service[$name] + } + + file { $instance_datadir: + ensure => 'directory', + owner => $elasticsearch::elasticsearch_user, + group => undef, + mode => '0644', + require => [ Exec["mkdir_datadir_elasticsearch_${name}"], Class['elasticsearch::package'] ], + before => Elasticsearch::Service[$name] + } + + exec { "mkdir_configdir_elasticsearch_${name}": + command => "mkdir -p ${instance_configdir}", + creates => $elasticsearch::configdir, + require => Class['elasticsearch::package'], + before => Elasticsearch::Service[$name] + } + + file { $instance_configdir: + ensure => 'directory', + mode => '0644', + purge => $elasticsearch::purge_configdir, + force => $elasticsearch::purge_configdir, + require => [ Exec["mkdir_configdir_elasticsearch_${name}"], Class['elasticsearch::package'] ], + before => Elasticsearch::Service[$name] + } + + file { "${instance_configdir}/logging.yml": + ensure => file, + content => $logging_content, + source => $logging_source, + mode => '0644', + notify => $notify_service, + require => Class['elasticsearch::package'], + before => Elasticsearch::Service[$name] + } + + # build up new config + $instance_conf = merge($main_config, $instance_node_name, $instance_config, $instance_datadir_config) + + # defaults file content + if (is_hash($elasticsearch::init_defaults)) { + $global_init_defaults = $elasticsearch::init_defaults + } else { + $global_init_defaults = { } + } + + $instance_init_defaults_main = { 'CONF_DIR' => $instance_configdir, 'CONF_FILE' => "${instance_configdir}/elasticsearch.yml", 'LOG_DIR' => "/var/log/elasticsearch/${name}", 'ES_HOME' => '/usr/share/elasticsearch' } + + if (is_hash($init_defaults)) { + $instance_init_defaults = $init_defaults + } else { + $instance_init_defaults = { } + } + $init_defaults_new = merge($global_init_defaults, $instance_init_defaults_main, $instance_init_defaults ) + + $user = $elasticsearch::elasticsearch_user + $group = $elasticsearch::elasticsearch_group + + file { "${instance_configdir}/elasticsearch.yml": + ensure => file, + content => template("${module_name}/etc/elasticsearch/elasticsearch.yml.erb"), + mode => '0644', + notify => $notify_service, + require => Class['elasticsearch::package'] + } + + $require_service = Class['elasticsearch::package'] + $before_service = undef + + } else { + + file { $instance_configdir: + ensure => 'absent', + recurse => true, + force => true, + } + + $require_service = undef + $before_service = File[$instance_configdir] + + $init_defaults_new = {} + } + + elasticsearch::service { $name: + ensure => $ensure, + status => $status, + init_defaults => $init_defaults_new, + init_template => "${module_name}/etc/init.d/${elasticsearch::params::init_template}", + require => $require_service, + before => $before_service + } + +} diff --git a/3rdparty/modules/elasticsearch/manifests/package.pp b/3rdparty/modules/elasticsearch/manifests/package.pp new file mode 100644 index 000000000..db1ff4541 --- /dev/null +++ b/3rdparty/modules/elasticsearch/manifests/package.pp @@ -0,0 +1,181 @@ +# == Class: elasticsearch::package +# +# This class exists to coordinate all software package management related +# actions, functionality and logical units in a central place. +# +# +# === Parameters +# +# This class does not provide any parameters. +# +# +# === Examples +# +# This class may be imported by other classes to use its functionality: +# class { 'elasticsearch::package': } +# +# It is not intended to be used directly by external resources like node +# definitions or other modules. +# +# +# === Authors +# +# * Richard Pijnenburg +# +class elasticsearch::package { + + Exec { + path => [ '/bin', '/usr/bin', '/usr/local/bin' ], + cwd => '/', + tries => 3, + try_sleep => 10 + } + + #### Package management + + # set params: in operation + if $elasticsearch::ensure == 'present' { + + # Check if we want to install a specific version or not + if $elasticsearch::version == false { + + $package_ensure = $elasticsearch::autoupgrade ? { + true => 'latest', + false => 'present', + } + + } else { + + # install specific version + $package_ensure = $elasticsearch::version + + } + + # action + if ($elasticsearch::package_url != undef) { + + case $elasticsearch::package_provider { + 'package': { $before = Package[$elasticsearch::package_name] } + default: { fail("software provider \"${elasticsearch::package_provider}\".") } + } + + $package_dir = $elasticsearch::package_dir + + # Create directory to place the package file + exec { 'create_package_dir_elasticsearch': + cwd => '/', + path => ['/usr/bin', '/bin'], + command => "mkdir -p ${elasticsearch::package_dir}", + creates => $elasticsearch::package_dir; + } + + file { $package_dir: + ensure => 'directory', + purge => $elasticsearch::purge_package_dir, + force => $elasticsearch::purge_package_dir, + backup => false, + require => Exec['create_package_dir_elasticsearch'], + } + + $filenameArray = split($elasticsearch::package_url, '/') + $basefilename = $filenameArray[-1] + + $sourceArray = split($elasticsearch::package_url, ':') + $protocol_type = $sourceArray[0] + + $extArray = split($basefilename, '\.') + $ext = $extArray[-1] + + $pkg_source = "${package_dir}/${basefilename}" + + case $protocol_type { + + puppet: { + + file { $pkg_source: + ensure => present, + source => $elasticsearch::package_url, + require => File[$package_dir], + backup => false, + before => $before + } + + } + ftp, https, http: { + + exec { 'download_package_elasticsearch': + command => "${elasticsearch::params::download_tool} ${pkg_source} ${elasticsearch::package_url} 2> /dev/null", + creates => $pkg_source, + timeout => $elasticsearch::package_dl_timeout, + require => File[$package_dir], + before => $before + } + + } + file: { + + $source_path = $sourceArray[1] + file { $pkg_source: + ensure => present, + source => $source_path, + require => File[$package_dir], + backup => false, + before => $before + } + + } + default: { + fail("Protocol must be puppet, file, http, https, or ftp. You have given \"${protocol_type}\"") + } + } + + if ($elasticsearch::package_provider == 'package') { + + case $ext { + 'deb': { $pkg_provider = 'dpkg' } + 'rpm': { $pkg_provider = 'rpm' } + default: { fail("Unknown file extention \"${ext}\".") } + } + + } + + } else { + $pkg_source = undef + $pkg_provider = undef + } + + # Package removal + } else { + + $pkg_source = undef + if ($::operatingsystem == 'OpenSuSE') { + $pkg_provider = 'rpm' + } else { + $pkg_provider = undef + } + $package_ensure = 'absent' + + $package_dir = $elasticsearch::package_dir + + file { $package_dir: + ensure => 'absent', + purge => true, + force => true, + backup => false + } + + } + + if ($elasticsearch::package_provider == 'package') { + + package { $elasticsearch::package_name: + ensure => $package_ensure, + source => $pkg_source, + provider => $pkg_provider, + } + + } else { + fail("\"${elasticsearch::package_provider}\" is not supported") + } + +} diff --git a/3rdparty/modules/elasticsearch/manifests/params.pp b/3rdparty/modules/elasticsearch/manifests/params.pp new file mode 100644 index 000000000..f9041d0b9 --- /dev/null +++ b/3rdparty/modules/elasticsearch/manifests/params.pp @@ -0,0 +1,190 @@ +# == Class: elasticsearch::params +# +# This class exists to +# 1. Declutter the default value assignment for class parameters. +# 2. Manage internally used module variables in a central place. +# +# Therefore, many operating system dependent differences (names, paths, ...) +# are addressed in here. +# +# +# === Parameters +# +# This class does not provide any parameters. +# +# +# === Examples +# +# This class is not intended to be used directly. +# +# +# === Links +# +# * {Puppet Docs: Using Parameterized Classes}[http://j.mp/nVpyWY] +# +# +# === Authors +# +# * Richard Pijnenburg +# +class elasticsearch::params { + + #### Default values for the parameters of the main module class, init.pp + + # ensure + $ensure = 'present' + + # autoupgrade + $autoupgrade = false + + # service status + $status = 'enabled' + + # restart on configuration change? + $restart_on_change = true + + # Purge configuration directory + $purge_configdir = false + + $purge_package_dir = false + + # package download timeout + $package_dl_timeout = 600 # 300 seconds is default of puppet + + $default_logging_level = 'INFO' + + $logging_defaults = { + 'action' => 'DEBUG', + 'com.amazonaws' => 'WARN', + 'index.search.slowlog' => 'TRACE, index_search_slow_log_file', + 'index.indexing.slowlog' => 'TRACE, index_indexing_slow_log_file' + } + + #### Internal module values + + # User and Group for the files and user to run the service as. + case $::kernel { + 'Linux': { + $elasticsearch_user = 'elasticsearch' + $elasticsearch_group = 'elasticsearch' + } + 'Darwin': { + $elasticsearch_user = 'elasticsearch' + $elasticsearch_group = 'elasticsearch' + } + default: { + fail("\"${module_name}\" provides no user/group default value + for \"${::kernel}\"") + } + } + + # Download tool + + case $::kernel { + 'Linux': { + $download_tool = 'wget --no-check-certificate -O' + } + 'Darwin': { + $download_tool = 'curl --insecure -o' + } + default: { + fail("\"${module_name}\" provides no download tool default value + for \"${::kernel}\"") + } + } + + # Different path definitions + case $::kernel { + 'Linux': { + $configdir = '/etc/elasticsearch' + $logdir = '/var/log/elasticsearch' + $package_dir = '/opt/elasticsearch/swdl' + $installpath = '/opt/elasticsearch' + $homedir = '/usr/share/elasticsearch' + $plugindir = "${homedir}/plugins" + $plugintool = "${homedir}/bin/plugin" + $datadir = '/usr/share/elasticsearch/data' + } + default: { + fail("\"${module_name}\" provides no config directory default value + for \"${::kernel}\"") + } + } + + # packages + case $::operatingsystem { + 'RedHat', 'CentOS', 'Fedora', 'Scientific', 'Amazon', 'OracleLinux', 'SLC': { + # main application + $package = [ 'elasticsearch' ] + } + 'Debian', 'Ubuntu': { + # main application + $package = [ 'elasticsearch' ] + } + 'OpenSuSE': { + $package = [ 'elasticsearch' ] + } + default: { + fail("\"${module_name}\" provides no package default value + for \"${::operatingsystem}\"") + } + } + + # service parameters + case $::operatingsystem { + 'RedHat', 'CentOS', 'Fedora', 'Scientific', 'Amazon', 'OracleLinux', 'SLC': { + + case $::operatingsystemmajrelease { + '7': { + $init_template = 'elasticsearch.systemd.erb' + $service_providers = 'systemd' + } + default: { + $init_template = 'elasticsearch.RedHat.erb' + $service_providers = [ 'init' ] + } + } + + $service_name = 'elasticsearch' + $service_hasrestart = true + $service_hasstatus = true + $service_pattern = $service_name + $defaults_location = '/etc/sysconfig' + $pid_dir = '/var/run/elasticsearch' + } + 'Debian', 'Ubuntu': { + $service_name = 'elasticsearch' + $service_hasrestart = true + $service_hasstatus = true + $service_pattern = $service_name + $service_providers = 'init' + $defaults_location = '/etc/default' + $init_template = 'elasticsearch.Debian.erb' + $pid_dir = false + } + 'Darwin': { + $service_name = 'FIXME/TODO' + $service_hasrestart = true + $service_hasstatus = true + $service_pattern = $service_name + $service_providers = 'launchd' + $defaults_location = false + $pid_dir = false + } + 'OpenSuSE': { + $service_name = 'elasticsearch' + $service_hasrestart = true + $service_hasstatus = true + $service_pattern = $service_name + $service_providers = 'systemd' + $defaults_location = '/etc/sysconfig' + $init_template = 'elasticsearch.systemd.erb' + $pid_dir = '/var/run/elasticsearch' + } + default: { + fail("\"${module_name}\" provides no service parameters + for \"${::operatingsystem}\"") + } + } + +} diff --git a/3rdparty/modules/elasticsearch/manifests/plugin.pp b/3rdparty/modules/elasticsearch/manifests/plugin.pp new file mode 100644 index 000000000..f49a6bd3e --- /dev/null +++ b/3rdparty/modules/elasticsearch/manifests/plugin.pp @@ -0,0 +1,126 @@ +# == Define: elasticsearch::plugin +# +# This define allows you to install arbitrary Elasticsearch plugins +# either by using the default repositories or by specifying an URL +# +# All default values are defined in the elasticsearch::params class. +# +# +# === Parameters +# +# [*module_dir*] +# Directory name where the module will be installed +# Value type is string +# Default value: None +# This variable is required +# +# [*ensure*] +# Whether the plugin will be installed or removed. +# Set to 'absent' to ensure a plugin is not installed +# Value type is string +# Default value: present +# This variable is optional +# +# [*url*] +# Specify an URL where to download the plugin from. +# Value type is string +# Default value: None +# This variable is optional +# +# [*proxy_host*] +# Proxy host to use when installing the plugin +# Value type is string +# Default value: None +# This variable is optional +# +# [*proxy_port*] +# Proxy port to use when installing the plugin +# Value type is number +# Default value: None +# This variable is optional +# +# [*instances*] +# Specify all the instances related +# value type is string or array +# +# === Examples +# +# # From official repository +# elasticsearch::plugin{'mobz/elasticsearch-head': module_dir => 'head'} +# +# # From custom url +# elasticsearch::plugin{ 'elasticsearch-jetty': +# module_dir => 'elasticsearch-jetty', +# url => 'https://oss-es-plugins.s3.amazonaws.com/elasticsearch-jetty/elasticsearch-jetty-0.90.0.zip', +# } +# +# === Authors +# +# * Matteo Sessa +# * Dennis Konert +# * Richard Pijnenburg +# +define elasticsearch::plugin( + $module_dir, + $instances, + $ensure = 'present', + $url = '', + $proxy_host = undef, + $proxy_port = undef, +) { + + include elasticsearch + + Exec { + path => [ '/bin', '/usr/bin', '/usr/local/bin' ], + cwd => '/', + user => $elasticsearch::elasticsearch_user, + tries => 6, + try_sleep => 10 + } + + $notify_service = $elasticsearch::restart_on_change ? { + false => undef, + default => Elasticsearch::Service[$instances], + } + + if ($module_dir != '') { + validate_string($module_dir) + } else { + fail("module_dir undefined for plugin ${name}") + } + + if ($proxy_host != undef and $proxy_port != undef) { + $proxy = " -DproxyPort=${proxy_port} -DproxyHost=${proxy_host}" + } else { + $proxy = '' + } + + if ($url != '') { + validate_string($url) + $install_cmd = "${elasticsearch::plugintool}${proxy} -install ${name} -url ${url}" + $exec_rets = [0,1] + } else { + $install_cmd = "${elasticsearch::plugintool}${proxy} -install ${name}" + $exec_rets = [0,] + } + + case $ensure { + 'installed', 'present': { + exec {"install_plugin_${name}": + command => $install_cmd, + creates => "${elasticsearch::plugindir}/${module_dir}", + returns => $exec_rets, + notify => $notify_service, + require => File[$elasticsearch::plugindir] + } + } + default: { + exec {"remove_plugin_${name}": + command => "${elasticsearch::plugintool} --remove ${module_dir}", + onlyif => "test -d ${elasticsearch::plugindir}/${module_dir}", + notify => $notify_service, + } + } + } +} diff --git a/3rdparty/modules/elasticsearch/manifests/python.pp b/3rdparty/modules/elasticsearch/manifests/python.pp new file mode 100644 index 000000000..fee783a76 --- /dev/null +++ b/3rdparty/modules/elasticsearch/manifests/python.pp @@ -0,0 +1,70 @@ +# == Define: elasticsearch::python +# +# there are many python bindings for elasticsearch. This provides all +# the ones we know about http://www.elasticsearch.org/guide/clients/ +# +# === Parameters +# +# [*ensure*] +# String. Controls if the managed resources shall be present or +# absent. If set to absent: +# * The managed software packages are being uninstalled. +# * Any traces of the packages will be purged as good as possible. This may +# include existing configuration files. The exact behavior is provider +# dependent. Q.v.: +# * Puppet type reference: {package, "purgeable"}[http://j.mp/xbxmNP] +# * {Puppet's package provider source code}[http://j.mp/wtVCaL] +# * System modifications (if any) will be reverted as good as possible +# (e.g. removal of created users, services, changed log settings, ...). +# * This is thus destructive and should be used with care. +# Defaults to present. +# +# === Examples +# +# elasticsearch::python { 'pyes':; } +# +# === Authors +# +# * Richard Pijnenburg +# +define elasticsearch::python ( + $ensure = 'present' +) { + + if ! ($ensure in [ 'present', 'absent' ]) { + fail("\"${ensure}\" is not a valid ensure parameter value") + } + + # make sure the package name is valid and setup the provider as + # necessary + case $name { + 'pyes': { + $provider = 'pip' + } + 'rawes': { + $provider = 'pip' + } + 'pyelasticsearch': { + $provider = 'pip' + } + 'ESClient': { + $provider = 'pip' + } + 'elasticutils': { + $provider = 'pip' + } + 'elasticsearch': { + $provider = 'pip' + } + default: { + fail("unknown python binding package '${name}'") + } + } + + package { "python_${name}": + ensure => $ensure, + name => $name, + provider => $provider, + } + +} diff --git a/3rdparty/modules/elasticsearch/manifests/repo.pp b/3rdparty/modules/elasticsearch/manifests/repo.pp new file mode 100644 index 000000000..326652d99 --- /dev/null +++ b/3rdparty/modules/elasticsearch/manifests/repo.pp @@ -0,0 +1,78 @@ +# == Class: elasticsearch::repo +# +# This class exists to install and manage yum and apt repositories +# that contain elasticsearch official elasticsearch packages +# +# +# === Parameters +# +# This class does not provide any parameters. +# +# +# === Examples +# +# This class may be imported by other classes to use its functionality: +# class { 'elasticsearch::repo': } +# +# It is not intended to be used directly by external resources like node +# definitions or other modules. +# +# +# === Authors +# +# * Phil Fenstermacher +# * Richard Pijnenburg +# +class elasticsearch::repo { + + Exec { + path => [ '/bin', '/usr/bin', '/usr/local/bin' ], + cwd => '/', + } + + case $::osfamily { + 'Debian': { + if !defined(Class['apt']) { + class { 'apt': } + } + + apt::source { 'elasticsearch': + location => "http://packages.elasticsearch.org/elasticsearch/${elasticsearch::repo_version}/debian", + release => 'stable', + repos => 'main', + key => 'D88E42B4', + key_source => 'http://packages.elasticsearch.org/GPG-KEY-elasticsearch', + include_src => false, + } + } + 'RedHat', 'Linux': { + yumrepo { 'elasticsearch': + descr => 'elasticsearch repo', + baseurl => "http://packages.elasticsearch.org/elasticsearch/${elasticsearch::repo_version}/centos", + gpgcheck => 1, + gpgkey => 'http://packages.elasticsearch.org/GPG-KEY-elasticsearch', + enabled => 1, + } + } + 'Suse': { + exec { 'elasticsearch_suse_import_gpg': + command => 'rpmkeys --import http://packages.elasticsearch.org/GPG-KEY-elasticsearch', + unless => 'test $(rpm -qa gpg-pubkey | grep -i "D88E42B4" | wc -l) -eq 1 ', + notify => [ Zypprepo['elasticsearch'] ] + } + + zypprepo { 'elasticsearch': + baseurl => "http://packages.elasticsearch.org/elasticsearch/${elasticsearch::repo_version}/centos", + enabled => 1, + autorefresh => 1, + name => 'elasticsearch', + gpgcheck => 1, + gpgkey => 'http://packages.elasticsearch.org/GPG-KEY-elasticsearch', + type => 'yum' + } + } + default: { + fail("\"${module_name}\" provides no repository information for OSfamily \"${::osfamily}\"") + } + } +} diff --git a/3rdparty/modules/elasticsearch/manifests/ruby.pp b/3rdparty/modules/elasticsearch/manifests/ruby.pp new file mode 100644 index 000000000..aba0bd7e5 --- /dev/null +++ b/3rdparty/modules/elasticsearch/manifests/ruby.pp @@ -0,0 +1,67 @@ +# == Define: elasticsearch::ruby +# +# there are many ruby bindings for elasticsearch. This provides all +# the ones we know about http://www.elasticsearch.org/guide/clients/ +# +# === Parameters +# +# [*ensure*] +# String. Controls if the managed resources shall be present or +# absent. If set to absent: +# * The managed software packages are being uninstalled. +# * Any traces of the packages will be purged as good as possible. This may +# include existing configuration files. The exact behavior is provider +# dependent. Q.v.: +# * Puppet type reference: {package, "purgeable"}[http://j.mp/xbxmNP] +# * {Puppet's package provider source code}[http://j.mp/wtVCaL] +# * System modifications (if any) will be reverted as good as possible +# (e.g. removal of created users, services, changed log settings, ...). +# * This is thus destructive and should be used with care. +# Defaults to present. +# +# === Examples +# +# elasticsearch::ruby { 'elasticsearch':; } +# +# === Authors +# +# * Richard Pijnenburg +# +define elasticsearch::ruby ( + $ensure = 'present' +) { + + if ! ($ensure in [ 'present', 'absent' ]) { + fail("\"${ensure}\" is not a valid ensure parameter value") + } + + # make sure the package name is valid and setup the provider as + # necessary + case $name { + 'tire': { + $provider = 'gem' + } + 'stretcher': { + $provider = 'gem' + } + 'elastic_searchable': { + $provider = 'gem' + } + 'elasticsearch': { + $provider = 'gem' + } + 'flex': { + $provider = 'gem' + } + default: { + fail("unknown ruby client package '${name}'") + } + } + + package { "ruby_${name}": + ensure => $ensure, + name => $name, + provider => $provider, + } + +} diff --git a/3rdparty/modules/elasticsearch/manifests/service.pp b/3rdparty/modules/elasticsearch/manifests/service.pp new file mode 100644 index 000000000..f80022ebc --- /dev/null +++ b/3rdparty/modules/elasticsearch/manifests/service.pp @@ -0,0 +1,91 @@ +# == Class: elasticsearch::service +# +# This class exists to coordinate all service management related actions, +# functionality and logical units in a central place. +# +# Note: "service" is the Puppet term and type for background processes +# in general and is used in a platform-independent way. E.g. "service" means +# "daemon" in relation to Unix-like systems. +# +# +# === Parameters +# +# [*ensure*] +# String. Controls if the managed resources shall be present or +# absent. If set to absent: +# * The managed software packages are being uninstalled. +# * Any traces of the packages will be purged as good as possible. This may +# include existing configuration files. The exact behavior is provider +# dependent. Q.v.: +# * Puppet type reference: {package, "purgeable"}[http://j.mp/xbxmNP] +# * {Puppet's package provider source code}[http://j.mp/wtVCaL] +# * System modifications (if any) will be reverted as good as possible +# (e.g. removal of created users, services, changed log settings, ...). +# * This is thus destructive and should be used with care. +# Defaults to present. +# +# [*status*] +# String to define the status of the service. Possible values: +# * enabled: Service is running and will be started at boot time. +# * disabled: Service is stopped and will not be started at boot +# time. +# * running: Service is running but will not be started at boot time. +# You can use this to start a service on the first Puppet run instead of +# the system startup. +# * unmanaged: Service will not be started at boot time and Puppet +# does not care whether the service is running or not. For example, this may +# be useful if a cluster management software is used to decide when to start +# the service plus assuring it is running on the desired node. +# Defaults to enabled. The singular form ("service") is used for the +# sake of convenience. Of course, the defined status affects all services if +# more than one is managed (see service.pp to check if this is the +# case). +# +# [*init_defaults*] +# Defaults file content in hash representation +# +# [*init_defaults_file*] +# Defaults file as puppet resource +# +# [*init_template*] +# Service file as a template +# +# === Authors +# +# * Richard Pijnenburg +# +define elasticsearch::service( + $ensure = $elasticsearch::ensure, + $status = $elasticsearch::status, + $init_defaults_file = undef, + $init_defaults = undef, + $init_template = undef, +) { + + case $elasticsearch::real_service_provider { + + init: { + elasticsearch::service::init { $name: + ensure => $ensure, + status => $status, + init_defaults_file => $init_defaults_file, + init_defaults => $init_defaults, + init_template => $init_template, + } + } + systemd: { + elasticsearch::service::systemd { $name: + ensure => $ensure, + status => $status, + init_defaults_file => $init_defaults_file, + init_defaults => $init_defaults, + init_template => $init_template, + } + } + default: { + fail("Unknown service provider ${elasticsearch::real_service_provider}") + } + + } + +} diff --git a/3rdparty/modules/elasticsearch/manifests/service/init.pp b/3rdparty/modules/elasticsearch/manifests/service/init.pp new file mode 100644 index 000000000..ae8806c95 --- /dev/null +++ b/3rdparty/modules/elasticsearch/manifests/service/init.pp @@ -0,0 +1,195 @@ +# == Define: elasticsearch::service::init +# +# This class exists to coordinate all service management related actions, +# functionality and logical units in a central place. +# +# Note: "service" is the Puppet term and type for background processes +# in general and is used in a platform-independent way. E.g. "service" means +# "daemon" in relation to Unix-like systems. +# +# +# === Parameters +# +# [*ensure*] +# String. Controls if the managed resources shall be present or +# absent. If set to absent: +# * The managed software packages are being uninstalled. +# * Any traces of the packages will be purged as good as possible. This may +# include existing configuration files. The exact behavior is provider +# dependent. Q.v.: +# * Puppet type reference: {package, "purgeable"}[http://j.mp/xbxmNP] +# * {Puppet's package provider source code}[http://j.mp/wtVCaL] +# * System modifications (if any) will be reverted as good as possible +# (e.g. removal of created users, services, changed log settings, ...). +# * This is thus destructive and should be used with care. +# Defaults to present. +# +# [*status*] +# String to define the status of the service. Possible values: +# * enabled: Service is running and will be started at boot time. +# * disabled: Service is stopped and will not be started at boot +# time. +# * running: Service is running but will not be started at boot time. +# You can use this to start a service on the first Puppet run instead of +# the system startup. +# * unmanaged: Service will not be started at boot time and Puppet +# does not care whether the service is running or not. For example, this may +# be useful if a cluster management software is used to decide when to start +# the service plus assuring it is running on the desired node. +# Defaults to enabled. The singular form ("service") is used for the +# sake of convenience. Of course, the defined status affects all services if +# more than one is managed (see service.pp to check if this is the +# case). +# +# [*init_defaults*] +# Defaults file content in hash representation +# +# [*init_defaults_file*] +# Defaults file as puppet resource +# +# [*init_template*] +# Service file as a template +# +# === Authors +# +# * Richard Pijnenburg +# +define elasticsearch::service::init( + $ensure = $elasticsearch::ensure, + $status = $elasticsearch::status, + $init_defaults_file = undef, + $init_defaults = undef, + $init_template = undef, +) { + + #### Service management + + # set params: in operation + if $ensure == 'present' { + + case $status { + # make sure service is currently running, start it on boot + 'enabled': { + $service_ensure = 'running' + $service_enable = true + } + # make sure service is currently stopped, do not start it on boot + 'disabled': { + $service_ensure = 'stopped' + $service_enable = false + } + # make sure service is currently running, do not start it on boot + 'running': { + $service_ensure = 'running' + $service_enable = false + } + # do not start service on boot, do not care whether currently running + # or not + 'unmanaged': { + $service_ensure = undef + $service_enable = false + } + # unknown status + # note: don't forget to update the parameter check in init.pp if you + # add a new or change an existing status. + default: { + fail("\"${status}\" is an unknown service status value") + } + } + + # set params: removal + } else { + + # make sure the service is stopped and disabled (the removal itself will be + # done by package.pp) + $service_ensure = 'stopped' + $service_enable = false + + } + + $notify_service = $elasticsearch::restart_on_change ? { + true => Service["elasticsearch-instance-${name}"], + false => undef, + } + + + if ( $status != 'unmanaged' and $ensure == 'present' ) { + + # defaults file content. Either from a hash or file + if ($init_defaults_file != undef) { + file { "${elasticsearch::params::defaults_location}/elasticsearch-${name}": + ensure => $ensure, + source => $init_defaults_file, + owner => 'root', + group => 'root', + mode => '0644', + before => Service["elasticsearch-instance-${name}"], + notify => $notify_service + } + + } elsif ($init_defaults != undef and is_hash($init_defaults) ) { + + if(has_key($init_defaults, 'ES_USER')) { + if($init_defaults['ES_USER'] != $elasticsearch::elasticsearch_user) { + fail('Found ES_USER setting for init_defaults but is not same as elasticsearch_user setting. Please use elasticsearch_user setting.') + } + } + + $init_defaults_pre_hash = { 'ES_USER' => $elasticsearch::elasticsearch_user, 'ES_GROUP' => $elasticsearch::elasticsearch_group, 'MAX_OPEN_FILES' => '65535' } + $new_init_defaults = merge($init_defaults_pre_hash, $init_defaults) + + augeas { "defaults_${name}": + incl => "${elasticsearch::params::defaults_location}/elasticsearch-${name}", + lens => 'Shellvars.lns', + changes => template("${module_name}/etc/sysconfig/defaults.erb"), + before => Service["elasticsearch-instance-${name}"], + notify => $notify_service + } + + } + + # init file from template + if ($init_template != undef) { + + file { "/etc/init.d/elasticsearch-${name}": + ensure => $ensure, + content => template($init_template), + owner => 'root', + group => 'root', + mode => '0755', + before => Service["elasticsearch-instance-${name}"], + notify => $notify_service + } + + } + + } elsif ($status != 'unmanaged') { + + file { "/etc/init.d/elasticsearch-${name}": + ensure => 'absent', + subscribe => Service["elasticsearch-instance-${name}"] + } + + file { "${elasticsearch::params::defaults_location}/elasticsearch-${name}": + ensure => 'absent', + subscribe => Service["elasticsearch-${$name}"] + } + + } + + + if ( $status != 'unmanaged') { + + # action + service { "elasticsearch-instance-${name}": + ensure => $service_ensure, + enable => $service_enable, + name => "elasticsearch-${name}", + hasstatus => $elasticsearch::params::service_hasstatus, + hasrestart => $elasticsearch::params::service_hasrestart, + pattern => $elasticsearch::params::service_pattern, + } + + } + +} diff --git a/3rdparty/modules/elasticsearch/manifests/service/systemd.pp b/3rdparty/modules/elasticsearch/manifests/service/systemd.pp new file mode 100644 index 000000000..92f216062 --- /dev/null +++ b/3rdparty/modules/elasticsearch/manifests/service/systemd.pp @@ -0,0 +1,202 @@ +# == Define: elasticsearch::service::systemd +# +# This define exists to coordinate all service management related actions, +# functionality and logical units in a central place. +# +# Note: "service" is the Puppet term and type for background processes +# in general and is used in a platform-independent way. E.g. "service" means +# "daemon" in relation to Unix-like systems. +# +# +# === Parameters +# +# [*ensure*] +# String. Controls if the managed resources shall be present or +# absent. If set to absent: +# * The managed software packages are being uninstalled. +# * Any traces of the packages will be purged as good as possible. This may +# include existing configuration files. The exact behavior is provider +# dependent. Q.v.: +# * Puppet type reference: {package, "purgeable"}[http://j.mp/xbxmNP] +# * {Puppet's package provider source code}[http://j.mp/wtVCaL] +# * System modifications (if any) will be reverted as good as possible +# (e.g. removal of created users, services, changed log settings, ...). +# * This is thus destructive and should be used with care. +# Defaults to present. +# +# [*status*] +# String to define the status of the service. Possible values: +# * enabled: Service is running and will be started at boot time. +# * disabled: Service is stopped and will not be started at boot +# time. +# * running: Service is running but will not be started at boot time. +# You can use this to start a service on the first Puppet run instead of +# the system startup. +# * unmanaged: Service will not be started at boot time and Puppet +# does not care whether the service is running or not. For example, this may +# be useful if a cluster management software is used to decide when to start +# the service plus assuring it is running on the desired node. +# Defaults to enabled. The singular form ("service") is used for the +# sake of convenience. Of course, the defined status affects all services if +# more than one is managed (see service.pp to check if this is the +# case). +# +# [*init_defaults*] +# Defaults file content in hash representation +# +# [*init_defaults_file*] +# Defaults file as puppet resource +# +# [*init_template*] +# Service file as a template +# +# === Authors +# +# * Richard Pijnenburg +# +define elasticsearch::service::systemd( + $ensure = $elasticsearch::ensure, + $status = $elasticsearch::status, + $init_defaults_file = undef, + $init_defaults = undef, + $init_template = undef, +) { + + #### Service management + + # set params: in operation + if $ensure == 'present' { + + case $status { + # make sure service is currently running, start it on boot + 'enabled': { + $service_ensure = 'running' + $service_enable = true + } + # make sure service is currently stopped, do not start it on boot + 'disabled': { + $service_ensure = 'stopped' + $service_enable = false + } + # make sure service is currently running, do not start it on boot + 'running': { + $service_ensure = 'running' + $service_enable = false + } + # do not start service on boot, do not care whether currently running + # or not + 'unmanaged': { + $service_ensure = undef + $service_enable = false + } + # unknown status + # note: don't forget to update the parameter check in init.pp if you + # add a new or change an existing status. + default: { + fail("\"${status}\" is an unknown service status value") + } + } + } else { + # make sure the service is stopped and disabled (the removal itself will be + # done by package.pp) + $service_ensure = 'stopped' + $service_enable = false + } + + $notify_service = $elasticsearch::restart_on_change ? { + true => [ Exec["systemd_reload_${name}"], Service["elasticsearch-instance-${name}"] ], + false => Exec["systemd_reload_${name}"] + } + + if ( $status != 'unmanaged' and $ensure == 'present' ) { + + # defaults file content. Either from a hash or file + if ($init_defaults_file != undef) { + file { "${elasticsearch::params::defaults_location}/elasticsearch-${name}": + ensure => $ensure, + source => $init_defaults_file, + owner => 'root', + group => 'root', + mode => '0644', + before => Service["elasticsearch-instance-${name}"], + notify => $notify_service + } + + } elsif ($init_defaults != undef and is_hash($init_defaults) ) { + + if(has_key($init_defaults, 'ES_USER')) { + if($init_defaults['ES_USER'] != $elasticsearch::elasticsearch_user) { + fail('Found ES_USER setting for init_defaults but is not same as elasticsearch_user setting. Please use elasticsearch_user setting.') + } + } + + $init_defaults_pre_hash = { 'ES_USER' => $elasticsearch::elasticsearch_user, 'ES_GROUP' => $elasticsearch::elasticsearch_group, 'MAX_OPEN_FILES' => '65535' } + $new_init_defaults = merge($init_defaults_pre_hash, $init_defaults) + + augeas { "defaults_${name}": + incl => "${elasticsearch::params::defaults_location}/elasticsearch-${name}", + lens => 'Shellvars.lns', + changes => template("${module_name}/etc/sysconfig/defaults.erb"), + before => Service["elasticsearch-instance-${name}"], + notify => $notify_service + } + + } + + # init file from template + if ($init_template != undef) { + + $user = $elasticsearch::elasticsearch_user + $group = $elasticsearch::elasticsearch_group + + file { "/usr/lib/systemd/system/elasticsearch-${name}.service": + ensure => $ensure, + content => template($init_template), + before => Service["elasticsearch-instance-${name}"], + notify => $notify_service + } + + } + + $service_require = Exec["systemd_reload_${name}"] + + } elsif($status != 'unmanaged') { + + file { "/usr/lib/systemd/system/elasticsearch-${name}.service": + ensure => 'absent', + subscribe => Service["elasticsearch-instance-${name}"], + notify => Exec["systemd_reload_${name}"] + } + + file { "${elasticsearch::params::defaults_location}/elasticsearch-${name}": + ensure => 'absent', + subscribe => Service["elasticsearch-instance-${name}"], + notify => Exec["systemd_reload_${name}"] + } + + $service_require = undef + + } + + exec { "systemd_reload_${name}": + command => '/bin/systemctl daemon-reload', + refreshonly => true, + } + + if ($status != 'unmanaged') { + + # action + service { "elasticsearch-instance-${name}": + ensure => $service_ensure, + enable => $service_enable, + name => "elasticsearch-${name}.service", + hasstatus => $elasticsearch::params::service_hasstatus, + hasrestart => $elasticsearch::params::service_hasrestart, + pattern => $elasticsearch::params::service_pattern, + provider => 'systemd', + require => $service_require, + } + + } + +} diff --git a/3rdparty/modules/elasticsearch/manifests/template.pp b/3rdparty/modules/elasticsearch/manifests/template.pp new file mode 100644 index 000000000..ade236c24 --- /dev/null +++ b/3rdparty/modules/elasticsearch/manifests/template.pp @@ -0,0 +1,145 @@ +# == Define: elasticsearch::template +# +# This define allows you to insert, update or delete templates that are used within Elasticsearch for the indexes +# +# === Parameters +# +# [*ensure*] +# String. Controls if the managed resources shall be present or +# absent. If set to absent: +# * The managed software packages are being uninstalled. +# * Any traces of the packages will be purged as good as possible. This may +# include existing configuration files. The exact behavior is provider +# dependent. Q.v.: +# * Puppet type reference: {package, "purgeable"}[http://j.mp/xbxmNP] +# * {Puppet's package provider source code}[http://j.mp/wtVCaL] +# * System modifications (if any) will be reverted as good as possible +# (e.g. removal of created users, services, changed log settings, ...). +# * This is thus destructive and should be used with care. +# Defaults to present. +# +# [*file*] +# File path of the template ( json file ) +# Value type is string +# Default value: undef +# This variable is optional +# +# [*content*] +# Contents of the template ( json ) +# Value type is string +# Default value: undef +# This variable is optional +# +# [*host*] +# Host name or IP address of the ES instance to connect to +# Value type is string +# Default value: localhost +# This variable is optional +# +# [*port*] +# Port number of the ES instance to connect to +# Value type is number +# Default value: 9200 +# This variable is optional +# +# === Authors +# +# * Richard Pijnenburg +# +define elasticsearch::template( + $ensure = 'present', + $file = undef, + $content = undef, + $host = 'localhost', + $port = 9200 +) { + + require elasticsearch + + # ensure + if ! ($ensure in [ 'present', 'absent' ]) { + fail("\"${ensure}\" is not a valid ensure parameter value") + } + + if ! is_integer($port) { + fail("\"${port}\" is not an integer") + } + + Exec { + path => [ '/bin', '/usr/bin', '/usr/local/bin' ], + cwd => '/', + tries => 6, + try_sleep => 10 + } + + # Build up the url + $es_url = "http://${host}:${port}/_template/${name}" + + # Can't do a replace and delete at the same time + + if ($ensure == 'present') { + + # Fail when no file or content is supplied + if $file == undef and $content == undef { + fail('The variables "file" and "content" cannot be empty when inserting or updating a template.') + } elsif $file != undef and $content != undef { + fail('The variables "file" and "content" cannot be used together when inserting or updating a template.') + } else { # we are good to go. notify to insert in case we deleted + $insert_notify = Exec[ "insert_template_${name}" ] + } + + } else { + + $insert_notify = undef + + } + + # Delete the existing template + # First check if it exists of course + exec { "delete_template_${name}": + command => "curl -s -XDELETE ${es_url}", + onlyif => "test $(curl -s '${es_url}?pretty=true' | wc -l) -gt 1", + notify => $insert_notify, + refreshonly => true + } + + if ($ensure == 'absent') { + + # delete the template file on disk and then on the server + file { "${elasticsearch::configdir}/templates_import/elasticsearch-template-${name}.json": + ensure => 'absent', + notify => Exec[ "delete_template_${name}" ], + require => Exec[ 'mkdir_templates_elasticsearch' ], + } + } + + if ($ensure == 'present') { + + if $content == undef { + # place the template file using the file source + file { "${elasticsearch::configdir}/templates_import/elasticsearch-template-${name}.json": + ensure => 'present', + source => $file, + notify => Exec[ "delete_template_${name}" ], + require => Exec[ 'mkdir_templates_elasticsearch' ], + } + } else { + # place the template file using content + file { "${elasticsearch::configdir}/templates_import/elasticsearch-template-${name}.json": + ensure => 'present', + content => $content, + notify => Exec[ "delete_template_${name}" ], + require => Exec[ 'mkdir_templates_elasticsearch' ], + } + } + + exec { "insert_template_${name}": + command => "curl -sL -w \"%{http_code}\\n\" -XPUT ${es_url} -d @${elasticsearch::configdir}/templates_import/elasticsearch-template-${name}.json -o /dev/null | egrep \"(200|201)\" > /dev/null", + unless => "test $(curl -s '${es_url}?pretty=true' | wc -l) -gt 1", + refreshonly => true, + loglevel => 'debug' + } + + } + +} diff --git a/3rdparty/modules/elasticsearch/metadata.json b/3rdparty/modules/elasticsearch/metadata.json new file mode 100644 index 000000000..460a2c146 --- /dev/null +++ b/3rdparty/modules/elasticsearch/metadata.json @@ -0,0 +1,80 @@ +{ + "name": "elasticsearch-elasticsearch", + "version": "0.9.3", + "author": "elasticsearch", + "summary": "Module for managing and configuring Elasticsearch nodes", + "license": "Apache License, Version 2.0", + "source": "https://github.com/elastic/puppet-elasticsearch", + "project_page": "https://github.com/elastic/puppet-elasticsearch", + "issues_url": "https://github.com/elastic/puppet-elasticsearch/issues", + "description": "Module for managing and configuring Elasticsearch nodes", + "operatingsystem_support": [ + { + "operatingsystem": "RedHat", + "operatingsystemrelease": [ + "5", + "6", + "7" + ] + }, + { + "operatingsystem": "CentOS", + "operatingsystemrelease": [ + "5", + "6", + "7" + ] + }, + { + "operatingsystem": "OracleLinux", + "operatingsystemrelease": [ + "5", + "6", + "7" + ] + }, + { + "operatingsystem": "Scientific", + "operatingsystemrelease": [ + "5", + "6", + "7" + ] + }, + { + "operatingsystem": "Debian", + "operatingsystemrelease": [ + "6", + "7" + ] + }, + { + "operatingsystem": "Ubuntu", + "operatingsystemrelease": [ + "10.04", + "12.04", + "14.04" + ] + }, + { + "operatingsystem": "OpenSuSE", + "operatingsystemrelease": [ + "12", + "13" + ] + } + ], + "requirements": [ + { + "name": "pe", + "version_requirement": ">= 3.1.3" + }, + { + "name": "puppet", + "version_requirement": ">=3.2.0 <4.0.0" + } + ], + "dependencies": [ + {"name":"puppetlabs/stdlib","version_requirement":">= 3.2.0 < 5.0.0"} + ] +} diff --git a/3rdparty/modules/elasticsearch/templates/etc/elasticsearch/elasticsearch.yml.erb b/3rdparty/modules/elasticsearch/templates/etc/elasticsearch/elasticsearch.yml.erb new file mode 100644 index 000000000..00a7220cb --- /dev/null +++ b/3rdparty/modules/elasticsearch/templates/etc/elasticsearch/elasticsearch.yml.erb @@ -0,0 +1,93 @@ +<%- + + # Function to make a structured and sorted yaml representation out of a hash + def recursive_hash_to_yml_string(hash, depth=0) + spacer = "" + depth.times { spacer += " "} + hash.keys.sort.each do |sorted_key| + @yml_string += spacer + sorted_key + ": " + if hash[sorted_key].is_a?(Array) + keyspacer = "" + sorted_key.length.times { keyspacer += " " } + @yml_string += "\n" + hash[sorted_key].each do |item| + @yml_string += spacer + keyspacer + "- " + item +"\n" + end + elsif hash[sorted_key].is_a?(Hash) + @yml_string += "\n" + recursive_hash_to_yml_string(hash[sorted_key], depth+1) + else + @yml_string += "#{hash[sorted_key].to_s}\n" + end + end + end + + # Function to transform shorted write up of the keys into full hash representation + def transform(hash) + return_vals = [] + + hash.each do |key,val| + if m = /^([^.]+)\.(.*)$/.match(key) + temp = { m[1] => { m[2] => val } } + transform(temp).each do |stuff| + return_vals << stuff + end + else + if val.is_a?(Hash) + transform(val).each do |stuff| + return_vals << { key => stuff } + end + else + return_vals << { key => val } + end + end + end + + return_vals + end + + # Function to deep merge hashes with same keys + class ::Hash + def deep_merge_with_array_values_concatenated(hash) + target = dup + + hash.keys.each do |key| + if hash[key].is_a? Hash and self[key].is_a? Hash + target[key] = target[key].deep_merge_with_array_values_concatenated(hash[key]) + next + end + + if hash[key].is_a?(Array) && target[key].is_a?(Array) + target[key] = target[key] + hash[key] + else + target[key] = hash[key] + end + end + + target + end + end + + # initial string + @yml_string = "### MANAGED BY PUPPET ###\n" + + if !@instance_conf.empty? + + @yml_string += "---\n" + + ## Transform shorted keys into full write up + transformed_config = transform(@instance_conf) + + # Merge it back into a hash + tmphash = { } + transformed_config.each do |subhash| + tmphash = tmphash.deep_merge_with_array_values_concatenated(subhash) + end + + # Transform it into yaml + recursive_hash_to_yml_string(tmphash) + + end + +-%> +<%= @yml_string -%> diff --git a/3rdparty/modules/elasticsearch/templates/etc/elasticsearch/logging.yml.erb b/3rdparty/modules/elasticsearch/templates/etc/elasticsearch/logging.yml.erb new file mode 100644 index 000000000..e24d41426 --- /dev/null +++ b/3rdparty/modules/elasticsearch/templates/etc/elasticsearch/logging.yml.erb @@ -0,0 +1,52 @@ +# This file is managed by Puppet, do not edit manually, your changes *will* be overwritten! +# +# Please see the source file for context and more information: +# +# https://github.com/elasticsearch/elasticsearch/blob/master/config/logging.yml +# + +es.logger.level: <%= @logging_level %> +rootLogger: <%= @logging_level %>, console, file + +# ----- Configuration set by Puppet --------------------------------------------- + +<% @logging_hash.sort.each do |key,value| %> +logger.<%= key %>: <%= value %> +<% end %> + +# ------------------------------------------------------------------------------- + +additivity: + index.search.slowlog: false + index.indexing.slowlog: 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] %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/3rdparty/modules/elasticsearch/templates/etc/init.d/elasticsearch.Debian.erb b/3rdparty/modules/elasticsearch/templates/etc/init.d/elasticsearch.Debian.erb new file mode 100644 index 000000000..23a4359f4 --- /dev/null +++ b/3rdparty/modules/elasticsearch/templates/etc/init.d/elasticsearch.Debian.erb @@ -0,0 +1,204 @@ +#!/bin/sh +# +# /etc/init.d/elasticsearch-<%= @name %> -- startup script for Elasticsearch +# +# Written by Miquel van Smoorenburg . +# Modified for Debian GNU/Linux by Ian Murdock . +# Modified for Tomcat by Stefan Gybas . +# Modified for Tomcat6 by Thierry Carrez . +# Additional improvements by Jason Brittain . +# Modified by Nicolas Huray for Elasticsearch . +# +### BEGIN INIT INFO +# Provides: elasticsearch-<%= @name %> +# Required-Start: $network $remote_fs $named +# Required-Stop: $network $remote_fs $named +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Starts elasticsearch-<%= @name %> +# Description: Starts elasticsearch-<%= @name %> using start-stop-daemon +### END INIT INFO + +PATH=/bin:/usr/bin:/sbin:/usr/sbin +NAME=elasticsearch-<%= @name %> +DESC="Elasticsearch Server <%= @name %>" +DEFAULT=/etc/default/$NAME + +if [ `id -u` -ne 0 ]; then + echo "You need root privileges to run this script" + exit 1 +fi + + +. /lib/lsb/init-functions + +if [ -r /etc/default/rcS ]; then + . /etc/default/rcS +fi + + +# The following variables can be overwritten in $DEFAULT + +# Run Elasticsearch as this user ID and group ID +ES_USER=elasticsearch +ES_GROUP=elasticsearch + +# The first existing directory is used for JAVA_HOME (if JAVA_HOME is not defined in $DEFAULT) +JDK_DIRS="/usr/lib/jvm/java-7-oracle /usr/lib/jvm/java-7-openjdk /usr/lib/jvm/java-7-openjdk-amd64/ /usr/lib/jvm/java-7-openjdk-armhf /usr/lib/jvm/java-7-openjdk-i386/ /usr/lib/jvm/java-6-sun /usr/lib/jvm/java-6-openjdk /usr/lib/jvm/java-6-openjdk-amd64 /usr/lib/jvm/java-6-openjdk-armhf /usr/lib/jvm/java-6-openjdk-i386 /usr/lib/jvm/default-java" + +# Look for the right JVM to use +for jdir in $JDK_DIRS; do + if [ -r "$jdir/bin/java" -a -z "${JAVA_HOME}" ]; then + JAVA_HOME="$jdir" + fi +done +export JAVA_HOME + +# Directory where the Elasticsearch binary distribution resides +ES_HOME=/usr/share/$NAME + +# Heap Size (defaults to 256m min, 1g max) +#ES_HEAP_SIZE=2g + +# Heap new generation +#ES_HEAP_NEWSIZE= + +# max direct memory +#ES_DIRECT_SIZE= + +# Additional Java OPTS +#ES_JAVA_OPTS= + +# Maximum number of open files +MAX_OPEN_FILES=65535 + +# Maximum amount of locked memory +#MAX_LOCKED_MEMORY= + +# Elasticsearch log directory +LOG_DIR=/var/log/$NAME + +# Elasticsearch data directory +DATA_DIR=/var/lib/$NAME + +# Elasticsearch work directory +WORK_DIR=/tmp/$NAME + +# Elasticsearch configuration directory +CONF_DIR=/etc/$NAME + +# Elasticsearch configuration file (elasticsearch.yml) +CONF_FILE=$CONF_DIR/elasticsearch.yml + +# Maximum number of VMA (Virtual Memory Areas) a process can own +MAX_MAP_COUNT=262144 + +# End of variables that can be overwritten in $DEFAULT + +# overwrite settings from default file +if [ -f "$DEFAULT" ]; then + . "$DEFAULT" +fi + +# Define other required variables +PID_FILE=/var/run/$NAME.pid +DAEMON=$ES_HOME/bin/elasticsearch +DAEMON_OPTS="-d -p $PID_FILE -Des.default.config=$CONF_FILE -Des.default.path.home=$ES_HOME -Des.default.path.logs=$LOG_DIR -Des.default.path.data=$DATA_DIR -Des.default.path.work=$WORK_DIR -Des.default.path.conf=$CONF_DIR" + +export ES_HEAP_SIZE +export ES_HEAP_NEWSIZE +export ES_DIRECT_SIZE +export ES_JAVA_OPTS +export ES_CLASSPATH + +# Check DAEMON exists +test -x $DAEMON || exit 0 + +checkJava() { + if [ -x "$JAVA_HOME/bin/java" ]; then + JAVA="$JAVA_HOME/bin/java" + else + JAVA=`which java` + fi + + if [ ! -x "$JAVA" ]; then + echo "Could not find any executable java binary. Please install java in your PATH or set JAVA_HOME" + exit 1 + fi +} + +case "$1" in + start) + checkJava + + if [ -n "$MAX_LOCKED_MEMORY" -a -z "$ES_HEAP_SIZE" ]; then + log_failure_msg "MAX_LOCKED_MEMORY is set - ES_HEAP_SIZE must also be set" + exit 1 + fi + + log_daemon_msg "Starting $DESC" + + pid=`pidofproc -p $PID_FILE elasticsearch` + if [ -n "$pid" ] ; then + log_begin_msg "Already running." + log_end_msg 0 + exit 0 + fi + + # Prepare environment + mkdir -p "$LOG_DIR" "$DATA_DIR" "$WORK_DIR" && chown "$ES_USER":"$ES_GROUP" "$LOG_DIR" "$DATA_DIR" "$WORK_DIR" + touch "$PID_FILE" && chown "$ES_USER":"$ES_GROUP" "$PID_FILE" + + if [ -n "$MAX_OPEN_FILES" ]; then + ulimit -n $MAX_OPEN_FILES + fi + + if [ -n "$MAX_LOCKED_MEMORY" ]; then + ulimit -l $MAX_LOCKED_MEMORY + fi + + if [ -n "$MAX_MAP_COUNT" ]; then + sysctl -q -w vm.max_map_count=$MAX_MAP_COUNT + fi + + # Start Daemon + start-stop-daemon --start -b --user "$ES_USER" -c "$ES_USER" --pidfile "$PID_FILE" --exec $DAEMON -- $DAEMON_OPTS + log_end_msg $? + ;; + stop) + log_daemon_msg "Stopping $DESC" + + if [ -f "$PID_FILE" ]; then + start-stop-daemon --stop --pidfile "$PID_FILE" \ + --user "$ES_USER" \ + --retry=TERM/20/KILL/5 >/dev/null + if [ $? -eq 1 ]; then + log_progress_msg "$DESC is not running but pid file exists, cleaning up" + elif [ $? -eq 3 ]; then + PID="`cat $PID_FILE`" + log_failure_msg "Failed to stop $DESC (pid $PID)" + exit 1 + fi + rm -f "$PID_FILE" + else + log_progress_msg "(not running)" + fi + log_end_msg 0 + ;; + status) + status_of_proc -p $PID_FILE elasticsearch elasticsearch && exit 0 || exit $? + ;; + restart|force-reload) + if [ -f "$PID_FILE" ]; then + $0 stop + sleep 1 + fi + $0 start + ;; + *) + log_success_msg "Usage: $0 {start|stop|restart|force-reload|status}" + exit 1 + ;; +esac + +exit 0 diff --git a/3rdparty/modules/elasticsearch/templates/etc/init.d/elasticsearch.RedHat.erb b/3rdparty/modules/elasticsearch/templates/etc/init.d/elasticsearch.RedHat.erb new file mode 100644 index 000000000..3bd303dc8 --- /dev/null +++ b/3rdparty/modules/elasticsearch/templates/etc/init.d/elasticsearch.RedHat.erb @@ -0,0 +1,159 @@ +#!/bin/sh +# +# elasticsearch<%= @name %> +# +# chkconfig: 2345 80 20 +# description: Starts and stops a single elasticsearch instance on this system +# + +### BEGIN INIT INFO +# Provides: Elasticsearch-<%= @name %> +# Required-Start: $network $named +# Required-Stop: $network $named +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: This service manages the elasticsearch daemon +# Description: Elasticsearch is a very scalable, schema-free and high-performance search solution supporting multi-tenancy and near realtime search. +### END INIT INFO + +# +# init.d / servicectl compatibility (openSUSE) +# +if [ -f /etc/rc.status ]; then + . /etc/rc.status + rc_reset +fi + +# +# Source function library. +# +if [ -f /etc/rc.d/init.d/functions ]; then + . /etc/rc.d/init.d/functions +fi + +exec="/usr/share/elasticsearch/bin/elasticsearch" +prog="elasticsearch-<%= @name %>" +pidfile=/var/run/elasticsearch/${prog}.pid + +[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog + +export ES_HEAP_SIZE +export ES_HEAP_NEWSIZE +export ES_DIRECT_SIZE +export ES_JAVA_OPTS +export ES_CLASSPATH + +lockfile=/var/lock/subsys/$prog + +# backwards compatibility for old config sysconfig files, pre 0.90.1 +if [ -n $USER ] && [ -z $ES_USER ] ; then + ES_USER=$USER +fi + +checkJava() { + if [ -x "$JAVA_HOME/bin/java" ]; then + JAVA="$JAVA_HOME/bin/java" + else + JAVA=`which java` + fi + + if [ ! -x "$JAVA" ]; then + echo "Could not find any executable java binary. Please install java in your PATH or set JAVA_HOME" + exit 1 + fi +} + +start() { + checkJava + [ -x $exec ] || exit 5 + [ -f $CONF_FILE ] || exit 6 + if [ -n "$MAX_LOCKED_MEMORY" -a -z "$ES_HEAP_SIZE" ]; then + echo "MAX_LOCKED_MEMORY is set - ES_HEAP_SIZE must also be set" + return 7 + fi + if [ -n "$MAX_OPEN_FILES" ]; then + ulimit -n $MAX_OPEN_FILES + fi + if [ -n "$MAX_LOCKED_MEMORY" ]; then + ulimit -l $MAX_LOCKED_MEMORY + fi + if [ -n "$MAX_MAP_COUNT" ]; then + sysctl -q -w vm.max_map_count=$MAX_MAP_COUNT + fi + if [ -n "$WORK_DIR" ]; then + mkdir -p "$WORK_DIR" + chown "$ES_USER":"$ES_GROUP" "$WORK_DIR" + fi + echo -n $"Starting $prog: " + # if not running, start it up here, usually something like "daemon $exec" + daemon --user $ES_USER --pidfile $pidfile $exec -p $pidfile -d -Des.default.path.home=$ES_HOME -Des.default.path.logs=$LOG_DIR -Des.default.path.data=$DATA_DIR -Des.default.path.work=$WORK_DIR -Des.default.path.conf=$CONF_DIR + retval=$? + echo + [ $retval -eq 0 ] && touch $lockfile + return $retval +} + +stop() { + echo -n $"Stopping $prog: " + # stop it here, often "killproc $prog" + killproc -p $pidfile -d 20 $prog + retval=$? + echo + [ $retval -eq 0 ] && rm -f $lockfile + return $retval +} + +restart() { + stop + start +} + +reload() { + restart +} + +force_reload() { + restart +} + +rh_status() { + # run checks to determine if the service is running or use generic status + status -p $pidfile $prog +} + +rh_status_q() { + rh_status >/dev/null 2>&1 +} + + +case "$1" in + start) + rh_status_q && exit 0 + $1 + ;; + stop) + rh_status_q || exit 0 + $1 + ;; + restart) + $1 + ;; + reload) + rh_status_q || exit 7 + $1 + ;; + force-reload) + force_reload + ;; + status) + rh_status + ;; + condrestart|try-restart) + rh_status_q || exit 0 + restart + ;; + *) + echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" + exit 2 +esac +exit $? diff --git a/3rdparty/modules/elasticsearch/templates/etc/init.d/elasticsearch.systemd.erb b/3rdparty/modules/elasticsearch/templates/etc/init.d/elasticsearch.systemd.erb new file mode 100644 index 000000000..5bdb6ba4c --- /dev/null +++ b/3rdparty/modules/elasticsearch/templates/etc/init.d/elasticsearch.systemd.erb @@ -0,0 +1,20 @@ +[Unit] +Description=Starts and stops a single elasticsearch instance on this system +Documentation=http://www.elasticsearch.org + +[Service] +Type=forking +EnvironmentFile=/etc/sysconfig/elasticsearch-<%= @name %> +User=<%= @user %> +Group=<%= @group %> +PIDFile=/var/run/elasticsearch/elasticsearch-<%= @name %>.pid +ExecStart=/usr/share/elasticsearch/bin/elasticsearch -d -p /var/run/elasticsearch/elasticsearch-<%= @name %>.pid -Des.default.config=$CONF_FILE -Des.default.path.home=$ES_HOME -Des.default.path.logs=$LOG_DIR -Des.default.path.data=$DATA_DIR -Des.default.path.work=$WORK_DIR -Des.default.path.conf=$CONF_DIR +# See MAX_OPEN_FILES in sysconfig +LimitNOFILE=65535 +# See MAX_LOCKED_MEMORY in sysconfig, use "infinity" when MAX_LOCKED_MEMORY=unlimited and using bootstrap.mlockall: true +#LimitMEMLOCK=infinity +# Shutdown delay in seconds, before process is tried to be killed with KILL (if configured) +TimeoutStopSec=20 + +[Install] +WantedBy=multi-user.target diff --git a/3rdparty/modules/elasticsearch/templates/etc/sysconfig/defaults.erb b/3rdparty/modules/elasticsearch/templates/etc/sysconfig/defaults.erb new file mode 100644 index 000000000..7dad4e078 --- /dev/null +++ b/3rdparty/modules/elasticsearch/templates/etc/sysconfig/defaults.erb @@ -0,0 +1,3 @@ +<% @new_init_defaults.sort.map do |key, value| -%> +set <%= key %> '<%= value %>' +<% end -%> diff --git a/hieradata/common.yaml b/hieradata/common.yaml index c2a30bc3c..eb2f6ec13 100644 --- a/hieradata/common.yaml +++ b/hieradata/common.yaml @@ -46,6 +46,8 @@ roles: - oyens.debian.org lists: - bendel.debian.org + list_search: + - stockhausen.debian.org mailrelay: - mailly.debian.org - muffat.debian.org diff --git a/modules/debian-org/templates/puppet.conf.erb b/modules/debian-org/templates/puppet.conf.erb index 3ac67f1e1..82d0546fc 100644 --- a/modules/debian-org/templates/puppet.conf.erb +++ b/modules/debian-org/templates/puppet.conf.erb @@ -10,6 +10,7 @@ ssldir=/var/lib/puppet/ssl rundir=/var/run/puppet factpath=$vardir/lib/facter pluginsync=true +modulepath=/etc/puppet/3rdparty/modules:$modulepath # This is the default environment for all clients environment=production diff --git a/modules/roles/manifests/init.pp b/modules/roles/manifests/init.pp index d79c0e81b..cab8edd97 100644 --- a/modules/roles/manifests/init.pp +++ b/modules/roles/manifests/init.pp @@ -154,6 +154,10 @@ class roles { include roles::lists } + if has_role('list_search') { + include roles::listsearch + } + if has_role('rtmaster') { include roles::rtmaster } diff --git a/modules/roles/manifests/listsearch.pp b/modules/roles/manifests/listsearch.pp new file mode 100644 index 000000000..02e935342 --- /dev/null +++ b/modules/roles/manifests/listsearch.pp @@ -0,0 +1,13 @@ +class roles::listsearch { + + class { 'elasticsearch': + autoupgrade => false, + config => { 'cluster.name' => 'listsearch' } + } + + elasticsearch::instance { 'es-01': + config => { 'node.name' => 'stockhausen' }, + init_defaults => { }, # Init defaults hash + datadir => [ '/srv/listsearch.debian.org/es-data-es01' ], # Data directory + } +} -- 2.20.1