Commit 3991711e by Yarko Tymciurak Committed by David Baumgold

Fixes for `vagrant up`

vagrant:
  - check actual IP;
  - only init machine first time, just as native installations;
  - add .bash_profile to permissions fixup;
  - cleanup excessive newlines in making .bash_profile;

README:
  - include admin & debugging use;
  - info about re-initializing VM & manually running create-dev-env.sh;
  - add django admin & debug_toolbar setting info

Conflicts:
	AUTHORS
	scripts/vagrant-provisioning.sh
parent 679b118e
...@@ -82,3 +82,5 @@ Adam Palay <adam@edx.org> ...@@ -82,3 +82,5 @@ Adam Palay <adam@edx.org>
Ian Hoover <ihoover@edx.org> Ian Hoover <ihoover@edx.org>
Mukul Goyal <miki@edx.org> Mukul Goyal <miki@edx.org>
Robert Marks <rmarks@edx.org> Robert Marks <rmarks@edx.org>
Yarko Tymciurak <yarkot1@gmail.com>
...@@ -12,30 +12,35 @@ installation process. ...@@ -12,30 +12,35 @@ installation process.
1. Make sure you have plenty of available disk space, >5GB 1. Make sure you have plenty of available disk space, >5GB
2. Install Git: http://git-scm.com/downloads 2. Install Git: http://git-scm.com/downloads
3. Install VirtualBox: https://www.virtualbox.org/wiki/Download_Old_Builds_4_2 3. Install VirtualBox: https://www.virtualbox.org/wiki/Downloads
(you need version 4.2.12, as later/earlier versions might not work well with See http://docs.vagrantup.com/v2/providers/index.html for a list of supported
Vagrant) Providers. You should use VirtualBox >= 4.2.12.
(Windows: later/earlier VirtualBox versions than 4.2.12 have been reported to not work well with
Vagrant. If this is still a problem, you can
install 4.2.12 from https://www.virtualbox.org/wiki/Download_Old_Builds_4_2).
4. Install Vagrant: http://www.vagrantup.com/ (Vagrant 1.2.2 or later) 4. Install Vagrant: http://www.vagrantup.com/ (Vagrant 1.2.2 or later)
5. Open a terminal 5. Open a terminal
6. Download the project: `git clone git://github.com/edx/edx-platform.git` 6. Download the project: `git clone git://github.com/edx/edx-platform.git`
7. Enter the project directory: `cd edx-platform/` 7. Enter the project directory: `cd edx-platform/`
8. (Windows only) Run the commands to 8. (Windows only) Run the commands to
[deal with line endings and symlinks under Windows](https://github.com/edx/edx-platform/wiki/Simplified-install-with-vagrant#dealing-with-line-endings-and-symlinks-under-windows) [deal with line endings and symlinks under Windows](https://github.com/edx/edx-platform/wiki/Simplified-install-with-vagrant#dealing-with-line-endings-and-symlinks-under-windows)
9. Start: `vagrant up` 9. Create the development environment and start it: `vagrant up`
The last step might require your host machine's administrator password to setup NFS. The initial `vagrant up` will download a Linux image, then boot and ask for your
host machine's administrator password to setup file sharing between your computer and the VM.
Once file sharing is established, `edx-platform/scripts/create-dev-env.sh` will
install dependencies and configure the VM.
This will take a while; go grab a coffee.
Afterwards, it will download an image, install all the dependencies and configure When complete, you should see a _"Success!"_ message.
the VM. It will take a while, go grab a coffee. If not, refer to the
[troubleshooting section](https://github.com/edx/edx-platform/wiki/Simplified-install-with-vagrant#troubleshooting).
Once completed, hopefully you should see a "Success!" message indicating that the Your development environment is initialized only on the first bring-up.
installation went fine. (If not, refer to the Subsequently `vagrant up` commands will boot your virtual machine normally.
[troubleshooting section](https://github.com/edx/edx-platform/wiki/Simplified-install-with-vagrant#troubleshooting).)
Note: by default, the VM will get the IP `192.168.20.40`. If you need to use a Note: by default, the VM will get the IP `192.168.20.40`.
different IP, you can edit the file `Vagrantfile`. If you have already started the You can change this in your `Vagrantfile` (the startup message will reflect your VM's actual IP).
VM with `vagrant up`, see "Stopping and restarting the VM" below to take the change
into account.
Accessing the VM Accessing the VM
---------------- ----------------
...@@ -46,15 +51,24 @@ Once the installation is finished, to log into the virtual machine: ...@@ -46,15 +51,24 @@ Once the installation is finished, to log into the virtual machine:
$ vagrant ssh $ vagrant ssh
``` ```
Note: This won't work from Windows, install install PuTTY from Note: This won't work from Windows. Instead, install PuTTY from
http://www.chiark.greenend.org.uk/%7Esgtatham/putty/download.html instead. Then http://www.chiark.greenend.org.uk/%7Esgtatham/putty/download.html. Then
connect to 127.0.0.1, port 2222, using vagrant/vagrant as a user/password. connect to 192.168.20.40, port 2222, using vagrant/vagrant as a user/password.
Using edX Using edX
--------- ---------
Once inside the VM, you can start Studio and LMS with the following commands When you login to your VM, you are in
(from the `/opt/edx/edx-platform` folder): `/opt/edx/edx-platform` by default, which is shared from your host workspace.
Your host computer contains the edx-project development code and repository.
Your VM runs edx-platform code mounted from your host, so
you can develop by editing on your host.
After logging into your VM with `vagrant ssh`,
start the _Studio_ and
_Learning management system (LMS)_
servers (run these from `/opt/edx/edx-platform`):
Learning management system (LMS): Learning management system (LMS):
...@@ -62,46 +76,85 @@ Learning management system (LMS): ...@@ -62,46 +76,85 @@ Learning management system (LMS):
$ rake lms[cms.dev,0.0.0.0:8000] $ rake lms[cms.dev,0.0.0.0:8000]
``` ```
Studio: Studio (CMS):
``` ```
$ rake cms[dev,0.0.0.0:8001] $ rake cms[dev,0.0.0.0:8001]
``` ```
Once started, open the following URLs in your browser: The servers will come up to these URLs:
* Learning management system (LMS): http://192.168.20.40:8000/ - LMS: http://192.168.20.40:8000/
* Studio (CMS): http://192.168.20.40:8001/ - CMS: http://192.168.20.40:8001/
You can develop by editing the files directly in the `edx-platform/` directory you Your VM's port 8000 is forwarded to host port 9000
downloaded before, you don't need to connect to the VM to edit them (the VM uses so you can also access the LMS with [http://localhost:9000/]().
those files to run edX, mirroring the folder in `/opt/edx/edx-platform`). Similarly, VM port 8001 is forwarded to host port 9001.
These are set in your `Vagrantfile`.
You may also want to create a super-user with: Note that when you register a new user through the web interface,
by default the activiation email will be appear on your VM's terminal.
``` Search for lines similar to:
$ rake django-admin["createsuperuser"]
```
Also note that if you register a new user through the web interface,
the activiation email will be posted to your VM's terminal window (search for
lines similar to):
``` ```
Subject: Your account for edX Studio Subject: Your account for edX Studio
From: registration@edx.org From: registration@edx.org
``` ```
and find the activation URL for the account you've created. and find the activation URL.
See the [Frequently Asked Questions](https://github.com/edx/edx-platform/wiki/Frequently-Asked-Questions) See the [Frequently Asked Questions](https://github.com/edx/edx-platform/wiki/Frequently-Asked-Questions)
for more usage tips. for more usage tips.
Django admin & debug toolbar
-----------------------------
You can enable admin logins and the debug_toolbar by editing
`lms/envs/common.py`:
- enable ADMIN login page by setting:
- ```
'ENABLE_DJANGO_ADMIN_SITE': True
```
- enable debug toolbar by uncommenting:
- ```
# 'debug_toolbar.middleware.DebugToolbarMiddleware',
```
These are also defined in `lms/envs/dev.py`,
and usually active on localhost.
To get at your VM's 127.0.0.1, explicitly forward one of VM's available localhost ports to your computer.
Instead of `vagrant ssh`, login with:
```
$ ssh -L 6080:127.0.0.1:8080 vagrant@192.168.20.40
```
The password is _vagrant_.
From your VM, start the LMS as a localhost instance:
```
$ rake lms[cms.dev,127.0.0.1:8080]
```
You should see the debug toolbar now on [http:/localhost:6080/]().
You should now also see a login on [http://localhost:6080/admin/]()
You will need a privileged user for the admin login.
You can create a CMS/LMS super-user with:
```
$ rake django-admin["createsuperuser"]
```
Stopping & starting Stopping & starting
------------------- -------------------
To stop the VM (from your `edx-platform/` directory):
To stop the VM (from your `edx-platform/` directory):
``` ```
$ vagrant halt $ vagrant halt
``` ```
...@@ -112,12 +165,23 @@ To restart: ...@@ -112,12 +165,23 @@ To restart:
$ vagrant up $ vagrant up
``` ```
or, to start without attempting to update the dependencies: To suspend and resume tasks in progress on your VM:
```
$ vagrant suspend
$ # and later...
$ vagrant resume
```
Your development environment is normally created once, on first `vagrant up`.
You can continue to fetch changes in edx-platform
as you work with your VM.
To re-create your VM and create a fresh development environment:
``` ```
$ vagrant up --no-provision $ vagrant destroy
$ vagrant up # will make a new VM
``` ```
Troubleshooting Troubleshooting
--------------- ---------------
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
# #
# Authors: Xavier Antoviaque <xavier@antoviaque.org> # Authors: Xavier Antoviaque <xavier@antoviaque.org>
# David Baumgold <david@davidbaumgold.com> # David Baumgold <david@davidbaumgold.com>
# Yarko Tymciurak <yarkot1@gmail.com>
# #
# This software's license gives you freedom; you can copy, convey, # This software's license gives you freedom; you can copy, convey,
# propagate, redistribute and/or modify this program under the terms of # propagate, redistribute and/or modify this program under the terms of
...@@ -30,102 +31,112 @@ ...@@ -30,102 +31,112 @@
# #
# This script is ran by `$ vagrant up`, see the README for more explanations # This script is ran by `$ vagrant up`, see the README for more explanations
on_create()
{
# APT - Packages ##############################################################
# APT - Packages ############################################################## apt-get update
apt-get install -y python-software-properties vim
apt-get update
apt-get install -y python-software-properties vim
# Curl - No progress bar ######################################################
# Curl - No progress bar ###################################################### [[ -f ~vagrant/.curlrc ]] || echo "silent show-error" > ~vagrant/.curlrc
chown vagrant.vagrant ~vagrant/.curlrc
[[ -f ~vagrant/.curlrc ]] || echo "silent show-error" > ~vagrant/.curlrc
chown vagrant.vagrant ~vagrant/.curlrc
# SSH - Known hosts ###########################################################
# SSH - Known hosts ########################################################### # Github
([[ -f ~vagrant/.ssh/known_hosts ]] && grep "zBX7bKA= ssh" ~vagrant/.ssh/known_hosts) || {
echo "|1|4DtBcMsTM4zgl/jTS7h3ZkmS/Vc=|XkRnn2xEhr8ixOxeskJAzBX7bKA= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==" >> ~vagrant/.ssh/known_hosts
}
([[ -f ~vagrant/.ssh/known_hosts ]] && grep "jO3J5bvw= ssh" ~vagrant/.ssh/known_hosts) || {
echo "|1|9rANf/qOAPgKH/TXpGuZCAgGxMs=|x9VYWEDI8kiotbhhNXqjO3J5bvw= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==" >> ~vagrant/.ssh/known_hosts
}
chown vagrant.vagrant ~vagrant/.ssh/known_hosts
# Github
([[ -f ~vagrant/.ssh/known_hosts ]] && grep "zBX7bKA= ssh" ~vagrant/.ssh/known_hosts) || {
echo "|1|4DtBcMsTM4zgl/jTS7h3ZkmS/Vc=|XkRnn2xEhr8ixOxeskJAzBX7bKA= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==" >> ~vagrant/.ssh/known_hosts
}
([[ -f ~vagrant/.ssh/known_hosts ]] && grep "jO3J5bvw= ssh" ~vagrant/.ssh/known_hosts) || {
echo "|1|9rANf/qOAPgKH/TXpGuZCAgGxMs=|x9VYWEDI8kiotbhhNXqjO3J5bvw= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==" >> ~vagrant/.ssh/known_hosts
}
chown vagrant.vagrant ~vagrant/.ssh/known_hosts
# edX - Development environment ###############################################
# edX - Development environment ############################################### # Node modules require a filesystem with symlinks (Windows support)
mkdir -p /opt/edx/node_modules /opt/edx/edx-platform/node_modules
([[ -f /etc/fstab ]] && grep '/opt/edx/node_modules' /etc/fstab) || {
echo '/opt/edx/node_modules /opt/edx/edx-platform/node_modules none bind,noauto 0 0' >> /etc/fstab
mount /opt/edx/node_modules
}
# Must be mounted *after* the NFS mount, made manually by Vagrant
([[ -f /etc/cron.d/nodemodules ]] && grep '/opt/edx/node_modules' /etc/cron.d/nodemodules) || {
echo '@reboot root until [ -n "`mount |grep "/opt/edx/edx-platform type"`" ]; do sleep 1; done; mount /opt/edx/node_modules' > /etc/cron.d/nodemodules
}
# Node modules require a filesystem with symlinks (Windows support) # Force rechecking all prerequisites (could have been fetched outside of the VM)
mkdir -p /opt/edx/node_modules /opt/edx/edx-platform/node_modules rm -rf /opt/edx/edx-platform/.prereqs_cache
([[ -f /etc/fstab ]] && grep '/opt/edx/node_modules' /etc/fstab) || {
echo '/opt/edx/node_modules /opt/edx/edx-platform/node_modules none bind,noauto 0 0' >> /etc/fstab
mount /opt/edx/node_modules
}
# Must be mounted *after* the NFS mount, made manually by Vagrant
([[ -f /etc/cron.d/nodemodules ]] && grep '/opt/edx/node_modules' /etc/cron.d/nodemodules) || {
echo '@reboot root until [ -n "`mount |grep "/opt/edx/edx-platform type"`" ]; do sleep 1; done; mount /opt/edx/node_modules' > /etc/cron.d/nodemodules
}
# Force rechecking all prerequisites (could have been fetched outside of the VM) # Permissions
rm -rf /opt/edx/edx-platform/.prereqs_cache chown vagrant.vagrant /opt/edx /opt/edx/node_modules /opt/edx/edx-platform/node_modules
# Permissions # For convenience with `vagrant ssh`, the `edx-platform` virtualenv is always
chown vagrant.vagrant /opt/edx /opt/edx/node_modules /opt/edx/edx-platform/node_modules # loaded after the first run, so we need to deactivate that behavior to run
# `create-dev-env.sh`.
[[ -f ~vagrant/.bash_profile ]] && {
mv ~vagrant/.bash_profile ~vagrant/.bash_profile.bak
}
sudo -u vagrant -i bash -c "cd /opt/edx/edx-platform && PROJECT_HOME=/opt/edx ./scripts/create-dev-env.sh -ynq"
# For convenience with `vagrant ssh`, the `edx-platform` virtualenv is always # Load .bashrc ################################################################
# loaded after the first run, so we need to deactivate that behavior to run ([[ -f ~vagrant/.bash_profile ]] && grep ".bashrc" ~vagrant/.bash_profile) || {
# `create-dev-env.sh`. echo ". /home/vagrant/.bashrc" >> ~vagrant/.bash_profile
[[ -f ~vagrant/.bash_profile ]] && { }
mv ~vagrant/.bash_profile ~vagrant/.bash_profile.bak
}
sudo -u vagrant -i bash -c "cd /opt/edx/edx-platform && PROJECT_HOME=/opt/edx ./scripts/create-dev-env.sh -ynq"
# Load .bashrc ################################################################
([[ -f ~vagrant/.bash_profile ]] && grep ".bashrc" ~vagrant/.bash_profile) || {
echo -e "\n. /home/vagrant/.bashrc\n" >> ~vagrant/.bash_profile
}
# Virtualenv - Always load ####################################################
# Virtualenv - Always load #################################################### ([[ -f ~vagrant/.bash_profile ]] && grep "edx-platform/bin/activate" ~vagrant/.bash_profile) || {
echo ". /home/vagrant/.virtualenvs/edx-platform/bin/activate" >> ~vagrant/.bash_profile
}
([[ -f ~vagrant/.bash_profile ]] && grep "edx-platform/bin/activate" ~vagrant/.bash_profile) || {
echo -e "\n. /home/vagrant/.virtualenvs/edx-platform/bin/activate\n" >> ~vagrant/.bash_profile
}
# Directory ###################################################################
# Directory ################################################################### grep "cd /opt/edx/edx-platform" ~vagrant/.bash_profile || {
echo "cd /opt/edx/edx-platform" >> ~vagrant/.bash_profile
}
grep "cd /opt/edx/edx-platform" ~vagrant/.bash_profile || { # Permissions
echo -e "\ncd /opt/edx/edx-platform\n" >> ~vagrant/.bash_profile chown vagrant.vagrant ~vagrant/.bash_profile
}
cat << EOF
# End #########################################################################
cat << EOF
============================================================================== ==============================================================================
Success! Success - Created your development environment!
============================================================================== ==============================================================================
Now, from the virtual machine (connect with "vagrant ssh" if vagrant didn't EOF
log you in already), you can start Studio & LMS with the following commands: } # End on_create() ########################################################
- Learning management system (LMS):
$ rake lms[cms.dev,0.0.0.0:8000]
=> http://192.168.20.40:8000/ ## only initialize / setup the development environment once:
# we create node_modules, so that's a good test:
[[ -d /opt/edx/node_modules ]] || on_create
- Studio: # grab what the Vagrantfile spec'd our IP to be:
$ rake cms[dev,0.0.0.0:8001] # expecting:
# - relevant ip on eth1;
# - line of interest to look like:
# inet 192.168.20.40/24 brd 192.168.20.255 scope global eth1
MY_IP=$(ip addr show dev eth1 | sed -n '/inet /{s/.*[ ]\(.*\)\/.*/\1/;p}')
=> http://192.168.20.40:8001/ cat << EOF
Connect to your virtual machine with "vagrant ssh".
Some examples you can use from your virtual machine:
- Start Learning management system (LMS):
$ rake lms[cms.dev,0.0.0.0:8000]
=> http://${MY_IP}:8000/
See the README for details. - Start Studio:
$ rake cms[dev,0.0.0.0:8001]
=> http://${MY_IP}:8001/
See the README for more.
EOF EOF
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