---
- name: remove firewalld
  package:
    name: firewalld
    state: removed

- name: install iptables-services
  package:
    name: iptables-services
    state: installed

- name: create iptables config
  template:
    src: "{{ item }}.j2"
    dest: "/etc/sysconfig/{{ item }}"
    mode: 0600
    owner: root
    group: root
  notify: "reload {{ item }}"
  with_items:
    - iptables
    - ip6tables

- name: enable iptables service
  service:
    name: "{{ item }}"
    state: started
    enabled: yes
  with_items:
    - iptables
    - ip6tables

---
- name: remove firewalld
  package:
    name: firewalld
    state: removed

- name: install iptables-services
  package:
    name: iptables-services
    state: installed

- name: copy iptables config
  template:
    src: "{{ firewall_src[item] }}"
    dest: "/etc/sysconfig/{{ item }}"
    mode: 0600
    owner: root
    group: root
  notify: "reload {{ item }}"
  with_items:
    - iptables
    - ip6tables
  when: firewall_src[item] is defined

- name: create iptables config from template
  template:
    src: "{{ item }}.j2"
    dest: "/etc/sysconfig/{{ item }}"
    mode: 0600
    owner: root
    group: root
  notify: "reload {{ item }}"
  with_items:
    - iptables
    - ip6tables
  when: firewall_src[item] is not defined

- name: enable iptables service
  service:
    name: "{{ item }}"
    state: started
    enabled: yes
  with_items:
    - iptables
    - ip6tables

Add support for custom iptables config
firewall: Add support for custom iptables config
