Skip to content

Instantly share code, notes, and snippets.

@tgs
Last active August 29, 2015 14:04
Show Gist options
  • Save tgs/d8f9e66a8426dcfea039 to your computer and use it in GitHub Desktop.
Save tgs/d8f9e66a8426dcfea039 to your computer and use it in GitHub Desktop.
Vagrantfile for developing edx/configuration
Vagrant.require_version ">= 1.5.3"
unless Vagrant.has_plugin?("vagrant-vbguest")
raise "Please install the vagrant-vbguest plugin by running `vagrant plugin install vagrant-vbguest`"
end
VAGRANTFILE_API_VERSION = "2"
MEMORY = 2048
CPU_COUNT = 3
$script = <<SCRIPT
if [ ! -d /edx/app/edx_ansible ]; then
echo "Error: Base box is missing provisioning scripts." 1>&2
exit 1
fi
export PYTHONUNBUFFERED=1
source /edx/app/edx_ansible/venvs/edx_ansible/bin/activate
cd /edx/app/edx_ansible/
rm -rf edx_ansible
git clone /vagrant/configuration edx_ansible
cd /edx/app/edx_ansible/edx_ansible/playbooks
sudo mkdir -p /edx/app/edxapp/{edx-platform,themes}
sudo mkdir -p /edx/app/{forum,ora}
sudo chown -R edxapp.www-data /edx/app/edxapp/{edx-platform,themes}
sudo chown -R forum.www-data /edx/app/forum
sudo chown -R ora.www-data /edx/app/ora
# Need to ensure that the configuration repo is updated
# The vagrant-devstack.yml playbook will also do this, but only
# after loading the playbooks into memory. If these are out of date,
# this can cause problems (e.g. looking for templates that no longer exist).
/edx/bin/update configuration release
ansible-playbook -i localhost, -c local vagrant-devstack.yml --tags=deploy \
-e configuration_version=badges \
-e edx_ansible_source_repo=/vagrant/configuration \
-e edx_platform_version=badges \
-e edx_platform_repo=/vagrant/edx-platform \
-v -v
SCRIPT
edx_platform_mount_dir = "edx-platform"
themes_mount_dir = "themes"
forum_mount_dir = "cs_comments_service"
ora_mount_dir = "ora"
ENV['VAGRANT_MOUNT_BASE'] = "in-vm"
if ENV['VAGRANT_MOUNT_BASE']
edx_platform_mount_dir = ENV['VAGRANT_MOUNT_BASE'] + "/" + edx_platform_mount_dir
themes_mount_dir = ENV['VAGRANT_MOUNT_BASE'] + "/" + themes_mount_dir
forum_mount_dir = ENV['VAGRANT_MOUNT_BASE'] + "/" + forum_mount_dir
ora_mount_dir = ENV['VAGRANT_MOUNT_BASE'] + "/" + ora_mount_dir
end
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Creates an edX devstack VM from an official release
config.vm.box = "johnnycake-devstack"
config.vm.box_url = "http://files.edx.org/vagrant-images/20140625-johnnycake-devstack.box"
config.vm.network :private_network, ip: "192.168.33.10"
config.vm.network :forwarded_port, guest: 8000, host: 8000, host_ip:"127.0.0.1"
config.vm.network :forwarded_port, guest: 8001, host: 8001, host_ip:"127.0.0.1"
config.vm.network :forwarded_port, guest: 18080, host: 18080, host_ip:"127.0.0.1"
config.vm.network :forwarded_port, guest: 8765, host: 8765, host_ip:"127.0.0.1"
config.vm.network :forwarded_port, guest: 9200, host: 9200, host_ip:"127.0.0.1"
config.ssh.insert_key = true
config.vm.synced_folder ".", "/vagrant", create: true
# Enable X11 forwarding so we can interact with GUI applications
if ENV['VAGRANT_X11']
config.ssh.forward_x11 = true
end
#if ENV['VAGRANT_USE_VBOXFS'] == 'true'
#config.vm.synced_folder "#{edx_platform_mount_dir}", "/edx/app/edxapp/edx-platform",
#create: true, owner: "edxapp", group: "www-data"
#config.vm.synced_folder "#{themes_mount_dir}", "/edx/app/edxapp/themes",
#create: true, owner: "edxapp", group: "www-data"
#config.vm.synced_folder "#{forum_mount_dir}", "/edx/app/forum/cs_comments_service",
#create: true, owner: "forum", group: "www-data"
#config.vm.synced_folder "#{ora_mount_dir}", "/edx/app/ora/ora",
#create: true, owner: "ora", group: "www-data"
#else
#config.vm.synced_folder "#{edx_platform_mount_dir}", "/edx/app/edxapp/edx-platform",
#create: true, nfs: true
#config.vm.synced_folder "#{themes_mount_dir}", "/edx/app/edxapp/themes",
#create: true, nfs: true
#config.vm.synced_folder "#{forum_mount_dir}", "/edx/app/forum/cs_comments_service",
#create: true, nfs: true
#config.vm.synced_folder "#{ora_mount_dir}", "/edx/app/ora/ora",
#create: true, nfs: true
#end
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", MEMORY.to_s]
vb.customize ["modifyvm", :id, "--cpus", CPU_COUNT.to_s]
# Allow DNS to work for Ubuntu 12.10 host
# http://askubuntu.com/questions/238040/how-do-i-fix-name-service-for-vagrant-client
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
end
["vmware_fusion", "vmware_workstation"].each do |vmware_provider|
config.vm.provider vmware_provider do |v, override|
override.vm.box = "johnnycake-devstack-vmware"
override.vm.box_url = "http://files.edx.org/vagrant-images/20140630-johnnycake-devstack-vmware.box"
v.vmx["memsize"] = MEMORY.to_s
v.vmx["numvcpus"] = CPU_COUNT.to_s
end
end
# Use vagrant-vbguest plugin to make sure Guest Additions are in sync
config.vbguest.auto_reboot = true
config.vbguest.auto_update = true
# Assume that the base box has the edx_ansible role installed
# We can then tell the Vagrant instance to update itself.
config.vm.provision "shell", inline: $script
end
@tgs
Copy link
Author

tgs commented Jul 22, 2014

To use it, first clone edx/configuration and edx/edx-platform into the same directory as this Vagrantfile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment