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,50 @@
1
+ # == Class: elasticsearch::java
2
+ #
3
+ # This class exists to install java if its not managed from an other module
4
+ #
5
+ #
6
+ # === Parameters
7
+ #
8
+ # This class does not provide any parameters.
9
+ #
10
+ #
11
+ # === Examples
12
+ #
13
+ # This class may be imported by other classes to use its functionality:
14
+ # class { 'elasticsearch::java': }
15
+ #
16
+ # It is not intended to be used directly by external resources like node
17
+ # definitions or other modules.
18
+ #
19
+ #
20
+ # === Authors
21
+ #
22
+ # * Richard Pijnenburg <mailto:richard@ispavailability.com>
23
+ #
24
+ class elasticsearch::java {
25
+
26
+ if $elasticsearch::java_package == undef {
27
+ # Default Java package
28
+ case $::operatingsystem {
29
+ 'CentOS', 'Fedora', 'Scientific', 'RedHat', 'Amazon', 'OracleLinux': {
30
+ $package = 'java-1.6.0-openjdk'
31
+ }
32
+ 'Debian', 'Ubuntu': {
33
+ $package = 'openjdk-6-jre-headless'
34
+ }
35
+ default: {
36
+ fail("\"${module_name}\" provides no java package
37
+ for \"${::operatingsystem}\"")
38
+ }
39
+ }
40
+ } else {
41
+ $package = $elasticsearch::java_package
42
+ }
43
+
44
+ ## Install the java package unless already specified somewhere else
45
+ if !defined(Package[$package]) {
46
+ package { $package:
47
+ ensure => present
48
+ }
49
+ }
50
+ }
@@ -0,0 +1,84 @@
1
+ # == Class: elasticsearch::package
2
+ #
3
+ # This class exists to coordinate all software package management related
4
+ # actions, 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::package': }
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::package {
26
+
27
+ #### Package management
28
+
29
+ # set params: in operation
30
+ if $elasticsearch::ensure == 'present' {
31
+
32
+ if $elasticsearch::version == false {
33
+
34
+ $package_ensure = $elasticsearch::autoupgrade ? {
35
+ true => 'latest',
36
+ default => 'present',
37
+ }
38
+
39
+ } else {
40
+
41
+ $package_ensure = $elasticsearch::version
42
+
43
+ }
44
+
45
+ # set params: removal
46
+ } else {
47
+ $package_ensure = 'purged'
48
+ }
49
+
50
+ if $elasticsearch::pkg_source {
51
+
52
+ $filenameArray = split($elasticsearch::pkg_source, '/')
53
+ $basefilename = $filenameArray[-1]
54
+
55
+ $extArray = split($basefilename, '\.')
56
+ $ext = $extArray[-1]
57
+
58
+ $tmpSource = "/tmp/${basefilename}"
59
+
60
+ file { $tmpSource:
61
+ source => $elasticsearch::pkg_source,
62
+ owner => 'root',
63
+ group => 'root',
64
+ backup => false
65
+ }
66
+
67
+ case $ext {
68
+ 'deb': { $pkg_provider = 'dpkg' }
69
+ 'rpm': { $pkg_provider = 'rpm' }
70
+ default: { fail("Unknown file extention \"${ext}\"") }
71
+ }
72
+ } else {
73
+ $tmpSource = undef
74
+ $pkg_provider = undef
75
+ }
76
+
77
+ # action
78
+ package { $elasticsearch::params::package:
79
+ ensure => $package_ensure,
80
+ source => $tmpSource,
81
+ provider => $pkg_provider
82
+ }
83
+
84
+ }
@@ -0,0 +1,103 @@
1
+ # == Class: elasticsearch::params
2
+ #
3
+ # This class exists to
4
+ # 1. Declutter the default value assignment for class parameters.
5
+ # 2. Manage internally used module variables in a central place.
6
+ #
7
+ # Therefore, many operating system dependent differences (names, paths, ...)
8
+ # are addressed in here.
9
+ #
10
+ #
11
+ # === Parameters
12
+ #
13
+ # This class does not provide any parameters.
14
+ #
15
+ #
16
+ # === Examples
17
+ #
18
+ # This class is not intended to be used directly.
19
+ #
20
+ #
21
+ # === Links
22
+ #
23
+ # * {Puppet Docs: Using Parameterized Classes}[http://j.mp/nVpyWY]
24
+ #
25
+ #
26
+ # === Authors
27
+ #
28
+ # * Richard Pijnenburg <mailto:richard@ispavailability.com>
29
+ #
30
+ class elasticsearch::params {
31
+
32
+ #### Default values for the parameters of the main module class, init.pp
33
+
34
+ # ensure
35
+ $ensure = 'present'
36
+
37
+ # autoupgrade
38
+ $autoupgrade = false
39
+
40
+ # restart on configuration change?
41
+ $restart_on_change = true
42
+
43
+ # service status
44
+ $status = 'enabled'
45
+
46
+ # configuration directory
47
+ $confdir = '/etc/elasticsearch'
48
+
49
+ # plugins directory
50
+ $plugindir = '/usr/share/elasticsearch/plugins'
51
+
52
+ # plugins helper binary
53
+ $plugintool = '/usr/share/elasticsearch/bin/plugin'
54
+
55
+ # default service settings
56
+ $service_settings = {
57
+ 'ES_USER' => 'elasticsearch',
58
+ 'ES_GROUP' => 'elasticsearch',
59
+ }
60
+
61
+ #### Internal module values
62
+
63
+ # packages
64
+ case $::operatingsystem {
65
+ 'CentOS', 'Fedora', 'Scientific', 'RedHat', 'Amazon', 'OracleLinux': {
66
+ # main application
67
+ $package = [ 'elasticsearch' ]
68
+ }
69
+ 'Debian', 'Ubuntu': {
70
+ # main application
71
+ $package = [ 'elasticsearch' ]
72
+ }
73
+ default: {
74
+ fail("\"${module_name}\" provides no package default value
75
+ for \"${::operatingsystem}\"")
76
+ }
77
+ }
78
+
79
+ # service parameters
80
+ case $::operatingsystem {
81
+ 'CentOS', 'Fedora', 'Scientific', 'RedHat', 'Amazon', 'OracleLinux': {
82
+ $service_name = 'elasticsearch'
83
+ $service_hasrestart = true
84
+ $service_hasstatus = true
85
+ $service_pattern = $service_name
86
+ $service_provider = 'redhat'
87
+ $service_settings_path = "/etc/sysconfig/${service_name}"
88
+ }
89
+ 'Debian', 'Ubuntu': {
90
+ $service_name = 'elasticsearch'
91
+ $service_hasrestart = true
92
+ $service_hasstatus = true
93
+ $service_pattern = $service_name
94
+ $service_provider = 'debian'
95
+ $service_settings_path = "/etc/default/${service_name}"
96
+ }
97
+ default: {
98
+ fail("\"${module_name}\" provides no service parameters
99
+ for \"${::operatingsystem}\"")
100
+ }
101
+ }
102
+
103
+ }
@@ -0,0 +1,97 @@
1
+ # == Define: elasticsearch::plugin
2
+ #
3
+ # This define allows you to install arbitrary Elasticsearch plugins
4
+ # either by using the default repositories or by specifying an URL
5
+ #
6
+ # All default values are defined in the elasticsearch::params class.
7
+ #
8
+ #
9
+ # === Parameters
10
+ #
11
+ # [*module_dir*]
12
+ # Directory name where the module will be installed
13
+ # Value type is string
14
+ # Default value: None
15
+ # This variable is required
16
+ #
17
+ # [*ensure*]
18
+ # Whether the plugin will be installed or removed.
19
+ # Set to 'absent' to ensure a plugin is not installed
20
+ # Value type is string
21
+ # Default value: present
22
+ # This variable is optional
23
+ #
24
+ # [*url*]
25
+ # Specify an URL where to download the plugin from.
26
+ # Value type is string
27
+ # Default value: None
28
+ # This variable is optional
29
+ #
30
+ #
31
+ # === Examples
32
+ #
33
+ # # From official repository
34
+ # elasticsearch::plugin{'mobz/elasticsearch-head': module_dir => 'head'}
35
+ #
36
+ # # From custom url
37
+ # elasticsearch::plugin{ 'elasticsearch-jetty':
38
+ # module_dir => 'elasticsearch-jetty',
39
+ # url => 'https://oss-es-plugins.s3.amazonaws.com/elasticsearch-jetty/elasticsearch-jetty-0.90.0.zip',
40
+ # }
41
+ #
42
+ # === Authors
43
+ #
44
+ # * Matteo Sessa <mailto:matteo.sessa@catchoftheday.com.au>
45
+ # * Dennis Konert <mailto:dkonert@gmail.com>
46
+ #
47
+ define elasticsearch::plugin(
48
+ $module_dir,
49
+ $ensure = 'present',
50
+ $url = ''
51
+ ) {
52
+
53
+ require elasticsearch::params
54
+
55
+ Exec {
56
+ path => [ '/bin', '/usr/bin', '/usr/local/bin' ],
57
+ cwd => '/',
58
+ }
59
+
60
+ $notify_elasticsearch = $elasticsearch::restart_on_change ? {
61
+ false => undef,
62
+ default => Class['elasticsearch::service'],
63
+ }
64
+
65
+ if ($module_dir != '') {
66
+ validate_string($module_dir)
67
+ } else {
68
+ fail("module_dir undefined for plugin ${name}")
69
+ }
70
+
71
+ if ($url != '') {
72
+ validate_string($url)
73
+ $install_cmd = "${elasticsearch::plugintool} -install ${name} -url ${url}"
74
+ $exec_rets = [0,1]
75
+ } else {
76
+ $install_cmd = "${elasticsearch::plugintool} -install ${name}"
77
+ $exec_rets = [0,]
78
+ }
79
+
80
+ case $ensure {
81
+ 'installed', 'present': {
82
+ exec {"install-plugin-${name}":
83
+ command => $install_cmd,
84
+ creates => "${elasticsearch::plugindir}/${module_dir}",
85
+ returns => $exec_rets,
86
+ notify => $notify_elasticsearch,
87
+ }
88
+ }
89
+ default: {
90
+ exec {"remove-plugin-${name}":
91
+ command => "${elasticsearch::plugintool} --remove ${module_dir}",
92
+ onlyif => "test -d ${elasticsearch::plugindir}/${module_dir}",
93
+ notify => $notify_elasticsearch,
94
+ }
95
+ }
96
+ }
97
+ }
@@ -0,0 +1,34 @@
1
+ # there are many python bindings for elasticsearch. This provides all
2
+ # the ones we know about http://www.elasticsearch.org/guide/clients/
3
+ define elasticsearch::python (
4
+ $ensure = 'installed',
5
+ ) {
6
+
7
+ # make sure the package name is valid and setup the provider as
8
+ # necessary
9
+ case $name {
10
+ 'pyes': {
11
+ $provider = 'pip'
12
+ }
13
+ 'rawes': {
14
+ $provider = 'pip'
15
+ }
16
+ 'pyelasticsearch': {
17
+ $provider = 'pip'
18
+ }
19
+ 'ESClient': {
20
+ $provider = 'pip'
21
+ }
22
+ 'elasticutils': {
23
+ $provider = 'pip'
24
+ }
25
+ default: {
26
+ fail("unknown python binding package '${name}'")
27
+ }
28
+ }
29
+
30
+ package { $name:
31
+ ensure => $ensure,
32
+ provider => $provider,
33
+ }
34
+ }
@@ -0,0 +1,114 @@
1
+ # == Class: elasticsearch::service
2
+ #
3
+ # This class exists to coordinate all service management related actions,
4
+ # functionality and logical units in a central place.
5
+ #
6
+ # <b>Note:</b> "service" is the Puppet term and type for background processes
7
+ # in general and is used in a platform-independent way. E.g. "service" means
8
+ # "daemon" in relation to Unix-like systems.
9
+ #
10
+ #
11
+ # === Parameters
12
+ #
13
+ # This class does not provide any parameters.
14
+ #
15
+ #
16
+ # === Examples
17
+ #
18
+ # This class may be imported by other classes to use its functionality:
19
+ # class { 'elasticsearch::service': }
20
+ #
21
+ # It is not intended to be used directly by external resources like node
22
+ # definitions or other modules.
23
+ #
24
+ #
25
+ # === Authors
26
+ #
27
+ # * Richard Pijnenburg <mailto:richard@ispavailability.com>
28
+ #
29
+ class elasticsearch::service {
30
+
31
+ include elasticsearch
32
+
33
+ $notify_elasticsearch = $elasticsearch::restart_on_change ? {
34
+ false => undef,
35
+ default => Service['elasticsearch'],
36
+ }
37
+
38
+ #### Service management
39
+
40
+ # set params: in operation
41
+ if $elasticsearch::ensure == 'present' {
42
+
43
+ case $elasticsearch::status {
44
+ # make sure service is currently running, start it on boot
45
+ 'enabled': {
46
+ $service_ensure = 'running'
47
+ $service_enable = true
48
+ }
49
+ # make sure service is currently stopped, do not start it on boot
50
+ 'disabled': {
51
+ $service_ensure = 'stopped'
52
+ $service_enable = false
53
+ }
54
+ # make sure service is currently running, do not start it on boot
55
+ 'running': {
56
+ $service_ensure = 'running'
57
+ $service_enable = false
58
+ }
59
+ # do not start service on boot, do not care whether currently running or not
60
+ 'unmanaged': {
61
+ $service_ensure = undef
62
+ $service_enable = false
63
+ }
64
+ # unknown status
65
+ # note: don't forget to update the parameter check in init.pp if you
66
+ # add a new or change an existing status.
67
+ default: {
68
+ fail("\"${elasticsearch::status}\" is an unknown service status value")
69
+ }
70
+ }
71
+
72
+ # set params: removal
73
+ } else {
74
+
75
+ # make sure the service is stopped and disabled (the removal itself will be
76
+ # done by package.pp)
77
+ $service_ensure = 'stopped'
78
+ $service_enable = false
79
+
80
+ }
81
+
82
+ file {$elasticsearch::params::service_settings_path:
83
+ ensure => file,
84
+ content => template("${module_name}/etc/default/elasticsearch.erb"),
85
+ owner => 'root',
86
+ group => 'root',
87
+ mode => '0644',
88
+ notify => $notify_elasticsearch,
89
+ }
90
+
91
+ if $elasticsearch::status != 'unmanaged' and $elasticsearch::initfile != undef {
92
+ # Write service file
93
+ file { '/etc/init.d/elasticsearch':
94
+ ensure => present,
95
+ source => $elasticsearch::initfile,
96
+ owner => 'root',
97
+ group => 'root',
98
+ mode => '0555',
99
+ before => Service[ 'elasticsearch' ]
100
+ }
101
+ }
102
+
103
+ # action
104
+ service { 'elasticsearch':
105
+ ensure => $service_ensure,
106
+ enable => $service_enable,
107
+ name => $elasticsearch::params::service_name,
108
+ hasstatus => $elasticsearch::params::service_hasstatus,
109
+ hasrestart => $elasticsearch::params::service_hasrestart,
110
+ pattern => $elasticsearch::params::service_pattern,
111
+ provider => $elasticsearch::params::service_provider,
112
+ }
113
+
114
+ }
@@ -0,0 +1,118 @@
1
+ # == Define: elasticsearch::template
2
+ #
3
+ # This define allows you to insert, update or delete templates that are used within Elasticsearch for the indexes
4
+ #
5
+ # === Parameters
6
+ #
7
+ # [*file*]
8
+ # File path of the template ( json file )
9
+ # Value type is string
10
+ # Default value: undef
11
+ # This variable is optional
12
+ #
13
+ # [*replace*]
14
+ # Set to 'true' if you intend to replace the existing template
15
+ # Value type is boolean
16
+ # Default value: false
17
+ # This variable is optional
18
+ #
19
+ # [*delete*]
20
+ # Set to 'true' if you intend to delete the existing template
21
+ # Value type is boolean
22
+ # Default value: false
23
+ # This variable is optional
24
+ #
25
+ # [*host*]
26
+ # Host name or IP address of the ES instance to connect to
27
+ # Value type is string
28
+ # Default value: localhost
29
+ # This variable is optional
30
+ #
31
+ # [*port*]
32
+ # Port number of the ES instance to connect to
33
+ # Value type is number
34
+ # Default value: 9200
35
+ # This variable is optional
36
+ #
37
+ # === Authors
38
+ #
39
+ # * Richard Pijnenburg <mailto:richard@ispavailability.com>
40
+ #
41
+ define elasticsearch::template(
42
+ $file = undef,
43
+ $replace = false,
44
+ $delete = false,
45
+ $host = 'localhost',
46
+ $port = 9200
47
+ ) {
48
+
49
+ require elasticsearch
50
+
51
+ Exec {
52
+ path => [ '/bin', '/usr/bin', '/usr/local/bin' ],
53
+ cwd => '/',
54
+ }
55
+
56
+ # Build up the url
57
+ $es_url = "http://${host}:${port}/_template/${name}"
58
+
59
+ # Can't do a replace and delete at the same time
60
+ if $replace == true and $delete == true {
61
+ fail('Replace and Delete cant be used together')
62
+ }
63
+
64
+ if $delete == false {
65
+ # Fail when no file is supplied
66
+ if $file == undef {
67
+ fail('The variable "file" cannot be empty when inserting or updating a template')
68
+ }
69
+ }
70
+
71
+ $file_ensure = $delete ? {
72
+ true => 'absent',
73
+ default => 'present'
74
+ }
75
+
76
+ $file_notify = $delete ? {
77
+ true => undef,
78
+ default => Exec[ "insert_template ${name}" ]
79
+ }
80
+
81
+ # place the template file
82
+ file { "${elasticsearch::confdir}/templates_import/elasticsearch-template-${name}.json":
83
+ ensure => $file_ensure,
84
+ source => $file,
85
+ notify => $file_notify,
86
+ require => Exec[ 'mkdir_templates' ],
87
+ }
88
+
89
+ if $replace == true or $delete == true {
90
+
91
+ # Only notify the insert_template call when we do a replace.
92
+ $exec_notify = $replace ? {
93
+ true => Exec[ "insert_template ${name}" ],
94
+ default => undef
95
+ }
96
+
97
+ # Delete the existing template
98
+ # First check if it exists of course
99
+ exec { "delete_template ${name}":
100
+ command => "curl -s -XDELETE ${es_url}",
101
+ onlyif => "test $(curl -s '${es_url}?pretty=true' | wc -l) -gt 1",
102
+ notify => $exec_notify
103
+ }
104
+
105
+ }
106
+
107
+ # Insert the template if we don't delete an existing one
108
+ # Before inserting we check if a template exists with that same name
109
+ if $delete == false {
110
+ exec { "insert_template ${name}":
111
+ command => "curl -s -XPUT ${es_url} -d @${elasticsearch::confdir}/templates_import/elasticsearch-template-${name}.json",
112
+ unless => "test $(curl -s '${es_url}?pretty=true' | wc -l) -gt 1",
113
+ refreshonly => true,
114
+ tries => 3,
115
+ try_sleep => 10
116
+ }
117
+ }
118
+ }
@@ -0,0 +1,41 @@
1
+ {
2
+ "project_page": "https://github.com/elasticsearch/puppet-elasticsearch",
3
+ "license": "Apache License, Version 2.0",
4
+ "source": "https://github.com/elasticsearch/puppet-elasticsearch",
5
+ "checksums": {
6
+ "spec/spec_helper.rb": "3ea886dd135e120afa31e0aab12e85b0",
7
+ "LICENSE": "1fc7fa7c411594f07888338b1865e9d7",
8
+ "templates/etc/elasticsearch/elasticsearch.yml.erb": "7960bf7708776396cf094e6bd5ee9e97",
9
+ "manifests/init.pp": "0a2ee898e72bc85b7f91b12b22072a04",
10
+ "manifests/package.pp": "f888a269dffc8ba1358b3fe558f7ddb9",
11
+ "manifests/template.pp": "a362fdf5c9e26510048fa9e730ed49bf",
12
+ "templates/etc/default/elasticsearch.erb": "496bf6f670c8a68653f2b9256c1539e0",
13
+ "spec/classes/elasticsearch_init_spec.rb": "d876ee65fe9cbabfc4f04de48a17c7a4",
14
+ "manifests/params.pp": "01a422c1a84ee073e0ebafc2585ff7ed",
15
+ "CHANGELOG": "6fa25a87d60ed7311403992eec4081c8",
16
+ "manifests/config.pp": "0463f24a00e0472996c0b18d5e976e5b",
17
+ "manifests/python.pp": "c3a546ce1eba575c209175867494f599",
18
+ "manifests/service.pp": "50709f07a8bea21172d59eeb15e589f1",
19
+ "Modulefile": "beaacf02407cbdcc878b0df8bef3b514",
20
+ "README.md": "a75ebe5b4562b12eda4cf4fa3f696931",
21
+ "Rakefile": "d9fad069cf2dfdc0541548e278e39bbb",
22
+ "manifests/java.pp": "94ecd1ef0bdccf492657c39a04d9d09e",
23
+ "manifests/plugin.pp": "b02c99cbd74aa0b20f547e942b854cf3",
24
+ "spec/defines/template_spec.rb": "a3bc69d8e679bdef1a4ff4957a2c68e8",
25
+ "CONTRIBUTORS": "14df2fd27cf7b6ca9833527f2ba93442"
26
+ },
27
+ "types": [
28
+
29
+ ],
30
+ "description": "Module for managing and configuring Elasticsearch nodes",
31
+ "version": "0.1.3",
32
+ "summary": "Module for managing and configuring Elasticsearch nodes",
33
+ "name": "ispavailability-elasticsearch",
34
+ "author": "ispavailability",
35
+ "dependencies": [
36
+ {
37
+ "version_requirement": ">= 3.0.0",
38
+ "name": "puppetlabs/stdlib"
39
+ }
40
+ ]
41
+ }