---
- 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 kubelet port with iptables
  command: /sbin/iptables -I INPUT 1 -p tcp --dport 10250 -j ACCEPT -m comment --comment "kubelet"
  when: kubelet not in iptablesrules.stdout
  notify:
          - restart iptables

- name: Save iptables rules
  command: service iptables save
  when: kubelet not in iptablesrules.stdout
