summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2017-12-20 18:35:50 +0000
committerGerrit Code Review <review@openstack.org>2017-12-20 18:35:50 +0000
commit21d3e22c7460a01d3eef4bb0c081d6107b31d064 (patch)
tree86c2f349d0c4dbbc7860ccf9c30480104260e562
parent78966becb97263731daa51feb1c17c4d0a6ca1c6 (diff)
parentc5043212ea2221626d2b076291c75a3c69a02b81 (diff)
downloadzuul-21d3e22c7460a01d3eef4bb0c081d6107b31d064.tar.gz
Merge "Use connection type supplied from nodepool" into feature/zuulv3
-rwxr-xr-xtests/base.py6
-rw-r--r--tests/fixtures/config/inventory/git/common-config/zuul.yaml2
-rw-r--r--tests/unit/test_inventory.py10
-rw-r--r--zuul/executor/server.py4
-rw-r--r--zuul/model.py1
5 files changed, 22 insertions, 1 deletions
diff --git a/tests/base.py b/tests/base.py
index a51eeddcd..7e63129ea 100755
--- a/tests/base.py
+++ b/tests/base.py
@@ -1432,7 +1432,8 @@ class RecordingAnsibleJob(zuul.executor.server.AnsibleJob):
self.log.debug("hostlist")
hosts = super(RecordingAnsibleJob, self).getHostList(args)
for host in hosts:
- host['host_vars']['ansible_connection'] = 'local'
+ if not host['host_vars'].get('ansible_connection'):
+ host['host_vars']['ansible_connection'] = 'local'
hosts.append(dict(
name=['localhost'],
@@ -1738,6 +1739,9 @@ class FakeNodepool(object):
executor='fake-nodepool')
if 'fakeuser' in node_type:
data['username'] = 'fakeuser'
+ if 'windows' in node_type:
+ data['connection_type'] = 'winrm'
+
data = json.dumps(data).encode('utf8')
path = self.client.create(path, data,
makepath=True,
diff --git a/tests/fixtures/config/inventory/git/common-config/zuul.yaml b/tests/fixtures/config/inventory/git/common-config/zuul.yaml
index ad530a783..36789a321 100644
--- a/tests/fixtures/config/inventory/git/common-config/zuul.yaml
+++ b/tests/fixtures/config/inventory/git/common-config/zuul.yaml
@@ -38,6 +38,8 @@
label: default-label
- name: fakeuser
label: fakeuser-label
+ - name: windows
+ label: windows-label
- job:
name: base
diff --git a/tests/unit/test_inventory.py b/tests/unit/test_inventory.py
index 1c41f5fa5..be504475a 100644
--- a/tests/unit/test_inventory.py
+++ b/tests/unit/test_inventory.py
@@ -119,5 +119,15 @@ class TestInventory(ZuulTestCase):
self.assertEqual(
inventory['all']['hosts'][node_name]['ansible_user'], username)
+ # check if the nodes use the correct or no ansible_connection
+ if node_name == 'windows':
+ self.assertEqual(
+ inventory['all']['hosts'][node_name]['ansible_connection'],
+ 'winrm')
+ else:
+ self.assertEqual(
+ 'local',
+ inventory['all']['hosts'][node_name]['ansible_connection'])
+
self.executor_server.release()
self.waitUntilSettled()
diff --git a/zuul/executor/server.py b/zuul/executor/server.py
index 22dee9aca..5a710a62d 100644
--- a/zuul/executor/server.py
+++ b/zuul/executor/server.py
@@ -931,6 +931,10 @@ class AnsibleJob(object):
if username:
host_vars['ansible_user'] = username
+ connection_type = node.get('connection_type')
+ if connection_type:
+ host_vars['ansible_connection'] = connection_type
+
host_keys = []
for key in node.get('host_keys'):
if port != 22:
diff --git a/zuul/model.py b/zuul/model.py
index 77770b793..dbae1f296 100644
--- a/zuul/model.py
+++ b/zuul/model.py
@@ -384,6 +384,7 @@ class Node(object):
self.private_ipv4 = None
self.public_ipv6 = None
self.connection_port = 22
+ self.connection_type = None
self._keys = []
self.az = None
self.provider = None