Installing Cloud Foundry on Vagrant

June 27, 2013 Andy Piper

featured-cf-genericThis is a guest blog post by Altoros, a software development firm specializing in PaaS enablement and integration services around Hadoop and NoSQL.

Cloud Foundry is by default a highly distributed multi-tenant platform that is usually deployed at scale (>40 nodes) on top of existing virtualized infrastructure (e.g., VMware vSphere or vCloud, Amazon AWS or OpenStack). For the novice Cloud Foundry developer, a full scale PaaS deployment isn’t always an affordable choice. To address this issue, the Cloud Foundry team released Micro Cloud Foundry as a virtual machine image that could be run on a laptop. Micro Cloud Foundry behaved much like a production cloud and provided developers a sandbox to play with. An alternative to using Micro Cloud Foundry on a virtual machine is to install Cloud Foundry natively on a development tool such as Vagrant.

What is Vagrant?

Vagrant is really a developer’s VM toolbox, as it provides an easy way to create and configure lightweight, reproducible, and portable development environments. It sits on top of a virtualization layer such as Virtualbox, VMware Fusion or VMware Workstation. The VM definition and configuration file (Vagrantfile) is part of the versioned source code repository.

Cloud Foundry on Vagrant

The Cloud Foundry deployment on Vagrant is a self-contained partial Cloud Foundry v2 installation which runs inside of a Vagrant-managed VM with Ubuntu 12.04.2 LTS. To get started, you need to download and install Vagrant. After that, just follow the step by step directions for deploying the Cloud Foundry Vagrant installer on Github.

You should be able to setup and configure everything in under 30 minutes, and easily push a simple Ruby Sinatra web application on the local Cloud Foundry PaaS.


Vagrant allows you to run Chef recipes after booting up the VM (these are located under the chef directory). Every time you bring up a VM (vagrant up), it will check the Chef folder and determine if any recipes should be run. The first time the Vagrant image is started, it will take some time to install all of the required packages.

The number of Chef recipes may be limited, so be sure to use Berkshelf to manage your cookbooks or their dependencies. Berkshelf maintains proven and stable recipes downloaded from OpsCode. Big thanks to Scott Frederick aka @scottyfred who provided the contribution of Berkshelf support!

Starting and Stopping Cloud Foundry Components

There are two main ways to start or stop the Cloud Foundry components. Most operators prefer to use and which are bash scripts that launch upstart commands to run the components.

$ cd /vagrant
$ ./
cf-ng start/running

# Verify  running processes
$ ps ax
11733 ?        S      0:00 /bin/bash ./bin/file_server
11734 ?        S      0:00 /bin/bash ./bin/dea_ng
11739 ?        Sl     0:00 ruby spec/bin/file_server.rb
11745 ?        S      0:00 /bin/bash ./bin/dir_server
11750 ?        Sl     0:00 ruby /home/vagrant/.rbenv/versions/1.9.3-p392/bin/nats-server
11752 ?        Sl     0:01 ruby bin/dea config/dea.yml
11759 ?        S      0:00 /bin/bash ./bin/warden
11766 ?        Sl     0:00 ruby /home/vagrant/.rbenv/versions/1.9.3-p392/bin/rake dir_server:run
11793 ?        S      0:00 bash /home/vagrant/.rbenv/plugins/rbenv-sudo/bin/rbenv-sudo bundle exec rake warden:start[config/test_vm.yml]
11842 ?        S      0:00 /bin/bash ./bin/health_manager
11852 ?        S      0:00 /bin/bash ./bin/gorouter
11861 ?        S      0:00 /bin/bash ./bin/cloud_controller
11865 ?        Sl     0:00 ruby ./bin/health_manager
11866 ?        S      0:00 sudo env PATH=/home/vagrant/.rbenv/shims:/home/vagrant/.rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin bundle exec rake warden:start[config/test_vm.yml]
11877 ?        S      0:00 sudo ./bin/router -c=config/gorouter.yml
11878 ?        Sl     0:00 ruby /home/vagrant/.rbenv/versions/1.9.3/bin/rake warden:start[config/test_vm.yml]
11896 ?        Sl     0:00 ./bin/router -c=config/gorouter.yml
11946 ?        S      0:00 /bin/bash ./bin/uaa
11951 ?        Sl     0:29 /usr/lib/jvm/default-java/bin/java -classpath /usr/share/maven/boot/plexus-classworlds-2.x.jar -Dclassworlds.conf=/usr/share/maven/bin/m2.conf -Dmaven.home=/usr/share/maven org
12012 ?        Sl     0:00 go/bin/runner -conf config/dea.yml
12103 ?        Sl     0:02 ruby bin/cloud_controller -m

An alternate method is to use Foreman to declare the processes required to run your application in a single file: Procfile. Foreman is a useful Ruby gem that allows you to run several processes with only one command (foreman start). Foreman will start and the display the stdout and stderr of each process – this is useful because you can see all the logs in one terminal with different colors for each process. The scripts below were generated using Foreman (via foreman export).

Our Procfile

nats: nats-server
warden: ./bin/warden
uaa: ./bin/uaa
dir_server: ./bin/dir_server
file_server: ./bin/file_server
dea_ng: ./bin/dea_ng
gorouter: ./bin/gorouter
cc_ng: ./bin/cloud_controller
health_manager: ./bin/health_manager

Foreman output (colored)

foreman output

Custom Config Files

Vagrant uses the Cloud Foundry source code, downloaded directly from the corresponding Github repository for each module (CCNG, Router, NATS, DEA, etc). The .gitmodules file contains configuration details that can be customized or adapted for local installation onto Vagrant. The following are a few examples of different customizations for local Cloud Foundry deployments.

To add logging and increase the verbosity of the logging stream:

  file: /vagrant/logs/cloud_controller.log
  level: debug2

To make a DB persistent after VM shutdown, configure it in the corresponding custom_config_files/cloud_controller_ng/cloud_controller.yml file.

  database: "sqlite:///vagrant/db/cloud_controller.db"

To set as default domain, which is pointed to localhost:

Domain in cloud_controller.yml:


There are more examples and detailed changes recommended to the configuration files in the documentation on Altoros’s Github Vagrant Installer.

Building the Virtual Machine

We won’t duplicate the instructions to build the Cloud Foundry virtual machine in this blog post. Just follow the step-by-step instructions provided and you’ll have a Cloud Foundry v2 instance in a matter of minutes.

Learn More About Cloud Foundry

Cloud Foundry on Vagrant is a great tool for learning about the inner workings of Cloud Foundry and its various components. As always, don’t forget to refer to the great wealth of documentation available at the Cloud Foundry project page, and in particular the sections on using and running Cloud Foundry. Also, if you’re a developer you should signup and subscribe to the mailing list.

You can also find more information on the web about Cloud Foundry, including these popular sites:

Feel free to leave us feedback on your experience deploying Cloud Foundry on Vagrant and be sure to check back frequently for updates and improvements on the Github project.

About the Author


5 Key Highlights: A Field Report from #HadoopSummit
5 Key Highlights: A Field Report from #HadoopSummit

In this field report from the Hadoop Summit, we cover community growth, the focus on real-time data, SQL on...

New in Pivotal Tracker – Story following and user @mentions
New in Pivotal Tracker – Story following and user @mentions

It’s now even easier to collaborate with your teammates and keep the right people up to date. We’re very ex...


Subscribe to our Newsletter

Thank you!
Error - something went wrong!