Add vagrant steps
Signed-off-by: Louis Abel <label@rockylinux.org>
This commit is contained in:
parent
b45f90f6f0
commit
c14492cf60
107
config.sh
107
config.sh
@ -579,6 +579,102 @@ function toolbox_container_steps() {
|
||||
rm -f /etc/rpm/macros.image-language-conf
|
||||
sed -i '/tsflags=nodocs/d' /etc/dnf/dnf.conf
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Vagrant
|
||||
function common_vagrant_steps() {
|
||||
fallocate -l 2G /swapfile
|
||||
chmod 600 /swapfile
|
||||
mkswap /swapfile
|
||||
echo "/swapfile none swap defaults 0 0" >> /etc/fstab
|
||||
|
||||
cat > /etc/sudoers.d/vagrant << EOF
|
||||
Defaults:vagrant !requiretty
|
||||
%vagrant ALL=(ALL) NOPASSWD: ALL
|
||||
EOF
|
||||
chmod 0440 /etc/sudoers.d/vagrant
|
||||
# This may have to be changed for 10
|
||||
ex -s /etc/ssh/sshd_config <<EOF
|
||||
:%substitute/^\(PasswordAuthentication\) yes$/\1 no/
|
||||
:%substitute/^#\(UseDNS\) yes$/&\r\1 no/
|
||||
:update
|
||||
:quit
|
||||
EOF
|
||||
|
||||
cat >>/etc/sysconfig/sshd <<EOF
|
||||
# Decrease connection time by preventing reverse DNS lookups
|
||||
# (see https://lists.centos.org/pipermail/centos-devel/2016-July/014981.html)
|
||||
OPTIONS="-u0"
|
||||
EOF
|
||||
|
||||
# Setup insecure key by default
|
||||
mkdir -m 0700 -p /home/vagrant/.ssh
|
||||
echo "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key" >> /home/vagrant/.ssh/authorized_keys
|
||||
chmod 600 /home/vagrant/.ssh/authorized_keys
|
||||
chown -R vagrant:vagrant /home/vagrant/.ssh
|
||||
|
||||
echo 'vag' > /etc/yum/vars/infra
|
||||
echo blacklist floppy > /etc/modprobe.d/nofloppy.conf
|
||||
pushd /etc/dracut.conf.d
|
||||
# Enable VMware PVSCSI support for VMware Fusion guests.
|
||||
echo 'add_drivers+=" vmw_pvscsi "' > vmware-fusion-drivers.conf
|
||||
echo 'add_drivers+=" hv_netvsc hv_storvsc hv_utils hv_vmbus hid-hyperv "' > hyperv-drivers.conf
|
||||
# There's no floppy controller, but probing for it generates timeouts
|
||||
echo 'omit_drivers+=" floppy "' > nofloppy.conf
|
||||
popd
|
||||
echo "Regenerating kernel"
|
||||
KERNEL_VERSION=$(rpm -q kernel --qf '%{version}-%{release}.%{arch}\n')
|
||||
dracut -f /boot/initramfs-${KERNEL_VERSION}.img ${KERNEL_VERSION}
|
||||
rm -rf /etc/ssh/ssh_host_*
|
||||
}
|
||||
|
||||
function vbox_vagrant_steps() {
|
||||
# legacy stuff, we won't have this for 10
|
||||
cat > /etc/sysconfig/network-scripts/ifcfg-eth0 << EOF
|
||||
DEVICE="eth0"
|
||||
BOOTPROTO="dhcp"
|
||||
ONBOOT="yes"
|
||||
TYPE="Ethernet"
|
||||
PERSISTENT_DHCLIENT="yes"
|
||||
EOF
|
||||
|
||||
# Install VBoxGuestAdditions for installed kernel.
|
||||
# https://git.resf.org/sig_kernel/meta/issues/13
|
||||
kver=$(rpm -q --queryformat="%{VERSION}-%{RELEASE}.%{ARCH}" kernel)
|
||||
echo "stg/rocky" > /etc/dnf/vars/contentdir
|
||||
sed -i 's/^#baseurl/baseurl/g;s/^mirrorlist/#mirrorlist/g' /etc/yum.repos.d/rocky*repo
|
||||
dnf -y install kernel-headers-$kver kernel-devel gcc make perl elfutils-libelf-devel
|
||||
sed -i 's/^baseurl/#baseurl/g;s/^#mirrorlist/mirrorlist/g' /etc/yum.repos.d/rocky*repo
|
||||
echo "pub/rocky" > /etc/dnf/vars/contentdir
|
||||
curl -L -o /tmp/vboxadditions.iso https://download.virtualbox.org/virtualbox/7.0.16/VBoxGuestAdditions_7.0.16.iso
|
||||
mkdir -p /media/VBoxGuestAdditions
|
||||
mount -o loop,ro /tmp/vboxadditions.iso /media/VBoxGuestAdditions
|
||||
mkdir -p /tmp/VBoxGuestAdditions
|
||||
sh /media/VBoxGuestAdditions/VBoxLinuxAdditions.run --nox11 --noexec --keep --target /tmp/VBoxGuestAdditions
|
||||
pushd /tmp/VBoxGuestAdditions
|
||||
./install.sh
|
||||
/sbin/rcvboxadd quicksetup all
|
||||
popd
|
||||
ls "/lib/modules/${kver}/misc/"
|
||||
modinfo "/lib/modules/${kver}/misc/vboxsf.ko"
|
||||
rm -rf /tmp/VBoxGuestAdditions
|
||||
umount /media/VBoxGuestAdditions
|
||||
rm -f /tmp/vboxadditions.iso
|
||||
rmdir /media/VBoxGuestAdditions
|
||||
dnf -y remove kernel-devel gcc make perl elfutils-libelf-devel
|
||||
}
|
||||
|
||||
function libvirt_vagrant_steps() {
|
||||
# legacy stuff, we won't have this for 10
|
||||
cat > /etc/sysconfig/network-scripts/ifcfg-eth0 << EOF
|
||||
DEVICE="eth0"
|
||||
BOOTPROTO="dhcp"
|
||||
ONBOOT="yes"
|
||||
TYPE="Ethernet"
|
||||
PERSISTENT_DHCLIENT="yes"
|
||||
EOF
|
||||
}
|
||||
|
||||
#
|
||||
################################################################################
|
||||
|
||||
@ -673,3 +769,14 @@ if [[ "$kiwi_profiles" == *"Container"* ]]; then
|
||||
toolbox_container_steps
|
||||
fi
|
||||
fi
|
||||
|
||||
# Vagrant only
|
||||
if [[ "$kiwi_profiles" == *"Vagrant"* ]]; then
|
||||
common_vagrant_steps
|
||||
if [[ "$kiwi_profiles" == *"Vagrant-Libvirt"* ]]; then
|
||||
libvirt_vagrant_steps
|
||||
fi
|
||||
if [[ "$kiwi_profiles" == *"Vagrant-Vbox"* ]]; then
|
||||
vbox_vagrant_steps
|
||||
fi
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user