ansible-runner icon indicating copy to clipboard operation
ansible-runner copied to clipboard

ansible-runner should not set `--workdir` for ad hoc commands

Open AlanCoding opened this issue 3 years ago • 5 comments

If using process_isolation=True, then the default behavior is to set --workdir, and the default location winds up being /runner/project.

https://github.com/ansible/ansible-runner/blob/dcdb62daf668a31754fc6fbf73374e7d14d5f52c/ansible_runner/config/_base.py#L432

Consider running with module="setup" as opposed to playbook - running an ad-hoc command. There should be no project directory, because it is not used for anything.

However, if the user does not create a project directory, podman fails with

Error: chdir: No such file or directory: OCI not found

type of errors. This is because ansible-runner, on its own, adds on --workdir /runner/project without checking that the "project" directory exists on the host machine, and ignorant of ad hoc commands. The directory doesn't exist, so podman tries to do a chdir to a directory that doesn't exist, so it errors.

This error is surfaced in the standard out, but that can still be challenging to debug.

AlanCoding avatar Jul 20 '21 01:07 AlanCoding

Hi @AlanCoding ,

I am hitting a related issue in that I cannot override the directory which is set via --workdir. I have posted at https://groups.google.com/g/awx-project/c/Il-q0mfkoeA and would welcome your feedback on this. Hopefully this is just something that I have overlooked.

Thanks for your help!

vrubiolo avatar Dec 09 '21 15:12 vrubiolo

Like you say, it looks like the input to override this is container_workdir. This is in the interface.py module, but that's it, no CLI option.

AlanCoding avatar Dec 09 '21 18:12 AlanCoding

Thank you @AlanCoding. Would it be appropriate to open a separate defect here?

I don't want to pollute yours; both are related but mine is not about ad-hoc commands...

vrubiolo avatar Dec 10 '21 08:12 vrubiolo

Yeah, that makes sense to track it separately.

AlanCoding avatar Dec 10 '21 14:12 AlanCoding

Yeah, that makes sense to track it separately.

Thank you, I have opened a separate ticket and referenced my issue there (:point_up: )

vrubiolo avatar Dec 20 '21 19:12 vrubiolo