Index: modules/fail2ban/manifests/filter.pp |
=================================================================== |
new file mode 100644 |
--- /dev/null |
+++ b/modules/fail2ban/manifests/filter.pp |
@@ -0,0 +1,45 @@ |
+# == Type: fail2ban::filter |
+# |
+# Manage filter information and files for any custom filter. |
+# |
+# == Parameters: |
+# |
+# [*failregex*] |
mathias
2016/11/29 13:21:24
Either we allow for passing a single string as wel
f.lopez
2016/12/01 09:13:48
Acknowledged.
|
+# Array of strings containing the regular expressions applied to |
+# the filter. |
+# |
+# [*ensure*] |
+# Translates directly into the state of the file resource. |
+# |
+# === Examples: |
+# |
+# fail2ban::filter => {'CVE-2013-0235': |
mathias
2016/11/29 13:21:24
The "=>" here is invalid syntax, and the sub-level
f.lopez
2016/12/01 09:13:48
Acknowledged.
|
+# failregex => [ |
+# '^<HOST>.*\"WordPress\/.*', |
+# '^.*\"WordPress\/.*<HOST>.*' |
mathias
2016/11/29 13:21:24
Missing a comma here, after the string item.
f.lopez
2016/12/01 09:13:48
Acknowledged.
|
+# ], |
+# 'ensure' => 'present', |
+# } |
mathias
2016/11/29 13:21:24
Another comment-line (hash-tag in the beginning, o
f.lopez
2016/12/01 09:13:48
Acknowledged.
|
+define fail2ban::filter ( |
+ $failregex = [], |
+ $ensure = 'present', |
+) { |
+ |
+ include fail2ban |
+ include stdlib |
+ |
+ if (size($failregex) == 0) and ($ensure == 'present') { |
+ fail('Require an array of string[s] with the regex patterns to apply.') |
mathias
2016/11/29 13:21:24
Those square brackets are not necessary. And the e
f.lopez
2016/12/01 09:13:48
Acknowledged.
|
+ } |
+ |
+ file {"/etc/fail2ban/filter.d/$title.conf": |
+ ensure => $ensure, |
+ content => template("fail2ban/filter.erb"), |
+ group => 'root', |
+ mode => '0644', |
+ owner => 'root', |
+ require => Package['fail2ban'], |
+ notify => Service['fail2ban'], |
+ } |
+} |
+ |