Git Product home page Git Product logo

fail2ban-formula's Introduction

fail2ban

fail2ban scans log files for malicious activity and executes actions based on what it finds.

Available states

Install the fail2ban package and enable the service.

Creates a jail.local config file based on pillar data to override configuration in the default jail.conf file and enables creation of all configuration files based on content blocks in pillar. See pillar-pt.example for reference and consult the fail2ban documentation.

Configuration

Simple:

First, fail2ban uses settings defined in /etc/fail2ban/jail.conf. jail.conf is provided by the package, and should not be changed.

Next, it uses /etc/fail2ban/jail.local to override settings from jail.conf. The fail2ban.config state populates the jail.local file using data from pillar. The jail.local file is only created if you use the fail2ban.config state.

Advanced (via config blocks in pillar):

The fail2ban.config state also populates the jail.local, fail2ban.local and the .conf files in action.d and filter.d via content blocks in pillar.

Gotchas

In the pillar.example, note that the iptable action uses port=ssh (lowercase), not port=SSH (uppercase).

Next-generation, alternate approach

The following states provide an alternate approach to managing fail2ban. Tested in Ubuntu 14/16 and CentOS 6/7.

Meta state for inclusion of all ng states.

Install the fail2ban package.

Configure fail2ban creating a jail.local file based on pillar data that overrid jail.conf. It also creates a file.local per action/filter. Either in jails, actions or filters is possible to setup a source_path options to upload your configuration directly (see pillar.example). It is also possible to remove either actions or filters setting up enabled: False in it section (see pillar.example).

Keep in mind that in ng states lookup, config, jails, actions and filters are at the same level (in the old states, all the sections are under lookup:

fail2ban:
  ng:
    lookup:
    config:
    jails:
    actions:
    filters:

Keep in mind also that in ng states change the syntax for the actions and filters adding a new config section and enabled option (optional):

fail2ban:
  ng:
    actions:
      name-of-action:
        enabled: True/False # OPTIONAL
        config:
          Definition:
              actionban:
              actionunban:
          Init:
              whatever:
    filters:
      name-of-filter:
        enabled: True/False # OPTIONAL
        config:
          Definition:
              failregex:

It is also possible to specify the source file for config, jails, actions and filters instead of using the template:

fail2ban:
  ng:
    config:
      source_path: salt://path-to-fail2ban-config-file
    jails:
      source_path: salt://path-to-fail2ban-config-file
    actions:
      name-of-action:
        config:
          source_path: salt://path-to-action-file
    filters:
      name-of-filter:
        config:
          source_path: salt://path-to-filter-file

Manage fail2ban service. It is also possible to disable the service using the following pillar configuration:

fail2ban:
  ng:
    enabled: False

fail2ban-formula's People

Contributors

aboe76 avatar adnanjp avatar devster31 avatar dseira avatar dustinrc avatar gravyboat avatar ixs avatar javierbertoli avatar jerrykan avatar kennydo avatar maratsh avatar martijnvanbeers avatar mboretto avatar nmadhok avatar puneetk avatar techhat avatar xenophonf avatar

Watchers

 avatar  avatar

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.