Fix ansible inventory

Actually write a correct host list for ansible.

Change-Id: I5e23f330476f064acf3cb87f746c5d3193cce274
diff --git a/tests/base.py b/tests/base.py
index bbf4d36..1847104 100755
--- a/tests/base.py
+++ b/tests/base.py
@@ -777,6 +777,14 @@
             result = build.run()
         return result
 
+    def getHostList(self, args):
+        self.log.debug("hostlist")
+        hosts = super(RecordingAnsibleJob, self).getHostList(args)
+        for name, d in hosts:
+            d['ansible_connection'] = 'local'
+        hosts.append(('localhost', dict(ansible_connection='local')))
+        return hosts
+
 
 class FakeGearmanServer(gear.Server):
     """A Gearman server for use in tests.
diff --git a/zuul/launcher/client.py b/zuul/launcher/client.py
index 23bec90..d9e7d21 100644
--- a/zuul/launcher/client.py
+++ b/zuul/launcher/client.py
@@ -338,7 +338,9 @@
 
         nodes = []
         for node in item.current_build_set.getJobNodeSet(job.name).getNodes():
-            nodes.append(dict(name=node.name, image=node.image))
+            nodes.append(dict(name=node.name, image=node.image,
+                              public_ipv6=node.public_ipv6,
+                              public_ipv4=node.public_ipv4))
         params['nodes'] = nodes
         params['zuul'] = zuul_params
         projects = set()
diff --git a/zuul/launcher/server.py b/zuul/launcher/server.py
index 1ba42da..3ee6c72 100644
--- a/zuul/launcher/server.py
+++ b/zuul/launcher/server.py
@@ -594,13 +594,14 @@
         return result
 
     def getHostList(self, args):
-        # TODOv3: the localhost addition is temporary so we have
-        # something to exercise ansible.
-        hosts = [('localhost', dict(ansible_connection='local'))]
+        # TODO(clarkb): This prefers v4 because we're not sure if we
+        # expect v6 to work.  If we can determine how to prefer v6
+        hosts = []
         for node in args['nodes']:
-            # TODOv3: the connection should almost certainly not be
-            # local.
-            hosts.append((node['name'], dict(ansible_connection='local')))
+            ip = node.get('public_ipv4')
+            if not ip:
+                ip = node.get('public_ipv6')
+            hosts.append((node['name'], dict(ansible_host=ip)))
         return hosts
 
     def _blockPluginDirs(self, path):