show exec command line arguments of ansible-playbook, ansible

95 views
Skip to first unread message

Jakub x

unread,
Dec 22, 2015, 12:27:10 PM12/22/15
to Ansible Project
Hi

I've been thinking what is the best ways of presenting actual command line "row" of the ansible/ansible-playbook execution.

It could be captured 'before execution' with a simple echo, but sometimes the escaping breaks the result (see the example below).
The easiest what I've found is just adding print into ansible-playbook script.
Before I do pull request, etc. - what do You think about it. Any better, easier, or ready-to-use solution?

Note, that presenting args after being parsed with argparse may destroy the view, I do not also wan't to see variables form vault that may be parsed along way. Just CLI exec+arguments.


ansible-playbook

def main(args):
    ''' run ansible-playbook operations '''
    print args
    (...)

Result:
$ ansible-playbook -i ~/ansible/etc/inv/inventory etc/playbooks/playbook.yml -e "system_version=../system_version/prd_default"  -D  -e '{"some_key": {"some_other_key": "x12"}}'            
['-i', '/home/useri/ansible/etc/inv/inventory', 'etc/playbooks/playbook.yml', '-e', 'system_version=../system_version/prd_default', '-D', '-e', '{"some_key": {"some_other_key": "x12"}}' ]  
^^ this result is enough :) If we could have the exact CLI (for further copy-paste execution) would be even better


Broken escaping example:
$ echo ansible-playbook -i ~/ansible/etc/inv/inventory etc/playbooks/playbook.yml -e "system_version=../system_version/prd_default"  -D  -e '{"some_key": {"some_other_key": "x12"}}'   
ansible-playbook -i /home/user/ansible/etc/inv/inventory etc/playbooks/playbook.yml -e system_version=../system_version/prd_default -D -e {"some_key": {"some_other_key": "x12"}}

Matt Martz

unread,
Dec 22, 2015, 12:42:32 PM12/22/15
to ansible...@googlegroups.com
You may wish to take a look at the following PR:  https://github.com/ansible/ansible/pull/13412

The above PR adds callback support based on verbosity to print out invocation information.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/f0b724db-b057-4475-847f-be3d38ed1010%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Matt Martz
@sivel
sivel.net
Reply all
Reply to author
Forward
0 new messages