Skip to content

CICD-259 · Configuration drift detection ​

Encyclopedia · Ansible and configuration management · All snippets

Previous · CICD-258 · Next · CICD-260

1. Where it fits ​

  • Placement CI run step.
  • Prerequisites controller with reviewed inventory, pinned Ansible collections and a non-production target.
  • Platforms local-linux, github-actions, gitea-actions.

2. Copy the snippet ​

bash
ansible-playbook -i inventory/staging.yml --check playbooks/site.yml | tee drift.txt
grep -Eq 'changed=[1-9][0-9]*' drift.txt && exit 2
grep -q 'PLAY RECAP' drift.txt

3. How it works ​

The selected inventory and limit determine the hosts a playbook can affect. Syntax check and check mode give different forms of preflight evidence.

4. Verify the result ​

Run with pipefail to retain Ansible errors. Inspect changed counts as proposed configuration drift.

Validation syntax-validated (Bash parse). Status definitions.