diff options
author | Ryan Harper <ryan.harper@canonical.com> | 2020-07-10 08:08:44 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-10 09:08:44 -0400 |
commit | 3d06abc2e0017436dadbf9c26fefa9f95368db9a (patch) | |
tree | c4aded5d47ee8c1162bcc5b4487edaaa3ac533db /cloudinit/config | |
parent | e753141fc7844e68b1f380d26fb3d250eb464ff7 (diff) | |
download | vyos-cloud-init-3d06abc2e0017436dadbf9c26fefa9f95368db9a.tar.gz vyos-cloud-init-3d06abc2e0017436dadbf9c26fefa9f95368db9a.zip |
cc_mounts: handle missing fstab (#484)
Do not fail if /etc/fstab is not present. Some images, like container
rootfs may not include this file by default.
LP: #1886531
Diffstat (limited to 'cloudinit/config')
-rw-r--r-- | cloudinit/config/cc_mounts.py | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/cloudinit/config/cc_mounts.py b/cloudinit/config/cc_mounts.py index e57d1b1f..773b8285 100644 --- a/cloudinit/config/cc_mounts.py +++ b/cloudinit/config/cc_mounts.py @@ -379,17 +379,18 @@ def handle(_name, cfg, cloud, log, _args): fstab_devs = {} fstab_removed = [] - for line in util.load_file(FSTAB_PATH).splitlines(): - if MNT_COMMENT in line: - fstab_removed.append(line) - continue + if os.path.exists(FSTAB_PATH): + for line in util.load_file(FSTAB_PATH).splitlines(): + if MNT_COMMENT in line: + fstab_removed.append(line) + continue - try: - toks = WS.split(line) - except Exception: - pass - fstab_devs[toks[0]] = line - fstab_lines.append(line) + try: + toks = WS.split(line) + except Exception: + pass + fstab_devs[toks[0]] = line + fstab_lines.append(line) for i in range(len(cfgmnt)): # skip something that wasn't a list |