Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 2089456

Summary: Network config in kickstart's %pre section doesnt work
Product: Red Hat Enterprise Linux 7 Reporter: Ozgur Yilmaz <yelbuke>
Component: doc-Installation_GuideAssignee: Jana Heves <jsvarova>
Status: CLOSED CURRENTRELEASE QA Contact: Jan Stodola <jstodola>
Severity: low Docs Contact:
Priority: medium    
Version: 7.9CC: jstodola, rvykydal, sdubewar
Target Milestone: rcKeywords: Documentation
Target Release: ---Flags: pm-rhel: mirror+
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-07-14 10:51:22 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 Ozgur Yilmaz 2022-05-23 17:57:49 UTC
Description of problem:
Network configuration in %pre section -that's included in kickstart's main body with %include- is not taken in consideration.

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


How reproducible:
Needs an iso prepared as below.


Steps to Reproduce:
1. Download ISO: Red Hat Enterprise Linux 7.9 Boot ISO
2. Modify iso/EFI/BOOT/grub.cfg's any menu entry for ks file:
linuxefi /images/pxeboot/vmlinuz inst.ks=cdrom:/ks.cfg
3. Create ks.cfg in iso/ folder
4. Define an url in ks.cfg for remote install folder:
url --url http://<base-host-ip>/path/to/folder
5. Modify ks.cfg and add %pre section for a static network configuration. Sample:
%pre
echo "network --ip=<valid-ip-address> --hostname=foo --nameserver=<nameserver-address> --netmask=<subnet> --gateway=<gateway-address> --device=<device-name> --bootproto=static" > /tmp/networkconfig.txt
%end
6. Include "/tmp/networkconfig.txt" file in ks.cfg's main body:
%include /tmp/networkconfig.txt
7. Run genisoimage command in iso/ folder to create iso file:
genisoimage -U -r -v -T -J -joliet-long -V "RHEL-7.9" -volset "RHEL-7.9" -A "RHEL-7.9" -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -eltorito-alt-boot -e images/efiboot.img -no-emul-boot -o ../NEW_ISO.iso .
8. Mount iso file and boot.


Actual results:
All interfaces checked for any DHCP configuration. After looping them dracut stops and after some time it timeouts.

Expected results:
Complete configuration for network interface defined in ks.cfg and continue with remote install.

Additional info:
If the network configuration is written in ks.cfg's main body (not in %pre) then everything works fine. For example if the config is written in body like below, there is no problem. But if it's written in %pre, it doesn't work.
network --ip=<valid-ip-address> --hostname=foo --nameserver=<nameserver-address> --netmask=<subnet> --gateway=<gateway-address> --device=<device-name> --bootproto=static

This case looks similar to a predefined bug in RHEL6.4's anaconda: https://access.redhat.com/solutions/396013

Comment 3 Ozgur Yilmaz 2022-05-25 06:45:58 UTC
Below %pre fails and dracut hangs during the installation process:

%include /tmp/networkconfig.txt

%pre --log=/tmp/ks-pre.log
sh -x
IP="--ip=XXX.XXX.XXX.XXX"
NODENAME="--hostname=deneme"
DNS="--nameserver=XXX.XXX.XXX.XXX"
MASK="--netmask=255.255.255.224"
GATEWAY="--gateway=XXX.XXX.XXX.XXX"
DEV="--device=ens3f1"
PROTO="--bootproto=static"
echo "network $IP $NODENAME $DNS $MASK $GATEWAY $DEV $PROTO" > /tmp/networkconfig.txt
%end

But if i dont use %pre and define the network in ks.cfg's main body, then everything works fine and the OS is installed with success:

network --ip=XXX.XXX.XXX.XXX --hostname=deneme --nameserver=XXX.XXX.XXX.XXX --netmask=255.255.255.224 --gateway=XXX.XXX.XXX.XXX --device=ens3f1 --bootproto=static

I've followed the procedure in the below url to build iso image:
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/installation_guide/s1-kickstart2-putkickstarthere

I've downloaded the RHEL7.9 boot image from below url:
https://access.redhat.com/downloads/content/69/ver=/rhel---7/7.9/x86_64/product-software

Comment 4 Ozgur Yilmaz 2022-05-25 06:49:31 UTC
I've tried the same procedure with also the below versions as their official boot images still downloadable on redhat.com. They all failed with network definition in %pre section.

RHEL7.1, RHEL7.2, RHEL7.8, RHEL8.4

Comment 5 Radek Vykydal 2022-05-30 13:47:58 UTC
Unfortunately, network configuration defined in %pre really does not apply in stage1 / initramfs.

So if you really need to configure the network already in stage1 you have to use regular network command.

I am not sure why is the network needed for in inintramfs in your case, but I'd guess it is the url --url http://<base-host-ip>/path/to/folder

If you need it to access just the software repositories - not the installer image which would be fetched from the iso - there is a chance that with specifying the local installer image correctlu via boot option added to the installer boot options, like:
inst.stage2=hd:LABEL=RHEL-7.9
the initramfs stage can proceed without network configuration.

Maybe changing the volume id (-V "RHEL-7.9") in process of regenerating of the iso (genisoimage) is the reason why it is not already picked up (matched) by the inst.stage2 option already present among the boot options. Maybe look at the isolinux.cfg of your boot.iso to see if the inst.stage2 matches the volume id of the regenerated boot.iso.

Comment 6 Ozgur Yilmaz 2022-05-31 19:27:15 UTC
Hello Radek,

Thanks for the good explanation. I've finally succeed to configure a network interface. Of course couldnt do it without inst.stage2 -as you've mentioned-. So the information you've given fits the situation well. An image -that not resides on a remote location- is needed if we want to configure network with some dynamic parameters in %pre section.

My goal is to build an bare metal automation that can determine the network port that is already configured on switch side with some script that can only work in %pre.

My opinion is all of the official documentation is lack of describing the needs of dynamic network configuration in Anaconda. My first decision was to name this issue as a bug but now i understand there is a logic behind this scenario, the installer needs an image to start the installation. inst.stage2 and LiveOS image was enough to achieve a network configuration in %pre section.

Thank you.

p.s. so who should mark this issue as "not a bug"?

Comment 7 Ozgur Yilmaz 2022-05-31 19:38:44 UTC
Hello,

I did think about it again, although a runtime image need seems logic, there is still a confusion about %pre. If i configure network in kickstart file's main body it works perfectly, without a runtime image. But if i want to configure that interface in %pre section -although it's said that %pre is called earlier than kickstart's main body- it doesnt work without a runtime image.

I think if this's not a bug it deserves a detailed description in official documentation. Am i wrong?

Thank you.

Comment 8 Radek Vykydal 2022-06-03 07:29:06 UTC
%pre section of kickstart is executed at the stage of installation which happens way after the installer image (inst.stage2) is fetched. It is after switch root to the installer environment (the installer image) and after anaconda installer itself starts. Then the configuration in %pre is applied and can be used to fetch packages from installation repositories (configured for example by url in kickstart). But it can't be used to configure network to fetch the image (inst.stage2) from network.

Maybe we should emphasize this aspect in https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/installation_guide/sect-kickstart-syntax#sect-kickstart-preinstall ?

Comment 9 Ozgur Yilmaz 2022-06-03 23:15:55 UTC
Hi Radek,

Thanks for details. Actually if i'd knew these details before trying to configure network in %pre, it could save lots of time. I also think the same about emphasizing this on official documentation.

Thanks again. Have a nice weekend.

Comment 10 Jan Stodola 2022-06-30 07:54:44 UTC
Switching the bug to Documentation based on comment 8.

Radku, does the same limitation with %pre section apply to RHEL-8/RHEL-9 as well? I assume the answer is yes, and in such a case also RHEL-8 and RHEL-9 documentation should be updated.

Comment 11 Radek Vykydal 2022-06-30 09:57:52 UTC
(In reply to Jan Stodola from comment #10)
> Switching the bug to Documentation based on comment 8.
> 
> Radku, does the same limitation with %pre section apply to RHEL-8/RHEL-9 as
> well? I assume the answer is yes, and in such a case also RHEL-8 and RHEL-9
> documentation should be updated.

Yes it does.