From dcc37b6eb910e1414580aadc5e7b8504ec24dc35 Mon Sep 17 00:00:00 2001 From: Peter Oliver Date: Thu, 11 Oct 2018 18:41:07 +0100 Subject: [PATCH] Locate prtdiag even when absent from /usr/bin (#44113) * Locate prtdiag even when absent from /usr/bin On Solaris 8 hosts, this prevents fact collection from aborting with: Argument 'args' to run_command must be list or string * Lint fix. * Style: pass /usr/platform/.../sbin as optional path to get_bin_path(). (cherry picked from commit 40fb992a6fbc6fbf111865845e53da6df50ddaf5) --- changelogs/fragments/solaris-prtdiag-path.yaml | 3 +++ lib/ansible/module_utils/facts/hardware/sunos.py | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/solaris-prtdiag-path.yaml diff --git a/changelogs/fragments/solaris-prtdiag-path.yaml b/changelogs/fragments/solaris-prtdiag-path.yaml new file mode 100644 index 00000000000..ae3cf426dc4 --- /dev/null +++ b/changelogs/fragments/solaris-prtdiag-path.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: + - Hardware fact gathering now completes on Solaris 8. Previously, it aborted with error `Argument 'args' to run_command must be list or string`. diff --git a/lib/ansible/module_utils/facts/hardware/sunos.py b/lib/ansible/module_utils/facts/hardware/sunos.py index 3433d23b72f..48993ef6ec9 100644 --- a/lib/ansible/module_utils/facts/hardware/sunos.py +++ b/lib/ansible/module_utils/facts/hardware/sunos.py @@ -168,8 +168,13 @@ class SunOSHardware(Hardware): def get_dmi_facts(self): dmi_facts = {} - uname_path = self.module.get_bin_path("prtdiag") - rc, out, err = self.module.run_command(uname_path) + # On Solaris 8 the prtdiag wrapper is absent from /usr/sbin, + # but that's okay, because we know where to find the real thing: + rc, platform, err = self.module.run_command('/usr/bin/uname -i') + platform_sbin = '/usr/platform/' + platform.rstrip() + '/sbin' + + prtdiag_path = self.module.get_bin_path("prtdiag", opt_dirs=[platform_sbin]) + rc, out, err = self.module.run_command(prtdiag_path) """ rc returns 1 """