Giter Club home page Giter Club logo

fail2ban's Introduction

fail2ban Cookbook

Cookbook Version CI State OpenCollective OpenCollective License

Installs and configures fail2ban, a utility that watches logs for failed login attempts and blocks repeat offenders with firewall rules. On Redhat systems this cookbook will enable the EPEL repository in order to retrieve the fail2ban package.

Maintainers

This cookbook is maintained by the Sous Chefs. The Sous Chefs are a community of Chef cookbook maintainers working together to maintain important cookbooks. If youโ€™d like to know more please visit sous-chefs.org or come chat with us on the Chef Community Slack in #sous-chefs.

Requirements

Platforms

  • Debian/Ubuntu
  • RHEL/CentOS/Scientific/Amazon/Oracle
  • Fedora
  • OpenSUSE

Chef

  • Chef 15.3+

Cookbooks

  • yum-epel

Recipes

default

Installs the fail2ban package, manages 2 templates: /etc/fail2ban/fail2ban.conf and /etc/fail2ban/jail.conf, and manages the fail2ban service.

Attributes

This cookbook has a set of configuration options for fail2ban

  • default['fail2ban']['loglevel'] = 'INFO'
  • default['fail2ban']['logtarget'] = '/var/log/fail2ban.log'
  • default['fail2ban']['syslogsocket'] = 'auto'
  • default['fail2ban']['socket'] = '/var/run/fail2ban/fail2ban.sock'
  • default['fail2ban']['pidfile'] = '/var/run/fail2ban/fail2ban.pid'
  • default['fail2ban']['dbfile'] = '/var/lib/fail2ban/fail2ban.sqlite3'
  • default['fail2ban']['dbpurgeage'] = 86_400

This cookbook has a set of configuration options for jail.conf

  • default['fail2ban']['ignoreip'] = '127.0.0.1/8'
  • default['fail2ban']['findtime'] = 600
  • default['fail2ban']['bantime'] = 300
  • default['fail2ban']['maxretry'] = 5
  • default['fail2ban']['backend'] = 'polling'
  • default['fail2ban']['email'] = 'root@localhost'
  • default['fail2ban']['sendername'] = 'Fail2Ban'
  • default['fail2ban']['action'] = 'action_'
  • default['fail2ban']['banaction'] = 'iptables-multiport'
  • default['fail2ban']['mta'] = 'sendmail'
  • default['fail2ban']['protocol'] = 'tcp'
  • default['fail2ban']['chain'] = 'INPUT'

This cookbook makes use of a hash to compile the jail.local-file and filter config files:

default['fail2ban']['services'] = {
  'ssh' => {
        "enabled" => "true",
        "port" => "ssh",
        "filter" => "sshd",
        "logpath" => node['fail2ban']['auth_log'],
        "maxretry" => "6"
     },
  'smtp' => {
        "enabled" => "true",
        "port" => "smtp",
        "filter" => "smtp",
        "logpath" => node['fail2ban']['auth_log'],
        "maxretry" => "6"
     }
}

The following attributes can be used per service:

  • backend
  • banaction
  • bantime
  • enabled
  • filter
  • findtime
  • ignorecommand
  • logpath
  • maxretry
  • port
  • protocol

Creating custom fail2ban filters:

default['fail2ban']['filters'] = {
  'nginx-proxy' => {
        "failregex" => ["^<HOST> -.*GET http.*"],
        "ignoreregex" => []
     },
}

In the case you would like to get Slack notifications on IP addresses banned/unbanned, this cookbook supports it by setting the following attributes:

# A Slack webhook looks like this:
# https://hooks.slack.com/services/A123BCD4E/FG5HI6KLM/7n8opqrsT9UVWxyZ0AbCdefG
default['fail2ban']['slack_webhook'] = nil
# Then setting the Slack channel name without the hashtag (#)
default['fail2ban']['slack_channel'] = 'general'

Then you will get notifications like this:

[hostname] Banned ๐Ÿ‡ณ๐Ÿ‡ฌ 217.117.13.12 in the jail sshd after 5 attempts

Resources

fail2ban_filter

Manages fail2ban filters in /etc/fail2ban/filters.d/.

Actions

  • create - Default. Creates a fail2ban filter.
  • delete - Deletes a fail2ban filter.

Properties

  • filter - Specifies the name of the filter. This is the name property.
  • source - Specifies the template source. By default, this is set to filter.erb.
  • cookbook - Specifies the template cookbook. By default, this is set to fail2ban.
  • failregex - Specifies one or multiple regular expressions matching the failure.
  • ignoreregex - Specifies one or multiple regular expressions to ignore.

Examples

Configure a file for webmin authentication with multiple regular expressions matching the failure.

fail2ban_filter 'webmin-auth' do
  failregex ["^%(__prefix_line)sNon-existent login as .+ from <HOST>\s*$",
             "^%(__prefix_line)sInvalid login as .+ from <HOST>\s*$"]
end

fail2ban_jail

Manages fail2ban jails in /etc/fail2ban/jail.d/.

Actions

  • create - Default. Creates a fail2ban jail.
  • delete - Deletes a fail2ban jail.

Properties

  • jail - Specifies the jail name. This is the name property.
  • source - Specifies the template source. By default, this is set to jail.erb.
  • cookbook - Specifies the template cookbook. By default, this is set to fail2ban.
  • filter - Specifies the name of the filter to be used by the jail to detect matches.
  • logpath - Specifies the path to the log file which is provided to the filter.
  • protocol - Specifies the protocol type, e.g. tcp, udp or all.
  • ports - Specifies an array of port(s) to watch.
  • maxretry - Specifies the number of matches which triggers ban action.
  • ignoreips - Specifies an array of IP addresses to ignore.

Examples

Create a new fail2ban jail for SSH that uses existing filter sshd and which bans client after 3 tries.

fail2ban_jail 'ssh' do
  ports %w(ssh)
  filter 'sshd'
  logpath node['fail2ban']['auth_log']
  maxretry 3
end

Issues related to rsyslog

If you are using rsyslog parameter "$RepeatedMsgReduction on" in rsyslog.conf file then you can get "Last message repeated N times" in system log file (for example auth.log). Fail2ban will not work because the internal counter maxretry will not expand the repeated messages. Change parameter "$RepeatedMsgReduction off" in rsyslog.conf file for maximum accuracy of failed login attempts.

This rsyslog parameter is default ON for ubuntu 12.04 LTS for example.

Contributors

This project exists thanks to all the people who contribute.

Backers

Thank you to all our backers!

https://opencollective.com/sous-chefs#backers

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website.

https://opencollective.com/sous-chefs/sponsor/0/website https://opencollective.com/sous-chefs/sponsor/1/website https://opencollective.com/sous-chefs/sponsor/2/website https://opencollective.com/sous-chefs/sponsor/3/website https://opencollective.com/sous-chefs/sponsor/4/website https://opencollective.com/sous-chefs/sponsor/5/website https://opencollective.com/sous-chefs/sponsor/6/website https://opencollective.com/sous-chefs/sponsor/7/website https://opencollective.com/sous-chefs/sponsor/8/website https://opencollective.com/sous-chefs/sponsor/9/website

fail2ban's People

Contributors

andytson avatar ares avatar axelrtgs avatar claco avatar cwebberops avatar damacus avatar digilist avatar djessich avatar facastagnini avatar iennae avatar jeffrafter avatar kitchen-porter avatar mbaitelman avatar meineerde avatar nathenharvey avatar nshenry03 avatar pjungwir avatar powerkiki avatar powerschill avatar pwalz avatar ramereth avatar renovate[bot] avatar restless-et avatar sethvargo avatar tas50 avatar vskubriev avatar xorima avatar xorimabot avatar zedtux avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fail2ban's Issues

Warnings generated on Ubuntu 14.04

The fail2ban.conf created by this cookbook doesn't have a pidfile entry. On Ubuntu 14.04 this generates warnings on restart/reload/etc:

 * Reloading authentication failure monitor fail2ban                                                    
WARNING 'pidfile' not defined in 'Definition'. Using default one: '/var/run/fail2ban/fail2ban.pid'
                                                                                                  [ OK ]

Warning emails are also generated by the weekly logrotate, so it's pretty annoying.

For ubuntu 10.04~14.04 (the versions I have handy..), it should have:

pidfile = /var/run/fail2ban/fail2ban.pid

in fail2ban.conf, but this path may be different on Redhat? I'd make a pull request but I don't have any non-ubuntu boxes to test it on sorry.

Not Getting email notifications after banning !

Hi ,

I'm able to recieve fail2ban start and stop notifications but i'm not able to get email notification when it is banning the ip address .

Please can you help me out on this ?

Thanks,
Naveen

New Tagged Version

A patch has already been submitted to correct the cookbook on Ubuntu 18.04, but a new release has not been submitted to the Supermarket. Would it be possible to tag and submit a new release so this cookbook will correctly work with Ubuntu 18.04+?

Issue Report Details

Cookbook version
5.0.2
Chef-client version
14.7.17
Platform Details
18.04.1
Scenario
Cookbook fails to correctly detect the system version of fail2ban.
Steps to Reproduce
Run cookbook on Ubuntu 18.04
Expected Result
Correct config syntax is used.
Actual Result
Old (< 0.9) config syntax is used.

Fail2ban 2.3.0 fails with Service Enable

Fail2ban cookbook ( and Chef::Provider::Service ) assumes Upstart for Ubuntu , but from 15.10 fail2ban uses systemd now .. the cookbook adds the wrong entries and seems to break fail2ban installation..

Fix, remove and purge fail2ban

I then added the following to the cookbook ( end of the default.rb )

service 'fail2ban' do
supports [:status => true, :restart => true]
action [:enable, :start]

if platform?('ubuntu') && node['platform_version'].to_f >= 15.10
provider Chef::Provider::Service::Systemd
end

if (platform?('ubuntu') && node['platform_version'].to_f < 12.04) ||
(platform?('debian') && node['platform_version'].to_f < 7)
# status command returns non-0 value only since fail2ban 0.8.6-3 (Debian)
status_command "/etc/init.d/fail2ban status | grep -q 'is running'"
end
end

Happy to propose a change, if someone can give a newbie a pointer or two

Investigate using .d folders for a LWRP

Modern versions of fail2ban support .d folders, which should allow for failban LWRPs and the removal of the monolithic config. Lets see what OS releases include the versions supporting this and get a LWRP going.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/ci.yml
  • sous-chefs/.github 3.0.0
  • actions/checkout v4
  • actionshub/chef-install 2.0.4
  • actionshub/test-kitchen 2.1.0
.github/workflows/stale.yml
  • actions/stale v8

  • Check this box to trigger a request for Renovate to run again on this repository

fail2ban_jail resource not working (for SSH service)

Cookbook version

6.0.0

Chef-client version

14.12.9

Platform Details

CentOS 7

Scenario:

Create Fail2Ban Jail Configuration using fail2ban_jail resource (here for SSH service).

Steps to Reproduce:

fail2ban_jail 'ssh' do
  ports %w(ssh)
  filter 'sshd'
  logpath node['fail2ban']['auth_log']
  maxretry 6
end

Expected Result:

Created Fail2Ban Jail Configuration (here for SSH service).

Actual Result:

The fail2ban_jail resource does not provide a filter property. The following may work:

property :filter, String, required: true

Results in the following error:

NoMethodError
-------------
undefined method `filter' for Custom resource fail2ban_jail from cookbook fail2ban

Cookbook Trace:
---------------
 /tmp/kitchen/cache/cookbooks/fail2ban-wrapper/recipes/default.rb:11:in `block in from_file'
 /tmp/kitchen/cache/cookbooks/fail2ban-wrapper/recipes/default.rb:9:in `from_file'

Relevant File Content:
----------------------
/tmp/kitchen/cache/cookbooks/fail2ban-wrapper/recipes/default.rb:

 6:
 7:  include_recipe 'fail2ban'
 8:
 9:  fail2ban_jail 'ssh' do
10:    ports %w(ssh)
11>>   filter 'sshd'
12:    logpath node['fail2ban']['auth_log']
13:  end
14:

System Info:
------------
chef_version=14.12.9
platform=centos
platform_version=7.6.1810
ruby=ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-linux]
program_name=/opt/chef/bin/chef-client
executable=/opt/chef/bin/chef-client

Additonal Improvements:

Additionally the wrong attribute is given to internal template resource of fail2ban_jail resource. The problematic code is the following line:

# ...
property :source, String, default: 'jail.erb'
# ...
template "/etc/fail2ban/jail.d/50-#{new_resource.jail}.conf" do
  # ...
  source new_resource.filter # Prolematic code
  # ...
end
# ...

Should be:

# ...
property :source, String, default: 'jail.erb'
# ...
template "/etc/fail2ban/jail.d/50-#{new_resource.jail}.conf" do
  # ...
  source new_resource.source # Fix
  # ...
end
# ...

Without this fix the fail2ban_jail resource will not work properly. See: https://github.com/chef-cookbooks/fail2ban/blob/v6.0.0/resources/jail.rb#L33

Fix all checks so they pass

๐Ÿ—ฃ๏ธ Foreword

Thank for taking the time to fill this bug report fully. Without it we may not be able to fix the bug, and the issue may be closed without resolution.

๐Ÿ‘ป Brief Description

The delivery check is failing.

๐Ÿฅž Cookbook version

Version of the cookbook where you are encountering the issue.

๐Ÿ‘ฉโ€๐Ÿณ Chef-Infra Version

Version of chef-client in your environment.

๐ŸŽฉ Platform details

Operating system distribution and release version. Cloud provider if running in the cloud.

Steps To Reproduce

Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

๐Ÿš“ Expected behavior

All checks including integration tests should pass.

โž• Additional context

Add any other context about the problem here. e.g. related issues or existing pull requests.

Run latest cookstyle

๐Ÿ—ฃ๏ธ Foreword

Thank for taking the time to fill this bug report fully. Without it we may not be able to fix the bug, and the issue may be closed without resolution.

๐Ÿ‘ป Brief Description

Chef have released updated cookstyle rules, we should therefore run the auto fix against the cookbook

  1. Ensure you are on the latest stable chef-workstation
  2. Run cookstyle -a

Issue sprouted from sous-chefs/meta/issues/111. If not applicable then issue should be closed.

Update Changelog

๐Ÿ—ฃ๏ธ Foreword

Thank for taking the time to fill this bug report fully. Without it we may not be able to fix the bug, and the issue may be closed without resolution.

๐Ÿ‘ป Brief Description

Update all CHANGELOGs to follow standard defined at https://keepachangelog.com/

Issue sprouted from sous-chefs/meta/issues/101. If not applicable then issue should be closed.

Creating fail2ban.conf fails with NoMethodError

Cookbook version

5.0.0

Chef-client version

12.7.2

Platform Details

CentOS 7.2 via Kitchen

$ ohai --version
Ohai: 8.10.0

Scenario:

Installing fail2ban via the default recipe.

Steps to Reproduce:

I'm using the following .kitchen.yml file:

---
driver:
  name: vagrant

provisioner:
  name: chef_solo
  require_chef_omnibus: 12.7.2

platforms:
  - name: centos-7.2

suites:
  - name: default
    run_list:
      - recipe[fail2ban::default]
    attributes:

and execute kitchen converge.

Expected Result:

fail2ban is installed.

Actual Result:

chef-client throws an error:

Recipe: fail2ban::default
 * yum_package[fail2ban] action install
   - install version 0.9.7-1.el7 of package fail2ban
 * ohai[reload package list] action reload
   - re-run ohai and merge results into node attributes
 * ohai[reload package list] action nothing (skipped due to action :nothing)
 * template[/etc/fail2ban/fail2ban.conf] action create

   ================================================================================
   Error executing action `create` on resource 'template[/etc/fail2ban/fail2ban.conf]'
   ================================================================================

   NoMethodError
   -------------
   undefined method `[]' for nil:NilClass

   Cookbook Trace:
   ---------------
   /tmp/kitchen/cookbooks/fail2ban/recipes/default.rb:46:in `block (2 levels) in from_file'
   /tmp/kitchen/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/property.rb:11:in `get'
   /tmp/kitchen/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/mixin/params_validate.rb:11:in `get'
   /tmp/kitchen/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:78:in `run_action'
   /tmp/kitchen/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:106:in `block (2 levels) in converge'
   /tmp/kitchen/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:106:in `each'
   /tmp/kitchen/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:106:in `block in converge'
   /tmp/kitchen/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:105:in `converge'

   Resource Declaration:
   ---------------------
   # In /tmp/kitchen/cookbooks/fail2ban/recipes/default.rb

    41: template '/etc/fail2ban/fail2ban.conf' do
    42:   source 'fail2ban.conf.erb'
    43:   owner 'root'
    44:   group 'root'
    45:   mode '0644'
    46:   variables(lazy { { f2b_version: node['packages']['fail2ban']['version'].match(/^[0-9]+\.[0-9]+/)[0].to_f } })
    47:   notifies :restart, 'service[fail2ban]'
    48: end
    49:

   Compiled Resource:
   ------------------
   # Declared in /tmp/kitchen/cookbooks/fail2ban/recipes/default.rb:41:in `from_file'

   template("/etc/fail2ban/fail2ban.conf") do
     action [:create]
     retries 0
     retry_delay 2
     default_guard_interpreter :default
     source "fail2ban.conf.erb"
     variables #<Chef::DelayedEvaluator:0x00000003d85e98@/tmp/kitchen/cookbooks/fail2ban/recipes/default.rb:46>
     declared_type :template
     cookbook_name :fail2ban
     recipe_name "default"
     owner "root"
     group "root"
     mode "0644"
     atomic_update true
     path "/etc/fail2ban/fail2ban.conf"
   end


Running handlers:
[2018-02-15T08:52:36+00:00] ERROR: Running exception handlers
Running handlers complete
[2018-02-15T08:52:36+00:00] ERROR: Exception handlers complete
Chef Client failed. 7 resources updated in 21 seconds
[2018-02-15T08:52:36+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
[2018-02-15T08:52:36+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2018-02-15T08:52:36+00:00] ERROR: template[/etc/fail2ban/fail2ban.conf] (fail2ban::default line 41) had an error: NoMethodError: undefined method `[]' for nil:NilClass
[2018-02-15T08:52:37+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

I've added the kitchen config file to make it easier for you to reproduce the issue. We are also seeing the same error on our servers.

Update builds to be parallel

๐Ÿ—ฃ๏ธ Foreword

Thank for taking the time to fill this bug report fully. Without it we may not be able to fix the bug, and the issue may be closed without resolution.

๐Ÿ‘ป Brief Description

As part of our build process we should build each possible operating system separately

  1. Ensure you have dokken setup and working:
  2. dokken: aliased to KITCHEN_LOCAL_YAML=kitchen.dokken.yml kitchen
  3. run dokken list, you should see a list of builds with dokken as the provider
  4. download: https://github.com/sous-chefs/repo-management/blob/master/scripts/circleci_maker.rb and make this executable
  5. run: dokken list -j | ./circleci_maker.rb > .circleci/config.yml

Issue sprouted from sous-chefs/meta/issues/112. If not applicable then issue should be closed.

Can't use defaults for pre-defined jails

Cookbook version

6.0.0

Chef-client version

15.0.300

Platform Details

  System Info:
  ------------
  chef_version=15.0.300
  platform=centos
  platform_version=6.10
  ruby=ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux]
  program_name=chef-client worker: ppid=28983;start=20:27:22;
  executable=/opt/chef/bin/chef-client

Scenario:

Used to do:

default_attributes fail2ban: {
  services: {
    'dovecot' => { enabled: 'true' },
    'postfix-sasl' => { enabled: 'true' } 
   }
}

which worked fine, since

[dovecot]
  enabled = true

which works perfectly, as other fields end up using defaults.

Trying to update to the new resource-based approach, but this doesn't work.

Steps to Reproduce:

fail2ban_jail 'dovecot' 
fail2ban_jail 'postfix-sasl' 

Expected Result:

Same result as before.

Actual Result:

    undefined method `filter' for Custom resource fail2ban_jail from cookbook fail2ban

because of unconditional use of new_resource.filter in fail2ban::default.

Priority field to fail2ban_jail Resource

Cookbook version

6.0.0

Chef-client version

14.12.9

Platform Details

CentOS 7

Scenario:

I want to set the priority of the Fail2Ban Jail in conf.d directory.

Steps to Reproduce:

Call fail2ban_jail resource. This should be an improvement.

Expected Result:

Expect to create Fail2Ban Jail with priority in conf.d directory for Jail.

Actual Result:

Priority is hardcoded to 50.

# ...
action :create do
  template "/etc/fail2ban/jail.d/50-#{new_resource.jail}.conf" do # priority hardcoded to 50
    # ...
  end
end
# ...

Should be something like:

# ...
property :priority, [String, Integer], default: '50'
# ...
action :create do
  template "/etc/fail2ban/jail.d/#{new_resource.priority}-#{new_resource.jail}.conf" do # priority hardcoded to 50
    # ...
  end
end
# ...

See https://github.com/chef-cookbooks/fail2ban/blob/v6.0.0/resources/jail.rb#L31.

Regex for postfix

Hello

Using fail2ban on CentoS 7, tries for smtp relay are not blocked.
Adding this regex solve the problem on postfix.conf. Can you add it by default ?

^%(__prefix_line)sNOQUEUE: reject: RCPT from \S+[]: 454 4.7.1 .*$

For info, log lines for these tries are :

Mar 1 18:26:24 server postfix/smtpd[14970]: NOQUEUE: reject: RCPT from unknown[50.60.146.24]: 454 4.7.1 [email protected]: Relay access denied; from=[email protected] to=[email protected] proto=SMTP helo=<relaytest.mydnstools.info>
Mar 1 18:26:25 server postfix/smtpd[14970]: NOQUEUE: reject: RCPT from unknown[50.60.146.24]: 454 4.7.1 returntest%[email protected]: Relay access denied; from=[email protected] to=returntest%[email protected] proto=SMTP helo=<relaytest.mydnstools.info>
Mar 1 18:26:25 server postfix/smtpd[14970]: NOQUEUE: reject: RCPT from unknown[50.60.146.24]: 454 4.7.1 [email protected]: Relay access denied; from=[email protected] to=[email protected] proto=SMTP helo=<relaytest.mydnstools.info>

Thanks

Remove .rubocop.yml with Dangerfile

๐Ÿ—ฃ๏ธ Foreword

Thank for taking the time to fill this bug report fully. Without it we may not be able to fix the bug, and the issue may be closed without resolution.

๐Ÿ‘ป Brief Description

If the only thing in the .rubocop/yml is Dangerfile
Run the latest cookstyle
Remove .rubpopo.yml

Issue sprouted from sous-chefs/meta/issues/108. If not applicable then issue should be closed.

Remove unused "syslog tunables"

The attributes fail2ban.syslog_target & fail2ban.syslog_facility respectively set syslog-target & syslog-facility in the fail2ban.conf template.

I'm skeptical they do anything. fail2ban/server/server.py:378 indicates this is hardcoded to the daemon facility. I also have no idea what the syslog-target line could be about.

Unless there is an actual use for them, they should be removed.

Different logpath for CentOS and RHEL on Softlayer

The current base images for CentOS and RHEL on Softlayer are logging ssh errors to /var/log/messages rather than /var/log/secure. Because fail2ban is monitoring the other one, the cookbook configuration doesn't work by default:

http://serverfault.com/questions/646167/why-is-fail2ban-not-banning-this-attack/673112

I would suggest modifying the default for the cookbook to monitor both log files for CentOS and RHEL, either by having two paths in the logpath directive or defining two separate jails, one for /var/log/secure and one for /var/log/messages

Changing the log level not possible anymore

In version 4.0 of this cookbook it's impossible to change the log level of fail2ban. In version 3.1.0 of this cookbook it was possible to change it but it was removed.

Is there a reason why?

At least for Ubuntu 16.04 LTS which has version 0.9.3 of fail2ban you can set the log level using one of these values.

Ubuntu 14.04 LTS seems to use 0.8.x where the values are different.

Does that mean that Ubuntu 14.04 is not supported anymore after version 4.0 of this cookbook?

Build failing on Ubuntu 16.04

Cookbook version

3.1.0

Chef-client version

[Version of chef-client in your environment]

Platform Details

Ubuntu 16.04

Scenario:

0.9.3-1

Steps to Reproduce:

Install cookbook as is - fails to start fail2ban

Expected Result:

cookbook works on current version of ubuntu

Actual Result:

cookbook doesn't work

Service enable and start doesn't work on Fedora

Cookbook version

4.0.1

Chef-client version

13.6.4

Platform Details

Fedora 27

Scenario:

Start and enable fail2ban

Steps to Reproduce:

Run on Fedora 27

Expected Result:

Run should enable and start fail2ban

Actual Result:

Doesn't start or enable due to platform_family not matching in recipes/default.rb

service 'fail2ban' do
  supports [status: true, restart: true]
  action [:enable, :start] if platform_family?('rhel')
  action [:enable] if platform_family?('debian')
end

Adding fedora as a platform_family in my wrapper cookbook fixed it.

ohai | grep platform_family
[2018-01-07T21:31:23+00:00] INFO: The plugin path /etc/chef/ohai/plugins does not exist. Skipping...
"platform_family": "fedora",

Guidelines for contributing out of date

A meta-issue.. If I open a ticket here, it asks me to see the guidelines for contributing. They say to open a ticket in Jira, but Jira tells me to open a ticket here.

I'm pretty sure here is the right location?

No directory /var/run/fail2ban created during installation

Cookbook version

"fail2ban","version":"5.0.1"

Chef-client version

chef-12.20.3-1.el7.x86_64
chef-server-core-12.15.8-1.el7.x86_64

Platform Details

Red Hat Enterprise Linux Server release 7.4 (Maipo)
Linux 3.10.0-693.17.1.el7.x86_64 x86_64 GNU/Linux

Scenario:

Fail2ban cannot start with command: "systemctl start fail2ban.service"

Steps to Reproduce:

  1. Try to start Fail2ban with command: "systemctl start fail2ban.service"
  2. Check for directory existence (dir /var/run/fail2ban was not created automatically during the installation)

Error captured in /var/log/messages
chef fail2ban-client: ERROR There is no directory /var/run/fail2ban to contain the socket file /var/run/fail2ban/fail2ban.sock.
chef systemd: fail2ban.service: control process exited, code=exited status=255
chef systemd: Failed to start Fail2Ban Service.
chef systemd: Unit fail2ban.service entered failed state.
3. Manually create missing dir (mkdir -p /var/run/fail2ban)
4. Fail2ban was properly started with command: systemctl start fail2ban.service

Expected Result:

There should be possible to start Fail2ban without changing the paths (when Fail2ban cookbook is included with Berksfile).

Actual Result:

Actually, Fail2ban was included with Berksfile, variables are overwritten with environment variables.
If we change the path to fail2ban.sock file from /var/run/fail2ban/fail2ban.sock into /var/run/fail2ban.sock - other installation parts will still use old path. Temporary fix would be to manually created missing /var/run/fail2ban dir.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.