Read-only drift detection for Consul ACL policies and tokens against a YAML configuration. This is the verify side of consul-acl-sync: consul-acl-sync writes, consul-acl-diff only reads and reports.
$ consul-acl-diff -config config.yamlThe config is the same file consul-acl-sync applies.
See example.yaml for the schema.
The Consul address defaults to http://127.0.0.1:8500. Point it elsewhere with
-consul-addr:
$ consul-acl-diff -config config.yaml -consul-addr http://consul.example.com:8500Drift is reported in three categories per resource:
modified: exists on both sides but differs (policy rules, description, or datacenters, or token description or policy set)only in local: declared in config but absent from Consul, so consul-acl-sync would create itonly in consul: present in Consul but not declared, so it was created out of band
Matching consul-kv-diff, so the tool works as a CI gate:
0: config matches Consul1: drift found2: an error occurred
All three categories, including only in consul, count as drift.
- Policies are keyed by
name. - Tokens are keyed by
accessor_id.secret_idis never compared. A token secret is immutable after creation and this tool never reads or transmits it. - Rules are compared after whitespace normalization, matching consul-acl-sync, so cosmetic differences are not reported as drift.
Consul creates a few resources itself: the global-management and
builtin/global-read-only policies, and the anonymous token. These are excluded
from only in consul, the same way Consul KV has no system keys for
consul-kv-diff to trip over.
Operator-created tokens are not filtered. A token that nobody declared in the
config, including the bootstrap management token, surfaces as only in consul
drift. Bring it under management by pinning its accessor_id and secret_id in
the config, or accept the drift signal.
The token is read from the CONSUL_HTTP_TOKEN environment variable, following
the consul CLI convention, rather than a flag so it does not leak into process
listings or shell history. It needs acl:read on a cluster that enforces ACLs.
This project is licensed under the MIT License.