title: How Do I Make Ansible Retry on SSH Errors?
body: <p>I am occasionally getting SSH failures in my Ansible 2.6.19 playbook during operations that that use <code>file</code> or <code>copy</code> with large <code>with_items</code>. Several items will succeed then at some point I will get</p>
  <pre><code>Shared connection to xxx.xyz.com closed
  sudo: PAM account management error: Authentication service cannot retrieve authentication info
  </code></pre>
  <p>Then 2 seconds later there is a <code>SUCCESS</code> message for each of the rest of the files. This suggests to me that something must have happened on the server to cause the issue and then it resolved itself.</p>
  <p>I have <code>pipelining = True</code> in my <code>ansible.cfg</code>.</p>
  <p>How do I make Ansible playbook try again on SSH errors like this so the playbook doesn't fail?</p>
  <p><strong>EDIT:</strong> To address the comment, I am investigating the source but since I don't have control of it I need a backup. The retry/until is at the task level, however, there are too many tasks to put it on each one. I really need something at a playbook level. e.g. in <code>ansible.cfg</code></p>