diff --git a/lib/ansible/modules/cloud/docker/docker_login.py b/lib/ansible/modules/cloud/docker/docker_login.py index 5349d71e0a..35c38fad1f 100644 --- a/lib/ansible/modules/cloud/docker/docker_login.py +++ b/lib/ansible/modules/cloud/docker/docker_login.py @@ -143,6 +143,7 @@ login_results: import base64 +from ansible.module_utils._text import to_bytes, to_text from ansible.module_utils.docker_common import * @@ -276,8 +277,13 @@ class LoginManager(DockerBaseClass): self.log("Adding registry_url %s to auths." % (self.registry_url)) config['auths'][self.registry_url] = dict() + b64auth = base64.b64encode( + to_bytes(self.username) + b':' + to_bytes(self.password) + ) + auth = to_text(b64auth) + encoded_credentials = dict( - auth=base64.b64encode(self.username + b':' + self.password), + auth=auth, email=self.email )