Ansible 1.9 Using Sudo on an Include?

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

You will likely be interested in a fix that was applied to devel a short time ago:

https://github.com/ansible/ansible/pull/10566