Runs the playbook and returns True if it completes successfully on all
  hosts.

def RunPlaybookOnHosts(playbook_path, hosts, private_key, extra_vars=None):
  """ Runs the playbook and returns True if it completes successfully on all
  hosts. """
  inventory = ansible_inventory.Inventory(hosts)
  if not inventory.list_hosts():
    raise RuntimeError("Host list is empty.")
  stats = callbacks.AggregateStats()
  verbose = 0
  playbook_cb = ansible.callbacks.PlaybookCallbacks(verbose=verbose)
  runner_cb = ansible.callbacks.PlaybookRunnerCallbacks(stats, verbose=verbose)
  pb = playbook.PlayBook(playbook=playbook_path,
                                  host_list=hosts,
                                  remote_user='ubuntu',
                                  private_key_file=None,
                                  private_key=private_key,
                                  stats=stats,
                                  callbacks=playbook_cb,
                                  runner_callbacks=runner_cb,
                                  extra_vars=extra_vars)
  results = pb.run()
  # Check if all hosts completed playbook without error
  success = True
  if 'dark' in results:
    if len(results['dark']) > 0:
      print "Contact failures:"
      for host, reason in results['dark'].iteritems():
        print "  %s (%s)" % (host, reason['msg'])
      success = False
  for host, status in results.iteritems():
      if host == 'dark':
        continue
      failures = status['failures']
      if failures:
        logging.info( '%s %s' % (host, status))
        success = False
  return success