Ansible output customize

253 views
Skip to first unread message

Parveen Datt

unread,
Mar 3, 2020, 3:42:10 PM3/3/20
to Ansible Project
Hi Team

I have written a playbook and using debug variable we are reading the output in multiple play. Is there any way we can customize the output of each registered variable and print it nicely formatted . Any suggestion would be appreciated

Thx

M F

unread,
Mar 3, 2020, 3:49:18 PM3/3/20
to Ansible Project

Jean-Yves LENHOF

unread,
Mar 3, 2020, 3:55:40 PM3/3/20
to ansible...@googlegroups.com
Hi,

What is nicely formatted ?

Please show on an example what you want

Regards,

JYL

Parveen Datt

unread,
Mar 6, 2020, 12:51:05 AM3/6/20
to Ansible Project
Hi JYL,

Here is what i mean. 


TASK [debug] ***********************************************************************************************************************************

ok: [192.168.56.50] => (item= 00:48:30 up 2 min,  1 user,  load average: 0.05, 0.06, 0.03) => {

    "msg": " 00:48:30 up 2 min,  1 user,  load average: 0.05, 0.06, 0.03"

}

ok: [192.168.56.50] => (item=4.1.12-124.36.4.el7uek.x86_64) => {

    "msg": "4.1.12-124.36.4.el7uek.x86_64"

}




Can we customize above output something like below

TASK [debug] ***********************************************************************************************************************************


    "msg": "Server Uptime is -> [' 00:50:34 up 4 min,  1 user,  load average: 0.01, 0.04, 0.03']"


    "msg": "Server Kernel is --> ['4.1.12-124.36.4.el7uek.x86_64']"



Jean-Yves LENHOF

unread,
Mar 6, 2020, 4:14:48 AM3/6/20
to ansible...@googlegroups.com

Hi,

Did you try a callback that satisfy you ?

https://docs.ansible.com/ansible/latest/plugins/callback.html

If not you should probably have to create yours...

Ansible is not the most obvious tool to create some reports... What did you want to achieve ? If you want a proper report, perhaps use a template to create what you want on destination nodes and after get files back to your controller with slurp module.

Regards,

JYL

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/a2a59ad5-fcea-4d84-8f09-ec954da750cf%40googlegroups.com.

madan gopal

unread,
Sep 18, 2020, 2:21:58 PM9/18/20
to Ansible Project
Hi Praveen,

I am looking for a script to take user input and provide system uptime for both Windows and Linux environments.

Any assistance with this playbook is greatly appreciated.

Regards,
Madan

Mike Eggleston

unread,
Sep 18, 2020, 2:23:56 PM9/18/20
to ansible...@googlegroups.com
I was only concerned with unix and would use this ad-hoc command:
$ ansible all -m command -a uptime -o

--
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.
Reply all
Reply to author
Forward
0 new messages