mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-13 21:13:26 +00:00
Upgrade php from 5.4.* to 5.5.*
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
fixtures:
|
||||
repositories:
|
||||
stdlib: git://github.com/puppetlabs/puppetlabs-stdlib.git
|
||||
symlinks:
|
||||
elasticsearch: "#{source_dir}"
|
33
resources/vagrant/vms/phraseanet-php55-nginx/puphpet/puppet/modules/elasticsearch/.travis.yml
vendored
Normal file
33
resources/vagrant/vms/phraseanet-php55-nginx/puphpet/puppet/modules/elasticsearch/.travis.yml
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
language: ruby
|
||||
rvm:
|
||||
- 1.8.7
|
||||
- 1.9.3
|
||||
- 2.0.0
|
||||
script:
|
||||
- "rake lint"
|
||||
- "rake parser_validate"
|
||||
- "rake template_verify"
|
||||
- "rake spec SPEC_OPTS='--format documentation'"
|
||||
env:
|
||||
- PUPPET_VERSION="~> 2.7.0"
|
||||
- PUPPET_VERSION="~> 3.0.0"
|
||||
- PUPPET_VERSION="~> 3.1.0"
|
||||
- PUPPET_VERSION="~> 3.2.0"
|
||||
- PUPPET_VERSION="~> 3.3.0"
|
||||
matrix:
|
||||
allow_failures:
|
||||
- rvm: 2.0.0
|
||||
gemfile: Gemfile
|
||||
notifications:
|
||||
email:
|
||||
recipients:
|
||||
- richard.pijnenburg@elasticsearch.com
|
||||
on_success: change
|
||||
on_failure: always
|
||||
hipchat:
|
||||
rooms:
|
||||
secure: "gFaED3lu9MRrmoojO2iagrfOaKAbCeQSqVZ9TsIo+qkqem8hwOsMuxsYQ9evPbPbanXQoVNALXTd4fgQW16+hfg/ClqI3nDtVZZJSy0W+U0yVZtz9TXFpi9Q/Z4TwK5TMdNMjemt0l2idY2SE3leHBZEeaIAGfLf0v38tCsNI84="
|
||||
template:
|
||||
- '@electrical %{repository}#%{build_number} (%{branch} - %{commit} : %{author}): %{message} %{build_url}'
|
||||
on_success: change
|
||||
on_failure: always
|
91
resources/vagrant/vms/phraseanet-php55-nginx/puphpet/puppet/modules/elasticsearch/CHANGELOG
vendored
Normal file
91
resources/vagrant/vms/phraseanet-php55-nginx/puphpet/puppet/modules/elasticsearch/CHANGELOG
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
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
|
@@ -0,0 +1,18 @@
|
||||
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 Elasticsearch repositories is similar.
|
||||
|
||||
1. Sign the contributor license agreement
|
||||
Please make sure you have signed the [Contributor License Agreement](http://www.elasticsearch.org/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. 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.
|
||||
|
||||
4. 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.
|
20
resources/vagrant/vms/phraseanet-php55-nginx/puphpet/puppet/modules/elasticsearch/CONTRIBUTORS
vendored
Normal file
20
resources/vagrant/vms/phraseanet-php55-nginx/puphpet/puppet/modules/elasticsearch/CONTRIBUTORS
vendored
Normal file
@@ -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)
|
7
resources/vagrant/vms/phraseanet-php55-nginx/puphpet/puppet/modules/elasticsearch/Gemfile
vendored
Normal file
7
resources/vagrant/vms/phraseanet-php55-nginx/puphpet/puppet/modules/elasticsearch/Gemfile
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
source 'https://rubygems.org'
|
||||
|
||||
puppetversion = ENV['PUPPET_VERSION']
|
||||
gem 'puppet', puppetversion, :require => false
|
||||
gem 'puppet-lint'
|
||||
gem 'rspec-puppet'
|
||||
gem 'puppetlabs_spec_helper', '>= 0.1.0'
|
13
resources/vagrant/vms/phraseanet-php55-nginx/puphpet/puppet/modules/elasticsearch/LICENSE
vendored
Normal file
13
resources/vagrant/vms/phraseanet-php55-nginx/puphpet/puppet/modules/elasticsearch/LICENSE
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
Copyright (c) 2012-2014 Elasticsearch <http://www.elasticsearch.org>
|
||||
|
||||
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.
|
9
resources/vagrant/vms/phraseanet-php55-nginx/puphpet/puppet/modules/elasticsearch/Modulefile
vendored
Normal file
9
resources/vagrant/vms/phraseanet-php55-nginx/puphpet/puppet/modules/elasticsearch/Modulefile
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
name 'elasticsearch-elasticsearch'
|
||||
version '0.2.2'
|
||||
source 'https://github.com/elasticsearch/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/elasticsearch/puppet-elasticsearch'
|
||||
dependency 'puppetlabs/stdlib', '>= 3.0.0'
|
203
resources/vagrant/vms/phraseanet-php55-nginx/puphpet/puppet/modules/elasticsearch/README.md
vendored
Normal file
203
resources/vagrant/vms/phraseanet-php55-nginx/puphpet/puppet/modules/elasticsearch/README.md
vendored
Normal file
@@ -0,0 +1,203 @@
|
||||
# puppet-elasticsearch
|
||||
|
||||
A puppet module for managing elasticsearch nodes
|
||||
|
||||
http://www.elasticsearch.org/
|
||||
|
||||
[](https://travis-ci.org/elasticsearch/puppet-elasticsearch)
|
||||
|
||||
## Usage
|
||||
|
||||
Installation, make sure service is running and will be started at boot time:
|
||||
|
||||
class { 'elasticsearch': }
|
||||
|
||||
Install a certain version:
|
||||
|
||||
class { 'elasticsearch':
|
||||
version => '0.90.3'
|
||||
}
|
||||
|
||||
This assumes an elasticsearch package is already available to your distribution's package manager. To install it in a different way:
|
||||
|
||||
To download from http/https/ftp source:
|
||||
|
||||
class { 'elasticsearch':
|
||||
package_url => 'https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.7.deb'
|
||||
}
|
||||
|
||||
To download from a puppet:// source:
|
||||
|
||||
class { 'elasticsearch':
|
||||
package_url => 'puppet:///path/to/elasticsearch-0.90.7.deb'
|
||||
}
|
||||
|
||||
Or use a local file source:
|
||||
|
||||
class { 'elasticsearch':
|
||||
package_url => 'file:/path/to/elasticsearch-0.90.7.deb'
|
||||
}
|
||||
|
||||
Automatic upgrade of the software ( default set to false ):
|
||||
|
||||
class { 'elasticsearch':
|
||||
autoupgrade => true
|
||||
}
|
||||
|
||||
Removal/decommissioning:
|
||||
|
||||
class { 'elasticsearch':
|
||||
ensure => 'absent'
|
||||
}
|
||||
|
||||
Install everything but disable service(s) afterwards:
|
||||
|
||||
class { 'elasticsearch':
|
||||
status => 'disabled'
|
||||
}
|
||||
|
||||
Disable automated restart of Elasticsearch on config file change:
|
||||
|
||||
class { 'elasticsearch':
|
||||
restart_on_change => false
|
||||
}
|
||||
|
||||
For the config variable a hash needs to be passed:
|
||||
|
||||
class { 'elasticsearch':
|
||||
config => {
|
||||
'node' => {
|
||||
'name' => 'elasticsearch001'
|
||||
},
|
||||
'index' => {
|
||||
'number_of_replicas' => '0',
|
||||
'number_of_shards' => '5'
|
||||
},
|
||||
'network' => {
|
||||
'host' => $::ipaddress
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Short write up of the config hash is also possible.
|
||||
|
||||
Instead of writing the full hash representation:
|
||||
|
||||
class { 'elasticsearch':
|
||||
config => {
|
||||
'cluster' => {
|
||||
'name' => 'ClusterName',
|
||||
'routing' => {
|
||||
'allocation' => {
|
||||
'awareness' => {
|
||||
'attributes' => 'rack'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
You can write the dotted key naming:
|
||||
|
||||
class { 'elasticsearch':
|
||||
config => {
|
||||
'cluster' => {
|
||||
'name' => 'ClusterName',
|
||||
'routing.allocation.awareness.attributes' => 'rack'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
## Manage templates
|
||||
|
||||
### Add a new template
|
||||
|
||||
This will install and/or replace the template in Elasticearch
|
||||
|
||||
elasticsearch::template { 'templatename':
|
||||
file => 'puppet:///path/to/template.json'
|
||||
}
|
||||
|
||||
### Delete a template
|
||||
|
||||
elasticsearch::template { 'templatename':
|
||||
ensure => 'absent'
|
||||
}
|
||||
|
||||
### Host
|
||||
|
||||
Default it uses localhost:9200 as host. you can change this with the 'host' and 'port' variables
|
||||
|
||||
elasticsearch::template { 'templatename':
|
||||
host => $::ipaddress,
|
||||
port => 9200
|
||||
}
|
||||
|
||||
## Bindings / clients
|
||||
|
||||
Install a variety of [clients/bindings](http://www.elasticsearch.org/guide/clients/):
|
||||
|
||||
### Python
|
||||
|
||||
elasticsearch::python { 'rawes': }
|
||||
|
||||
### Ruby
|
||||
|
||||
elasticsearch::ruby { 'elasticsearch': }
|
||||
|
||||
## Plugins
|
||||
|
||||
Install [a variety of plugins](http://www.elasticsearch.org/guide/clients/):
|
||||
|
||||
### From official repository:
|
||||
|
||||
elasticsearch::plugin{'mobz/elasticsearch-head':
|
||||
module_dir => 'head'
|
||||
}
|
||||
|
||||
### From custom url:
|
||||
|
||||
elasticsearch::plugin{ 'elasticsearch-jetty':
|
||||
module_dir => 'jetty',
|
||||
url => 'https://oss-es-plugins.s3.amazonaws.com/elasticsearch-jetty/elasticsearch-jetty-0.90.0.zip'
|
||||
}
|
||||
|
||||
## Java install
|
||||
|
||||
For those that have no separate module for installation of java:
|
||||
|
||||
class { 'elasticsearch':
|
||||
java_install => true
|
||||
}
|
||||
|
||||
If you want a specific java package/version:
|
||||
|
||||
class { 'elasticsearch':
|
||||
java_install => true,
|
||||
java_package => 'packagename'
|
||||
}
|
||||
|
||||
## Service providers
|
||||
|
||||
Currently only the 'init' service provider is supported but others can be implemented quite easy.
|
||||
|
||||
### init
|
||||
|
||||
#### Defaults file
|
||||
|
||||
You can populate the defaults file ( /etc/defaults/elasticsearch or /etc/sysconfig/elasticsearch )
|
||||
|
||||
##### hash representation
|
||||
|
||||
class { 'elasticsearch':
|
||||
init_defaults => { 'ES_USER' => 'elasticsearch', 'ES_GROUP' => 'elasticsearch' }
|
||||
}
|
||||
|
||||
##### file source
|
||||
|
||||
class { 'elasticsearch':
|
||||
init_defaults_file => 'puppet:///path/to/defaults'
|
||||
}
|
||||
|
7
resources/vagrant/vms/phraseanet-php55-nginx/puphpet/puppet/modules/elasticsearch/Rakefile
vendored
Normal file
7
resources/vagrant/vms/phraseanet-php55-nginx/puphpet/puppet/modules/elasticsearch/Rakefile
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
require 'rubygems'
|
||||
require 'puppetlabs_spec_helper/rake_tasks'
|
||||
require 'puppet-lint'
|
||||
require './spec/lib/template_check_task.rb'
|
||||
require './spec/lib/parser_validate_task.rb'
|
||||
PuppetLint.configuration.send("disable_80chars")
|
||||
PuppetLint.configuration.send("disable_class_inherits_from_params_class")
|
@@ -0,0 +1,90 @@
|
||||
# == 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 <mailto:richard@ispavailability.com>
|
||||
#
|
||||
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::confdir:
|
||||
ensure => directory,
|
||||
mode => '0644',
|
||||
purge => $elasticsearch::purge_confdir,
|
||||
force => $elasticsearch::purge_confdir
|
||||
}
|
||||
|
||||
file { "${elasticsearch::confdir}/elasticsearch.yml":
|
||||
ensure => file,
|
||||
content => template("${module_name}/etc/elasticsearch/elasticsearch.yml.erb"),
|
||||
mode => '0644',
|
||||
notify => $notify_service
|
||||
}
|
||||
|
||||
exec { 'mkdir_templates_elasticsearch':
|
||||
command => "mkdir -p ${elasticsearch::confdir}/templates_import",
|
||||
creates => "${elasticsearch::confdir}/templates_import"
|
||||
}
|
||||
|
||||
file { "${elasticsearch::confdir}/templates_import":
|
||||
ensure => 'directory',
|
||||
mode => '0644',
|
||||
require => Exec['mkdir_templates_elasticsearch']
|
||||
}
|
||||
|
||||
if ( $elasticsearch::datadir != undef ) {
|
||||
file { $elasticsearch::datadir:
|
||||
ensure => 'directory',
|
||||
owner => $elasticsearch::elasticsearch_user,
|
||||
group => $elasticsearch::elasticsearch_group,
|
||||
mode => '0770',
|
||||
}
|
||||
}
|
||||
|
||||
} elsif ( $elasticsearch::ensure == 'absent' ) {
|
||||
|
||||
file { $elasticsearch::confdir:
|
||||
ensure => 'absent',
|
||||
recurse => true,
|
||||
force => true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
208
resources/vagrant/vms/phraseanet-php55-nginx/puphpet/puppet/modules/elasticsearch/manifests/init.pp
vendored
Normal file
208
resources/vagrant/vms/phraseanet-php55-nginx/puphpet/puppet/modules/elasticsearch/manifests/init.pp
vendored
Normal file
@@ -0,0 +1,208 @@
|
||||
# == 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 <tt>present</tt> or
|
||||
# <tt>absent</tt>. If set to <tt>absent</tt>:
|
||||
# * 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 <tt>present</tt>.
|
||||
#
|
||||
# [*autoupgrade*]
|
||||
# Boolean. If set to <tt>true</tt>, 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 <tt>false</tt>.
|
||||
#
|
||||
# [*status*]
|
||||
# String to define the status of the service. Possible values:
|
||||
# * <tt>enabled</tt>: Service is running and will be started at boot time.
|
||||
# * <tt>disabled</tt>: Service is stopped and will not be started at boot
|
||||
# time.
|
||||
# * <tt>running</tt>: 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.
|
||||
# * <tt>unmanaged</tt>: 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 <tt>enabled</tt>. 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 <tt>service.pp</tt> to check if this is the
|
||||
# case).
|
||||
#
|
||||
# [*version*]
|
||||
# String to set the specific version you want to install.
|
||||
# Defaults to <tt>false</tt>.
|
||||
#
|
||||
# [*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 <tt>true</tt>, which will restart the application on any config
|
||||
# change. Setting to <tt>false</tt> disables the automatic restart.
|
||||
#
|
||||
# [*confdir*]
|
||||
# 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)
|
||||
#
|
||||
# The default values for the parameters are set in elasticsearch::params. Have
|
||||
# a look at the corresponding <tt>params.pp</tt> 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 <mailto:richard@ispavailability.com>
|
||||
#
|
||||
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,
|
||||
$purge_package_dir = $elasticsearch::params::purge_package_dir,
|
||||
$elasticsearch_user = $elasticsearch::params::elasticsearch_user,
|
||||
$elasticsearch_group = $elasticsearch::params::elasticsearch_group,
|
||||
$purge_confdir = $elasticsearch::params::purge_confdir,
|
||||
$service_provider = 'init',
|
||||
$init_defaults = undef,
|
||||
$init_defaults_file = undef,
|
||||
$init_template = undef,
|
||||
$config = {},
|
||||
$confdir = $elasticsearch::params::confdir,
|
||||
$datadir = undef,
|
||||
$plugindir = $elasticsearch::params::plugindir,
|
||||
$plugintool = $elasticsearch::params::plugintool,
|
||||
$java_install = false,
|
||||
$java_package = undef
|
||||
) 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_confdir)
|
||||
|
||||
if ! ($service_provider in $elasticsearch::params::service_providers) {
|
||||
fail("\"${service_provider}\" is not a valid provider for \"${::operatingsystem}\"")
|
||||
}
|
||||
|
||||
if ($package_url != undef and $version != false) {
|
||||
fail('Unable to set the version number when using package_url option.')
|
||||
}
|
||||
|
||||
# validate config hash
|
||||
validate_hash($config)
|
||||
|
||||
# java install validation
|
||||
validate_bool($java_install)
|
||||
|
||||
#### Manage actions
|
||||
|
||||
# package(s)
|
||||
class { 'elasticsearch::package': }
|
||||
|
||||
# configuration
|
||||
class { 'elasticsearch::config': }
|
||||
|
||||
# service(s)
|
||||
class { 'elasticsearch::service': }
|
||||
|
||||
if $java_install == true {
|
||||
# Install java
|
||||
class { 'elasticsearch::java': }
|
||||
|
||||
# ensure we first java java and then manage the service
|
||||
Anchor['elasticsearch::begin']
|
||||
-> Class['elasticsearch::java']
|
||||
-> Class['elasticsearch::service']
|
||||
}
|
||||
|
||||
#### Manage relationships
|
||||
|
||||
if $ensure == 'present' {
|
||||
|
||||
# we need the software before configuring it
|
||||
Anchor['elasticsearch::begin']
|
||||
-> Class['elasticsearch::package']
|
||||
-> Class['elasticsearch::config']
|
||||
|
||||
# we need the software and a working configuration before running a service
|
||||
Class['elasticsearch::package'] -> Class['elasticsearch::service']
|
||||
Class['elasticsearch::config'] -> Class['elasticsearch::service']
|
||||
|
||||
Class['elasticsearch::service'] -> Anchor['elasticsearch::end']
|
||||
|
||||
} else {
|
||||
|
||||
# make sure all services are getting stopped before software removal
|
||||
Anchor['elasticsearch::begin']
|
||||
-> Class['elasticsearch::service']
|
||||
-> Class['elasticsearch::package']
|
||||
-> Anchor['elasticsearch::end']
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,50 @@
|
||||
# == Class: elasticsearch::java
|
||||
#
|
||||
# This class exists to install java if its not managed from an other module
|
||||
#
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# This class does not provide any parameters.
|
||||
#
|
||||
#
|
||||
# === Examples
|
||||
#
|
||||
# This class may be imported by other classes to use its functionality:
|
||||
# class { 'elasticsearch::java': }
|
||||
#
|
||||
# It is not intended to be used directly by external resources like node
|
||||
# definitions or other modules.
|
||||
#
|
||||
#
|
||||
# === Authors
|
||||
#
|
||||
# * Richard Pijnenburg <mailto:richard@ispavailability.com>
|
||||
#
|
||||
class elasticsearch::java {
|
||||
|
||||
if $elasticsearch::java_package == undef {
|
||||
# Default Java package
|
||||
case $::operatingsystem {
|
||||
'CentOS', 'Fedora', 'Scientific', 'RedHat', 'Amazon', 'OracleLinux': {
|
||||
$package = 'java-1.7.0-openjdk'
|
||||
}
|
||||
'Debian', 'Ubuntu': {
|
||||
$package = 'openjdk-7-jre-headless'
|
||||
}
|
||||
default: {
|
||||
fail("\"${module_name}\" provides no java package
|
||||
for \"${::operatingsystem}\"")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$package = $elasticsearch::java_package
|
||||
}
|
||||
|
||||
## Install the java package unless already specified somewhere else
|
||||
if !defined(Package[$package]) {
|
||||
package { $package:
|
||||
ensure => present
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,145 @@
|
||||
# == 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 <mailto:richard@ispavailability.com>
|
||||
#
|
||||
class elasticsearch::package {
|
||||
|
||||
|
||||
#### 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) {
|
||||
|
||||
$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,
|
||||
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]
|
||||
|
||||
case $protocol_type {
|
||||
|
||||
puppet: {
|
||||
|
||||
file { "${package_dir}/${basefilename}":
|
||||
ensure => present,
|
||||
source => $elasticsearch::package_url,
|
||||
require => File[$package_dir],
|
||||
backup => false,
|
||||
before => Package[$elasticsearch::params::package]
|
||||
}
|
||||
|
||||
}
|
||||
ftp, https, http: {
|
||||
|
||||
exec { 'download_package_elasticsearch':
|
||||
command => "${elasticsearch::params::dlcmd} ${package_dir}/${basefilename} ${elasticsearch::package_url} 2> /dev/null",
|
||||
path => ['/usr/bin', '/bin'],
|
||||
creates => "${package_dir}/${basefilename}",
|
||||
require => File[$package_dir],
|
||||
before => Package[$elasticsearch::params::package]
|
||||
}
|
||||
|
||||
}
|
||||
file: {
|
||||
|
||||
$source_path = $sourceArray[1]
|
||||
file { "${package_dir}/${basefilename}":
|
||||
ensure => present,
|
||||
source => $source_path,
|
||||
require => File[$package_dir],
|
||||
backup => false,
|
||||
before => Package[$elasticsearch::params::package]
|
||||
}
|
||||
|
||||
}
|
||||
default: {
|
||||
fail("Protocol must be puppet, file, http, https, or ftp. You have given \"${protocol_type}\"")
|
||||
}
|
||||
}
|
||||
|
||||
case $ext {
|
||||
'deb': { $pkg_provider = 'dpkg' }
|
||||
'rpm': { $pkg_provider = 'rpm' }
|
||||
default: { fail("Unknown file extention \"${ext}\".") }
|
||||
}
|
||||
|
||||
$pkg_source = "${package_dir}/${basefilename}"
|
||||
|
||||
} else {
|
||||
$pkg_source = undef
|
||||
$pkg_provider = undef
|
||||
}
|
||||
|
||||
# Package removal
|
||||
} else {
|
||||
|
||||
$pkg_source = undef
|
||||
$pkg_provider = undef
|
||||
$package_ensure = 'purged'
|
||||
}
|
||||
|
||||
package { $elasticsearch::params::package:
|
||||
ensure => $package_ensure,
|
||||
source => $pkg_source,
|
||||
provider => $pkg_provider
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,122 @@
|
||||
# == 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 <mailto:richard@ispavailability.com>
|
||||
#
|
||||
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
|
||||
|
||||
# Package dir. Temporary place to download the package to for installation
|
||||
$package_dir = '/var/lib/elasticsearch'
|
||||
|
||||
# User and Group for the files and user to run the service as.
|
||||
$elasticsearch_user = 'elasticsearch'
|
||||
$elasticsearch_group = 'elasticsearch'
|
||||
|
||||
# Purge configuration directory
|
||||
$purge_confdir = true
|
||||
|
||||
## init service provider
|
||||
|
||||
# configuration directory
|
||||
$confdir = '/etc/elasticsearch'
|
||||
|
||||
# plugins directory
|
||||
$plugindir = '/usr/share/elasticsearch/plugins'
|
||||
|
||||
# plugins helper binary
|
||||
$plugintool = '/usr/share/elasticsearch/bin/plugin'
|
||||
|
||||
# Download tool
|
||||
$dlcmd = 'wget -O'
|
||||
|
||||
$purge_package_dir = false
|
||||
|
||||
#### Internal module values
|
||||
|
||||
# packages
|
||||
case $::operatingsystem {
|
||||
'RedHat', 'CentOS', 'Fedora', 'Scientific', 'Amazon', 'OracleLinux': {
|
||||
# main application
|
||||
$package = [ 'elasticsearch' ]
|
||||
}
|
||||
'Debian', 'Ubuntu': {
|
||||
# main application
|
||||
$package = [ 'elasticsearch' ]
|
||||
}
|
||||
default: {
|
||||
fail("\"${module_name}\" provides no package default value
|
||||
for \"${::operatingsystem}\"")
|
||||
}
|
||||
}
|
||||
|
||||
# service parameters
|
||||
case $::operatingsystem {
|
||||
'RedHat', 'CentOS', 'Fedora', 'Scientific', 'Amazon', 'OracleLinux': {
|
||||
$service_name = 'elasticsearch'
|
||||
$service_hasrestart = true
|
||||
$service_hasstatus = true
|
||||
$service_pattern = $service_name
|
||||
$service_providers = [ 'init' ]
|
||||
$defaults_location = '/etc/sysconfig'
|
||||
}
|
||||
'Debian', 'Ubuntu': {
|
||||
$service_name = 'elasticsearch'
|
||||
$service_hasrestart = true
|
||||
$service_hasstatus = true
|
||||
$service_pattern = $service_name
|
||||
$service_providers = [ 'init' ]
|
||||
$defaults_location = '/etc/default'
|
||||
}
|
||||
'Darwin': {
|
||||
$service_name = 'FIXME/TODO'
|
||||
$service_hasrestart = true
|
||||
$service_hasstatus = true
|
||||
$service_pattern = $service_name
|
||||
$service_providers = [ 'launchd' ]
|
||||
$defaults_location = false
|
||||
}
|
||||
default: {
|
||||
fail("\"${module_name}\" provides no service parameters
|
||||
for \"${::operatingsystem}\"")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,96 @@
|
||||
# == 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
|
||||
#
|
||||
#
|
||||
# === 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 <mailto:matteo.sessa@catchoftheday.com.au>
|
||||
# * Dennis Konert <mailto:dkonert@gmail.com>
|
||||
#
|
||||
define elasticsearch::plugin(
|
||||
$module_dir,
|
||||
$ensure = 'present',
|
||||
$url = ''
|
||||
) {
|
||||
|
||||
Exec {
|
||||
path => [ '/bin', '/usr/bin', '/usr/local/bin' ],
|
||||
cwd => '/',
|
||||
}
|
||||
|
||||
$notify_service = $elasticsearch::restart_on_change ? {
|
||||
false => undef,
|
||||
default => Service['elasticsearch'],
|
||||
}
|
||||
|
||||
if ($module_dir != '') {
|
||||
validate_string($module_dir)
|
||||
} else {
|
||||
fail("module_dir undefined for plugin ${name}")
|
||||
}
|
||||
|
||||
if ($url != '') {
|
||||
validate_string($url)
|
||||
$install_cmd = "${elasticsearch::plugintool} -install ${name} -url ${url}"
|
||||
$exec_rets = [0,1]
|
||||
} else {
|
||||
$install_cmd = "${elasticsearch::plugintool} -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 => Class['elasticsearch::package']
|
||||
}
|
||||
}
|
||||
default: {
|
||||
exec {"remove_plugin_${name}":
|
||||
command => "${elasticsearch::plugintool} --remove ${module_dir}",
|
||||
onlyif => "test -d ${elasticsearch::plugindir}/${module_dir}",
|
||||
notify => $notify_service,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,73 @@
|
||||
# == 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 <tt>present</tt> or
|
||||
# <tt>absent</tt>. If set to <tt>absent</tt>:
|
||||
# * 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 <tt>present</tt>.
|
||||
|
||||
#
|
||||
#
|
||||
# === Examples
|
||||
#
|
||||
# elasticsearch::python { 'pyes':; }
|
||||
#
|
||||
#
|
||||
# === Authors
|
||||
#
|
||||
# * Richard Pijnenburg <mailto:richard@ispavailability.com>
|
||||
#
|
||||
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 { $name:
|
||||
ensure => $ensure,
|
||||
provider => $provider,
|
||||
}
|
||||
|
||||
}
|
@@ -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 <tt>present</tt> or
|
||||
# <tt>absent</tt>. If set to <tt>absent</tt>:
|
||||
# * 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 <tt>present</tt>.
|
||||
|
||||
#
|
||||
#
|
||||
# === Examples
|
||||
#
|
||||
# elasticsearch::ruby { 'elasticsearch':; }
|
||||
#
|
||||
#
|
||||
# === Authors
|
||||
#
|
||||
# * Richard Pijnenburg <mailto:richard@ispavailability.com>
|
||||
#
|
||||
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'
|
||||
}
|
||||
default: {
|
||||
fail("unknown ruby client package '${name}'")
|
||||
}
|
||||
}
|
||||
|
||||
package { $name:
|
||||
ensure => $ensure,
|
||||
provider => $provider,
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,43 @@
|
||||
# == Class: elasticsearch::service
|
||||
#
|
||||
# This class exists to coordinate all service management related actions,
|
||||
# functionality and logical units in a central place.
|
||||
#
|
||||
# <b>Note:</b> "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
|
||||
#
|
||||
# This class does not provide any parameters.
|
||||
#
|
||||
#
|
||||
# === Examples
|
||||
#
|
||||
# This class may be imported by other classes to use its functionality:
|
||||
# class { 'elasticsearch::service': }
|
||||
#
|
||||
# It is not intended to be used directly by external resources like node
|
||||
# definitions or other modules.
|
||||
#
|
||||
#
|
||||
# === Authors
|
||||
#
|
||||
# * Richard Pijnenburg <mailto:richard@ispavailability.com>
|
||||
#
|
||||
class elasticsearch::service {
|
||||
|
||||
case $elasticsearch::service_provider {
|
||||
|
||||
init: {
|
||||
elasticsearch::service::init { 'elasticsearch': }
|
||||
}
|
||||
|
||||
default: {
|
||||
fail("Unknown service provider ${elasticsearch::service_provider}")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,132 @@
|
||||
# == Define: elasticsearch::service::init
|
||||
#
|
||||
# This class exists to coordinate all service management related actions,
|
||||
# functionality and logical units in a central place.
|
||||
#
|
||||
# <b>Note:</b> "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
|
||||
#
|
||||
# This class does not provide any parameters.
|
||||
#
|
||||
#
|
||||
# === Examples
|
||||
#
|
||||
# === Authors
|
||||
#
|
||||
# * Richard Pijnenburg <mailto:richard@ispavailability.com>
|
||||
#
|
||||
define elasticsearch::service::init{
|
||||
|
||||
#### Service management
|
||||
|
||||
# set params: in operation
|
||||
if $elasticsearch::ensure == 'present' {
|
||||
|
||||
case $elasticsearch::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("\"${elasticsearch::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[$name],
|
||||
false => undef,
|
||||
}
|
||||
|
||||
|
||||
if ( $elasticsearch::status != 'unmanaged' ) {
|
||||
|
||||
# defaults file content. Either from a hash or file
|
||||
if ($elasticsearch::init_defaults_file != undef) {
|
||||
$defaults_content = undef
|
||||
$defaults_source = $elasticsearch::init_defaults_file
|
||||
} elsif ($elasticsearch::init_defaults != undef and is_hash($elasticsearch::init_defaults) ) {
|
||||
$defaults_content = template("${module_name}/etc/sysconfig/defaults.erb")
|
||||
$defaults_source = undef
|
||||
} else {
|
||||
$defaults_content = undef
|
||||
$defaults_source = undef
|
||||
}
|
||||
|
||||
# Check if we are going to manage the defaults file.
|
||||
if ( $defaults_content != undef or $defaults_source != undef ) {
|
||||
|
||||
file { "${elasticsearch::params::defaults_location}/${name}":
|
||||
ensure => $elasticsearch::ensure,
|
||||
source => $defaults_source,
|
||||
content => $defaults_content,
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
mode => '0644',
|
||||
before => Service[$name],
|
||||
notify => $notify_service
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
# init file from template
|
||||
if ($elasticsearch::init_template != undef) {
|
||||
|
||||
file { "/etc/init.d/${name}":
|
||||
ensure => $elasticsearch::ensure,
|
||||
content => template($elasticsearch::init_template),
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
mode => '0755',
|
||||
before => Service[$name],
|
||||
notify => $notify_service
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
# action
|
||||
service { $name:
|
||||
ensure => $service_ensure,
|
||||
enable => $service_enable,
|
||||
name => $elasticsearch::params::service_name,
|
||||
hasstatus => $elasticsearch::params::service_hasstatus,
|
||||
hasrestart => $elasticsearch::params::service_hasrestart,
|
||||
pattern => $elasticsearch::params::service_pattern,
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,114 @@
|
||||
# == Define: elasticsearch::template
|
||||
#
|
||||
# This define allows you to insert, update or delete templates that are used within Elasticsearch for the indexes
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# [*file*]
|
||||
# File path of the template ( json file )
|
||||
# Value type is string
|
||||
# Default value: undef
|
||||
# This variable is optional
|
||||
#
|
||||
# [*replace*]
|
||||
# Set to 'true' if you intend to replace the existing template
|
||||
# Value type is boolean
|
||||
# Default value: false
|
||||
# This variable is optional
|
||||
#
|
||||
# [*delete*]
|
||||
# Set to 'true' if you intend to delete the existing template
|
||||
# Value type is boolean
|
||||
# Default value: false
|
||||
# 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 <mailto:richard@ispavailability.com>
|
||||
#
|
||||
define elasticsearch::template(
|
||||
$ensure = 'present',
|
||||
$file = 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 => 3,
|
||||
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 is supplied
|
||||
if $file == undef {
|
||||
fail('The variable "file" cannot be empty 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 == 'present') {
|
||||
|
||||
# place the template file
|
||||
file { "${elasticsearch::confdir}/templates_import/elasticsearch-template-${name}.json":
|
||||
ensure => 'present',
|
||||
source => $file,
|
||||
notify => Exec[ "delete_template_${name}" ],
|
||||
require => Exec[ 'mkdir_templates' ],
|
||||
}
|
||||
|
||||
exec { "insert_template_${name}":
|
||||
command => "curl -s -XPUT ${es_url} -d @${elasticsearch::confdir}/templates_import/elasticsearch-template-${name}.json",
|
||||
unless => "test $(curl -s '${es_url}?pretty=true' | wc -l) -gt 1",
|
||||
refreshonly => true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,219 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'elasticsearch', :type => 'class' do
|
||||
|
||||
[ 'Debian', 'Ubuntu'].each do |distro|
|
||||
|
||||
context "on #{distro} OS" do
|
||||
|
||||
let :facts do {
|
||||
:operatingsystem => distro
|
||||
} end
|
||||
|
||||
context 'main class tests' do
|
||||
|
||||
# init.pp
|
||||
it { should contain_class('elasticsearch::package') }
|
||||
it { should contain_class('elasticsearch::config') }
|
||||
it { should contain_class('elasticsearch::service') }
|
||||
|
||||
end
|
||||
|
||||
context 'package installation' do
|
||||
|
||||
context 'via repository' do
|
||||
|
||||
context 'with default settings' do
|
||||
|
||||
it { should contain_package('elasticsearch').with(:ensure => 'present') }
|
||||
|
||||
end
|
||||
|
||||
context 'with specified version' do
|
||||
|
||||
let :params do {
|
||||
:version => '1.0'
|
||||
} end
|
||||
|
||||
it { should contain_package('elasticsearch').with(:ensure => '1.0') }
|
||||
end
|
||||
|
||||
context 'with auto upgrade enabled' do
|
||||
|
||||
let :params do {
|
||||
:autoupgrade => true
|
||||
} end
|
||||
|
||||
it { should contain_package('elasticsearch').with(:ensure => 'latest') }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'when setting package version and package_url' do
|
||||
|
||||
let :params do {
|
||||
:version => '0.90.10',
|
||||
:package_url => 'puppet:///path/to/some/elasticsearch-0.90.10.deb'
|
||||
} end
|
||||
|
||||
it { expect { should raise_error(Puppet::Error) } }
|
||||
|
||||
end
|
||||
|
||||
context 'via package_url setting' do
|
||||
|
||||
context 'using puppet:/// schema' do
|
||||
|
||||
let :params do {
|
||||
:package_url => 'puppet:///path/to/package.deb'
|
||||
} end
|
||||
|
||||
it { should contain_file('/var/lib/elasticsearch/package.deb').with(:source => 'puppet:///path/to/package.deb', :backup => false) }
|
||||
it { should contain_package('elasticsearch').with(:ensure => 'present', :source => '/var/lib/elasticsearch/package.deb', :provider => 'dpkg') }
|
||||
end
|
||||
|
||||
context 'using http:// schema' do
|
||||
|
||||
let :params do {
|
||||
:package_url => 'http://www.domain.com/path/to/package.deb'
|
||||
} end
|
||||
|
||||
it { should contain_exec('create_package_dir_elasticsearch').with(:command => 'mkdir -p /var/lib/elasticsearch') }
|
||||
it { should contain_file('/var/lib/elasticsearch').with(:purge => false, :force => false, :require => "Exec[create_package_dir_elasticsearch]") }
|
||||
it { should contain_exec('download_package_elasticsearch').with(:command => 'wget -O /var/lib/elasticsearch/package.deb http://www.domain.com/path/to/package.deb 2> /dev/null', :require => 'File[/var/lib/elasticsearch]') }
|
||||
it { should contain_package('elasticsearch').with(:ensure => 'present', :source => '/var/lib/elasticsearch/package.deb', :provider => 'dpkg') }
|
||||
end
|
||||
|
||||
context 'using https:// schema' do
|
||||
|
||||
let :params do {
|
||||
:package_url => 'https://www.domain.com/path/to/package.deb'
|
||||
} end
|
||||
|
||||
it { should contain_exec('create_package_dir_elasticsearch').with(:command => 'mkdir -p /var/lib/elasticsearch') }
|
||||
it { should contain_file('/var/lib/elasticsearch').with(:purge => false, :force => false, :require => 'Exec[create_package_dir_elasticsearch]') }
|
||||
it { should contain_exec('download_package_elasticsearch').with(:command => 'wget -O /var/lib/elasticsearch/package.deb https://www.domain.com/path/to/package.deb 2> /dev/null', :require => 'File[/var/lib/elasticsearch]') }
|
||||
it { should contain_package('elasticsearch').with(:ensure => 'present', :source => '/var/lib/elasticsearch/package.deb', :provider => 'dpkg') }
|
||||
end
|
||||
|
||||
context 'using ftp:// schema' do
|
||||
|
||||
let :params do {
|
||||
:package_url => 'ftp://www.domain.com/path/to/package.deb'
|
||||
} end
|
||||
|
||||
it { should contain_exec('create_package_dir_elasticsearch').with(:command => 'mkdir -p /var/lib/elasticsearch') }
|
||||
it { should contain_file('/var/lib/elasticsearch').with(:purge => false, :force => false, :require => 'Exec[create_package_dir_elasticsearch]') }
|
||||
it { should contain_exec('download_package_elasticsearch').with(:command => 'wget -O /var/lib/elasticsearch/package.deb ftp://www.domain.com/path/to/package.deb 2> /dev/null', :require => 'File[/var/lib/elasticsearch]') }
|
||||
it { should contain_package('elasticsearch').with(:ensure => 'present', :source => '/var/lib/elasticsearch/package.deb', :provider => 'dpkg') }
|
||||
end
|
||||
|
||||
context 'using file:// schema' do
|
||||
|
||||
let :params do {
|
||||
:package_url => 'file:/path/to/package.deb'
|
||||
} end
|
||||
|
||||
it { should contain_exec('create_package_dir_elasticsearch').with(:command => 'mkdir -p /var/lib/elasticsearch') }
|
||||
it { should contain_file('/var/lib/elasticsearch').with(:purge => false, :force => false, :require => 'Exec[create_package_dir_elasticsearch]') }
|
||||
it { should contain_file('/var/lib/elasticsearch/package.deb').with(:source => '/path/to/package.deb', :backup => false) }
|
||||
it { should contain_package('elasticsearch').with(:ensure => 'present', :source => '/var/lib/elasticsearch/package.deb', :provider => 'dpkg') }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end # package
|
||||
|
||||
context 'service setup' do
|
||||
|
||||
context 'with provider \'init\'' do
|
||||
|
||||
context 'and default settings' do
|
||||
|
||||
it { should contain_service('elasticsearch').with(:ensure => 'running') }
|
||||
|
||||
end
|
||||
|
||||
context 'and set defaults via hash param' do
|
||||
|
||||
let :params do {
|
||||
:init_defaults => { 'SERVICE_USER' => 'root', 'SERVICE_GROUP' => 'root' }
|
||||
} end
|
||||
|
||||
it { should contain_file('/etc/default/elasticsearch').with(:content => "### MANAGED BY PUPPET ###\n\nSERVICE_GROUP=root\nSERVICE_USER=root\n", :notify => 'Service[elasticsearch]') }
|
||||
|
||||
end
|
||||
|
||||
context 'and set defaults via file param' do
|
||||
|
||||
let :params do {
|
||||
:init_defaults_file => 'puppet:///path/to/elasticsearch.defaults'
|
||||
} end
|
||||
|
||||
it { should contain_file('/etc/default/elasticsearch').with(:source => 'puppet:///path/to/elasticsearch.defaults', :notify => 'Service[elasticsearch]') }
|
||||
|
||||
end
|
||||
|
||||
context 'no service restart when defaults change' do
|
||||
|
||||
let :params do {
|
||||
:init_defaults => { 'SERVICE_USER' => 'root', 'SERVICE_GROUP' => 'root' },
|
||||
:restart_on_change => false
|
||||
} end
|
||||
|
||||
it { should contain_file('/etc/default/elasticsearch').with(:content => "### MANAGED BY PUPPET ###\n\nSERVICE_GROUP=root\nSERVICE_USER=root\n").without_notify }
|
||||
|
||||
end
|
||||
|
||||
context 'and set init file via template' do
|
||||
|
||||
let :params do {
|
||||
:init_template => "elasticsearch/etc/init.d/elasticsearch.Debian.erb"
|
||||
} end
|
||||
|
||||
it { should contain_file('/etc/init.d/elasticsearch').with(:notify => 'Service[elasticsearch]') }
|
||||
|
||||
end
|
||||
|
||||
context 'No service restart when restart_on_change is false' do
|
||||
|
||||
let :params do {
|
||||
:init_template => "elasticsearch/etc/init.d/elasticsearch.Debian.erb",
|
||||
:restart_on_change => false
|
||||
} end
|
||||
|
||||
it { should contain_file('/etc/init.d/elasticsearch').without_notify }
|
||||
|
||||
end
|
||||
|
||||
context 'when its unmanaged do nothing with it' do
|
||||
|
||||
let :params do {
|
||||
:status => 'unmanaged'
|
||||
} end
|
||||
|
||||
it { should contain_service('elasticsearch').with(:ensure => nil, :enable => false) }
|
||||
|
||||
end
|
||||
|
||||
end # provider init
|
||||
|
||||
end # Services
|
||||
|
||||
context 'when setting the module to absent' do
|
||||
|
||||
let :params do {
|
||||
:ensure => 'absent'
|
||||
} end
|
||||
|
||||
it { should contain_file('/etc/elasticsearch').with(:ensure => 'absent', :force => true, :recurse => true) }
|
||||
it { should contain_package('elasticsearch').with(:ensure => 'purged') }
|
||||
it { should contain_service('elasticsearch').with(:ensure => 'stopped', :enable => false) }
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
@@ -0,0 +1,219 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'elasticsearch', :type => 'class' do
|
||||
|
||||
[ 'RedHat', 'CentOS', 'Fedora', 'Scientific', 'Amazon', 'OracleLinux' ].each do |distro|
|
||||
|
||||
context "on #{distro} OS" do
|
||||
|
||||
let :facts do {
|
||||
:operatingsystem => distro
|
||||
} end
|
||||
|
||||
context 'Main class' do
|
||||
|
||||
# init.pp
|
||||
it { should contain_class('elasticsearch::package') }
|
||||
it { should contain_class('elasticsearch::config') }
|
||||
it { should contain_class('elasticsearch::service') }
|
||||
|
||||
end
|
||||
|
||||
context 'package installation' do
|
||||
|
||||
context 'via repository' do
|
||||
|
||||
context 'with default settings' do
|
||||
|
||||
it { should contain_package('elasticsearch').with(:ensure => 'present') }
|
||||
|
||||
end
|
||||
|
||||
context 'with specified version' do
|
||||
|
||||
let :params do {
|
||||
:version => '1.0'
|
||||
} end
|
||||
|
||||
it { should contain_package('elasticsearch').with(:ensure => '1.0') }
|
||||
end
|
||||
|
||||
context 'with auto upgrade enabled' do
|
||||
|
||||
let :params do {
|
||||
:autoupgrade => true
|
||||
} end
|
||||
|
||||
it { should contain_package('elasticsearch').with(:ensure => 'latest') }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'when setting package version and package_url' do
|
||||
|
||||
let :params do {
|
||||
:version => '0.90.10',
|
||||
:package_url => 'puppet:///path/to/some/elasticsearch-0.90.10.rpm'
|
||||
} end
|
||||
|
||||
it { expect { should raise_error(Puppet::Error) } }
|
||||
|
||||
end
|
||||
|
||||
context 'via package_url setting' do
|
||||
|
||||
context 'using puppet:/// schema' do
|
||||
|
||||
let :params do {
|
||||
:package_url => 'puppet:///path/to/package.rpm'
|
||||
} end
|
||||
|
||||
it { should contain_file('/var/lib/elasticsearch/package.rpm').with(:source => 'puppet:///path/to/package.rpm', :backup => false) }
|
||||
it { should contain_package('elasticsearch').with(:ensure => 'present', :source => '/var/lib/elasticsearch/package.rpm', :provider => 'rpm') }
|
||||
end
|
||||
|
||||
context 'using http:// schema' do
|
||||
|
||||
let :params do {
|
||||
:package_url => 'http://www.domain.com/path/to/package.rpm'
|
||||
} end
|
||||
|
||||
it { should contain_exec('create_package_dir_elasticsearch').with(:command => 'mkdir -p /var/lib/elasticsearch') }
|
||||
it { should contain_file('/var/lib/elasticsearch').with(:purge => false, :force => false, :require => "Exec[create_package_dir_elasticsearch]") }
|
||||
it { should contain_exec('download_package_elasticsearch').with(:command => 'wget -O /var/lib/elasticsearch/package.rpm http://www.domain.com/path/to/package.rpm 2> /dev/null', :require => 'File[/var/lib/elasticsearch]') }
|
||||
it { should contain_package('elasticsearch').with(:ensure => 'present', :source => '/var/lib/elasticsearch/package.rpm', :provider => 'rpm') }
|
||||
end
|
||||
|
||||
context 'using https:// schema' do
|
||||
|
||||
let :params do {
|
||||
:package_url => 'https://www.domain.com/path/to/package.rpm'
|
||||
} end
|
||||
|
||||
it { should contain_exec('create_package_dir_elasticsearch').with(:command => 'mkdir -p /var/lib/elasticsearch') }
|
||||
it { should contain_file('/var/lib/elasticsearch').with(:purge => false, :force => false, :require => 'Exec[create_package_dir_elasticsearch]') }
|
||||
it { should contain_exec('download_package_elasticsearch').with(:command => 'wget -O /var/lib/elasticsearch/package.rpm https://www.domain.com/path/to/package.rpm 2> /dev/null', :require => 'File[/var/lib/elasticsearch]') }
|
||||
it { should contain_package('elasticsearch').with(:ensure => 'present', :source => '/var/lib/elasticsearch/package.rpm', :provider => 'rpm') }
|
||||
end
|
||||
|
||||
context 'using ftp:// schema' do
|
||||
|
||||
let :params do {
|
||||
:package_url => 'ftp://www.domain.com/path/to/package.rpm'
|
||||
} end
|
||||
|
||||
it { should contain_exec('create_package_dir_elasticsearch').with(:command => 'mkdir -p /var/lib/elasticsearch') }
|
||||
it { should contain_file('/var/lib/elasticsearch').with(:purge => false, :force => false, :require => 'Exec[create_package_dir_elasticsearch]') }
|
||||
it { should contain_exec('download_package_elasticsearch').with(:command => 'wget -O /var/lib/elasticsearch/package.rpm ftp://www.domain.com/path/to/package.rpm 2> /dev/null', :require => 'File[/var/lib/elasticsearch]') }
|
||||
it { should contain_package('elasticsearch').with(:ensure => 'present', :source => '/var/lib/elasticsearch/package.rpm', :provider => 'rpm') }
|
||||
end
|
||||
|
||||
context 'using file:// schema' do
|
||||
|
||||
let :params do {
|
||||
:package_url => 'file:/path/to/package.rpm'
|
||||
} end
|
||||
|
||||
it { should contain_exec('create_package_dir_elasticsearch').with(:command => 'mkdir -p /var/lib/elasticsearch') }
|
||||
it { should contain_file('/var/lib/elasticsearch').with(:purge => false, :force => false, :require => 'Exec[create_package_dir_elasticsearch]') }
|
||||
it { should contain_file('/var/lib/elasticsearch/package.rpm').with(:source => '/path/to/package.rpm', :backup => false) }
|
||||
it { should contain_package('elasticsearch').with(:ensure => 'present', :source => '/var/lib/elasticsearch/package.rpm', :provider => 'rpm') }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end # package
|
||||
|
||||
context 'service setup' do
|
||||
|
||||
context 'with provider \'init\'' do
|
||||
|
||||
context 'and default settings' do
|
||||
|
||||
it { should contain_service('elasticsearch').with(:ensure => 'running') }
|
||||
|
||||
end
|
||||
|
||||
context 'and set defaults via hash param' do
|
||||
|
||||
let :params do {
|
||||
:init_defaults => { 'SERVICE_USER' => 'root', 'SERVICE_GROUP' => 'root' }
|
||||
} end
|
||||
|
||||
it { should contain_file('/etc/sysconfig/elasticsearch').with(:content => "### MANAGED BY PUPPET ###\n\nSERVICE_GROUP=root\nSERVICE_USER=root\n", :notify => 'Service[elasticsearch]') }
|
||||
|
||||
end
|
||||
|
||||
context 'and set defaults via file param' do
|
||||
|
||||
let :params do {
|
||||
:init_defaults_file => 'puppet:///path/to/elasticsearch.defaults'
|
||||
} end
|
||||
|
||||
it { should contain_file('/etc/sysconfig/elasticsearch').with(:source => 'puppet:///path/to/elasticsearch.defaults', :notify => 'Service[elasticsearch]') }
|
||||
|
||||
end
|
||||
|
||||
context 'no service restart when defaults change' do
|
||||
|
||||
let :params do {
|
||||
:init_defaults => { 'SERVICE_USER' => 'root', 'SERVICE_GROUP' => 'root' },
|
||||
:restart_on_change => false
|
||||
} end
|
||||
|
||||
it { should contain_file('/etc/sysconfig/elasticsearch').with(:content => "### MANAGED BY PUPPET ###\n\nSERVICE_GROUP=root\nSERVICE_USER=root\n").without_notify }
|
||||
|
||||
end
|
||||
|
||||
context 'and set init file via template' do
|
||||
|
||||
let :params do {
|
||||
:init_template => "elasticsearch/etc/init.d/elasticsearch.RedHat.erb"
|
||||
} end
|
||||
|
||||
it { should contain_file('/etc/init.d/elasticsearch').with(:notify => 'Service[elasticsearch]') }
|
||||
|
||||
end
|
||||
|
||||
context 'No service restart when restart_on_change is false' do
|
||||
|
||||
let :params do {
|
||||
:init_template => "elasticsearch/etc/init.d/elasticsearch.RedHat.erb",
|
||||
:restart_on_change => false
|
||||
} end
|
||||
|
||||
it { should contain_file('/etc/init.d/elasticsearch').without_notify }
|
||||
|
||||
end
|
||||
|
||||
context 'when its unmanaged do nothing with it' do
|
||||
|
||||
let :params do {
|
||||
:status => 'unmanaged'
|
||||
} end
|
||||
|
||||
it { should contain_service('elasticsearch').with(:ensure => nil, :enable => false) }
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end # Services
|
||||
|
||||
context 'when setting the module to absent' do
|
||||
|
||||
let :params do {
|
||||
:ensure => 'absent'
|
||||
} end
|
||||
|
||||
it { should contain_file('/etc/elasticsearch').with(:ensure => 'absent', :force => true, :recurse => true) }
|
||||
it { should contain_package('elasticsearch').with(:ensure => 'purged') }
|
||||
it { should contain_service('elasticsearch').with(:ensure => 'stopped', :enable => false) }
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
@@ -0,0 +1,18 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'elasticsearch', :type => 'class' do
|
||||
|
||||
context "on an unknown OS" do
|
||||
|
||||
context "it should fail" do
|
||||
let :facts do {
|
||||
:operatingsystem => 'Windows'
|
||||
} end
|
||||
|
||||
it { expect { should raise_error(Puppet::Error) } }
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
@@ -0,0 +1,112 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'elasticsearch', :type => 'class' do
|
||||
|
||||
let :facts do {
|
||||
:operatingsystem => 'CentOS'
|
||||
} end
|
||||
|
||||
context "config file content" do
|
||||
|
||||
context "with nothing set" do
|
||||
|
||||
let :params do {
|
||||
} end
|
||||
|
||||
it { should contain_file('/etc/elasticsearch/elasticsearch.yml').with(:content => "### MANAGED BY PUPPET ###\n") }
|
||||
|
||||
end
|
||||
|
||||
context "set a value" do
|
||||
|
||||
let :params do {
|
||||
:config => { 'node' => { 'name' => 'test' } }
|
||||
} end
|
||||
|
||||
it { should contain_file('/etc/elasticsearch/elasticsearch.yml').with(:content => "### MANAGED BY PUPPET ###\n---\nnode: \n name: test\n") }
|
||||
|
||||
end
|
||||
|
||||
context "set a value to true" do
|
||||
|
||||
let :params do {
|
||||
:config => { 'node' => { 'master' => true } }
|
||||
} end
|
||||
|
||||
it { should contain_file('/etc/elasticsearch/elasticsearch.yml').with(:content => "### MANAGED BY PUPPET ###\n---\nnode: \n master: true\n") }
|
||||
|
||||
end
|
||||
|
||||
context "set a value to false" do
|
||||
|
||||
let :params do {
|
||||
:config => { 'node' => { 'data' => false } }
|
||||
} end
|
||||
|
||||
it { should contain_file('/etc/elasticsearch/elasticsearch.yml').with(:content => "### MANAGED BY PUPPET ###\n---\nnode: \n data: false\n") }
|
||||
|
||||
end
|
||||
|
||||
context "deeper hash and multiple keys" do
|
||||
|
||||
let :params do {
|
||||
:config => { 'index' => { 'routing' => { 'allocation' => { 'include' => 'tag1', 'exclude' => [ 'tag2', 'tag3' ] } } }, 'node' => { 'name' => 'somename' } }
|
||||
} end
|
||||
|
||||
it { should contain_file('/etc/elasticsearch/elasticsearch.yml').with(:content => "### MANAGED BY PUPPET ###\n---\nindex: \n routing: \n allocation: \n exclude: \n - tag2\n - tag3\n include: tag1\nnode: \n name: somename\n") }
|
||||
|
||||
end
|
||||
|
||||
context "Combination of full hash and shorted write up keys" do
|
||||
|
||||
let :params do {
|
||||
:config => { 'node' => { 'name' => 'NodeName', 'rack' => 46 }, 'boostrap.mlockall' => true, 'cluster' => { 'name' => 'ClusterName', 'routing.allocation.awareness.attributes' => 'rack' }, 'discovery.zen' => { 'ping.unicast.hosts'=> [ "host1", "host2" ], 'minimum_master_nodes' => 3, 'ping.multicast.enabled' => false }, 'gateway' => { 'expected_nodes' => 4, 'recover_after_nodes' => 3 }, 'network.host' => '123.123.123.123' }
|
||||
} end
|
||||
|
||||
it { should contain_file('/etc/elasticsearch/elasticsearch.yml').with(:content => "### MANAGED BY PUPPET ###\n---\nboostrap: \n mlockall: true\ncluster: \n name: ClusterName\n routing: \n allocation: \n awareness: \n attributes: rack\ndiscovery: \n zen: \n minimum_master_nodes: 3\n ping: \n multicast: \n enabled: false\n unicast: \n hosts: \n - host1\n - host2\ngateway: \n expected_nodes: 4\n recover_after_nodes: 3\nnetwork: \n host: 123.123.123.123\nnode: \n name: NodeName\n rack: 46\n") }
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context "service restarts" do
|
||||
|
||||
let :facts do {
|
||||
:operatingsystem => 'CentOS'
|
||||
} end
|
||||
|
||||
context "does not restart when restart_on_change is false" do
|
||||
let :params do {
|
||||
:config => { 'node' => { 'name' => 'test' } },
|
||||
:restart_on_change => false,
|
||||
} end
|
||||
|
||||
it { should contain_file('/etc/elasticsearch/elasticsearch.yml').without_notify }
|
||||
end
|
||||
|
||||
context "should happen restart_on_change is true (default)" do
|
||||
let :params do {
|
||||
:config => { 'node' => { 'name' => 'test' } },
|
||||
:restart_on_change => true,
|
||||
} end
|
||||
|
||||
it { should contain_file('/etc/elasticsearch/elasticsearch.yml').with(:notify => "Class[Elasticsearch::Service]") }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'data directory' do
|
||||
let(:facts) do {
|
||||
:operatingsystem => 'CentOS'
|
||||
} end
|
||||
|
||||
context 'should allow creating datadir' do
|
||||
let(:params) do {
|
||||
:datadir => '/foo'
|
||||
} end
|
||||
|
||||
it { should contain_file('/foo').with(:ensure => 'directory') }
|
||||
end
|
||||
|
||||
end
|
||||
end
|
@@ -0,0 +1,120 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'elasticsearch', :type => 'class' do
|
||||
|
||||
context "install java" do
|
||||
|
||||
let :params do {
|
||||
:java_install => true,
|
||||
:config => { 'node' => { 'name' => 'test' } }
|
||||
} end
|
||||
|
||||
context "On Debian OS" do
|
||||
|
||||
let :facts do {
|
||||
:operatingsystem => 'Debian'
|
||||
} end
|
||||
|
||||
it { should contain_package('openjdk-7-jre-headless') }
|
||||
|
||||
end
|
||||
|
||||
context "On Ubuntu OS" do
|
||||
|
||||
let :facts do {
|
||||
:operatingsystem => 'Ubuntu'
|
||||
} end
|
||||
|
||||
it { should contain_package('openjdk-7-jre-headless') }
|
||||
|
||||
end
|
||||
|
||||
context "On CentOS OS " do
|
||||
|
||||
let :facts do {
|
||||
:operatingsystem => 'CentOS'
|
||||
} end
|
||||
|
||||
it { should contain_package('java-1.7.0-openjdk') }
|
||||
|
||||
end
|
||||
|
||||
context "On RedHat OS " do
|
||||
|
||||
let :facts do {
|
||||
:operatingsystem => 'Redhat'
|
||||
} end
|
||||
|
||||
it { should contain_package('java-1.7.0-openjdk') }
|
||||
|
||||
end
|
||||
|
||||
context "On Fedora OS " do
|
||||
|
||||
let :facts do {
|
||||
:operatingsystem => 'Fedora'
|
||||
} end
|
||||
|
||||
it { should contain_package('java-1.7.0-openjdk') }
|
||||
|
||||
end
|
||||
|
||||
context "On Scientific OS " do
|
||||
|
||||
let :facts do {
|
||||
:operatingsystem => 'Scientific'
|
||||
} end
|
||||
|
||||
it { should contain_package('java-1.7.0-openjdk') }
|
||||
|
||||
end
|
||||
|
||||
context "On Amazon OS " do
|
||||
|
||||
let :facts do {
|
||||
:operatingsystem => 'Amazon'
|
||||
} end
|
||||
|
||||
it { should contain_package('java-1.7.0-openjdk') }
|
||||
|
||||
end
|
||||
|
||||
context "On OracleLinux OS " do
|
||||
|
||||
let :facts do {
|
||||
:operatingsystem => 'OracleLinux'
|
||||
} end
|
||||
|
||||
it { should contain_package('java-1.7.0-openjdk') }
|
||||
|
||||
end
|
||||
|
||||
context "On an unknown OS" do
|
||||
|
||||
let :facts do {
|
||||
:operatingsystem => 'Windows'
|
||||
} end
|
||||
|
||||
it { expect { should raise_error(Puppet::Error) } }
|
||||
|
||||
end
|
||||
|
||||
context "Custom java package" do
|
||||
|
||||
let :facts do {
|
||||
:operatingsystem => 'CentOS'
|
||||
} end
|
||||
|
||||
let :params do {
|
||||
:java_install => true,
|
||||
:java_package => 'java-1.6.0-openjdk',
|
||||
:config => { 'node' => { 'name' => 'test' } }
|
||||
} end
|
||||
|
||||
it { should contain_package('java-1.6.0-openjdk') }
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
@@ -0,0 +1,19 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'elasticsearch::python', :type => 'define' do
|
||||
|
||||
let(:facts) { {:operatingsystem => 'CentOS' }}
|
||||
|
||||
[ 'pyes', 'rawes', 'pyelasticsearch', 'ESClient', 'elasticutils', 'elasticsearch' ].each do |pythonlib|
|
||||
|
||||
context "installation of library #{pythonlib}" do
|
||||
|
||||
let(:title) { pythonlib }
|
||||
|
||||
it { should contain_package(pythonlib).with(:provider => 'pip') }
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
@@ -0,0 +1,19 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'elasticsearch::ruby', :type => 'define' do
|
||||
|
||||
let(:facts) { {:operatingsystem => 'CentOS' }}
|
||||
|
||||
[ 'tire', 'stretcher', 'elastic_searchable', 'elasticsearch'].each do |rubylib|
|
||||
|
||||
context "installation of library #{rubylib}" do
|
||||
|
||||
let(:title) { rubylib }
|
||||
|
||||
it { should contain_package(rubylib).with(:provider => 'gem') }
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
@@ -0,0 +1,43 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'elasticsearch::template', :type => 'define' do
|
||||
|
||||
let(:title) { 'foo' }
|
||||
let(:facts) { {:operatingsystem => 'CentOS' }}
|
||||
let(:pre_condition) { 'class {"elasticsearch": config => { "node" => {"name" => "test" }}}'}
|
||||
|
||||
context "Add a template" do
|
||||
|
||||
let :params do {
|
||||
:ensure => 'present',
|
||||
:file => 'puppet:///path/to/foo.json',
|
||||
} end
|
||||
|
||||
it { should contain_file('/etc/elasticsearch/templates_import/elasticsearch-template-foo.json').with(:source => 'puppet:///path/to/foo.json', :notify => "Exec[delete_template_foo]", :require => "Exec[mkdir_templates]") }
|
||||
it { should contain_exec('insert_template_foo').with(:command => 'curl -s -XPUT http://localhost:9200/_template/foo -d @/etc/elasticsearch/templates_import/elasticsearch-template-foo.json', :unless => 'test $(curl -s \'http://localhost:9200/_template/foo?pretty=true\' | wc -l) -gt 1') }
|
||||
end
|
||||
|
||||
context "Delete a template" do
|
||||
|
||||
let :params do {
|
||||
:ensure => 'absent'
|
||||
} end
|
||||
|
||||
it { should_not contain_file('/etc/elasticsearch/templates_import/elasticsearch-template-foo.json').with(:source => 'puppet:///path/to/foo.json') }
|
||||
it { should_not contain_exec('insert_template_foo') }
|
||||
it { should contain_exec('delete_template_foo').with(:command => 'curl -s -XDELETE http://localhost:9200/_template/foo', :notify => nil, :onlyif => 'test $(curl -s \'http://localhost:9200/_template/foo?pretty=true\' | wc -l) -gt 1' ) }
|
||||
end
|
||||
|
||||
context "Add template with alternative host and port" do
|
||||
|
||||
let :params do {
|
||||
:file => 'puppet:///path/to/foo.json',
|
||||
:host => 'otherhost',
|
||||
:port => '9201'
|
||||
} end
|
||||
|
||||
it { should contain_file('/etc/elasticsearch/templates_import/elasticsearch-template-foo.json').with(:source => 'puppet:///path/to/foo.json') }
|
||||
it { should contain_exec('insert_template_foo').with(:command => 'curl -s -XPUT http://otherhost:9201/_template/foo -d @/etc/elasticsearch/templates_import/elasticsearch-template-foo.json', :unless => 'test $(curl -s \'http://otherhost:9201/_template/foo?pretty=true\' | wc -l) -gt 1') }
|
||||
end
|
||||
|
||||
end
|
@@ -0,0 +1,29 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'elasticsearch::plugin', :type => 'define' do
|
||||
|
||||
let(:title) { 'mobz/elasticsearch-head' }
|
||||
let(:facts) { {:operatingsystem => 'CentOS' }}
|
||||
let(:pre_condition) { 'class {"elasticsearch": config => { "node" => {"name" => "test" }}}'}
|
||||
|
||||
context "Add a plugin" do
|
||||
|
||||
let :params do {
|
||||
:ensure => 'present',
|
||||
:module_dir => 'head',
|
||||
} end
|
||||
|
||||
it { should contain_exec('install_plugin_mobz/elasticsearch-head').with(:command => '/usr/share/elasticsearch/bin/plugin -install mobz/elasticsearch-head', :creates => '/usr/share/elasticsearch/plugins/head') }
|
||||
end
|
||||
|
||||
context "Remove a plugin" do
|
||||
|
||||
let :params do {
|
||||
:ensure => 'absent',
|
||||
:module_dir => 'head'
|
||||
} end
|
||||
|
||||
it { should contain_exec('remove_plugin_mobz/elasticsearch-head').with(:command => '/usr/share/elasticsearch/bin/plugin --remove head', :onlyif => 'test -d /usr/share/elasticsearch/plugins/head') }
|
||||
end
|
||||
|
||||
end
|
@@ -0,0 +1,40 @@
|
||||
require 'find'
|
||||
require 'pathname'
|
||||
require 'rake'
|
||||
require 'rspec/core/rake_task'
|
||||
|
||||
desc "run Puppet parser validate"
|
||||
task :parser_validate do
|
||||
|
||||
pwd = ENV["PWD"]
|
||||
puppet_file_paths = []
|
||||
Find.find(pwd) do |path|
|
||||
puppet_file_paths << path if path =~ /.*\.pp$/
|
||||
end
|
||||
|
||||
exit_code = 0
|
||||
puppet_file_paths.each do |puppetfile|
|
||||
|
||||
pwdpath = Pathname.new(pwd)
|
||||
pn = Pathname.new(puppetfile)
|
||||
rel_path = pn.relative_path_from(pwdpath)
|
||||
|
||||
print "Validating #{rel_path}.... "
|
||||
$stdout.flush
|
||||
|
||||
result = `puppet parser validate #{puppetfile}`
|
||||
if $?.exitstatus == 0
|
||||
res = 'OK'
|
||||
else
|
||||
res = 'ERR'
|
||||
end
|
||||
|
||||
puts "#{res}"
|
||||
|
||||
if $?.exitstatus != 0
|
||||
exit_code = 1
|
||||
end
|
||||
end
|
||||
exit exit_code
|
||||
|
||||
end
|
@@ -0,0 +1,31 @@
|
||||
require 'find'
|
||||
require 'pathname'
|
||||
require 'rake'
|
||||
require 'rspec/core/rake_task'
|
||||
|
||||
desc "Verify puppet templates"
|
||||
task :template_verify do
|
||||
|
||||
pwd = ENV["PWD"]
|
||||
erb_file_paths = []
|
||||
Find.find(pwd) do |path|
|
||||
erb_file_paths << path if path =~ /.*\.erb$/
|
||||
end
|
||||
|
||||
exit_code = 0
|
||||
erb_file_paths.each do |erbfile|
|
||||
|
||||
pwdpath = Pathname.new(pwd)
|
||||
pn = Pathname.new(erbfile)
|
||||
rel_path = pn.relative_path_from(pwdpath)
|
||||
|
||||
result = `erb -P -x -T '-' #{erbfile} | ruby -c`
|
||||
puts "Verifying #{rel_path}.... #{result}"
|
||||
|
||||
if $?.exitstatus != 0
|
||||
exit_code = 1
|
||||
end
|
||||
end
|
||||
exit exit_code
|
||||
|
||||
end
|
@@ -0,0 +1,2 @@
|
||||
require 'rubygems'
|
||||
require 'puppetlabs_spec_helper/module_spec_helper'
|
@@ -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 !scope.lookupvar('elasticsearch::config').empty?
|
||||
|
||||
@yml_string += "---\n"
|
||||
|
||||
## Transform shorted keys into full write up
|
||||
transformed_config = transform(scope.lookupvar('elasticsearch::config'))
|
||||
|
||||
# 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 -%>
|
@@ -0,0 +1,196 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# /etc/init.d/elasticsearch -- startup script for Elasticsearch
|
||||
#
|
||||
# Written by Miquel van Smoorenburg <miquels@cistron.nl>.
|
||||
# Modified for Debian GNU/Linux by Ian Murdock <imurdock@gnu.ai.mit.edu>.
|
||||
# Modified for Tomcat by Stefan Gybas <sgybas@debian.org>.
|
||||
# Modified for Tomcat6 by Thierry Carrez <thierry.carrez@ubuntu.com>.
|
||||
# Additional improvements by Jason Brittain <jason.brittain@mulesoft.com>.
|
||||
# Modified by Nicolas Huray for ElasticSearch <nicolas.huray@gmail.com>.
|
||||
#
|
||||
### BEGIN INIT INFO
|
||||
# Provides: elasticsearch
|
||||
# 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
|
||||
# Description: Starts elasticsearch using start-stop-daemon
|
||||
### END INIT INFO
|
||||
|
||||
PATH=/bin:/usr/bin:/sbin:/usr/sbin
|
||||
NAME=elasticsearch
|
||||
DESC="ElasticSearch Server"
|
||||
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
|
||||
|
||||
# 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="-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
|
||||
|
||||
# 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
|
||||
|
||||
# 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
|
@@ -0,0 +1,155 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# elasticsearch <summary>
|
||||
#
|
||||
# chkconfig: 2345 80 20
|
||||
# description: Starts and stops a single elasticsearch instance on this system
|
||||
#
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: Elasticsearch
|
||||
# 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"
|
||||
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
|
||||
|
||||
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 "$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 -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 $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 $?
|
@@ -0,0 +1,5 @@
|
||||
### MANAGED BY PUPPET ###
|
||||
|
||||
<% scope.lookupvar('elasticsearch::init_defaults').sort.map do |key, value| -%>
|
||||
<%= key %>=<%= value %>
|
||||
<% end -%>
|
Reference in New Issue
Block a user