Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 # == Class: fail2ban | 1 # == Class: fail2ban |
2 # | 2 # |
3 # Create and maintain fail2ban (http://www.fail2ban.org/) setups. | 3 # Create and maintain fail2ban (http://www.fail2ban.org/) setups. |
4 # | 4 # |
5 # == Parameters: | 5 # == Parameters: |
6 # | 6 # |
7 # [*jail_config*] | 7 # [*jails*] |
8 # Provisions a jail.local adjacent to the default configuration. | 8 # Provisions a jail.local adjacent to the default configuration. |
9 # By default entries will have the following parameters: | 9 # By default entries will have the following parameters: |
10 # 'enabled' => 'true', | 10 # 'enabled' => 'true', |
11 # 'port' => 'all', | 11 # 'port' => 'all', |
12 # 'maxretry' => 6, | 12 # 'maxretry' => 6, |
13 # 'banaction' => 'iptables-allports', | 13 # 'banaction' => 'iptables-allports', |
14 # 'bantime' => 3600, | 14 # 'bantime' => 3600, |
15 # | 15 # |
16 # For the default banaction iptables-allports, the port parameter | 16 # For the default banaction iptables-allports, the port parameter |
17 # is not used and only set here for documentation purposes. Note | 17 # is not used and only set here for documentation purposes. Note |
18 # that if 'banaction' is set to iptables-multiport, it requires that | 18 # that if 'banaction' is set to iptables-multiport, it requires that |
19 # the 'port' parameter contains one or more comma-separated ports or protocols . | 19 # the 'port' parameter contains one or more comma-separated ports or protocols . |
20 # | 20 # |
21 # [*package*] | 21 # [*package*] |
22 # Overwrite the default package options, to fine-tune the target version (i.e. | 22 # Overwrite the default package options, to fine-tune the target version (i.e. |
23 # ensure => 'latest') or remove fail2ban (ensure => 'absent' or 'purged') | 23 # ensure => 'latest') or remove fail2ban (ensure => 'absent' or 'purged') |
24 # | 24 # |
25 # [*service*] | 25 # [*service*] |
26 # Overwrite the default service options. | 26 # Overwrite the default service options. |
27 # | 27 # |
28 # [*filters*] | 28 # [*filters*] |
29 # Adds adittional filters to the filters.d folder. | 29 # Adds adittional filters to the filters.d folder. |
30 # | 30 # |
31 # === Examples: | 31 # === Examples: |
32 # | 32 # |
33 # class {'fail2ban': | 33 # class {'fail2ban': |
34 # package => {ensure => 'present',}, | 34 # package => {ensure => 'present',}, |
35 # service => {}, | 35 # service => {}, |
36 # jail_config => { | 36 # jails => { |
37 # 'CVE-2013-0235' => { | 37 # 'CVE-2013-0235' => { |
38 # 'logpath' => '/var/log/nginx/access_log_hg', | 38 # 'logpath' => '/var/log/nginx/access_log_hg', |
39 # 'banaction' => 'iptables-multiport', | 39 # 'banaction' => 'iptables-multiport', |
40 # 'port' => 'https, http', | 40 # 'port' => 'https, http', |
41 # } | 41 # } |
42 # }, | 42 # }, |
43 # filters => { | 43 # filters => { |
44 # 'CVE-2013-0235' => { | 44 # 'CVE-2013-0235' => { |
45 # regexes => [ | 45 # regexes => [ |
46 # '^<HOST>.*\"WordPress\/.*', | 46 # '^<HOST>.*\"WordPress\/.*', |
47 # ], | 47 # ], |
48 # } | 48 # } |
49 # }, | 49 # }, |
50 # } | 50 # } |
51 # | 51 # |
52 class fail2ban ( | 52 class fail2ban ( |
53 $package = {}, | 53 $package = hiera('fail2ban::package', {}), |
mathias
2016/12/01 09:32:44
Please consistently use hiera('fail2ban::PARAMETER
f.lopez
2016/12/01 10:16:05
Acknowledged.
| |
54 $service = {}, | 54 $service = hiera('fail2ban::service', {}), |
55 $jail_config = {}, | 55 $jails = hiera('fail2ban::jails', {}), |
56 $filters = {}, | 56 $filters = hiera('fail2ban::filters', {}), |
57 ) { | 57 ) { |
58 | 58 |
59 include stdlib | 59 include stdlib |
60 | 60 |
61 $jail_default = { | 61 $jail_default = { |
62 'enabled' => 'true', | 62 'enabled' => 'true', |
63 'port' => 'all', | 63 'port' => 'all', |
64 'maxretry' => 6, | 64 'maxretry' => 6, |
65 'banaction' => 'iptables-allports', | 65 'banaction' => 'iptables-allports', |
66 'bantime' => 3600, | 66 'bantime' => 3600, |
67 } | 67 } |
68 | 68 |
69 ensure_resource('package', $title, $package) | 69 ensure_resource('package', $title, $package) |
70 | 70 |
71 # Used as default $ensure parameter for most resources below | |
mathias
2016/12/01 09:28:30
It is not used as parameter anywhere, just in the
f.lopez
2016/12/01 10:16:05
Acknowledged.
| |
72 $ensure = getparam(Package[$title], 'ensure') ? { | 71 $ensure = getparam(Package[$title], 'ensure') ? { |
73 /^(absent|purged)$/ => 'absent', | 72 /^(absent|purged)$/ => 'absent', |
74 default => 'present', | 73 default => 'present', |
75 } | 74 } |
76 | 75 |
77 if ($ensure == 'present') { | 76 if ($ensure == 'present') { |
78 | 77 |
79 ensure_resource('service', $title, merge({ | 78 ensure_resource('service', $title, merge({ |
80 hasrestart => true, | 79 hasrestart => true, |
81 hasstatus => true, | 80 hasstatus => true, |
(...skipping 11 matching lines...) Expand all Loading... | |
93 notify => Service['fail2ban'], | 92 notify => Service['fail2ban'], |
94 require => Package['fail2ban'], | 93 require => Package['fail2ban'], |
95 } | 94 } |
96 | 95 |
97 Package[$title] -> File['/etc/fail2ban/jail.local'] | 96 Package[$title] -> File['/etc/fail2ban/jail.local'] |
98 Service[$title] <~ Package[$title] | 97 Service[$title] <~ Package[$title] |
99 } | 98 } |
100 | 99 |
101 } | 100 } |
102 | 101 |
LEFT | RIGHT |