Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: modules/fail2ban/manifests/filter.pp

Issue 29364214: Issue 2487 - Introduce fail2ban module (Closed)
Left Patch Set: Created Nov. 28, 2016, 3:59 p.m.
Right Patch Set: For comment 22 and 23 Created Dec. 2, 2016, 2:22 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | modules/fail2ban/manifests/init.pp » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 }
f.nicolaisen 2016/11/29 00:38:54 No empty line at end of file
47
LEFTRIGHT

Powered by Google App Engine
This is Rietveld