Refactor extract-fw-host-vars.py to improve quoted value handling and add fw_manage_config to generated YAML; create ipt-server.yml for a.mx.oopen.de with initial configuration

This commit is contained in:
2026-06-29 08:13:40 +02:00
parent b9e5b0f5e2
commit 682a08b53e
3 changed files with 64 additions and 13 deletions
+13 -12
View File
@@ -363,26 +363,24 @@ def parse_bash_config(text):
varname = m.group(1)
rest = m.group(2).strip()
# Quoted value
if rest.startswith('"'):
# Collect until closing quote (may span multiple lines)
collected = rest[1:] # strip opening "
# Quoted value (single or double quotes, may span multiple lines)
if rest and rest[0] in ('"', "'"):
quote_char = rest[0]
collected = rest[1:] # strip opening quote
parts = []
closed = False
extra_lines = []
while True:
# Check if closing " is in collected
close_pos = collected.find('"')
close_pos = collected.find(quote_char)
if close_pos != -1:
value = collected[:close_pos].strip()
if extra_lines:
warnings.append(f" # {varname}: multiline value — verify manually")
parts.append(collected[:close_pos])
# join all parts; split() collapses whitespace and drops empty lines
value = ' '.join(' '.join(parts).split())
result[varname] = value
closed = True
break
else:
# Value continues on next line
extra_lines.append(collected.strip())
parts.append(collected)
i += 1
if i >= len(lines):
break
@@ -546,6 +544,9 @@ def render_yaml(hostname, host_vars, all_warnings):
"",
]
lines.append("fw_manage_config: false")
lines.append("")
if all_warnings:
lines.append("# WARNINGS — manual review needed:")
for w in all_warnings: