Re-add the ability to set username on zuul-executor
Sometimes we need to log in to a nodepool node using a username of
something other than zuul. This used to be possible by setting that
[launcher] username= property. Re-enable it with the [executor]
default_username= property.
default_username is used instead of simply username as it is likely in
future this information will be able to be supplied by nodepool or other
in a node or image specific way. At which time that information will be
used in priority to the default specified in zuul.
Change-Id: Icf657b4f0bbe34e182307b9eea0cd64a8d813464
diff --git a/etc/zuul.conf-sample b/etc/zuul.conf-sample
index bf19895..1065cec 100644
--- a/etc/zuul.conf-sample
+++ b/etc/zuul.conf-sample
@@ -18,6 +18,9 @@
;git_user_name=zuul
zuul_url=http://zuul.example.com/p
+[executor]
+default_username=zuul
+
[webapp]
listen_address=0.0.0.0
port=8001
diff --git a/zuul/executor/server.py b/zuul/executor/server.py
index 0adb6de..5aa9700 100644
--- a/zuul/executor/server.py
+++ b/zuul/executor/server.py
@@ -239,6 +239,12 @@
else:
self.merge_root = '/var/lib/zuul/executor-git'
+ if self.config.has_option('executor', 'default_username'):
+ self.default_username = self.config.get('executor',
+ 'default_username')
+ else:
+ self.default_username = 'zuul'
+
if self.config.has_option('merger', 'git_user_email'):
self.merge_email = self.config.get('merger', 'git_user_email')
else:
@@ -672,6 +678,7 @@
ip = node.get('interface_ip')
host_vars = dict(
ansible_host=ip,
+ ansible_user=self.executor_server.default_username,
nodepool_az=node.get('az'),
nodepool_provider=node.get('provider'),
nodepool_region=node.get('region'))