Hi Folks!


In this post, I will introduce you about packer. Packer is actually open source tool for creating machine and container images for multiple platforms from single source of configuration. As a configuration It uses a json syntax for creating machines for different platforms such as  Amazon EC2, Docker, VirtualBox, VMware etc. Actually I will not get into more detail. For more information please visit website. As an example, I created very simple configuration for VMware Workstation platform by installing CentOS 7 without keyboard interaction. For non-interactive installation(kick-start installation). I have used kickstart file. Next tutorial will be about kick-start installation of RedHat system.

Installing Packer:

I have a CentOS 7 system, So you can download file by using wget command.(Figure-1)

For 64 bit system.

[root@hulk ~]# wget -O

Figure-1 Download file

Unzip the file.

[root@hulk ~]# unzip

Usage of Packer:

You can run packer the same as ordinary executable Linux file like below.(Figure-2)

./packer -h
usage: packer [--version] [--help] <command> [<args>]

Available commands are:
    build       build image(s) from template
    fix         fixes templates from old versions of packer
    inspect     see components of a template
    push        push a template and supporting files to a Packer build service
    validate    check that a template is valid
    version     Prints the Packer version

Figure-2 Usage of Packer

We have packer, but we do not have any configuration file to tell the packer what to do. Below, I shared very simple packer configuration for VMware Workstation platform to give you an overview. For other platforms please see packer documents. Plus, For auto-installation, you will need a machine to serve kick-start.(dhcp, tftp, http). Do not worry! Next tutorial will be about kick-start installation. So For now, stick with packer configuration.

    "builders": [{
        "name": "centos-latest",
        "type": "vmware-iso",
        "guest_os_type": "centos-64",
        "tools_upload_flavor": "linux",
        "iso_url": "",
        "iso_checksum": "27bd866242ee058b7a5754e83d8ee8403e216b93d130d800852a96f41c34d86a",
        "iso_checksum_type": "sha256",
        "ssh_username": "root",
        "ssh_password": "vagrant",
        "ssh_port": "22",
        "ssh_host": "",
        "ssh_wait_timeout": "10000s",
        "shutdown_timeout": "20s",
        "shutdown_command": "shutdown -P now",
        "vm_name": "mypacker",
        "format": "vmx",
        "boot_wait": "10s",
        "http_directory": "/var/www/html/http",
        "http_port_min": "8008",
        "http_port_max": "8008",
        "disk_size": "12000",
        "vmx_data": {
        "cpuid.coresPerSocket": "1",
        "memsize": "1024",
        "numvcpus": "1",
        "ethernet0.present": "TRUE",
        "ethernet0.connectionType": "nat"

        "boot_command": [
        "<tab> ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg<enter><wait>"


    "provisioners": [
    "type": "shell",
    "inline": [
      "touch /home/vagrant/test1234.packer",
      "echo 'Hello Packer !' > /home/vagrant/test1234.packer"


Figure-3 Simple packer directive first.json file

Verify first.json with Packer

Before building a machine, configuration file should be verified for error-free.

[root@hulk packer]# ./packer validate first.json
Template validated successfully.

Build first.json with Packer

After successful validation, we can build our guest on VMware Workstation. Just run ./packer build first.json. While packer is building,  take some coffee 🙂

[root@hulk packer]# ./packer build first.json

Figure-4 Packer building


Kickstart File

Kickstart(ks.cfg) is  a actually configuration file for RedHat based systems to install system without human interaction. In doing so, hundreds of system can be installed just a snippet of directives.(Figure-4)

# System authorization information
auth --enableshadow --passalgo=sha512
# Use CDROM installation media
url --url
# Use graphical install
# Run the Setup Agent on first boot
firstboot --enable
ignoredisk --only-use=sda
# Keyboard layouts
keyboard --vckeymap=tr --xlayouts='tr'
# System language
lang en_US.UTF-8
# Network information
network  --bootproto static --device=ens33 --gateway --ip --nameserver, --netmask=  --activate
network  --hostname vagrant.tbag.local

# Root password
rootpw vagrant --plaintext
# System services
services --disabled="chronyd"
# System timezone
timezone Europe/Istanbul --isUtc --nontp
user --name=vagrant --password=vagrant --plaintext
# System bootloader configuration
bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda
# Partition clearing information
clearpart --none --initlabel
# Disk partitioning information
autopart --type=lvm



Figure-4 Sample Kickstart File






Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.