Paste P7842

ats-origin-no-tls.py
ActivePublic

Authored by ema on Mon, Nov 26, 3:20 PM.
#!/usr/bin/env python3
# Depends on: python3-yaml
import yaml
stream = file("./hieradata/role/common/trafficserver/backend.yaml", "r")
rules = yaml.load(stream)["profile::trafficserver::backend::mapping_rules"]
origins = set()
for rule in rules:
if "http:" in rule["replacement"]:
origins.add(rule["replacement"])
for origin in sorted(origins):
sites = [rule["target"] for rule in rules if rule["replacement"] == origin]
print(
"[] {} - {}".format(
origin.replace("http://", ""),
" ".join(sites),
)
)