summaryrefslogtreecommitdiff
path: root/roles/installer/ubuntu/autoinstall/files/early-command.py
blob: 0be450c96641089f093c5e7476bad904643e9686 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env python3

import os
from shutil import copyfile
import yaml

os.umask(0o077)
copyfile('/autoinstall.yaml', '/autoinstall.yaml_before-early-command')

config = {}
with open('/autoinstall.yaml', 'r') as file:
    config = yaml.safe_load(file)

try:
    for c in config['storage']['config']:
        if 'type' not in c or c['type'] != 'disk' or 'path' not in c:
            continue
        c['path'] = os.path.realpath(c['path'])
except KeyError:
    pass

with open('/autoinstall.yaml', 'w') as file:
    yaml.dump(config, file, default_flow_style=False)