Can lock_timeout be applied to a role that uses package module?

139 views
Skip to first unread message

Scott Lundgren

unread,
Jun 27, 2019, 3:59:32 PM6/27/19
to Ansible Project
If I'm calling the role newrelic.newrelic-infra that uses the package module, 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"}

---
- hosts: all
  become: true
  roles:
    - roles/geerlingguy.apache
    - roles/newrelic.newrelic-infra
    - roles/ansible-role-apache-modsecurity
    - roles/nickhammond.logrotate
  tasks:
<-- snip -->

Matt Martz

unread,
Jun 27, 2019, 4:03:50 PM6/27/19
to ansible...@googlegroups.com
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.


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:


--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/55d1ab83-32c1-43fa-9bd5-9b4dbefcab4f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Matt Martz
@sivel
sivel.net

Scott Lundgren

unread,
Jun 28, 2019, 10:22:48 AM6/28/19
to Ansible Project
Thanks for such a quick response. I did find your comment referenced this thread 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 role to install.

On Thursday, June 27, 2019 at 4:03:50 PM UTC-4, Matt Martz wrote:
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.


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:


On Thu, Jun 27, 2019 at 2:59 PM Scott Lundgren <sc...@payzer.com> wrote:
If I'm calling the role newrelic.newrelic-infra that uses the package module, 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"}

---
- hosts: all
  become: true
  roles:
    - roles/geerlingguy.apache
    - roles/newrelic.newrelic-infra
    - roles/ansible-role-apache-modsecurity
    - roles/nickhammond.logrotate
  tasks:
<-- snip -->

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible...@googlegroups.com.

Matt Martz

unread,
Jun 28, 2019, 10:25:07 AM6/28/19
to ansible...@googlegroups.com
The module_defaults attribute only can be used at the play, block, and task level.  You cannot add it to a roles defaults.

To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.

To post to this group, send email to ansible...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages