R.I.Pienaar
03/16/2026, 10:02 PMccm registration for dynamic infra taking shape....
We start a service with registration:
ccm:
resources:
- service:
my-app:
ensure: running
enable: true
health_checks:
- check: exec
command: curl -sf http://localhost:8080/health
register_when_stable:
- cluster: production
service: web
protocol: http
address: "{{ Facts.network.primaryIP }}"
port: "{{ Data.web_port }}"
priority: 10
ttl: 10m
Then we create a haproxy frontend that must dynamically add backends:
ccm:
resources:
- file:
/etc/haproxy/backends.cfg:
ensure: present
content: |
{{ template("backends.cfg.jet") }}
- exec:
reload-haproxy:
command: systemctl reload haproxy
refresh_only: true
subscribe:
- "file#/etc/haproxy/backends.cfg"
It uses this template to query registration and build the backends.
backend web_servers
balance roundrobin
[[ range entry := registrations("production", "http", "web", "*") ]]
server [[ entry.IP ]] [[ entry.IP ]]:[[ entry.Port ]] check weight [[ 256 - entry.Priority ]]
[[ end ]]