Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scientific Linux packer built vagrant box #1051

Merged
merged 1 commit into from
Jun 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions scientificlinux/SL-7-x86_64.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
{
"builders": [
{
"boot_command": [
"<up><wait><tab> text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/{{user `ks_path`}}<enter><wait>"
],
"boot_wait": "10s",
"disk_size": "{{user `disk_size`}}",
"guest_additions_path": "VBoxGuestAdditions_{{.Version}}.iso",
"guest_os_type": "RedHat_64",
"hard_drive_interface": "sata",
"headless": "{{ user `headless` }}",
"http_directory": "http",
"iso_checksum": "{{user `iso_checksum`}}",
"iso_checksum_type": "{{user `iso_checksum_type`}}",
"iso_url": "{{user `mirror`}}/{{user `mirror_directory`}}/{{user `iso_name`}}",
"output_directory": "../builds/packer-{{user `template`}}-virtualbox",
"shutdown_command": "echo 'vagrant' | sudo -S /sbin/halt -h -p",
"ssh_password": "vagrant",
"ssh_port": 22,
"ssh_username": "vagrant",
"ssh_wait_timeout": "10000s",
"type": "virtualbox-iso",
"vboxmanage": [
[
"modifyvm",
"{{.Name}}",
"--memory",
"{{ user `memory` }}"
],
[
"modifyvm",
"{{.Name}}",
"--cpus",
"{{ user `cpus` }}"
]
],
"virtualbox_version_file": ".vbox_version",
"vm_name": "{{ user `template` }}"
}
],
"post-processors": [
{
"output": "../builds/{{user `box_basename`}}.{{.Provider}}.box",
"type": "vagrant"
}
],
"provisioners": [
{
"environment_vars": [
"HOME_DIR=/home/vagrant",
"http_proxy={{user `http_proxy`}}",
"https_proxy={{user `https_proxy`}}",
"no_proxy={{user `no_proxy`}}"
],
"execute_command": "echo 'vagrant' | {{.Vars}} sudo -S -E sh -eux '{{.Path}}'",
"expect_disconnect": true,
"scripts": [
"scripts/update.sh",
"../_common/sshd.sh",
"scripts/networking.sh",
"../_common/vagrant.sh",
"../_common/virtualbox.sh",
"scripts/cleanup.sh",
"../_common/minimize.sh"
],
"type": "shell"
}
],
"variables": {
"box_basename": "SL-7.3",
"build_timestamp": "{{isotime \"20080506150405\"}}",
"cpus": "1",
"disk_size": "65536",
"git_revision": "__unknown_git_revision__",
"headless": "",
"http_proxy": "{{env `http_proxy`}}",
"https_proxy": "{{env `https_proxy`}}",
"hyperv_generation": "1",
"hyperv_switch": "{{env `hyperv_switch`}}",
"iso_checksum": "ef3dd1b2a45c81b682a42d39ed3088e8649f836c32900331935f7a26e6ee316a",
"iso_checksum_type": "sha256",
"iso_name": "SL-7-DVD-x86_64.iso",
"ks_path": "7/ks.cfg",
"memory": "1024",
"mirror": "http://mirrors.up.pt/pub/scientific/",
"mirror_directory": "7.3/x86_64/iso",
"name": "SL-7.3",
"no_proxy": "{{env `no_proxy`}}",
"template": "SL-7-x86_64",
"version": "TIMESTAMP"
}
}
92 changes: 92 additions & 0 deletions scientificlinux/http/7/ks.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
install
cdrom
lang en_US.UTF-8
keyboard us
network --bootproto=dhcp --onboot=on --device=eth0
rootpw vagrant
firewall --disabled
selinux --permissive
timezone UTC
unsupported_hardware
bootloader --location=mbr
text
skipx
zerombr
clearpart --all --initlabel
autopart
auth --enableshadow --passalgo=sha512 --kickstart
firstboot --disabled
reboot --eject
user --name=vagrant --plaintext --password vagrant

%packages --nobase --ignoremissing --excludedocs
# vagrant needs this to copy initial files via scp
openssh-clients
sudo
kernel-headers
kernel-devel
gcc
make
perl
selinux-policy-devel
wget
nfs-utils
net-tools
bzip2
-fprintd-pam
-intltool

# unnecessary firmware
-aic94xx-firmware
-atmel-firmware
-b43-openfwwf
-bfa-firmware
-ipw2100-firmware
-ipw2200-firmware
-ivtv-firmware
-iwl100-firmware
-iwl105-firmware
-iwl135-firmware
-iwl1000-firmware
-iwl2000-firmware
-iwl2030-firmware
-iwl3160-firmware
-iwl3945-firmware
-iwl4965-firmware
-iwl5000-firmware
-iwl5150-firmware
-iwl6000-firmware
-iwl6000g2a-firmware
-iwl6000g2b-firmware
-iwl6050-firmware
-iwl7260-firmware
-iwl7265-firmware
-libertas-usb8388-firmware
-libertas-sd8686-firmware
-libertas-sd8787-firmware
-ql2100-firmware
-ql2200-firmware
-ql23xx-firmware
-ql2400-firmware
-ql2500-firmware
-rt61pci-firmware
-rt73usb-firmware
-xorg-x11-drv-ati-firmware
-zd1211-firmware
-alsa-tools-firmware
-alsa-firmware
-kernel-firmware
%end

%post
# sudo
echo "%vagrant ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/vagrant

#Enable hyper-v daemons only if using hyper-v virtualization
if [ $(virt-what) == "hyperv" ]; then
yum -y install hyperv-daemons cifs-utils
systemctl enable hypervvssd
systemctl enable hypervkvpd
fi

%end
59 changes: 59 additions & 0 deletions scientificlinux/scripts/cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/sh -eux

# should output one of 'redhat' 'centos' 'oraclelinux'
distro="`rpm -qf --queryformat '%{NAME}' /etc/redhat-release | cut -f 1 -d '-'`"

# Remove development and kernel source packages
yum -y remove gcc cpp kernel-devel kernel-headers;

if [ "$distro" != 'redhat' ]; then
yum -y clean all;
fi

# Clean up network interface persistence
rm -f /etc/udev/rules.d/70-persistent-net.rules;
mkdir -p /etc/udev/rules.d/70-persistent-net.rules;
rm -f /lib/udev/rules.d/75-persistent-net-generator.rules;
rm -rf /dev/.udev/;

for ndev in `ls -1 /etc/sysconfig/network-scripts/ifcfg-*`; do
if [ "`basename $ndev`" != "ifcfg-lo" ]; then
sed -i '/^HWADDR/d' "$ndev";
sed -i '/^UUID/d' "$ndev";
fi
done

# new-style network device naming for centos7
if grep -q -i "release 7" /etc/redhat-release ; then
# radio off & remove all interface configration
nmcli radio all off
/bin/systemctl stop NetworkManager.service
for ifcfg in `ls /etc/sysconfig/network-scripts/ifcfg-* |grep -v ifcfg-lo` ; do
rm -f $ifcfg
done
rm -rf /var/lib/NetworkManager/*

echo "==> Setup /etc/rc.d/rc.local for CentOS7"
cat <<_EOF_ | cat >> /etc/rc.d/rc.local
#BENTO-BEGIN
LANG=C
# delete all connection
for con in \`nmcli -t -f uuid con\`; do
if [ "\$con" != "" ]; then
nmcli con del \$con
fi
done
# add gateway interface connection.
gwdev=\`nmcli dev | grep ethernet | egrep -v 'unmanaged' | head -n 1 | awk '{print \$1}'\`
if [ "\$gwdev" != "" ]; then
nmcli c add type eth ifname \$gwdev con-name \$gwdev
fi
sed -i "/^#BENTO-BEGIN/,/^#BENTO-END/d" /etc/rc.d/rc.local
chmod -x /etc/rc.d/rc.local
#BENTO-END
_EOF_
chmod +x /etc/rc.d/rc.local
fi

# delete any logs that have built up during the install
find /var/log/ -name *.log -exec rm -f {} \;
19 changes: 19 additions & 0 deletions scientificlinux/scripts/networking.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh -eux

case "$PACKER_BUILDER_TYPE" in

virtualbox-iso|virtualbox-ovf)
major_version="`sed 's/^.\+ release \([.0-9]\+\).*/\1/' /etc/redhat-release | awk -F. '{print $1}'`";

if [ "$major_version" -ge 6 ]; then
# Fix slow DNS:
# Add 'single-request-reopen' so it is included when /etc/resolv.conf is
# generated
# https://access.redhat.com/site/solutions/58625 (subscription required)
echo 'RES_OPTIONS="single-request-reopen"' >>/etc/sysconfig/network;
service network restart;
echo 'Slow DNS fix applied (single-request-reopen)';
fi
;;

esac
5 changes: 5 additions & 0 deletions scientificlinux/scripts/update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh -eux

yum -y update;
reboot;
sleep 60;