Add possibility to restart Fail2ban service

This commit is contained in:
Jeremy Gardais 2018-08-07 11:03:29 +02:00
parent fb43eeeb47
commit f47be2bebe
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
4 changed files with 10 additions and 1 deletions

View File

@ -2,6 +2,7 @@
### Fix ### Fix
* Set empty dependencies line to fix Galaxy warning. * Set empty dependencies line to fix Galaxy warning.
* Add possibility to restart Fail2ban service.
## v1.4 ## v1.4

View File

@ -54,6 +54,7 @@ Highly inspired by [Mike Gleason firewall role][mikegleasonjr firewall github] (
* **nft_service_manage**: If `nftables` service should be managed with this role [default: `true`]. * **nft_service_manage**: If `nftables` service should be managed with this role [default: `true`].
* **nft_service_name**: `nftables` service name [default: `nftables`]. * **nft_service_name**: `nftables` service name [default: `nftables`].
* **nft_service_enabled**: Set `nftables` service available at startup [default: `true`]. * **nft_service_enabled**: Set `nftables` service available at startup [default: `true`].
* **nft__fail2ban_service**: If the Nftables service should also restart the Fail2ban service [default: `False`].
### OS Specific Variables ### OS Specific Variables

View File

@ -128,3 +128,4 @@ nft_service_name: 'nftables'
nft_service_enabled: true nft_service_enabled: true
nft_service_unit_path: '/lib/systemd/system/nftables.service' nft_service_unit_path: '/lib/systemd/system/nftables.service'
nft_service_unit_content: 'lib/systemd/system/nftables.service.j2' nft_service_unit_content: 'lib/systemd/system/nftables.service.j2'
nft__fail2ban_service: False

View File

@ -2,7 +2,7 @@
[Unit] [Unit]
Description={{ nft_service_name }} Description={{ nft_service_name }}
Documentation=man:nft(8) http://wiki.nftables.org Documentation=man:nft(8) http://wiki.nftables.org
Before=fail2ban.service ;Before=fail2ban.service
[Service] [Service]
Type=oneshot Type=oneshot
@ -10,9 +10,15 @@ RemainAfterExit=yes
StandardInput=null StandardInput=null
ProtectSystem=full ProtectSystem=full
ProtectHome=true ProtectHome=true
{% if nft__fail2ban_service %}
ExecStart=/usr/sbin/nft -f {{ nft_main_conf_path }} ; /bin/systemctl restart fail2ban.service
ExecReload=/usr/sbin/nft -f {{ nft_main_conf_path }} ; /bin/systemctl restart fail2ban.service
ExecStop=/bin/systemctl stop fail2ban.service ; /usr/sbin/nft flush ruleset
{% else %}
ExecStart=/usr/sbin/nft -f {{ nft_main_conf_path }} ExecStart=/usr/sbin/nft -f {{ nft_main_conf_path }}
ExecReload=/usr/sbin/nft -f {{ nft_main_conf_path }} ExecReload=/usr/sbin/nft -f {{ nft_main_conf_path }}
ExecStop=/usr/sbin/nft flush ruleset ExecStop=/usr/sbin/nft flush ruleset
{% endif %}
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target