summaryrefslogtreecommitdiff
path: root/v-i
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2022-01-07 15:06:29 +0200
committerLars Wirzenius <liw@liw.fi>2022-01-07 18:52:02 +0200
commit2c3f88259122323eb73eb40f4dec9d66483d926c (patch)
treeca22c3b0740bb2db51f1775d80dec57b7317140f /v-i
parent79dd4f5367ca66df6c2c56b751b4582554e39032 (diff)
downloadv-i-2c3f88259122323eb73eb40f4dec9d66483d926c.tar.gz
feat: make v-i script support my standard base install
Also, put as many packages as possible inside the cached portion, for speed. Sponsored-by: author
Diffstat (limited to 'v-i')
-rwxr-xr-xv-i64
1 files changed, 44 insertions, 20 deletions
diff --git a/v-i b/v-i
index bf1903e..49721e4 100755
--- a/v-i
+++ b/v-i
@@ -107,7 +107,7 @@ def clean_up_disks():
run(["cryptsetup", "close", mapping], check=False)
-def vmdb_spec(cryptsetup_password, playbook):
+def vmdb_spec(cryptsetup_password, playbook, extra_vars):
device = "{{ image }}"
spec = {
"steps": [
@@ -190,16 +190,17 @@ def vmdb_spec(cryptsetup_password, playbook):
{
"mount": "root",
},
- {"mount": "boot", "dirname": "/boot", "mount-on": "root"},
+ {
+ "mount": "boot",
+ "dirname": "/boot",
+ "mount-on": "root",
+ },
{
"mount": "efi",
"dirname": "/boot/efi",
"mount-on": "boot",
},
{
- "virtual-filesystems": "root",
- },
- {
"unpack-rootfs": "root",
},
{
@@ -209,35 +210,46 @@ def vmdb_spec(cryptsetup_password, playbook):
"unless": "rootfs_unpacked",
},
{
+ "apt": "install",
+ "packages": [
+ "console-setup",
+ "dosfstools",
+ "ifupdown",
+ "linux-image-amd64",
+ "locales-all",
+ "lvm2",
+ "psmisc",
+ "python3",
+ "ssh",
+ "strace",
+ ],
+ "tag": "root",
+ "unless": "rootfs_unpacked",
+ },
+ {
"cache-rootfs": "root",
"unless": "rootfs_unpacked",
},
{
- "fstab": "root",
+ # This MUST be after the debootstrap step.
+ "virtual-filesystems": "root",
},
{
- "apt": "install",
- "packages": ["linux-image-amd64"],
- "tag": "root",
+ "fstab": "root",
},
{
+ # These MUST come after the fstab step so that they add the
+ # crypttab in the initramfs.
"apt": "install",
"packages": [
- "console-setup",
"cryptsetup",
"cryptsetup-initramfs",
- "dosfstools",
- "ifupdown",
- "locales-all",
- "lvm2",
- "psmisc",
- "python3",
- "ssh",
- "strace",
],
"tag": "root",
},
{
+ # This also MUST come outside the rootfs caching, as it install
+ # things outside the file systems.
"grub": "uefi",
"tag": "root",
"efi": "efi",
@@ -249,7 +261,9 @@ def vmdb_spec(cryptsetup_password, playbook):
# If a playbook has been specified, add an ansible step.
if playbook:
- spec["steps"].append({"ansible": "root", "playbook": playbook})
+ spec["steps"].append(
+ {"ansible": "root", "playbook": playbook, "extra_vars": extra_vars}
+ )
return spec
@@ -260,13 +274,19 @@ def main():
p.add_argument("--log", default="install.log")
p.add_argument("--cache", default="cache.tar.gz")
p.add_argument("--playbook")
+ p.add_argument("--vars")
p.add_argument("--luks")
p.add_argument("device")
args = p.parse_args()
+ extra_vars = {}
+ if args.vars:
+ with open(args.vars) as f:
+ extra_vars = yaml.safe_load(f)
+
clean_up_disks()
- spec = vmdb_spec(args.luks, args.playbook)
+ spec = vmdb_spec(args.luks, args.playbook, extra_vars)
tmp = tempfile.mkdtemp()
specfile = os.path.join(tmp, "spec.yaml")
if args.verbose:
@@ -275,6 +295,10 @@ def main():
yaml.dump(spec, stream=f, indent=4)
log(f"run vmdb2 to install on {args.device}")
+ env = dict(os.environ)
+ env["ANSIBLE_STDOUT_CALLBACK"] = "yaml"
+ env["ANSIBLE_NOCOWS"] = "1"
+ env["ANSIBLE_LOG_PATH"] = "ansible.log"
run(
[
"vmdb2",