diff --git a/fedora-cloud-base.ks b/fedora-cloud-base.ks index e2d0bf2..7c93309 100644 --- a/fedora-cloud-base.ks +++ b/fedora-cloud-base.ks @@ -34,17 +34,22 @@ rootpw --lock --iscrypted locked firewall --disabled -# We pass net.ifnames=0 because we always want to use eth0 here on all the cloud images. -bootloader --timeout=1 --append="no_timer_check net.ifnames=0 console=tty1 console=ttyS0,115200n8" +# First iteration: Change to GCP's serial port configuration; don't show bootloader screen. +# https://cloud.google.com/compute/docs/import/import-existing-image +bootloader --timeout=0 --append="no_timer_check net.ifnames=0 console=ttyS0,38400n8d" -network --bootproto=dhcp --device=link --activate --onboot=on +# First iteration: GCP uses 1460 as its MTU. +# https://cloud.google.com/network-connectivity/docs/vpn/concepts/mtu-considerations +network --bootproto=dhcp --device=link --activate --onboot=on --mtu=1460 services --enabled=sshd,cloud-init,cloud-init-local,cloud-config,cloud-final zerombr clearpart --all autopart --noboot --nohome --noswap --nolvm -%include fedora-repo.ks +# Inline %include (Only for this demo.) +repo --name=rawhide --mirrorlist=https://mirrors.fedoraproject.org/mirrorlist?repo=rawhide&arch=$basearch +url --mirrorlist=https://mirrors.fedoraproject.org/mirrorlist?repo=rawhide&arch=$basearch reboot @@ -92,28 +97,28 @@ which %post --erroronfail -# Create grub.conf for EC2. This used to be done by appliance creator but -# anaconda doesn't do it. And, in case appliance-creator is used, we're -# overriding it here so that both cases get the exact same file. -# Note that the console line is different -- that's because EC2 provides -# different virtual hardware, and this is a convenient way to act differently -echo -n "Creating grub.conf for pvgrub" -rootuuid=$( awk '$2=="/" { print $1 };' /etc/fstab ) -mkdir /boot/grub -echo -e 'default=0\ntimeout=0\n\n' > /boot/grub/grub.conf -for kv in $( ls -1v /boot/vmlinuz* |grep -v rescue |sed s/.*vmlinuz-// ); do - echo "title Fedora ($kv)" >> /boot/grub/grub.conf - echo -e "\troot (hd0,0)" >> /boot/grub/grub.conf - echo -e "\tkernel /boot/vmlinuz-$kv ro root=$rootuuid no_timer_check console=hvc0 LANG=en_US.UTF-8" >> /boot/grub/grub.conf - echo -e "\tinitrd /boot/initramfs-$kv.img" >> /boot/grub/grub.conf - echo -done - - -#link grub.conf to menu.lst for ec2 to work -echo -n "Linking menu.lst to old-style grub.conf for pv-grub" -ln -sf grub.conf /boot/grub/menu.lst -ln -sf /boot/grub/grub.conf /etc/grub.conf +# Install guest agent from CentOS8 (Only for this demo). +tee -a /etc/yum.repos.d/google-cloud.repo << EOM +[google-compute-engine] +name=Google Compute Engine +baseurl=https://packages.cloud.google.com/yum/repos/google-compute-engine-el8-x86_64-stable +enabled=1 +gpgcheck=1 +repo_gpgcheck=1 +gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg + https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg +EOM +curl -o /etc/pki/rpm-gpg/google-rpm-package-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg +curl -o /etc/pki/rpm-gpg/google-key.gpg https://packages.cloud.google.com/yum/doc/yum-key.gpg +rpmkeys --import /etc/pki/rpm-gpg/google-rpm-package-key.gpg +rpmkeys --import /etc/pki/rpm-gpg/google-key.gpg +dnf install -y google-compute-engine + +# First iteration: These aren't required for GCP. +##link grub.conf to menu.lst for ec2 to work +#echo -n "Linking menu.lst to old-style grub.conf for pv-grub" +#ln -sf grub.conf /boot/grub/menu.lst +#ln -sf /boot/grub/grub.conf /etc/grub.conf # older versions of livecd-tools do not follow "rootpw --lock" line above # https://bugzilla.redhat.com/show_bug.cgi?id=964299 @@ -154,13 +159,14 @@ mv -f /usr/lib/locale/locale-archive /usr/lib/locale/locale-archive.tmpl build-locale-archive echo '%_install_langs C:en:en_US:en_US.UTF-8' >> /etc/rpm/macros.image-language-conf - -echo -n "Getty fixes" -# although we want console output going to the serial console, we don't -# actually have the opportunity to login there. FIX. -# we don't really need to auto-spawn _any_ gettys. -sed -i '/^#NAutoVTs=.*/ a\ -NAutoVTs=0' /etc/systemd/logind.conf +# First iteration: Allow access to serial console. +# https://cloud.google.com/compute/docs/instances/interacting-with-serial-console +#echo -n "Getty fixes" +## although we want console output going to the serial console, we don't +## actually have the opportunity to login there. FIX. +## we don't really need to auto-spawn _any_ gettys. +#sed -i '/^#NAutoVTs=.*/ a\ +#NAutoVTs=0' /etc/systemd/logind.conf echo -n "Network fixes" # initscripts don't like this file to be missing.