Add Packer template from b1-systems/packer-templates

This packer template is usded to create the packstack-vagrant
basebox and should be part of packstack-vagrant.

Change-Id: I8283faaeafb12b9c8be7c85b3fc9ee093cbf154e
This commit is contained in:
Christian Berendt
2015-01-08 10:00:03 +01:00
committed by Christian Berendt
parent 5b68c5f03e
commit e342568a87
8 changed files with 163 additions and 0 deletions

4
packer/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
packer_cache
output-virtualbox-iso
*.box
build.*

View File

@@ -0,0 +1,43 @@
{
"builders": [
{
"vm_name": "centos-packstack",
"type": "virtualbox-iso",
"http_directory": "http",
"iso_url": "http://ftp.halifax.rwth-aachen.de/centos/7.0.1406/isos/x86_64/CentOS-7.0-1406-x86_64-DVD.iso",
"iso_checksum": "713ea7847adcdd1700e92429f212721a",
"iso_checksum_type": "md5",
"guest_os_type": "RedHat_64",
"guest_additions_path": "VBoxGuestAdditions_{{.Version}}.iso",
"virtualbox_version_file": ".vbox_version",
"ssh_username": "vagrant",
"ssh_password": "vagrant",
"ssh_wait_timeout": "10000s",
"headless": "true",
"boot_command": [
"<tab> text ks=http://{{ .HTTPIP }}:{{ .HTTPPort}}/ks.cfg<enter>"
],
"shutdown_command": "echo 'vagrant'|sudo -S shutdown -P now",
"disk_size": 16384,
"hard_drive_interface": "sata",
"vboxmanage": [
["storagectl", "{{.Name}}", "--name", "SATA Controller", "--portcount", "4"]
]
}],
"provisioners": [{
"type": "shell",
"execute_command": "echo 'vagrant' | {{.Vars}} sudo -E -S bash '{{.Path}}'",
"scripts": [
"scripts/update.sh",
"scripts/vbox.sh",
"scripts/sshd.sh",
"scripts/vagrant.sh",
"scripts/cleanup.sh"
]
}],
"post-processors": [{
"type": "vagrant",
"keep_input_artifact": false,
"output": "centos-packstack-7.0.box"
}]
}

81
packer/http/ks.cfg Normal file
View File

@@ -0,0 +1,81 @@
lang en_US.UTF-8
keyboard us
rootpw vagrant
authconfig --enableshadow --enablemd5
timezone UTC
install
cdrom
user --name=vagrant --plaintext --password vagrant
unsupported_hardware
network --bootproto=dhcp
firewall --disabled
selinux --disabled
bootloader --location=mbr
text
skipx
zerombr
clearpart --all --initlabel
autopart --type=plain
firstboot --disabled
reboot
%packages --nobase --ignoremissing --excludedocs
openssh-clients
kernel-headers
kernel-devel
gcc
make
perl
curl
wget
bzip2
dkms
patch
net-tools
git
sudo
nfs-utils
-fprintd-pam
-intltool
-aic94xx-firmware
-atmel-firmware
-b43-openfwwf
-bfa-firmware
-ipw2100-firmware
-ipw2200-firmware
-ivtv-firmware
-iwl100-firmware
-iwl1000-firmware
-iwl105-firmware
-iwl135-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
-libertas-usb8388-firmware
-ql2100-firmware
-ql2200-firmware
-ql23xx-firmware
-ql2400-firmware
-ql2500-firmware
-rt61pci-firmware
-rt73usb-firmware
-xorg-x11-drv-ati-firmware
-zd1211-firmware
%end
%post
echo "%vagrant ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/vagrant
cp /etc/sudoers /etc/sudoers.orig
sed -i "s/^\(.*requiretty\)$/#\1/" /etc/sudoers
echo 'Defaults env_keep += "HTTP_PROXY HTTPS_PROXY FTP_PROXY RSYNC_PROXY NO_PROXY"' >> /etc/sudoers
%end

View File

@@ -0,0 +1,7 @@
#!/usr/bin/env bash
rm -rf /dev/.udev/
rm -rf /tmp/*
dd if=/dev/zero of=/EMPTY bs=1M
rm -f /EMPTY
sync

4
packer/scripts/sshd.sh Normal file
View File

@@ -0,0 +1,4 @@
#!/bin/sh
echo "UseDNS no" >> /etc/ssh/sshd_config
echo "GSSAPIAuthentication no" >> /etc/ssh/sshd_config

4
packer/scripts/update.sh Normal file
View File

@@ -0,0 +1,4 @@
#!/bin/sh
yum update -y
reboot

View File

@@ -0,0 +1,8 @@
#!/bin/sh
mkdir /home/vagrant/.ssh
wget --no-check-certificate \
'https://github.com/mitchellh/vagrant/raw/master/keys/vagrant.pub' \
-O /home/vagrant/.ssh/authorized_keys
chown -R vagrant /home/vagrant/.ssh
chmod -R go-rwsx /home/vagrant/.ssh

12
packer/scripts/vbox.sh Normal file
View File

@@ -0,0 +1,12 @@
#!/bin/sh
VBOX_VERSION=$(cat /home/vagrant/.vbox_version)
mount -o loop /home/vagrant/VBoxGuestAdditions_$VBOX_VERSION.iso /mnt
sh /mnt/VBoxLinuxAdditions.run --nox11
umount /mnt
rm -rf /home/vagrant/VBoxGuestAdditions_$VBOX_VERSION.iso
rm -f /home/vagrant/.vbox_version
if [[ $VBOX_VERSION = "4.3.10" ]]; then
ln -s /opt/VBoxGuestAdditions-4.3.10/lib/VBoxGuestAdditions /usr/lib/VBoxGuestAdditions
fi
yum -y remove gcc cpp kernel-devel kernel-headers perl