Skip to content

Instantly share code, notes, and snippets.

@fmount
Last active May 14, 2026 15:37
Show Gist options
  • Select an option

  • Save fmount/8ef2bebaaa47965860bef7776045decd to your computer and use it in GitHub Desktop.

Select an option

Save fmount/8ef2bebaaa47965860bef7776045decd to your computer and use it in GitHub Desktop.

Common Templates Deduplication: ssl.conf

Problem

The ssl.conf Apache mod_ssl configuration template is duplicated across service operators. Every operator ships the exact same file. A TLS policy change (cipher suite, protocol version) requires coordinated patches across all repositories.

Approach

Use Go's //go:embed to ship common templates inside lib-common itself. A new exported function util.GetCommonTemplates() renders the embedded templates and returns map[filename]renderedContent. Service operators call it before EnsureSecrets, merging the result into their existing CustomData map. Operator-specific entries take precedence — if an operator already defines a file with the same name, the common version is skipped.

This requires:

  • No changes to the Template struct
  • No changes to EnsureSecrets / GetTemplateData pipeline
  • No changes to the Dockerfile or container build
  • No new abstractions (no MergeFS, no overlay filesystem)

Each operator adds ~8 lines of Go code and deletes its local ssl.conf.

Patches

lib-common (templates branch)

File Description
modules/common/util/templates/common/config/ssl.conf The common ssl.conf, embedded via //go:embed
modules/common/util/template_util.go Added //go:embed directive, commonTemplates var, and GetCommonTemplates() function — reads embedded FS, renders with Go templates, returns map[string]string
modules/common/util/template_util_test.go Added TestGetCommonTemplates verifying ssl.conf is returned and contains expected directives

Consumer-side usage (e.g. in generateServiceConfigs):

commonTemplates, err := util.GetCommonTemplates(templateParameters)
if err != nil {
    return err
}
for k, v := range commonTemplates {
    if _, exists := customData[k]; !exists {
        customData[k] = v
    }
}

cinder-operator

File Change
internal/controller/cinder_controller.go +10 lines: calls util.GetCommonTemplates(templateParameters) and merges into customData
templates/cinder/config/ssl.conf Deleted (now provided by lib-common)

ssl.conf Compatibility Across Operators

All 19 copies are byte-for-byte identical to the lib-common version.

Operator Template path(s) Identical Drop-in
barbican barbican/config/ YES YES
cinder cinder/config/ YES Done
designate designateapi/config/ YES YES
glance common/config/ + glanceapi/config/ YES (x2) YES
heat heat/config/ YES YES
horizon horizon/config/ YES YES
ironic ironicapi/config/ + ironicinspector/config/ YES (x2) YES
keystone keystoneapi/config/ YES YES
manila manila/config/ YES YES
nova nova/api/config/ + nova/metadata/config/ YES (x2) YES
octavia octaviaapi/config/ YES YES
placement placementapi/config/ YES YES
swift swiftproxy/config/ YES YES
telemetry autoscaling/config/ + ceilometercentral/config/ + cloudkitty/config/ YES (x3) YES
watcher watcherapi/config/ YES YES

httpd.conf Compatibility Across Operators (future work)

httpd.conf varies significantly across operators. Only a subset can use a common template; the rest embed VirtualHost blocks or have substantially different structures.

Operator httpd.conf compatible Reason if not
cinder YES
manila YES
telemetry (aodh) YES
telemetry (cloudkitty) YES
glance (x2) PARTIAL Conditional include ({{ if .Wsgi }} wsgi vs proxypass)
designate NO Inline VirtualHost with WSGI
keystone NO Inline VirtualHost with WSGI, DocumentRoot, custom includes
nova (api + metadata) NO Inline VirtualHost with WSGI, Alias blocks
placement NO Inline VirtualHost with WSGI, Alias blocks
octavia (api) NO Inline VirtualHost with WSGI, Alias blocks
octavia (core) NO Full default Apache config (~200 lines)
baremetal NO Full default Apache config (~200 lines)
swift NO Inline VirtualHost with ProxyPass
ironic NO Inline VirtualHost with ProxyPass
horizon NO Inline VirtualHost with WSGI, custom log vars
telemetry (ceilometer) NO Inline VirtualHost with ProxyPass
barbican NO Extra directives (KeepAlive, Timeout), logs to files
watcher NO Extra directives (KeepAlive, Timeout), different log format
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment