Skip to content

Commit

Permalink
Update README, add example
Browse files Browse the repository at this point in the history
  • Loading branch information
fishnix committed May 18, 2017
1 parent 178b9d6 commit a3e3910
Show file tree
Hide file tree
Showing 7 changed files with 285 additions and 0 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Well, I thought it would, so now you can! This currently only works for buildin

This runs during the provisioning process since the machine being provisioned is only available at that time.

There is an example packer build with goss tests in the `example/` directory.

## Configuration

```json
Expand Down Expand Up @@ -40,3 +42,18 @@ This runs during the provisioning process since the machine being provisioned is
]
```

## Author

E. Camden Fisher <[email protected]>

## License

### MIT

Copyright 2017 Yale University

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
47 changes: 47 additions & 0 deletions example/goss/goss.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
port:
tcp:22:
listening: true
ip:
- 0.0.0.0
tcp6:22:
listening: true
ip:
- '::'
service:
sshd:
enabled: true
running: true
user:
sshd:
exists: true
uid: 74
gid: 74
groups:
- sshd
home: /var/empty/sshd
shell: /sbin/nologin
vagrant:
exists: true
groups:
- vagrant
- wheel
home: /home/vagrant
group:
sshd:
exists: true
gid: 74
vagrant:
exists: true
process:
sshd:
running: true
file:
/home/vagrant/.ssh:
exists: true
filetype: directory
/home/vagrant/.ssh/authorized_keys:
filetype: file
exists: true
mode: "0600"
owner: vagrant
group: vagrant
108 changes: 108 additions & 0 deletions example/http/ks7.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
install
url --url=http://mirrors.kernel.org/centos/7/os/x86_64

lang en_US.UTF-8
keyboard us
timezone America/New_York

network --bootproto=dhcp
firewall --disabled

authconfig --enableshadow --passalgo=sha512
selinux --disabled
rootpw changeme

text
skipx

clearpart --all --initlabel
zerombr
autopart
bootloader --location=mbr

firstboot --disabled
reboot

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

-fprintd-pam
-intltool
-avahi
-bluez-utils
-dogtail
-kudzu

# 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
-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
%end

%post
yum update -y

# disable unnecessary services
chkconfig acpid off
chkconfig auditd off
chkconfig blk-availability off
chkconfig bluetooth off
chkconfig certmonger off
chkconfig cpuspeed off
chkconfig cups off
chkconfig haldaemon off
chkconfig ip6tables off
chkconfig lvm2-monitor off
chkconfig messagebus off
chkconfig mdmonitor off
chkconfig rpcbind off
chkconfig rpcgssd off
chkconfig rpcidmapd off
chkconfig yum-updateonboot off

echo 'useDNS no' >> /etc/ssh/sshd_config
yum clean all
%end
66 changes: 66 additions & 0 deletions example/packer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"variables": {
"iso_url": "http://mirrors.rit.edu/centos/7/isos/x86_64/CentOS-7-x86_64-NetInstall-1611.iso",
"iso_checksum": "156f4cb711fdbd668943711f853fb6da89581aad",
"iso_checksum_type ": "sha1"
},
"builders": [
{
"name": "centos-7-x86_64",
"type": "virtualbox-iso",
"communicator": "ssh",
"boot_command": [
"<tab> text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks7.cfg<enter>"
],
"boot_wait": "10s",
"disk_size": 10240,
"headless": true,
"guest_os_type": "RedHat_64",
"http_directory": "http",
"iso_url": "{{user `iso_url`}}",
"iso_checksum": "{{user `iso_checksum`}}",
"iso_checksum_type": "sha1",
"output_directory": "img_centos_7_virtualbox",
"ssh_username": "root",
"ssh_password": "changeme",
"ssh_port": 22,
"ssh_wait_timeout": "20000s",
"ssh_handshake_attempts": 50,
"shutdown_command": "echo 'packer'|sudo -S /sbin/halt -h -p",
"virtualbox_version_file": ".vbox_version",
"hard_drive_interface": "scsi",
"vboxmanage": [
["modifyvm", "{{.Name}}", "--paravirtprovider", "kvm"],
["modifyvm", "{{.Name}}", "--nictype1", "virtio"],
["modifyvm", "{{.Name}}", "--memory", "1024"],
["modifyvm", "{{.Name}}", "--cpus", "1"]
]
}
],
"provisioners" : [
{
"type": "shell",
"scripts": [
"scripts/vagrant.sh"
],
"execute_command": "{{ .Vars }} /bin/sh '{{.Path}}'"
}, {
"type": "goss",
"tests": [
"goss/goss.yaml"
]
},{
"type": "shell",
"scripts": [
"scripts/cleanup.sh",
"scripts/zerodisk.sh"
],
"execute_command": "{{ .Vars }} /bin/sh '{{.Path}}'"
}
],
"post-processors": [
{
"type": "vagrant"
}
]
}
11 changes: 11 additions & 0 deletions example/scripts/cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
echo "Cleaning up ..."

yum -y erase gtk2 libX11 hicolor-icon-theme avahi bitstream-vera-fonts
yum -y clean all
rm -rf /etc/yum.repos.d/{puppetlabs,epel}.repo
rm -rf /etc/yum.repos.d/mysql*.repo
rm -rf VBoxGuestAdditions_*.iso

# Remove traces of mac address from network configuration
sed -i /HWADDR/d /etc/sysconfig/network-scripts/ifcfg-eth0
rm -f /etc/udev/rules.d/70-persistent-net.rules
31 changes: 31 additions & 0 deletions example/scripts/vagrant.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
echo "Configuring vagrant-specific stuff ..."

# Vagrant specific
date > /etc/vagrant_box_build_time

# install wget
yum -y install wget

# disable iptables
/etc/init.d/iptables stop
/sbin/chkconfig iptables off

# Add vagrant user
/usr/sbin/groupadd vagrant
/usr/sbin/useradd vagrant -g vagrant -G wheel
echo "vagrant"|passwd --stdin vagrant
/bin/sed -i 's/[^\!]requiretty/\!requiretty/' /etc/sudoers
/bin/sed -i 's/^\(Default.*secure_path.*$\)/\1:\/usr\/local\/bin/' /etc/sudoers
echo "vagrant ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/vagrant
chmod 0440 /etc/sudoers.d/vagrant

# Speed up ssh connections
/bin/sed -i 's/^#UseDNS.*$/UseDNS no/' /etc/ssh/sshd_config
/bin/sed -i 's/^.*GSSAPIAuthentication.*$/GSSAPIAuthentication no/' /etc/ssh/sshd_config

# Installing vagrant keys
mkdir -pm 700 /home/vagrant/.ssh
wget --no-check-certificate 'https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub' -O /home/vagrant/.ssh/authorized_keys
chmod 0600 /home/vagrant/.ssh/authorized_keys
chown -R vagrant:vagrant /home/vagrant/.ssh

5 changes: 5 additions & 0 deletions example/scripts/zerodisk.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
echo "Zeroing out free space ..."

# Zero out the free space to save space in the final image:
dd if=/dev/zero of=/EMPTY bs=1M
rm -f /EMPTY

0 comments on commit a3e3910

Please sign in to comment.