From 0d31dba6cbad84708efad93c0a5eed411208ef0e Mon Sep 17 00:00:00 2001 From: Paul Belanger Date: Fri, 7 Dec 2018 09:03:55 -0500 Subject: [PATCH] Add nodepool.host_id variable to inventory file We recently exposed node.host_id in zookeeper from nodepool. Also include it into the inventory file so jobs can access it. Change-Id: Ic90af15dd86555aca2ce09120715b0aeb8af8516 Signed-off-by: Paul Belanger --- releasenotes/notes/host-id-inventory-e1cba009bb5a536d.yaml | 5 +++++ tests/base.py | 1 + .../ansible/git/common-config/playbooks/check-vars.yaml | 1 + zuul/executor/server.py | 1 + zuul/model.py | 1 + 5 files changed, 9 insertions(+) create mode 100644 releasenotes/notes/host-id-inventory-e1cba009bb5a536d.yaml diff --git a/releasenotes/notes/host-id-inventory-e1cba009bb5a536d.yaml b/releasenotes/notes/host-id-inventory-e1cba009bb5a536d.yaml new file mode 100644 index 0000000000..61dcc2f456 --- /dev/null +++ b/releasenotes/notes/host-id-inventory-e1cba009bb5a536d.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + The Ansible inventory file now includes nodepool.host_id variable if the + node was launched using the OpenStack Nodepool driver. diff --git a/tests/base.py b/tests/base.py index 7e6fa468a3..2bfc89caac 100644 --- a/tests/base.py +++ b/tests/base.py @@ -1835,6 +1835,7 @@ class FakeNodepool(object): region='test-region', az='test-az', attributes=self.attributes, + host_id='test-host-id', interface_ip=remote_ip, public_ipv4=remote_ip, private_ipv4=None, diff --git a/tests/fixtures/config/ansible/git/common-config/playbooks/check-vars.yaml b/tests/fixtures/config/ansible/git/common-config/playbooks/check-vars.yaml index a5bbe6158b..a307961b4c 100644 --- a/tests/fixtures/config/ansible/git/common-config/playbooks/check-vars.yaml +++ b/tests/fixtures/config/ansible/git/common-config/playbooks/check-vars.yaml @@ -5,6 +5,7 @@ that: - nodepool.az == 'test-az' - nodepool.cloud == 'test-cloud' + - nodepool.host_id == 'test-host-id' - nodepool.region == 'test-region' - nodepool.provider == 'test-provider' diff --git a/zuul/executor/server.py b/zuul/executor/server.py index 0c9e912951..8405e94806 100644 --- a/zuul/executor/server.py +++ b/zuul/executor/server.py @@ -1227,6 +1227,7 @@ class AnsibleJob(object): cloud=node.get('cloud'), provider=node.get('provider'), region=node.get('region'), + host_id=node.get('host_id'), interface_ip=node.get('interface_ip'), public_ipv4=node.get('public_ipv4'), private_ipv4=node.get('private_ipv4'), diff --git a/zuul/model.py b/zuul/model.py index 374e59bc16..0fe1c9b695 100644 --- a/zuul/model.py +++ b/zuul/model.py @@ -517,6 +517,7 @@ class Node(ConfigObject): # Attributes from Nodepool self._state = 'unknown' self.state_time = time.time() + self.host_id = None self.interface_ip = None self.public_ipv4 = None self.private_ipv4 = None