# docker\_login works in playbook, but not in role?

**URL:** <https://forum.ansible.com/t/docker-login-works-in-playbook-but-not-in-role/24270>\
**Category:** Ansible Project\
**Created:** [April 20, 2017, 7:05pm UTC](https://forum.ansible.com/t/docker-login-works-in-playbook-but-not-in-role/24270 "2017-04-20T19:05:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bjorn\_Hansen](https://avatars.discourse-cdn.com/v4/letter/b/7ba0ec/32.png) [@Bjorn\_Hansen](https://forum.ansible.com/u/Bjorn_Hansen)\
**Post date:** [April 20, 2017, 7:05pm UTC](https://forum.ansible.com/t/docker-login-works-in-playbook-but-not-in-role/24270/1 "2017-04-20T19:05:56Z")

</div>

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](http://hoylu.azurecr.io)  
username: hoylu  
password: MyPassword

`

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

`

---

<div class="post-metadata">

**Author:** ![Bjorn\_Hansen](https://avatars.discourse-cdn.com/v4/letter/b/7ba0ec/32.png) [@Bjorn\_Hansen](https://forum.ansible.com/u/Bjorn_Hansen)\
**Post date:** [April 20, 2017, 9:03pm UTC](https://forum.ansible.com/t/docker-login-works-in-playbook-but-not-in-role/24270/2 "2017-04-20T21:03:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Bjorn\_Hansen](https://avatars.discourse-cdn.com/v4/letter/b/7ba0ec/32.png) [@Bjorn\_Hansen](https://forum.ansible.com/u/Bjorn_Hansen)\
**Post date:** [April 20, 2017, 9:13pm UTC](https://forum.ansible.com/t/docker-login-works-in-playbook-but-not-in-role/24270/3 "2017-04-20T21:13:50Z")

</div>

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.
