The main tutorial for deploying Cloud Foundry on Vagrant can be found on the following URL:
This tutorial is aimed at Ubuntu users and comes with commands and scripts for such systems. I have listed the steps that I used to deploy Cloud Foundry and elaborated where I deviated from the tutorial. This installation is only for 64-bit systems, as the stem cells are packaged as 64-bit images. It will also not work if you try and run this setup on a virtual machine, since you will be required another VM.This installation is only for 64-bit systems, as the stem cells are packaged as 64-bit images. This also means that this installation will only work on systems that support VT-x or some other hardware virtualization technology (AMD-V for AMD machines). It will also not work if you try and run this setup on a virtual machine, since you will be required another VM. Currently, VT-X can only be used by a single virtual machine.
Package Requirements and Installation
Install Vagrant, Virtualbox Ruby, RubyGems and Bundler:
Bundler [gem install bundler]
Most of the above can be usually done usually synaptic package manager, but I faced issues which made me install proper version so that ‘bundle’ works properly.It appears that vagrant-1.0.1 (a relative old version) is installed, when doing a regular
sudo apt-get install vagrant on stock Ubuntu 12.04, whereas we need a newer Vagrant installation. So download Vagrant from vagrant download site.
Download the bosh-lite repository from github [bosh-lite github] into your work space and run ‘bundle’ from the base directory.
I faced an issue during the run of bundle command which was not mentioned in any documentation. The run of ‘bundle’ failed with specific version of ‘nokogiri’. The version dependency is mentioned in ‘Gemfile’ in your workspace and you need to find the related ‘nokogiri’ version and ensure that the same is mentioned in ‘Gemfile’.
In case you are sitting behind a proxy you will have to specify the proxy configurations in the Vagrantfile (located in the base directory of bosh-lite) as follows:
config.proxy.http = “http://address:port/”
config.proxy.https = “https:// address:port /”
config.proxy.no_proxy = “localhost,127.0.0.1,.example.com”
Setting up the VM
By default the memory is set to 6 GBs and the cores to 4.It is a good idea to configure the a VM_CORES and VM_MEMORY depending on your system. If youe local setup is on a laptop, do necessary changes.
Once the Vagrantfile has been configured it is time to boot up the virtual machine by running the command:
Bosh needs to be told where the virtual machine is hosted. Therefore, as specified in the tutorial set the bosh target to the VM IP (the IP can also be found in the vagrant file):
‘bosh target 192.168.50.4’
The username and password are ‘admin’.
Next the tutorial specifies that the add-route script be run. This script is Linux or Darwin specific.
Upload Warden Stemcell
As specified in the tutorial:
· Download the latest warden stemcell
· Upload it using bosh
‘bosh upload stemcell latest-bosh-stemcell-warden.tgz’
When performing the upload, Minitar (a Ruby gem) was complaining that there is an ‘unexpected end of file’. Normally this should not be the case. However, to solve this, go to the line that is complaining, and change the file open command to read binary (by adding a ‘b’ to the open command). More information can be found here:
Deploying Cloud Foundry
This part resulted in the most number of challenges. To create the manifest file for Cloud Foundry the tutorial recommends using a declarative BOSH deployment manifest builder called Spiff. However, at the point of writing this tutorial spiff only works with Linux or Darwin systems. Therefore the commands to install spiff won’t work directly. The alternate to this is to build spiff on windows from source. To do this, you will need to install Python. Ideally, you would install the 64-bit version of Python, but that does not work well with Bazaar. There are known issues with Python 64-bit (such as http://stackoverflow.com/questions/3008509/python-version-2-6-required-which-was-not-found-in-the-registry). There are also some work around that I did not try (such as http://stackoverflow.com/questions/3652625/installing-setuptools-on-64-bit-windows). The easy solution was to just use 32-bit version of Python. Don’t forget to add it to the environment variables!
Here is where I made the mistake of installing Bazaar to Cygwin (since Bazaar has an installation specifically for Cigwin), instead of directly installing it on Windows. This caused quite a few problems since Python was not able to locate Bazaar. The solution was to download Bazaar locally on Windows [http://wiki.bazaar.canonical.com/WindowsDownloads]. Spiff will also require you to install Go [http://golang.org/doc/install] and add the GOPATH to the environment variables. Run the commands
‘go get -v github.com/cloudfoundry-incubator/spiff’
If spiff was able to install correctly it will list the options. There might be the case the Bazaar complains about and SSL certificate verification. To disable it run the following command
‘bzr config ssl.cert_reqs=none’
Since this command is branch specific, it might not work. To do it globally go to UserAppDataRoamingbazaar2.0 and add it to the bazaar.conf file. If the file does not exist then create it.
Following back the tutorial, run the following after deciding on the release.
‘git checkout v’
The tutorial then moves on to running the scripts/make_manifest_spiff script. To run this you would need to change all the relative paths to absolute. Since Cygwin uses a different set of paths than Windows, it causes some mapping issues with spiff (which is now installed on Windows). The paths would also be need to change in ~/ workspace/cf-release/generate_deployment_manifest. Once these changes have been made the make_manifest_spiff can be run.
The next step is to upload the release:
‘bosh upload release releases/cf-.yml’
In case you are behind a proxy you will need to add the mapping of the IP to the host. To allow Cloud Foundry CLI to be able to connect to the different containers, add the following to the ‘C:WindowsSystem32driversetchosts’
Download the cloud foundry command line by running
‘gem install cf’
Use it to login first by running:
‘cf login –username –password ’
Most likely, you should be able to login successfully. In my case I got the following error:
I solved it by explicitly adding the ha-proxy IP in the /etc/hosts for the login container. Probably not the best solution, but works:
Running the test on windows is a more complicated issue as the gems such as blue-shell and vcap-logging use POSIX specific Ruby libraries such as PTY and syslog.