Let's always generate the unattended script file as, by doing this, we can treat the files we have as templates, being able to change them accordingly to whatever is needed by specific distros. It's important to note that we *must* be careful and keep generating those files using their "expected" filename, preferably using the same name of the template, as some of the distros require that. Signed-off-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx> Reviewed-by: Andrea Bolognani <abologna@xxxxxxxxxx> --- guests/lcitool | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/guests/lcitool b/guests/lcitool index 8436ce7..379fecc 100755 --- a/guests/lcitool +++ b/guests/lcitool @@ -23,9 +23,11 @@ import json import os import platform import random +import shutil import string import subprocess import sys +import tempfile import textwrap import yaml @@ -537,7 +539,18 @@ class Application: raise Exception( "Host {} doesn't support installation".format(host) ) - initrd_inject = os.path.join(base, "configs", install_config) + + # Unattended install scripts are being generated on the fly, based + # on the templates present in guests/configs/ + initrd_template = os.path.join(base, "configs", install_config) + with open(initrd_template, 'r') as template: + content = template.read() + + tempdir = tempfile.mkdtemp() + initrd_inject = os.path.join(tempdir, install_config) + + with open(initrd_inject, "w") as inject: + inject.write(content) # preseed files must use a well-known name to be picked up by # d-i; for kickstart files, we can use whatever name we please @@ -587,6 +600,8 @@ class Application: except Exception as ex: raise Exception("Failed to install '{}': {}".format(host, ex)) + shutil.rmtree(tempdir, ignore_errors=True) + def _action_update(self, args): self._execute_playbook("update", args.hosts, args.projects, args.git_revision) -- 2.23.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list