Single line output in AWX

Hi,

I have used ansible a lot on the command line and used to do things like this:

ansible -i hosts database -m shell -a ‘mysql --version’ -o

Output will be like:

DBTEST01 | CHANGED | rc=0 | (stdout) mysql Ver 14.14 Distrib 5.7.35, for Linux (x86_64) using EditLine wrapper
DBTEST02 | CHANGED | rc=0 | (stdout) mysql Ver 14.14 Distrib 5.7.35, for Linux (x86_64) using EditLine wrapper

It makes the output easily greppable or easily pasted into spreadsheets etc.

But when I try to do the same sort of thing from AWX I can’t see a way to restrict the output to one line. Is there a way?

I am clicking on Inventory → my-inventory → Groups → Database → Run Command and select shell, and type the command in to Arguments, and I have the ability to change Verbosity, Limit, and Forks, but nothing equivalent to “-o”.

AWX output is in 2-line format which makes it harder to parse:

DBTEST01 | CHANGED | rc=0 >>
mysql Ver 14.14 Distrib 5.7.35, for Linux (x86_64) using EditLine wrapper
DBTEST02 | CHANGED | rc=0 >>
mysql Ver 14.14 Distrib 5.7.35, for Linux (x86_64) using EditLine wrapper

This is a minor detail but causes additional work that the “-o” option would negate.

Why are you bothering to use AWX for this? It’s pointless. Write playbooks/roles which are repeatable.
You might as well just use the command line using this approach.

Hi Phil.

Firstly I have no command line access to AWX. It’s a shared server with RBAC giving me access to only my inventory and my projects.

Secondly, this is ad-hoc stuff, not anything I’d want to write a playbook for - especially as I have to do that in git and sync the project etc.

This is just an example of a single command I might want to run against my inventory (e.g. for audit purposes) and the command will be different each time so the effort of writing a playbook or role for every one is a waste - and that’s where the “run command” feature of AWX is so useful - but just with this one caveat that it doesn’t have a flag forcing one-line output like the -o command line option does.

If it can’t be done, it can’t be done, I’ll just have to get better at multi-line grep.