title: 'NoneType' object has no attribute 'upper' while running playbook using ansible-python module?
body: <p>Here is code,</p>
  
  <pre><code>class AnsibleRunner:
  
      def __init__(self):
          self.variable_manager = VariableManager()
          self.loader = DataLoader()
          self.inventory = Inventory(loader=self.loader, variable_manager=self.variable_manager)
          Options = namedtuple('Options', ['listtags', 'listtasks', 'listhosts', 'syntax', 'connection','module_path', 'forks', 'remote_user', 'private_key_file', 'ssh_common_args', 'ssh_extra_args', 'sftp_extra_args', 'scp_extra_args', 'become', 'become_method', 'become_user', 'verbosity', 'check'])
          self.options = Options(listtags=False, listtasks=False, listhosts=True, syntax=False, connection='ssh', module_path=None, forks=100, remote_user='ubuntu', private_key_file=os.getcwd()+"/private-key.pem", ssh_common_args=None, ssh_extra_args=None, sftp_extra_args=None, scp_extra_args=None, become=False, become_method=None, become_user='root', verbosity=None, check=False)
  
  
      def execute_playbook(self, playbook, host, scriptname=None, command=None,
                           path=None, username=None, password=None, key=None):
          playbook_path = os.getcwd() + '/playbooks/'+playbook
  
          if not os.path.exists(playbook_path):
              print '[INFO] The playbook does not exist'
              sys.exit()
  
          script_path = None
          if scriptname is not None:
              script_path = os.getcwd() + '/' + scriptname
              if not os.path.exists(script_path):
                  print '[INFO] The script does not exist'
                  sys.exit()
          play_source = self.loader.load_from_file(playbook_path)
          play = Play().load(play_source[0], self.variable_manager, self.loader)
          self.variable_manager.extra_vars = {'scriptname': script_path,
                              'host': host, 'command': command, 'path': path} 
  
          passwords = {}
          if password is not None:
              self.loader.set_vault_password(password)
  
          callback = CallbackModule()
          tqm = TaskQueueManager(
              inventory=self.inventory,
              variable_manager=self.variable_manager,
              loader=self.loader,
              options=self.options,
              passwords=passwords,
              stdout_callback=callback
          )
  
          result = tqm.run(play)
          print result
  </code></pre>
  
  <p>Output is like :</p>
  
  <pre><code>PLAY [110.110.112.139]
  
  TASK [Gathering Facts]
  
  AttributeError: 'NoneType' object has no attribute 'upper'
  
  fatal: [110.110.112.139]: FAILED! =&gt; {"failed": true, "msg": "Unexpected failure during module execution.", "stdout": ""}
  </code></pre>
  
  <p>I tried to debug the code so will put where that host got failed due to the reason which I asked.</p>
  
  <pre><code> display.debug("checking for any_errors_fatal")
  </code></pre>
  
  <p>/usr/lib/python2.7/dist-packages/ansible/plugins/strategy/linear.py(387)run()</p>
  
  <pre><code>failed_hosts = []
  </code></pre>
  
  <p>/usr/lib/python2.7/dist-packages/ansible/plugins/strategy/linear.py(388)run()</p>
  
  <pre><code>unreachable_hosts = []
  </code></pre>
  
  <p>/usr/lib/python2.7/dist-packages/ansible/plugins/strategy/linear.py(389)run()</p>
  
  <pre><code>for res in results:
  </code></pre>
  
  <p>/usr/lib/python2.7/dist-packages/ansible/plugins/strategy/linear.py(390)run()</p>
  
  <pre><code>if res.is_failed() and iterator.is_failed(res._host):
  
  res.is_failed()
  True
  
  iterator.is_failed(res._host)
  True
  </code></pre>
  
  <p>/usr/lib/python2.7/dist-packages/ansible/plugins/strategy/linear.py(391)run()</p>
  
  <p>failed_hosts.append(res._host.name)</p>
  
  <pre><code>res._host.name
  u'110.110.112.139'
  </code></pre>
  
  <p>I tried to print host value from failed host list.</p>
  
  <p>Here the host stored as failed host because of NoneType Exception. Can you please check now?</p>
  
  <p>This is my sample playbook which i am trying to execute,</p>
  
  <pre><code>---
  - hosts: 110.110.112.139
    user: ubuntu
    gather_facts: no
    connection: ssh
    become: yes
    tasks:
    - name: "run shell script on host"
      shell: /bin/true
  </code></pre>
  
  <p>the output after putting <strong>callback._display.verbosity = 3</strong></p>
  
  <pre><code>fatal: [110.110.112.139]: FAILED! =&gt; {
  "failed": true, 
  "msg": "Unexpected failure during module execution.", 
  "stdout": ""
  }
  </code></pre>