summaryrefslogtreecommitdiff
path: root/v-i
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2022-01-07 18:44:18 +0200
committerLars Wirzenius <liw@liw.fi>2022-01-07 18:52:02 +0200
commit04224dc0b688abfbb67f796fd9fa89330bc5bf49 (patch)
tree8d6c209fb3d1cd0e133d4891fce20da6a1d1a651 /v-i
parent2c3f88259122323eb73eb40f4dec9d66483d926c (diff)
downloadv-i-04224dc0b688abfbb67f796fd9fa89330bc5bf49.tar.gz
feat: hide output unless --verbose is used
but do explicitly say OK if all went well Sponsored-by: author
Diffstat (limited to 'v-i')
-rwxr-xr-xv-i44
1 files changed, 27 insertions, 17 deletions
diff --git a/v-i b/v-i
index 49721e4..ce26933 100755
--- a/v-i
+++ b/v-i
@@ -10,8 +10,12 @@ import yaml
from subprocess import run
+verbose = False
+
+
def log(msg):
- print("INSTALLER:", msg)
+ if verbose:
+ print("INSTALLER:", msg)
def physical_volumes():
@@ -89,22 +93,22 @@ def clean_up_disks():
for lv in lvs:
for m in find_mount_points(mounts, lv["path"]):
log(f"unmount {m['mount']}")
- run(["umount", m["mount"]])
+ run(["umount", m["mount"]], capture_output=True)
for vg in vgs:
log(f"remove volume group {vg}")
- run(["vgremove", "--yes", vg], check=True)
+ run(["vgremove", "--yes", vg], check=True, capture_output=True)
for pv in pvs:
log(f"remove physical volume {pv}")
- run(["pvremove", pv["pv"]], check=True)
+ run(["pvremove", pv["pv"]], check=True, capture_output=True)
if is_luks(pv["pv"]):
- run(["cryptsetup", "close", pv["pv"]], check=True)
+ run(["cryptsetup", "close", pv["pv"]], check=True, capture_output=True)
for mapping in glob.glob("/dev/mapper/*"):
if not mapping.endswith("/control"):
log(f"open LUKS volume {mapping} (just in case it is one)")
- run(["cryptsetup", "close", mapping], check=False)
+ run(["cryptsetup", "close", mapping], check=False, capture_output=True)
def vmdb_spec(cryptsetup_password, playbook, extra_vars):
@@ -279,6 +283,10 @@ def main():
p.add_argument("device")
args = p.parse_args()
+ if args.verbose:
+ global verbose
+ verbose = args.verbose
+
extra_vars = {}
if args.vars:
with open(args.vars) as f:
@@ -299,22 +307,24 @@ def main():
env["ANSIBLE_STDOUT_CALLBACK"] = "yaml"
env["ANSIBLE_NOCOWS"] = "1"
env["ANSIBLE_LOG_PATH"] = "ansible.log"
- run(
- [
- "vmdb2",
- "--verbose",
- f"--rootfs-tarball={args.cache}",
- f"--log={args.log}",
- f"--image={args.device}",
- specfile,
- ],
- check=True,
- )
+
+ argv = [
+ "vmdb2",
+ f"--rootfs-tarball={args.cache}",
+ f"--log={args.log}",
+ f"--image={args.device}",
+ specfile,
+ ]
+ if verbose:
+ argv.append("--verbose")
+
+ run(argv, check=True, capture_output=True)
log("cleanup")
shutil.rmtree(tmp)
log("OK, done")
+ print("OK, done")
main()