-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomprehensive-app-config.tmpl
More file actions
202 lines (179 loc) · 6.77 KB
/
Copy pathcomprehensive-app-config.tmpl
File metadata and controls
202 lines (179 loc) · 6.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# Application Configuration
# Generated: {{ now() }}
# Instance ID: {{ uuid() }}
{# ============================================
Service Configuration
============================================ #}
service:
name: {{ get_env(name="APP_NAME", default="myapp") | upper }}
version: {{ get_env(name="APP_VERSION", default="1.0.0") }}
environment: {{ get_env(name="ENV", default="development") | upper }}
# Unique identifiers
instance_id: {{ uuid() }}
deployment_id: {{ uuid() }}
{# ============================================
Security & Authentication
============================================ #}
security:
# Hash functions for integrity checks
config_checksum: {{ md5(string="v1.0-config") }}
license_hash: {{ sha256(string=get_env(name="LICENSE_KEY", default="trial-license")) }}
# Generated secrets
api_key: {{ random_string(length=32, charset="hex") }}
secret_token: {{ random_string(length=64) }}
csrf_token: {{ random_string(length=40, charset="hex") }}
session_secret: {{ random_string(length=32, charset="alphanumeric") }}
# Password hashing (example - use proper password hashing in production!)
{% set admin_pwd = get_env(name="ADMIN_PASSWORD", default="changeme123") %}
admin_password_hash: {{ sha512(string=admin_pwd) }}
{# ============================================
Database Configuration
============================================ #}
database:
# Filter all DB_* environment variables
{% set db_vars = filter_env(pattern="DB_*") %}
{% if db_vars | length > 0 %}
# From environment:
{% for var in db_vars %}
{{ var.key | lower | replace(from="db_", to="") }}: {{ var.value }}
{% endfor %}
{% else %}
# Default configuration:
host: {{ get_env(name="DB_HOST", default="localhost") }}
port: {{ get_env(name="DB_PORT", default="5432") }}
name: {{ get_env(name="DB_NAME", default="myapp_db") }}
user: {{ get_env(name="DB_USER", default="app_user") }}
{% endif %}
# Connection pool
max_connections: {{ get_env(name="DB_MAX_CONNECTIONS", default="20") }}
connection_id: {{ uuid() }}
{# ============================================
Server Configuration
============================================ #}
server:
{% set servers = filter_env(pattern="SERVER_*") %}
{% if servers | length > 0 %}
# Detected server configuration:
{% for srv in servers %}
{{ srv.key | lower | replace(from="server_", to="") }}: {{ srv.value }}
{% endfor %}
{% else %}
# Default server configuration:
host: {{ get_env(name="HOST", default="0.0.0.0") }}
port: {{ get_env(name="PORT", default="8080") }}
protocol: {{ get_env(name="PROTOCOL", default="http") }}
{% endif %}
# TLS/SSL
{% set enable_tls = get_env(name="ENABLE_TLS", default="false") %}
{% if enable_tls == "true" %}
tls:
enabled: true
cert_path: {{ get_env(name="TLS_CERT_PATH", default="/etc/ssl/cert.pem") }}
key_path: {{ get_env(name="TLS_KEY_PATH", default="/etc/ssl/key.pem") }}
{% else %}
tls:
enabled: false
{% endif %}
{# ============================================
Logging Configuration
============================================ #}
logging:
{% set env_type = get_env(name="ENV", default="development") %}
{% if env_type == "production" %}
level: ERROR
format: json
output: /var/log/app/production.log
{% elif env_type == "staging" %}
level: WARN
format: json
output: /var/log/app/staging.log
{% else %}
level: DEBUG
format: text
output: stdout
{% endif %}
# Log rotation ID
rotation_id: {{ uuid() }}
{# ============================================
Feature Flags
============================================ #}
features:
{% set features = get_env(name="FEATURES", default="api,web,admin") | split(pat=",") %}
enabled: [{% for feature in features %}"{{ feature | trim }}"{% if not loop.last %}, {% endif %}{% endfor %}]
count: {{ features | length }}
# Feature-specific settings
{% for feature in features %}
{{ feature | trim | slugify }}:
enabled: true
token: {{ random_string(length=16, charset="hex") }}
{% endfor %}
{# ============================================
External Services
============================================ #}
external_services:
# All API_* environment variables
{% set api_vars = filter_env(pattern="API_*") %}
{% if api_vars | length > 0 %}
apis:
{% for api in api_vars %}
{{ api.key | lower | replace(from="api_", to="") }}:
url: {{ api.value }}
key: {{ random_string(length=32, charset="hex") }}
checksum: {{ md5(string=api.value) }}
{% endfor %}
{% else %}
apis: []
{% endif %}
{# ============================================
Cache Configuration
============================================ #}
cache:
{% set cache_type = get_env(name="CACHE_TYPE", default="memory") %}
type: {{ cache_type }}
ttl: {{ get_env(name="CACHE_TTL", default="3600") }}
{% if cache_type == "redis" %}
redis:
host: {{ get_env(name="REDIS_HOST", default="localhost") }}
port: {{ get_env(name="REDIS_PORT", default="6379") }}
db: {{ get_env(name="REDIS_DB", default="0") }}
password_hash: {{ sha256(string=get_env(name="REDIS_PASSWORD", default="")) }}
{% endif %}
{# ============================================
Monitoring & Metrics
============================================ #}
monitoring:
enabled: {{ get_env(name="ENABLE_MONITORING", default="true") }}
endpoint: {{ get_env(name="METRICS_ENDPOINT", default="/metrics") }}
# Unique tracking IDs
cluster_id: {{ uuid() }}
node_id: {{ uuid() }}
# Sample intervals (in seconds)
{% set intervals = get_env(name="SAMPLE_INTERVALS", default="10,30,60") | split(pat=",") %}
sample_intervals: [{% for interval in intervals %}{{ interval }}{% if not loop.last %}, {% endif %}{% endfor %}]
{# ============================================
Recovery & Backup
============================================ #}
recovery:
# Recovery codes (for 2FA backup)
codes:
{% for i in range(end=5) %}
- {{ random_string(length=8, charset="uppercase") }}-{{ random_string(length=8, charset="uppercase") }}
{% endfor %}
# Backup encryption key
backup_key: {{ random_string(length=64, charset="hex") }}
backup_key_hash: {{ sha256(string=get_env(name="BACKUP_PASSPHRASE", default="default-passphrase")) }}
{# ============================================
Metadata
============================================ #}
metadata:
generated_at: {{ now() }}
generated_by: tmpltool
template_version: "2.0"
config_hash: {{ sha1(string="comprehensive-config-v2.0") }}
# All environment variables used
environment_variables:
{% set all_env = filter_env(pattern="*") %}
total_count: {{ all_env | length }}
app_vars: {{ filter_env(pattern="APP_*") | length }}
db_vars: {{ filter_env(pattern="DB_*") | length }}
server_vars: {{ filter_env(pattern="SERVER_*") | length }}