Skip to content

Bail out gracefully if custom venv cannot be used for inventory updates #3139

@kdelee

Description

@kdelee
ISSUE TYPE
  • Bughancement Report
COMPONENT NAME
  • API
SUMMARY

Since inventory updates now use the custom venv set at the organization level, we should fail more gracefully if the custom venv provided does not provide necessary elements such as ansible-inventory that did not exist in anisble 2.3 or prior versions.

ENVIRONMENT
  • AWX version: devel
  • AWX install method: docker on linux
  • Ansible version: custom venv using ansible 2.3
STEPS TO REPRODUCE

Provide a custom venv with ansible 2.3 or prior versions
Attempt to run an inventory update

EXPECTED RESULTS

Tell me that my ancient ansible version does not support inventory updates in tower

ACTUAL RESULTS
stdout:
    6.399 INFO     Updating inventory 239: Inventory - StaffSalary\ufffd
    6.438 INFO     Reading Ansible inventory source: /awx_devel/awx/plugins/inventory/openstack_inventory.py                                                                                                      
    6.439 INFO     Using VIRTUAL_ENV: /venv/python2_ansible23/
    6.439 INFO     Using PATH: /venv/python2_ansible23/bin:/venv/awx/bin:/venv/awx/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    6.439 INFO     Using PYTHONPATH: /venv/python2_ansible23/lib/python2.7/site-packages:
Traceback (most recent call last):
  File "/usr/local/bin/awx-manage", line 9, in <module>
    load_entry_point('awx', 'console_scripts', 'awx-manage')()
  File "/awx_devel/awx/__init__.py", line 150, in manage
    execute_from_command_line(sys.argv)
  File "/venv/awx/lib64/python3.6/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
    utility.execute()
  File "/venv/awx/lib64/python3.6/site-packages/django/core/management/__init__.py", line 356, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/venv/awx/lib64/python3.6/site-packages/django/core/management/base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/venv/awx/lib64/python3.6/site-packages/django/core/management/base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "/awx_devel/awx/main/management/commands/inventory_import.py", line 1049, in handle
    raise exc
  File "/awx_devel/awx/main/management/commands/inventory_import.py", line 949, in handle
    data = AnsibleInventoryLoader(source=source, is_custom=self.is_custom, venv_path=venv_path).load()
  File "/awx_devel/awx/main/management/commands/inventory_import.py", line 194, in load
    return self.command_to_json(base_args + ['--list'])
  File "/awx_devel/awx/main/management/commands/inventory_import.py", line 171, in command_to_json
    self.method, proc.returncode, raw_stdout, stderr))
RuntimeError: ansible-inventory failed (rc=1) with stdout:

stderr:
ERROR! Ansible sub-program not implemented: ansible-inventory

Which would be confusing if you did not understand the implementation details of how inventory updates work now that we use the organization level venv.

Inattentive users many not even realize that the selection of the venv on the org level would change behavior at the the inventory update layer, as this did not use to happen.

ADDITIONAL INFORMATION

affects work on adoption of inventory plugins that @AlanCoding and @jladdjr are working on, but would happen in devel currently as well

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions