In any environment where multiple engineers manage vCenter, configuration drift is inevitable. An administrator temporarily disables an NTP server on a host during maintenance, changes a Syslog target, or modifies a vSwitch MTU, and forgets to revert it.
When a host fails months later and vSphere HA attempts to restart VMs on an out-of-sync node, unexpected network partitions or storage timeouts occur. Here is how to build an automated, daily drift detection pipeline.
1. Writing the PowerCLI Cluster Audit Script
Rather than manual UI inspections, we query all hosts in a target cluster and compare their settings against an expected gold standard:
2. Enforcing Declarative State with Terraform
The ultimate prevention against configuration drift is managing vSphere clusters as code through the official HashiCorp VMware vSphere Provider.
terraform plan in a daily GitHub Action or GitLab CI pipeline immediately surfaces any
manual out-of-band changes introduced by administrators in the GUI.
3. Automated CI/CD Drift Alerting in Production
By integrating terraform plan -detailed-exitcode into a scheduled GitHub Action or GitLab CI
pipeline, infrastructure teams receive immediate Slack or email notifications whenever an exit code of
2 (drift detected) occurs. This prevents silent divergence before critical maintenance windows.