Skip to content

Instantly share code, notes, and snippets.

@yarko
Created February 7, 2014 15:55
Show Gist options
  • Save yarko/8865534 to your computer and use it in GitHub Desktop.
Save yarko/8865534 to your computer and use it in GitHub Desktop.
W.I.P. edx configuration/vagrant/release/devstack Vagrantfile
MEMORY = 2048
CPU_COUNT = 2
$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/edx_ansible/playbooks
# 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 master
# handle case where build_version file was removed
export EXTRA_VARS=""
BUILD_FILE=/vagrant/build_version.yml
[ -r ${BUILD_FILE} -a -f ${BUILD_FILE} ] && EXTRA_VARS="--extra-vars \"@${BUILD_FILE}\""
# ansible-playbook -i localhost, -c local vagrant-devstack.yml --extra-vars "@/vagrant/build_version.yml"
echo "EXTRA_VARS: [${EXTRA_VARS}]"
ansible-playbook -i localhost, -c local vagrant-devstack.yml ${EXTRA_VARS}
SCRIPT
edx_platform_mount_dir = "edx-platform"
forum_mount_dir = "cs_comments_service"
ora_mount_dir = "ora"
if ENV['VAGRANT_MOUNT_BASE']
edx_platform_mount_dir = ENV['VAGRANT_MOUNT_BASE'] + "/" + edx_platform_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("2") do |config|
# Creates an edX devstack VM from an official release
config.vm.box = "focaccia-devstack"
config.vm.box_url = "http://files.edx.org/vagrant-images/20140130-focaccia-devstack.box"
config.vm.network :private_network, ip: "192.168.33.10"
config.vm.network :forwarded_port, guest: 8000, host: 8000
config.vm.network :forwarded_port, guest: 8001, host: 8001
config.vm.network :forwarded_port, guest: 4567, host: 4567
config.vm.synced_folder "#{edx_platform_mount_dir}", "/edx/app/edxapp/edx-platform", :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
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
# 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
@yarko
Copy link
Author

yarko commented Feb 7, 2014

This has a remaining problem: the sh provisioning part hard-declares a variable (configuration repo and version) which may reasonably be overriden by build_version.yml

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