With ansible-pull it’s possible to scale Ansible to near-limitless deployments by inverting Ansible’s default push architecture into a pull-based architecture. This is done by having a remote copy of Ansible on each managed node, each configured to run via a cronjob and update the playbooks source from a source control repository.
Due to ansible-pull being run headless it’s important to configure logging as well as monitoring for the playbook execution. As they’re crucial for investigating playbook failures, detecting changes and configuration drift as well as audibility.
Even though, Ansible doesn’t provide any direct integration for Prometheus, it’s possible to report playbook execution statistics using a custom callback_plugin. The plugin is used for writing metrics to a local file that’s being read and exposed by the node exporters textfile collector.
I’ve previously written such a plugin which can simply be copied into the callback_plugins
directory. It’s inspired by
the JUnit callback plugin and makes use of the Prometheus client_python
library. The plugin is currently provided through this GitHub
Gist.