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