diff options
author | Michael Scherer <mscherer@users.noreply.github.com> | 2016-08-27 15:53:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-27 15:53:13 +0200 |
commit | 21688383c39c63fb42a5a1c4c8610af2659c4915 (patch) | |
tree | 9430f543d63b004afce97773d21298315a8fbb7b | |
parent | 6ca02cadd05150817ac9ded2284691c8204ded81 (diff) | |
download | ansible-modules-core-21688383c39c63fb42a5a1c4c8610af2659c4915.tar.gz |
Convert command output to native string (#4559)
Without it, the module always return changed on python3,
which is harmless but add noise and can have some side effects.
-rw-r--r-- | system/hostname.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/system/hostname.py b/system/hostname.py index 5e98d5bd..d16b1ccc 100644 --- a/system/hostname.py +++ b/system/hostname.py @@ -49,6 +49,7 @@ from distutils.version import LooseVersion # import module snippets from ansible.module_utils.basic import * from ansible.module_utils.facts import * +from ansible.module_utils._text import to_bytes, to_native class UnimplementedStrategy(object): @@ -135,7 +136,7 @@ class GenericStrategy(object): if rc != 0: self.module.fail_json(msg="Command failed rc=%d, out=%s, err=%s" % (rc, out, err)) - return out.strip() + return to_native(out).strip() def set_current_hostname(self, name): cmd = [self.hostname_cmd, name] @@ -297,7 +298,7 @@ class SystemdStrategy(GenericStrategy): if rc != 0: self.module.fail_json(msg="Command failed rc=%d, out=%s, err=%s" % (rc, out, err)) - return out.strip() + return to_native(out).strip() def set_current_hostname(self, name): if len(name) > 64: @@ -314,7 +315,7 @@ class SystemdStrategy(GenericStrategy): if rc != 0: self.module.fail_json(msg="Command failed rc=%d, out=%s, err=%s" % (rc, out, err)) - return out.strip() + return to_native(out).strip() def set_permanent_hostname(self, name): if len(name) > 64: @@ -442,7 +443,7 @@ class SolarisStrategy(GenericStrategy): if rc != 0: self.module.fail_json(msg="Command failed rc=%d, out=%s, err=%s" % (rc, out, err)) - return out.strip() + return to_native(out).strip() def set_permanent_hostname(self, name): cmd = [self.hostname_cmd, name] |