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

Command-line argument --inventory does not work #1295

Closed
LDTips opened this issue Aug 15, 2023 · 6 comments · Fixed by #1307
Closed

Command-line argument --inventory does not work #1295

LDTips opened this issue Aug 15, 2023 · 6 comments · Fixed by #1307
Labels
bug Something isn't working

Comments

@LDTips
Copy link

LDTips commented Aug 15, 2023

When using ansible-runner I wanted to specify alternate inventory directory by using the --inventory commandline argument

However, it does not work as expected. Instead it changes the hosts file in <private_data_dir>/inventory to be equal to the provided

The command I run:
ansible-runner run -p install_sim.yml --inventory /runner/inventory2/ --process-isolation --container-image localhost/ran-deployment-stable .

Results not in using the inventory found in this location, but rather replaces the hosts file contents inside the default folder (/runner/inventory) with the path supplied to the --inventory argument. My hosts file just has the line /runner/inventory2/

If I rearrange the folder structure and use the ansible-playbook install_sim.yml --inventory inventory2, it works as expected

@github-actions github-actions bot added the needs_triage New item that needs to be triaged label Aug 15, 2023
@Shrews
Copy link
Contributor

Shrews commented Aug 29, 2023

I believe our handling of --inventory might indeed be broken, but I need to research a bit more.

What version of ansible-runner are you using?

@LDTips
Copy link
Author

LDTips commented Aug 30, 2023

The version is 2.3.2

@Shrews
Copy link
Contributor

Shrews commented Sep 5, 2023

Thanks.

I've dug into this more and it appears that the --inventory value is not being validated properly. The only value that is supported in this CLI parameter is a relative location under the <private_data_dir>/inventory subdirectory. Apparently, it's not designed to support a full path, nor any other value. The inventory parameter to the run() API method is supposed to support multiple types of values, however.

I'll work on getting a fix out for this, as well as improving the documentation around it.

@Shrews
Copy link
Contributor

Shrews commented Sep 6, 2023

@LDTips I can only reproduce the behavior you see (contents of inventory/hosts being replaced) when I specify a value for --inventory that does not exist on the localhost. Since you are using /runner in your path, are you attempting to specify the location on the container image (the private data dir is mounted into the container image at that location)? If so, that is not what you should be doing. You should be referencing paths on the localhost.

@LDTips
Copy link
Author

LDTips commented Sep 16, 2023

I think this occurred even when I was specifying localhost paths, but can't remember it for now. In any case, this behaviour seems weird. You can close this issue for now, as for the time being I am unable to check it due to lack of access to the device on which this bug occurred.

When I have time, I will check it and reopen the issue if even after following your guidelines the issue will still occur.

@Shrews
Copy link
Contributor

Shrews commented Sep 18, 2023

Thanks for the response. Going to keep this open as I feel there are improvements to be made wrt the CLI option, at least.

@Shrews Shrews added bug Something isn't working and removed needs_triage New item that needs to be triaged labels Sep 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants