---
- name: Get iptables rules
  shell: iptables -L
  register: iptablesrules
  always_run: yes

- name: Enable iptables at boot
  service: name=iptables enabled=yes state=started

- name: Open etcd client port with iptables
  command: /sbin/iptables -I INPUT 1 -p tcp --dport {{ item }} -j ACCEPT -m comment --comment "etcd"
  when: etcd not in iptablesrules.stdout
  notify:
          - Save iptables rules
  with_items:
          - 2379
          - 2380
