New to Kestra?
Use blueprints to kickstart your first workflows.
Detect infrastructure configuration drift with Ansible and Kestra. Run a playbook across hosts on a schedule and send Slack alerts only when settings change.
Detect and alert on infrastructure configuration drift with Ansible and Kestra. This blueprint runs an idempotent Ansible playbook across a fleet of hosts, inspects the per-host results, and notifies Slack only when a host actually changed, so your team hears about real drift instead of a green run every night. It turns Ansible's natural idempotency into a continuous compliance signal: if a managed setting was edited out of band, the playbook corrects it and you get told; if nothing changed, you stay quiet.
set_up_env is an io.kestra.plugin.ansible.cli.AnsibleCLI task that ships an inline inventory.ini (three example servers) and an inline myplaybook.yml as inputFiles. The playbook uses lineinfile to enforce MY_APP_MODE=production in each host's .bashrc and notifies a handler to refresh the environment.io.kestra.plugin.core.runner.Process with an inline ansibleConfig that sets the Python interpreter, writes a log to {{ workingDir }}/ansible.log, and uses the yaml stdout callback so results parse cleanly. The command is ansible-playbook -i inventory.ini myplaybook.yml.loop_hosts is an io.kestra.plugin.core.flow.ForEach over {{ outputs.set_up_env.vars.outputs }}, iterating the per-host Ansible results.check_drift is an io.kestra.plugin.slack.notifications.SlackIncomingWebhook guarded by runIf: "{{ (taskrun.value | jq('.changed') | first) == true }}", so a message is posted only for hosts where Ansible reported a change. The message includes the Ansible msg for context.check_nightly io.kestra.plugin.core.trigger.Schedule trigger (cron: 0 3 * * *, shipped disabled: true) runs the drift check every night once enabled.Ansible has no built-in scheduler, no durable run history, and no native conditional alerting per host. Kestra adds event and schedule triggers, automatic retries, full execution lineage and logs, and declarative YAML you keep in Git. The runIf expression and ForEach loop let you branch on Ansible's own output and notify selectively, which an ansible-playbook cron job on a box cannot do without bespoke scripting.
SLACK_WEBHOOK: the Slack Incoming Webhook URL used by check_drift.SLACK_WEBHOOK secret in Kestra.inventory.ini hosts and SSH details with your real targets.myplaybook.yml to enforce the settings you care about.check_nightly trigger to run the check on a schedule.inputFiles.check_mode to report drift without correcting it, or aggregate results into a compliance report.