refactor(ansible): prefer iptables module
This commit is contained in:
parent
08c64f3f42
commit
4803ee9181
@ -1,2 +1,2 @@
|
|||||||
[ovh]
|
[ovh]
|
||||||
ovh1 ansible_host=5.39.72.167 ansible_port=7511 ansible_user=ubuntu
|
ovh1 ansible_host=5.39.72.167 ansible_port=7511 ansible_user=ubuntu firewall_ports=80,443,6443,7511
|
||||||
|
@ -41,32 +41,14 @@
|
|||||||
command: sshd -t
|
command: sshd -t
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
- name: Create iptables rules file
|
- name: Open firewall ports
|
||||||
copy:
|
iptables:
|
||||||
dest: /etc/iptables.rules
|
chain: INPUT
|
||||||
content: |
|
protocol: tcp
|
||||||
*filter
|
destination_port: "{{ item }}"
|
||||||
:INPUT DROP [0:0]
|
jump: ACCEPT
|
||||||
:FORWARD DROP [0:0]
|
state: present
|
||||||
:OUTPUT ACCEPT [0:0]
|
loop: "{{ firewall_ports }}"
|
||||||
-A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
|
|
||||||
-A INPUT -p tcp --dport 80 -j ACCEPT
|
|
||||||
-A INPUT -p tcp --dport 443 -j ACCEPT
|
|
||||||
-A INPUT -p tcp --dport 7511 -j ACCEPT
|
|
||||||
-A INPUT -i lo -j ACCEPT
|
|
||||||
COMMIT
|
|
||||||
|
|
||||||
- name: Apply iptables rules
|
|
||||||
shell: iptables-restore < /etc/iptables.rules
|
|
||||||
changed_when: false
|
|
||||||
|
|
||||||
- name: Ensure iptables rules are loaded on boot (Debian/Ubuntu)
|
|
||||||
copy:
|
|
||||||
dest: /etc/network/if-pre-up.d/iptablesload
|
|
||||||
content: |
|
|
||||||
#!/bin/sh
|
|
||||||
iptables-restore < /etc/iptables.rules
|
|
||||||
mode: '0755'
|
|
||||||
|
|
||||||
- name: Ensure fail2ban is started and enabled
|
- name: Ensure fail2ban is started and enabled
|
||||||
service:
|
service:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user