Files
computer-playbook/plugins/filter/ruby.py
T
kevinveenbirkenbachandClaude Opus 4.8 0bf1e8ef8c refactor(gitlab): replace Omnibus with the Cloud Native GitLab composition
Deploy GitLab from the official CNG CE images as six services: webservice (puma) and sidekiq scale to the topology default, workhorse is the sole HTTP entry, gitaly and a one-shot migrations job are pinned singletons, shell runs gitlab-sshd. The Omnibus container, its Dockerfile and the GITLAB_OMNIBUS_* config groups are removed. All rails/workhorse/shell/gitaly configs and shared secrets are pre-rendered by Ansible and mounted read-only; eleven credentials land in meta/schema.yml including an rsa_pem_2048 OIDC signing key (new value_generator algorithm). Postgres, redis and S3 object storage ride the existing lookups; OIDC, SMTP, the public SSH port and the root password are preserved. compose_volumes gains a per-volume nfs:false opt-out so the gitaly repositories volume stays node-local in swarm (upstream forbids git repositories on NFS); nfs_prep skips volumes without driver_opts accordingly. The Nextcloud gitlab integration execs the CNG rails runner. ruby_single_line dies with its only consumer; ruby_dq keeps test coverage. Ports (8181/8080/2222/8075/3808/9122) and service names resolve from single SPOT declarations in meta/services.yml via vars constants; the version pin sits on the webservice image pair so the updater can bump it. Live-validated in compose up to all six services healthy and migrations completed; fresh-install-only semantics for existing Omnibus data are documented.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 02:37:27 +02:00

50 lines
1.0 KiB
Python

#
# Ansible filter for safely embedding values into Ruby double-quoted strings.
#
# Example:
# {{ my_password | ruby_dq }}
#
# Output:
# "escaped_value"
#
# Safe for Ruby DSLs (rails initializers, Chef).
class FilterModule:
def filters(self):
return {
"ruby_dq": self.ruby_double_quoted_string,
}
@staticmethod
def ruby_double_quoted_string(value):
"""
Escape a value for use inside a Ruby double-quoted string
and wrap it in double quotes.
Ruby rules handled:
- " -> \"
- \\ -> \\\\
- newlines -> \n
- carriage return -> \r
- tab -> \t
NOT escaped on purpose:
- $
- €
- !
- '
"""
if value is None:
return '""'
s = str(value)
s = s.replace("\\", "\\\\")
s = s.replace('"', '\\"')
s = s.replace("\n", "\\n")
s = s.replace("\r", "\\r")
s = s.replace("\t", "\\t")
return f'"{s}"'