#!/usr/bin/env python3
from ruamel.yaml import YAML

yaml = YAML()
yaml.preserve_quotes = True

with open("/tmp/kube-flannel.yml", "r") as f:
    docs = list(yaml.load_all(f))

for doc in docs:
    if doc.get("kind") == "ConfigMap" and doc.get("metadata", {}).get("name") == "kube-flannel-cfg":
        doc["data"]["net-conf.json"] = '''{
  "Network": "10.240.0.0/16",
  "Backend": {
    "Type": "vxlan"
  },
  "Interface": "eth0"
}'''

with open("/tmp/kube-flannel.yml", "w") as f:
    yaml.dump_all(docs, f)