Fix ansible inventory

Actually write a correct host list for ansible.

Change-Id: I5e23f330476f064acf3cb87f746c5d3193cce274
This commit is contained in:
James E. Blair 2017-02-21 11:48:32 -05:00
parent 572a52c82a
commit ad8dca05e3
3 changed files with 18 additions and 7 deletions

View File

@ -777,6 +777,14 @@ class RecordingAnsibleJob(zuul.launcher.server.AnsibleJob):
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.

View File

@ -338,7 +338,9 @@ class LaunchClient(object):
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()

View File

@ -594,13 +594,14 @@ class AnsibleJob(object):
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):