Make it possible to skip saving of kickstart (both input & output)
and logs to the installed system by adding the save_kickstarts and
save_logs CLI-/boot-options.
The main use case is image generation that might use internal
repository URLs and other internal resources that would then
otherwise be included in kickstart and/or logs on the resulting
image. Other scenarios, such as OEM OS installs, are also likely to
benefit from this added functionality.
Signed-off-by: Martin Kolman <mkolman(a)redhat.com>
---
anaconda | 12 ++++++++++++
data/anaconda_options.txt | 6 ++++++
data/post-scripts/99-copy-logs.ks | 29 ++++++++++++++++++++---------
pyanaconda/anaconda_argparse.py | 6 ++++++
pyanaconda/install.py | 8 +++++++-
5 files changed, 51 insertions(+), 10 deletions(-)
diff --git a/anaconda b/anaconda
index 7095862..bcc79cd 100755
--- a/anaconda
+++ b/anaconda
@@ -694,6 +694,18 @@ if __name__ == "__main__":
stdoutLog.error("anaconda must be run as root.")
sys.exit(1)
+ # check if kickstarts should be saved
+ if not flags.cmdline.getbool('save_kickstarts', True):
+ log.warning("Input & output kickstart copying to the installed system
has been disabled"
+ " by the copy_kickstarts option.")
+ os.mknod('/tmp/DONT_COPY_KICKSTARTS')
+
+ # check if logs should be saved
+ if not flags.cmdline.getbool('save_logs', True):
+ log.warning("Installation logscopying to the installed system has been
disabled"
+ " by the save_logs option.")
+ os.mknod('/tmp/DONT_COPY_LOGS')
+
# see if we're on s390x and if we've got an ssh connection
uname = os.uname()
if uname[4] == 's390x':
diff --git a/data/anaconda_options.txt b/data/anaconda_options.txt
index a42c453..2976ee4 100644
--- a/data/anaconda_options.txt
+++ b/data/anaconda_options.txt
@@ -235,3 +235,9 @@ be retried if there is no listener (ie. won't block the
installation).
kexec
Reboot the system using kexec with the new kernel and initrd. This will result in
a faster reboot by skipping the BIOS/Firmware and bootloader steps.
+
+save-kickstarts
+Controls saving of input and output kickstarts to the installed system.
+
+save-logs
+Controls saving of installation logs to the installed system.
diff --git a/data/post-scripts/99-copy-logs.ks b/data/post-scripts/99-copy-logs.ks
index 5640cce..60dba17 100644
--- a/data/post-scripts/99-copy-logs.ks
+++ b/data/post-scripts/99-copy-logs.ks
@@ -1,14 +1,25 @@
# Note, this script log will not be copied to the installed system.
%post --nochroot
-mkdir -p $ANA_INSTALL_PATH/var/log/anaconda
-for log in anaconda.log syslog X.log program.log packaging.log storage.log ifcfg.log
yum.log dnf.log dnf.rpm.log lvm.log; do
- [ -e /tmp/$log ] && cp /tmp/$log $ANA_INSTALL_PATH/var/log/anaconda/
-done
-cp /tmp/ks-script*.log $ANA_INSTALL_PATH/var/log/anaconda/
-journalctl -b > $ANA_INSTALL_PATH/var/log/anaconda/journal.log
-chmod 0600 $ANA_INSTALL_PATH/var/log/anaconda/*
-
-[ -e /run/install/ks.cfg ] && cp /run/install/ks.cfg
$ANA_INSTALL_PATH/root/original-ks.cfg
+NO_LOGS_FILE=/tmp/DONT_COPY_LOGS
+NO_KS_FILE=/tmp/DONT_COPY_KICKSTARTS
+
+if [ -e ${NO_LOGS_FILE} ]; then
+ rm -f ${NO_LOGS_FILE}
+else
+ mkdir -p $ANA_INSTALL_PATH/var/log/anaconda
+ for log in anaconda.log syslog X.log program.log packaging.log storage.log ifcfg.log
yum.log dnf.log dnf.rpm.log lvm.log; do
+ [ -e /tmp/$log ] && cp /tmp/$log $ANA_INSTALL_PATH/var/log/anaconda/
+ done
+ cp /tmp/ks-script*.log $ANA_INSTALL_PATH/var/log/anaconda/
+ journalctl -b > $ANA_INSTALL_PATH/var/log/anaconda/journal.log
+ chmod 0600 $ANA_INSTALL_PATH/var/log/anaconda/*
+fi
+
+if [ -e ${NO_KS_FILE} ]; then
+ rm -f ${NO_KS_FILE}
+else
+ [ -e /run/install/ks.cfg ] && cp /run/install/ks.cfg
$ANA_INSTALL_PATH/root/original-ks.cfg
+fi
%end
diff --git a/pyanaconda/anaconda_argparse.py b/pyanaconda/anaconda_argparse.py
index 3caf107..b36a3c0 100644
--- a/pyanaconda/anaconda_argparse.py
+++ b/pyanaconda/anaconda_argparse.py
@@ -480,6 +480,12 @@ def getArgumentParser(version_string, boot_cmdline=None):
# Geolocation
ap.add_argument("--geoloc", metavar="PROVIDER_ID",
help=help_parser.help_text("geoloc"))
+ # Kickstart and log saving
+ ap.add_argument("--save-kickstarts", action="store_true",
default=True,
+ help=help_parser.help_text("save-kickstarts"))
+ ap.add_argument("--save-logs", action="store_true",
default=True,
+ help=help_parser.help_text("save-logs"))
+
# Miscellaneous
ap.add_argument("--nomount", dest="rescue_nomount",
action="store_true", default=False,
help=help_parser.help_text("nomount"))
diff --git a/pyanaconda/install.py b/pyanaconda/install.py
index d84186a..8060b61 100644
--- a/pyanaconda/install.py
+++ b/pyanaconda/install.py
@@ -122,7 +122,13 @@ def doConfiguration(storage, payload, ksdata, instClass):
# Write the kickstart file to the installed system (or, copy the input
# kickstart file over if one exists).
- _writeKS(ksdata)
+ if flags.flags.cmdline.getbool('save_kickstarts', True):
+ # don't write the kickstart file to the installed system if this has
+ # been disabled by the save_kickstarts option
+ _writeKS(ksdata)
+ else:
+ log.warning("Writing of the output kickstart to installed system has been
disabled"
+ " by the copy_kickstarts option.")
progress_complete()
--
2.5.0