`ccm` registration for dynamic infra taking shape....
# choria
r
ccm
registration for dynamic infra taking shape.... We start a service with registration:
Copy code
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:
Copy code
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.
Copy code
backend web_servers
  balance roundrobin
[[ range entry := registrations("production", "http", "web", "*") ]]
  server [[ entry.IP ]] [[ entry.IP ]]:[[ entry.Port ]] check weight [[ 256 - entry.Priority ]]
[[ end ]]