ansible-runner
ansible-runner copied to clipboard
Cannot specify container work dir when running `ansible-runner` via cmdline
Hi guys,
[Based on advice from @AlanCoding on issues/758, I am opening a separate issue to track my issue. I also posted about the issue on https://groups.google.com/g/awx-project/c/Il-q0mfkoeA and will reference this ticket there.]
I am focusing on running ansible-runner
locally in commandline mode on our existing repositories with process isolation done via docker (so as to try and match what AWX does).
This playbook repository has a particular structure which does not abide by the ansible-runner input directory hierarchy (https://ansible-runner.readthedocs.io/en/stable/intro/#inputdir). I am thus using the several ansible-runner commandline parameters to point at the various pieces that are required.
I am stumbling upon an issue in that the playbook I specify cannot be found by the newly spawned container: ERROR! the playbook: deploy-stack.yaml could not be found
Investigating in debug mode log attached, I see this is because the underlying docker commandline always has --workdir /runner/project
specified whereas the playbook is actually located/mounted under /runner/deploy-stack.yaml
If I edit the docker commandline and run it manually to specify --workdir /runner
, then ansible-playbook
starts and find the playbook, as expected.
I have looked into the ansible-runner
source (I am using v2.1.1) and it seems the logic which sets the working directory is at https://github.com/ansible/ansible-runner/blob/2.1.1/ansible_runner/config/_base.py#L451
It should be overridable via either self.container_dir
or self.host_cwd
. The thing is, I can't find where the commandline entry point (and not the Python one) is actually setting those values. It looks like this option is missing.
Could someone explain how to specify the container working directory when running ansible-runner
from the commandline?