# Buggy code
def get_dmi_facts(self):
    uname_path = self.module.get_bin_path("prtdiag")
    rc, out, err = self.module.run_command(uname_path)
    """
        rc returns 1
        """
    if out:
        system_conf = out.split("\n")[0]
        self.facts["product_name"] = re.search(
            r"(\w+\sEnterprise\s\w+)", system_conf
        ).group(1)


# Traceback (nAttributeError)
statically included: /Users/tanner/projects/ansible.git/playbooks.git/roles/updates/tasks/debian.yml
statically included: /Users/tanner/projects/ansible.git/playbooks.git/roles/updates/tasks/ubuntu/lucid.yml
statically included: /Users/tanner/projects/ansible.git/playbooks.git/roles/updates/tasks/suse.yml
statically included: /Users/tanner/projects/ansible.git/playbooks.git/roles/updates/tasks/solaris.yml
statically included: /Users/tanner/projects/ansible.git/playbooks.git/roles/virtual-servers/tasks/debian.yml
statically included: /Users/tanner/projects/ansible.git/playbooks.git/roles/virtual-servers/tasks/remove-official-vmware-tools.yml
statically included: /Users/tanner/projects/ansible.git/playbooks.git/roles/virtual-servers/tasks/install-official-vmware-tools.yml
statically included: /Users/tanner/projects/ansible.git/playbooks.git/roles/virtual-servers/tasks/suse.yml
statically included: /Users/tanner/projects/ansible.git/playbooks.git/roles/support-users/tasks/suse.yml
Loading callback plugin default of type stdout, v2.0 from /Users/tanner/projects/ansible.git/ansible/lib/ansible/plugins/callback/__init__.pyc

PLAYBOOK: linux-servers.yml ****************************************************
1 plays in linux-servers.yml

PLAY [linux-servers] ***********************************************************

TASK [Gathering Facts] *********************************************************
Using module file /Users/tanner/projects/ansible.git/ansible/lib/ansible/modules/core/system/setup.py
<crashplan.local> ESTABLISH SSH CONNECTION FOR USER: ansible
<crashplan.local> SSH: EXEC ssh -vvv -o ControlMaster=auto -o ControlPersist=600s -o ForwardAgent=yes -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ansible -o ConnectTimeout=10 -o ControlPath=/Users/tanner/.ansible/cp/%C crashplan.local '/bin/sh -c '"'"'/usr/bin/python &amp;&amp; sleep 0'"'"''
fatal: [crashplan.local]: FAILED! => {
"changed": false,
"failed": true,
"invocation": {
"module_name": "setup"
},
"module_stderr": "OpenSSH_7.2p2, LibreSSL 2.4.1\r\ndebug1: Reading configuration data /Users/tanner/.ssh/config\r\ndebug3: kex names ok: [diffie-hellman-group1-sha1]\r\ndebug3: kex names ok: [diffie-hellman-group1-sha1]\r\ndebug3: kex names ok: [diffie-hellman-group1-sha1]\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 20: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 8579\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\n/tmp/ansible_vdZiV_/ansible_modlib.zip/ansible/module_utils/facts.py:968: DeprecationWarning: object.__new__() takes no parameters\nTraceback (most recent call last):\n  File \"/tmp/ansible_vdZiV_/ansible_module_setup.py\", line 134, in <module>\n    main()\n  File \"/tmp/ansible_vdZiV_/ansible_module_setup.py\", line 126, in main\n    data = get_all_facts(module)\n  File \"/tmp/ansible_vdZiV_/ansible_modlib.zip/ansible/module_utils/facts.py\", line 3727, in get_all_facts\n  File \"/tmp/ansible_vdZiV_/ansible_modlib.zip/ansible/module_utils/facts.py\", line 3670, in ansible_facts\n  File \"/tmp/ansible_vdZiV_/ansible_modlib.zip/ansible/module_utils/facts.py\", line 1518, in populate\n  File \"/tmp/ansible_vdZiV_/ansible_modlib.zip/ansible/module_utils/facts.py\", line 1603, in get_dmi_facts\nAttributeError: 'NoneType' object has no attribute 'group'\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 1\r\n",
"module_stdout": "",
"msg": "MODULE FAILURE"
}

# Fixed code
def get_dmi_facts(self):
    uname_path = self.module.get_bin_path("prtdiag")
    rc, out, err = self.module.run_command(uname_path)
    """
        rc returns 1
        """
    if out:
        system_conf = out.split("\n")[0]
        found = re.search(r"(\w+\sEnterprise\s\w+)", system_conf)
        if found:
            self.facts["product_name"] = found.group(1)