Vagrantfile 5.51 KB
Newer Older
1
Vagrant.require_version ">= 1.6.5"
Gabe Mulley committed
2 3 4 5 6 7 8 9 10
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 = 4096
CPU_COUNT = 2

11 12 13 14 15
$script = <<SCRIPT
if [ ! -d /edx/app/edx_ansible ]; then
    echo "Error: Base box is missing provisioning scripts." 1>&2
    exit 1
fi
16
OPENEDX_RELEASE=$1
17 18 19 20
export PYTHONUNBUFFERED=1
source /edx/app/edx_ansible/venvs/edx_ansible/bin/activate
cd /edx/app/edx_ansible/edx_ansible/playbooks

21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
# Did we specify an openedx release?
if [ -n "$OPENEDX_RELEASE" ]; then
  EXTRA_VARS="-e edx_platform_version=$OPENEDX_RELEASE \
    -e certs_version=$OPENEDX_RELEASE \
    -e forum_version=$OPENEDX_RELEASE \
    -e xqueue_version=$OPENEDX_RELEASE \
  "
  CONFIG_VER=$OPENEDX_RELEASE
  # Need to ensure that the configuration repo is updated
  # The vagrant-analyticstack.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 $CONFIG_VER
else
  CONFIG_VER="master"
fi

ansible-playbook -i localhost, -c local run_role.yml -e role=edx_ansible -e configuration_version=$CONFIG_VER $EXTRA_VARS
ansible-playbook -i localhost, -c local vagrant-analytics.yml -e configuration_version=$CONFIG_VER $EXTRA_VARS -e ELASTICSEARCH_CLUSTER_MEMBERS=[]
40 41 42

SCRIPT

43 44 45 46 47 48 49 50 51 52 53
MOUNT_DIRS = {
  :edx_platform => {:repo => "edx-platform", :local => "/edx/app/edxapp/edx-platform", :owner => "edxapp"},
  :themes => {:repo => "themes", :local => "/edx/app/edxapp/themes", :owner => "edxapp"},
  :forum => {:repo => "cs_comments_service", :local => "/edx/app/forum/cs_comments_service", :owner => "forum"},
  :insights => {:repo => "insights", :local => "/edx/app/insights/edx_analytics_dashboard", :owner => "insights"},
  :analytics_api => {:repo => "analytics_api", :local => "/edx/app/analytics_api/analytics_api", :owner => "analytics_api"},
  # This src directory won't have useful permissions. You can set them from the
  # vagrant user in the guest OS. "sudo chmod 0777 /edx/src" is useful.
  :src => {:repo => "src", :local => "/edx/src", :owner => "root"},

}
Gabe Mulley committed
54
if ENV['VAGRANT_MOUNT_BASE']
55
  MOUNT_DIRS.each { |k, v| MOUNT_DIRS[k][:repo] = ENV['VAGRANT_MOUNT_BASE'] + "/" + MOUNT_DIRS[k][:repo] }
Gabe Mulley committed
56 57
end

58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
# map the name of the git branch that we use for a release
# to a name and a file path, which are used for retrieving
# a Vagrant box from the internet.
openedx_releases = {
  "named-release/dogwood.rc" => {
    :name => "analyticstack", :file => "analyticstack.box",
  },
  "named-release/dogwood" => {
    :name => "analyticstack", :file => "analyticstack.box",
  },
}
openedx_releases.default = {
  :name => "analyticstack", :file => "analyticstack.box",
}
rel = ENV['OPENEDX_RELEASE']

Gabe Mulley committed
74 75
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

76 77 78
  # Creates an edX analyticstack VM from an official release
  config.vm.box     = openedx_releases[rel][:name]
  config.vm.box_url = "http://files.edx.org/vagrant-images/#{openedx_releases[rel][:file]}"
Gabe Mulley committed
79 80

  config.vm.network :private_network, ip: "192.168.33.10"
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98

  # If you want to run the box but don't need network ports, set VAGRANT_NO_PORTS=1.
  # This is useful if you want to run more than one box at once.
  if not ENV['VAGRANT_NO_PORTS']
    config.vm.network :forwarded_port, guest: 8000, host: 8000  # LMS
    config.vm.network :forwarded_port, guest: 8001, host: 8001  # Studio
    config.vm.network :forwarded_port, guest: 8003, host: 8003  # LMS for Bok Choy
    config.vm.network :forwarded_port, guest: 8031, host: 8031  # Studio for Bok Choy
    config.vm.network :forwarded_port, guest: 8120, host: 8120  # edX Notes Service
    config.vm.network :forwarded_port, guest: 8765, host: 8765
    config.vm.network :forwarded_port, guest: 9200, host: 9200  # Elasticsearch
    config.vm.network :forwarded_port, guest: 18080, host: 18080  # Forums
    config.vm.network :forwarded_port, guest: 8100, host: 8100  # Analytics Data API
    config.vm.network :forwarded_port, guest: 8110, host: 8110  # Insights
    config.vm.network :forwarded_port, guest: 9876, host: 9876  # ORA2 Karma tests
    config.vm.network :forwarded_port, guest: 50070, host: 50070  # HDFS Admin UI
    config.vm.network :forwarded_port, guest: 8088, host: 8088  # Hadoop Resource Manager
  end
Gabe Mulley committed
99 100 101 102 103 104 105 106 107 108
  config.ssh.insert_key = true

  config.vm.synced_folder  ".", "/vagrant", disabled: 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'
109 110 111
    MOUNT_DIRS.each { |k, v|
      config.vm.synced_folder v[:repo], v[:local], create: true, owner: v[:owner], group: "www-data"
    }
Gabe Mulley committed
112
  else
113 114 115
    MOUNT_DIRS.each { |k, v|
      config.vm.synced_folder v[:repo], v[:local], create: true, nfs: true
    }
Gabe Mulley committed
116 117 118 119 120 121 122 123 124 125 126 127 128 129
  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

  # Use vagrant-vbguest plugin to make sure Guest Additions are in sync
  config.vbguest.auto_reboot = true
  config.vbguest.auto_update = true
130 131 132

  # Assume that the base box has the edx_ansible role installed
  # We can then tell the Vagrant instance to update itself.
133
  config.vm.provision "shell", inline: $script, args: rel
Gabe Mulley committed
134
end