diff --git a/tasks/main.yml b/tasks/main.yml index f4790bc..9eaa878 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -12,10 +12,10 @@ - fail2ban - fail2ban-install -- name: update configuration file - /etc/fail2ban/fail2ban.conf +- name: update configuration file - /etc/fail2ban/fail2ban.local template: - src: etc/fail2ban/fail2ban.conf.j2 - dest: /etc/fail2ban/fail2ban.conf + src: etc/fail2ban/fail2ban.local.j2 + dest: /etc/fail2ban/fail2ban.local owner: root group: root mode: 0644 diff --git a/templates/etc/fail2ban/fail2ban.conf.j2 b/templates/etc/fail2ban/fail2ban.conf.j2 deleted file mode 100644 index a7a4866..0000000 --- a/templates/etc/fail2ban/fail2ban.conf.j2 +++ /dev/null @@ -1,46 +0,0 @@ -# {{ ansible_managed }} - -# Fail2Ban configuration file -# -# Author: Cyril Jaquier -# -# $Revision$ -# - -[Definition] - -# Option: loglevel -# Notes.: Set the log level output. -# 1 = ERROR -# 2 = WARN -# 3 = INFO -# 4 = DEBUG -# Values: NUM Default: 3 -# -loglevel = {{ fail2ban_loglevel }} - -# Option: logtarget -# Notes.: Set the log target. This could be a file, SYSLOG, STDERR or STDOUT. -# Only one log target can be specified. -# Values: STDOUT STDERR SYSLOG file Default: /var/log/fail2ban.log -# -logtarget = {{ fail2ban_logtarget }} -{% if fail2ban_logtarget == "SYSLOG" %} -syslog-target = {{ fail2ban_syslog_target }} -syslog-facility = {{ fail2ban_syslog_facility }} -{% endif %} - -# Option: socket -# Notes.: Set the socket file. This is used to communicate with the daemon. Do -# not remove this file when Fail2ban runs. It will not be possible to -# communicate with the server afterwards. -# Values: FILE Default: /var/run/fail2ban/fail2ban.sock -# -socket = {{ fail2ban_socket }} - -# Option: pidfile -# Notes.: Set the PID file. This is used to store the process ID of the -# fail2ban server. -# Values: [ FILE ] Default: /var/run/fail2ban/fail2ban.pid -# -pidfile = {{ fail2ban_pidfile }} diff --git a/templates/etc/fail2ban/fail2ban.local.j2 b/templates/etc/fail2ban/fail2ban.local.j2 new file mode 100644 index 0000000..1643807 --- /dev/null +++ b/templates/etc/fail2ban/fail2ban.local.j2 @@ -0,0 +1,19 @@ +# {{ ansible_managed }} + +# Overrides values from the fail2ban.conf configuration file. +# +# For comments relating to each setting see fail2ban.conf + +[Definition] + +loglevel = {{ fail2ban_loglevel }} +logtarget = {{ fail2ban_logtarget }} + +{% if fail2ban_logtarget == "SYSLOG" %} +syslog-target = {{ fail2ban_syslog_target }} +syslog-facility = {{ fail2ban_syslog_facility }} +{% endif %} + +socket = {{ fail2ban_socket }} + +pidfile = {{ fail2ban_pidfile }}