safeguard-devise 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. checksums.yaml +15 -0
  2. data/.vagrant/machines/default/virtualbox/action_provision +1 -0
  3. data/.vagrant/machines/default/virtualbox/action_set_name +1 -0
  4. data/.vagrant/machines/default/virtualbox/id +1 -0
  5. data/Gemfile +25 -0
  6. data/Gemfile.lock +186 -0
  7. data/Rakefile +51 -0
  8. data/VERSION +1 -0
  9. data/Vagrantfile +128 -0
  10. data/app/controllers/devise/devise_safeguard_controller.rb +56 -0
  11. data/app/views/devise/verify_safeguard.html.erb +9 -0
  12. data/app/views/devise/verify_safeguard.html.haml +7 -0
  13. data/config/locales/pt-BR.yml +5 -0
  14. data/lib/devise-safeguard/controllers/helpers.rb +54 -0
  15. data/lib/devise-safeguard/hooks/safeguard_authenticatable.rb +7 -0
  16. data/lib/devise-safeguard/models/safeguard_authenticatable.rb +18 -0
  17. data/lib/devise-safeguard/rails.rb +7 -0
  18. data/lib/devise-safeguard/routes.rb +17 -0
  19. data/lib/generators/active_record/devise_safeguard_generator.rb +13 -0
  20. data/lib/generators/active_record/templates/migration.rb +15 -0
  21. data/lib/generators/devise_safeguard/devise_safeguard_generator.rb +30 -0
  22. data/lib/generators/devise_safeguard/install_generator.rb +44 -0
  23. data/lib/safeguard-devise.rb +24 -0
  24. data/puppet/manifests/default.pp +66 -0
  25. data/puppet/modules/elasticsearch/CHANGELOG +62 -0
  26. data/puppet/modules/elasticsearch/CONTRIBUTORS +20 -0
  27. data/puppet/modules/elasticsearch/LICENSE +13 -0
  28. data/puppet/modules/elasticsearch/Modulefile +9 -0
  29. data/puppet/modules/elasticsearch/README.md +147 -0
  30. data/puppet/modules/elasticsearch/Rakefile +5 -0
  31. data/puppet/modules/elasticsearch/manifests/config.pp +64 -0
  32. data/puppet/modules/elasticsearch/manifests/init.pp +208 -0
  33. data/puppet/modules/elasticsearch/manifests/java.pp +50 -0
  34. data/puppet/modules/elasticsearch/manifests/package.pp +84 -0
  35. data/puppet/modules/elasticsearch/manifests/params.pp +103 -0
  36. data/puppet/modules/elasticsearch/manifests/plugin.pp +97 -0
  37. data/puppet/modules/elasticsearch/manifests/python.pp +34 -0
  38. data/puppet/modules/elasticsearch/manifests/service.pp +114 -0
  39. data/puppet/modules/elasticsearch/manifests/template.pp +118 -0
  40. data/puppet/modules/elasticsearch/metadata.json +41 -0
  41. data/puppet/modules/elasticsearch/spec/classes/elasticsearch_init_spec.rb +596 -0
  42. data/puppet/modules/elasticsearch/spec/defines/template_spec.rb +66 -0
  43. data/puppet/modules/elasticsearch/spec/spec_helper.rb +2 -0
  44. data/puppet/modules/elasticsearch/templates/etc/default/elasticsearch.erb +5 -0
  45. data/puppet/modules/elasticsearch/templates/etc/elasticsearch/elasticsearch.yml.erb +93 -0
  46. data/puppet/modules/memcached/.gitignore +2 -0
  47. data/puppet/modules/memcached/Modulefile +8 -0
  48. data/puppet/modules/memcached/README.md +29 -0
  49. data/puppet/modules/memcached/manifests/init.pp +33 -0
  50. data/puppet/modules/memcached/manifests/params.pp +21 -0
  51. data/puppet/modules/memcached/templates/memcached.conf.erb +46 -0
  52. data/puppet/modules/memcached/templates/memcached_sysconfig.erb +5 -0
  53. data/puppet/modules/mysql/.fixtures.yml +3 -0
  54. data/puppet/modules/mysql/.gemfile +5 -0
  55. data/puppet/modules/mysql/LICENSE +201 -0
  56. data/puppet/modules/mysql/Modulefile +8 -0
  57. data/puppet/modules/mysql/README.md +124 -0
  58. data/puppet/modules/mysql/files/mysqltuner.pl +966 -0
  59. data/puppet/modules/mysql/lib/puppet/parser/functions/mysql_password.rb +15 -0
  60. data/puppet/modules/mysql/lib/puppet/provider/database/mysql.rb +42 -0
  61. data/puppet/modules/mysql/lib/puppet/provider/database_grant/mysql.rb +177 -0
  62. data/puppet/modules/mysql/lib/puppet/provider/database_user/mysql.rb +42 -0
  63. data/puppet/modules/mysql/lib/puppet/type/database.rb +17 -0
  64. data/puppet/modules/mysql/lib/puppet/type/database_grant.rb +75 -0
  65. data/puppet/modules/mysql/lib/puppet/type/database_user.rb +25 -0
  66. data/puppet/modules/mysql/manifests/backup.pp +68 -0
  67. data/puppet/modules/mysql/manifests/config.pp +122 -0
  68. data/puppet/modules/mysql/manifests/db.pp +77 -0
  69. data/puppet/modules/mysql/manifests/init.pp +24 -0
  70. data/puppet/modules/mysql/manifests/java.pp +24 -0
  71. data/puppet/modules/mysql/manifests/params.pp +91 -0
  72. data/puppet/modules/mysql/manifests/python.pp +26 -0
  73. data/puppet/modules/mysql/manifests/ruby.pp +28 -0
  74. data/puppet/modules/mysql/manifests/server/account_security.pp +13 -0
  75. data/puppet/modules/mysql/manifests/server/monitor.pp +19 -0
  76. data/puppet/modules/mysql/manifests/server/mysqltuner.pp +22 -0
  77. data/puppet/modules/mysql/manifests/server.pp +52 -0
  78. data/puppet/modules/mysql/templates/my.cnf.erb +42 -0
  79. data/puppet/modules/mysql/templates/my.cnf.pass.erb +6 -0
  80. data/puppet/modules/mysql/templates/mysqlbackup.sh.erb +23 -0
  81. data/puppet/modules/postgresql/GPL-3 +674 -0
  82. data/puppet/modules/postgresql/Modulefile +13 -0
  83. data/puppet/modules/postgresql/README.md +156 -0
  84. data/puppet/modules/postgresql/lib/puppet/provider/pg_database/debian_postgresql.rb +30 -0
  85. data/puppet/modules/postgresql/lib/puppet/provider/pg_database/default.rb +17 -0
  86. data/puppet/modules/postgresql/lib/puppet/provider/pg_user/debian_postgresql.rb +63 -0
  87. data/puppet/modules/postgresql/lib/puppet/provider/pg_user/default.rb +17 -0
  88. data/puppet/modules/postgresql/lib/puppet/type/pg_database.rb +29 -0
  89. data/puppet/modules/postgresql/lib/puppet/type/pg_user.rb +45 -0
  90. data/puppet/modules/postgresql/manifests/db.pp +20 -0
  91. data/puppet/modules/postgresql/manifests/init.pp +12 -0
  92. data/puppet/modules/postgresql/manifests/params.pp +15 -0
  93. data/puppet/modules/postgresql/manifests/server.pp +47 -0
  94. data/puppet/modules/postgresql/templates/pg_hba.conf.erb +105 -0
  95. data/puppet/modules/postgresql/templates/postgresql.conf.erb +559 -0
  96. data/puppet/modules/redis/CHANGELOG +41 -0
  97. data/puppet/modules/redis/Gemfile +7 -0
  98. data/puppet/modules/redis/Gemfile.lock +18 -0
  99. data/puppet/modules/redis/Modulefile +10 -0
  100. data/puppet/modules/redis/README.md +34 -0
  101. data/puppet/modules/redis/Rakefile +6 -0
  102. data/puppet/modules/redis/manifests/init.pp +153 -0
  103. data/puppet/modules/redis/manifests/params.pp +39 -0
  104. data/puppet/modules/redis/metadata.json +31 -0
  105. data/puppet/modules/redis/spec/spec_helper.rb +17 -0
  106. data/puppet/modules/redis/templates/redis.debian.conf.erb +217 -0
  107. data/puppet/modules/redis/templates/redis.logrotate.erb +9 -0
  108. data/puppet/modules/redis/templates/redis.rhel.conf.erb +547 -0
  109. data/puppet/modules/redis/tests/init.pp +8 -0
  110. data/puppet/upgrade-puppet.sh +16 -0
  111. data/safeguard-devise.gemspec +249 -0
  112. data/spec/controllers/safeguard_devise_controller_spec.rb +67 -0
  113. data/spec/devise/safeguard_authenticatable_spec.rb +71 -0
  114. data/spec/orm/active_record.rb +4 -0
  115. data/spec/routing/routes_spec.rb +13 -0
  116. data/spec/safeguard-devise-test-app/.gitignore +16 -0
  117. data/spec/safeguard-devise-test-app/Gemfile +14 -0
  118. data/spec/safeguard-devise-test-app/Gemfile.lock +119 -0
  119. data/spec/safeguard-devise-test-app/README.rdoc +28 -0
  120. data/spec/safeguard-devise-test-app/Rakefile +6 -0
  121. data/spec/safeguard-devise-test-app/app/assets/images/.keep +0 -0
  122. data/spec/safeguard-devise-test-app/app/assets/javascripts/application.js +13 -0
  123. data/spec/safeguard-devise-test-app/app/assets/stylesheets/application.css +13 -0
  124. data/spec/safeguard-devise-test-app/app/controllers/application_controller.rb +5 -0
  125. data/spec/safeguard-devise-test-app/app/controllers/concerns/.keep +0 -0
  126. data/spec/safeguard-devise-test-app/app/controllers/home_controller.rb +6 -0
  127. data/spec/safeguard-devise-test-app/app/helpers/application_helper.rb +2 -0
  128. data/spec/safeguard-devise-test-app/app/mailers/.keep +0 -0
  129. data/spec/safeguard-devise-test-app/app/models/.keep +0 -0
  130. data/spec/safeguard-devise-test-app/app/models/concerns/.keep +0 -0
  131. data/spec/safeguard-devise-test-app/app/models/user.rb +6 -0
  132. data/spec/safeguard-devise-test-app/app/views/devise/devise_safeguard/verify_safeguard.html.erb +9 -0
  133. data/spec/safeguard-devise-test-app/app/views/devise/devise_safeguard/verify_safeguard.html.haml +6 -0
  134. data/spec/safeguard-devise-test-app/app/views/home/index.html.erb +1 -0
  135. data/spec/safeguard-devise-test-app/app/views/layouts/application.html.erb +14 -0
  136. data/spec/safeguard-devise-test-app/bin/bundle +3 -0
  137. data/spec/safeguard-devise-test-app/bin/rails +4 -0
  138. data/spec/safeguard-devise-test-app/bin/rake +4 -0
  139. data/spec/safeguard-devise-test-app/config/application.rb +31 -0
  140. data/spec/safeguard-devise-test-app/config/boot.rb +4 -0
  141. data/spec/safeguard-devise-test-app/config/database.yml +25 -0
  142. data/spec/safeguard-devise-test-app/config/environment.rb +5 -0
  143. data/spec/safeguard-devise-test-app/config/environments/development.rb +29 -0
  144. data/spec/safeguard-devise-test-app/config/environments/production.rb +80 -0
  145. data/spec/safeguard-devise-test-app/config/environments/test.rb +36 -0
  146. data/spec/safeguard-devise-test-app/config/initializers/backtrace_silencers.rb +7 -0
  147. data/spec/safeguard-devise-test-app/config/initializers/devise.rb +259 -0
  148. data/spec/safeguard-devise-test-app/config/initializers/filter_parameter_logging.rb +4 -0
  149. data/spec/safeguard-devise-test-app/config/initializers/inflections.rb +16 -0
  150. data/spec/safeguard-devise-test-app/config/initializers/mime_types.rb +5 -0
  151. data/spec/safeguard-devise-test-app/config/initializers/secret_token.rb +12 -0
  152. data/spec/safeguard-devise-test-app/config/initializers/session_store.rb +3 -0
  153. data/spec/safeguard-devise-test-app/config/initializers/wrap_parameters.rb +14 -0
  154. data/spec/safeguard-devise-test-app/config/locales/devise.en.yml +59 -0
  155. data/spec/safeguard-devise-test-app/config/locales/devise.safeguard.pt-BR.yml +5 -0
  156. data/spec/safeguard-devise-test-app/config/locales/en.yml +23 -0
  157. data/spec/safeguard-devise-test-app/config/routes.rb +59 -0
  158. data/spec/safeguard-devise-test-app/config.ru +4 -0
  159. data/spec/safeguard-devise-test-app/db/migrate/20140220191103_create_users.rb +9 -0
  160. data/spec/safeguard-devise-test-app/db/migrate/20140220191247_add_devise_to_users.rb +49 -0
  161. data/spec/safeguard-devise-test-app/db/migrate/20140220191522_devise_safeguard_add_to_users.rb +15 -0
  162. data/spec/safeguard-devise-test-app/db/schema.rb +37 -0
  163. data/spec/safeguard-devise-test-app/db/seeds.rb +7 -0
  164. data/spec/safeguard-devise-test-app/lib/assets/.keep +0 -0
  165. data/spec/safeguard-devise-test-app/lib/tasks/.keep +0 -0
  166. data/spec/safeguard-devise-test-app/log/.keep +0 -0
  167. data/spec/safeguard-devise-test-app/public/404.html +58 -0
  168. data/spec/safeguard-devise-test-app/public/422.html +58 -0
  169. data/spec/safeguard-devise-test-app/public/500.html +57 -0
  170. data/spec/safeguard-devise-test-app/public/favicon.ico +0 -0
  171. data/spec/safeguard-devise-test-app/public/robots.txt +5 -0
  172. data/spec/safeguard-devise-test-app/test/controllers/.keep +0 -0
  173. data/spec/safeguard-devise-test-app/test/fixtures/.keep +0 -0
  174. data/spec/safeguard-devise-test-app/test/fixtures/users.yml +9 -0
  175. data/spec/safeguard-devise-test-app/test/helpers/.keep +0 -0
  176. data/spec/safeguard-devise-test-app/test/integration/.keep +0 -0
  177. data/spec/safeguard-devise-test-app/test/mailers/.keep +0 -0
  178. data/spec/safeguard-devise-test-app/test/models/.keep +0 -0
  179. data/spec/safeguard-devise-test-app/test/models/user_test.rb +7 -0
  180. data/spec/safeguard-devise-test-app/test/test_helper.rb +15 -0
  181. data/spec/safeguard-devise-test-app/vendor/assets/javascripts/.keep +0 -0
  182. data/spec/safeguard-devise-test-app/vendor/assets/stylesheets/.keep +0 -0
  183. data/spec/spec_helper.rb +31 -0
  184. data/spec/tests_helper/helpers.rb +34 -0
  185. metadata +381 -0
@@ -0,0 +1,596 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'elasticsearch', :type => 'class' do
4
+
5
+ let :params do {
6
+ :config => { 'node' => { 'name' => 'test' } }
7
+ } end
8
+
9
+ context "On Debian OS" do
10
+
11
+ let :facts do {
12
+ :operatingsystem => 'Debian'
13
+ } end
14
+
15
+ # init.pp
16
+ it { should contain_class('elasticsearch::package') }
17
+ it { should contain_class('elasticsearch::config') }
18
+ it { should contain_class('elasticsearch::service') }
19
+
20
+ # package.pp
21
+ it { should contain_package('elasticsearch') }
22
+
23
+ # service.pp
24
+ it { should contain_service('elasticsearch') }
25
+
26
+ # config.pp
27
+
28
+ end
29
+
30
+ context "On Ubuntu OS" do
31
+
32
+ let :facts do {
33
+ :operatingsystem => 'Ubuntu'
34
+ } end
35
+
36
+ # init.pp
37
+ it { should contain_class('elasticsearch::package') }
38
+ it { should contain_class('elasticsearch::config') }
39
+ it { should contain_class('elasticsearch::service') }
40
+
41
+ # package.pp
42
+ it { should contain_package('elasticsearch') }
43
+
44
+ # service.pp
45
+ it { should contain_service('elasticsearch') }
46
+
47
+ # config.pp
48
+
49
+ end
50
+
51
+ context "On CentOS OS" do
52
+
53
+ let :facts do {
54
+ :operatingsystem => 'CentOS'
55
+ } end
56
+
57
+ # init.pp
58
+ it { should contain_class('elasticsearch::package') }
59
+ it { should contain_class('elasticsearch::config') }
60
+ it { should contain_class('elasticsearch::service') }
61
+
62
+ # package.pp
63
+ it { should contain_package('elasticsearch') }
64
+
65
+ # service.pp
66
+ it { should contain_service('elasticsearch') }
67
+
68
+ # config.pp
69
+
70
+ end
71
+
72
+ context "On RedHat OS" do
73
+
74
+ let :facts do {
75
+ :operatingsystem => 'Redhat'
76
+ } end
77
+
78
+ # init.pp
79
+ it { should contain_class('elasticsearch::package') }
80
+ it { should contain_class('elasticsearch::config') }
81
+ it { should contain_class('elasticsearch::service') }
82
+
83
+ # package.pp
84
+ it { should contain_package('elasticsearch') }
85
+
86
+ # service.pp
87
+ it { should contain_service('elasticsearch') }
88
+
89
+ # config.pp
90
+
91
+ end
92
+
93
+ context "On Fedora OS" do
94
+
95
+ let :facts do {
96
+ :operatingsystem => 'Fedora'
97
+ } end
98
+
99
+ # init.pp
100
+ it { should contain_class('elasticsearch::package') }
101
+ it { should contain_class('elasticsearch::config') }
102
+ it { should contain_class('elasticsearch::service') }
103
+
104
+ # package.pp
105
+ it { should contain_package('elasticsearch') }
106
+
107
+ # service.pp
108
+ it { should contain_service('elasticsearch') }
109
+
110
+ # config.pp
111
+
112
+ end
113
+
114
+ context "On Scientific OS" do
115
+
116
+ let :facts do {
117
+ :operatingsystem => 'Scientific'
118
+ } end
119
+
120
+ # init.pp
121
+ it { should contain_class('elasticsearch::package') }
122
+ it { should contain_class('elasticsearch::config') }
123
+ it { should contain_class('elasticsearch::service') }
124
+
125
+ # package.pp
126
+ it { should contain_package('elasticsearch') }
127
+
128
+ # service.pp
129
+ it { should contain_service('elasticsearch') }
130
+
131
+ # config.pp
132
+
133
+ end
134
+
135
+ context "On Amazon OS" do
136
+
137
+ let :facts do {
138
+ :operatingsystem => 'Amazon'
139
+ } end
140
+
141
+ # init.pp
142
+ it { should contain_class('elasticsearch::package') }
143
+ it { should contain_class('elasticsearch::config') }
144
+ it { should contain_class('elasticsearch::service') }
145
+
146
+ # package.pp
147
+ it { should contain_package('elasticsearch') }
148
+
149
+ # service.pp
150
+ it { should contain_service('elasticsearch') }
151
+
152
+ # config.pp
153
+
154
+ end
155
+
156
+ context "On OracleLinux OS" do
157
+
158
+ let :facts do {
159
+ :operatingsystem => 'OracleLinux'
160
+ } end
161
+
162
+ # init.pp
163
+ it { should contain_class('elasticsearch::package') }
164
+ it { should contain_class('elasticsearch::config') }
165
+ it { should contain_class('elasticsearch::service') }
166
+
167
+ # package.pp
168
+ it { should contain_package('elasticsearch') }
169
+
170
+ # service.pp
171
+ it { should contain_service('elasticsearch') }
172
+
173
+ # config.pp
174
+
175
+ end
176
+
177
+ context "On an unknown OS" do
178
+
179
+ let :facts do {
180
+ :operatingsystem => 'Darwin'
181
+ } end
182
+
183
+ it { expect { should raise_error(Puppet::Error) } }
184
+
185
+ end
186
+
187
+ context "install using an alternative package source" do
188
+
189
+ context "with a debian package" do
190
+
191
+ let :facts do {
192
+ :operatingsystem => 'Debian'
193
+ } end
194
+
195
+ let :params do {
196
+ :pkg_source => 'puppet:///path/to/package.deb',
197
+ :config => { 'node' => { 'name' => 'test' } }
198
+ } end
199
+
200
+ it { should contain_file('/tmp/package.deb').with(:source => 'puppet:///path/to/package.deb') }
201
+
202
+ it { should contain_package('elasticsearch').with(:source => '/tmp/package.deb', :provider => 'dpkg') }
203
+
204
+ end
205
+
206
+ context "with a redhat package" do
207
+
208
+ let :facts do {
209
+ :operatingsystem => 'CentOS'
210
+ } end
211
+
212
+ let :params do {
213
+ :pkg_source => 'puppet:///path/to/package.rpm',
214
+ :config => { 'node' => { 'name' => 'test' } }
215
+ } end
216
+
217
+ it { should contain_file('/tmp/package.rpm').with(:source => 'puppet:///path/to/package.rpm') }
218
+
219
+ it { should contain_package('elasticsearch').with(:source => '/tmp/package.rpm', :provider => 'rpm') }
220
+
221
+ end
222
+
223
+ context "with an unsupported package" do
224
+
225
+ let :facts do {
226
+ :operatingsystem => 'CentOS'
227
+ } end
228
+
229
+ let :params do {
230
+ :pkg_source => 'puppet:///path/to/package.yaml',
231
+ :config => { 'node' => { 'name' => 'test' } }
232
+ } end
233
+
234
+ it { expect { should raise_error(Puppet::Error) } }
235
+
236
+ end
237
+
238
+ end
239
+
240
+ context "install java" do
241
+
242
+ let :params do {
243
+ :java_install => true,
244
+ :config => { 'node' => { 'name' => 'test' } }
245
+ } end
246
+
247
+ context "On a Debian OS" do
248
+
249
+ let :facts do {
250
+ :operatingsystem => 'Debian'
251
+ } end
252
+
253
+ it { should contain_package('openjdk-6-jre-headless') }
254
+
255
+ end
256
+
257
+ context "On an Ubuntu OS" do
258
+
259
+ let :facts do {
260
+ :operatingsystem => 'Ubuntu'
261
+ } end
262
+
263
+ it { should contain_package('openjdk-6-jre-headless') }
264
+
265
+ end
266
+
267
+ context "On a CentOS OS " do
268
+
269
+ let :facts do {
270
+ :operatingsystem => 'CentOS'
271
+ } end
272
+
273
+ it { should contain_package('java-1.6.0-openjdk') }
274
+
275
+ end
276
+
277
+ context "On a RedHat OS " do
278
+
279
+ let :facts do {
280
+ :operatingsystem => 'Redhat'
281
+ } end
282
+
283
+ it { should contain_package('java-1.6.0-openjdk') }
284
+
285
+ end
286
+
287
+ context "On a Fedora OS " do
288
+
289
+ let :facts do {
290
+ :operatingsystem => 'Fedora'
291
+ } end
292
+
293
+ it { should contain_package('java-1.6.0-openjdk') }
294
+
295
+ end
296
+
297
+ context "On a Scientific OS " do
298
+
299
+ let :facts do {
300
+ :operatingsystem => 'Scientific'
301
+ } end
302
+
303
+ it { should contain_package('java-1.6.0-openjdk') }
304
+
305
+ end
306
+
307
+ context "On a Amazon OS " do
308
+
309
+ let :facts do {
310
+ :operatingsystem => 'Amazon'
311
+ } end
312
+
313
+ it { should contain_package('java-1.6.0-openjdk') }
314
+
315
+ end
316
+
317
+ context "On a OracleLinux OS " do
318
+
319
+ let :facts do {
320
+ :operatingsystem => 'OracleLinux'
321
+ } end
322
+
323
+ it { should contain_package('java-1.6.0-openjdk') }
324
+
325
+ end
326
+
327
+ context "On an unknown OS" do
328
+
329
+ let :facts do {
330
+ :operatingsystem => 'Darwin'
331
+ } end
332
+
333
+ it { expect { should raise_error(Puppet::Error) } }
334
+
335
+ end
336
+
337
+ context "Custom java package" do
338
+
339
+ let :facts do {
340
+ :operatingsystem => 'CentOS'
341
+ } end
342
+
343
+ let :params do {
344
+ :java_install => true,
345
+ :java_package => 'java-1.7.0-openjdk',
346
+ :config => { 'node' => { 'name' => 'test' } }
347
+ } end
348
+
349
+ it { should contain_package('java-1.7.0-openjdk') }
350
+
351
+ end
352
+
353
+ end
354
+
355
+ context "test restarts on configuration change" do
356
+
357
+ let :facts do {
358
+ :operatingsystem => 'CentOS'
359
+ } end
360
+
361
+ context "does not restart when restart_on_change is false" do
362
+ let :params do {
363
+ :config => { 'node' => { 'name' => 'test' } },
364
+ :restart_on_change => false,
365
+ } end
366
+
367
+ it { should contain_file('/etc/elasticsearch/elasticsearch.yml').without_notify }
368
+ end
369
+
370
+ context "restarts when restart_on_change is true" do
371
+ let :params do {
372
+ :config => { 'node' => { 'name' => 'test' } },
373
+ :restart_on_change => true,
374
+ } end
375
+
376
+ it { should contain_file('/etc/elasticsearch/elasticsearch.yml').with(:notify => "Class[Elasticsearch::Service]") }
377
+ end
378
+
379
+ end
380
+
381
+ context "test content of default service file" do
382
+
383
+ context "On a CentOS OS" do
384
+
385
+ let :facts do {
386
+ :operatingsystem => 'CentOS'
387
+ } end
388
+
389
+ context "set a value" do
390
+
391
+ let :params do {
392
+ :config => { 'node' => { 'name' => 'test' } },
393
+ :service_settings => { 'ES_USER' => 'elasticsearch', 'ES_GROUP' => 'elasticsearch' }
394
+ } end
395
+
396
+ it { should contain_file('/etc/sysconfig/elasticsearch').with(:content => "### MANAGED BY PUPPET ###\n\nES_GROUP=elasticsearch\nES_USER=elasticsearch\n") }
397
+
398
+ end
399
+
400
+ end
401
+
402
+ context "On a Debian OS" do
403
+
404
+ let :facts do {
405
+ :operatingsystem => 'Debian'
406
+ } end
407
+
408
+ context "set a value" do
409
+
410
+ let :params do {
411
+ :config => { 'node' => { 'name' => 'test' } },
412
+ :service_settings => { 'ES_USER' => 'elasticsearch', 'ES_GROUP' => 'elasticsearch' }
413
+ } end
414
+
415
+ it { should contain_file('/etc/default/elasticsearch').with(:content => "### MANAGED BY PUPPET ###\n\nES_GROUP=elasticsearch\nES_USER=elasticsearch\n") }
416
+
417
+ end
418
+
419
+ end
420
+
421
+ end
422
+
423
+ context "test content of config file" do
424
+
425
+ let :facts do {
426
+ :operatingsystem => 'CentOS'
427
+ } end
428
+
429
+ context "with nothing set" do
430
+
431
+ let :params do {
432
+ } end
433
+
434
+ it { should contain_file('/etc/elasticsearch/elasticsearch.yml').with(:content => "### MANAGED BY PUPPET ###\n") }
435
+
436
+ end
437
+
438
+ context "set a value" do
439
+
440
+ let :params do {
441
+ :config => { 'node' => { 'name' => 'test' } }
442
+ } end
443
+
444
+ it { should contain_file('/etc/elasticsearch/elasticsearch.yml').with(:content => "### MANAGED BY PUPPET ###\n---\nnode: \n name: test\n") }
445
+
446
+ end
447
+
448
+ context "set a value to true" do
449
+
450
+ let :params do {
451
+ :config => { 'node' => { 'master' => true } }
452
+ } end
453
+
454
+ it { should contain_file('/etc/elasticsearch/elasticsearch.yml').with(:content => "### MANAGED BY PUPPET ###\n---\nnode: \n master: true\n") }
455
+
456
+ end
457
+
458
+ context "set a value to false" do
459
+
460
+ let :params do {
461
+ :config => { 'node' => { 'data' => false } }
462
+ } end
463
+
464
+ it { should contain_file('/etc/elasticsearch/elasticsearch.yml').with(:content => "### MANAGED BY PUPPET ###\n---\nnode: \n data: false\n") }
465
+ end
466
+
467
+ context "deeper hash and multiple keys" do
468
+
469
+ let :params do {
470
+ :config => { 'index' => { 'routing' => { 'allocation' => { 'include' => 'tag1', 'exclude' => [ 'tag2', 'tag3' ] } } }, 'node' => { 'name' => 'somename' } }
471
+ } end
472
+
473
+ 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") }
474
+ end
475
+
476
+ context "Combination of full hash and shorted write up keys" do
477
+
478
+ let :params do {
479
+ :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' }
480
+ } end
481
+
482
+ 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") }
483
+
484
+ end
485
+
486
+ end
487
+
488
+ context "try with different configdir" do
489
+
490
+ let :facts do {
491
+ :operatingsystem => 'CentOS'
492
+ } end
493
+
494
+ let :params do {
495
+ :config => { 'node' => { 'name' => 'test' } },
496
+ :confdir => '/opt/elasticsearch/etc'
497
+ } end
498
+
499
+ it { should contain_file('/opt/elasticsearch/etc/elasticsearch.yml') }
500
+
501
+ end
502
+
503
+ context "install init script" do
504
+
505
+ let :facts do {
506
+ :operatingsystem => 'CentOS'
507
+ } end
508
+
509
+ context "default" do
510
+
511
+ let :params do {
512
+ :config => { 'node' => { 'name' => 'test' } }
513
+ } end
514
+
515
+ it { should_not contain_file('/etc/init.d/elasticsearch') }
516
+
517
+ end
518
+
519
+ context "when unmanaged" do
520
+
521
+ let :params do {
522
+ :config => { 'node' => { 'name' => 'test' } },
523
+ :status => 'unmanaged',
524
+ :initfile => 'puppet:///data/elasticsearch/elasticsearch.init'
525
+ } end
526
+
527
+ it { should_not contain_file('/etc/init.d/elasticsearch') }
528
+
529
+ end
530
+
531
+ context "when not unmanaged" do
532
+
533
+ let :params do {
534
+ :config => { 'node' => { 'name' => 'test' } },
535
+ :initfile => 'puppet:///data/elasticsearch/elasticsearch.init'
536
+ } end
537
+
538
+ it { should contain_file('/etc/init.d/elasticsearch').with(:source => 'puppet:///data/elasticsearch/elasticsearch.init') }
539
+
540
+ end
541
+
542
+ end
543
+
544
+ context "package options" do
545
+
546
+ let :facts do {
547
+ :operatingsystem => 'CentOS'
548
+ } end
549
+
550
+ context "default" do
551
+
552
+ let :params do {
553
+ :config => { 'node' => { 'name' => 'test' } }
554
+ } end
555
+
556
+ it { should contain_package('elasticsearch').with(:ensure => 'present') }
557
+
558
+ end
559
+
560
+ context "when autoupgrade is true" do
561
+
562
+ let :params do {
563
+ :config => { 'node' => { 'name' => 'test' } },
564
+ :autoupgrade => true
565
+ } end
566
+
567
+ it { should contain_package('elasticsearch').with(:ensure => 'latest') }
568
+
569
+ end
570
+
571
+ context "when version is set" do
572
+
573
+ let :params do {
574
+ :config => { 'node' => { 'name' => 'test' } },
575
+ :version => '0.20.5'
576
+ } end
577
+
578
+ it { should contain_package('elasticsearch').with(:ensure => '0.20.5') }
579
+
580
+ end
581
+
582
+ context "when absent" do
583
+
584
+ let :params do {
585
+ :config => { 'node' => { 'name' => 'test' } },
586
+ :ensure => 'absent'
587
+ } end
588
+
589
+ it { should contain_package('elasticsearch').with(:ensure => 'purged') }
590
+
591
+ end
592
+
593
+ end
594
+
595
+ end
596
+
@@ -0,0 +1,66 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'elasticsearch::template', :type => 'define' do
4
+
5
+ let(:title) { 'foo' }
6
+ let(:facts) { {:operatingsystem => 'CentOS' }}
7
+ let(:pre_condition) { 'class {"elasticsearch": config => { "node" => {"name" => "test" }}}'}
8
+
9
+ context "Add a template" do
10
+
11
+ let :params do {
12
+ :file => 'puppet:///path/to/foo.json',
13
+ } end
14
+
15
+ it { should contain_file('/etc/elasticsearch/templates_import/elasticsearch-template-foo.json').with(:source => 'puppet:///path/to/foo.json') }
16
+ 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') }
17
+ end
18
+
19
+ context "Delete a template" do
20
+
21
+ let :params do {
22
+ :delete => true
23
+ } end
24
+
25
+ it { should_not contain_file('/etc/elasticsearch/templates_import/elasticsearch-template-foo.json').with(:source => 'puppet:///path/to/foo.json') }
26
+ it { should_not contain_exec('insert_template foo') }
27
+ 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' ) }
28
+ end
29
+
30
+ context "Replace a template" do
31
+
32
+ let :params do {
33
+ :replace => true,
34
+ :file => 'puppet:///path/to/foo.json'
35
+ } end
36
+
37
+ it { should contain_file('/etc/elasticsearch/templates_import/elasticsearch-template-foo.json').with(:source => 'puppet:///path/to/foo.json') }
38
+ 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') }
39
+ it { should contain_exec('delete_template foo').with(:command => 'curl -s -XDELETE http://localhost:9200/_template/foo', :notify => 'Exec[insert_template foo]', :onlyif => 'test $(curl -s \'http://localhost:9200/_template/foo?pretty=true\' | wc -l) -gt 1' ) }
40
+
41
+ end
42
+
43
+ context "Try replace and delete at the same time" do
44
+
45
+ let :params do {
46
+ :replace => true,
47
+ :delete => true,
48
+ :file => 'puppet:///path/to/foo.json'
49
+ } end
50
+
51
+ it { expect { should raise_error(Puppet::Error) } }
52
+
53
+ end
54
+
55
+ context "Add template with alternative host" do
56
+
57
+ let :params do {
58
+ :file => 'puppet:///path/to/foo.json',
59
+ :host => 'otherhost'
60
+ } end
61
+
62
+ it { should contain_file('/etc/elasticsearch/templates_import/elasticsearch-template-foo.json').with(:source => 'puppet:///path/to/foo.json') }
63
+ it { should contain_exec('insert_template foo').with(:command => 'curl -s -XPUT http://otherhost:9200/_template/foo -d @/etc/elasticsearch/templates_import/elasticsearch-template-foo.json', :unless => 'test $(curl -s \'http://otherhost:9200/_template/foo?pretty=true\' | wc -l) -gt 1') }
64
+ end
65
+
66
+ end
@@ -0,0 +1,2 @@
1
+ require 'rubygems'
2
+ require 'puppetlabs_spec_helper/module_spec_helper'
@@ -0,0 +1,5 @@
1
+ ### MANAGED BY PUPPET ###
2
+
3
+ <% scope.lookupvar('elasticsearch::service_settings').sort.map do |key, value| -%>
4
+ <%= key %>=<%= value %>
5
+ <% end -%>