---
- name: open gluster ports
  iptables:
    chain: INPUT
    destination_port: "{{ item }}"
    jump: ACCEPT
    ctstate: NEW
    protocol: tcp
    action: insert
    match: tcp
  with_items: "{{ gluster_ports }}"
  when: groups['storage'] is defined and groups['storage'] != []
  register: rule

- name: save iptables
  shell: iptables-save > /etc/sysconfig/iptables
  when: rule|changed
  notify:
    - restart iptables

- name: open gluster ports
  iptables:
    chain: INPUT
    destination_port: "{{ item }}"
    ctstate: NEW
    jump: ACCEPT
    protocol: tcp
    action: insert
    match: tcp
  with_items: "{{ crs_ports }}"
  when: groups['crs'] is defined and groups['crs'] != []
  register: heketi

- name: save iptables
  shell: iptables-save > /etc/sysconfig/iptables
  when: heketi|changed
  notify:
    - restart iptables
