diff options
author | Lars Wirzenius <liw@liw.fi> | 2022-09-17 16:01:19 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2022-09-17 16:01:19 +0300 |
commit | 9ce78c6f1dc931644bd890527a1ade89c940b8dd (patch) | |
tree | 8907f89298adbe088460ebbd36577d0fcdbfb1d7 /v-i | |
parent | 4602d23c327841ef2f2e0e123dc7185d0ed92c05 (diff) | |
download | v-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-x | v-i | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -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") |