Creating WebCenter Sites environments, part 2: using Packer

In the first part of this tutorial we got as far as creating recipes with Ansible to automate installation and configuration of WebCenter Sites environments but with two problems: a lack of speed and a horrible hack to get around the problem of limited swap space in our VM. Both of those tools can be solved by using a tool called packer.

Introduction to Packer

I like to think of packer as a golden master producer, it gives you the ability to “create machine and container images for multiple platforms from a single source of configuration.”

Webcenter Sites and Packer

In practice this means we can use packer to create our development environments as self-contained Vagrant boxes (as in boxes with all the provisioning already completed). We could just do this with Vagrant itself but Packer’s real value comes with being able to build for multiple platforms and containers – imagine being able to take our development environment and create it as an AMI for running on Amazon Web Services or as a VMWare VM for deploying into VSphere or even as a docker container.

Imagine being able to create all of our environments from dev all the way through to production from the same version controlled configuration! Exciting stuff indeed.

In the mean time it also means that we can fix our issue with swap space and the Oracle XE installer when we create the our initial virtual machine and as a side effect remove our dependency on the Bento virtual box.

First off we’ll start by looking at how packer works and once we’ve configured the build of our VM we’ll look at adding some Ansible provisioning to automate the install of WebCenter Sites and all it’s associated software.

You can have a look at our sample packer project by cloning it from here

git clone --recursive https://github.com/Manifesto-Digital/wcs-env-tutorial-packer-templates.git

The –recursive switch makes sure we pull in our ansible roles and playbooks which are stored in a separate but linked git repo. These are the same ansible roles and playbooks we used in our last post so if you haven’t already, it’s worth reviewing this again to make sure you’ve got everything in place for the full installation – Creating Web Center Sites Environments

Layout of packer project

+ wcs-centos-6.6-x86_64.json
- ansible
  + hosts
  + wcs.yml
  - group_vars
  - roles
- http
  - centos-6.6
    + ks.cfg
- scripts
  - centos
    + cleanup.sh
    + fix-slow-dns.sh
  - common
    + ansible.sh
    + minimize.sh
    + shutdown.sh
    + sshd.sh
    + sudoers
    + vagrant.sh
    + vmtools.sh
- vagrantfile_templates
  + macosx.rb

The most important file in this list is wcs-centos-6.6-x86_64.json.

It’s the main Packer configuration file and describes the how and what that we’re going to build. Let’s have a look in a little more detail.

At the top level we have the following objects

  • builders
  • post-processors
  • provisioners
  • variables


A builder in Packer is responsible for creating the machines and generating images from them for the platforms we’re targeting (in our case that’s just VirtualBox for now).


This section contains the list of all the provisioners that will be run as part of the creation of a machine image. In our case we’re going to plugin the Ansible playbook and roles that we’ve already developed.

Post processors

Post processors describe any tasks that need to be performed on machine images once the building and provisioning is complete. In our scenario we’re only using one that creates us our vagrant box. However, this would be the place to configure things like pushing a docker build to a registry.


Variables holds any user defined variables we need to use as part of our build.

Packer, provisioners and Ansible

Before we run our Packer build we should talk a little bit about what we need to do to get our Ansible playbook running as a provisioner in Packer.

The following section from our configuration is the pertinent part. It describes two things: firstly installing Ansible in our local environment; and secondly running the Ansible provisioner provided by Packer.

      "type": "shell",
      "execute_command": "echo 'vagrant' | {{.Vars}} sudo -S -E bash '{{.Path}}'",
      "script": "scripts/common/ansible.sh"
      "type": "ansible-local",
      "playbook_file": "ansible/wcs.yml",
      "group_vars": "ansible/group_vars",
      "inventory_file": "ansible/hosts",
      "role_paths": [

In order to install Ansible we’ve written a short shell script that looks like this

#!/bin/bash -eux

# Install EPEL repository.
rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

# Install Ansible.
yum -y install ansible

We then pass some configuration to the Ansible provisioner about where our roles are in our Packer project filesystem, where our inventory file is, where our group variables are and, finally, where our main playbook file is. The playbooks are exactly the same as the ones we used when we we’re working with Vagrant directly.

Now is the time (finally) to run Packer – assuming of course that you haven’t already 😉

packer build wcs-centos-6.6-x86_64.json

You should see a whole series of things start to happen on your machine now: Packer will start by downloading the Centos installer DVD iso (this can take a while); then it will run an unattended installation; finally it will provision the image and then create a Vagrant box.

Once all of this is finished we can add the newly minted Vagrant box to Vagrant using this command

vagrant box add wcs-centos-6.6 builds/wcs-centos-6.6.virtualbox.box

Testing our new Vagrant Box

Now to test we can update our Vagrantfile to look a bit more like this:

# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.

Vagrant.configure(2) do |config|

  config.vm.box = "wcs-centos-6.6"

  # Application server.
  config.vm.define "wcs-server" do |app|
    app.vm.hostname = "wcs."
    app.vm.network :private_network, ip: ""
    app.vm.network "forwarded_port", guest: 8080, host: 8080, auto_correct: true
    app.vm.network "forwarded_port", guest: 1521, host: 1521, auto_correct: true      
    app.vm.network "forwarded_port", guest: 9090, host: 9090, auto_correct: true

This Vagrantfile is now using our newly created box and although we’re still specifying our networking we’ve removed all of the provisioning as it’s not needed. To start it all up run…

vagrant up

… and you should be able to browse to http://wcs. and log in to WCS using the standard fwadmin credentials.

Next steps

Now that you’ve automated the creation of your WebCenter Sites development environments there are a number of directions you could pursue to take things further.

Making the Vagrant boxes accessible

Vagrant can download boxes from URLs so perhaps make it easier for colleagues to get hold of box updates by placing your box on a web server for easier distribution.

Creating other types of machine images

One of the big benefits of Packer is the ability to create multiple machine image formats from one configuration file. How about creating a docker image for your WCS development environments as well?

Let me know how you get on.

Leave a reply

You can use these tags:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Sign up for the Manifesto newsletter and exclusive event invites