# Can lock\_timeout be applied to a role that uses package module?

**URL:** <https://forum.ansible.com/t/can-lock-timeout-be-applied-to-a-role-that-uses-package-module/30677>\
**Category:** Ansible Project\
**Created:** [June 27, 2019, 7:59pm UTC](https://forum.ansible.com/t/can-lock-timeout-be-applied-to-a-role-that-uses-package-module/30677 "2019-06-27T19:59:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Scott\_Lundgren](https://avatars.discourse-cdn.com/v4/letter/s/7bcc69/32.png) [@Scott\_Lundgren](https://forum.ansible.com/u/Scott_Lundgren)\
**Post date:** [June 27, 2019, 7:59pm UTC](https://forum.ansible.com/t/can-lock-timeout-be-applied-to-a-role-that-uses-package-module/30677/1 "2019-06-27T19:59:32Z")

</div>

If I’m calling the role [newrelic.newrelic-infra that uses the package module](https://github.com/newrelic/infrastructure-agent-ansible/blob/34e290787a83a47d4edb77dcae7685c942515a39/tasks/install_dist_pkgs.yml#L85), is there a way to set or override lock\_timeout’s default value of 0 ?  
Can you suggest another solution than forking the role, rewriting the task in an OS dependent way using the yum module and setting lock\_timeout ?

I have a simple playbook below to setup a web application firewall. I’m using Amazon Linux 2 (4.14.123-111.109.amzn2.x86\_64) with python (v2.7.14) that has installed Ansible (v2.8.1) via pip. Packer (v1.4.1) builds of AMI’s thru ansible\_local fail with

`  
amazon-ebs: TASK [roles/newrelic.newrelic-infra : install agent] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
amazon-ebs: fatal: [127.0.0.1]: FAILED! =\> {“changed”: false, “msg”: “yum lockfile is held by another process”}

`

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [June 27, 2019, 8:02pm UTC](https://forum.ansible.com/t/can-lock-timeout-be-applied-to-a-role-that-uses-package-module/30677/2 "2019-06-27T20:02:47Z")

</div>

By using `module_defaults` in a play, you can impact all uses of an underlying module.

This can be done for `yum`, even if using the `package` module.

[https://docs.ansible.com/ansible/latest/user\_guide/playbooks\_module\_defaults.html](https://docs.ansible.com/ansible/latest/user_guide/playbooks_module_defaults.html)

There is however a bug in Ansible 2.8 that prevents this from working right now, but a backport PR is waiting to be merged:

[https://github.com/ansible/ansible/pull/56400](https://github.com/ansible/ansible/pull/56400)

---

<div class="post-metadata">

**Author:** ![Scott\_Lundgren](https://avatars.discourse-cdn.com/v4/letter/s/7bcc69/32.png) [@Scott\_Lundgren](https://forum.ansible.com/u/Scott_Lundgren)\
**Post date:** [June 28, 2019, 2:22pm UTC](https://forum.ansible.com/t/can-lock-timeout-be-applied-to-a-role-that-uses-package-module/30677/3 "2019-06-28T14:22:47Z")

</div>

Thanks for such a quick response. I did find [your comment](https://github.com/ansible/ansible/issues/57189#issuecomment-499165098) referenced [this thread](https://groups.google.com/forum/#!topic/ansible-project/sRkPvDE-dPU) and tried to apply the following in my playbook’s defaults/main.yml.

module\_defaults:  
yum:  
lock\_timeout: 30

Letting me know there’s a bug in 2.8 explains why that didn’t work. Changing my build script to:

`sudo pip install paramiko git+https://github.com/ansible/ansible.git@devel`

Allows the [newrelic.newrelic-infra](https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2Fnewrelic%2Finfrastructure-agent-ansible%2Fblob%2F34e290787a83a47d4edb77dcae7685c942515a39%2Ftasks%2Finstall_dist_pkgs.yml%23L85&sa=D&sntz=1&usg=AFQjCNEKcRWD42lPFVzfAYEscbTXnk8lAA) role to install.

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [June 28, 2019, 2:24pm UTC](https://forum.ansible.com/t/can-lock-timeout-be-applied-to-a-role-that-uses-package-module/30677/4 "2019-06-28T14:24:19Z")

</div>

The module\_defaults attribute only can be used at the play, block, and task level. You cannot add it to a roles defaults.
