Let's always generate the unattended script file as, by doing this, we
can trea 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, preferrably using the same
name of the template, as some of the distros require that.
Signed-off-by: Fabiano FidĂȘncio <fidencio(a)redhat.com>
---
guests/lcitool | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/guests/lcitool b/guests/lcitool
index 8436ce7..3985e90 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,14 @@ class Application:
raise Exception(
"Host {} doesn't support installation".format(host)
)
- initrd_inject = os.path.join(base, "configs", install_config)
+ initrd_template = os.path.join(base, "configs", install_config)
+ with open(initrd_template) as template:
+ content = template.read()
+
+ tempdir = tempfile.mkdtemp()
+ initrd_inject = os.path.join(tempdir, install_config)
+
+ open(initrd_inject, "w").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 +596,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