[ansible-project] Playbook output to markdown?

295 views
Skip to first unread message

Leandro Montesoro

unread,
Sep 13, 2022, 8:52:19 AM9/13/22
to Ansible Project
Hello!

In my organization we have some jobs in jenkins that executes differents ansible playbooks to analize things from the differents servers (for example if certain services are found installed).
The problem I have, this playbook is running on many servers, and the output is not very friendly.
Something that would help me is to be able to show, in markdown for example, the final result since the "failed" records give me the indication that something is wrong. Is there a way to model the output as markdown? What do you suggest for this problem?

ansible_mail.png


Thank you very much!

Brian Coca

unread,
Sep 13, 2022, 10:24:17 AM9/13/22
to ansible...@googlegroups.com
You can do this with a custom callback plugin or look for already existing solutions like ara https://ara.recordsansible.org/

--
----------
Brian Coca

Hearn, Stan J.

unread,
Sep 13, 2022, 10:49:11 AM9/13/22
to ansible...@googlegroups.com

You didn't mention awx or Ansible Automation, so I assume you are using command line.

 

ansible-playbook someplay.yml | sed -n '/PLAY RECAP /,$p' | egrep 'failed=[1-9]'

 

sed  - only print the lines from "PLAY RECAP " top the end.

egrep - only print lines that contain "failed=" with a non zero first digit.

 

And then I would add '~~~' at the beginning and the end.

 

Is that the mark down you are looking for?

 

Regards,

Stan



Thank you very much!

--
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/17d9e52a-35a6-4520-8d9e-e78d33ecd7fan%40googlegroups.com.

Evan Hisey

unread,
Sep 13, 2022, 10:57:55 AM9/13/22
to ansible...@googlegroups.com
Leandro-
 The best solution is let Ansible do the hard work instead oi trying to parse the out put for failures, setup an error trap for failures that captures them in a report. Then email this repot to someone or drop the report in an bucket or Jenkins process to be acted on.  Add bonus of doing that based on the output you sent is that you can keep running tasks checking for other services on the same server instead of that server halting on the failure.

The next iteration of that play would then be to have the failures create secondary playbooks or inventories and trigger a remediation task against them.

Leandro Montesoro

unread,
Sep 15, 2022, 10:24:33 AM9/15/22
to ansible...@googlegroups.com
Hi! 

Thanks for the replies, I'll try your suggestions and let you know!

Regards,
Lean


montesoro leandro
devops
TEL: +54 9 11 4786-5787
WEB: www.keepcon.com



Reply all
Reply to author
Forward
0 new messages