Merge "Create zuul.executor.hostname ansible variable" into feature/zuulv3
diff --git a/tests/base.py b/tests/base.py
index 29981ac..9a6fb69 100755
--- a/tests/base.py
+++ b/tests/base.py
@@ -801,9 +801,13 @@
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')))
+ for host in hosts:
+ host['host_vars']['ansible_connection'] = 'local'
+
+ hosts.append(dict(
+ name='localhost',
+ host_vars=dict(ansible_connection='local'),
+ host_keys=[]))
return hosts
@@ -990,6 +994,7 @@
created_time=now,
updated_time=now,
image_id=None,
+ host_keys=["fake-key1", "fake-key2"],
executor='fake-nodepool')
data = json.dumps(data)
path = self.client.create(path, data,
diff --git a/zuul/driver/gerrit/gerritconnection.py b/zuul/driver/gerrit/gerritconnection.py
index 286006f..c5fefaf 100644
--- a/zuul/driver/gerrit/gerritconnection.py
+++ b/zuul/driver/gerrit/gerritconnection.py
@@ -108,6 +108,7 @@
'reviewer-added': 'reviewer', # Gerrit 2.5/2.6
'ref-replicated': None,
'ref-replication-done': None,
+ 'ref-replication-scheduled': None,
'topic-changed': 'changer',
}
event.account = None
diff --git a/zuul/executor/client.py b/zuul/executor/client.py
index 31646f8..f86b447 100644
--- a/zuul/executor/client.py
+++ b/zuul/executor/client.py
@@ -312,6 +312,7 @@
for node in item.current_build_set.getJobNodeSet(job.name).getNodes():
nodes.append(dict(name=node.name, image=node.image,
az=node.az,
+ host_keys=node.host_keys,
provider=node.provider,
region=node.region,
public_ipv6=node.public_ipv6,
diff --git a/zuul/executor/server.py b/zuul/executor/server.py
index 862053a..60b30c7 100644
--- a/zuul/executor/server.py
+++ b/zuul/executor/server.py
@@ -641,11 +641,15 @@
ip = node.get('public_ipv4')
if not ip:
ip = node.get('public_ipv6')
- hosts.append((node['name'], dict(
+ host_vars = dict(
ansible_host=ip,
nodepool_az=node.get('az'),
nodepool_provider=node.get('provider'),
- nodepool_region=node.get('region'))))
+ nodepool_region=node.get('region'))
+ hosts.append(dict(
+ name=node['name'],
+ host_vars=host_vars,
+ host_keys=node.get('host_keys')))
return hosts
def _blockPluginDirs(self, path):
@@ -806,16 +810,19 @@
self.jobdir.roles_path.append(role_path)
def prepareAnsibleFiles(self, args):
+ keys = []
with open(self.jobdir.inventory, 'w') as inventory:
- for host_name, host_vars in self.getHostList(args):
- inventory.write(host_name)
- for k, v in host_vars.items():
+ for item in self.getHostList(args):
+ inventory.write(item['name'])
+ for k, v in item['host_vars'].items():
inventory.write(' %s=%s' % (k, v))
inventory.write('\n')
- if 'ansible_host' in host_vars:
- os.system("ssh-keyscan %s >> %s" % (
- host_vars['ansible_host'],
- self.jobdir.known_hosts))
+ for key in item['host_keys']:
+ keys.append(key)
+
+ with open(self.jobdir.known_hosts, 'w') as known_hosts:
+ for key in keys:
+ known_hosts.write('%s\n' % key)
with open(self.jobdir.vars, 'w') as vars_yaml:
zuul_vars = dict(args['vars'])
@@ -845,6 +852,7 @@
if self.jobdir.roles_path:
config.write('roles_path = %s\n' %
':'.join(self.jobdir.roles_path))
+ config.write('command_warnings = False\n')
config.write('callback_plugins = %s\n'
% self.executor_server.callback_dir)
config.write('stdout_callback = zuul_stream\n')