The previous post promised a simple reporting solution and two potential possibilities. Now it's time to go through the solution that would help you with report publications.
The diagram from the previous post depicts information flow between components.
- The Ansible Controller pulls project code and reports templates from the code repository. Separate repositories give you better access control to the code repository.
- The controller runs playbook(-s) against targets to collect target-specific details.
- The local part of the playbook uses collected reports and updates the local Wiki-repository clone.
- The last step - commit the new changes and publish changes to the server.
I have created one sample report and published it on GitHub. There are a few things that required your attention before (and if) running this example:
- Sample code refers to the sample Wiki repository - ansible-wiki-demo. Feel free to fork it or use your own. In any case, do not forget to update the repository URL in the code.
- The published code was created for Oracle Cloud Infrastructure instances. It was tested on a single compute instance with core Ansible installation. If you are going to use it on-premises or run against other cloud providers, you may need to populate variable inst_meta with your own data or adjust the instance template code to report some different target facts.
- Core Ansible git task can clone a repository but can't update or publish changes. There are a few collections and roles to address it, for example, git_acp. But I intentionally used shell task to run native command, because you may not have enough privileges to install additional Python and system libraries.
Sample code produces a Wiki home page with a reference to all your inventory targets and a separate report page per target. The final home page should look like the one on the screenshot below.