Greetings everyone,
I am currently integrating some playbooks to run from AWX: the playbooks used to run from the commandline only, and only one at a time (whereas we have multiple environments). There are some things to adapt to in them, tied to the execution environments or inventory management.
I thus find myself frequently updating my playbook repo, syncing both inventory source and project in AWX and re-launching the job template and this takes time. The AWX web console for getting job outputs is great but also takes time to refresh compared to running Ansible in a single shell on my machine.
My question is thus: what would be the best way to short-cycle this loop while still keeping the specifics of AWX (execution environment, etc)? Ideally, I would have a single command to run over my local playbook git repo to validate my changes and be confident they would run w/o errors when done in AWX. I would tend to think this would be something like ansible-runner but I don’t know which exact arguments to use for it.
Would you have any suggestions?
Thanks for your help,
Vincent
Hi again everyone,
After reading more and building a custom execution environment myself (which worked great, thanks for ansible-builder btw!), I am now certain ansible-runner is what I want to use to be able to run jobs on my machine with the same execution environment and parameters than within AWX.
The thing is I cannot manage to find the actual ansible-runner arguments which are used when a job is run. The closest I could get was using the AWX CLI client and finding a related commandline for a job in its job_args variable:
“job_args”: “["ssh-agent", "sh", "-c", "trap ‘rm -f /runner/artifacts/112/ssh_key_data’ EXIT && ssh-add /runner/artifacts/112/ssh_key_data && rm -f /runner/artifacts/112/ssh_key_data && ansible-playbook -u root --become-method
sudo -i /runner/inventory/hosts -e @/runner/env/extravars ansible/vrubiolo-playbook.yaml"]”,
This is one level too deep: it calls directly ansible-playbook and does not describe how the ansible-runner was called. I also don’t know whether it’s the directory input interface (described at https://ansible-runner.readthedocs.io/en/latest/intro/#inputdir) or the commandline which was used.
Would you have any hint? Are you guys using such an interface to debug/run jobs on your workstation?
Thanks for your input here,
Vincent
Hi Vincent.
You are looking at using the wrong tool. Have a look at https://github.com/ansible/ansible-navigator which is designed to do this.
Phil.
Hi Phil,
Thanks for the pointer, I did not know this existed, I will take a look at it, it seems very interesting.
Can you confirm the playbooks run locally and not via a connected AWX instance? This was not fully obvious to me when watching the YT video.
Vincent
Hi Vincent.
Yes it’s local dev based. navigator can be used with or without EEs as well. The idea though is to develop and test a custom EE locally but that’s then consistent throughout wherever else it gets used.
Phil.
Thank you Phil. The idea of being able to test locally a custom EE is definitely appealing to me, this is what I am looking for!
Vincent