From 9efac6864d5a8531942902d303a1c6beae7690d9 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sat, 21 Sep 2019 15:13:31 +0200 Subject: [PATCH] docker_login: fix Python 3 problem in #60381 (#62621) * Fix Python 3 problem: run_command() returns native strings, not byte strings. * Add changelog. (cherry picked from commit 2e5137078d33db1b83f343edc0bf81fd4258f140) --- changelogs/fragments/62621-docker_login-fix-60381.yaml | 2 ++ lib/ansible/modules/cloud/docker/docker_login.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/62621-docker_login-fix-60381.yaml diff --git a/changelogs/fragments/62621-docker_login-fix-60381.yaml b/changelogs/fragments/62621-docker_login-fix-60381.yaml new file mode 100644 index 00000000000..4df8d111fd4 --- /dev/null +++ b/changelogs/fragments/62621-docker_login-fix-60381.yaml @@ -0,0 +1,2 @@ +bugfixes: +- "docker_login - correct broken fix for https://github.com/ansible/ansible/pull/60381 which crashes for Python 3." diff --git a/lib/ansible/modules/cloud/docker/docker_login.py b/lib/ansible/modules/cloud/docker/docker_login.py index 590379a4ba2..8b805fce93a 100644 --- a/lib/ansible/modules/cloud/docker/docker_login.py +++ b/lib/ansible/modules/cloud/docker/docker_login.py @@ -224,9 +224,9 @@ class LoginManager(DockerBaseClass): (rc, out, err) = self.client.module.run_command(cmd) if rc != 0: self.fail("Could not log out: %s" % err) - if b'Not logged in to ' in out: + if 'Not logged in to ' in out: self.results['changed'] = False - elif b'Removing login credentials for ' in out: + elif 'Removing login credentials for ' in out: self.results['changed'] = True else: self.client.module.warn('Unable to determine whether logout was successful.')