Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 27 additions & 27 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -16,49 +16,49 @@

### Application related parameters

$package = $::operatingsystem ? {
$package = $::osfamily ? {
default => 'fail2ban',
}

$service = $::operatingsystem ? {
$service = $::osfamily ? {
default => 'fail2ban',
}

$service_status = $::operatingsystem ? {
$service_status = $::osfamily ? {
default => true,
}

$process = $::operatingsystem ? {
/(?i:Debian|Ubuntu|Mint)/ => 'fail2ban-server',
/(?i:RedHat|Centos|Scientific|Fedora|OracleLinux)/ => 'fail2ban-server',
default => 'fail2ban',
$process = $::osfamily ? {
'Debian' => 'fail2ban-server',
'RedHat' => 'fail2ban-server',
default => 'fail2ban',
}

$process_args = $::operatingsystem ? {
$process_args = $::osfamily ? {
default => '',
}

$process_user = $::operatingsystem ? {
$process_user = $::osfamily ? {
default => 'fail2ban',
}

$config_dir = $::operatingsystem ? {
$config_dir = $::osfamily ? {
default => '/etc/fail2ban',
}

$config_file = $::operatingsystem ? {
$config_file = $::osfamily ? {
default => '/etc/fail2ban/fail2ban.local',
}

$config_file_mode = $::operatingsystem ? {
$config_file_mode = $::osfamily ? {
default => '0644',
}

$config_file_owner = $::operatingsystem ? {
$config_file_owner = $::osfamily ? {
default => 'root',
}

$config_file_group = $::operatingsystem ? {
$config_file_group = $::osfamily ? {
default => 'root',
}

Expand All @@ -69,41 +69,41 @@
# fail2ban::jail define
$jails_config = ''

$jails_file = $::operatingsystem ? {
$jails_file = $::osfamily ? {
default => '/etc/fail2ban/jail.local',
}

$jails_file_mode = $::operatingsystem ? {
$jails_file_mode = $::osfamily ? {
default => '0644',
}

$jails_file_owner = $::operatingsystem ? {
$jails_file_owner = $::osfamily ? {
default => 'root',
}

$jails_file_group = $::operatingsystem ? {
$jails_file_group = $::osfamily ? {
default => 'root',
}

$config_file_init = $::operatingsystem ? {
/(?i:Debian|Ubuntu|Mint)/ => '/etc/default/fail2ban',
default => '/etc/sysconfig/fail2ban',
$config_file_init = $::osfamily ? {
'Debian' => '/etc/default/fail2ban',
default => '/etc/sysconfig/fail2ban',
}

$pid_file = $::operatingsystem ? {
/(?i:Debian|Ubuntu|Mint)/ => '/var/run/fail2ban/fail2ban.pid',
default => '/var/run/fail2ban.pid',
$pid_file = $::osfamily ? {
'Debian' => '/var/run/fail2ban/fail2ban.pid',
default => '/var/run/fail2ban.pid',
}

$data_dir = $::operatingsystem ? {
$data_dir = $::osfamily ? {
default => '/etc/fail2ban',
}

$log_dir = $::operatingsystem ? {
$log_dir = $::osfamily ? {
default => '/var/log/fail2ban',
}

$log_file = $::operatingsystem ? {
$log_file = $::osfamily ? {
default => '/var/log/fail2ban/fail2ban.log',
}

Expand Down
2 changes: 1 addition & 1 deletion spec/classes/fail2ban_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
end

describe 'Test jails managed throuh file - template' do
let(:facts) { {:operatingsystem => 'Debian' } }
let(:facts) { {:osfamily => 'Debian' } }
let(:params) { {:jails_config => 'file', :jails_template => 'fail2ban/jail.local.erb', :jails => 'ssh' } }
it { should contain_file('jail.local').without_source }
it { should contain_file('jail.local').with_content(/ssh-iptables\]
Expand Down
10 changes: 9 additions & 1 deletion templates/jail.local.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ action = iptables[name=IMAP, port=imap, protocol=tcp]
<% unless scope.lookupvar('fail2ban::mailto').empty? -%>
sendmail-whois[name=POP3, dest=<%= scope.lookupvar('fail2ban::mailto') %>, sender=fail2ban@<%= @fqdn %>]
<% end -%>
<% if @osfamily == "Debian" -%>
logpath = /var/log/mail.log
<% else -%>
logpath = /var/log/maillog
<% end -%>
maxretry = 5

[pop3-iptables]
Expand All @@ -23,7 +27,11 @@ action = iptables[name=POP3, port=pop3, protocol=tcp]
<% unless scope.lookupvar('fail2ban::mailto').empty? -%>
sendmail-whois[name=POP3, dest=<%= scope.lookupvar('fail2ban::mailto') %>, sender=fail2ban@<%= @fqdn %>]
<% end -%>
<% if @osfamily == "Debian" -%>
logpath = /var/log/mail.log
<% else -%>
logpath = /var/log/maillog
<% end -%>
maxretry = 5

[ssh-iptables]
Expand All @@ -33,7 +41,7 @@ action = iptables[name=SSH, port=ssh, protocol=tcp]
<% unless scope.lookupvar('fail2ban::mailto').empty? -%>
sendmail-whois[name=SSH, dest=<%= scope.lookupvar('fail2ban::mailto') %>, sender=fail2ban@<%= @fqdn %>]
<% end -%>
<% if @operatingsystem == "Debian" -%>
<% if @osfamily == "Debian" -%>
logpath = /var/log/auth.log
<% else -%>
logpath = /var/log/secure
Expand Down