Ansible: Simple Reports

Any IT system, bigger than a chihuahua, ought to produce reports. It does not matter how they look, but it should generate and share information that humans can read. Automation projects are not immune to this, and I don't mean reports on automation tools but rather on the target state.

Ansible is a great candidate for generating reports, starting with the integrated Jinja 2 engine, native Python syntax and ubiquitous template support are keys for producing dynamic content. We need to find a modern way for the report presentation, and Ansible can offer you more than one option. Naturally, every environment is different, and you may have requirements, limitations, or some excellent reporting tool, that you use for such tasks. Let's talk about something you can do on your  

HTML-formatted emails

Ansible Core has a mail task that allows you to create plain-text or HTML-formatted e-mails and supports attachments. I use them for messaging or as a part of human tasks. You can find a code sample and walkthrough in my post  "Ansible: Format e-mail Body." My biggest concern with e-mails - they tend to get lost. Your report should survive through the e-mail server security policies, spam filters, inbox cleanups, and endless FWD: chains. Plus, somebody should print it or store it somewhere else.

To summarize: e-mails are suitable for sharing current information, not great for publications and records management.

Markdown reports

Markdown reports are hard to miss when you consider your report format.  It is text-based, and the report source is still human-readable, even if you don't know Markdown language. Still, it is a text, not a well-formatted document you can share with your stakeholders.  The good news here - Markdown is everywhere; most of the modern CMS or SCM supports Markdown natively. It means that if you use one of the modern code management platforms, you already have the publication platform.

Ansible Markdown Reports on Git/GitLab

With GitHub or GitLab as a publication platform, you would benefit from

  • Most likely, you already have Git or GitLab configured with your controller.
  • It will produce good-looking pages from your Markdown reports.
  • Structured content with navigation and URLs.
  • Track history of all report changes.    
  • No separate integration and publication tools are required.

The separate post describes base implementation details.