<p dir="auto">From <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/telbizov/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/telbizov">@telbizov</a> on 2016-09-06T18:02:16Z</p>
<h5 dir="auto">ISSUE TYPE</h5>
<ul dir="auto">
<li>Feature Idea</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>
<ul dir="auto">
<li>apt</li>
</ul>
<h5 dir="auto">ANSIBLE VERSION</h5>
<p dir="auto">Any, but most likely 2.x branch</p>
<h5 dir="auto">CONFIGURATION</h5>
<p dir="auto">N/A</p>
<h5 dir="auto">OS / ENVIRONMENT</h5>
<p dir="auto">Debian family Linux running apt package management</p>
<h5 dir="auto">SUMMARY</h5>
<p dir="auto">This is a feature request but also works around a problem that is very common when manipulating apt packages/repositories on a given host from multiple instances of apt.</p>
<p dir="auto">Currently if there is an instance working with apt (via ansible apt module or not) there is a lock which is being held exclusively and as such no other apt instance can get a hold of. The result is that if there's a second instance of apt which tries to acquire the lock it gets an instant failure. In the case of doing this via ansible the result is:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="msg: Failed to lock apt for exclusive operation"><pre class="notranslate"><code class="notranslate">msg: Failed to lock apt for exclusive operation
</code></pre></div>
<p dir="auto">This is the default apt behavior and as far as I can tell there is not way to pass a flag to apt command line, or apt configuraion, to tell it to <strong>wait</strong> for the lock to be released and then only timeout after a certain period of time.</p>
<p dir="auto">It would be very useful if ansible's apt module itself was to provide such a feature. Say an optional flag - for example <code class="notranslate">lock_wait=60</code> which would make ansible try to acquire the lock every second for X seconds and eventually timing out. This way if two ansible playbooks running at the same time are trying to use the apt repository they will have much higher chance of succeeding.</p>
<p dir="auto">Currently one of them errors out only so that the user retry the entire playbook .</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>
<p dir="auto">Run two ansible instances each utilizing the apt module at the very same time - one of them will fail with the above error.</p>
<h5 dir="auto">EXPECTED RESULTS</h5>
<p dir="auto">If we have this feature in ansible then we don't need to wrap each individual playbook's apt calls with retries and have it built-in the apt module itself.</p>
<p dir="auto">Copied from original issue: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="175311582" data-permission-text="Title is private" data-url="https://github.com/ansible/ansible-modules-core/issues/4717" data-hovercard-type="issue" data-hovercard-url="/ansible/ansible-modules-core/issues/4717/hovercard" href="https://github.com/ansible/ansible-modules-core/issues/4717">ansible/ansible-modules-core#4717</a></p>
<h5 dir="auto">ISSUE TYPE</h5>
<ul dir="auto">
<li>Feature Idea<br>
This is a copy of the issue on the old repository: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="175311582" data-permission-text="Title is private" data-url="https://github.com/ansible/ansible-modules-core/issues/4717" data-hovercard-type="issue" data-hovercard-url="/ansible/ansible-modules-core/issues/4717/hovercard" href="https://github.com/ansible/ansible-modules-core/issues/4717">ansible/ansible-modules-core#4717</a><br>
There was some work on it, I don't know why it's not added: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="176947454" data-permission-text="Title is private" data-url="https://github.com/ansible/ansible-modules-core/issues/4842" data-hovercard-type="pull_request" data-hovercard-url="/ansible/ansible-modules-core/pull/4842/hovercard" href="https://github.com/ansible/ansible-modules-core/pull/4842">ansible/ansible-modules-core#4842</a></li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>
<p dir="auto">apt</p>
<h5 dir="auto">SUMMARY</h5>
<p dir="auto">This is a feature request but also works around a problem that is very common when manipulating apt packages/repositories on a given host from multiple instances of apt.</p>
<p dir="auto">Currently if there is an instance working with apt (via ansible apt module or not) there is a lock which is being held exclusively and as such no other apt instance can get a hold of. The result is that if there's a second instance of apt which tries to acquire the lock it gets an instant failure. In the case of doing this via ansible the result is:</p>
<p dir="auto">msg: Failed to lock apt for exclusive operation</p>
<p dir="auto">This is the default apt behavior and as far as I can tell there is not way to pass a flag to apt command line, or apt configuraion, to tell it to wait for the lock to be released and then only timeout after a certain period of time.</p>
<p dir="auto">It would be very useful if ansible's apt module itself was to provide such a feature. Say an optional flag - for example lock_wait=60 which would make ansible try to acquire the lock every second for X seconds and eventually timing out. This way if two ansible playbooks running at the same time are trying to use the apt repository they will have much higher chance of succeeding.</p>
<p dir="auto">Currently one of them errors out only so that the user retry the entire playbook .</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>
<p dir="auto">Run two ansible instances each utilizing the apt module at the very same time - one of them will fail with the above error.</p>
<h5 dir="auto">EXPECTED RESULTS</h5>
<p dir="auto">If we have this feature in ansible then we don't need to wrap each individual playbook's apt calls with retries and have it built-in the apt module itself.</p>