<p dir="auto">From <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/cherusk/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/cherusk">@cherusk</a> on 2016-09-16T16:58:59Z<br>
Come back to me asap, please. Were prepared for impl. if OK.</p>
<h5 dir="auto">ISSUE TYPE</h5>

<ul dir="auto">
<li>Feature Idea</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>

<p dir="auto">mount module</p>
<h5 dir="auto">ANSIBLE VERSION</h5>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible 2.0.0.2"><pre class="notranslate"><code class="notranslate">ansible 2.0.0.2
</code></pre></div>
<p dir="auto">Copied from original issue: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="177472990" data-permission-text="Title is private" data-url="https://github.com/ansible/ansible-modules-core/issues/4885" data-hovercard-type="issue" data-hovercard-url="/ansible/ansible-modules-core/issues/4885/hovercard" href="https://github.com/ansible/ansible-modules-core/issues/4885">ansible/ansible-modules-core#4885</a></p>
<h5 dir="auto">Issue Type:</h5>
<p dir="auto">Bug Report</p>
<h5 dir="auto">Ansible Version:</h5>
<p dir="auto">Ansible 1.9.2</p>
<h5 dir="auto">Ansible Configuration:</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[defaults]
library = /etc/ansible/library"><pre class="notranslate"><code class="notranslate">[defaults]
library = /etc/ansible/library
</code></pre></div>
<h5 dir="auto">Environment:</h5>
<p dir="auto">Ubuntu 14.04 LTS</p>
<h5 dir="auto">Summary:</h5>
<p dir="auto">When a playbook is run more than once concurrency from one host to another a suspected race condition occurs</p>
<h5 dir="auto">Steps To Reproduce:</h5>
<p dir="auto">I think there might be a race condition in the function involving </p><div class="Box Box--condensed my-2">
  <div class="Box-header f6">
    <p class="mb-0 text-bold">
      <a href="https://github.com/ansible/ansible/blob/5ce3988d8693357f671f3fbec43b2d3b862db5f6/v1/ansible/utils/__init__.py#L319">ansible/v1/ansible/utils/__init__.py</a>
    </p>
    <p class="mb-0 color-fg-muted">
         Line 319
      in
      <a data-pjax="true" class="commit-tease-sha" href="/ansible/ansible/commit/5ce3988d8693357f671f3fbec43b2d3b862db5f6">5ce3988</a>
    </p>
  </div>
  <div itemprop="text" class="Box-body p-0 blob-wrapper blob-wrapper-embedded data">
    <table class="highlight tab-size mb-0 js-file-line-container" data-tab-size="8" data-paste-markdown-skip="">

        <tbody><tr class="border-0">
          <td id="L319" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="319"></td>
          <td id="LC319" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-k">raise</span> <span class="pl-s1">errors</span>.<span class="pl-v">AnsibleError</span>(<span class="pl-s">"Could not make dir %s: %s"</span> <span class="pl-c1">%</span> (<span class="pl-s1">tree</span>, <span class="pl-s1">e</span>)) </td>
        </tr>
    </tbody></table>
  </div>
</div>
<p></p>
<p dir="auto">If I run the same playbook twice against the same host it is possible that one of the runs dies with the following:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="GATHERING FACTS ***
fatal: [web.tst.example.com] =&gt; Could not make dir /var/lib/jenkins/.ansible/cp: [Errno 17] File exists: '/var/lib/jenkins/.ansible/cp'"><pre class="notranslate"><code class="notranslate">GATHERING FACTS ***
fatal: [web.tst.example.com] =&gt; Could not make dir /var/lib/jenkins/.ansible/cp: [Errno 17] File exists: '/var/lib/jenkins/.ansible/cp'
</code></pre></div>
<p dir="auto">My use case is I have Jenkins jobs running a playbook against a host that manages Apache config along with some application specific settings. Even if I do run two Jenkins jobs at the same time the above doesn't always happen so it leads me to suspect a race condition during the temporary directory creation.</p>
<p dir="auto">Is there a reason this directory isn't also unique per run as the things placed under it?</p>
<h5 dir="auto">Expected Results:</h5>
<p dir="auto">I'd expect each separate playbook run not to try to create and delete the same directory so they can happily run side by side.</p>
<h5 dir="auto">Actual Results:</h5>
<p dir="auto">If I run the same playbook twice against the same host it is possible that one of the runs dies with the following:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="GATHERING FACTS ***
fatal: [web.tst.example.com] =&gt; Could not make dir /var/lib/jenkins/.ansible/cp: [Errno 17] File exists: '/var/lib/jenkins/.ansible/cp'"><pre class="notranslate"><code class="notranslate">GATHERING FACTS ***
fatal: [web.tst.example.com] =&gt; Could not make dir /var/lib/jenkins/.ansible/cp: [Errno 17] File exists: '/var/lib/jenkins/.ansible/cp'
</code></pre></div>