# Ansible.builtin.package - Could not get lock

**URL:** <https://forum.ansible.com/t/ansible-builtin-package-could-not-get-lock/45469>\
**Category:** Get Help\
**Created:** [March 3, 2026, 3:19pm UTC](https://forum.ansible.com/t/ansible-builtin-package-could-not-get-lock/45469 "2026-03-03T15:19:46Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![romgo](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/romgo/32/5202_2.png) [@romgo](https://forum.ansible.com/u/romgo)\
**Post date:** [March 3, 2026, 3:19pm UTC](https://forum.ansible.com/t/ansible-builtin-package-could-not-get-lock/45469/1 "2026-03-03T15:19:46Z")

</div>

Dear community,

I am having some issues when running ansible against target running unattende-upgrades.  
Sometimes run failed with this error :

```auto
TASK [figlet : Install figlet] *************************************************
fatal: [server01]: FAILED! => {"cache_update_time": 1772446127, "cache_updated": false, "changed": false, "msg": "'/usr/bin/apt-get -y -o \"Dpkg::Options::=--force-confdef\" -o \"Dpkg::Options::=--force-confold\" install 'figlet=2.2.5-3+b1'' failed: E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 5374 (unattended-upgr)\nE: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?\n", "rc": 100, "stderr": "E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 5374 (unattended-upgr)\nE: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?\n", "stderr_lines": ["E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 5374 (unattended-upgr)", "E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?"], "stdout": "", "stdout_lines": []}

```

When this happen I just need to re-run the playbook and it works. Now I want to make my playbook bulletproof to this error. After reading documentation, the cleanest way seems to use the module\_defaults to increase lock\_timeout for `ansible.builtin.apt`

So I came to this :

```auto
---
- name: Commons roles
  hosts: server01
  module_defaults:
    ansible.builtin.apt:
      lock_timeout: 300
  gather_facts: true
  roles:
    - { role: figlet, tags: figlet }

```

looks like module\_defaults was somehow ignored. Any idea on what I did wrong ?

thanks

---

<div class="post-metadata">

**Author:** ![Lyle\_McKarns](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/lyle_mckarns/32/8142_2.png) [@Lyle\_McKarns](https://forum.ansible.com/u/Lyle_McKarns)\
**Post date:** [March 3, 2026, 3:23pm UTC](https://forum.ansible.com/t/ansible-builtin-package-could-not-get-lock/45469/2 "2026-03-03T15:23:59Z")

</div>

Your post title says you’re using `ansible.builtin.package`, but the code you shared has a default for `ansible.builtin.apt`. Those are different modules, and as such, the defaults applied to one won’t apply to the other.

Could you share the code from the role that’s actually doing the package updates?

---

<div class="post-metadata">

**Author:** ![bcoca](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/bcoca/32/9269_2.png) [@bcoca](https://forum.ansible.com/u/bcoca)\
**Post date:** [March 3, 2026, 3:33pm UTC](https://forum.ansible.com/t/ansible-builtin-package-could-not-get-lock/45469/3 "2026-03-03T15:33:09Z")

</div>

package is an action plugin, that chooses the appropriate module to use on the target system

---

<div class="post-metadata">

**Author:** ![Lyle\_McKarns](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/lyle_mckarns/32/8142_2.png) [@Lyle\_McKarns](https://forum.ansible.com/u/Lyle_McKarns)\
**Post date:** [March 3, 2026, 3:39pm UTC](https://forum.ansible.com/t/ansible-builtin-package-could-not-get-lock/45469/4 "2026-03-03T15:39:25Z")

</div>

Oh, well, today I learned. Thanks for the insight.

---

<div class="post-metadata">

**Author:** ![romgo](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/romgo/32/5202_2.png) [@romgo](https://forum.ansible.com/u/romgo)\
**Post date:** [March 3, 2026, 3:41pm UTC](https://forum.ansible.com/t/ansible-builtin-package-could-not-get-lock/45469/5 "2026-03-03T15:41:39Z")

</div>

hello,

indeed I install the package like this in the role :

```auto
---
# tasks file for figlet
- name: Install figlet
  ansible.builtin.package:
    name: figlet
    state: present

```

My subsystem is debian so `ansible.builtin.apt` should be use, but maybe the parameter is ignored ?

---

<div class="post-metadata">

**Author:** ![bcoca](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/bcoca/32/9269_2.png) [@bcoca](https://forum.ansible.com/u/bcoca)\
**Post date:** [March 3, 2026, 3:42pm UTC](https://forum.ansible.com/t/ansible-builtin-package-could-not-get-lock/45469/6 "2026-03-03T15:42:07Z")

</div>

@romgo there was a bug with module\_defaults not being recognized as it went by the task action, not the module executed, please check with the latest version of ansible, if it still does not work, open a bug report [new issue](https://github.com/ansible/ansible/issues/new/choose)

---

<div class="post-metadata">

**Author:** ![romgo](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/romgo/32/5202_2.png) [@romgo](https://forum.ansible.com/u/romgo)\
**Post date:** [March 3, 2026, 3:59pm UTC](https://forum.ansible.com/t/ansible-builtin-package-could-not-get-lock/45469/7 "2026-03-03T15:59:06Z")

</div>

> [@bcoca](#):
>
> version

I am currently using :

```auto
ansible [core 2.15.8]
  config file = /root/.ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /builds/path/infra/ansible/venv/lib/python3.11/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /builds/path/infra/ansible/venv/bin/ansible
  python version = 3.11.2 (main, Apr 28 2025, 14:11:48) [GCC 12.2.0] (/builds/path/infra/ansible/venv/bin/python3)
  jinja version = 3.1.6
  libyaml = True

```

The thing is I’m not able to reproduce the error on demand, because this needs unattended upgrades to be busy

---

<div class="post-metadata">

**Author:** ![bcoca](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/bcoca/32/9269_2.png) [@bcoca](https://forum.ansible.com/u/bcoca)\
**Post date:** [March 3, 2026, 4:01pm UTC](https://forum.ansible.com/t/ansible-builtin-package-could-not-get-lock/45469/8 "2026-03-03T16:01:16Z")

</div>

that version has the bug, its EOL, 2.20 is current version

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [April 2, 2026, 4:01pm UTC](https://forum.ansible.com/t/ansible-builtin-package-could-not-get-lock/45469/9 "2026-04-02T16:01:29Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
