poise-monit 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.kitchen.yml +1 -6
  3. data/.travis.yml +6 -0
  4. data/Berksfile +2 -10
  5. data/CHANGELOG.md +7 -0
  6. data/Gemfile +2 -1
  7. data/README.md +5 -1
  8. data/Rakefile +1 -1
  9. data/chef/attributes/default.rb +3 -1
  10. data/chef/recipes/default.rb +1 -1
  11. data/chef/templates/monit.conf.erb +8 -0
  12. data/lib/poise_monit.rb +1 -1
  13. data/lib/poise_monit/cheftie.rb +1 -1
  14. data/lib/poise_monit/error.rb +1 -1
  15. data/lib/poise_monit/monit_providers.rb +1 -1
  16. data/lib/poise_monit/monit_providers/base.rb +6 -3
  17. data/lib/poise_monit/monit_providers/binaries.rb +10 -3
  18. data/lib/poise_monit/monit_providers/dummy.rb +1 -1
  19. data/lib/poise_monit/monit_providers/system.rb +1 -1
  20. data/lib/poise_monit/resources.rb +1 -1
  21. data/lib/poise_monit/resources/monit.rb +12 -1
  22. data/lib/poise_monit/resources/monit_config.rb +2 -2
  23. data/lib/poise_monit/resources/monit_service.rb +22 -6
  24. data/lib/poise_monit/resources/monit_test.rb +1 -1
  25. data/lib/poise_monit/service_providers.rb +1 -1
  26. data/lib/poise_monit/service_providers/monit.rb +1 -1
  27. data/lib/poise_monit/version.rb +2 -2
  28. data/poise-monit.gemspec +4 -3
  29. data/test/{cookbooks/poise-monit_test → cookbook}/attributes/default.rb +1 -1
  30. data/test/{cookbooks/poise-monit_test → cookbook}/metadata.rb +1 -1
  31. data/test/{cookbooks/poise-monit_test → cookbook}/recipes/default.rb +1 -1
  32. data/test/gemfiles/chef-12.1.gemfile +19 -0
  33. data/test/gemfiles/chef-12.2.gemfile +19 -0
  34. data/test/gemfiles/chef-12.3.gemfile +19 -0
  35. data/test/gemfiles/chef-12.4.gemfile +21 -0
  36. data/test/gemfiles/chef-12.5.gemfile +19 -0
  37. data/test/gemfiles/chef-12.6.gemfile +19 -0
  38. data/test/gemfiles/chef-12.gemfile +2 -2
  39. data/test/gemfiles/master.gemfile +2 -1
  40. data/test/integration/default/serverspec/Gemfile +1 -1
  41. data/test/integration/default/serverspec/default_spec.rb +15 -15
  42. data/test/spec/monit_providers/binaries_spec.rb +20 -8
  43. data/test/spec/monit_providers/dummy_spec.rb +1 -1
  44. data/test/spec/monit_providers/system_spec.rb +1 -1
  45. data/test/spec/recipe_spec.rb +1 -1
  46. data/test/spec/resources/monit_config_spec.rb +1 -1
  47. data/test/spec/resources/monit_service_spec.rb +32 -5
  48. data/test/spec/resources/monit_spec.rb +88 -1
  49. data/test/spec/service_providers/monit_spec.rb +1 -1
  50. data/test/spec/spec_helper.rb +1 -1
  51. metadata +38 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e9eed9d6be8fea50a14e11d1d7d6121df701f523
4
- data.tar.gz: c772a05c0c3e5847273aef9dee0a3badda59c8ff
3
+ metadata.gz: 3b8431aa0868c66f89d7de71426b2f9f1cfb3dbd
4
+ data.tar.gz: ae851e48383783f8ee8c18731aea27310a9c2077
5
5
  SHA512:
6
- metadata.gz: f4b482f94cffcb183b05928211f331b39d939855692c6e58dbe9981ff37aa289f69d97416189e53564e14cc826dd589e14fde90208afef68e3480cb3b57cb808
7
- data.tar.gz: 1fa4a28e969c98219be54689fc7b3b5d3f79d03b55d723d4c41c62e0b2dfb363b29120d9640c3cb3bf2b2977c082d0df109c52f2d9e4551e565e1956ca8ecac0
6
+ metadata.gz: a057f285f6ab413378e3a6cc863ff11a98698ce8470f5e2b249d0cb2a0576aa28574c14bdb60cacc5d6d83d1c71d00368e12b168d675ca735a97a5454c4b3183
7
+ data.tar.gz: 1a8a1a3895ac84e20bb6d747af4af3724362ac4737231fcf69af42f1b51e24e3613e28c07995fff485afcfe229253a4d9a526234fa005d93220e23c87d91ec16
data/.kitchen.yml CHANGED
@@ -1,8 +1,3 @@
1
1
  ---
2
2
  #<% require 'poise_boiler' %>
3
- <%= PoiseBoiler.kitchen(platforms: 'linux') %>
4
-
5
- suites:
6
- - name: default
7
- run_list:
8
- - recipe[poise-monit_test]
3
+ <%= PoiseBoiler.kitchen %>
data/.travis.yml CHANGED
@@ -17,4 +17,10 @@ script:
17
17
  - "./bin/rake travis"
18
18
  gemfile:
19
19
  - test/gemfiles/chef-12.gemfile
20
+ - test/gemfiles/chef-12.1.gemfile
21
+ - test/gemfiles/chef-12.2.gemfile
22
+ - test/gemfiles/chef-12.3.gemfile
23
+ - test/gemfiles/chef-12.4.gemfile
24
+ - test/gemfiles/chef-12.5.gemfile
25
+ - test/gemfiles/chef-12.6.gemfile
20
26
  - test/gemfiles/master.gemfile
data/Berksfile CHANGED
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015, Noah Kantrowitz
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -15,15 +15,7 @@
15
15
  #
16
16
 
17
17
  source 'https://supermarket.chef.io/'
18
- extension 'halite'
19
-
20
- # Force the rebuild every time for development.
21
- cookbook 'poise', gem: 'poise'
22
- cookbook 'poise-languages', gem: 'poise-languages'
23
- cookbook 'poise-service', gem: 'poise-service'
24
- cookbook 'poise-monit', gem: 'poise-monit'
25
18
 
26
19
  group :test do
27
- cookbook 'poise-monit_test', path: 'test/cookbooks/poise-monit_test'
28
- cookbook 'apt'
20
+ cookbook 'yum-epel'
29
21
  end
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Poise-Monit Changelog
2
2
 
3
+ ## v1.1.0
4
+
5
+ * Improve compatibility with Chef 12.4 and earlier.
6
+ * New property for `monit` resource: `demon_delay` to control start delay.
7
+ * More verbose output from Monit when Chef is running in debug mode.
8
+ * Update binaries provider for Monit 5.16.
9
+
3
10
  ## v1.0.1
4
11
 
5
12
  * Small fix for compatibility with `poise-service-monit`.
data/Gemfile CHANGED
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015, Noah Kantrowitz
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -31,5 +31,6 @@ dev_gem 'halite'
31
31
  dev_gem 'poise'
32
32
  dev_gem 'poise-boiler'
33
33
  dev_gem 'poise-languages'
34
+ dev_gem 'poise-profiler'
34
35
  dev_gem 'poise-service'
35
36
 
data/README.md CHANGED
@@ -88,6 +88,10 @@ end
88
88
 
89
89
  * `service_name` – Name of the Monit instance. *(name attribute)*
90
90
  * `daemon_interval` – Number of seconds between service checks. *(default: 120)*
91
+ * `daemon_delay` – Number of intervals to wait on startup before running service
92
+ checks. If unset or 0, no start delay is used. *(default: nil)*
93
+ * `daemon_verbose` – Run the daemon in verbose mode for debugging. *(default:
94
+ log_level==debug)*
91
95
  * `event_slots` – Number of slots in the Monit event buffer. Set to 0 to disable
92
96
  event buffering, or -1 for an unlimited queue. *(default: 100)*
93
97
  * `httpd_port` – Port to listen on for Monit's HTTPD. If a path is specified, it
@@ -227,7 +231,7 @@ The Poise test server infrastructure is sponsored by [Rackspace](https://rackspa
227
231
 
228
232
  ## License
229
233
 
230
- Copyright 2015, Noah Kantrowitz
234
+ Copyright 2015-2016, Noah Kantrowitz
231
235
 
232
236
  Licensed under the Apache License, Version 2.0 (the "License");
233
237
  you may not use this file except in compliance with the License.
data/Rakefile CHANGED
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015, Noah Kantrowitz
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015, Noah Kantrowitz
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -24,6 +24,8 @@ default['poise-monit']['options'] = {}
24
24
  # Attributes for recipe[poise-monit]. All values are nil because the actual
25
25
  # defaults live in the resource.
26
26
  default['poise-monit']['recipe']['daemon_interval'] = nil
27
+ default['poise-monit']['recipe']['daemon_delay'] = nil
28
+ default['poise-monit']['recipe']['daemon_verbose'] = nil
27
29
  default['poise-monit']['recipe']['event_slots'] = nil
28
30
  default['poise-monit']['recipe']['httpd_port'] = nil
29
31
  default['poise-monit']['recipe']['httpd_password'] = nil
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015, Noah Kantrowitz
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -1,5 +1,13 @@
1
1
  # Generated by Chef for <%= @new_resource.to_s %>
2
2
 
3
+ <%# If daemon_delay is nil/false we put the value on the command line with -d %>
4
+ <%- if @new_resource.daemon_delay -%>
5
+ SET DAEMON <%= @new_resource.daemon_interval %>
6
+ <%- if @new_resource.daemon_delay > 0 -%>
7
+ WITH START DELAY <%= @new_resource.daemon_delay %>
8
+ <%- end -%>
9
+ <%- end -%>
10
+
3
11
  SET PIDFILE <%= @new_resource.pidfile %>
4
12
 
5
13
  <%- if @new_resource.logfile -%>
data/lib/poise_monit.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015, Noah Kantrowitz
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015, Noah Kantrowitz
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015, Noah Kantrowitz
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015, Noah Kantrowitz
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015, Noah Kantrowitz
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -141,7 +141,7 @@ module PoiseMonit
141
141
  mode '600'
142
142
  notifies :reload, new_resource, :immediately
143
143
  owner new_resource.owner
144
- verify "#{monit_binary} -t -c %{path}"
144
+ verify "#{monit_binary} -t -c #{Poise::Backports::VERIFY_PATH}" if defined?(verify)
145
145
  end
146
146
  end
147
147
 
@@ -163,7 +163,10 @@ module PoiseMonit
163
163
 
164
164
  # Configure properties for Monit service resource.
165
165
  def service_options(r)
166
- r.command("#{monit_binary} -c #{new_resource.config_path} -I -d #{new_resource.daemon_interval}")
166
+ cmd = "#{monit_binary} -c #{new_resource.config_path} -I"
167
+ cmd << " -d #{new_resource.daemon_interval}" unless new_resource.daemon_delay
168
+ cmd << ' -v' if new_resource.daemon_verbose
169
+ r.command(cmd)
167
170
  r.provider_no_auto('monit')
168
171
  r.user(new_resource.owner)
169
172
  end
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015, Noah Kantrowitz
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -30,7 +30,7 @@ module PoiseMonit
30
30
  provides(:binaries)
31
31
  include PoiseLanguages::Static(
32
32
  name: 'monit',
33
- versions: %w{5.15},
33
+ versions: %w{5.16},
34
34
  machines: %w{aix5.3-ppc aix6.1-ppc freebsd-x64 freebsd-x86 linux-x64 linux-x86 linux-arm macosx-universal openbsd-x64 openbsd-x86 solaris-sparc solaris-x64},
35
35
  url: 'https://bitbucket.org/tildeslash/monit/downloads/monit-%{version}-%{machine_label}.tar.gz'
36
36
  )
@@ -70,7 +70,14 @@ module PoiseMonit
70
70
  raw_kernel = (node['kernel']['name'] || 'unknown').downcase
71
71
  kernel = case raw_kernel
72
72
  when 'aix'
73
- "aix#{node['kernel']['version']}.#{node['kernel']['release']}"
73
+ # Less correct than "aix#{node['kernel']['version']}.#{node['kernel']['release']}"
74
+ # but more likely to work on more systems. Notably we think the 6.1
75
+ # build should work on AIX 7 just fine.
76
+ if node['kernel']['version'].to_i <= 5
77
+ 'aix5.3'
78
+ else
79
+ 'aix6.1'
80
+ end
74
81
  when 'sunos'
75
82
  'solaris'
76
83
  when 'darwin'
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015, Noah Kantrowitz
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015, Noah Kantrowitz
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015, Noah Kantrowitz
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015, Noah Kantrowitz
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -52,6 +52,17 @@ module PoiseMonit
52
52
  # Number of seconds between service checks. Defaults to 120 seconds.
53
53
  # @return [Integer]
54
54
  attribute(:daemon_interval, kind_of: Integer, default: 120)
55
+ # @!attribute daemon_delay
56
+ # Number of intervals to wait on startup before running service checks.
57
+ # If unset or 0, no start delay is used. Defaults to nil for backwards
58
+ # compat.
59
+ # @return [Integer, nil, false]
60
+ attribute(:daemon_delay, kind_of: [Integer, NilClass, FalseClass], default: nil)
61
+ # @!attribute daemon_verbose
62
+ # Run the daemon in verbose mode for debugging. Defaults to true if
63
+ # Chef is run with debug logging.
64
+ # @return [Boolean]
65
+ attribute(:daemon_verbose, equal_to: [true, false], default: lazy { Chef::Log.level == :debug })
55
66
  # @!attribute event_slots
56
67
  # Number of slots in the Monit event buffer. Set to 0 to disable
57
68
  # event buffering, or -1 for an unlimited queue. Defaults to 100.
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015, Noah Kantrowitz
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -93,7 +93,7 @@ module PoiseMonit
93
93
  mode '600'
94
94
  notifies :reload, new_resource.parent, :immediately
95
95
  owner new_resource.parent.owner if new_resource.parent.owner
96
- verify "#{new_resource.parent.monit_binary} -t -c %{path}"
96
+ verify "#{new_resource.parent.monit_binary} -t -c #{Poise::Backports::VERIFY_PATH}" if defined?(verify)
97
97
  end
98
98
  end
99
99
 
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015, Noah Kantrowitz
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -51,7 +51,16 @@ module PoiseMonit
51
51
  provides(:monit_service)
52
52
  actions(:enable, :disable, :start, :stop, :restart)
53
53
 
54
+ # @!attribute monit_config_path
55
+ # Optional path to a config file that corresponds to this service to
56
+ # speed up some idempotence checks.
57
+ # @return [String, nil, false]
54
58
  attribute(:monit_config_path, kind_of: [String, NilClass, FalseClass])
59
+ # @!attribute monit_verbose
60
+ # Run monit commands in verbose mode for debugging. Defaults to true
61
+ # if Chef is run with debug logging.
62
+ # @return [Boolean]
63
+ attribute(:monit_verbose, equal_to: [true, false], default: lazy { Chef::Log.level == :debug })
55
64
 
56
65
  # Unsupported properties.
57
66
  %w{pattern reload_command priority timeout parameters run_levels}.each do |name|
@@ -76,10 +85,12 @@ module PoiseMonit
76
85
  provides(:monit_service)
77
86
 
78
87
  def load_current_resource
79
- super
88
+ # Only call super if it won't ruin things. Chef 12.4 and earlier didn't
89
+ # declare Provider::Service#load_current_resource.
90
+ super if self.class.superclass.instance_method(:load_current_resource).owner != Chef::Provider
80
91
  @current_resource = MonitService::Resource.new(new_resource.name).tap do |r|
81
92
  r.service_name(new_resource.service_name)
82
- if new_resource.monit_config_path && !::File.exist?(new_resource.monit_config_path)
93
+ if defined?(new_resource.monit_config_path) && new_resource.monit_config_path && !::File.exist?(new_resource.monit_config_path)
83
94
  Chef::Log.debug("[#{new_resource}] Config file #{new_resource.monit_config_path} does not exist, not checking status")
84
95
  r.enabled(false)
85
96
  r.running(false)
@@ -119,7 +130,7 @@ module PoiseMonit
119
130
  end
120
131
 
121
132
  def disable_service
122
- if new_resource.monit_config_path && !::File.exist?(new_resource.monit_config_path)
133
+ if defined?(new_resource.monit_config_path) && new_resource.monit_config_path && !::File.exist?(new_resource.monit_config_path)
123
134
  Chef::Log.debug("[#{new_resource}] Config file #{new_resource.monit_config_path} does not exist, not trying to unmonitor")
124
135
  return
125
136
  end
@@ -132,11 +143,14 @@ module PoiseMonit
132
143
 
133
144
  def start_service
134
145
  monit_shell_out!('start')
146
+ # No this isn't a typo, it's a ragefix to make older Monit (like
147
+ # Ubuntu' packages) always start things even right after an enable
148
+ # action. I am really unclear why running start twice fixes this :-(
135
149
  monit_shell_out!('start')
136
150
  end
137
151
 
138
152
  def stop_service
139
- if new_resource.monit_config_path && !::File.exist?(new_resource.monit_config_path)
153
+ if defined?(new_resource.monit_config_path) && new_resource.monit_config_path && !::File.exist?(new_resource.monit_config_path)
140
154
  Chef::Log.debug("[#{new_resource}] Config file #{new_resource.monit_config_path} does not exist, not trying to stop")
141
155
  return
142
156
  end
@@ -163,7 +177,9 @@ module PoiseMonit
163
177
 
164
178
  def monit_shell_out!(monit_cmd, timeout: DEFAULT_TIMEOUT, wait: DEFAULT_WAIT, &block)
165
179
  while true
166
- cmd_args = [new_resource.parent.monit_binary, '-c', new_resource.parent.config_path, monit_cmd, new_resource.service_name]
180
+ cmd_args = [new_resource.parent.monit_binary]
181
+ cmd_args << '-v' if (defined?(new_resource.monit_verbose) && new_resource.monit_verbose) || Chef::Log.level == :debug
182
+ cmd_args.concat(['-c', new_resource.parent.config_path, monit_cmd, new_resource.service_name])
167
183
  Chef::Log.debug("[#{new_resource}] Running #{cmd_args.join(' ')}")
168
184
  cmd = poise_shell_out(cmd_args, user: new_resource.parent.owner, group: new_resource.parent.group)
169
185
  error = block ? block.call(cmd) : cmd.error?
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015, Noah Kantrowitz
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015, Noah Kantrowitz
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015, Noah Kantrowitz
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015, Noah Kantrowitz
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -16,5 +16,5 @@
16
16
 
17
17
 
18
18
  module PoiseMonit
19
- VERSION = '1.0.1'
19
+ VERSION = '1.1.0'
20
20
  end
data/poise-monit.gemspec CHANGED
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015, Noah Kantrowitz
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -34,11 +34,12 @@ Gem::Specification.new do |spec|
34
34
  spec.require_paths = %w{lib}
35
35
 
36
36
  spec.add_dependency 'halite', '~> 1.1'
37
- spec.add_dependency 'poise', '~> 2.5'
37
+ spec.add_dependency 'poise', '~> 2.6'
38
38
  spec.add_dependency 'poise-languages', '~> 1.3'
39
39
  spec.add_dependency 'poise-service', '~> 1.1'
40
40
 
41
- spec.add_development_dependency 'poise-boiler', '~> 1.0'
41
+ spec.add_development_dependency 'berkshelf', '~> 4.0'
42
+ spec.add_development_dependency 'poise-boiler', '~> 1.6'
42
43
 
43
44
  # Leaving this hear but commented so it is clear this dependency has been
44
45
  # removed on purpose. It's going to be a rare thing, so don't pull it in.
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015, Noah Kantrowitz
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015, Noah Kantrowitz
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015, Noah Kantrowitz
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -0,0 +1,19 @@
1
+ #
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ eval_gemfile File.expand_path('../../../Gemfile', __FILE__)
18
+
19
+ gem 'chef', '~> 12.1.2'
@@ -0,0 +1,19 @@
1
+ #
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ eval_gemfile File.expand_path('../../../Gemfile', __FILE__)
18
+
19
+ gem 'chef', '~> 12.2.1'
@@ -0,0 +1,19 @@
1
+ #
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ eval_gemfile File.expand_path('../../../Gemfile', __FILE__)
18
+
19
+ gem 'chef', '~> 12.3.0'
@@ -0,0 +1,21 @@
1
+ #
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ eval_gemfile File.expand_path('../../../Gemfile', __FILE__)
18
+
19
+ gem 'chef', '~> 12.4.3'
20
+ # Pending https://github.com/berkshelf/ridley/pull/335
21
+ gem 'ridley', '4.4.1'
@@ -0,0 +1,19 @@
1
+ #
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ eval_gemfile File.expand_path('../../../Gemfile', __FILE__)
18
+
19
+ gem 'chef', '~> 12.5.1'
@@ -0,0 +1,19 @@
1
+ #
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ eval_gemfile File.expand_path('../../../Gemfile', __FILE__)
18
+
19
+ gem 'chef', '~> 12.6.0'
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015, Noah Kantrowitz
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -16,4 +16,4 @@
16
16
 
17
17
  eval_gemfile File.expand_path('../../../Gemfile', __FILE__)
18
18
 
19
- gem 'chef', '~> 12.0'
19
+ gem 'chef', '~> 12.6'
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015, Noah Kantrowitz
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -21,4 +21,5 @@ gem 'halite', github: 'poise/halite'
21
21
  gem 'poise', github: 'poise/poise'
22
22
  gem 'poise-boiler', github: 'poise/poise-boiler'
23
23
  gem 'poise-languages', github: 'poise/poise-languages'
24
+ gem 'poise-profiler', github: 'poise/poise-profiler'
24
25
  gem 'poise-service', github: 'poise/poise-service'
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015, Noah Kantrowitz
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -1,18 +1,18 @@
1
- # #
2
- # # Copyright 2015, Noah Kantrowitz
3
- # #
4
- # # Licensed under the Apache License, Version 2.0 (the "License");
5
- # # you may not use this file except in compliance with the License.
6
- # # You may obtain a copy of the License at
7
- # #
8
- # # http://www.apache.org/licenses/LICENSE-2.0
9
- # #
10
- # # Unless required by applicable law or agreed to in writing, software
11
- # # distributed under the License is distributed on an "AS IS" BASIS,
12
- # # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # # See the License for the specific language governing permissions and
14
- # # limitations under the License.
15
- # #
1
+ #
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
16
 
17
17
  require 'serverspec'
18
18
  set :backend, :exec
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015, Noah Kantrowitz
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -37,7 +37,7 @@ describe PoiseMonit::MonitProviders::Binaries do
37
37
  end
38
38
 
39
39
  context 'with no version' do
40
- it_behaves_like 'binaries provider', 'monit-5.15', 'https://bitbucket.org/tildeslash/monit/downloads/monit-5.15-linux-x64.tar.gz'
40
+ it_behaves_like 'binaries provider', 'monit-5.16', 'https://bitbucket.org/tildeslash/monit/downloads/monit-5.16-linux-x64.tar.gz'
41
41
  end # /context with no version
42
42
 
43
43
  context 'with version 5.14' do
@@ -58,27 +58,39 @@ describe PoiseMonit::MonitProviders::Binaries do
58
58
 
59
59
  context 'on CentOS 7' do
60
60
  let(:chefspec_options) { {platform: 'centos', version: '7.0'} }
61
- it_behaves_like 'binaries provider', 'monit-5.15', 'https://bitbucket.org/tildeslash/monit/downloads/monit-5.15-linux-x64.tar.gz'
61
+ it_behaves_like 'binaries provider', 'monit-5.16', 'https://bitbucket.org/tildeslash/monit/downloads/monit-5.16-linux-x64.tar.gz'
62
62
  end # /context on CentOS 7
63
63
 
64
64
  context 'on Fedora 18 (x86)' do
65
65
  let(:chefspec_options) { {platform: 'fedora', version: '18'} }
66
- it_behaves_like 'binaries provider', 'monit-5.15', 'https://bitbucket.org/tildeslash/monit/downloads/monit-5.15-linux-x86.tar.gz'
66
+ it_behaves_like 'binaries provider', 'monit-5.16', 'https://bitbucket.org/tildeslash/monit/downloads/monit-5.16-linux-x86.tar.gz'
67
67
  end # /context on Fedora 18 (x86)
68
68
 
69
+ context 'on AIX 5' do
70
+ # Fauxhai doesn't have AIX 5 data, so fake it.
71
+ let(:chefspec_options) { {platform: 'aix', version: '6.1'} }
72
+ before { chef_runner.node.automatic['kernel']['version'] = 5 }
73
+ it_behaves_like 'binaries provider', 'monit-5.16', 'https://bitbucket.org/tildeslash/monit/downloads/monit-5.16-aix5.3-ppc.tar.gz'
74
+ end # /context on AIX 5
75
+
69
76
  context 'on AIX 6' do
70
77
  let(:chefspec_options) { {platform: 'aix', version: '6.1'} }
71
- it_behaves_like 'binaries provider', 'monit-5.15', 'https://bitbucket.org/tildeslash/monit/downloads/monit-5.15-aix6.1-ppc.tar.gz'
78
+ it_behaves_like 'binaries provider', 'monit-5.16', 'https://bitbucket.org/tildeslash/monit/downloads/monit-5.16-aix6.1-ppc.tar.gz'
72
79
  end # /context on AIX 6
73
80
 
81
+ context 'on AIX 7' do
82
+ let(:chefspec_options) { {platform: 'aix', version: '7.1'} }
83
+ it_behaves_like 'binaries provider', 'monit-5.16', 'https://bitbucket.org/tildeslash/monit/downloads/monit-5.16-aix6.1-ppc.tar.gz'
84
+ end # /context on AIX 7
85
+
74
86
  context 'on Solaris 5.11' do
75
87
  let(:chefspec_options) { {platform: 'solaris2', version: '5.11'} }
76
- it_behaves_like 'binaries provider', 'monit-5.15', 'https://bitbucket.org/tildeslash/monit/downloads/monit-5.15-solaris-x64.tar.gz'
88
+ it_behaves_like 'binaries provider', 'monit-5.16', 'https://bitbucket.org/tildeslash/monit/downloads/monit-5.16-solaris-x64.tar.gz'
77
89
  end # /context on Solaris 5.11
78
90
 
79
91
  context 'on OS X 10.11.1' do
80
92
  let(:chefspec_options) { {platform: 'mac_os_x', version: '10.11.1'} }
81
- it_behaves_like 'binaries provider', 'monit-5.15', 'https://bitbucket.org/tildeslash/monit/downloads/monit-5.15-macosx-universal.tar.gz'
93
+ it_behaves_like 'binaries provider', 'monit-5.16', 'https://bitbucket.org/tildeslash/monit/downloads/monit-5.16-macosx-universal.tar.gz'
82
94
  end # /context on OS X 10.11.1
83
95
 
84
96
  context 'action :disable' do
@@ -90,6 +102,6 @@ describe PoiseMonit::MonitProviders::Binaries do
90
102
  end
91
103
  end
92
104
 
93
- it { is_expected.to uninstall_poise_languages_static('/opt/monit-5.15') }
105
+ it { is_expected.to uninstall_poise_languages_static('/opt/monit-5.16') }
94
106
  end # /context action :disable
95
107
  end
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015, Noah Kantrowitz
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015, Noah Kantrowitz
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015, Noah Kantrowitz
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015, Noah Kantrowitz
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015, Noah Kantrowitz
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -24,6 +24,8 @@ describe PoiseMonit::Resources::MonitService do
24
24
  let(:test_provider) { test_resource.provider_for_action(action) }
25
25
  subject { test_provider.run_action }
26
26
  before do
27
+ # Force the default log level because it alters the tests.
28
+ chefspec_options.delete(:log_level)
27
29
  # Give us some files to work with that won't hit the disk.
28
30
  allow(File).to receive(:exist?).and_call_original
29
31
  allow(File).to receive(:exist?).with('/exists').and_return(true)
@@ -34,19 +36,19 @@ describe PoiseMonit::Resources::MonitService do
34
36
  # Status for simple cases.
35
37
  stub_status(status) if status
36
38
  end
37
- def stub_cmd(cmd, error: false, stdout: '', stderr: '', &block)
39
+ def stub_cmd(cmd, error: false, stdout: '', stderr: '', verbose: false, &block)
38
40
  fake_cmd = double("output of monit #{cmd}", error?: error, stdout: stdout, stderr: stderr)
39
41
  if error
40
42
  allow(fake_cmd).to receive(:error!).and_raise(Mixlib::ShellOut::ShellCommandFailed)
41
43
  else
42
44
  allow(fake_cmd).to receive(:error!)
43
45
  end
44
- matcher = receive(:poise_shell_out).with(['/bin/monit', '-c', '/etc/monit/monitrc', cmd, 'myapp'], user: nil, group: nil).and_return(fake_cmd).ordered
46
+ matcher = receive(:poise_shell_out).with(['/bin/monit', (verbose ? '-v' : []), '-c', '/etc/monit/monitrc', cmd, 'myapp'].flatten, user: nil, group: nil).and_return(fake_cmd).ordered
45
47
  matcher = block.call(matcher) if block
46
48
  expect(test_provider).to matcher
47
49
  end
48
- def stub_status(status)
49
- stub_cmd('status', stdout: "Process 'myapp'\n status #{status}")
50
+ def stub_status(status, verbose: false)
51
+ stub_cmd('status', stdout: "Process 'myapp'\n status #{status}", verbose: verbose)
50
52
  end
51
53
 
52
54
  describe 'action :enable' do
@@ -67,6 +69,31 @@ describe PoiseMonit::Resources::MonitService do
67
69
  subject
68
70
  end
69
71
  end # /context with status Running
72
+
73
+ context 'with monit_verbose' do
74
+ before do
75
+ test_resource.monit_verbose(true)
76
+ end
77
+ it do
78
+ stub_status('Not monitored', verbose: true)
79
+ stub_cmd('monitor', verbose: true)
80
+ subject
81
+ end
82
+ end # /context with monit_verbose
83
+
84
+ context 'with log_level debug' do
85
+ before do
86
+ chefspec_options[:log_level] = :debug
87
+ # Don't actually show debug or info logs.
88
+ allow(Chef::Log).to receive(:info)
89
+ allow(Chef::Log).to receive(:debug)
90
+ end
91
+ it do
92
+ stub_status('Not monitored', verbose: true)
93
+ stub_cmd('monitor', verbose: true)
94
+ subject
95
+ end
96
+ end # /context with log_level debug
70
97
  end # /describe action :enable
71
98
 
72
99
  describe 'action :disable' do
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015, Noah Kantrowitz
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -21,9 +21,14 @@ describe PoiseMonit::Resources::Monit do
21
21
  let(:monit_version) { '5.15' }
22
22
  let(:monit_version_cmd) { double('monit_version_cmd', error?: false, stdout: "This is Monit version #{monit_version}\nCopyright (C) 2001-2013 Tildeslash Ltd. All Rights Reserved.\n") }
23
23
  before do
24
+ # Force the default log level because it alters the tests.
25
+ chefspec_options.delete(:log_level)
24
26
  allow_any_instance_of(described_class::Resource).to receive(:shell_out).and_call_original
25
27
  allow_any_instance_of(described_class::Resource).to receive(:shell_out).with(%w{/bin/monit -V}).and_return(monit_version_cmd)
26
28
  end
29
+ def service_resource(name)
30
+ chef_run.monit(name).provider_for_action(:enable).send(:service_resource)
31
+ end
27
32
 
28
33
  context 'action :enable' do
29
34
  recipe do
@@ -33,6 +38,7 @@ describe PoiseMonit::Resources::Monit do
33
38
  it { is_expected.to render_file('/etc/monit/monitrc').with_content(<<-EOH) }
34
39
  # Generated by Chef for monit[monit]
35
40
 
41
+
36
42
  SET PIDFILE /var/run/monit_real.pid
37
43
 
38
44
  SET LOGFILE /var/log/monit.log
@@ -50,6 +56,7 @@ EOH
50
56
  it { is_expected.to create_directory('/etc/monit/conf.d') }
51
57
  it { is_expected.to create_directory('/var/lib/monit') }
52
58
  it { is_expected.to create_directory('/var/lib/monit/events') }
59
+ it { expect(service_resource('monit').command).to eq '/bin/monit -c /etc/monit/monitrc -I -d 120' }
53
60
 
54
61
  context 'with a different name' do
55
62
  recipe do
@@ -59,6 +66,7 @@ EOH
59
66
  it { is_expected.to render_file('/etc/monit-other/monitrc').with_content(<<-EOH) }
60
67
  # Generated by Chef for monit[other]
61
68
 
69
+
62
70
  SET PIDFILE /var/run/monit-other_real.pid
63
71
 
64
72
  SET LOGFILE /var/log/monit-other.log
@@ -76,8 +84,66 @@ EOH
76
84
  it { is_expected.to create_directory('/etc/monit-other/conf.d') }
77
85
  it { is_expected.to create_directory('/var/lib/monit-other') }
78
86
  it { is_expected.to create_directory('/var/lib/monit-other/events') }
87
+ it { expect(service_resource('other').command).to eq '/bin/monit -c /etc/monit-other/monitrc -I -d 120' }
79
88
  end # /context with a different name
80
89
 
90
+ context 'with daemon_delay 0' do
91
+ recipe do
92
+ monit 'monit' do
93
+ daemon_delay 0
94
+ end
95
+ end
96
+
97
+ it { is_expected.to render_file('/etc/monit/monitrc').with_content(<<-EOH) }
98
+ # Generated by Chef for monit[monit]
99
+
100
+ SET DAEMON 120
101
+
102
+ SET PIDFILE /var/run/monit_real.pid
103
+
104
+ SET LOGFILE /var/log/monit.log
105
+
106
+ SET IDFILE /var/lib/monit/id
107
+ SET STATEFILE /var/lib/monit/state
108
+ SET EVENTQUEUE BASEDIR /var/lib/monit/events SLOTS 100
109
+
110
+ SET HTTPD UNIXSOCKET /var/run/monit.sock
111
+ ALLOW 0.0.0.0/0
112
+
113
+ INCLUDE /etc/monit/conf.d/*
114
+ EOH
115
+ it { expect(service_resource('monit').command).to eq '/bin/monit -c /etc/monit/monitrc -I' }
116
+ end # /context with daemon_delay 0
117
+
118
+ context 'with daemon_delay 5' do
119
+ recipe do
120
+ monit 'monit' do
121
+ daemon_delay 5
122
+ end
123
+ end
124
+
125
+ it { is_expected.to render_file('/etc/monit/monitrc').with_content(<<-EOH) }
126
+ # Generated by Chef for monit[monit]
127
+
128
+ SET DAEMON 120
129
+ WITH START DELAY 5
130
+
131
+ SET PIDFILE /var/run/monit_real.pid
132
+
133
+ SET LOGFILE /var/log/monit.log
134
+
135
+ SET IDFILE /var/lib/monit/id
136
+ SET STATEFILE /var/lib/monit/state
137
+ SET EVENTQUEUE BASEDIR /var/lib/monit/events SLOTS 100
138
+
139
+ SET HTTPD UNIXSOCKET /var/run/monit.sock
140
+ ALLOW 0.0.0.0/0
141
+
142
+ INCLUDE /etc/monit/conf.d/*
143
+ EOH
144
+ it { expect(service_resource('monit').command).to eq '/bin/monit -c /etc/monit/monitrc -I' }
145
+ end # /context with daemon_delay 5
146
+
81
147
  context 'with 0 events slots' do
82
148
  recipe do
83
149
  monit 'monit' do
@@ -97,5 +163,26 @@ EOH
97
163
 
98
164
  it { is_expected.to render_file('/etc/monit/monitrc').with_content("SET EVENTQUEUE BASEDIR /var/lib/monit/events\n") }
99
165
  end # /context with -1 events slots
166
+
167
+ context 'with daemon_verbose' do
168
+ recipe do
169
+ monit 'monit' do
170
+ daemon_verbose true
171
+ end
172
+ end
173
+
174
+ it { expect(service_resource('monit').command).to eq '/bin/monit -c /etc/monit/monitrc -I -d 120 -v' }
175
+ end # /context with daemon_verbose
176
+
177
+ context 'with log_level debug' do
178
+ before do
179
+ chefspec_options[:log_level] = :debug
180
+ # Don't actually show debug or info logs.
181
+ allow(Chef::Log).to receive(:info)
182
+ allow(Chef::Log).to receive(:debug)
183
+ end
184
+
185
+ it { expect(service_resource('monit').command).to eq '/bin/monit -c /etc/monit/monitrc -I -d 120 -v' }
186
+ end # /context with log_level debug
100
187
  end # /context action :enable
101
188
  end
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015, Noah Kantrowitz
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2015, Noah Kantrowitz
2
+ # Copyright 2015-2016, Noah Kantrowitz
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: poise-monit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Noah Kantrowitz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-09 00:00:00.000000000 Z
11
+ date: 2016-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: halite
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '2.5'
33
+ version: '2.6'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '2.5'
40
+ version: '2.6'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: poise-languages
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -66,20 +66,34 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.1'
69
+ - !ruby/object:Gem::Dependency
70
+ name: berkshelf
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '4.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '4.0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: poise-boiler
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
87
  - - "~>"
74
88
  - !ruby/object:Gem::Version
75
- version: '1.0'
89
+ version: '1.6'
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
94
  - - "~>"
81
95
  - !ruby/object:Gem::Version
82
- version: '1.0'
96
+ version: '1.6'
83
97
  description: A Chef cookbook for managing the Monit process manager.
84
98
  email:
85
99
  - noah@coderanger.net
@@ -118,11 +132,17 @@ files:
118
132
  - lib/poise_monit/service_providers/monit.rb
119
133
  - lib/poise_monit/version.rb
120
134
  - poise-monit.gemspec
121
- - test/cookbooks/poise-monit_test/attributes/default.rb
122
- - test/cookbooks/poise-monit_test/metadata.rb
123
- - test/cookbooks/poise-monit_test/recipes/default.rb
135
+ - test/cookbook/attributes/default.rb
136
+ - test/cookbook/metadata.rb
137
+ - test/cookbook/recipes/default.rb
124
138
  - test/docker/docker.ca
125
139
  - test/docker/docker.pem
140
+ - test/gemfiles/chef-12.1.gemfile
141
+ - test/gemfiles/chef-12.2.gemfile
142
+ - test/gemfiles/chef-12.3.gemfile
143
+ - test/gemfiles/chef-12.4.gemfile
144
+ - test/gemfiles/chef-12.5.gemfile
145
+ - test/gemfiles/chef-12.6.gemfile
126
146
  - test/gemfiles/chef-12.gemfile
127
147
  - test/gemfiles/master.gemfile
128
148
  - test/integration/default/serverspec/Gemfile
@@ -161,11 +181,17 @@ signing_key:
161
181
  specification_version: 4
162
182
  summary: A Chef cookbook for managing the Monit process manager.
163
183
  test_files:
164
- - test/cookbooks/poise-monit_test/attributes/default.rb
165
- - test/cookbooks/poise-monit_test/metadata.rb
166
- - test/cookbooks/poise-monit_test/recipes/default.rb
184
+ - test/cookbook/attributes/default.rb
185
+ - test/cookbook/metadata.rb
186
+ - test/cookbook/recipes/default.rb
167
187
  - test/docker/docker.ca
168
188
  - test/docker/docker.pem
189
+ - test/gemfiles/chef-12.1.gemfile
190
+ - test/gemfiles/chef-12.2.gemfile
191
+ - test/gemfiles/chef-12.3.gemfile
192
+ - test/gemfiles/chef-12.4.gemfile
193
+ - test/gemfiles/chef-12.5.gemfile
194
+ - test/gemfiles/chef-12.6.gemfile
169
195
  - test/gemfiles/chef-12.gemfile
170
196
  - test/gemfiles/master.gemfile
171
197
  - test/integration/default/serverspec/Gemfile