Notify `nftables` service when configuration file is modified.

This commit is contained in:
Jeremy Gardais 2017-08-07 14:14:14 +02:00
parent bc6f69fc59
commit 1c1013067d
6 changed files with 19 additions and 1 deletions

View File

@ -19,6 +19,8 @@ A role to manage Nftables rules and packages.
* **nft_pkg_state**: State of new `nftables` package(s) [default: `installed`].
* **nft_main_conf_path**: Main configuration file loaded by systemd unit [default: `/etc/nftables.conf`].
* **nft_main_conf_content**: Template used to generate the previous main configuration file [default: `etc/nftables.conf.j2`].
* **nft_service_manage**: If `nftables` service should be managed with this role [default: `true`].
* **nft_service_name**: `nftables` service name [default: `nftables`].
### OS Specific Variables
@ -41,6 +43,7 @@ Please see default value by Operating System file in [vars][vars directory] dire
This role will:
* Install `nftables` on the system.
* Generate a default configuration file loaded by systemd unit.
* Restart `nftables` service.
## Development

View File

@ -8,3 +8,7 @@ nft_pkg_state: 'installed'
# conf
nft_main_conf_path: '/etc/nftables.conf'
nft_main_conf_content: 'etc/nftables.conf.j2'
# service
nft_service_manage: true
nft_service_name: 'nftables'

5
handlers/main.yml Normal file
View File

@ -0,0 +1,5 @@
---
# handlers file for nftables
- name: restart nftables service
service: name={{ nft_service_name }} state=restarted
when: nft_service_manage

View File

@ -28,5 +28,5 @@
group: root
mode: 0755
backup: yes
notify: restart nftables service
# }}}

1
tests/inventory Normal file
View File

@ -0,0 +1 @@
localhost

5
tests/test.yml Normal file
View File

@ -0,0 +1,5 @@
---
- hosts: localhost
remote_user: root
roles:
- nftables