Bug 2173992

Summary: [Regression] Anaconda doesn't configure the network specified in a kickstart prior to executing %pre script
Product: Red Hat Enterprise Linux 9 Reporter: Renaud Métrich <rmetrich>
Component: doc-Release_Notes-9-en-USAssignee: Gabi Fialová <gfialova>
Status: CLOSED CURRENTRELEASE QA Contact: RHEL DPM <rhel-docs>
Severity: high Docs Contact: Sagar Dubewar <sdubewar>
Priority: high    
Version: 9.1CC: jkonecny, lkuprova, lmanasko, rhel-docs, rvykydal, sbarcomb
Target Milestone: rcKeywords: Documentation
Target Release: 9.2Flags: pm-rhel: mirror+
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Known Issue
Doc Text:
.Kickstart installations fail to configure the network connection Anaconda performs the Kickstart network configuration only through the NetworkManager API. Anaconda processes the network configuration after the `%pre` Kickstart section. As a consequence, some tasks from the Kickstart `%pre` section are blocked. For example, downloading packages from the `%pre` section fails due to unavailability of the network configuration. To work around this problem: * Configure the network, for example using the `nmcli` tool, as a part of the `%pre` script. * Use the installer boot options to configure the network for the `%pre` script. As a result, it is possible to use the network for tasks in the `%pre` section and the Kickstart installation process completes.
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-05-11 08:06:41 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Renaud Métrich 2023-02-28 15:38:50 UTC
Description of problem:

With RHEL9 DVD, booting a system on the DVD while specifying a kickstart (e.g. using a OEMDRV disk), shows that even though the kickstart contains a "network" directive, the network doesn't get configured prior to executing %pre script, causing it impossible to download kickstart "includes" for example.

Before switching root, we can see that "parse-kickstart" generates the /etc/cmdline.d/80-kickstart.conf snippet properly:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
switch_root:/# cat /etc/cmdline.d/80-kickstart.conf 
ip=192.168.0.250::192.168.0.1:255.255.255.0:test:enp1s0:none: nameserver=192.168.0.1 bootdev=enp1s0
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

After switching root, the network is configured, but after %pre executed, as shown with the kickstart below:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
network --noipv6 --bootproto static --ip 192.168.0.250 --netmask 255.255.255.0 --gateway 192.168.0.1 --nameserver 192.168.0.1 --device=enp1s0 --hostname=test

%pre --log=/tmp/ks-pre.log
echo HELLO
ip r
echo DONE
%end
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

%pre execution output:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
[anaconda root@localhost ~]# cat /tmp/ks-pre.log 
HELLO
DONE
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

After %pre execution, we have the network configured properly:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
[anaconda root@localhost ~]# ip r
default via 192.168.0.1 dev enp1s0 proto static metric 100 
192.168.0.0/24 dev enp1s0 proto kernel scope link src 192.168.0.250 metric 100 
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

Additionally (and related somehow): if DHCP is present on the network, at time of %pre execution, we have an IP address, but this is an IP address delivered by the DHCP server, not what got specified as "network" directive!

This works fine on RHEL8. The main difference with RHEL8 is "ifcfg-xxx" snippets are not created anymore by parse-kickstart.

Version-Release number of selected component (if applicable):

RHEL9/RHEL9.1

How reproducible:

Always

Steps to Reproduce:
1. Create a OEMDRV disk with kickstart above
2. Start the installation using the DVD

Actual results:

No IP address in %pre configured / Unexpected IP address if DHCP is on the network

Expected results:

IP address specified by "network" directive

Comment 1 Radek Vykydal 2023-03-01 09:49:28 UTC
The root cause of the issue is a change in RHEL 9: https://github.com/rhinstaller/anaconda/pull/2870
In RHEL 8 kickstart configuration was parsed into ifcfg files in dracut and after switch root NetworkManger (before %pre section in anaconda) applied the ifcfg configuration. Then the kickstart configuration was applied one more time in Anaconda via NM dbus API after %pre section (for the case of kickstart network configuration created in %pre section).
In RHEL 9 we apply kickstart configuration only in Anaconda via NM dbus API. Generating NM config files directly from kickstart configuration (as in RHEL 8) became unmaintainable, especially with NM now using keyfile format as new default. Also this approach required ugly hacks for ONBOOT setting.

The cause of the automatic DHCP configuration is this change in RHEL 9: https://bugzilla.redhat.com/show_bug.cgi?id=1978264. The automatic configuration should be disabled in case kickstart is used but this is determined by presence of inst.ks boot option which is not used in the OEMDRV case. (Note: we have added option to explicitly turn the DHCP autoconfigration off in Fedora/upstream: https://bugzilla.redhat.com/show_bug.cgi?id=2033231).

There is still one case where network is activated form kickstart early - in intitramfs/dracut. The case was fixed in RHEL 9.2 in https://bugzilla.redhat.com/show_bug.cgi?id=2153361. However this case is limited: network must not be activated via boot options; and installer image (stage2) is fetched from network location based on kickstart "url" command. Also it applies only the first network command.

Comment 3 Jiri Konecny 2023-03-16 10:36:34 UTC
After SST team discussion we decided to close this bug with documenting this behavior. As explained in comment 1 it is not a regression but impact of change done on purpose.

Switching to the documentation component so the bug could be closed after it's documented.

Comment 5 Radek Vykydal 2023-03-24 08:46:21 UTC
We should update the documentation: https://pykickstart.readthedocs.io/en/latest/kickstart-docs.html#chapter-4-pre-installation-script