From eb4249c7da73029c1e1bab1405fcaebc292d28c1 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Wed, 2 Jan 2019 08:50:40 -0800 Subject: [PATCH] Fix for the new 2.8 feature to have modprobe check for builtins. uname output includes a newline. strip() the newline so that the filepath we construct points to the right place. --- lib/ansible/modules/system/modprobe.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/system/modprobe.py b/lib/ansible/modules/system/modprobe.py index b102e0c76ae..e6e090889eb 100644 --- a/lib/ansible/modules/system/modprobe.py +++ b/lib/ansible/modules/system/modprobe.py @@ -52,6 +52,7 @@ EXAMPLES = ''' params: 'numdummies=2' ''' +import os.path import shlex import traceback @@ -94,7 +95,9 @@ def main(): command = [module.get_bin_path('uname', True), '-r'] rc, uname_kernel_release, err = module.run_command(command) module_file = '/' + name + '.ko' - with open('/lib/modules/' + uname_kernel_release + '/modules.builtin') as builtins: + builtin_path = os.path.join('/lib/modules/', uname_kernel_release.strip(), + 'modules.builtin') + with open(builtin_path) as builtins: for line in builtins: if line.endswith(module_file): present = True