|
1 # == Class: elasticsearch::config |
|
2 # |
|
3 # This class exists to coordinate all configuration related actions, |
|
4 # functionality and logical units in a central place. |
|
5 # |
|
6 # |
|
7 # === Parameters |
|
8 # |
|
9 # This class does not provide any parameters. |
|
10 # |
|
11 # |
|
12 # === Examples |
|
13 # |
|
14 # This class may be imported by other classes to use its functionality: |
|
15 # class { 'elasticsearch::config': } |
|
16 # |
|
17 # It is not intended to be used directly by external resources like node |
|
18 # definitions or other modules. |
|
19 # |
|
20 # |
|
21 # === Authors |
|
22 # |
|
23 # * Richard Pijnenburg <mailto:richard.pijnenburg@elasticsearch.com> |
|
24 # |
|
25 class elasticsearch::config { |
|
26 |
|
27 #### Configuration |
|
28 |
|
29 File { |
|
30 owner => $elasticsearch::elasticsearch_user, |
|
31 group => $elasticsearch::elasticsearch_group, |
|
32 } |
|
33 |
|
34 Exec { |
|
35 path => [ '/bin', '/usr/bin', '/usr/local/bin' ], |
|
36 cwd => '/', |
|
37 } |
|
38 |
|
39 if ( $elasticsearch::ensure == 'present' ) { |
|
40 |
|
41 $notify_service = $elasticsearch::restart_on_change ? { |
|
42 true => Class['elasticsearch::service'], |
|
43 false => undef, |
|
44 } |
|
45 |
|
46 file { $elasticsearch::configdir: |
|
47 ensure => directory, |
|
48 mode => '0644', |
|
49 } |
|
50 |
|
51 file { $elasticsearch::params::logdir: |
|
52 ensure => 'directory', |
|
53 group => undef, |
|
54 mode => '0644', |
|
55 recurse => true, |
|
56 } |
|
57 |
|
58 file { $elasticsearch::params::homedir: |
|
59 ensure => 'directory', |
|
60 } |
|
61 |
|
62 file { "${elasticsearch::params::homedir}/bin": |
|
63 ensure => 'directory', |
|
64 recurse => true, |
|
65 mode => '0755', |
|
66 } |
|
67 |
|
68 file { $elasticsearch::datadir: |
|
69 ensure => 'directory', |
|
70 } |
|
71 |
|
72 file { "${elasticsearch::homedir}/lib": |
|
73 ensure => 'directory', |
|
74 recurse => true, |
|
75 } |
|
76 |
|
77 if $elasticsearch::params::pid_dir { |
|
78 file { $elasticsearch::params::pid_dir: |
|
79 ensure => 'directory', |
|
80 group => undef, |
|
81 recurse => true, |
|
82 } |
|
83 |
|
84 if ($elasticsearch::service_providers == 'systemd') { |
|
85 $user = $elasticsearch::elasticsearch_user |
|
86 $group = $elasticsearch::elasticsearch_group |
|
87 $pid_dir = $elasticsearch::params::pid_dir |
|
88 |
|
89 file { '/usr/lib/tmpfiles.d/elasticsearch.conf': |
|
90 ensure => 'file', |
|
91 content => template("${module_name}/usr/lib/tmpfiles.d/elasticsearch.conf.erb"), |
|
92 owner => 'root', |
|
93 group => 'root', |
|
94 } |
|
95 } |
|
96 } |
|
97 |
|
98 |
|
99 file { "${elasticsearch::params::homedir}/templates_import": |
|
100 ensure => 'directory', |
|
101 mode => '0644', |
|
102 } |
|
103 |
|
104 file { "${elasticsearch::params::homedir}/scripts": |
|
105 ensure => 'directory', |
|
106 mode => '0644', |
|
107 } |
|
108 |
|
109 # Removal of files that are provided with the package which we don't use |
|
110 file { '/etc/init.d/elasticsearch': |
|
111 ensure => 'absent', |
|
112 } |
|
113 file { '/lib/systemd/system/elasticsearch.service': |
|
114 ensure => 'absent', |
|
115 } |
|
116 |
|
117 $new_init_defaults = { 'CONF_DIR' => $elasticsearch::configdir } |
|
118 augeas { "${elasticsearch::params::defaults_location}/elasticsearch": |
|
119 incl => "${elasticsearch::params::defaults_location}/elasticsearch", |
|
120 lens => 'Shellvars.lns', |
|
121 changes => template("${module_name}/etc/sysconfig/defaults.erb"), |
|
122 } |
|
123 |
|
124 file { '/etc/elasticsearch/elasticsearch.yml': |
|
125 ensure => 'absent', |
|
126 } |
|
127 file { '/etc/elasticsearch/logging.yml': |
|
128 ensure => 'absent', |
|
129 } |
|
130 |
|
131 } elsif ( $elasticsearch::ensure == 'absent' ) { |
|
132 |
|
133 file { $elasticsearch::plugindir: |
|
134 ensure => 'absent', |
|
135 force => true, |
|
136 backup => false, |
|
137 } |
|
138 |
|
139 } |
|
140 |
|
141 } |