Role ipt-server: allow IPv6-only overrides of shared variables; migrate nd, oolm-shop, web-01, web0.
Shared variables (and fw_ext_interfaces / fw_local_interfaces) can now be overridden for IPv6 via <name>_v6. extract-fw-host-vars.py emits these overrides when the IPv4 and IPv6 configs differ, instead of a warning. Add host_vars for nd.warenform.de, oolm-shop.oopen.de, web-01.oopen.de and web0.warenform.de (fw_manage_config: true). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+28
-7
@@ -543,21 +543,33 @@ def build_host_vars(parsed_iface_v4, parsed_iface_v6, parsed_main_v4, parsed_mai
|
||||
if v and v != DEFAULTS.get(ansible_var, ""):
|
||||
result[ansible_var] = v
|
||||
|
||||
# IPv6 interface lists that differ from IPv4 -> fw_*_interfaces_v6 override
|
||||
for prefix, ansible_var, v4_list in [("ext_if_", "fw_ext_interfaces", fw_ext_interfaces),
|
||||
("local_if_", "fw_local_interfaces", fw_local_interfaces)]:
|
||||
v6_list = extract_list(parsed_iface_v6, prefix)
|
||||
if v6_list != v4_list:
|
||||
result[f"{ansible_var}_v6"] = v6_list
|
||||
|
||||
# --- Shared main variables (read from ipv4, fall back to ipv6) ---
|
||||
# If IPv4 and IPv6 differ, the IPv6 value goes into <ansible_var>_v6.
|
||||
def to_value(raw):
|
||||
raw = normalize_value(raw)
|
||||
return coerce_bool(raw) if raw.lower() in ("true", "false") else raw
|
||||
|
||||
for bash_var, ansible_var in MAIN_SHARED.items():
|
||||
raw_v4 = parsed_main_v4.get(bash_var)
|
||||
raw_v6 = parsed_main_v6.get(bash_var)
|
||||
if raw_v4 is not None and raw_v6 is not None \
|
||||
and normalize_value(raw_v4) != normalize_value(raw_v6):
|
||||
warnings.append(f" # {ansible_var}: IPv4 '{raw_v4}' != IPv6 '{raw_v6}' — IPv4 value used")
|
||||
raw = raw_v4 if raw_v4 is not None else raw_v6
|
||||
if raw is None:
|
||||
continue
|
||||
raw = normalize_value(raw)
|
||||
v = coerce_bool(raw) if raw.lower() in ("true", "false") else raw
|
||||
v = to_value(raw)
|
||||
default = DEFAULTS.get(ansible_var)
|
||||
if v != default:
|
||||
result[ansible_var] = v
|
||||
if raw_v4 is not None and raw_v6 is not None:
|
||||
v6 = to_value(raw_v6)
|
||||
if v6 != v:
|
||||
result[f"{ansible_var}_v6"] = v6
|
||||
|
||||
# --- IPv4-only main variables ---
|
||||
for bash_var, ansible_var in MAIN_V4_ONLY.items():
|
||||
@@ -681,13 +693,20 @@ def render_yaml(hostname, host_vars, all_warnings):
|
||||
("Special", ["fw_create_traffic_counter", "fw_create_iperf_rules"]),
|
||||
]
|
||||
|
||||
# IPv6-only overrides of shared variables follow their base variable
|
||||
sections = [(name, [x for k in keys for x in (k, f"{k}_v6")
|
||||
if x == k or x not in keys])
|
||||
for name, keys in sections]
|
||||
|
||||
emitted = set()
|
||||
for section_name, keys in sections:
|
||||
section_lines = []
|
||||
for k in keys:
|
||||
if k in host_vars:
|
||||
v = host_vars[k]
|
||||
if isinstance(v, list):
|
||||
if isinstance(v, list) and not v:
|
||||
section_lines.append(f"{k}: []")
|
||||
elif isinstance(v, list):
|
||||
section_lines.append(f"{k}:")
|
||||
for item in v:
|
||||
section_lines.append(f" - \"{item}\"")
|
||||
@@ -707,7 +726,9 @@ def render_yaml(hostname, host_vars, all_warnings):
|
||||
if remaining:
|
||||
lines.append("# --- Other")
|
||||
for k, v in remaining.items():
|
||||
if isinstance(v, list):
|
||||
if isinstance(v, list) and not v:
|
||||
lines.append(f"{k}: []")
|
||||
elif isinstance(v, list):
|
||||
lines.append(f"{k}:")
|
||||
for item in v:
|
||||
lines.append(f" - \"{item}\"")
|
||||
|
||||
Reference in New Issue
Block a user