Add README for fail2ban
+ Remove redundant playbooks
This commit is contained in:
@@ -1,31 +1,73 @@
|
||||
Role Name
|
||||
Fail2ban
|
||||
=========
|
||||
|
||||
A brief description of the role goes here.
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
|
||||
An ansible role for installing fail2ban with basic configuration options
|
||||
|
||||
Role Variables
|
||||
--------------
|
||||
|
||||
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
|
||||
`packages: [fail2ban]`
|
||||
* A list of packages to install on the server
|
||||
|
||||
`ssh_port: 22`
|
||||
* The port SSH where is running on the remote server
|
||||
|
||||
`relay_host: "[sub.domain.com]:777"`
|
||||
`sender_email: "senderemail@domain.com"`
|
||||
* The relay to route mail through, and a corresponding email to send as
|
||||
|
||||
`email: "email@domain.com"`
|
||||
* The email address to send alerts to when an IP is banned or jailed
|
||||
|
||||
`nginx_botsearch: "true"`
|
||||
`nginx_http_auth: "true"`
|
||||
`nginx_nobinary: "true"`
|
||||
`nginx_nohome: "true"`
|
||||
`nginx_noproxy: "true"`
|
||||
`nginx_wplogin: "true"`
|
||||
`nginx_noscan: "true"`
|
||||
`nginx_noenv: "true"`
|
||||
`nginx_noscript: "true"`
|
||||
`sshd: "true"`
|
||||
`sshd_badproto: "true"`
|
||||
* Each of these variables are an existing fail2ban filter with a corresponding
|
||||
bool to enable or disable them.
|
||||
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
|
||||
Requires that postfix is configured to send email alerts
|
||||
on behalf of the `sender_email` address.
|
||||
|
||||
Example Playbook
|
||||
----------------
|
||||
|
||||
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
|
||||
First, make sure all settings within `defaults/main.yml` are correct for your
|
||||
server. All settings and their purposes are outline in the section above.
|
||||
|
||||
- hosts: servers
|
||||
roles:
|
||||
- { role: username.rolename, x: 42 }
|
||||
Create a new ansible play. You can name it whatever you want, but this
|
||||
example play will simply be named `fail2ban.yml`.
|
||||
|
||||
```yml
|
||||
---
|
||||
- hosts: testserver
|
||||
become: yes
|
||||
roles:
|
||||
- fail2ban
|
||||
```
|
||||
|
||||
Make sure the IP for `testserver` is correct in the `/etc/ansible/hosts` file -
|
||||
```
|
||||
[testserver]
|
||||
123.123.123.123:22
|
||||
```
|
||||
|
||||
Run the play!
|
||||
|
||||
```bash
|
||||
ansible-playbook fail2ban.yml
|
||||
```
|
||||
|
||||
License
|
||||
-------
|
||||
@@ -35,4 +77,4 @@ BSD
|
||||
Author Information
|
||||
------------------
|
||||
|
||||
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
|
||||
Contact: shaunrd0@gmail.com | URL: www.shaunreed.com | GitHub: shaunrd0
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
packages: [fail2ban]
|
||||
ssh_port: 22
|
||||
relay_host: "[sub.domain.com]:777"
|
||||
email: "email@domain.com"
|
||||
sender_email: "senderemail@domain.com"
|
||||
dest_email: "email@domain.com"
|
||||
nginx_botsearch: "true"
|
||||
nginx_http_auth: "true"
|
||||
nginx_nobinary: "true"
|
||||
|
||||
@@ -54,7 +54,7 @@ __date_ambit = (?:\[\])
|
||||
#
|
||||
# [bsdverbose]? [hostname] [vserver tag] daemon_id spaces
|
||||
#
|
||||
# This can be optional (for instance if we match named native log files)
|
||||
# This can be optional (for getInstance if we match named native log files)
|
||||
__prefix_line = %(__date_ambit)s?\s*(?:%(__bsd_syslog_verbose)s\s+)?(?:%(__hostname)s\s+)?(?:%(__kernel_prefix)s\s+)?(?:%(__vserver)s\s+)?(?:%(__daemon_combs_re)s\s+)?(?:%(__daemon_extra_re)s\s+)?
|
||||
|
||||
# PAM authentication mechanism check for failures, e.g.: pam_unix, pam_sss,
|
||||
|
||||
@@ -31,7 +31,7 @@ __daemon_re=\(?%(_daemon)s(?:\(\S+\))?\)?:?
|
||||
__daemon_combs_re=(?:%(__pid_re)s?:\s+%(__daemon_re)s|%(__daemon_re)s%(__pid_re)s?:)
|
||||
|
||||
# hostname daemon_id spaces
|
||||
# this can be optional (for instance if we match named native log files)
|
||||
# this can be optional (for getInstance if we match named native log files)
|
||||
__line_prefix=(?:\s\S+ %(__daemon_combs_re)s\s+)?
|
||||
|
||||
prefregex = ^%(__line_prefix)s( error:)?\s*client <HOST>#\S+( \([\S.]+\))?: <F-CONTENT>.+</F-CONTENT>$
|
||||
|
||||
@@ -134,10 +134,10 @@ filter = %(__name__)s[mode=%(mode)s]
|
||||
|
||||
# Destination email address used solely for the interpolations in
|
||||
# jail.{conf,local,d/*} configuration files.
|
||||
destemail = {{ email }}
|
||||
destemail = {{ dest_email }}
|
||||
|
||||
# Sender email address used solely for some actions
|
||||
sender = admin@bookstack
|
||||
sender = {{ sender_email }}
|
||||
|
||||
# E-mail action. Since 0.8.1 Fail2Ban uses sendmail MTA for the
|
||||
# mailing. Change mta configuration parameter to mail if you want to
|
||||
|
||||
Reference in New Issue
Block a user