From 9ce78c6f1dc931644bd890527a1ade89c940b8dd Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 17 Sep 2022 16:01:19 +0300 Subject: 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 --- v-i | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'v-i') 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") -- cgit v1.2.1