{
"builders":
[
{
"type": "qemu",
"iso_url": "file:///devops/packer/images/rhel-server-6.6-x86_64-dvd.iso",
"iso_checksum": "ef031b0ae8458d6489eb277ba1dcb5de",
"iso_checksum_type": "md5",
"output_directory": "output_centos_qcow2",
"ssh_wait_timeout": "30s",
"shutdown_command": "shutdown -P now",
"disk_size": 5000,
"format": "qcow2",
"headless": true,
"accelerator": "kvm",
"http_directory": "httpdir",
"http_port_min": 10082,
"http_port_max": 10089,
"ssh_host_port_min": 2222,
"ssh_host_port_max": 2229,
"ssh_username": "root",
"ssh_password": "MySecretPassword",
"ssh_port": 22,
"ssh_wait_timeout": "900m",
"vm_name": "testvm",
"net_device": "virtio-net",
"disk_interface": "virtio",
"boot_wait": "5s",
"qemuargs": [ "-serial", "file:serial.out" ],
"boot_command":
[
"",
" append console=ttyS0,115200n8 ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/centos6-ks.cfg",
""
]
}
],
"provisioners":
[
{
"type": "shell",
"inline": [
"sleep 3",
"yum -y update",
"yum -y install cloud-init cloud-utils-growpart dracut-modules-growroot",
"echo \"NOZEROCONF=yes\" >> /etc/sysconfig/network",
"adduser build-user",
"echo 'build-user:MySecretPassword' |chpasswd",
"mkdir /home/build-user/.ssh",
"chown build-user:build-user /home/build-user/.ssh",
"chmod 700 /home/build-user/.ssh",
"echo \"build-user ALL=(ALL) ALL\" >> /etc/sudoers",
"yum clean cache",
"yum clean all"
]
},
{
"type": "file",
"source": "centos.json",
"destination": "/root/centos.json",
"source": "httpdir/centos6-ks.cfg",
"destination": "/root/centos6-ks.cfg"
},
{
"type": "file",
"source": "id_rsa_cloud-user.pub",
"destination": "/home/build-user/.ssh/authorized_keys"
},
{
"type": "shell",
"inline": [
"chmod 600 /home/build-user/.ssh/authorized_keys",
"chown build-user:build-user /home/build-user/.ssh/authorized_keys",
"sed -i 's/^SELINUX=.*/SELINUX=permissive/g' /etc/selinux/config",
"echo package_upgrade: true >>/etc/cloud/cloud.cfg"
]
}
]
}
cmdline
skipx
install
# url of CentOS Mirror
lang en_US.UTF-8
keyboard us
rootpw MySecretPassword
# enable firewall, allow ssh
firewall --enabled --ssh
authconfig --enableshadow --passalgo=sha512
# selinux can be disabled during installation, please reenable thereafter
selinux --disabled
timezone Etc/UTC
%include /tmp/kspre.cfg
services --enabled=network,sshd/sendmail
reboot
# because of dependency problems we can not use --nobase (some essencial are missing)
#%packages --nobase
%packages --nobase
selinux-policy-targeted
at
acpid
cronie-noanacron
crontabs
logrotate
mailx
mlocate
openssh-clients
openssh-server
rsync
sendmail
tmpwatch
vixie-cron
which
wget
epel-release
yum
-biosdevname
-postfix
-prelink
%end
%pre
bootdrive=vda
if [ -f "/dev/$bootdrive" ] ; then
exec < /dev/tty3 > /dev/tty3
chvt 3
echo "ERROR: Drive device does not exist at /dev/$bootdrive!"
sleep 5
halt -f
fi
cat >/tmp/kspre.cfg <> /etc/ssh/sshd_config
# at last to clean the image -->
yum clean all
%end