Repository: ansible/ansible

Issue:
Ansible 2.2 fails to run on Solaris 8 & 9, worked in 2.1
<!---
Please verify first that your issue/request is not already reported in GitHub
-->


##### ISSUE TYPE
<!--- Pick one below and delete the rest: -->
 - Bug Report

##### COMPONENT NAME
<!--- Name of the module/plugin/task/feature -->
Core

##### ANSIBLE VERSION
<!--- Paste verbatim output from “ansible --version” between quotes below -->
```
ansible 2.2.0.0
  config file = /local/home/ans_unix/.ansible.cfg
  configured module search path = Default w/o overrides
```

##### CONFIGURATION
<!---
Mention any settings you have changed/added/removed in ansible.cfg
(or using the ANSIBLE_* environment variables).
-->

##### OS / ENVIRONMENT
```
Ansible server running SLES 12SP1
Clients with problems: Solaris 8 and Solaris 9 (sparc). Python 2.7.12
```

##### SUMMARY
<!--- Explain the problem briefly -->
After upgrading to Ansible 2.2.0.0, Ansible fails almost immediately on Solaris 8 & 9. Solaris 10 still works fine. Solaris 8 & 9 worked fine in Ansible 2.1.2.0 & 2.1.3.0

##### STEPS TO REPRODUCE
Run any playbook on a Solaris 8 or 9 machine

<!--- Paste example playbooks or commands between quotes below -->
```

```

<!--- You can also paste gist.github.com links for larger files -->

##### EXPECTED RESULTS
<!--- What did you expect to happen when running the steps above? -->
Playbooks should run as in previous Ansible versions

##### ACTUAL RESULTS
<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->

(2.2.0.0) -bash-4.2$ ansible-playbook --inventory-file=/local/ansible/unix/staging/inventory/hosts site.yml --limit xx.xxx.xxx

PLAY [First ansible tests] *****************************************************

TASK [setup] *******************************************************************
fatal: [xxx.xxx.xxx]: FAILED! => {"changed": false, "cmd": null, "failed": true, "msg": "Argument 'args' to run_command must be list or string", "rc": 257}
        to retry, use: --limit @/local/ansible/unix/staging/site.retry

PLAY RECAP *********************************************************************
xxx.xxx.xxx      : ok=0    changed=0    unreachable=0    failed=1

<!--- Paste verbatim command output between quotes below -->

Full -vvvv output here: https://gist.github.com/ddelin/4a7bc5acfcca17f6242dbfe9790853ea#file-ansiblebug_solaris-txt

My Google groups thread on the same issue : https://groups.google.com/forum/#!msg/ansible-project/6dZ1JA2mF9E/bm-prDt7CQAJ;context-place=forum/ansible-project



Discussion:
@ddelin Please detail how you installed and then upgraded ansible. The error in the description resembles a mismatch between module code versus module util code.

needs_info
Actually I should have been more clear about how the installation was done, I have not really upgraded the installation, I use Python virtual environments to have the different versions separated, and to be able to switch between them. All installations was done with PIP. If I switch back to any of the 2.1.x environments, everything works fine again. 
Not an expert on Python virtual env., but I think I get a completely new installation of Ansible and it´s dependencies in each virtual env. ?
The 2.2 installation works for us on SLES 9-12, RHEL 4-6, AIX 5.3 and Solaris 10 so it seems to only affect Solaris 8 & 9.
Going on the theory that the setup.py module is calling module_utils.basic.run_command with args=None at some point, there are a few code paths in setup.py that look like they could end up doing that.

Do the client systems have 'virtinfo' on the path?  facts's SunOSVirtual.get_virtual_facts will try some smbios tools if 'virtinfo' isn't available. The code that uses smbios doesn't check if 'smbios' exists  (and I'm guessing it doesn't exist if those are solaris 8/9 sparc machines).  (https://github.com/ansible/ansible/blob/devel/lib/ansible/module_utils/facts.py#L3593-L3594)

(That facts.py code looks buggy either way, but not sure thats the root cause. That was new code in 2.2.0.0 though.)

Resolving patch:
diff --git a/lib/ansible/module_utils/facts.py b/lib/ansible/module_utils/facts.py
--- a/lib/ansible/module_utils/facts.py
+++ b/lib/ansible/module_utils/facts.py
@@ -3591,6 +3591,8 @@ def get_virtual_facts(self):
 
         else:
             smbios = self.module.get_bin_path('smbios')
+            if not smbios:
+                return
             rc, out, err = self.module.run_command(smbios)
             if rc == 0:
                 for line in out.splitlines():


Test patch: