Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: modules/elasticsearch/manifests/init.pp

Issue 29327597: Issue 2864 - Introduce class elasticsearch (Closed)
Patch Set: Created Sept. 14, 2015, 7:26 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « hiera/roles/elasticsearch.yaml ('k') | modules/elasticsearch/manifests/plugin.pp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # == Class: elasticsearch
2 #
3 # Manage Elasticsearch (https://www.elastic.co/products/elasticsearch)
4 # installations via APT.
5 #
6 # === Parameters:
7 #
8 # [*directory*]
9 # The root directory of the Elasticsearch installation.
10 #
11 # [*ensure*]
12 # Either 'present'/'stopped', 'running'/'started', or 'absent'/'purged'.
13 # Note that Service['elasticsearch'] is only realized implicitly when
14 # $ensure is neither 'absent' nor 'purged'.
15 #
16 # [*java_packages*]
17 # A list of package names required to ensure a JDK for running the
18 # Elasticsearch service being present.
19 #
20 # [*plugins*]
21 # A hash of elasticsearch::plugin setups to ensure implicitly.
22 #
23 # [*settings*]
24 # A hash of options that translate directly into entires in the global
25 # Elasticsearch configuration file.
26 #
27 # [*version*]
28 # The http://packages.elasticsearch.org/elasticsearch/%s/debian $version.
29 #
30 # === Examples:
31 #
32 # class {'elasticsearch':
33 # }
34 #
35 class elasticsearch (
36 $directory = '/usr/share/elasticsearch',
37 $ensure = 'running',
38 $java_packages = ['openjdk-7-jre'],
39 $plugins = {},
40 $settings = {},
41 $version = '1.6',
42 ) {
43
44 $ensure_file = $ensure ? {
45 /^(absent|purged)$/ => 'absent',
46 default => 'present',
47 }
48
49 ensure_packages($java_packages)
50
51 apt::key {'elasticsearch':
52 ensure => $ensure_file,
53 key => 'D88E42B4',
54 key_content => template('elasticsearch/elasticsearch-gpg-key.erb'),
55 }
56
57 apt::source {'elasticsearch':
58 ensure => $ensure_file,
59 include_src => false,
60 location => "http://packages.elasticsearch.org/elasticsearch/$version/debian ",
61 release => 'stable',
62 require => Apt::Key['elasticsearch'],
63 }
64
65 package {'elasticsearch':
66 ensure => $ensure_file,
67 require => Apt::Source['elasticsearch'],
68 }
69
70 @service {'elasticsearch':
71 enable => $ensure ? {
72 /^(absent|purged)$/ => false,
73 default => true,
74 },
75 ensure => $ensure ? {
76 /^(running|started)$/ => 'running',
77 default => 'stopped',
78 },
79 hasrestart => true,
80 require => Package['elasticsearch'],
81 subscribe => Package[$java_packages],
82 }
83
84 file {'elasticsearch.yml':
85 content => template('elasticsearch/config.yml.erb'),
86 ensure => $ensure_file,
87 notify => Service['elasticsearch'],
88 path => '/etc/elasticsearch/elasticsearch.yml',
89 require => Package['elasticsearch'],
90 }
91
92 if $ensure !~ /^(absent|purged)$/ {
93 realize(Service['elasticsearch'])
94 }
95
96 create_resources('elasticsearch::plugin', $plugins)
97 }
OLDNEW
« no previous file with comments | « hiera/roles/elasticsearch.yaml ('k') | modules/elasticsearch/manifests/plugin.pp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld