Merge pull request #3 from DexterTheDragon/add_findtime_to_jail_resource
Add findtime to the fail2ban::jail resource
This commit is contained in:
+4
-1
@@ -21,6 +21,8 @@
|
||||
# $action - The action to take when fail2ban finds $maxretry $filter-matching
|
||||
# records in $logpath
|
||||
# $bantime - How much time to apply the ban, in seconds
|
||||
# $findtime - The counter is set to zero if no match is found within "findtime"
|
||||
# seconds.
|
||||
|
||||
define fail2ban::jail (
|
||||
$jailname = '',
|
||||
@@ -32,6 +34,7 @@ define fail2ban::jail (
|
||||
$logpath = '',
|
||||
$maxretry = '',
|
||||
$bantime = '',
|
||||
$findtime = '',
|
||||
$enable = true ) {
|
||||
|
||||
include concat::setup
|
||||
@@ -119,7 +122,7 @@ define fail2ban::jail (
|
||||
notify => Service['fail2ban'],
|
||||
}
|
||||
}
|
||||
concat::fragment{ "fail2ban_jail_$name":
|
||||
concat::fragment{ "fail2ban_jail_${name}":
|
||||
ensure => $ensure,
|
||||
target => $fail2ban::jails_file,
|
||||
content => template('fail2ban/concat/jail.local-stanza.erb'),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
require "#{File.join(File.dirname(__FILE__),'..','spec_helper.rb')}"
|
||||
require File.join(File.dirname(__FILE__), '..', 'spec_helper.rb')
|
||||
|
||||
describe 'fail2ban::jail' do
|
||||
|
||||
@@ -7,14 +7,15 @@ describe 'fail2ban::jail' do
|
||||
let(:facts) { { :ipaddress => '10.42.42.42', :jails_file => '/etc/fail2ban/jail.local', :concat_basedir => '/var/lib/puppet/concat'} }
|
||||
|
||||
describe 'Test basic jail.local is created' do
|
||||
let(:params) { { :name => 'sample1',
|
||||
:port => '42',
|
||||
:logpath => '/path/to/somelog',
|
||||
:enable => true, } }
|
||||
let(:params) { { :name => 'sample1',
|
||||
:port => '42',
|
||||
:logpath => '/path/to/somelog',
|
||||
:enable => true,
|
||||
:findtime => '9000', } }
|
||||
|
||||
it { should include_class('concat::setup') }
|
||||
# it { should contain_concat__fragment('fail2ban_jail_sample1').with_target('/etc/fail2ban/jail.local').with_content(/*port = 42
|
||||
#logpath = \/path\/to\/somelog*/) }
|
||||
it { should contain_concat__fragment('fail2ban_jail_sample1').with_target('/etc/fail2ban/jail.local').with_content("##################\n[fail2ban::jail]\nenabled = true\nfilter = fail2ban::jail\nport = 42\nlogpath = /path/to/somelog\n\n") }
|
||||
it { should contain_concat__fragment('fail2ban_jail_sample1').with_target('/etc/fail2ban/jail.local').with_content("##################\n[fail2ban::jail]\nenabled = true\nfilter = fail2ban::jail\nport = 42\nlogpath = /path/to/somelog\nfindtime = 9000\n\n") }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -21,4 +21,7 @@ maxretry = <%= @real_maxretry %>
|
||||
<% if @real_bantime != '' -%>
|
||||
bantime = <%= @real_bantime %>
|
||||
<% end -%>
|
||||
<% if @findtime != '' -%>
|
||||
findtime = <%= @findtime %>
|
||||
<% end -%>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user