Skip to content

Commit

Permalink
Support overriding ssh port in default config
Browse files Browse the repository at this point in the history
 - Include param tags
 - fail2ban::port function to simplify syntax
  • Loading branch information
deric committed Jun 14, 2023
1 parent d152058 commit 35299b6
Show file tree
Hide file tree
Showing 22 changed files with 2,611 additions and 2,545 deletions.
707 changes: 0 additions & 707 deletions REFERENCE.md

This file was deleted.

19 changes: 19 additions & 0 deletions functions/port.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# See https://puppet.com/docs/puppet/latest/lang_write_functions_in_puppet.html
# for more information on native puppet functions.
#
# Looks up fail2ban::jails_config.{namespace} for port configuration
#
# @param config_key
# @param default_port
# @return actual config
function fail2ban::port(String $config_key, Fail2ban::Port $default_port) >> String {
$needle = "fail2ban::jails_config.${config_key}.port"
$result = lookup($needle, undef, undef, $default_port)

case $result {
String : { $result }
Integer : { String($result) }
Array,Tuple : { join($result, ',') }
default : { raise(Puppet::ParseError, "Unsupported type in lookup result: ${result}.class") }
}
}
11 changes: 11 additions & 0 deletions manifests/define.pp
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# == Define: fail2ban::define
#
# @param config_file_path
# @param config_file_owner
# @param config_file_group
# @param config_file_mode
# @param config_file_source
# @param config_file_string
# @param config_file_template
# @param config_file_notify
# @param config_file_require
# @param config_file_options_hash
#
define fail2ban::define (
Stdlib::Absolutepath $config_file_path = "${fail2ban::config_dir_path}/${title}",
String $config_file_owner = $fail2ban::config_file_owner,
Expand Down
40 changes: 40 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -1,5 +1,44 @@
# == Class: fail2ban
#
# @param config_file_before
# @param package_name
# @param package_list
# @param package_ensure
# @param config_dir_path
# @param config_dir_filter_path
# @param config_dir_purge
# @param config_dir_recurse
# @param config_dir_source
# @param config_file_path
# @param config_file_owner
# @param config_file_group
# @param config_file_mode
# @param config_file_source
# @param config_file_string
# @param config_file_template
# @param config_file_notify
# @param config_file_require
# @param config_file_hash
# @param config_file_options_hash
# @param manage_defaults
# @param manage_firewalld
# @param service_ensure
# @param service_name
# @param service_enable
# @param action
# @param bantime
# @param email
# @param sender
# @param iptables_chain
# @param jails
# @param jails_config
# @param maxretry
# @param default_backend
# @param whitelist
# @param custom_jails
# @param banaction
# @param sendmail_config
# @param sendmail_actions
class fail2ban (
String[1] $config_file_before,

Expand Down Expand Up @@ -40,6 +79,7 @@
String[1] $sender = "fail2ban@${facts['networking']['fqdn']}",
String[1] $iptables_chain = 'INPUT',
Array[String[1]] $jails = ['ssh', 'ssh-ddos'],
Hash $jails_config = {},
Integer[0] $maxretry = 3,
Enum['pyinotify', 'gamin', 'polling', 'systemd', 'auto'] $default_backend = 'auto',
Array $whitelist = ['127.0.0.1/8', '192.168.56.0/24'],
Expand Down
24 changes: 24 additions & 0 deletions manifests/jail.pp
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
# == Define: fail2ban::jail
#
# @param filter_includes
# @param filter_failregex
# @param filter_ignoreregex
# @param filter_maxlines
# @param filter_datepattern
# @param filter_additional_config
# @param enabled
# @param action
# @param filter
# @param logpath
# @param maxretry
# @param findtime
# @param bantime
# @param port
# @param backend
# @param journalmatch
# @param ignoreip
# @param config_dir_filter_path
# @param config_file_owner
# @param config_file_group
# @param config_file_mode
# @param config_file_source
# @param config_file_notify
# @param config_file_require
define fail2ban::jail (
Optional[String] $filter_includes = undef,
Optional[String] $filter_failregex = undef,
Expand Down
Loading

0 comments on commit 35299b6

Please sign in to comment.