Set default owner for all the file (or template) resources in a role

Hello,

I found a role in galaxy and it’s creating config files for a service. The author was running it without sudo. When I run it with sudo, the config files (created by template module) are owned by the ansible_ssh_user rather than root. They need to be owned by root. I was thinking to add “owner: root” to all the template resources in the role, but then I thought it might be better to specify it only once, and make root the default owner somehow in order to not to repeat myself.

Is it possible to specify default owner for all the files or templates in a role somehow?

How I would expect it to work: In /defaults/main.yml, I’d set “template.owner: root”. The resources would then be root-owned unless specified otherwise.

Cheers,
Tomas

There is no facility to set per-module defaults in Ansible right now.

It’s been discussed, and it’s something I’d like to be able to support, but there’s enough going on right now that I’d want to consider this for a later release.

–Michael