Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Initial packer setup
Jim Van Fleet committed Jul 7, 2016
1 parent 97ba6b2 commit e42bc5c
Showing 7 changed files with 219 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .gitignore
@@ -0,0 +1,5 @@
packer_cache/*
*.box
iso/*
output-virtualbox-iso/*
builds/*
49 changes: 47 additions & 2 deletions README.md
@@ -1,2 +1,47 @@
# packer-centos-7
Packaging instructions for VM appliances
# Packer Image Builder for CentOS

## Introduction

This packer templates create vmware image of CentOS 7 with `.vmx` file type.

The OS versions are:

- Centos 7

For all operating systems we generate images for

- VmWare (user: packer/changeme1234)

This template only is tested against 64 bit systems. With the following sizing requirements:
```
"vmx_data": {
"cpuid.coresPerSocket": "1",
"memsize": "512",
"numvcpus": "2"
}
```

```
"disk_size": 81920
```

## Requirements

The templates are only tested with [packer](http://www.packer.io/downloads.html) 0.10.1 and later.

## Run conversion process

# Build CentOS VMWare image
PACKER_LOG=1 packer build centos7.json

## Issues during build time

If you experience issues with packer, please use `PACKER_LOG=1 packer ... ` to find the errors.

## Author

- Author:: Mason Packard (<mason.packard@levvel.io>)

# License

TBD
8 changes: 8 additions & 0 deletions ansible/main.yml
@@ -0,0 +1,8 @@
---
- hosts: all
become: yes
gather_facts: yes

tasks:
- name: "Run the Playbook"
shell: echo "<-------~ Playbook Start ~---------->"
58 changes: 58 additions & 0 deletions centos7.json
@@ -0,0 +1,58 @@
{
"provisioners": [
{
"type": "shell",
"execute_command": "echo 'packer' | {{.Vars}} sudo -S -E bash '{{.Path}}'",
"script": "scripts/ansible.sh"
},
{
"type": "ansible-local",
"playbook_file": "ansible/main.yml"
},
{
"type": "shell",
"execute_command": "echo 'packer' | {{.Vars}} sudo -S -E bash '{{.Path}}'",
"script": "scripts/cleanup.sh"
}
],
"builders": [
{
"type": "vmware-iso",
"name": "centos-7-vmx",
"boot_command": [
"<tab> text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg<enter><wait>"
],
"boot_wait": "10s",
"disk_size": 81920,
"guest_os_type": "centos-64",
"headless": true,
"http_directory": "http",
"iso_urls": [
"CentOS-7-x86_64-Minimal-1511.iso",
"http://mirror.vcu.edu/pub/gnu+linux/centos/7/isos/x86_64/CentOS-7-x86_64-Minimal-1511.iso"
],
"iso_checksum_type": "md5",
"iso_checksum": "88c0437f0a14c6e2c94426df9d43cd67",
"output_directory": "img-centos-7-vmware",
"ssh_username": "packer",
"ssh_password": "changeme1234",
"ssh_port": 22,
"ssh_wait_timeout": "10000s",
"shutdown_command": "echo 'packer'|sudo -S /sbin/halt -h -p",
"tools_upload_flavor": "linux",
"vm_name": "packer-centos-7-x86_64",
"vmdk_name": "packer-centos-7-x86_64-disk0",
"vmx_data": {
"cpuid.coresPerSocket": "1",
"memsize": "512",
"numvcpus": "2"
}
}
],
"post-processors": [
{
"output": "builds/packer_centos7_{{.BuilderType}}.tar",
"type": "compress"
}
]
}
83 changes: 83 additions & 0 deletions http/ks.cfg
@@ -0,0 +1,83 @@
install
cdrom
lang en_US.UTF-8
keyboard us
unsupported_hardware
network --bootproto=dhcp
rootpw changeme1234
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
eula --agreed
services --enabled=NetworkManager,sshd
reboot
user --name=packer --plaintext --password changeme1234 --groups=tier_group,wheel

%packages --ignoremissing --excludedocs
@Base
@Core
@Development Tools
openssh-clients
sudo
openssl-devel
readline-devel
zlib-devel
kernel-headers
kernel-devel
net-tools
vim
wget
curl
rsync

# unnecessary firmware
-aic94xx-firmware
-atmel-firmware
-b43-openfwwf
-bfa-firmware
-ipw2100-firmware
-ipw2200-firmware
-ivtv-firmware
-iwl100-firmware
-iwl1000-firmware
-iwl3945-firmware
-iwl4965-firmware
-iwl5000-firmware
-iwl5150-firmware
-iwl6000-firmware
-iwl6000g2a-firmware
-iwl6050-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
yum update -y

# update root certs
wget -O/etc/pki/tls/certs/ca-bundle.crt http://curl.haxx.se/ca/cacert.pem

# sudo
yum install -y sudo
echo "packer ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/packer
sed -i "s/^.*requiretty/#Defaults requiretty/" /etc/sudoers

yum clean all
%end
7 changes: 7 additions & 0 deletions scripts/ansible.sh
@@ -0,0 +1,7 @@
#!/bin/bash -eux

# Install EPEL repository.
yum -y install epel-release

# Install Ansible.
yum -y install ansible
11 changes: 11 additions & 0 deletions scripts/cleanup.sh
@@ -0,0 +1,11 @@
#!/bin/bash -eux

# Remove Ansible and its dependencies.
yum -y remove ansible

# Zero out the rest of the free space using dd, then delete the written file.
dd if=/dev/zero of=/EMPTY bs=1M
rm -f /EMPTY

# Add `sync` so Packer doesn't quit too early, before the large file is deleted.
sync

0 comments on commit e42bc5c

Please sign in to comment.