summaryrefslogtreecommitdiff
path: root/v-i
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2022-09-17 16:01:19 +0300
committerLars Wirzenius <liw@liw.fi>2022-09-17 16:01:19 +0300
commit9ce78c6f1dc931644bd890527a1ade89c940b8dd (patch)
tree8907f89298adbe088460ebbd36577d0fcdbfb1d7 /v-i
parent4602d23c327841ef2f2e0e123dc7185d0ed92c05 (diff)
downloadv-i-9ce78c6f1dc931644bd890527a1ade89c940b8dd.tar.gz
feat: allow additional files with Ansible vars
v-i reads them and gives the values to Ansible, just like with values in the "ansible_vars" key in the spec file. Sponsored-by: author
Diffstat (limited to 'v-i')
-rwxr-xr-xv-i12
1 files changed, 10 insertions, 2 deletions
diff --git a/v-i b/v-i
index 8bdd6dd..d4f9efd 100755
--- a/v-i
+++ b/v-i
@@ -385,6 +385,7 @@ class SystemSpec:
"extra_lvs": [],
"extra_playbooks": [],
"ansible_vars": {},
+ "ansible_vars_files": [],
"luks": "",
}
with open(filename) as f:
@@ -442,10 +443,17 @@ def main():
system = SystemSpec(args.spec)
log(f"spec: {system!r}")
- clean_up_disks([system.drive] + system.extra_drives)
-
ansible_vars = dict(system.ansible_vars)
ansible_vars["hostname"] = system.hostname
+ for filename in system.ansible_vars_files:
+ log(f"reading Ansible vars from {filename}")
+ with open(filename) as f:
+ vars_dict = yaml.safe_load(f)
+ ansible_vars.update(vars_dict)
+ log(f"ansible_vars: {ansible_vars!r}")
+
+ clean_up_disks([system.drive] + system.extra_drives)
+
vmdb = vmdb_spec(system, ansible_vars)
tmp = tempfile.mkdtemp()
specfile = os.path.join(tmp, "spec.yaml")