Hi All,
I am trying to build RHEL 8 image from Hyper-V Windows Host.
Packer builds not taking kickstart file.
Main Template File (main.json):
{
“variables”: {
“disk_size_rhel_7”: “65536”,
“disk_size_rhel_8”: “32768”,
“iso_url_rhel_8_0”: “F:\ISOs\rhel-8.0-x86_64-dvd.iso”,
“iso_checksum_rhel_8_0”: “005d4f88fff6d63b0fc01a10822380ef52570edd8834321de7be63002cc6cc43”,
“iso_checksum_type”: “sha256”,
“output_directory”: “F:\Images_GCP\”
},
“provisioners”: [
{
“type”: “shell”,
“execute_command”: “bash ‘{{.Path}}’”,
“script”: “scripts/redhat_prep.sh”
},
{
“type”: “shell”,
“execute_command”: “bash ‘{{.Path}}’”,
“script”: “scripts/install_ansible.sh”
},
{
“type”: “shell”,
“execute_command”: “bash ‘{{.Path}}’”,
“script”: “scripts/retrieve_goss.sh”
},
{
“destination”: “/var/tmp/packer-image”,
“source”: “validation”,
“type”: “file”
},
{
“type”: “shell”,
“execute_command”: “bash ‘{{.Path}}’”,
“script”: “scripts/redhat_cleanup.sh”
}
],
“builders”: [
{
“type”: “hyperv-iso”,
“http_directory”: “http”,
“floppy_files”: [
“http/ks_rhel_7_7.cfg”
],
“boot_command”: [
" text ks=hd:fd0:/ks_rhel_7_7.cfg"
],
“boot_wait”: “10s”,
“cpus”: 1,
“disk_size”: “{{ user disk_size_rhel_8
}}”,
“enable_dynamic_memory”: false,
“enable_mac_spoofing”: true,
“generation”: 1,
“iso_url”: “{{ user iso_url_rhel_8_0
}}”,
“iso_checksum_type”: “{{ user iso_checksum_type
}}”,
“iso_checksum”: “{{ user iso_checksum_rhel_8_0
}}”,
“output_directory”: “{{ user output_directory
}}”,
“memory”: 4096,
“skip_export”: true,
“ssh_username”: “root”,
“ssh_password”: “l!nux”,
“ssh_port”: 22,
“ssh_timeout”: “4h”,
“shutdown_command”: “echo ‘{{ user ssh_username
}}’|sudo -S /sbin/halt -h -p”,
“switch_name”: “ImageBuild”,
“vm_name”: “gcp_rhel_8_0”
}
],
“post-processors”: [
{
“output”: “manifest.json”,
“strip_path”: true,
“type”: “manifest”
}
]
}
ks.cfg.
#version=RHEL8
Autopartition as lvm without home partition (CHANGED)
ignoredisk --only-use=sda
System bootloader configuration
bootloader --append=“crashkernel=auto” --location=mbr --boot-drive=sda
Clear the Master Boot Record
#zerombr
Partition clearing information
clearpart --all --initlabel --drives=sda
Disk partitioning information
part /boot --fstype=“xfs” --size=500
part / --fstyp=“xfs” --size=1 --grow --asprimary
part /boot --fstype=xfs --size=1024 --ondisk=/dev/sda
part pv.01 --size=50000 --grow --ondisk=/dev/sda
volgroup rootvg pv.01
logvol / --vgname=rootvg --name=rootvg-rootlv --size=8589 --grow
logvol /usr --vgname=rootvg --name=usrlv --size=10240 --grow
logvol /opt --vgname=rootvg --name=optlv --size=2147 --grow
logvol /tmp --vgname=rootvg --name=rootvg-tmplv --size=2147 --grow
logvol /var --vgname=rootvg --name=rootvg-varlv --size=8589 --grow
logvol /home --vgname=rootvg --name=homelv --size=1073 --grow
%post --interpreter=/usr/bin/bash
Create of [ /tmp ] mount using the tmpfs filesystem type.
Create the tmpfs mount point if it doesn’t already exist.
mkdir -p /tmp
mkdir -p /var/tmp
Mount the tmp directory initially.
mount -t tmpfs -o size=2048m tmpfs /tmp
mount --bind /tmp /var/tmp
Append an entry to mount the tmp directory in the [ /etc/fstab ] file.
echo “” >> /etc/fstab
echo "# Secure /tmp Mount Point " >> /etc/fstab
echo “” >> /etc/fstab
echo “tmpfs /tmp tmpfs size=2048m 0 0” >> /etc/fstab
%end
End User License Agreement
eula --agreed
Use graphical install
graphical
Use CDROM installation media
cdrom
Keyboard layouts
keyboard --vckeymap=us --xlayouts=‘us’
System language
lang en_US.UTF-8
Network information - disable ipv6 (CHANGED)
network --onboot yes --device eth0 --bootproto dhcp --noipv6 --hostname=localhost.localdomain
authconfig --enableshadow --passalgo=sha512
selinux --disabled
Root password
rootpw l!nux
Don’t run the Setup Agent on first boot (CHANGED)
firstboot --enable
Do not configure the X Window System
skipx
System services (ADDED VMTOOLS)
services --enabled=chronyd,sshd,NetworkManager
services --enabled=“tmp.mount”
System timezone (not UTC in VM environment) (CHANGED)
timezone Europe/London --isUtc
Add rn-user service account and add to ‘wheel’ group
user --groups=wheel --name=rn-user --password=$6$d1k0savclA12hRRX$dbpxmwUWZsvWpX506AM95r9d.sX0YcVQGrJ5LyqNd1Gzd.Q9Adot3WGYmHeUJL3SsmpHRMQ.EW8sJOzqflvx3. --iscrypted
Reboot after installation (ADDED)
reboot
%packages --ignoremissing
@Base
@Core
python
qemu-kvm-tools
kernel-devel
wget
chrony
cloud-init
kernel-headers
perl
curl
net-tools
lvm2
grub2
kernel
rsync
tar
yum-utils
unzip
ssh
vim-enhanced
sudo
%end
%addon com_redhat_kdump --disable --reserve-mb=‘auto’
%end
%anaconda
pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
%end
I am keeping my kickstart file in one of my windows drive like F:\http\ks.cfg