Code Monkey home page Code Monkey logo

django-vagrant's Introduction

Django-Vagrant

Django-Vagrant aims to be a quick way to get up and running with a new Django project in a Virtualbox built with Vagrant and Salt. Out of the box, it provides a pre-configured Nginx installation setup to proxy requests to Django via Gunicorn and includes a pre-configured Postgresql installation as well. Supervisor is used to monitor Gunicorn.

The packages should be easily extensible to include extra software by adding new Salt states as required and doing a vagrant reload or adding Python based dependencies to one of the targetted requirements files. By default, 'requirements/vagrant.txt' contains all of the Python dependencies (such as Django) in use on the Vagrant box. There are also requirements files that target production and local environments exclusively, as well as a common requirements file for any requirement that should always be met.

For ease of use, all Python dependencies are installed to a virtualenv, managed by virtualenvwrapper, with the same name as your project.

Finally, the Vagrant configured VM is setup with Werkzeug(http://werkzeug.pocoo.org/) to make debugging easier.

Getting Started

Assuming a pre-existing django-admin.py on your path, execute a variant of the following to build your new project:

django-admin.py startproject --template=https://github.com/notanumber/django-vagrant/archive/master.zip <my_project> --name=Vagrantfile --extension=py --extension=sls

This should result in a source tree like:

project_name
          |
          +--docs
          +-- log
          +-- project_name
          | |
          | +-- assets
          | | |
          | | +-- css
          | | +-- img
          | | +-- js
          | |
          | +-- media
          | +-- project_name
          | | |
          | | +-- settings
          | | | |
          | | | +- __init__.py
          | | | +- base.py
          | | | +- local.py
          | | | +- production.py
          | | | +- vagrant.py
          | | |
          | | +-- __init__.py
          | | +-- urls.py
          | | +-- wsgi.py
          | |
          | +-- templates
          | +-- __init__.py
          |
          +-- requirements
          | |
          | +-- common.txt
          | +-- local.txt
          | +-- production.txt
          | +-- vagrant.txt
          |
          +-- salt
          | |
          | +-- pillar
          | | |
          | | +-- db.sls
          | | +-- project.sls
          | | +-- top.sls
          | |
          |  -- salt
          | | |
          | | +-- db
          | | | |
          | | | +-- init.sls  
          | | |
          | | +-- project
          | | | |
          | | | +-- .profile  
          | | | +-- _virtualenv_path_extensions.pth
          | | | +-- gunicorn.conf
          | | | +-- init.sls
          | | | +-- vhost.conf  
          | | |
          | | +-- www
          | | | |
          | | | +-- init.sls  
          | |
          | +-- minion.conf
          |
          +-- README
          +-- requirements.txt
          +-- Vagrantfile

Once you have the project layout in place, simply issue the vagrant up command to have Vagrant provision your server. This should take a few minutes, but once it's done, you can access your new server at 'localhost' in your browser! Alternatively, you can uncomment the config.vm.network :private_network, ip: "10.0.0.10" line in Vagrantfile to setup a private network. Once you've done this, you can add a line to your /etc/hosts (or your OS equivalent) to map your choice of domain name to the private network. eg., dev.myproject.com where www.myproject.com is your live site.

Requirements

Django-Vagrant has the following requirements. Versions used in testing are noted alongside.

  • Virtualbox 4.2.12 - https://www.virtualbox.org/<https://www.virtualbox.org/>
  • Vagrant 1.2.0 - http://www.vagrantup.com/<http://www.vagrantup.com/>
  • Vagrant-salt 0.4.0 - https://github.com/saltstack/salty-vagrant<https://github.com/saltstack/salty-vagrant>

Any other requirements should be installed automatically by Salt during the provisioning of the Virtualbox.

django-vagrant's People

Contributors

notanumber avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-vagrant's Issues

Permissions Issues (Errno 13)

I setup a vagrant using your commands listed and then used vagrant ssh to get in and workon <project_name>. After that I had to sudo django-admin.py startapp testapp to get startapp to work.

When using stuff like south, django-admin.py schemamigration appname errors out due to permissions. sudo django-admin.py schemamigration appname returns schemamigration command not found.

Just curious how to get around this or how you work with it?

No manage.py and out of date requirements

I found your django-vagrant template and noticed that the requirements are all several versions behind, as well as a lack of a manage.py file and improperly configured database settings (couldn't the local settings be filled out automatically since we define those in the salt files?) I'm working on an update to send as a pull request but I want to get your ideas.

undefined method 'salt_install_type=' for #<VagrantPlugins::Salt::Config:0x000001008cc138> (NoMethodError)

I get this error when I try to bring up the Vagrant VM:

Vagrantfile:15:in `block (2 levels) in <top (required)>': undefined method `salt_install_type=' for #<VagrantPlugins::Salt::Config:0x000001008cc138> (NoMethodError)
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.1.5/plugins/kernel_v2/config/vm_provisioner.rb:42:in `call'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.1.5/plugins/kernel_v2/config/vm_provisioner.rb:42:in `initialize'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.1.5/plugins/kernel_v2/config/vm.rb:154:in `new'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.1.5/plugins/kernel_v2/config/vm.rb:154:in `provision'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.1.5/plugins/kernel_v1/config/vm.rb:146:in `block in upgrade'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.1.5/plugins/kernel_v1/config/vm.rb:145:in `each'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.1.5/plugins/kernel_v1/config/vm.rb:145:in `upgrade'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.1.5/lib/vagrant/config/v2/loader.rb:112:in `block in upgrade'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.1.5/lib/vagrant/config/v2/loader.rb:110:in `each'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.1.5/lib/vagrant/config/v2/loader.rb:110:in `upgrade'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.1.5/lib/vagrant/config/loader.rb:124:in `block (3 levels) in load'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.1.5/lib/vagrant/config/loader.rb:118:in `upto'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.1.5/lib/vagrant/config/loader.rb:118:in `block (2 levels) in load'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.1.5/lib/vagrant/config/loader.rb:98:in `each'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.1.5/lib/vagrant/config/loader.rb:98:in `block in load'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.1.5/lib/vagrant/config/loader.rb:95:in `each'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.1.5/lib/vagrant/config/loader.rb:95:in `load'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.1.5/lib/vagrant/environment.rb:238:in `config_global'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.1.5/lib/vagrant/environment.rb:443:in `block in action_runner'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.1.5/lib/vagrant/action/runner.rb:28:in `call'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.1.5/lib/vagrant/action/runner.rb:28:in `run'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.1.5/lib/vagrant/environment.rb:251:in `hook'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.1.5/lib/vagrant/environment.rb:131:in `initialize'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.1.5/bin/vagrant:53:in `new'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.1.5/bin/vagrant:53:in `<top (required)>'
    from /Applications/Vagrant/bin/../embedded/gems/bin/vagrant:23:in `load'
    from /Applications/Vagrant/bin/../embedded/gems/bin/vagrant:23:in `<main>'

Any idea how I might get around this?

Problems with pip

Hi,
thank you a lot for this greate django vagrant template. I have actually the following problem. When i try to work with this configuration and i'm behind a proxy the VM isn't created successfully. The first step has been to configure my proxy. For this case i have used vagrant-proxyconf and apt-get works. Pip didn't :-( Pip ignore the configuration and cannot connect and for all packages i get the error:
Cannot fetch index base URL https://pypi.python.org/simple/.
Any idea what i could do to set a availabe index_url for pip or how to force pip to use the correct proxy?

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.