Skip to content

Commit

Permalink
iptables: Make the role Debian compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
quartje committed Apr 11, 2024
1 parent 060442d commit 946d3cd
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
31 changes: 23 additions & 8 deletions roles/iptables/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,46 @@
---
- name: Uninstall firewalld
yum:
ansible.builtin.package:
name: firewalld
state: absent

- name: Install iptables and ip6tables
yum:
- name: Install iptables and ip6tables on CentOS
ansible.builtin.yum:
name:
- iptables-services
state: present
when: ansible_os_family == 'RedHat'

- name: Install iptables on debian system
ansible.builtin.apt:
name:
- iptables
- iptables-persistent
state: present
when: ansible_os_family == 'Debian'

- name: Put iptables
template:
ansible.builtin.template:
src: "iptables.j2"
dest: "/etc/sysconfig/iptables"
dest: /etc/sysconfig/iptables
owner: root
group: root
mode: "0644"
notify:
- "restart iptables"

- name: Put ip6tables
template:
ansible.builtin.template:
src: "ip6tables.j2"
dest: "/etc/sysconfig/ip6tables"
dest: /etc/sysconfig/ip6tables
owner: root
group: root
mode: "0644"
notify:
- "restart ip6tables"

- name: Start and enable services iptables and iptables6
service:
ansible.builtin.service:
name: "{{ item }}"
state: started
enabled: true
Expand Down
2 changes: 2 additions & 0 deletions roles/iptables/vars/Debian.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
iptables_location: /etc/sysconfig/iptables
iptables_location6: /etc/sysconfig/ip6tables

0 comments on commit 946d3cd

Please sign in to comment.