Commit 4100b6db authored by Corey Hinshaw's avatar Corey Hinshaw

Added Vagrant development files

parent b2f86eb9
......@@ -14,4 +15,16 @@ bin/*
# OS files
......@@ -21,9 +21,9 @@ Cookbook has been tested and it is known to work on:
## Installation
* [Development installation on a virtual machine with Vagrant](doc/
* [Development installation](doc/
* [Development installation on metal (outside a Virtual Machine)](doc/ May run much faster than inside a VM.
* [Development installation on a virtual machine with Vagrant](doc/
* [Production installation on Amazon Web Services (AWS) with Vagrant](doc/
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Throw an error if required Vagrant plugins are not installed
plugins = { 'vagrant-berkshelf' => '2.0.1', 'vagrant-omnibus' => nil, 'vagrant-bindfs' => nil }
plugins.each do |plugin, version|
unless Vagrant.has_plugin? plugin
error = "The '#{plugin}' plugin is not installed! Try running:\nvagrant plugin install #{plugin}"
error += " --plugin-version #{version}" if version
raise error
# You can ask for more memory and cores when creating your Vagrant machine:
# Determine if we need to forward ports
Vagrant.configure("2") do |config|
config.vm.hostname = "gitlab-dev" = "precise64"
config.vm.box_url = ""
config.vm.provider "vmware_fusion" do |vmware, override| = "precise64_fusion"
override.vm.box_url = ""
# Assign this VM to a host-only network IP, allowing you to access it
# via the IP. Host-only networks can talk to the host machine as well as
# any other machines on the same network, but cannot be accessed (through this
# network interface) by any external networks. :private_network, ip: ""
if FORWARD.to_i > 0 :forwarded_port, guest: 3000, host: 3000 :forwarded_port, guest: 80, host: 8888
# Remove the default Vagrant directory sync
config.vm.synced_folder ".", "/vagrant", disabled: true
# Sync the 'vagrant' directory on the host to /gitlab on guest
# Use NFS on Linux/OS X and SMB on Windows
config.nfs.map_uid = Process.uid
config.nfs.map_gid = Process.gid
config.vm.synced_folder "vagrant", "/gitlab", create: true
config.vm.synced_folder "vagrant", "/vagrant-nfs", :create => true, :nfs => true
config.bindfs.bind_folder "/vagrant-nfs", "/gitlab", :owner => "vagrant", :group => "vagrant", :'create-as-user' => true, :perms => "u=rwx:g=rwx:o=rD", :'create-with-perms' => "u=rwx:g=rwx:o=rD", :'chown-ignore' => true, :'chgrp-ignore' => true, :'chmod-ignore' => true
config.vm.provider :virtualbox do |v|
# Use VBoxManage to customize the VM. For example to change memory:
v.customize ["modifyvm", :id, "--memory", MEMORY.to_i]
v.customize ["modifyvm", :id, "--cpus", CORES.to_i]
if CORES.to_i > 1
v.customize ["modifyvm", :id, "--ioapic", "on"]
config.vm.provider :vmware_fusion do |v, override|
override.vm.box_url = ""
v.vmx["memsize"] = MEMORY
v.vmx["numvcpus"] = CORES
config.vm.provider :parallels do |v, override|
v.customize ["set", :id, "--memsize", MEMORY, "--cpus", CORES]
# Install Chef with Vagrant Omnibus
# version is :latest or "11.4.4"
# Note:
# Using version "11.4.4" because that is the latest version
# AWS OpsWorks supports
config.omnibus.chef_version = "11.4.4"
# Enabling the Berkshelf plugin. To enable this globally, add this configuration
# option to your ~/.vagrant.d/Vagrantfile file
config.berkshelf.enabled = true
config.vm.provision :chef_solo do |chef|
chef.json = {
"gitlab" => {
"env" => "development",
"user" => "vagrant",
"group" => "vagrant",
"home" => "/home/vagrant",
"path" => "/gitlab/gitlab",
"satellites_path" => "/gitlab/gitlab-satellites",
"repos_path" => "/gitlab/repositories",
"shell_path" => "/gitlab/gitlab-shell",
"database_adapter" => "mysql"
"phantomjs" => {
"version" => "1.8.1"
chef.run_list = [
# Enable verbose console output
chef.arguments = '-l debug'
GitLab Development with Vagrant
Sets up a local development environment for GitLab using a Vagrant virtual machine.
After a successful installation, you will have a complete, self-contained virtual machine running GitLab. The database will also be seeded with sample content.
**IMPORTANT:** This virtual machine has been configured for ease of local development. Security of the resulting environment is deliberately lax. Do not use this method to prepare a production machine!
* [Ruby]( 2.0.0 or higher and [Rubygems](
* [Bundler](
* [Git](
* [VirtualBox]( 4.3.x
* [Vagrant]( 1.6.x
* NFS packages. Already installed if you are using Mac OS X, and not necessary if you are using Windows. On Linux:
sudo apt-get install nfs-kernel-server nfs-common portmap
* Administrative, sudo, or root privileges on your computer
* Some patience :smiley:
On OS X you can also choose to use the [Vagrant VMware provider]( instead of VirtualBox.
**Note:** Make sure to use Vagrant v1.6.x. Do not install via Instead, grab the latest version from
First, install all necessary dependencies listed above, then clone the cookbook repository:
git clone
cd cookbook-gitlab
And install all required gems and plugins:
vagrant plugin install vagrant-berkshelf --plugin-version 2.0.1
vagrant plugin install vagrant-omnibus
vagrant plugin install vagrant-bindfs
bundle install
Finally, you should be able to start and configure the Vagrant box. This operation can take a long time, up to an hour depending on your computer's performance and internet connection.
vagrant up
You will likely encounter errors during the initial set up provisioning process. It is important to keep rerunning `vagrant provision` until it does not report any errors and returns you to the command prompt. See the Troubleshooting section for help.
By default the VM uses 1.5GB of memory and 2 CPU cores. If you want to use more memory or cores you can use the GITLAB_VAGRANT_MEMORY and GITLAB_VAGRANT_CORES environment variables:
You can't run a vagrant project on an encrypted partition (ie. it won't work if your home directory is encrypted). You can still run the VM if you are using products like Apple FileVault 2 or Microsoft Bitlocker to encrypt your system drive.
You'll be asked for your administrative account password to set up NFS shares. If the NFS mount succeeds, the `cookbook-gitlab/vagrant` directory will be shared between your local computer and the Vagrant box. Any chnages made to files locally will be available to the GitLab server in the VM.
### Starting GitLab ###
Once the Vagrant box is up and running, you'll need to log in with
vagrant ssh
Then start GitLab with:
or with the full command:
cd /gitlab/gitlab; bundle exec foreman start
The first time GitLab is started, it may take up to five minutes to begin responding to web requests.
You can stop the service any time with the `Ctrl + C` key combination.
### Running tests ###
Once everything is done you can verify the installation by running tests. This may take a _very_ long time:
vagrant ssh
bundle exec rake gitlab:test
If `vagrant up` fails or reports any errors, try again with `vagrant provision`. Try this a couple of times. Installation errors often resolve themselves. You might also try disabling any virus protection software or third-party firewalls running on the host machine.
If you run into port conflicts between the guest and host, you can either:
1. Shut down any services on your computer currently listening on ports 3000 or 8888.
2. Disable Vagrant port forwarding using `GITLAB_VAGRANT_FORWARD=0 vagrant up`
If you are using a firewall on the host machine, it should allow NFS related traffic, otherwise you might encouter NFS mounting errors during vagrant up like:
mount.nfs: mount to NFS server '.../cookbook-gitlab/vagrant' failed: timed out, giving up
After starting the server, you may not be able to log in to the GitLab web interface or you might see ActiveRecord errors. If this happens, the database may not have been seeded properly. Try logging in to the VM and running the tasks manually:
vagrant ssh
cd /gitlab/gitlab
bundle exec rake db:schema:load db:migrate db:seed_fu
Accessing Gitlab
Once installed and started, you'll be able to access GitLab in a browser from your local machine. You can visit it at the following address:
* http://localhost:3000
If you started the VM with the `GITLAB_VAGRANT_FORWARD=0` option, you'll need to use the local IP address. Point your bowser to:
Sometimes, when making changes to application code, you will need to restart GitLab to see the results:
Ctrl + C
### Updating GitLab ###
GitLab is _not_ updated when you rebuild your virtual machine with the following command:
vagrant destroy && vagrant up
You must update it yourself by going to the `vagrant/gitlab` subdirectory in the repo and pulling the latest changes:
cd vagrant/gitlab && git pull
You can also simply delete the vagrant/gitlab, vagrant/gitlab-shell, vagrant/gitlab-satellites, and vagrant/repositories directories to grab a fresh copy of the project.
vagrant halt
rm -rf vagrant/gitlab vagrant/gitlab-shell vagrant/gitlab-satellites vagrant/repositories
vagrant destroy && vagrant up
Virtual Machine Management
When you are finished working in the Vagrant VM, logout with `exit` and suspend the virtual machine
vagrant suspend
then, resume to start developing again
vagrant resume
vagrant halt
to shutdown the virtual machine, and
vagrant up
to boot it again. If you want to run the provisioning scripts again, use the provision command.
vagrant up && vagrant provision
You can find out the state of a virtual machine anytime by invoking
vagrant status
Finally, to completely wipe the virtual machine from the disk **destroying all its contents**:
vagrant destroy # DANGER: deletes all virtual machine files
* Virtual Machine IP:
* GitLab web interface running at: http://localhost:3000/ or
* Virtual Machine user/password: vagrant/vagrant
* GitLab webapp user/password: root/5iveL!fe
* MySQL user/password: git/datapass
* MySQL root password: rootpass
# Cookbook Name:: gitlab
# Recipe:: vagrant
gitlab = node['gitlab']
# Add gitlab start command alias
template File.join(gitlab['home'], '.bash_aliases') do
source 'bash_aliases.erb'
user gitlab['user']
group gitlab['group']
:gitlab_path => gitlab['path'],
alias gitlab="cd <%= @gitlab_path %>; bundle exec foreman start"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment