From 691fb8d9363674235cdd157942cb90b0a3dfe704 Mon Sep 17 00:00:00 2001 From: Tomasz Sikora Date: Sat, 28 Mar 2015 20:24:43 +0100 Subject: [PATCH] Add Packer template with CentOS, Guest Additions and nvm Running some of the NodeSchool workshoppers can be tricky on Windows platform. To decrease preparation time for workshops a VM/OVA generated by the template can be used. In addition the VM includes all native dependencies the workshoppers (#12). --- tools/packer/centos-cmd.json | 38 ++++++++++ tools/packer/http/ks.cfg | 73 +++++++++++++++++++ .../packer/scripts/install-guest-additions.sh | 5 ++ tools/packer/scripts/install-nvm.sh | 5 ++ 4 files changed, 121 insertions(+) create mode 100644 tools/packer/centos-cmd.json create mode 100644 tools/packer/http/ks.cfg create mode 100755 tools/packer/scripts/install-guest-additions.sh create mode 100755 tools/packer/scripts/install-nvm.sh diff --git a/tools/packer/centos-cmd.json b/tools/packer/centos-cmd.json new file mode 100644 index 0000000..16e26f5 --- /dev/null +++ b/tools/packer/centos-cmd.json @@ -0,0 +1,38 @@ +{ + "provisioners": [{ + "type": "shell", + "execute_command": "sudo {{.Vars}} bash {{.Path}}", + "scripts": [ + "scripts/install-guest-additions.sh" + ]}, { + "type": "shell", + "execute_command": "{{.Vars}} bash {{.Path}}", + "scripts": [ + "scripts/install-nvm.sh" + ]} + ], + "builders": [{ + "vm_name": "nodeschool-vm", + "type": "virtualbox-iso", + "format": "ova", + "guest_os_type": "RedHat_64", + "iso_url": "http://ftp.pbone.net/pub/centos/7/isos/x86_64/CentOS-7.0-1406-x86_64-Minimal.iso", + "iso_checksum_type": "sha256", + "iso_checksum": "04e99a4f1a013b95a7ebc9a90ffa9ac64d28eb9872bc193fbd7c581ec9b6a360", + "hard_drive_interface": "sata", + "disk_size": "5000", + "headless": false, + "ssh_username": "vagrant", + "ssh_password": "vagrant", + "guest_additions_mode": "upload", + "http_directory": "http", + "boot_command": [ + " text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg" + ], + "shutdown_command": "echo 'Packer says bye ;-)' | sudo /sbin/halt -p", + "vboxmanage": [ + [ "modifyvm", "{{.Name}}", "--memory", "512" ], + [ "modifyvm", "{{.Name}}", "--cpus", "1" ] + ] + }] +} diff --git a/tools/packer/http/ks.cfg b/tools/packer/http/ks.cfg new file mode 100644 index 0000000..87fb000 --- /dev/null +++ b/tools/packer/http/ks.cfg @@ -0,0 +1,73 @@ +# More about kickstart script for Centos at: +# https://www.centos.org/docs/5/html/Installation_Guide-en-US/s1-kickstart2-file.html + +## Kickstart options + +install +cdrom +repo --name base --baseurl=http://ftp.pbone.net/pub/centos/7/os/x86_64/ +repo --name updates --baseurl=http://ftp.pbone.net/pub/centos/7/updates/x86_64/ +repo --name epel --baseurl=https://dl.fedoraproject.org/pub/epel/7/x86_64/ + +lang pl_PL.UTF-8 +keyboard pl +network --onboot yes --device eth0 --bootproto dhcp --noipv6 +# Root password, allows to be consistent with with Vagrant requirements +rootpw --plaintext vagrant +firewall --enabled --service=ssh +authconfig --enableshadow --passalgo=sha512 +# We don't need SELinux on workshop machines +selinux --disabled +timezone Europe/Warsaw +bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet" + +# Perform installation in text mode +text +# Skips X configuration +skipx + +zerombr +clearpart --all --initlabel +autopart + +auth --useshadow --enablemd5 +firstboot --disabled +reboot + +## Packages to be installed + +%packages +@core +-ipw2100-firmware +-ipw2200-firmware +-ivtv-firmware +sudo +bzip2 +kernel-devel +kernel-headers +gcc +gcc-c++ +wget +git + +### workshopper dependencies +# - shader-school (node-canvas) +cairo +cairo-devel +cairomm-devel +libjpeg-turbo-devel +pango +pango-devel +pangomm +pangomm-devel +giflib-devel + +%end + +%post +/usr/sbin/groupadd -g 501 vagrant +/usr/sbin/useradd vagrant -u 501 -g vagrant -G wheel +echo "vagrant" | passwd --stdin vagrant +echo "vagrant ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/vagrant +chmod 0440 /etc/sudoers.d/vagrant +%end \ No newline at end of file diff --git a/tools/packer/scripts/install-guest-additions.sh b/tools/packer/scripts/install-guest-additions.sh new file mode 100755 index 0000000..e00ef1b --- /dev/null +++ b/tools/packer/scripts/install-guest-additions.sh @@ -0,0 +1,5 @@ +mkdir /mnt/guest +mount -o loop /home/vagrant/VBoxGuestAdditions.iso /mnt/guest +sh /mnt/guest/VBoxLinuxAdditions.run +umount /mnt/guest +rm -rf /home/vagrant/VBoxGuestAdditions.iso /mnt/guest diff --git a/tools/packer/scripts/install-nvm.sh b/tools/packer/scripts/install-nvm.sh new file mode 100755 index 0000000..65c3f23 --- /dev/null +++ b/tools/packer/scripts/install-nvm.sh @@ -0,0 +1,5 @@ +curl https://raw.githubusercontent.com/creationix/nvm/v0.24.0/install.sh | bash +source ~/.nvm/nvm.sh +nvm install 0.12 # for 'shader-school' +nvm install iojs +nvm alias default iojs