Oefenweb / ansible-fail2ban

Ansible role to set up fail2ban in Debian-like systems
MIT License
117 stars 55 forks source link

Allow templating of jails/actions/filters #59

Open simonspa opened 4 years ago

simonspa commented 4 years ago

This PR allows templating of the jails etc by running the files through the Joinja2 templating engine. By this, local variables can directly be used in a jail, e.g.

my_data_dir = "/home/data"

in the jail:

[myjail]
backend = auto
enabled = true
port = 80,443
protocol = tcp
filter = myfilter
logpath = {{ my_data_dir }}/the.log

Furthermore, the new configuration parameters are lists of templates - which means not all jails/filters end up on all target hosts, but the inventory can be used to set specific jails/filters for specific target machines.

This currently breaks backwards compatibility - if this is of concern I can add the old behavior back in addition to the feature here.