safeguard-devise 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
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,44 @@
1
+ module DeviseSafeguard
2
+ module Generators
3
+ # Install Generator
4
+ class InstallGenerator < Rails::Generators::Base
5
+ source_root File.expand_path("../../templates", __FILE__)
6
+
7
+ class_option :haml, :type => :boolean, :required => false, :default => false, :desc => "Generate views in Haml"
8
+ class_option :sass, :type => :boolean, :required => false, :default => false, :desc => "Generate stylesheet in Sass"
9
+
10
+ desc "Install the devise safeguard extension"
11
+
12
+ def add_configs
13
+ inject_into_file "config/initializers/devise.rb", "\n" +
14
+ " # ==> Devise Safeguard Authentication Extension\n" +
15
+ " # How long should the user's device be remembered for.\n" +
16
+ " # config.safeguard_remember_device = 1.month\n\n", :before => /^end[\r\n]*$/
17
+ end
18
+
19
+ def copy_locale
20
+ copy_file "../../../config/locales/pt-BR.yml", "config/locales/devise.safeguard.pt-BR.yml"
21
+ copy_file "../../../config/locales/en.yml", "config/locales/devise.safeguard.en.yml"
22
+ end
23
+
24
+ def copy_views
25
+ if options.haml?
26
+ copy_file '../../../app/views/devise/verify_safeguard.html.haml', 'app/views/devise/devise_safeguard/verify_safeguard.html.haml'
27
+ else
28
+ copy_file '../../../app/views/devise/verify_safeguard.html.erb', 'app/views/devise/devise_safeguard/verify_safeguard.html.erb'
29
+ end
30
+ end
31
+
32
+ def copy_assets
33
+ if options.sass?
34
+ copy_file '../../../app/assets/stylesheets/devise_safeguard.sass', 'app/assets/stylesheets/devise_safeguard.sass'
35
+ else
36
+ copy_file '../../../app/assets/stylesheets/devise_safeguard.css', 'app/assets/stylesheets/devise_safeguard.css'
37
+ end
38
+ end
39
+
40
+ def inject_assets_in_layout
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,24 @@
1
+ require 'active_support/concern'
2
+ require 'active_support/core_ext/integer/time'
3
+ require 'devise'
4
+ require 'safeguard-api'
5
+ module Devise
6
+
7
+ end
8
+
9
+ module DeviseSafeguard
10
+ module Controllers
11
+ autoload :Helpers, 'devise-safeguard/controllers/helpers'
12
+ end
13
+
14
+ module Views
15
+
16
+ end
17
+ end
18
+
19
+ require 'devise-safeguard/routes'
20
+ require 'devise-safeguard/rails'
21
+ require 'devise-safeguard/models/safeguard_authenticatable'
22
+ Devise::Models.config(self, :safeguard_remember_device)
23
+
24
+ Devise.add_module :safeguard_authenticatable, :model => 'devise-safeguard/models/safeguard_authenticatable', :controller => :devise_safeguard, :route => :safeguard
@@ -0,0 +1,66 @@
1
+ $ar_databases = ['activerecord_unittest', 'activerecord_unittest2']
2
+ $as_vagrant = 'sudo -u vagrant -H bash -l -c'
3
+ $home = '/home/vagrant'
4
+
5
+ Exec {
6
+ path => ['/usr/sbin', '/usr/bin', '/sbin', '/bin']
7
+ }
8
+
9
+ # --- Preinstall Stage ---------------------------------------------------------
10
+
11
+ stage { 'preinstall':
12
+ before => Stage['main']
13
+ }
14
+
15
+ class apt_get_update {
16
+ exec { 'apt-get -y update':
17
+ unless => "test -e ${home}/.rvm"
18
+ }
19
+ }
20
+ class { 'apt_get_update':
21
+ stage => preinstall
22
+ }
23
+
24
+ # --- Packages -----------------------------------------------------------------
25
+
26
+ package { 'curl':
27
+ ensure => installed
28
+ }
29
+
30
+ package { 'build-essential':
31
+ ensure => installed
32
+ }
33
+
34
+ package { 'git-core':
35
+ ensure => installed
36
+ }
37
+
38
+ # Nokogiri dependencies.
39
+ package { ['libxml2', 'libxml2-dev', 'libxslt1-dev']:
40
+ ensure => installed
41
+ }
42
+
43
+ # --- Ruby ---------------------------------------------------------------------
44
+
45
+ exec { 'install_rvm':
46
+ command => "${as_vagrant} 'curl -L https://get.rvm.io | bash -s stable'",
47
+ creates => "${home}/.rvm/bin/rvm",
48
+ require => Package['curl']
49
+ }
50
+
51
+ exec { 'install_ruby':
52
+ # We run the rvm executable directly because the shell function assumes an
53
+ # interactive environment, in particular to display messages or ask questions.
54
+ # The rvm executable is more suitable for automated installs.
55
+ #
56
+ # Thanks to @mpapis for this tip.
57
+
58
+ command => "${as_vagrant} '${home}/.rvm/bin/rvm install 1.9.3 --latest-binary --autolibs=enabled && rvm --fuzzy alias create default 1.9.3'",
59
+ creates => "${home}/.rvm/bin/ruby",
60
+ require => Exec['install_rvm']
61
+ }
62
+
63
+ exec { "${as_vagrant} 'gem install bundler --no-rdoc --no-ri'":
64
+ creates => "${home}/.rvm/bin/bundle",
65
+ require => Exec['install_ruby']
66
+ }
@@ -0,0 +1,62 @@
1
+ 0.1.3 ( Sep 06, 2013 )
2
+ Exec path settings has been updated to fix warnings ( PR #37, #47 )
3
+ Adding define to install python bindings ( PR #43 )
4
+ Scope deprecation fixes ( PR #41 )
5
+ feature to install plugins ( PR #40 )
6
+
7
+ 0.1.2 ( Jun 21, 2013 )
8
+ Update rake file to ignore the param inherit
9
+ Added missing documentation to the template define
10
+ Fix for template define to allow multiple templates ( PR #36 by Bruce Morrison )
11
+
12
+ 0.1.1 ( Jun 14, 2013 )
13
+ Add Oracle Linux to the OS list ( PR #25 by Stas Alekseev )
14
+ Respect the restart_on_change on the defaults ( PR #29 by Simon Effenberg )
15
+ Make sure the config can be empty as advertised in the readme
16
+ Remove dependency cycle when the defaults file is updated ( PR #31 by Bruce Morrison )
17
+ Enable retry on the template insert in case ES isn't started yet ( PR #32 by Bruce Morrison )
18
+ Update templates to avoid deprecation notice with Puppet 3.2.x
19
+ Update template define to avoid auto insert issue with ES
20
+ Update spec tests to reflect changes to template define
21
+
22
+ 0.1.0 ( May 09, 2013 )
23
+ Populate .gitignore ( PR #19 by Igor Galić )
24
+ Add ability to install initfile ( PR #20 by Justin Lambert )
25
+ Add ability to manage default file* service parameters ( PR #21 by Mathieu Bornoz )
26
+ Providing complete containment of the module ( PR #24 by Brian Lalor )
27
+ Add ability to specify package version ( PR #25 by Justin Lambert )
28
+ Adding license file
29
+
30
+ 0.0.7 ( Mar 23, 2013 )
31
+ Ensure config directory is created and managed ( PR #13 by Martin Seener )
32
+ Dont backup package if it changes
33
+ Create explicit dependency on template directory ( PR #16 by Igor Galić )
34
+ Make the config directory variable ( PR #17 by Igor Galić and PR #18 by Vincent Janelle )
35
+ Fixing template define
36
+
37
+ 0.0.6 ( Mar 05, 2013 )
38
+ Fixing issue with configuration not printing out arrays
39
+ New feature to write the config hash shorter
40
+ Updated readme to reflect the new feature
41
+ Adding spec tests for config file generation
42
+
43
+ 0.0.5 ( Mar 03, 2013 )
44
+ Option to disable restart on config file change ( PR #10 by Chris Boulton )
45
+
46
+ 0.0.4 ( Mar 02, 2013 )
47
+ Fixed a major issue with the config template ( Issue #9 )
48
+
49
+ 0.0.3 ( Mar 02, 2013 )
50
+ Adding spec tests
51
+ Fixed init issue on Ubuntu ( Issue #6 by Marcus Furlong )
52
+ Fixed config template problem ( Issue #8 by surfchris )
53
+ New feature to manage templates
54
+
55
+ 0.0.2 ( Feb 16, 2013 )
56
+ Feature to supply a package instead of being dependent on the repository
57
+ Feature to install java in case one doesn't manage it externally
58
+ Adding RedHat and Amazon as Operating systems
59
+ fixed a typo - its a shard not a shared :) ( PR #5 by Martin Seener )
60
+
61
+ 0.0.1 ( Jan 13, 2013 )
62
+ Initial release of the module
@@ -0,0 +1,20 @@
1
+ The following is a list of people who have contributed ideas, code, bug
2
+ reports, or in general have helped this puppet module along its way.
3
+
4
+ Project Owner
5
+ * Richard Pijnenburg (electrical)
6
+
7
+ Contributors:
8
+ Martin Seener (martinseener)
9
+ Marcus Furlong (furlongm)
10
+ Chris Boulton (chrisboulton)
11
+ Igor Galić (igalic)
12
+ Vincent Janelle (vjanelle)
13
+ Mathieu Bornoz (mbornoz)
14
+ Justin Lambert (jlambert121)
15
+ Brian Lalor (blalor)
16
+ Stas Alekseev (salekseev)
17
+ Simon Effenberg (Savar)
18
+ Bruce Morrison (brucem)
19
+ deanmalmgren
20
+ Matteo Sessa (msessa-cotd)
@@ -0,0 +1,13 @@
1
+ Copyright 2012-2013 Richard Pijnenburg
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
@@ -0,0 +1,9 @@
1
+ name 'ispavailability-elasticsearch'
2
+ version '0.1.3'
3
+ source 'https://github.com/elasticsearch/puppet-elasticsearch'
4
+ author 'ispavailability'
5
+ license 'Apache License, Version 2.0'
6
+ summary 'Module for managing and configuring Elasticsearch nodes'
7
+ description 'Module for managing and configuring Elasticsearch nodes'
8
+ project_page 'https://github.com/elasticsearch/puppet-elasticsearch'
9
+ dependency 'puppetlabs/stdlib', '>= 3.0.0'
@@ -0,0 +1,147 @@
1
+ # puppet-elasticsearch
2
+
3
+ A puppet module for managing elasticsearch nodes
4
+
5
+ http://www.elasticsearch.org/
6
+
7
+ [![Build Status](https://travis-ci.org/elasticsearch/puppet-elasticsearch.png?branch=master)](https://travis-ci.org/elasticsearch/puppet-elasticsearch)
8
+
9
+ ## Usage
10
+
11
+ Installation, make sure service is running and will be started at boot time:
12
+
13
+ class { 'elasticsearch': }
14
+
15
+ Install a certain version:
16
+
17
+ class { 'elasticsearch':
18
+ version => '0.90.3'
19
+ }
20
+
21
+ Removal/decommissioning:
22
+
23
+ class { 'elasticsearch':
24
+ ensure => 'absent',
25
+ }
26
+
27
+ Install everything but disable service(s) afterwards:
28
+
29
+ class { 'elasticsearch':
30
+ status => 'disabled',
31
+ }
32
+
33
+ Disable automated restart of Elasticsearch on config file change:
34
+
35
+ class { 'elasticsearch':
36
+ restart_on_change => false
37
+ }
38
+
39
+ For the config variable a hash needs to be passed:
40
+
41
+ class { 'elasticsearch':
42
+ config => {
43
+ 'node' => {
44
+ 'name' => 'elasticsearch001'
45
+ },
46
+ 'index' => {
47
+ 'number_of_replicas' => '0',
48
+ 'number_of_shards' => '5'
49
+ },
50
+ 'network' => {
51
+ 'host' => $::ipaddress
52
+ }
53
+ }
54
+ }
55
+
56
+ Short write up of the config hash is also possible.
57
+
58
+ Instead of writing the full hash representation:
59
+
60
+ class { 'elasticsearch':
61
+ config => {
62
+ 'cluster' => {
63
+ 'name' => 'ClusterName',
64
+ 'routing' => {
65
+ 'allocation' => {
66
+ 'awareness' => {
67
+ 'attributes' => 'rack'
68
+ }
69
+ }
70
+ }
71
+ }
72
+ }
73
+ }
74
+
75
+ You can write the dotted key naming:
76
+
77
+ class { 'elasticsearch':
78
+ config => {
79
+ 'cluster' => {
80
+ 'name' => 'ClusterName',
81
+ 'routing.allocation.awareness.attributes' => 'rack'
82
+ }
83
+ }
84
+ }
85
+
86
+ ## Defaults file
87
+
88
+ You can populate the defaults file ( /etc/defaults/elasticsearch or /etc/sysconfig/elasticsearch )
89
+
90
+ class { 'elasticsearch':
91
+ service_settings => { 'ES_USER' => 'elasticsearch', 'ES_GROUP' => 'elasticsearch' }
92
+ }
93
+
94
+ ## Manage templates
95
+
96
+ ### Add a new template
97
+
98
+ elasticsearch::template { 'templatename':
99
+ file => 'puppet:///path/to/template.json'
100
+ }
101
+
102
+ ### Delete a template
103
+
104
+ elasticsearch::template { 'templatename':
105
+ delete => true
106
+ }
107
+
108
+ ### Replace a template
109
+
110
+ elasticsearch::template { 'templatename':
111
+ file => 'puppet:///path/to/template.json',
112
+ replace => true
113
+ }
114
+
115
+ ### Host
116
+
117
+ Default it uses localhost:9200 as host. you can change this with the 'host' and 'port' variables
118
+
119
+ elasticsearch::template { 'templatename':
120
+ host => $::ipaddress,
121
+ port => 9200
122
+ }
123
+
124
+ ## Bindings / clients
125
+
126
+ Install [a variety of python bindings](http://www.elasticsearch.org/guide/clients/):
127
+
128
+ elasticsearch::python { "rawes": }
129
+
130
+
131
+ ## Plugins
132
+
133
+ Install [a variety of plugins](http://www.elasticsearch.org/guide/clients/):
134
+
135
+ ### From official repository:
136
+
137
+ elasticsearch::plugin{'mobz/elasticsearch-head':
138
+ module_dir => 'head'
139
+ }
140
+
141
+ ### From custom url:
142
+
143
+ elasticsearch::plugin{ 'elasticsearch-jetty':
144
+ module_dir => 'elasticsearch-jetty',
145
+ url => 'https://oss-es-plugins.s3.amazonaws.com/elasticsearch-jetty/elasticsearch-jetty-0.90.0.zip'
146
+ }
147
+
@@ -0,0 +1,5 @@
1
+ require 'rubygems'
2
+ require 'puppetlabs_spec_helper/rake_tasks'
3
+ require 'puppet-lint'
4
+ PuppetLint.configuration.send("disable_80chars")
5
+ PuppetLint.configuration.send("disable_class_inherits_from_params_class")
@@ -0,0 +1,64 @@
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@ispavailability.com>
24
+ #
25
+ class elasticsearch::config {
26
+
27
+ include elasticsearch
28
+
29
+ Exec {
30
+ path => [ '/bin', '/usr/bin', '/usr/local/bin' ],
31
+ cwd => '/',
32
+ }
33
+
34
+ $settings = $elasticsearch::config
35
+
36
+ $notify_elasticsearch = $elasticsearch::restart_on_change ? {
37
+ false => undef,
38
+ default => Class['elasticsearch::service'],
39
+
40
+ }
41
+
42
+ file { $elasticsearch::confdir:
43
+ ensure => directory,
44
+ owner => 'root',
45
+ group => 'root',
46
+ mode => '0644',
47
+ }
48
+
49
+ file { "${elasticsearch::confdir}/elasticsearch.yml":
50
+ ensure => file,
51
+ content => template("${module_name}/etc/elasticsearch/elasticsearch.yml.erb"),
52
+ owner => 'root',
53
+ group => 'root',
54
+ mode => '0644',
55
+ require => [ Class['elasticsearch::package'], File[$elasticsearch::confdir] ],
56
+ notify => $notify_elasticsearch,
57
+ }
58
+
59
+ exec { 'mkdir_templates':
60
+ command => "mkdir -p ${elasticsearch::confdir}/templates_import",
61
+ creates => "${elasticsearch::confdir}/templates_import"
62
+ }
63
+
64
+ }
@@ -0,0 +1,208 @@
1
+ # == Class: elasticsearch
2
+ #
3
+ # This class is able to install or remove elasticsearch on a node.
4
+ # It manages the status of the related service.
5
+ #
6
+ # === Parameters
7
+ #
8
+ # [*config*]
9
+ # Hash. Hash that defines the configuration.
10
+ #
11
+ # [*ensure*]
12
+ # String. Controls if the managed resources shall be <tt>present</tt> or
13
+ # <tt>absent</tt>. If set to <tt>absent</tt>:
14
+ # * The managed software packages are being uninstalled.
15
+ # * Any traces of the packages will be purged as good as possible. This may
16
+ # include existing configuration files. The exact behavior is provider
17
+ # dependent. Q.v.:
18
+ # * Puppet type reference: {package, "purgeable"}[http://j.mp/xbxmNP]
19
+ # * {Puppet's package provider source code}[http://j.mp/wtVCaL]
20
+ # * System modifications (if any) will be reverted as good as possible
21
+ # (e.g. removal of created users, services, changed log settings, ...).
22
+ # * This is thus destructive and should be used with care.
23
+ # Defaults to <tt>present</tt>.
24
+ #
25
+ # [*autoupgrade*]
26
+ # Boolean. If set to <tt>true</tt>, any managed package gets upgraded
27
+ # on each Puppet run when the package provider is able to find a newer
28
+ # version than the present one. The exact behavior is provider dependent.
29
+ # Q.v.:
30
+ # * Puppet type reference: {package, "upgradeable"}[http://j.mp/xbxmNP]
31
+ # * {Puppet's package provider source code}[http://j.mp/wtVCaL]
32
+ # Defaults to <tt>false</tt>.
33
+ #
34
+ # [*status*]
35
+ # String to define the status of the service. Possible values:
36
+ # * <tt>enabled</tt>: Service is running and will be started at boot time.
37
+ # * <tt>disabled</tt>: Service is stopped and will not be started at boot
38
+ # time.
39
+ # * <tt>running</tt>: Service is running but will not be started at boot time.
40
+ # You can use this to start a service on the first Puppet run instead of
41
+ # the system startup.
42
+ # * <tt>unmanaged</tt>: Service will not be started at boot time and Puppet
43
+ # does not care whether the service is running or not. For example, this may
44
+ # be useful if a cluster management software is used to decide when to start
45
+ # the service plus assuring it is running on the desired node.
46
+ # Defaults to <tt>enabled</tt>. The singular form ("service") is used for the
47
+ # sake of convenience. Of course, the defined status affects all services if
48
+ # more than one is managed (see <tt>service.pp</tt> to check if this is the
49
+ # case).
50
+ #
51
+ # [*restart_on_change*]
52
+ # Boolean that determines if ElasticSearch should be automatically restarted
53
+ # whenever the configuration changes. Disabling automatic restarts on config
54
+ # changes may be desired in an environment where you need to ensure restarts
55
+ # occur in a controlled/rolling manner rather than during a Puppet run.
56
+ #
57
+ # Defaults to <tt>true</tt>, which will restart ElasticSearch on any config
58
+ # change. Setting to <tt>false</tt> disables the automatic restart.
59
+ #
60
+ # [*confdir*]
61
+ # Path to directory containing the elasticsearch configuration.
62
+ # Use this setting if your packages deviate from the norm (/etc/elasticsearch)
63
+ #
64
+ # [*plugindir*]
65
+ # Path to directory containing the elasticsearch plugins
66
+ # Use this setting if your packages deviate from the norm (/usr/share/elasticsearch/plugins)
67
+ #
68
+ # [*plugintool*]
69
+ # Path to directory containing the elasticsearch plugin installation script
70
+ # Use this setting if your packages deviate from the norm (/usr/share/elasticsearch/bin/plugin)
71
+ #
72
+ # [*service_settings*]
73
+ # A hash to define the default service settings. Values must be consistent
74
+ # with those defined in the init script and overwritten from the default
75
+ # file (/etc/default/elasticsearch or /etc/sysconfig/elasticsearch).
76
+ #
77
+ # [*initfile*]
78
+ # Source file to be used as the elasticsearch init script.
79
+ #
80
+ # [*version*]
81
+ # String to set the specific version you want to install.
82
+ # Defaults to <tt>false</tt>.
83
+ #
84
+ #
85
+ # The default values for the parameters are set in elasticsearch::params. Have
86
+ # a look at the corresponding <tt>params.pp</tt> manifest file if you need more
87
+ # technical information about them.
88
+ #
89
+ #
90
+ # === Examples
91
+ #
92
+ # * Installation, make sure service is running and will be started at boot time:
93
+ # class { 'elasticsearch': }
94
+ #
95
+ # * Removal/decommissioning:
96
+ # class { 'elasticsearch':
97
+ # ensure => 'absent',
98
+ # }
99
+ #
100
+ # * Install everything but disable service(s) afterwards
101
+ # class { 'elasticsearch':
102
+ # status => 'disabled',
103
+ # }
104
+ #
105
+ # * For the config variable a hash needs to be passed:
106
+ #
107
+ # class { 'elasticsearch':
108
+ # config => {
109
+ # 'node' => {
110
+ # 'name' => 'elasticsearch001'
111
+ # },
112
+ # 'index' => {
113
+ # 'number_of_replicas' => '0',
114
+ # 'number_of_shards' => '5'
115
+ # },
116
+ # 'network' => {
117
+ # 'host' => $::ipaddress
118
+ # }
119
+ # }
120
+ # }
121
+ #
122
+ # === Authors
123
+ #
124
+ # * Richard Pijnenburg <mailto:richard@ispavailability.com>
125
+ #
126
+ class elasticsearch(
127
+ $config = {},
128
+ $ensure = $elasticsearch::params::ensure,
129
+ $autoupgrade = $elasticsearch::params::autoupgrade,
130
+ $status = $elasticsearch::params::status,
131
+ $restart_on_change = $elasticsearch::params::restart_on_change,
132
+ $confdir = $elasticsearch::params::confdir,
133
+ $plugindir = $elasticsearch::params::plugindir,
134
+ $plugintool = $elasticsearch::params::plugintool,
135
+ $service_settings = $elasticsearch::params::service_settings,
136
+ $pkg_source = undef,
137
+ $version = false,
138
+ $java_install = false,
139
+ $java_package = undef,
140
+ $initfile = undef
141
+ ) inherits elasticsearch::params {
142
+
143
+ #### Validate parameters
144
+
145
+ # ensure
146
+ if ! ($ensure in [ 'present', 'absent' ]) {
147
+ fail("\"${ensure}\" is not a valid ensure parameter value")
148
+ }
149
+
150
+ # autoupgrade
151
+ validate_bool($autoupgrade)
152
+
153
+ # service status
154
+ if ! ($status in [ 'enabled', 'disabled', 'running', 'unmanaged' ]) {
155
+ fail("\"${status}\" is not a valid status parameter value")
156
+ }
157
+
158
+ # Config
159
+ validate_hash($config)
160
+ validate_bool($restart_on_change)
161
+
162
+ #### Manage actions
163
+ anchor {'elasticsearch::begin': }
164
+ anchor {'elasticsearch::end': }
165
+
166
+ # package(s)
167
+ class { 'elasticsearch::package': }
168
+
169
+ # config
170
+ class { 'elasticsearch::config': }
171
+
172
+ # service(s)
173
+ class { 'elasticsearch::service': }
174
+
175
+ if $java_install == true {
176
+ # Install java
177
+ class { 'elasticsearch::java': }
178
+
179
+ # ensure we first java java and then manage the service
180
+ Anchor['elasticsearch::begin']
181
+ -> Class['elasticsearch::java']
182
+ -> Class['elasticsearch::service']
183
+ }
184
+
185
+ #### Manage relationships
186
+
187
+ if $ensure == 'present' {
188
+ # we need the software before configuring it
189
+ Anchor['elasticsearch::begin']
190
+ -> Class['elasticsearch::package']
191
+ -> Class['elasticsearch::config']
192
+
193
+ # we need the software before running a service
194
+ Class['elasticsearch::package'] -> Class['elasticsearch::service']
195
+ Class['elasticsearch::config'] -> Class['elasticsearch::service']
196
+
197
+ Class['elasticsearch::service']
198
+ -> Anchor['elasticsearch::end']
199
+ } else {
200
+
201
+ # make sure all services are getting stopped before software removal
202
+ Anchor['elasticsearch::begin']
203
+ -> Class['elasticsearch::service']
204
+ -> Class['elasticsearch::package']
205
+ -> Anchor['elasticsearch::end']
206
+ }
207
+
208
+ }