executor: add inventory_file path to the zuul.executor job variable

This will simplify the log-inventory zuul-jobs role usage for nodeless job.

Change-Id: Ic5b0a3414b79ec9d9dd8502cef970db0b1406b35
This commit is contained in:
Tristan Cacqueray
2018-06-27 00:34:32 +00:00
parent 640fde3545
commit 0419f79632
3 changed files with 11 additions and 2 deletions

View File

@@ -511,6 +511,13 @@ executor running the job is available:
The path to the working directory.
.. var:: inventory_file
The path to the inventory. This variable is needed for jobs running
without a nodeset since Ansible doesn't set it for localhost, see
this `porting guide
<https://docs.ansible.com/ansible/latest/porting_guides/porting_guide_2.4.html#inventory>`_
.. _user_sitewide_variables:
Site-wide Variables

View File

@@ -15,6 +15,7 @@
- zuul.executor.src_root is defined
- zuul.executor.log_root is defined
- zuul.executor.work_root is defined
- zuul.executor.inventory_file is defined
- name: Assert zuul.project variables are valid.
assert:
@@ -39,4 +40,4 @@
- vartest_job == 'vartest_job'
- vartest_secret.value == 'vartest_secret'
- vartest_site == 'vartest_site'
- base_var == 'base_var'
- base_var == 'base_var'

View File

@@ -1350,7 +1350,8 @@ class AnsibleJob(object):
src_root=self.jobdir.src_root,
log_root=self.jobdir.log_root,
work_root=self.jobdir.work_root,
result_data_file=self.jobdir.result_data_file)
result_data_file=self.jobdir.result_data_file,
inventory_file=self.jobdir.inventory)
nodes = self.getHostList(args)
setup_inventory = make_setup_inventory_dict(nodes)