docker_login works in playbook, but not in role?

I’m trying to use a private docker registry, and seeing some weirdness that I can’t explain. Running the exact same task yaml is working as expected when I put it in a playbook and run it, but not working when running as part of a role (the task runs, but comes back with status “changed”: false

Here’s my playbook, which works:

`

  • name: docker login test
    hosts: myhost-02
    tasks:
  • name: log in to my docker registry
    docker_login:
    registry: hoylu.azurecr.io
    username: hoylu
    password: MyPassword

`

and here’s what I have under roles/dockerhost/tasks:

`

hmm, after further investigation, it seems not to have to do with the fact that it’s a role, and more to do, presumably, with something that’s running before this task in the playbook. I created a ‘debug’ role with just these tasks, and that works as expected. So any ideas about what previous tasks could cause this not to work as expected would be helpful.

thanks,
Bjorn

Ok, never mind, I solved it. I had failed to notice that the top level playbook had ’ become: true’, and so the docker_login was running as root, and not the user I was expecting.