import yaml import os ainst = {} with open('/autoinstall.yaml', 'r') as allin: ainst = yaml.safe_load(allin) ainst['storage']['layout']['password'] = os.environ['lukspass'] with open('/autoinstall.yaml', 'w') as allout: yaml.safe_dump(ainst, allout)