Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Special variable "inventory_dir" is filled in incorrectly #5926

Closed
Elbje opened this issue Feb 13, 2020 · 4 comments
Closed

Special variable "inventory_dir" is filled in incorrectly #5926

Elbje opened this issue Feb 13, 2020 · 4 comments

Comments

@Elbje
Copy link

Elbje commented Feb 13, 2020

ISSUE TYPE
  • Bug Report
SUMMARY

The special variable "inventory_dir" has the wrong value according to the ansible docs.

ENVIRONMENT
  • AWX version: 9.1.1
  • AWX install method: kubernetes
  • Ansible version: 2.8.5
  • Operating System: MacOS 10.15.2
  • Web Browser: Chrome
STEPS TO REPRODUCE

When using a project from GIT the inventory_dir is incorrect.
Steps to reproduce:

  1. Create a directory inside the root called "inventory".
  2. Create a directory inside the directory "inventory" called "myTest"
  3. Create an "inventory.ini" file inside "myTest"
  4. Run a playbook against a host defined in inventory.ini
  5. Put a file you want to copy to the remote host.
  6. if using {{ inventory_dir }}/file_i_want_to_copy.yml awx throws an error "Could not find or access".
EXPECTED RESULTS

As described in the docs https://docs.ansible.com/ansible/latest/reference_appendices/special_variables.html inventory_dir should be filled in with the directory where your host is first defined in the inventory file, in my case /inventory/myTest/

ACTUAL RESULTS

inventory_dir points at the root of my project.

ADDITIONAL INFORMATION
@ryanpetrello
Copy link
Contributor

@Elbje

if using {{ inventory_dir }}/file_i_want_to_copy.yml awx throws an error "Could not find or access".

Is there more context of the error you're seeing here? Perhaps more verbosity, or a traceback?

@Elbje
Copy link
Author

Elbje commented Feb 14, 2020

@ryanpetrello it is just a file not found error because the inventory_dir variable is filled in differently when running in awx. Running the playbook locally using Ansible (2.8.5) works fine because the inventory_dir variable is filled in correctly there. I use the inventory_dir variable to construct the rest of my paths (eg. Filepaths for files I want to copy form local to remote host)

Thanks for your comment, If you need any more information please let me know!

@wenottingham
Copy link
Contributor

AWX gathers inventory by connecting to the database to pull information on the imported inventory. There is not an inventory directory in this context; it will likely be set to a temporary directory where this inventory is pulled. You'll need to calculate this differently.

@ng-bsy
Copy link

ng-bsy commented Nov 21, 2022

@wenottingham

AWX gathers inventory by connecting to the database to pull information on the imported inventory. There is not an inventory directory in this context; it will likely be set to a temporary directory where this inventory is pulled. You'll need to calculate this differently.

Knowing all the internals and specifics of AWX... could you specify, how we would do that exactly?
Did I overlook it in the documentation?
Surely it has been documented, as it's obviously not working in compliance with Ansible.
Thanks in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants