change iptables to nftables

This commit is contained in:
Ruben Blanco 2023-10-26 14:16:21 +02:00
parent 13eb16ac17
commit f2b6b61840
3 changed files with 21 additions and 15 deletions

View File

@ -1,5 +1,10 @@
# restart fail2ban service to apply changes # restart fail2ban service to apply changes
- name: Restart fail2ban - name: restart fail2ban
service: service:
name: "{{ fail2ban_daemon }}" name: "{{ fail2ban_daemon }}"
state: restarted
# restart nftables service
- name: restart nftables
service:
name: "{{ nftables_daemon }}"
state: restarted state: restarted

View File

@ -5,18 +5,17 @@
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# comprobe if fail2ban is installed if not then install fail2ban # comprobe if fail2ban is installed if not then install fail2ban
# Gather the package facts # Gather the package facts
- name: Gather the package facts #- name: Gather the package facts
package_facts: # package_facts:
manager: auto # manager: auto
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# install packages if is not in the system # install packages if is not in the system
- name: install fail2ban package if is not in the system #- name: install fail2ban package if is not in the system
apt: # apt:
name: fail2ban # name: fail2ban
state: present # state: present
when: "'fail2ban' not in ansible_facts.packages" # when: "'fail2ban' not in ansible_facts.packages"
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@ -30,11 +29,12 @@
group: root group: root
mode: '0644' mode: '0644'
backup: true backup: true
notify: Restart fail2ban notify: restart fail2ban
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# service should start on boot. # service nftables should start on boot.
- name: service should start on boot - name: service nftables should start on boot
service: service:
name: "{{ fail2ban_daemon }}" name: "{{ nftables_daemon }}"
enabled: yes enabled: yes
notify: restart nftables
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

View File

@ -1,3 +1,4 @@
# vars file # vars file
path_jail_local: /etc/fail2ban/jail.local path_jail_local: /etc/fail2ban/jail.local
fail2ban_daemon: fail2ban fail2ban_daemon: fail2ban
nftables_daemon: nftables