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”}}