Ansible 1.9 Using Sudo on an Include?

180 views
Skip to first unread message

Greg Peterson

unread,
Apr 2, 2015, 3:20:50 PM4/2/15
to ansible...@googlegroups.com
Didn't see anything mentioned in changes notes for 1.9 about changing the way sudo worked with includes, so wanted to post this:

In the below example, sudo is no longer seeming to apply to the tasks in the included file .  If I attach "sudo: True" directly to the task then the playbook runs, see second example.

First example works fine in 1.8.4, but 1.9.0.1 the playbooks/roles break:

TASK: [sts-base-system | apt packages | update cache] *************************
failed: [10.0.50.50] => {"failed": true}
msg: Failed to lock apt for exclusive operation

FATAL: all hosts have already failed -- aborting

Can workaround by updating all playbooks and roles to apply sudo directly to each task, but pretty inconvenient.


main.yml
---
- { include: packages.yml, sudo: True, tags: ['packages'] }

packages.yml (1)
---
- name: apt packages | update cache
  apt:
    update_cache: True
    cache_valid_time: 600

packages.yml (2)
---
- name: apt packages | update cache
  sudo: True
  apt:
    update_cache: True
    cache_valid_time: 600

Matt Martz

unread,
Apr 2, 2015, 3:39:28 PM4/2/15
to ansible...@googlegroups.com
You will likely be interested in a fix that was applied to devel a short time ago:


--
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/6ab38fcf-c5fc-4f0c-ad6a-549953b6eae7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Matt Martz
@sivel
sivel.net
Reply all
Reply to author
Forward
0 new messages