How to shorten my playbooks AWX adaptation development cycle loop?

63 views
Skip to first unread message

Vincent Rubiolo

unread,
Nov 25, 2021, 3:39:22 AM11/25/21
to AWX Project
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

Vincent Rubiolo

unread,
Nov 30, 2021, 8:02:37 AM11/30/21
to AWX Project
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

phil.gr...@gmail.com

unread,
Dec 1, 2021, 5:27:25 AM12/1/21
to AWX Project
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.

Vincent Rubiolo

unread,
Dec 1, 2021, 5:51:27 PM12/1/21
to AWX Project
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

phil.gr...@gmail.com

unread,
Dec 2, 2021, 6:49:15 AM12/2/21
to AWX Project

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.

Vincent Rubiolo

unread,
Dec 6, 2021, 4:14:59 AM12/6/21
to AWX Project
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

Reply all
Reply to author
Forward
0 new messages