LEFT | RIGHT |
1 # == Type: fail2ban::filter | 1 # == Type: fail2ban::filter |
2 # | 2 # |
3 # Manage filter information and files for any custom filter. | 3 # Manage filter information and files for any custom filter. |
4 # | 4 # |
5 # == Parameters: | 5 # == Parameters: |
6 # | 6 # |
7 # [*failregex*] | 7 # [*regexes*] |
8 # Array of strings containing the regular expressions applied to | 8 # Array of strings containing the regular expressions applied to |
9 # the filter. | 9 # the filter. |
10 # | 10 # |
11 # [*ensure*] | 11 # [*ensure*] |
12 # Translates directly into the state of the file resource. | 12 # Translates directly into the state of the file resource. |
13 # | 13 # |
14 # === Examples: | 14 # === Examples: |
15 # | 15 # |
16 # fail2ban::filter => {'CVE-2013-0235': | 16 # fail2ban::filter {'CVE-2013-0235': |
17 # failregex => [ | 17 # regexes => [ |
18 # » '^<HOST>.*\"WordPress\/.*', | 18 # '^<HOST>.*\"WordPress\/.*', |
19 #» '^.*\"WordPress\/.*<HOST>.*' | 19 #» '^.*\"WordPress\/.*<HOST>.*', |
20 # » ], | 20 # ], |
21 # » 'ensure' => 'present', | 21 # 'ensure' => 'present', |
22 # } | 22 # } |
| 23 # |
23 define fail2ban::filter ( | 24 define fail2ban::filter ( |
24 $failregex = [], | 25 $regexes = [], |
25 $ensure = 'present', | 26 $ensure = 'present', |
26 ) { | 27 ) { |
27 | 28 |
28 include fail2ban | 29 include fail2ban |
29 include stdlib | 30 include stdlib |
30 | 31 |
31 if (size($failregex) == 0) and ($ensure == 'present') { | 32 if (size($regexes) == 0) and ($ensure == 'present') { |
32 fail('Require an array of string[s] with the regex patterns to apply.') | 33 fail("An array of one or more regular expressions is needed.") |
33 } | 34 } |
34 | 35 |
35 file {"/etc/fail2ban/filter.d/$title.conf": | 36 # The $name parameter is used to compose the file name. |
| 37 file {"/etc/fail2ban/filter.d/$name.conf": |
36 ensure => $ensure, | 38 ensure => $ensure, |
37 content => template("fail2ban/filter.erb"), | 39 content => template("fail2ban/filter.erb"), |
38 group => 'root', | 40 group => 'root', |
39 mode => '0644', | 41 mode => '0644', |
40 owner => 'root', | 42 owner => 'root', |
41 require => Package['fail2ban'], | 43 require => Package['fail2ban'], |
42 notify => Service['fail2ban'], | 44 notify => Service['fail2ban'], |
43 } | 45 } |
44 } | 46 } |
| 47 |
LEFT | RIGHT |