Skip to content

Commit 22f2142

Browse files
committed
Use to_text for subprocess calls in collect_kernel_info (fixes #59)
1 parent aeb79d6 commit 22f2142

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

library/collect_kernel_info.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import subprocess
55

66
from ansible.module_utils.basic import AnsibleModule
7+
from ansible.module_utils._text import to_text
78

89
def main():
910
module = AnsibleModule(
@@ -51,17 +52,17 @@ def main():
5152

5253
# This will likely output a path that considers the boot partition as /
5354
# e.g. /vmlinuz-4.4.44-1-pve
54-
booted_kernel = subprocess.check_output(["grep", "-o", "-P", "(?<=BOOT_IMAGE=).*?(?= )", "/proc/cmdline"]).strip()
55+
booted_kernel = to_text(subprocess.check_output(["grep", "-o", "-P", "(?<=BOOT_IMAGE=).*?(?= )", "/proc/cmdline"]).strip())
5556

5657
booted_kernel_package = ""
5758
old_kernel_packages = []
5859

5960
if params['lookup_packages']:
6061
for kernel in kernels:
6162
if kernel.split("/")[-1] == booted_kernel.split("/")[-1]:
62-
booted_kernel_package = subprocess.check_output(["dpkg-query", "-S", kernel]).split(":")[0]
63+
booted_kernel_package = to_text(subprocess.check_output(["dpkg-query", "-S", kernel])).split(":")[0]
6364
elif kernel != latest_kernel:
64-
old_kernel_packages.append(subprocess.check_output(["dpkg-query", "-S", kernel]).split(":")[0])
65+
old_kernel_packages.append(to_text(subprocess.check_output(["dpkg-query", "-S", kernel])).split(":")[0])
6566

6667
# returns True if we're not booted into the latest kernel
6768
new_kernel_exists = booted_kernel.split("/")[-1] != latest_kernel.split("/")[-1]

0 commit comments

Comments
 (0)