Browse Source

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
changes/35/578235/4
Tristan Cacqueray 3 years ago
parent
commit
0419f79632
3 changed files with 11 additions and 2 deletions
  1. +7
    -0
      doc/source/user/jobs.rst
  2. +2
    -1
      tests/fixtures/config/ansible/git/common-config/playbooks/check-vars.yaml
  3. +2
    -1
      zuul/executor/server.py

+ 7
- 0
doc/source/user/jobs.rst 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


+ 2
- 1
tests/fixtures/config/ansible/git/common-config/playbooks/check-vars.yaml 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'

+ 2
- 1
zuul/executor/server.py 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)


Loading…
Cancel
Save