title: Flush iptables with ansible
body: <p>How do you use Ansible to flush iptables?  Without locking yourself out of the target system because you denied port 22 in the flush?</p>
  
  <p>The iptables module was released with Ansible 2.0, and the flush parameter was added in Ansible 2.2.  So I am wondering how to use that new option.</p>
  
  <p>I want to do the equivalent of this:</p>
  
  <pre><code>$ iptables -F
  $ iptables -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
  $ iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
  $ etc etc
  $ iptables-save
  </code></pre>
  
  <p>I have tried doing a:</p>
  
  <pre><code>- name: Reset iptables to blank slate
    command: "{{item}}"
    with_items:
      - 'iptables -F'
      - 'iptables -A INPUT -p tcp --dport 22 -j ACCEPT'
      - 'iptables-save'
  </code></pre>
  
  <p>Which locked me out of SSH.</p>
  
  <p>I'm assuming that using the following will have the same effect:</p>
  
  <pre><code>-iptables: flush
   become: yes
  </code></pre>