summaryrefslogtreecommitdiff
path: root/v-i
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2022-01-06 20:08:28 +0200
committerLars Wirzenius <liw@liw.fi>2022-01-06 20:08:28 +0200
commit602680ab9db41e60ffadacae5c9f190c6d105d86 (patch)
treec0346af742973940684d17daf31a843df352a3cb /v-i
parent5503ec94aac5f0af66d6627202e442220b26f632 (diff)
downloadv-i-602680ab9db41e60ffadacae5c9f190c6d105d86.tar.gz
make v-i use luks only if specified
Sponsored-by: author
Diffstat (limited to 'v-i')
-rwxr-xr-xv-i57
1 files changed, 43 insertions, 14 deletions
diff --git a/v-i b/v-i
index e585de1..bf1903e 100755
--- a/v-i
+++ b/v-i
@@ -129,13 +129,43 @@ def vmdb_spec(cryptsetup_password, playbook):
"end": "1G",
"tag": "boot",
},
- {
- "mkpart": "primary",
- "device": device,
- "start": "1G",
- "end": "100%",
- "tag": "cryptsetup0",
- },
+ ]
+ }
+
+ # Set up pv0 for lvm2, either encrypted or cleartext.
+ if cryptsetup_password:
+ spec["steps"].extend(
+ [
+ {
+ "mkpart": "primary",
+ "device": device,
+ "start": "1G",
+ "end": "100%",
+ "tag": "cryptsetup0",
+ },
+ {
+ "cryptsetup": "cryptsetup0",
+ "password": cryptsetup_password,
+ "name": "pv0",
+ },
+ ]
+ )
+ else:
+ spec["steps"].extend(
+ [
+ {
+ "mkpart": "primary",
+ "device": device,
+ "start": "1G",
+ "end": "100%",
+ "tag": "pv0",
+ },
+ ]
+ )
+
+ # Create file systems and install Debian.
+ spec["steps"].extend(
+ [
{
"mkfs": "vfat",
"partition": "efi",
@@ -145,11 +175,6 @@ def vmdb_spec(cryptsetup_password, playbook):
"partition": "boot",
},
{
- "cryptsetup": "cryptsetup0",
- "password": cryptsetup_password,
- "name": "pv0",
- },
- {
"vgcreate": "vg0",
"physical": ["pv0"],
},
@@ -220,9 +245,12 @@ def vmdb_spec(cryptsetup_password, playbook):
"image-dev": device,
},
]
- }
+ )
+
+ # If a playbook has been specified, add an ansible step.
if playbook:
spec["steps"].append({"ansible": "root", "playbook": playbook})
+
return spec
@@ -232,12 +260,13 @@ def main():
p.add_argument("--log", default="install.log")
p.add_argument("--cache", default="cache.tar.gz")
p.add_argument("--playbook")
+ p.add_argument("--luks")
p.add_argument("device")
args = p.parse_args()
clean_up_disks()
- spec = vmdb_spec("asdf", args.playbook)
+ spec = vmdb_spec(args.luks, args.playbook)
tmp = tempfile.mkdtemp()
specfile = os.path.join(tmp, "spec.yaml")
if args.verbose: