diff --git a/roles/iptables/tasks/main.yml b/roles/iptables/tasks/main.yml index 1d11fe00f..e4171abd2 100644 --- a/roles/iptables/tasks/main.yml +++ b/roles/iptables/tasks/main.yml @@ -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 diff --git a/roles/iptables/vars/Debian.yml b/roles/iptables/vars/Debian.yml new file mode 100644 index 000000000..671ccd232 --- /dev/null +++ b/roles/iptables/vars/Debian.yml @@ -0,0 +1,2 @@ +iptables_location: /etc/sysconfig/iptables +iptables_location6: /etc/sysconfig/ip6tables