Skip to content

Commit

Permalink
Merge pull request bbg-cookbooks#72 from StuporHero/issue-71
Browse files Browse the repository at this point in the history
Corrected hash index syntax
  • Loading branch information
nathwill authored Apr 13, 2017
2 parents 4b3b47f + a2625a7 commit d5d4c53
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 15 deletions.
30 changes: 15 additions & 15 deletions templates/default/monit.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ set pidfile <%= @pid_file %>

<% @mail_servers.each do |mailserver| %>
set mailserver
<%= mailserver.hostname %>
<% if mailserver.key?('port') && mailserver.port %>
port <%= mailserver.port %>
<%= mailserver['hostname'] %>
<% if mailserver.key?('port') && mailserver['port'] %>
port <%= mailserver['port'] %>
<% end %>
<% if mailserver.key?('username') && mailserver.username %>
username '<%= mailserver.username %>'
<% if mailserver.key?('username') && mailserver['username'] %>
username '<%= mailserver['username'] %>'
<% end %>
<% if mailserver.key?('password') && mailserver.password %>
password '<%= mailserver.password %>'
<% if mailserver.key?('password') && mailserver['password'] %>
password '<%= mailserver['password'] %>'
<% end %>
<% if mailserver.key?('security') && mailserver.security %>
using <%= mailserver.security.upcase %>
<% if mailserver.key?('security') && mailserver['security'] %>
using <%= mailserver['security'].upcase %>
<% end %>
<% if mailserver.key?('timeout') && mailserver.timeout %>
with timeout <%= mailserver.timeout %>
<% if mailserver.key?('timeout') && mailserver['timeout'] %>
with timeout <%= mailserver['timeout'] %>
<% end %>

<% end %>
Expand All @@ -39,13 +39,13 @@ set mail-format {
}

<% @alert.each do |alert| %>
set alert <%= alert.name %>
set alert <%= alert['name'] %>
<% if alert.has_key?('only_on') -%>
only on { <%= alert.only_on.join(', ') %> }
only on { <%= alert['only_on'].join(', ') %> }
<% elsif alert.has_key?('subscriptions') -%>
only on { <%= alert.subscriptions.join(', ') %> }
only on { <%= alert['subscriptions'].join(', ') %> }
<% elsif alert.has_key?('but_not_on') -%>
but not on { <%= alert.but_not_on.join(', ') %> }
but not on { <%= alert['but_not_on'].join(', ') %> }
<% end -%>

<% end %>
Expand Down
9 changes: 9 additions & 0 deletions test/fixtures/cookbooks/setup/attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,12 @@
'only_on' => %w( size timeout timestamp uid ),
},
]
node.default['monit']['config']['mail_servers'] = [
{
'hostname' => 'thisisonlyatest.com',
'port' => '25',
'username' => 'test1',
'password' => 'test2',
'timeout' => '30 seconds'
}
]
6 changes: 6 additions & 0 deletions test/integration/repo/serverspec/localhost/monit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@
'use address 127.0.0.1',
'allow localhost',
"include #{conf_dir}/\\*\.conf",
'set mailserver',
'thisisonlyatest.com',
'port 25',
'username \'test1\'',
'password \'test2\'',
'with timeout 30 seconds',
].each do |directive|
its(:content) { should match Regexp.new(directive) }
end
Expand Down

0 comments on commit d5d4c53

Please sign in to comment.